-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmxswm.h
285 lines (242 loc) · 7 KB
/
mxswm.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*
* ISC License
*
* Copyright (c) 2021, Tommi Leino <namhas@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MXSWM_H
#define MXSWM_H
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#ifdef TRACE
#include <stdio.h>
#include <time.h>
const char *str_event(XEvent *);
const char *current_event(void);
Window current_window(void);
time_t start_time();
#define TRACE_LOG(...) \
do { \
fprintf(stderr, "%d %-16s 0x%08lx %-16s %-16s ", \
(int) (time(0) - start_time()), \
current_event(), current_window(), \
event_client() ? event_client()->name : \
"", __FUNCTION__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while(0)
#define TRACE_SET_CLIENT(client) set_event_client(client)
#define EVENT_STR(event) str_event(event)
#else
#define TRACE_LOG(...) ((void) 0)
#define EVENT_STR(...) ((void) 0)
#define TRACE_SET_CLIENT(...) ((void) 0)
#endif
#ifndef ARRLEN
#define ARRLEN(_x) sizeof((_x)) / sizeof((_x)[0])
#endif
#ifndef MIN
#define MIN(_x, _y) ((_x) < (_y) ? (_x) : (_y))
#endif
#ifndef MAX
#define MAX(_x, _y) ((_x) > (_y) ? (_x) : (_y))
#endif
enum ewmh {
WM_PROTOCOLS=0,
_NET_WM_NAME,
_NET_WM_VISIBLE_NAME,
UTF8_STRING,
NUM_WMH
};
extern Atom wmh[NUM_WMH];
void init_wmh(void);
#include "fontnames.h"
#include "colornames.h"
/*
* These are sane defaults for a 2560x1440 screen.
* Modify freely locally.
*/
#define BORDERWIDTH 28
/*
* For 80-column terminals.
*/
#if WANT_MAXWIDTH
#define FONTWIDTH 14
#define MAXWIDTH (FONTWIDTH * 80)
#endif
struct client;
struct stack {
unsigned short width;
unsigned short height;
unsigned short x;
unsigned short y;
unsigned short num;
struct stack *next;
struct stack *prev;
Window window;
int maxwidth_override;
int prefer_width;
int hidden;
int sticky;
int mapped;
int monitor;
};
struct client {
Window window;
char *name;
char *renamed_name;
int mapped;
#define CF_HAS_TAKEFOCUS (1 << 0)
#define CF_HAS_DELWIN (1 << 1)
#define CF_FOCUS_WHEN_MAPPED (1 << 2)
int flags;
struct stack *stack;
struct stack *reappear;
struct client *next;
struct client *prev;
};
#define STACK_WIDTH(_x) (_x)->width
#define STACK_HEIGHT(_x) (_x)->height
#define STACK_X(_x) (_x)->x
#define STACK_Y(_x) (_x)->y
#define CLIENT_STACK(_x) (_x)->stack
#define CLIENT_REAPPEAR_STACK(_x) (_x)->reappear
int get_utf8_property(Window, Atom, char **);
struct stack *add_stack(struct stack *);
struct stack *add_stack_to_monitor(struct stack *, int);
struct stack *have_stack(Window);
struct stack *last_stack(void);
void remove_stack(struct stack *);
void draw_stack(struct stack *);
void add_stack_here(void);
void remove_stack_here(void);
void resize_stacks(void);
void adjust_stacks_height(int);
void focus_stack(struct stack *);
void focus_stack_forward(void);
void focus_stack_backward(void);
struct stack *current_stack(void);
void resize_stack(struct stack *, unsigned short);
struct stack *find_stack(int);
struct stack *find_stack_xy(unsigned short, unsigned short);
void resize_client(struct client *);
void resize_clients(struct stack *);
size_t count_clients(struct stack *);
void toggle_stacks_maxwidth_override(void);
void toggle_hide_other_stacks(void);
void toggle_sticky_stack(void);
void highlight_stacks(int);
void draw_stacks(void);
void move_stack(int);
void move_stack_left(void);
void move_stack_right(void);
void read_protocols(struct client *);
void send_delete_window(struct client *);
void send_take_focus(struct client *);
#if TRACE
void dump_stack(struct stack *);
void dump_stacks(void);
#else
#define dump_stacks(x) do { } while(0)
#define dump_stack(x) do { } while(0)
#endif
struct client *add_client(Window, struct client *, int, struct stack *, int);
struct client *have_client(Window);
void remove_client(struct client *);
void top_client(struct client *);
void focus_client(struct client *, struct stack *);
void focus_client_forward(void);
void focus_client_backward(void);
void focus_client_cycle_here(void);
struct client *current_client(void);
struct client *next_client(struct client *, struct stack *);
struct client *prev_client(struct client *, struct stack *);
char *client_name(struct client *);
struct client *find_top_client(struct stack *);
void unmap_clients(struct stack *);
void map_clients(struct stack *);
void update_client_name(struct client *);
void set_client_name(struct client *, const char *);
void rename_client_name(struct client *, const char *);
void delete_client(void);
void destroy_client(void);
struct client *match_client(const char *);
int monitors(void);
int monitor(int, int);
int monitor_x(int);
unsigned short display_height(int);
unsigned short display_width(int);
Display *display(void);
int handle_event(XEvent *);
void open_menu(void);
void draw_menu(void);
void close_menu(void);
void draw_global_menu(void);
void open_global_menu(void);
void close_global_menu(void);
void reset_global_menu(void);
void focus_menu_forward(void);
void focus_menu_backward(void);
void select_menu_item(void);
void select_next_global_menu(void);
void select_move_menu_item(void);
void select_menu_item_right(void);
void select_menu_item_left(void);
void move_menu_item_right(void);
void move_menu_item_left(void);
void show_menu(void);
void hide_menu(void);
int is_menu_visible(void);
void highlight_menu(int);
int menu_has_highlight(void);
void draw_statusbar(void);
int is_statusbar(Window);
void show_statusbar(void);
void set_statusbar_mapped_status(int);
void hide_statusbar(void);
void toggle_statusbar(void);
int add_command_to_history(const char *, int reorder);
void save_command_history(void);
const char *match_command(const char *s);
void do_keyaction(XKeyEvent *);
void unbind_keys();
void bind_keys();
void set_font_color(int);
void set_font(int);
int get_font_height(void);
int draw_font(Window, int, int, int, const char *);
void font_extents(const char *, size_t, XGlyphInfo *);
XColor query_color(int);
Time current_event_timestamp(void);
void prompt_command(void);
void prompt_rename(void);
void prompt_find(void);
#ifdef TRACE
struct client *event_client();
void set_event_client(struct client *);
#endif
#if WANT_CTLSOCKET
int listen_ctlsocket(void);
void run_ctlsocket_event_loop(int);
#endif
void run_ctl_line(const char *);
void run_ctl_lines(void);
#if TRACE
void dump_client(struct client *);
void dump_clients(void);
#else
#define dump_clients(x) do { } while(0)
#define dump_client(x) do { } while(0)
#endif
#endif