-
Notifications
You must be signed in to change notification settings - Fork 0
/
nwm.h
227 lines (191 loc) · 6.53 KB
/
nwm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#pragma once
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif // XINERAMA
#include <errno.h>
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
/* --------------------------------- macros --------------------------------- */
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
#define ISVISIBLE(C) \
((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
#define TAGMASK ((1 << TAGS_N) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define MWM_HINTS_FLAGS_FIELD 0
#define MWM_HINTS_DECORATIONS_FIELD 2
#define MWM_HINTS_DECORATIONS (1 << 1)
#define MWM_DECOR_ALL (1 << 0)
#define MWM_DECOR_BORDER (1 << 1)
#define MWM_DECOR_TITLE (1 << 3)
#define SYSTEM_TRAY_REQUEST_DOCK 0
/* ----------------------------- XEMBED messages ---------------------------- */
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
#define XEMBED_FOCUS_IN 4
#define XEMBED_MODALITY_ON 10
#define XEMBED_MAPPED (1 << 0)
#define XEMBED_WINDOW_ACTIVATE 1
#define XEMBED_WINDOW_DEACTIVATE 2
#define VERSION_MAJOR 0
#define VERSION_MINOR 0
#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
/* ---------------------------------- enums --------------------------------- */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeDark, SchemeInv, SchemeSel }; /* color schemes */
enum {
NetSupported,
NetWMName,
NetWMState,
NetWMCheck,
NetSystemTray,
NetSystemTrayOP,
NetSystemTrayOrientation,
NetSystemTrayOrientationHorz,
NetWMFullscreen,
NetActiveWindow,
NetWMWindowType,
NetWMWindowTypeDialog,
NetClientList,
NetWMWindowTypeDesktop,
NetLast,
}; /* EWMH atoms */
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
enum {
WMProtocols,
WMDelete,
WMState,
WMTakeFocus,
WMLast
}; /* default atoms */
enum {
ClkTagBar,
ClkTabBar,
ClkLtSymbol,
ClkStatusText,
ClkWinTitle,
ClkClientWin,
ClkRootWin,
ClkLast
}; /* clicks */
/* ---------------------------------- types --------------------------------- */
// action arguments
typedef union {
int i; // int
unsigned ui; // unsigned int
float f; // float
const void* v; // void
} Arg;
// button
typedef struct {
unsigned click;
unsigned mask;
unsigned button;
void (*func)(const Arg* arg);
const Arg arg;
} Button;
typedef struct Monitor Monitor;
typedef struct Client Client;
struct Client {
char name[256]; // client's name
float mina, maxa; // aspect ratio
int x, y, oldx, oldy; // client coordinates
unsigned w, h, oldw, oldh; // client dimension
unsigned basew, baseh, incw, inch; // base/incremental dimension
unsigned maxw, maxh, minw, minh; // dimension limit
unsigned bw, oldbw; // border width
unsigned tags; // assigned tags
Bool isfixed, isfloating, isurgent; // client state
Bool neverfocus, oldstate, isfullscreen; // client state
Bool issticky; // client state
Bool nocenter, nosnap; // client config
Client* next; // next client link
Client* snext; // next stack
Monitor* mon; // assigned monitor
Window win; // client's window
};
typedef struct {
unsigned mod;
KeySym keysym;
void (*func)(const Arg*);
const Arg arg;
} Key;
typedef struct {
const char* symbol;
void (*arrange)(Monitor*);
} Layout;
#define MAXTABS 50
typedef struct Pertag Pertag; // Pertag
struct Monitor {
char ltsymbol[16]; // symbolic representation of layout
float mfact; // ratio factor of layout
int nmaster; // number of masters
int num; // number (id)
int bary; // bar geometry
int taby; // tab bar geometry
int mx, my; // screen coordinates
unsigned mw, mh; // screen dimensions
int wx, wy; // window coordinates
unsigned ww, wh; // window dimensions
unsigned seltags; // selected tags
unsigned sellt; // selected layout
unsigned tagset[2]; // set of tags for the monitor
Bool showbar; // false means no bar
Bool showtab; // false means no tab bar
Bool topbar; // false means bottom bar
Bool toptab; // false means bottom tab bar
Client* clients; // clients on this monitor
Client* sel; // selected client
Client* stack; // current stack of clients
Monitor* next; // pointer to next monitor
Window barwin; // window of the native bar
Window tabwin; // window of the tab bar
unsigned ntabs; // number of tab bars
unsigned tab_widths[MAXTABS]; // width of tab bars
const Layout* lt[2]; // layouts
Pertag* pertag; // separated parameters (e.g. layout) per tag
};
typedef struct {
const char* class;
const char* instance;
const char* title;
unsigned tags;
int isfloating;
int nosnap;
int nocenter;
int monitor;
} Rule;
typedef struct {
unsigned tag; // index of tag in array
unsigned layout; // index of layout in array
float mfact; // ratio, -1 for default
} PertagRule;
typedef struct Systray Systray;
struct Systray {
Window win;
Client* icons;
};
// TODO: get rid of pertag scum, write your own that works better
#define TAGS_N 10
struct Pertag {
unsigned curtag, prevtag; // current and previous tag
int nmasters[TAGS_N + 1]; // number of windows in master area
float mfacts[TAGS_N + 1]; // mfacts per tag
unsigned sellts[TAGS_N + 1]; // selected layouts
const Layout* ltidxs[TAGS_N + 1][2]; // matrix of tags and layouts indexes
Bool showbars[TAGS_N + 1]; // display bar for the current tag
};
// compile-time check if all tags fit into an unsigned int bit array.
struct NumTags {
char limitexceeded[TAGS_N > 31 ? -1 : 1];
};