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))
37 #define INIT __attribute__((section( ".gwminit.text" ) ))
38 #define INITD __attribute__((section( ".gwminit.rodata" ) ))
41 #define SEND_EVENT_MASK 0x80
43 extern MALLOC
void *xmalloc( size_t size
);
44 extern void *xrealloc( void *p
, size_t size
);
45 extern MALLOC
void *xcalloc( size_t number
, size_t size
);
47 enum _extended_event_type
{
48 SYNTHETIC_EVENT
= XCB_MAPPING_NOTIFY
+ 1,
52 extern xcb_connection_t
*c
;
53 extern xcb_timestamp_t latest_timestamp
;
56 /* See X Window System Protocol (version 11, release 6.7), Appendix B. */
76 ATOM__NET_CURRENT_DESKTOP
,
77 ATOM__NET_DESKTOP_GEOMETRY
,
78 ATOM__NET_DESKTOP_VIEWPORT
,
79 ATOM__NET_FRAME_EXTENTS
,
80 ATOM__NET_NUMBER_OF_DESKTOPS
,
82 ATOM__NET_SUPPORTING_WM_CHECK
,
89 ATOM_WM_COLORMAP_NOTIFY
,
90 ATOM_WM_COLORMAP_WINDOWS
,
91 ATOM_WM_DELETE_WINDOW
,
98 extern xcb_atom_t atoms
[ NUM_ATOMS
];
100 enum gwm_property_type
{
101 PROP__MOTIF_WM_HINTS
,
104 PROP_WM_COLORMAP_WINDOWS
,
107 PROP_WM_NORMAL_HINTS
,
112 #define PROP_SIZE 262144 /* maximum number of 32-bit words to retrieve */
114 extern xcb_atom_t prop_atoms
[ NUM_PROPS
];
115 extern xcb_atom_t prop_types
[ NUM_PROPS
];
128 EXT_SHAPE
, /* any version */
131 EXT_XFIXES
, /* requires version 2 */
136 #if USE_COMPOSITE || USE_DAMAGE || USE_RENDER || USE_SHAPE || USE_FIXES
137 #define EXTENSIONS_SIZE NUM_EXTENSIONS
139 #define EXTENSIONS_SIZE 1 /* avoid zero length arrays */
142 extern int have_extension
[ EXTENSIONS_SIZE
];
143 extern uint8_t extension_event
[ EXTENSIONS_SIZE
],
144 extension_error
[ EXTENSIONS_SIZE
];
146 enum decoration_col
{
156 COL_MENU_ACTIVE_BACK
,
157 COL_MENU_ACTIVE_FORE
,
158 COL_MENU_INACTIVE_BACK
,
159 COL_MENU_INACTIVE_FORE
,
163 extern int num_screens
;
164 extern xcb_screen_t
**screens
;
167 xcb_visualtype_t
*root_visual
;
168 xcb_atom_t wm_atom
; /* the atom WM_Sn, where n is the screen number */
169 xcb_colormap_t cmap
; /* the most recently installed colormap */
170 xcb_timestamp_t cmap_time
; /* the time at which it was installed */
171 uint32_t pixels
[ NUM_COLS
]; /* pixel values in the default cmap */
174 extern struct gwm_screen
*gwm_screens
;
202 extern xcb_cursor_t cursors
[ NUM_CURSORS
];
204 union callback_param
{
211 #define HINT_ICONIC 0x1 /* otherwise normal */
212 #define HINT_INPUT 0x2
213 #define HINT_USER_POSITION 0x4
214 #define HINT_PROGRAM_POSITION 0x8
215 #define HINT_POSITION 0xC /* HINT_USER_POSITION | HINT_PROGRAM_POSITION */
216 #define PROTOCOL_DELETE_WINDOW 0x1
217 #define PROTOCOL_TAKE_FOCUS 0x2
219 #define STATE_WITHDRAWN 0
220 #define STATE_NORMAL 1
221 #define STATE_ICONIC 3
223 #define DEC_BORDER 0x1
224 #define DEC_TITLE 0x2
225 #define DEC_DEFAULT ( DEC_BORDER | DEC_TITLE )
230 enum _gwm_window_type
{
231 WINDOW_ROOT
, WINDOW_MANAGED
, WINDOW_FRAME
, WINDOW_BUTTON
, WINDOW_MENU
,
232 WINDOW_MENUITEM
, WINDOW_FAKE
, WINDOW_FEEDBACK
, WINDOW_INCOMPLETE
,
235 xcb_rectangle_t update
; /* the area which needs updating */
236 int cleared
; /* TRUE if the update area has already been cleared */
237 union _gwm_window_union
{
238 struct _gwm_managed
{
239 struct gwm_window
*frame
;
240 uint16_t border_width
;
245 /* from WM_COLORMAP_WINDOWS: */
246 xcb_window_t cmap_window
;
248 int hints
; /* see HINT_* above */
249 /* from _NET_WM_ICON: */
251 uint32_t *full_icons
, *menu_icons
; /* pictures, screen indexed */
254 /* from WM_NAME and _NET_WM_NAME: */
255 char *name
; /* legal UTF-8; must be free()d */
257 /* from WM_NORMAL_HINTS: */
258 int min_width
, min_height
, max_width
, max_height
, width_inc
,
259 height_inc
, min_aspect_x
, min_aspect_y
, max_aspect_x
,
260 max_aspect_y
, base_width
, base_height
, win_gravity
;
261 /* from WM_PROTOCOLS: */
262 int protocols
; /* see PROTOCOL_* above */
264 int state
; /* see STATE_* above */
267 struct gwm_window
*child
, *button
;
268 int x
, y
, width
, height
;
269 int decoration
; /* see DEC_* above */
270 xcb_window_t border_regions
[ NUM_BORDER_REGIONS
];
273 struct gwm_window
*frame
;
276 xcb_window_t window_param
;
277 int num_items
, active_item
;
280 struct gwm_window
**items
; /* must be free()d */
282 struct _gwm_menuitem
{
283 struct gwm_window
*menu
;
284 char *label
; /* must be free()d */
285 void ( *action
)( struct gwm_window
*window
,
286 xcb_generic_event_t
*ev
,
287 union callback_param cp
);
288 void ( *enter_action
)( struct gwm_window
*window
,
289 xcb_generic_event_t
*ev
,
290 union callback_param cp
);
291 void ( *leave_action
)( struct gwm_window
*window
,
292 xcb_generic_event_t
*ev
,
293 union callback_param cp
);
294 union callback_param cp
;
298 xcb_timestamp_t timestamp
;
300 struct _gwm_feedback
{
301 int fb_width
, fb_height
;
303 struct _gwm_incomplete
{
304 unsigned int sequence
;
309 extern struct gwm_window
*fake_window
; /* a window created solely to hold the
312 extern const char *argv0
;
313 extern volatile int signal_caught
;
315 extern FORMAT( printf
, 1, 2 ) void warning( char *format
, ... );
316 extern FORMAT( printf
, 1, 2 ) NORETURN
void fatal( char *format
, ... );
318 /* Schedule a callback function to be invoked when a reply or error is
319 available for handling, or when neither can arrive. */
320 extern void handle_async_reply( unsigned int sequence
,
321 void ( *callback
)( unsigned int sequence
,
323 xcb_generic_error_t
*error
,
324 union callback_param p
),
325 union callback_param p
);
326 /* Block until the scheduled callback function has completed. */
327 extern void sync_with_callback( unsigned int sequence
);
329 #define ERR_MASK_REQUEST 0x000001
330 #define ERR_MASK_VALUE 0x00002
331 #define ERR_MASK_WINDOW 0x00004
332 #define ERR_MASK_PIXMAP 0x00008
333 #define ERR_MASK_ATOM 0x00010
334 #define ERR_MASK_CURSOR 0x00020
335 #define ERR_MASK_FONT 0x00040
336 #define ERR_MASK_MATCH 0x00080
337 #define ERR_MASK_DRAWABLE 0x00100
338 #define ERR_MASK_ACCESS 0x00200
339 #define ERR_MASK_ALLOC 0x00400
340 #define ERR_MASK_COLORMAP 0x00800
341 #define ERR_MASK_G_CONTEXT 0x01000
342 #define ERR_MASK_ID_CHOICE 0x02000
343 #define ERR_MASK_NAME 0x04000
344 #define ERR_MASK_LENGTH 0x08000
345 #define ERR_MASK_IMPLEMENTATION 0x10000
347 extern void handle_error_reply( xcb_void_cookie_t cookie
, unsigned ignore
);
348 extern void show_error( xcb_generic_error_t
*error
);
350 typedef void ( *event_handler
)( struct gwm_window
*window
,
351 xcb_generic_event_t
*ev
);
353 /* Return TRUE iff an event is the only button pressed. */
354 extern CONST
int initial_press( xcb_button_press_event_t
*ev
);
356 /* Return TRUE iff an event is the release of the last button (and so would
357 terminate a passive grab). */
358 extern CONST
int final_release( xcb_button_release_event_t
*ev
);
360 extern CONST xcb_timestamp_t
event_time( xcb_generic_event_t
*ev
);
362 /* The window whose event handler(s) should be invoked for pointer events.
363 Unlike pointer grabs, this mechanism is implemented entirely on the
364 client side, and has no effect on the contents of events. */
365 extern xcb_window_t pointer_demux
;
367 /* Install a window's colormap on a screen, or the default colormap if
369 extern void install_window_colormap( int screen
, struct gwm_window
*window
,
372 extern void generic_expose( struct gwm_window
*window
,
373 xcb_expose_event_t
*ev
);
375 extern void manage_window( xcb_window_t w
, int map_request
);
376 extern void unmanage_window( struct gwm_window
*window
);
378 /* A replacement for xcb_wait_for_event (which is broken, because it
379 always restarts interrupted system calls). Also invokes any
380 asynchronous callbacks scheduled for replies and errors. */
381 extern xcb_generic_event_t
*wait_for_event( void );
383 extern void ( *window_size
)( struct gwm_window
*window
, int *width
,
385 extern void ( *replace_icons
)( struct gwm_window
*window
, int num_icons
,
386 int *widths
, int *heights
, uint32_t **icons
,
387 xcb_pixmap_t
*pixmaps
);