event: Prevent seeing banned clients on the visible screen.
[awesome.git] / common / xutil.h
blob3a5ca359ef6451a8c6f514519a949c14b19b951a
1 /*
2 * common/xutil.h - X-related useful functions header
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_COMMON_XUTIL_H
23 #define AWESOME_COMMON_XUTIL_H
25 #include <xcb/xcb.h>
26 #include <xcb/xcb_keysyms.h>
27 #include <xcb/xcb_aux.h>
28 #include <xcb/xcb_event.h>
30 /* XCB doesn't provide keysyms definition */
31 #include <X11/keysym.h>
33 #include "array.h"
35 #define XUTIL_MASK_CLEAN(mask) (mask & ~(globalconf.numlockmask | XCB_MOD_MASK_LOCK))
37 /* X error codes */
39 /* Everything's okay */
40 #define XUTIL_SUCCESS 0
41 /* Bad request code */
42 #define XUTIL_BAD_REQUEST 1
43 /* Int parameter out of range */
44 #define XUTIL_BAD_VALUE 2
45 /* Parameter not a Window */
46 #define XUTIL_BAD_WINDOW 3
47 /* Parameter not a Pixmap */
48 #define XUTIL_BAD_PIXMAP 4
49 /* Parameter not an Atom */
50 #define XUTIL_BAD_ATOM 5
51 /* Parameter not a Cursor */
52 #define XUTIL_BAD_CURSOR 6
53 /* Parameter not a Font */
54 #define XUTIL_BAD_FONT 7
55 /* Parameter mismatch */
56 #define XUTIL_BAD_MATCH 8
57 /* Parameter not a Pixmap or Window */
58 #define XUTIL_BAD_DRAWABLE 9
59 /* Depending on context:
60 - key/button already grabbed
61 - attempt to free an illegal
62 cmap entry
63 - attempt to store into a read-only
64 color map entry.
65 - attempt to modify the access control
66 list from other than the local host.
68 #define XUTIL_BAD_ACCESS 10
69 /* Insufficient resources */
70 #define XUTIL_BAD_ALLOC 11
71 /* No such colormap */
72 #define XUTIL_BAD_COLOR 12
73 /* Parameter not a GC */
74 #define XUTIL_BAD_GC 13
75 /* Choice not in range or already used */
76 #define XUTIL_BAD_ID_CHOICE 14
77 /* Font or color name doesn't exist */
78 #define XUTIL_BAD_NAME 15
79 /* Request length incorrect */
80 #define XUTIL_BAD_LENGTH 16
81 /* Server is defective */
82 #define XUTIL_BAD_IMPLEMENTATION 17
84 bool xutil_text_prop_get(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **, ssize_t *);
86 void xutil_lock_mask_get(xcb_connection_t *, xcb_get_modifier_mapping_cookie_t,
87 xcb_key_symbols_t *, unsigned int *, unsigned int *,
88 unsigned int *);
90 /** Set the same handler for all errors */
91 void xutil_error_handler_catch_all_set(xcb_event_handlers_t *,
92 xcb_generic_error_handler_t, void *);
94 typedef struct
96 uint8_t request_code;
97 char *request_label;
98 char *error_label;
99 } xutil_error_t;
101 bool xutil_error_init(const xcb_generic_error_t *, xutil_error_t *);
102 xcb_keysym_t xutil_key_mask_fromstr(const char *, size_t);
103 unsigned int xutil_button_fromint(int);
105 static inline void
106 xutil_error_wipe(xutil_error_t *err)
108 p_delete(&err->error_label);
109 p_delete(&err->request_label);
112 /* Get the informations about the screen.
113 * \param c X connection.
114 * \param screen Screen number.
115 * \return Screen informations (must not be freed!).
117 static inline xcb_screen_t *
118 xutil_screen_get(xcb_connection_t *c, int screen)
120 xcb_screen_t *s;
122 if(xcb_connection_has_error(c))
123 fatal("X connection invalid");
125 s = xcb_aux_get_screen(c, screen);
127 assert(s);
129 return s;
132 int xutil_root2screen(xcb_connection_t *, xcb_window_t);
134 #endif
135 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80