11 #if !defined(__GNUC__) && !defined(__attribute__)
12 #define __attribute__()
16 #define CONST __attribute__((const))
20 #define FORMAT( archetype, string_index, first_to_check ) \
21 __attribute__((format( archetype, string_index, first_to_check ) ))
25 #define MALLOC __attribute__((malloc))
29 #define NORETURN __attribute__((noreturn))
33 #define PURE __attribute__((pure))
36 #define SEND_EVENT_MASK 0x80
38 extern MALLOC
void *xmalloc( size_t size
);
39 extern void *xrealloc( void *p
, size_t size
);
40 extern MALLOC
void *xcalloc( size_t number
, size_t size
);
42 enum _extended_event_type
{
43 SYNTHETIC_EVENT
= XCB_MAPPING_NOTIFY
+ 1,
47 extern xcb_connection_t
*c
;
48 extern xcb_timestamp_t latest_timestamp
;
51 /* See X Window System Protocol (version 11, release 6.7), Appendix B. */
71 ATOM_WM_COLORMAP_NOTIFY
,
72 ATOM_WM_COLORMAP_WINDOWS
,
73 ATOM_WM_DELETE_WINDOW
,
80 extern xcb_atom_t atoms
[ NUM_ATOMS
];
82 enum gwm_property_type
{
83 PROP_WM_COLORMAP_WINDOWS
,
91 #define PROP_SIZE 64 /* maximum number of 32-bit words to retrieve */
93 extern xcb_atom_t prop_atoms
[ NUM_PROPS
];
94 extern xcb_atom_t prop_types
[ NUM_PROPS
];
107 EXT_SHAPE
, /* any version */
110 EXT_XFIXES
, /* requires version 2 */
115 #if USE_COMPOSITE || USE_DAMAGE || USE_RENDER || USE_SHAPE || USE_FIXES
116 #define EXTENSIONS_SIZE NUM_EXTENSIONS
118 #define EXTENSIONS_SIZE 1 /* avoid zero length arrays */
121 extern int have_extension
[ EXTENSIONS_SIZE
];
122 extern uint8_t extension_event
[ EXTENSIONS_SIZE
],
123 extension_error
[ EXTENSIONS_SIZE
];
125 enum decoration_col
{
138 extern int num_screens
;
139 extern xcb_screen_t
**screens
;
142 xcb_visualtype_t
*root_visual
;
143 xcb_atom_t wm_atom
; /* the atom WM_Sn, where n is the screen number */
144 xcb_colormap_t cmap
; /* the most recently installed colormap */
145 xcb_timestamp_t cmap_time
; /* the time at which it was installed */
146 uint32_t pixels
[ NUM_COLS
]; /* pixel values in the default cmap */
149 extern struct gwm_screen
*gwm_screens
;
165 extern xcb_cursor_t cursors
[ NUM_CURSORS
];
167 #define HINT_ICONIC 0x1 /* otherwise normal */
168 #define HINT_INPUT 0x2
169 #define HINT_USER_POSITION 0x4
170 #define HINT_PROGRAM_POSITION 0x8
171 #define HINT_POSITION 0xC /* HINT_USER_POSITION | HINT_PROGRAM_POSITION */
172 #define PROTOCOL_DELETE_WINDOW 0x1
173 #define PROTOCOL_TAKE_FOCUS 0x2
175 #define STATE_WITHDRAWN 0
176 #define STATE_NORMAL 1
177 #define STATE_ICONIC 3
182 enum _gwm_window_type
{
183 WINDOW_ROOT
, WINDOW_MANAGED
, WINDOW_FRAME
, WINDOW_BUTTON
, WINDOW_FAKE
,
184 WINDOW_FEEDBACK
, WINDOW_INCOMPLETE
186 xcb_rectangle_t update
; /* the area which needs updating */
187 int cleared
; /* TRUE if the update area has already been cleared */
188 union _gwm_window_union
{
189 struct _gwm_managed
{
190 struct gwm_window
*frame
;
191 uint16_t border_width
;
193 /* from WM_COLORMAP_WINDOWS: */
194 xcb_window_t cmap_window
;
196 int hints
; /* see HINT_* above */
198 char *name
; /* must be free()d */
199 /* from WM_NORMAL_HINTS: */
200 int min_width
, min_height
, max_width
, max_height
, width_inc
,
201 height_inc
, min_aspect_x
, min_aspect_y
, max_aspect_x
,
202 max_aspect_y
, base_width
, base_height
, win_gravity
;
203 /* from WM_PROTOCOLS: */
204 int protocols
; /* see PROTOCOL_* above */
206 int state
; /* see STATE_* above */
209 struct gwm_window
*child
, *button
;
210 int x
, y
, width
, height
;
213 struct gwm_window
*frame
;
216 xcb_timestamp_t timestamp
;
218 struct _gwm_feedback
{
219 int fb_width
, fb_height
;
221 struct _gwm_incomplete
{
222 unsigned int sequence
;
227 extern struct gwm_window
*fake_window
; /* a window created solely to hold the
229 extern struct gwm_window
*focus_frame
; /* the WINDOW_FRAME which has the
232 extern const char *argv0
;
234 union callback_param
{
239 /* Schedule a callback function to be invoked when a reply or error is
240 available for handling, or when neither can arrive. */
241 extern void handle_async_reply( unsigned int sequence
,
242 void ( *callback
)( unsigned int sequence
,
244 xcb_generic_error_t
*error
,
245 union callback_param p
),
246 union callback_param p
);
247 /* Block until the scheduled callback function has completed. */
248 extern void sync_with_callback( unsigned int sequence
);
250 #define ERR_MASK_REQUEST 0x000001
251 #define ERR_MASK_VALUE 0x00002
252 #define ERR_MASK_WINDOW 0x00004
253 #define ERR_MASK_PIXMAP 0x00008
254 #define ERR_MASK_ATOM 0x00010
255 #define ERR_MASK_CURSOR 0x00020
256 #define ERR_MASK_FONT 0x00040
257 #define ERR_MASK_MATCH 0x00080
258 #define ERR_MASK_DRAWABLE 0x00100
259 #define ERR_MASK_ACCESS 0x00200
260 #define ERR_MASK_ALLOC 0x00400
261 #define ERR_MASK_COLORMAP 0x00800
262 #define ERR_MASK_G_CONTEXT 0x01000
263 #define ERR_MASK_ID_CHOICE 0x02000
264 #define ERR_MASK_NAME 0x04000
265 #define ERR_MASK_LENGTH 0x08000
266 #define ERR_MASK_IMPLEMENTATION 0x10000
268 extern void handle_error_reply( xcb_void_cookie_t cookie
, unsigned ignore
);
269 extern void show_error( xcb_generic_error_t
*error
);
271 typedef void ( *event_handler
)( struct gwm_window
*window
,
272 xcb_generic_event_t
*ev
);
274 /* Return TRUE iff an event is the only button pressed (and so would
275 initiate a passive grab). */
276 extern CONST
int initial_press( xcb_button_press_event_t
*ev
);
278 /* Return TRUE iff an event is the release of the last button (and so would
279 terminate a passive grab). */
280 extern CONST
int final_release( xcb_button_release_event_t
*ev
);
282 /* The window which has the pointer automatically grabbed via a button
283 press, or XCB_NONE. */
284 extern xcb_window_t passive_grab
;
286 /* Install a window's colormap on a screen, or the default colormap if
288 extern void install_window_colormap( int screen
, struct gwm_window
*window
,
291 extern void translate_child_to_frame( int *fx
, int *fy
, int *fwidth
,
292 int *fheight
, int cx
, int cy
,
293 int cwidth
, int cheight
,
294 int cborder
, int win_gravity
);
296 extern void translate_frame_to_child( int *cx
, int *cy
, int fx
, int fy
,
297 int cborder
, int win_gravity
);
299 extern void apply_size_constraints( struct gwm_window
*window
, int *width
,
302 extern void generic_expose( struct gwm_window
*window
,
303 xcb_expose_event_t
*ev
);
305 extern void deactivate_focus_frame( void );
307 extern void iconic_to_normal( struct gwm_window
*window
);
309 extern void manage_window( xcb_window_t w
, int map_request
);
310 extern void unmanage_window( struct gwm_window
*window
);
312 /* A replacement for xcb_wait_for_event (which is broken, because it
313 always restarts interrupted system calls). Also invokes any
314 asynchronous callbacks scheduled for replies and errors. */
315 extern xcb_generic_event_t
*wait_for_event( void );
317 #define FRAME_X_BORDER 1 /* X border added to all four sides of frame */
318 #define FRAME_BORDER_WIDTH 2 /* pixels added to left, right and bottom;
319 includes padding but excludes X border */
320 #define FRAME_TITLE_HEIGHT 16 /* pixels added to top; includes title
321 bar but excludes X border */
322 #define FRAME_BUTTON_SIZE 12 /* size of buttons in title bar; excludes
324 #define FEEDBACK_WIDTH 96 /* width of size feedback window */
325 #define FEEDBACK_HEIGHT 24 /* height of size feedback window */