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" ) ))
44 #define SEND_EVENT_MASK 0x80
46 extern MALLOC
void *xmalloc( size_t size
);
47 extern void *xrealloc( void *p
, size_t size
);
48 extern MALLOC
void *xcalloc( size_t number
, size_t size
);
50 enum _extended_event_type
{
51 SYNTHETIC_EVENT
= XCB_MAPPING_NOTIFY
+ 1,
55 extern xcb_connection_t
*c
;
56 extern xcb_timestamp_t latest_timestamp
;
59 /* See X Window System Protocol (version 11, release 6.7), Appendix B. */
79 ATOM__NET_CURRENT_DESKTOP
,
80 ATOM__NET_DESKTOP_GEOMETRY
,
81 ATOM__NET_DESKTOP_VIEWPORT
,
82 ATOM__NET_FRAME_EXTENTS
,
83 ATOM__NET_NUMBER_OF_DESKTOPS
,
85 ATOM__NET_SUPPORTING_WM_CHECK
,
92 ATOM_WM_COLORMAP_NOTIFY
,
93 ATOM_WM_COLORMAP_WINDOWS
,
94 ATOM_WM_DELETE_WINDOW
,
101 extern xcb_atom_t atoms
[ NUM_ATOMS
];
103 enum gwm_property_type
{
104 PROP__MOTIF_WM_HINTS
,
107 PROP_WM_COLORMAP_WINDOWS
,
110 PROP_WM_NORMAL_HINTS
,
115 #define PROP_SIZE 262144 /* maximum number of 32-bit words to retrieve */
117 extern xcb_atom_t prop_atoms
[ NUM_PROPS
];
118 extern xcb_atom_t prop_types
[ NUM_PROPS
];
131 EXT_SHAPE
, /* any version */
134 EXT_XFIXES
, /* requires version 2 */
139 #if USE_COMPOSITE || USE_DAMAGE || USE_RENDER || USE_SHAPE || USE_FIXES
140 #define EXTENSIONS_SIZE NUM_EXTENSIONS
142 #define EXTENSIONS_SIZE 1 /* avoid zero length arrays */
145 extern int have_extension
[ EXTENSIONS_SIZE
];
146 extern uint8_t extension_event
[ EXTENSIONS_SIZE
],
147 extension_error
[ EXTENSIONS_SIZE
];
149 enum decoration_col
{
159 COL_MENU_ACTIVE_BACK
,
160 COL_MENU_ACTIVE_FORE
,
161 COL_MENU_INACTIVE_BACK
,
162 COL_MENU_INACTIVE_FORE
,
166 extern int num_screens
;
167 extern xcb_screen_t
**screens
;
170 xcb_visualtype_t
*root_visual
;
171 xcb_atom_t wm_atom
; /* the atom WM_Sn, where n is the screen number */
172 xcb_colormap_t cmap
; /* the most recently installed colormap */
173 xcb_timestamp_t cmap_time
; /* the time at which it was installed */
174 uint32_t pixels
[ NUM_COLS
]; /* pixel values in the default cmap */
177 extern struct gwm_screen
*gwm_screens
;
205 extern xcb_cursor_t cursors
[ NUM_CURSORS
];
207 union callback_param
{
214 #define HINT_ICONIC 0x1 /* otherwise normal */
215 #define HINT_INPUT 0x2
216 #define HINT_USER_POSITION 0x4
217 #define HINT_PROGRAM_POSITION 0x8
218 #define HINT_POSITION 0xC /* HINT_USER_POSITION | HINT_PROGRAM_POSITION */
219 #define PROTOCOL_DELETE_WINDOW 0x1
220 #define PROTOCOL_TAKE_FOCUS 0x2
222 #define STATE_WITHDRAWN 0
223 #define STATE_NORMAL 1
224 #define STATE_ICONIC 3
226 #define DEC_BORDER 0x1
227 #define DEC_TITLE 0x2
228 #define DEC_DEFAULT ( DEC_BORDER | DEC_TITLE )
233 enum _gwm_window_type
{
234 WINDOW_ROOT
, WINDOW_MANAGED
, WINDOW_FRAME
, WINDOW_BUTTON
, WINDOW_MENU
,
235 WINDOW_MENUITEM
, WINDOW_FAKE
, WINDOW_FEEDBACK
, WINDOW_INCOMPLETE
,
238 xcb_rectangle_t update
; /* the area which needs updating */
239 int cleared
; /* TRUE if the update area has already been cleared */
240 union _gwm_window_union
{
241 struct _gwm_managed
{
242 struct gwm_window
*frame
;
243 uint16_t border_width
;
248 /* from WM_COLORMAP_WINDOWS: */
249 xcb_window_t cmap_window
;
251 int hints
; /* see HINT_* above */
252 /* from _NET_WM_ICON: */
254 uint32_t *full_icons
, *menu_icons
; /* pictures, screen indexed */
257 /* from WM_NAME and _NET_WM_NAME: */
258 char *name
; /* legal UTF-8; must be free()d */
260 /* from WM_NORMAL_HINTS: */
261 int min_width
, min_height
, max_width
, max_height
, width_inc
,
262 height_inc
, min_aspect_x
, min_aspect_y
, max_aspect_x
,
263 max_aspect_y
, base_width
, base_height
, win_gravity
;
264 /* from WM_PROTOCOLS: */
265 int protocols
; /* see PROTOCOL_* above */
267 int state
; /* see STATE_* above */
270 struct gwm_window
*child
, *button
;
271 int x
, y
, width
, height
;
272 int decoration
; /* see DEC_* above */
273 xcb_window_t border_regions
[ NUM_BORDER_REGIONS
];
276 struct gwm_window
*frame
;
279 xcb_window_t window_param
;
280 int num_items
, active_item
;
283 struct gwm_window
**items
; /* must be free()d */
285 struct _gwm_menuitem
{
286 struct gwm_window
*menu
;
287 char *label
; /* must be free()d */
288 void ( *action
)( struct gwm_window
*window
,
289 xcb_generic_event_t
*ev
,
290 union callback_param cp
);
291 void ( *enter_action
)( struct gwm_window
*window
,
292 xcb_generic_event_t
*ev
,
293 union callback_param cp
);
294 void ( *leave_action
)( struct gwm_window
*window
,
295 xcb_generic_event_t
*ev
,
296 union callback_param cp
);
297 union callback_param cp
;
301 xcb_timestamp_t timestamp
;
303 struct _gwm_feedback
{
304 int fb_width
, fb_height
;
306 struct _gwm_incomplete
{
307 unsigned int sequence
;
312 extern struct gwm_window
*fake_window
; /* a window created solely to hold the
315 extern const char *argv0
;
316 extern volatile int signal_caught
;
318 extern FORMAT( printf
, 1, 2 ) void warning( char *format
, ... );
319 extern FORMAT( printf
, 1, 2 ) NORETURN
void fatal( char *format
, ... );
321 /* Schedule a callback function to be invoked when a reply or error is
322 available for handling, or when neither can arrive. */
323 extern void handle_async_reply( unsigned int sequence
,
324 void ( *callback
)( unsigned int sequence
,
326 xcb_generic_error_t
*error
,
327 union callback_param p
),
328 union callback_param p
);
329 /* Block until the scheduled callback function has completed. */
330 extern void sync_with_callback( unsigned int sequence
);
332 #define ERR_MASK_REQUEST 0x000001
333 #define ERR_MASK_VALUE 0x00002
334 #define ERR_MASK_WINDOW 0x00004
335 #define ERR_MASK_PIXMAP 0x00008
336 #define ERR_MASK_ATOM 0x00010
337 #define ERR_MASK_CURSOR 0x00020
338 #define ERR_MASK_FONT 0x00040
339 #define ERR_MASK_MATCH 0x00080
340 #define ERR_MASK_DRAWABLE 0x00100
341 #define ERR_MASK_ACCESS 0x00200
342 #define ERR_MASK_ALLOC 0x00400
343 #define ERR_MASK_COLORMAP 0x00800
344 #define ERR_MASK_G_CONTEXT 0x01000
345 #define ERR_MASK_ID_CHOICE 0x02000
346 #define ERR_MASK_NAME 0x04000
347 #define ERR_MASK_LENGTH 0x08000
348 #define ERR_MASK_IMPLEMENTATION 0x10000
350 extern void handle_error_reply( xcb_void_cookie_t cookie
, unsigned ignore
);
351 extern void show_error( xcb_generic_error_t
*error
);
353 typedef void ( *event_handler
)( struct gwm_window
*window
,
354 xcb_generic_event_t
*ev
);
356 /* Return TRUE iff an event is the only button pressed. */
357 extern CONST
int initial_press( xcb_button_press_event_t
*ev
);
359 /* Return TRUE iff an event is the release of the last button (and so would
360 terminate a passive grab). */
361 extern CONST
int final_release( xcb_button_release_event_t
*ev
);
363 extern CONST xcb_timestamp_t
event_time( xcb_generic_event_t
*ev
);
365 /* The window whose event handler(s) should be invoked for pointer events.
366 Unlike pointer grabs, this mechanism is implemented entirely on the
367 client side, and has no effect on the contents of events. */
368 extern xcb_window_t pointer_demux
;
370 /* Install a window's colormap on a screen, or the default colormap if
372 extern void install_window_colormap( int screen
, struct gwm_window
*window
,
375 extern void generic_expose( struct gwm_window
*window
,
376 xcb_expose_event_t
*ev
);
378 extern void manage_window( xcb_window_t w
, int map_request
);
379 extern void unmanage_window( struct gwm_window
*window
);
381 /* A replacement for xcb_wait_for_event (which is broken, because it
382 always restarts interrupted system calls). Also invokes any
383 asynchronous callbacks scheduled for replies and errors. */
384 extern xcb_generic_event_t
*wait_for_event( void );
386 extern void ( *window_size
)( struct gwm_window
*window
, int *width
,
388 extern void ( *replace_icons
)( struct gwm_window
*window
, int num_icons
,
389 int *widths
, int *heights
, uint32_t **icons
,
390 xcb_pixmap_t
*pixmaps
);