1 /*
2  * calmwm - the calm window manager
3  *
4  * Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * $OpenBSD$
19  */
20 
21 #ifndef _CALMWM_H_
22 #define _CALMWM_H_
23 
24 #include <sys/param.h>
25 #include <stdio.h>
26 #include "queue.h"
27 
28 /* prototypes for portable-included functions */
29 char *fgetln(FILE *, size_t *);
30 long long strtonum(const char *, long long, long long, const char **);
31 void *reallocarray(void *, size_t, size_t);
32 
33 
34 #ifdef strlcat
35 #define HAVE_STRLCAT
36 #else
37 size_t strlcat(char *, const char *, size_t);
38 #endif
39 #ifdef strlcpy
40 #define HAVE_STRLCPY
41 #else
42 size_t strlcpy(char *, const char *, size_t);
43 #endif
44 
45 #include <X11/XKBlib.h>
46 #include <X11/Xatom.h>
47 #include <X11/Xft/Xft.h>
48 #include <X11/Xlib.h>
49 #include <X11/Xproto.h>
50 #include <X11/Xutil.h>
51 #include <X11/cursorfont.h>
52 #include <X11/extensions/Xrandr.h>
53 #include <X11/keysym.h>
54 
55 #define LOG_DEBUG0(...)	log_debug(0, __func__, __VA_ARGS__)
56 #define LOG_DEBUG1(...)	log_debug(1, __func__, __VA_ARGS__)
57 #define LOG_DEBUG2(...)	log_debug(2, __func__, __VA_ARGS__)
58 #define LOG_DEBUG3(...)	log_debug(3, __func__, __VA_ARGS__)
59 
60 #undef MIN
61 #undef MAX
62 #define MIN(x, y) ((x) < (y) ? (x) : (y))
63 #define MAX(x, y) ((x) > (y) ? (x) : (y))
64 
65 #ifndef nitems
66 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
67 #endif
68 
69 #define BUTTONMASK	(ButtonPressMask | ButtonReleaseMask)
70 #define MOUSEMASK	(BUTTONMASK | PointerMotionMask)
71 #define IGNOREMODMASK	(LockMask | Mod2Mask | 0x2000)
72 
73 /* direction/amount */
74 #define CWM_UP			0x0001
75 #define CWM_DOWN		0x0002
76 #define CWM_LEFT		0x0004
77 #define CWM_RIGHT		0x0008
78 #define CWM_BIGAMOUNT		0x0010
79 #define CWM_UP_BIG		(CWM_UP | CWM_BIGAMOUNT)
80 #define CWM_DOWN_BIG		(CWM_DOWN | CWM_BIGAMOUNT)
81 #define CWM_LEFT_BIG		(CWM_LEFT | CWM_BIGAMOUNT)
82 #define CWM_RIGHT_BIG		(CWM_RIGHT | CWM_BIGAMOUNT)
83 #define CWM_UP_RIGHT		(CWM_UP | CWM_RIGHT)
84 #define CWM_UP_LEFT		(CWM_UP | CWM_LEFT)
85 #define CWM_DOWN_RIGHT		(CWM_DOWN | CWM_RIGHT)
86 #define CWM_DOWN_LEFT		(CWM_DOWN | CWM_LEFT)
87 
88 #define CWM_CYCLE_FORWARD	0x0001
89 #define CWM_CYCLE_REVERSE	0x0002
90 #define CWM_CYCLE_INGROUP	0x0004
91 
92 enum cwm_status {
93 	CWM_QUIT,
94 	CWM_RUNNING,
95 	CWM_EXEC_WM
96 };
97 enum cursor_font {
98 	CF_NORMAL,
99 	CF_MOVE,
100 	CF_RESIZE,
101 	CF_QUESTION,
102 	CF_NITEMS
103 };
104 enum color {
105 	CWM_COLOR_BORDER_ACTIVE,
106 	CWM_COLOR_BORDER_INACTIVE,
107 	CWM_COLOR_BORDER_URGENCY,
108 	CWM_COLOR_BORDER_GROUP,
109 	CWM_COLOR_BORDER_UNGROUP,
110 	CWM_COLOR_MENU_FG,
111 	CWM_COLOR_MENU_BG,
112 	CWM_COLOR_MENU_FONT,
113 	CWM_COLOR_MENU_FONT_SEL,
114 	CWM_COLOR_NITEMS
115 };
116 
117 struct geom {
118 	int		 x;
119 	int		 y;
120 	int		 w;
121 	int		 h;
122 };
123 struct gap {
124 	int		 top;
125 	int		 bottom;
126 	int		 left;
127 	int		 right;
128 };
129 
130 struct winname {
131 	TAILQ_ENTRY(winname)	 entry;
132 	char			*name;
133 };
134 TAILQ_HEAD(name_q, winname);
135 TAILQ_HEAD(ignore_q, winname);
136 
137 struct client_ctx {
138 	TAILQ_ENTRY(client_ctx)	 entry;
139 	struct screen_ctx	*sc;
140 	struct group_ctx	*gc;
141 	Window			 win;
142 	Colormap		 colormap;
143 	int			 bwidth; /* border width */
144 	int			 obwidth; /* original border width */
145 	struct geom		 geom, savegeom, fullgeom;
146 	struct {
147 		long		 flags;	/* defined hints */
148 		int		 basew;	/* desired width */
149 		int		 baseh;	/* desired height */
150 		int		 minw;	/* minimum width */
151 		int		 minh;	/* minimum height */
152 		int		 maxw;	/* maximum width */
153 		int		 maxh;	/* maximum height */
154 		int		 incw;	/* width increment progression */
155 		int		 inch;	/* height increment progression */
156 		float		 mina;	/* minimum aspect ratio */
157 		float		 maxa;	/* maximum aspect ratio */
158 	} hint;
159 	struct {
160 		int		 x;	/* x position */
161 		int		 y;	/* y position */
162 	} ptr;
163 	struct {
164 		int		 h;	/* height */
165 		int		 w;	/* width */
166 	} dim;
167 #define CLIENT_HIDDEN			0x0001
168 #define CLIENT_IGNORE			0x0002
169 #define CLIENT_VMAXIMIZED		0x0004
170 #define CLIENT_HMAXIMIZED		0x0008
171 #define CLIENT_FREEZE			0x0010
172 #define CLIENT_GROUP			0x0020
173 #define CLIENT_UNGROUP			0x0040
174 #define CLIENT_INPUT			0x0080
175 #define CLIENT_WM_DELETE_WINDOW		0x0100
176 #define CLIENT_WM_TAKE_FOCUS		0x0200
177 #define CLIENT_URGENCY			0x0400
178 #define CLIENT_FULLSCREEN		0x0800
179 #define CLIENT_STICKY			0x1000
180 #define CLIENT_ACTIVE			0x2000
181 #define CLIENT_SKIP_PAGER		0x4000
182 #define CLIENT_SKIP_TASKBAR		0x8000
183 
184 #define CLIENT_SKIP_CYCLE		(CLIENT_HIDDEN | CLIENT_IGNORE | \
185 					 CLIENT_SKIP_TASKBAR | CLIENT_SKIP_PAGER)
186 #define CLIENT_HIGHLIGHT		(CLIENT_GROUP | CLIENT_UNGROUP)
187 #define CLIENT_MAXFLAGS			(CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
188 #define CLIENT_MAXIMIZED		(CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
189 	int			 flags;
190 	int			 stackingorder;
191 	struct name_q		 nameq;
192 	char			*name;
193 	char			*label;
194 	char			*res_class; /* class hint */
195 	char			*res_name; /* class hint */
196 	int			 initial_state; /* wm hint */
197 };
198 TAILQ_HEAD(client_q, client_ctx);
199 
200 struct group_ctx {
201 	TAILQ_ENTRY(group_ctx)	 entry;
202 	struct screen_ctx	*sc;
203 	char			*name;
204 	int			 num;
205 };
206 TAILQ_HEAD(group_q, group_ctx);
207 
208 struct autogroup {
209 	TAILQ_ENTRY(autogroup)	 entry;
210 	char			*class;
211 	char			*name;
212 	int 			 num;
213 };
214 TAILQ_HEAD(autogroup_q, autogroup);
215 
216 struct region_ctx {
217 	TAILQ_ENTRY(region_ctx)	 entry;
218 	int			 num;
219 	struct geom		 view; /* viewable area */
220 	struct geom		 work; /* workable area, gap-applied */
221 };
222 TAILQ_HEAD(region_q, region_ctx);
223 
224 struct screen_ctx {
225 	TAILQ_ENTRY(screen_ctx)	 entry;
226 	int			 which;
227 	Window			 rootwin;
228 	int			 cycling;
229 	int			 hideall;
230 	int			 snapdist;
231 	struct geom		 view; /* viewable area */
232 	struct geom		 work; /* workable area, gap-applied */
233 	struct gap		 gap;
234 	struct client_q		 clientq;
235 	struct region_q		 regionq;
236 	struct group_q		 groupq;
237 	struct group_ctx	*group_active;
238 	Colormap		 colormap;
239 	Visual			*visual;
240 	struct {
241 		Window		 win;
242 		XftDraw		*xftdraw;
243 	} prop;
244 	XftColor		 xftcolor[CWM_COLOR_NITEMS];
245 	XftFont			*xftfont;
246 };
247 TAILQ_HEAD(screen_q, screen_ctx);
248 
249 struct cargs {
250 	char		*cmd;
251 	int		 flag;
252 	enum {
253 		CWM_XEV_KEY,
254 		CWM_XEV_BTN
255 	} xev;
256 };
257 enum context {
258 	CWM_CONTEXT_NONE = 0,
259 	CWM_CONTEXT_CC,
260 	CWM_CONTEXT_SC
261 };
262 struct bind_ctx {
263 	TAILQ_ENTRY(bind_ctx)	 entry;
264 	void			(*callback)(void *, struct cargs *);
265 	struct cargs		*cargs;
266 	enum context		 context;
267 	unsigned int		 modmask;
268 	union {
269 		KeySym		 keysym;
270 		unsigned int	 button;
271 	} press;
272 };
273 TAILQ_HEAD(keybind_q, bind_ctx);
274 TAILQ_HEAD(mousebind_q, bind_ctx);
275 
276 struct cmd_ctx {
277 	TAILQ_ENTRY(cmd_ctx)	 entry;
278 	char			*name;
279 	char			*path;
280 };
281 TAILQ_HEAD(cmd_q, cmd_ctx);
282 TAILQ_HEAD(wm_q, cmd_ctx);
283 
284 #define CWM_MENU_DUMMY		0x0001
285 #define CWM_MENU_FILE		0x0002
286 #define CWM_MENU_LIST		0x0004
287 #define CWM_MENU_WINDOW_ALL	0x0008
288 #define CWM_MENU_WINDOW_HIDDEN	0x0010
289 
290 struct menu {
291 	TAILQ_ENTRY(menu)	 entry;
292 	TAILQ_ENTRY(menu)	 resultentry;
293 #define MENU_MAXENTRY		 200
294 	char			 text[MENU_MAXENTRY + 1];
295 	char			 print[MENU_MAXENTRY + 1];
296 	void			*ctx;
297 	short			 dummy;
298 	short			 abort;
299 };
300 TAILQ_HEAD(menu_q, menu);
301 
302 struct conf {
303 	struct keybind_q	 keybindq;
304 	struct mousebind_q	 mousebindq;
305 	struct autogroup_q	 autogroupq;
306 	struct ignore_q		 ignoreq;
307 	struct cmd_q		 cmdq;
308 	struct wm_q		 wmq;
309 	int			 ngroups;
310 	int			 stickygroups;
311 	int			 nameqlen;
312 	int			 bwidth;
313 	int			 mamount;
314 	int			 snapdist;
315 	int			 htile;
316 	int			 vtile;
317 	struct gap		 gap;
318 	char			*color[CWM_COLOR_NITEMS];
319 	char			*font;
320 	char			*wmname;
321 	Cursor			 cursor[CF_NITEMS];
322 	int			 xrandr;
323 	int			 xrandr_event_base;
324 	char			*conf_file;
325 	char			*known_hosts;
326 	char			*wm_argv;
327 	int			 debug;
328 };
329 
330 /* MWM hints */
331 struct mwm_hints {
332 #define MWM_HINTS_ELEMENTS	3L
333 #define MWM_FLAGS_STATUS	(1<<3)
334 
335 #define MWM_FLAGS_FUNCTIONS	(1<<0)
336 #define MWM_FLAGS_DECORATIONS	(1<<1)
337 #define MWM_FLAGS_INPUT_MODE	(1<<2)
338 	unsigned long	flags;
339 
340 #define MWM_FUNCS_ALL		(1<<0)
341 #define MWM_FUNCS_RESIZE	(1<<1)
342 #define MWM_FUNCS_MOVE		(1<<2)
343 #define MWM_FUNCS_MINIMIZE	(1<<3)
344 #define MWM_FUNCS_MAXIMIZE	(1<<4)
345 #define MWM_FUNCS_CLOSE		(1<<5)
346 	unsigned long	functions;
347 
348 #define	MWM_DECOR_ALL		(1<<0)
349 #define	MWM_DECOR_BORDER	(1<<1)
350 #define MWM_DECOR_RESIZE_HANDLE	(1<<2)
351 #define MWM_DECOR_TITLEBAR	(1<<3)
352 #define MWM_DECOR_MENU		(1<<4)
353 #define MWM_DECOR_MINIMIZE	(1<<5)
354 #define MWM_DECOR_MAXIMIZE	(1<<6)
355 	unsigned long	decorations;
356 };
357 
358 enum cwmh {
359 	WM_STATE,
360 	WM_DELETE_WINDOW,
361 	WM_TAKE_FOCUS,
362 	WM_PROTOCOLS,
363 	_MOTIF_WM_HINTS,
364 	UTF8_STRING,
365 	WM_CHANGE_STATE,
366 	CWMH_NITEMS
367 };
368 enum ewmh {
369 	_NET_SUPPORTED,
370 	_NET_SUPPORTING_WM_CHECK,
371 	_NET_ACTIVE_WINDOW,
372 	_NET_CLIENT_LIST,
373 	_NET_CLIENT_LIST_STACKING,
374 	_NET_NUMBER_OF_DESKTOPS,
375 	_NET_CURRENT_DESKTOP,
376 	_NET_DESKTOP_VIEWPORT,
377 	_NET_DESKTOP_GEOMETRY,
378 	_NET_VIRTUAL_ROOTS,
379 	_NET_SHOWING_DESKTOP,
380 	_NET_DESKTOP_NAMES,
381 	_NET_WORKAREA,
382 	_NET_WM_NAME,
383 	_NET_WM_DESKTOP,
384 	_NET_CLOSE_WINDOW,
385 	_NET_WM_STATE,
386 #define	_NET_WM_STATES_NITEMS	9
387 	_NET_WM_STATE_STICKY,
388 	_NET_WM_STATE_MAXIMIZED_VERT,
389 	_NET_WM_STATE_MAXIMIZED_HORZ,
390 	_NET_WM_STATE_HIDDEN,
391 	_NET_WM_STATE_FULLSCREEN,
392 	_NET_WM_STATE_DEMANDS_ATTENTION,
393 	_NET_WM_STATE_SKIP_PAGER,
394 	_NET_WM_STATE_SKIP_TASKBAR,
395 	_CWM_WM_STATE_FREEZE,
396 	EWMH_NITEMS
397 };
398 enum net_wm_state {
399 	_NET_WM_STATE_REMOVE,
400 	_NET_WM_STATE_ADD,
401 	_NET_WM_STATE_TOGGLE
402 };
403 
404 extern Display				*X_Dpy;
405 extern Time				 Last_Event_Time;
406 extern Atom				 cwmh[CWMH_NITEMS];
407 extern Atom				 ewmh[EWMH_NITEMS];
408 extern struct screen_q			 Screenq;
409 extern struct conf			 Conf;
410 
411 void			 usage(void);
412 
413 void			 client_apply_sizehints(struct client_ctx *);
414 void			 client_close(struct client_ctx *);
415 void			 client_config(struct client_ctx *);
416 struct client_ctx	*client_current(struct screen_ctx *);
417 void			 client_draw_border(struct client_ctx *);
418 struct client_ctx	*client_find(Window);
419 void			 client_get_sizehints(struct client_ctx *);
420 void			 client_hide(struct client_ctx *);
421 void 			 client_htile(struct client_ctx *);
422 int			 client_inbound(struct client_ctx *, int, int);
423 struct client_ctx	*client_init(Window, struct screen_ctx *);
424 void			 client_lower(struct client_ctx *);
425 void			 client_move(struct client_ctx *);
426 void			 client_mtf(struct client_ctx *);
427 struct client_ctx	*client_next(struct client_ctx *);
428 struct client_ctx	*client_prev(struct client_ctx *);
429 void			 client_ptr_inbound(struct client_ctx *, int);
430 void			 client_ptr_save(struct client_ctx *);
431 void			 client_ptr_warp(struct client_ctx *);
432 void			 client_raise(struct client_ctx *);
433 void			 client_remove(struct client_ctx *);
434 void			 client_resize(struct client_ctx *, int);
435 void			 client_set_active(struct client_ctx *);
436 void			 client_set_name(struct client_ctx *);
437 void			 client_show(struct client_ctx *);
438 int			 client_snapcalc(int, int, int, int, int);
439 void			 client_toggle_hidden(struct client_ctx *);
440 void			 client_toggle_hmaximize(struct client_ctx *);
441 void			 client_toggle_fullscreen(struct client_ctx *);
442 void			 client_toggle_freeze(struct client_ctx *);
443 void			 client_toggle_maximize(struct client_ctx *);
444 void			 client_toggle_skip_pager(struct client_ctx *);
445 void			 client_toggle_skip_taskbar(struct client_ctx *);
446 void			 client_toggle_sticky(struct client_ctx *);
447 void			 client_toggle_vmaximize(struct client_ctx *);
448 void			 client_transient(struct client_ctx *);
449 void			 client_urgency(struct client_ctx *);
450 void 			 client_vtile(struct client_ctx *);
451 void			 client_wm_hints(struct client_ctx *);
452 
453 void			 group_assign(struct group_ctx *, struct client_ctx *);
454 int			 group_autogroup(struct client_ctx *);
455 void			 group_cycle(struct screen_ctx *, int);
456 void			 group_hide(struct group_ctx *);
457 int			 group_holds_only_hidden(struct group_ctx *);
458 int			 group_holds_only_sticky(struct group_ctx *);
459 void			 group_init(struct screen_ctx *, int, const char *);
460 void			 group_movetogroup(struct client_ctx *, int);
461 void			 group_only(struct screen_ctx *, int);
462 void			 group_close(struct screen_ctx *, int);
463 int			 group_restore(struct client_ctx *);
464 void			 group_show(struct group_ctx *);
465 void			 group_toggle(struct screen_ctx *, int);
466 void			 group_toggle_all(struct screen_ctx *);
467 void			 group_toggle_membership(struct client_ctx *);
468 void			 group_update_names(struct screen_ctx *);
469 
470 void			 search_match_client(struct menu_q *, struct menu_q *,
471 			     char *);
472 void			 search_match_cmd(struct menu_q *, struct menu_q *,
473 			     char *);
474 void			 search_match_exec(struct menu_q *, struct menu_q *,
475 			     char *);
476 void			 search_match_group(struct menu_q *, struct menu_q *,
477 			     char *);
478 void			 search_match_path(struct menu_q *, struct menu_q *,
479 			     char *);
480 void			 search_match_text(struct menu_q *, struct menu_q *,
481 			     char *);
482 void			 search_match_wm(struct menu_q *, struct menu_q *,
483 			     char *);
484 void			 search_print_client(struct menu *, int);
485 void			 search_print_cmd(struct menu *, int);
486 void			 search_print_group(struct menu *, int);
487 void			 search_print_text(struct menu *, int);
488 void			 search_print_wm(struct menu *, int);
489 
490 struct region_ctx	*region_find(struct screen_ctx *, int, int);
491 void			 screen_assert_clients_within(struct screen_ctx *);
492 struct geom		 screen_area(struct screen_ctx *, int, int, int);
493 struct screen_ctx	*screen_find(Window);
494 void			 screen_init(int);
495 void			 screen_prop_win_create(struct screen_ctx *, Window);
496 void			 screen_prop_win_destroy(struct screen_ctx *);
497 void			 screen_prop_win_draw(struct screen_ctx *,
498 			     const char *, ...)
499 			    __attribute__((__format__ (printf, 2, 3)))
500 			    __attribute__((__nonnull__ (2)));
501 void			 screen_update_geometry(struct screen_ctx *);
502 void			 screen_updatestackingorder(struct screen_ctx *);
503 
504 void			 kbfunc_cwm_status(void *, struct cargs *);
505 void			 kbfunc_ptrmove(void *, struct cargs *);
506 void			 kbfunc_client_snap(void *, struct cargs *);
507 void			 kbfunc_client_move(void *, struct cargs *);
508 void			 kbfunc_client_resize(void *, struct cargs *);
509 void			 kbfunc_client_close(void *, struct cargs *);
510 void			 kbfunc_client_lower(void *, struct cargs *);
511 void			 kbfunc_client_raise(void *, struct cargs *);
512 void			 kbfunc_client_hide(void *, struct cargs *);
513 void			 kbfunc_client_toggle_freeze(void *, struct cargs *);
514 void			 kbfunc_client_toggle_sticky(void *, struct cargs *);
515 void			 kbfunc_client_toggle_fullscreen(void *,
516 			      struct cargs *);
517 void			 kbfunc_client_toggle_maximize(void *, struct cargs *);
518 void			 kbfunc_client_toggle_hmaximize(void *, struct cargs *);
519 void			 kbfunc_client_toggle_vmaximize(void *, struct cargs *);
520 void 			 kbfunc_client_htile(void *, struct cargs *);
521 void 			 kbfunc_client_vtile(void *, struct cargs *);
522 void			 kbfunc_client_cycle(void *, struct cargs *);
523 void			 kbfunc_client_toggle_group(void *, struct cargs *);
524 void			 kbfunc_client_movetogroup(void *, struct cargs *);
525 void			 kbfunc_group_toggle(void *, struct cargs *);
526 void			 kbfunc_group_only(void *, struct cargs *);
527 void			 kbfunc_group_close(void *, struct cargs *);
528 void			 kbfunc_group_cycle(void *, struct cargs *);
529 void			 kbfunc_group_toggle_all(void *, struct cargs *);
530 void			 kbfunc_menu_client(void *, struct cargs *);
531 void			 kbfunc_menu_cmd(void *, struct cargs *);
532 void			 kbfunc_menu_group(void *, struct cargs *);
533 void			 kbfunc_menu_wm(void *, struct cargs *);
534 void			 kbfunc_menu_exec(void *, struct cargs *);
535 void			 kbfunc_menu_ssh(void *, struct cargs *);
536 void			 kbfunc_client_menu_label(void *, struct cargs *);
537 void			 kbfunc_exec_cmd(void *, struct cargs *);
538 void			 kbfunc_exec_lock(void *, struct cargs *);
539 void			 kbfunc_exec_term(void *, struct cargs *);
540 
541 struct menu  		*menu_filter(struct screen_ctx *, struct menu_q *,
542 			     const char *, const char *, int,
543 			     void (*)(struct menu_q *, struct menu_q *, char *),
544 			     void (*)(struct menu *, int));
545 void			 menuq_add(struct menu_q *, void *, const char *, ...)
546 			    __attribute__((__format__ (printf, 3, 4)));
547 void			 menuq_clear(struct menu_q *);
548 
549 int			 parse_config(const char *, struct conf *);
550 
551 void			 conf_autogroup(struct conf *, int, const char *,
552 			     const char *);
553 int			 conf_bind_key(struct conf *, const char *,
554     			     const char *);
555 int			 conf_bind_mouse(struct conf *, const char *,
556     			     const char *);
557 void			 conf_clear(struct conf *);
558 void			 conf_client(struct client_ctx *);
559 void			 conf_cmd_add(struct conf *, const char *,
560 			     const char *);
561 void			 conf_wm_add(struct conf *, const char *,
562 			     const char *);
563 void			 conf_cursor(struct conf *);
564 void			 conf_grab_kbd(Window);
565 void			 conf_grab_mouse(Window);
566 void			 conf_init(struct conf *);
567 void			 conf_ignore(struct conf *, const char *);
568 void			 conf_screen(struct screen_ctx *);
569 void			 conf_group(struct screen_ctx *);
570 
571 void			 xev_process(void);
572 
573 int			 xu_get_prop(Window, Atom, Atom, long, unsigned char **);
574 int			 xu_get_strprop(Window, Atom, char **);
575 void			 xu_ptr_get(Window, int *, int *);
576 void			 xu_ptr_set(Window, int, int);
577 void			 xu_get_wm_state(Window, long *);
578 void			 xu_set_wm_state(Window, long);
579 void			 xu_send_clientmsg(Window, Atom, Time);
580 void 			 xu_xorcolor(XftColor, XftColor, XftColor *);
581 
582 void			 xu_atom_init(void);
583 void			 xu_ewmh_net_supported(struct screen_ctx *);
584 void			 xu_ewmh_net_supported_wm_check(struct screen_ctx *);
585 void			 xu_ewmh_net_desktop_geometry(struct screen_ctx *);
586 void			 xu_ewmh_net_desktop_viewport(struct screen_ctx *);
587 void			 xu_ewmh_net_workarea(struct screen_ctx *);
588 void			 xu_ewmh_net_client_list(struct screen_ctx *);
589 void			 xu_ewmh_net_client_list_stacking(struct screen_ctx *);
590 void			 xu_ewmh_net_active_window(struct screen_ctx *, Window);
591 void			 xu_ewmh_net_number_of_desktops(struct screen_ctx *);
592 void			 xu_ewmh_net_showing_desktop(struct screen_ctx *);
593 void			 xu_ewmh_net_virtual_roots(struct screen_ctx *);
594 void			 xu_ewmh_net_current_desktop(struct screen_ctx *);
595 void			 xu_ewmh_net_desktop_names(struct screen_ctx *);
596 int			 xu_ewmh_get_net_wm_desktop(struct client_ctx *, long *);
597 void			 xu_ewmh_set_net_wm_desktop(struct client_ctx *);
598 Atom 			*xu_ewmh_get_net_wm_state(struct client_ctx *, int *);
599 void 			 xu_ewmh_handle_net_wm_state_msg(struct client_ctx *,
600 			     int, Atom , Atom);
601 void 			 xu_ewmh_set_net_wm_state(struct client_ctx *);
602 void 			 xu_ewmh_restore_net_wm_state(struct client_ctx *);
603 
604 char			*u_argv(char * const *);
605 void			 u_exec(char *);
606 void			 u_spawn(char *);
607 void			 log_debug(int, const char *, const char *, ...)
608 			    __attribute__((__format__ (printf, 3, 4)))
609 			    __attribute__((__nonnull__ (3)));
610 
611 void			*xcalloc(size_t, size_t);
612 void			*xmalloc(size_t);
613 void			*xreallocarray(void *, size_t, size_t);
614 char			*xstrdup(const char *);
615 int			 xasprintf(char **, const char *, ...)
616 			    __attribute__((__format__ (printf, 2, 3)))
617 			    __attribute__((__nonnull__ (2)));
618 int			 xvasprintf(char **, const char *, va_list)
619 			    __attribute__((__nonnull__ (2)));
620 
621 #endif /* _CALMWM_H_ */
622