diff options
-rw-r--r-- | event/events.c | 44 | ||||
-rw-r--r-- | event/xcb_event.h | 22 | ||||
-rw-r--r-- | icccm/icccm.c | 502 | ||||
-rw-r--r-- | icccm/xcb_icccm.h | 410 | ||||
-rw-r--r-- | property/prop.c | 60 | ||||
-rw-r--r-- | property/xcb_property.h | 18 | ||||
-rw-r--r-- | wm/manage.c | 6 | ||||
-rw-r--r-- | wm/xcb_wm.h | 4 | ||||
-rw-r--r-- | wm/xcbwm-test.c | 18 |
9 files changed, 544 insertions, 540 deletions
diff --git a/event/events.c b/event/events.c index f7d4fed..2900bd3 100644 --- a/event/events.c +++ b/event/events.c @@ -3,37 +3,37 @@ #include "xcb_event.h" -typedef struct event_handler event_handler_t; -struct event_handler { - generic_event_handler handler; - void *data; +typedef struct xcb_event_handler_t xcb_event_handler_t; +struct xcb_event_handler_t { + xcb_generic_event_handler_t handler; + void *data; }; -struct event_handlers { - event_handler_t event[126]; - event_handler_t error[256]; - xcb_connection_t *c; +struct xcb_event_handlers_t { + xcb_event_handler_t event[126]; + xcb_event_handler_t error[256]; + xcb_connection_t *c; }; -event_handlers_t *alloc_event_handlers(xcb_connection_t *c) +xcb_event_handlers_t *xcb_alloc_event_handlers(xcb_connection_t *c) { - event_handlers_t *ret = calloc(1, sizeof(event_handlers_t)); + xcb_event_handlers_t *ret = calloc(1, sizeof(xcb_event_handlers_t)); if(ret) ret->c = c; return ret; } -void free_event_handlers(event_handlers_t *evenths) +void xcb_free_event_handlers(xcb_event_handlers_t *evenths) { free(evenths); } -xcb_connection_t *get_xcb_connection(event_handlers_t *evenths) +xcb_connection_t *xcb_get_xcb_connection(xcb_event_handlers_t *evenths) { return evenths->c; } -static event_handler_t *get_event_handler(event_handlers_t *evenths, int event) +static xcb_event_handler_t *get_event_handler(xcb_event_handlers_t *evenths, int event) { assert(event < 256); event &= 0x7f; @@ -41,15 +41,15 @@ static event_handler_t *get_event_handler(event_handlers_t *evenths, int event) return &evenths->event[event - 2]; } -static event_handler_t *get_error_handler(event_handlers_t *evenths, int error) +static xcb_event_handler_t *get_error_handler(xcb_event_handlers_t *evenths, int error) { assert(error >= 0 && error < 256); return &evenths->error[error]; } -static int handle_event(event_handlers_t *evenths, xcb_generic_event_t *event) +static int handle_event(xcb_event_handlers_t *evenths, xcb_generic_event_t *event) { - event_handler_t *eventh = 0; + xcb_event_handler_t *eventh = 0; assert(event->response_type != 1); if(event->response_type == 0) @@ -62,7 +62,7 @@ static int handle_event(event_handlers_t *evenths, xcb_generic_event_t *event) return 0; } -void event_loop(event_handlers_t *evenths) +void xcb_event_loop(xcb_event_handlers_t *evenths) { xcb_generic_event_t *event; while((event = xcb_wait_for_event(evenths->c))) @@ -72,18 +72,18 @@ void event_loop(event_handlers_t *evenths) } } -static void set_handler(generic_event_handler handler, void *data, event_handler_t *place) +static void set_handler(xcb_generic_event_handler_t handler, void *data, xcb_event_handler_t *place) { - event_handler_t eventh = { handler, data }; + xcb_event_handler_t eventh = { handler, data }; *place = eventh; } -void set_event_handler(event_handlers_t *evenths, int event, generic_event_handler handler, void *data) +void xcb_set_event_handler(xcb_event_handlers_t *evenths, int event, xcb_generic_event_handler_t handler, void *data) { set_handler(handler, data, get_event_handler(evenths, event)); } -void set_error_handler(event_handlers_t *evenths, int error, generic_error_handler handler, void *data) +void xcb_set_error_handler(xcb_event_handlers_t *evenths, int error, xcb_generic_error_handler_t handler, void *data) { - set_handler((generic_event_handler) handler, data, get_error_handler(evenths, error)); + set_handler((xcb_generic_event_handler_t) handler, data, get_error_handler(evenths, error)); } diff --git a/event/xcb_event.h b/event/xcb_event.h index 9045a7e..deb7ba8 100644 --- a/event/xcb_event.h +++ b/event/xcb_event.h @@ -9,23 +9,23 @@ extern "C" { #endif -typedef struct event_handlers event_handlers_t; -event_handlers_t *alloc_event_handlers(xcb_connection_t *c); -void free_event_handlers(event_handlers_t *evenths); -xcb_connection_t *get_xcb_connection(event_handlers_t *evenths); +typedef struct xcb_event_handlers_t xcb_event_handlers_t; +xcb_event_handlers_t *xcb_alloc_event_handlers(xcb_connection_t *c); +void xcb_free_event_handlers(xcb_event_handlers_t *evenths); +xcb_connection_t *xcb_get_xcb_connection(xcb_event_handlers_t *evenths); -void event_loop(event_handlers_t *evenths); +void xcb_event_loop(xcb_event_handlers_t *evenths); -typedef int (*generic_event_handler)(void *data, xcb_connection_t *c, xcb_generic_event_t *event); -typedef int (*generic_error_handler)(void *data, xcb_connection_t *c, xcb_generic_error_t *error); +typedef int (*xcb_generic_event_handler_t)(void *data, xcb_connection_t *c, xcb_generic_event_t *event); +typedef int (*xcb_generic_error_handler_t)(void *data, xcb_connection_t *c, xcb_generic_error_t *error); -void set_event_handler(event_handlers_t *evenths, int event, generic_event_handler handler, void *data); -void set_error_handler(event_handlers_t *evenths, int error, generic_error_handler handler, void *data); +void xcb_set_event_handler(xcb_event_handlers_t *evenths, int event, xcb_generic_event_handler_t handler, void *data); +void xcb_set_error_handler(xcb_event_handlers_t *evenths, int error, xcb_generic_error_handler_t handler, void *data); #define MAKE_HANDLER(cls,lkind, ukind) \ -static inline void set_##lkind##_##cls##_handler(event_handlers_t *evenths, int (*handler)(void *, xcb_connection_t *, xcb_##lkind##_##cls##_t *), void *data) \ +static inline void set_##lkind##_##cls##_handler(xcb_event_handlers_t *evenths, int (*handler)(void *, xcb_connection_t *, xcb_##lkind##_##cls##_t *), void *data) \ { \ - set_##cls##_handler(evenths, XCB_##ukind, (generic_event_handler) handler, data); \ + xcb_set_##cls##_handler(evenths, XCB_##ukind, (xcb_generic_event_handler_t) handler, data); \ } MAKE_HANDLER(event, key_press, KEY_PRESS) diff --git a/icccm/icccm.c b/icccm/icccm.c index 969d8aa..7c51bdd 100644 --- a/icccm/icccm.c +++ b/icccm/icccm.c @@ -5,18 +5,18 @@ static int -get_text_property(xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t property, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name) +xcb_get_text_property(xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t property, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; - cookie = get_any_property(c, 0, window, property, 128); + cookie = xcb_get_any_property(c, 0, window, property, 128); reply = xcb_get_property_reply(c, cookie, 0); if(!reply) return 0; @@ -39,97 +39,97 @@ get_text_property(xcb_connection_t *c, /* WM_NAME */ void -set_wm_name (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name) +xcb_set_wm_name (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name) { xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_NAME, encoding, 8, name_len, name); } int -get_wm_name (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name) +xcb_get_wm_name (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name) { - return get_text_property(c, window, WM_NAME, format, encoding, name_len, name); + return xcb_get_text_property(c, window, WM_NAME, format, encoding, name_len, name); } void -watch_wm_name (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data) +xcb_watch_wm_name (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data) { - set_property_handler(prophs, WM_NAME, long_len, handler, data); + xcb_set_property_handler(prophs, WM_NAME, long_len, handler, data); } /* WM_ICON_NAME */ void -set_wm_icon_name (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name) +xcb_set_wm_icon_name (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name) { xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_ICON_NAME, encoding, 8, name_len, name); } int -get_wm_icon_name (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name) +xcb_get_wm_icon_name (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name) { - return get_text_property(c, window, WM_ICON_NAME, format, encoding, name_len, name); + return xcb_get_text_property(c, window, WM_ICON_NAME, format, encoding, name_len, name); } void -watch_wm_icon_name (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data) +xcb_watch_wm_icon_name (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data) { - set_property_handler(prophs, WM_ICON_NAME, long_len, handler, data); + xcb_set_property_handler(prophs, WM_ICON_NAME, long_len, handler, data); } /* WM_CLIENT_MACHINE */ void -set_wm_client_machine (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name) +xcb_set_wm_client_machine (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name) { xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_CLIENT_MACHINE, encoding, 8, name_len, name); } int -get_wm_client_machine (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name) +xcb_get_wm_client_machine (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name) { - return get_text_property(c, window, WM_CLIENT_MACHINE, format, encoding, name_len, name); + return xcb_get_text_property(c, window, WM_CLIENT_MACHINE, format, encoding, name_len, name); } void -watch_wm_client_machine (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data) +xcb_watch_wm_client_machine (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data) { - set_property_handler(prophs, WM_CLIENT_MACHINE, long_len, handler, data); + xcb_set_property_handler(prophs, WM_CLIENT_MACHINE, long_len, handler, data); } /* WM_SIZE_HINTS */ @@ -145,9 +145,9 @@ typedef enum { PAspect = 1 << 7, PBaseSize = 1 << 8, PWinGravity = 1 << 9 -} SizeHintsFlags; +} xcb_size_hints_flags_t; -struct size_hints_t { +struct xcb_size_hints_t { uint32_t flags; int32_t x, y, width, height; int32_t min_width, min_height; @@ -159,227 +159,227 @@ struct size_hints_t { uint32_t win_gravity; }; -size_hints_t * -alloc_size_hints() +xcb_size_hints_t * +xcb_alloc_size_hints() { - return calloc(1, sizeof(size_hints_t)); + return calloc(1, sizeof(xcb_size_hints_t)); } void -free_size_hints(size_hints_t *hints) +xcb_free_size_hints(xcb_size_hints_t *hints) { free(hints); } void -size_hints_get_position (size_hints_t *hints, - int32_t *x, - int32_t *y) +xcb_size_hints_get_position (xcb_size_hints_t *hints, + int32_t *x, + int32_t *y) { *x = hints->x; *y = hints->y; } void -size_hints_get_size (size_hints_t *hints, - int32_t *width, - int32_t *height) +xcb_size_hints_get_size (xcb_size_hints_t *hints, + int32_t *width, + int32_t *height) { *width = hints->width; *height = hints->height; } void -size_hints_get_min_size (size_hints_t *hints, - int32_t *min_width, - int32_t *min_height) +xcb_size_hints_get_min_size (xcb_size_hints_t *hints, + int32_t *min_width, + int32_t *min_height) { *min_width = hints->min_width; *min_height = hints->min_height; } void -size_hints_get_max_size (size_hints_t *hints, - int32_t *max_width, - int32_t *max_height) +xcb_size_hints_get_max_size (xcb_size_hints_t *hints, + int32_t *max_width, + int32_t *max_height) { *max_width = hints->max_width; *max_height = hints->max_height; } void -size_hints_get_increase (size_hints_t *hints, - int32_t *width_inc, - int32_t *height_inc) +xcb_size_hints_get_increase (xcb_size_hints_t *hints, + int32_t *width_inc, + int32_t *height_inc) { *width_inc = hints->width_inc; *height_inc = hints->height_inc; } void -size_hints_get_min_aspect (size_hints_t *hints, - int32_t *min_aspect_num, - int32_t *min_aspect_den) +xcb_size_hints_get_min_aspect (xcb_size_hints_t *hints, + int32_t *min_aspect_num, + int32_t *min_aspect_den) { *min_aspect_num = hints->min_aspect_num; *min_aspect_den = hints->min_aspect_den; } void -size_hints_get_max_aspect (size_hints_t *hints, - int32_t *max_aspect_num, - int32_t *max_aspect_den) +xcb_size_hints_get_max_aspect (xcb_size_hints_t *hints, + int32_t *max_aspect_num, + int32_t *max_aspect_den) { *max_aspect_num = hints->max_aspect_num; *max_aspect_den = hints->max_aspect_den; } void -size_hints_get_base_size (size_hints_t *hints, - int32_t *base_width, - int32_t *base_height) +xcb_size_hints_get_base_size (xcb_size_hints_t *hints, + int32_t *base_width, + int32_t *base_height) { *base_width = hints->base_width; *base_height = hints->base_height; } uint32_t -size_hints_get_win_gravity (size_hints_t *hints) +xcb_size_hints_get_win_gravity (xcb_size_hints_t *hints) { return hints->win_gravity; } uint8_t -size_hints_is_us_position (size_hints_t *hints) +xcb_size_hints_is_us_position (xcb_size_hints_t *hints) { return (hints->flags & USPosition); } uint8_t -size_hints_is_us_size (size_hints_t *hints) +xcb_size_hints_is_us_size (xcb_size_hints_t *hints) { return (hints->flags & USSize); } uint8_t -size_hints_is_p_position (size_hints_t *hints) +xcb_size_hints_is_p_position (xcb_size_hints_t *hints) { return (hints->flags & PPosition); } uint8_t -size_hints_is_p_size (size_hints_t *hints) +xcb_size_hints_is_p_size (xcb_size_hints_t *hints) { return (hints->flags & PSize); } uint8_t -size_hints_is_p_min_size (size_hints_t *hints) +xcb_size_hints_is_p_min_size (xcb_size_hints_t *hints) { return (hints->flags & PMinSize); } uint8_t -size_hints_is_p_max_size (size_hints_t *hints) +xcb_size_hints_is_p_max_size (xcb_size_hints_t *hints) { return (hints->flags & PMaxSize); } uint8_t -size_hints_is_p_resize_inc (size_hints_t *hints) +xcb_size_hints_is_p_resize_inc (xcb_size_hints_t *hints) { return (hints->flags & PResizeInc); } uint8_t -size_hints_is_p_aspect (size_hints_t *hints) +xcb_size_hints_is_p_aspect (xcb_size_hints_t *hints) { return (hints->flags & PAspect); } uint8_t -size_hints_is_p_base_size (size_hints_t *hints) +xcb_size_hints_is_p_base_size (xcb_size_hints_t *hints) { return (hints->flags & PBaseSize); } uint8_t -size_hints_is_p_win_gravity (size_hints_t *hints) +xcb_size_hints_is_p_win_gravity (xcb_size_hints_t *hints) { return (hints->flags & PWinGravity); } void -size_hints_set_flag_none (size_hints_t *hints) +xcb_size_hints_set_flag_none (xcb_size_hints_t *hints) { hints->flags = 0; } void -size_hints_set_flag_us_position (size_hints_t *hints) +xcb_size_hints_set_flag_us_position (xcb_size_hints_t *hints) { hints->flags = USPosition; } void -size_hints_set_flag_us_size (size_hints_t *hints) +xcb_size_hints_set_flag_us_size (xcb_size_hints_t *hints) { hints->flags = USSize; } void -size_hints_set_flag_p_position (size_hints_t *hints) +xcb_size_hints_set_flag_p_position (xcb_size_hints_t *hints) { hints->flags = PPosition; } void -size_hints_set_flag_p_size (size_hints_t *hints) +xcb_size_hints_set_flag_p_size (xcb_size_hints_t *hints) { hints->flags = PSize; } void -size_hints_set_flag_p_min_size (size_hints_t *hints) +xcb_size_hints_set_flag_p_min_size (xcb_size_hints_t *hints) { hints->flags = PMinSize; } void -size_hints_set_flag_p_max_size (size_hints_t *hints) +xcb_size_hints_set_flag_p_max_size (xcb_size_hints_t *hints) { hints->flags = PMaxSize; } void -size_hints_set_flag_p_resize_inc (size_hints_t *hints) +xcb_size_hints_set_flag_p_resize_inc (xcb_size_hints_t *hints) { hints->flags = PResizeInc; } void -size_hints_set_flag_p_aspect (size_hints_t *hints) +xcb_size_hints_set_flag_p_aspect (xcb_size_hints_t *hints) { hints->flags = PAspect; } void -size_hints_set_flag_p_base_size (size_hints_t *hints) +xcb_size_hints_set_flag_p_base_size (xcb_size_hints_t *hints) { hints->flags = PBaseSize; } void -size_hints_set_flag_p_win_gravity (size_hints_t *hints) +xcb_size_hints_set_flag_p_win_gravity (xcb_size_hints_t *hints) { hints->flags = PWinGravity; } void -size_hints_set_position (size_hints_t *hints, - int user_specified, - int32_t x, - int32_t y) +xcb_size_hints_set_position (xcb_size_hints_t *hints, + int user_specified, + int32_t x, + int32_t y) { hints->flags &= ~(USPosition | PPosition); if (user_specified) @@ -391,10 +391,10 @@ size_hints_set_position (size_hints_t *hints, } void -size_hints_set_size (size_hints_t *hints, - int user_specified, - int32_t width, - int32_t height) +xcb_size_hints_set_size (xcb_size_hints_t *hints, + int user_specified, + int32_t width, + int32_t height) { hints->flags &= ~(USSize | PSize); if (user_specified) @@ -406,9 +406,9 @@ size_hints_set_size (size_hints_t *hints, } void -size_hints_set_min_size (size_hints_t *hints, - int32_t min_width, - int32_t min_height) +xcb_size_hints_set_min_size (xcb_size_hints_t *hints, + int32_t min_width, + int32_t min_height) { hints->flags |= PMinSize; hints->min_width = min_width; @@ -416,9 +416,9 @@ size_hints_set_min_size (size_hints_t *hints, } void -size_hints_set_max_size (size_hints_t *hints, - int32_t max_width, - int32_t max_height) +xcb_size_hints_set_max_size (xcb_size_hints_t *hints, + int32_t max_width, + int32_t max_height) { hints->flags |= PMaxSize; hints->max_width = max_width; @@ -426,9 +426,9 @@ size_hints_set_max_size (size_hints_t *hints, } void -size_hints_set_resize_inc (size_hints_t *hints, - int32_t width_inc, - int32_t height_inc) +xcb_size_hints_set_resize_inc (xcb_size_hints_t *hints, + int32_t width_inc, + int32_t height_inc) { hints->flags |= PResizeInc; hints->width_inc = width_inc; @@ -436,11 +436,11 @@ size_hints_set_resize_inc (size_hints_t *hints, } void -size_hints_set_aspect (size_hints_t *hints, - int32_t min_aspect_num, - int32_t min_aspect_den, - int32_t max_aspect_num, - int32_t max_aspect_den) +xcb_size_hints_set_aspect (xcb_size_hints_t *hints, + int32_t min_aspect_num, + int32_t min_aspect_den, + int32_t max_aspect_num, + int32_t max_aspect_den) { hints->flags |= PAspect; hints->min_aspect_num = min_aspect_num; @@ -450,9 +450,9 @@ size_hints_set_aspect (size_hints_t *hints, } void -size_hints_set_base_size (size_hints_t *hints, - int32_t base_width, - int32_t base_height) +xcb_size_hints_set_base_size (xcb_size_hints_t *hints, + int32_t base_width, + int32_t base_height) { hints->flags |= PBaseSize; hints->base_width = base_width; @@ -460,31 +460,31 @@ size_hints_set_base_size (size_hints_t *hints, } void -size_hints_set_win_gravity (size_hints_t *hints, - uint8_t win_gravity) +xcb_size_hints_set_win_gravity (xcb_size_hints_t *hints, + uint8_t win_gravity) { hints->flags |= PWinGravity; hints->win_gravity = win_gravity; } void -set_wm_size_hints (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t property, - size_hints_t *hints) +xcb_set_wm_size_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t property, + xcb_size_hints_t *hints) { xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, property, WM_SIZE_HINTS, 32, sizeof(*hints) / 4, hints); } int -get_wm_size_hints (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t property, - size_hints_t *hints, - long *supplied) +xcb_get_wm_size_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t property, + xcb_size_hints_t *hints, + long *supplied) { xcb_get_property_cookie_t cookie; - xcb_get_property_reply_t *rep; + xcb_get_property_reply_t *rep; cookie = xcb_get_property (c, 0, window, property, WM_SIZE_HINTS, @@ -508,7 +508,7 @@ get_wm_size_hints (xcb_connection_t *c, prop = (char *)malloc(sizeof(char)*length); memcpy(prop, xcb_get_property_value (rep), length); prop[length] = '\0'; - hints = (size_hints_t *)strdup (prop); + hints = (xcb_size_hints_t *)strdup (prop); *supplied = (USPosition | USSize | PPosition | PSize | @@ -538,257 +538,257 @@ get_wm_size_hints (xcb_connection_t *c, /* WM_NORMAL_HINTS */ void -set_wm_normal_hints (xcb_connection_t *c, - xcb_window_t window, - size_hints_t *hints) +xcb_set_wm_normal_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_size_hints_t *hints) { - set_wm_size_hints(c, window, WM_NORMAL_HINTS, hints); + xcb_set_wm_size_hints(c, window, WM_NORMAL_HINTS, hints); } int -get_wm_normal_hints (xcb_connection_t *c, - xcb_window_t window, - size_hints_t *hints, - long *supplied) +xcb_get_wm_normal_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_size_hints_t *hints, + long *supplied) { - return (get_wm_size_hints (c, window, WM_NORMAL_HINTS, hints, supplied)); + return (xcb_get_wm_size_hints (c, window, WM_NORMAL_HINTS, hints, supplied)); } /* WM_HINTS */ -struct wm_hints_t { - int32_t flags; /* marks which fields in this structure are defined */ +struct xcb_wm_hints_t { + int32_t flags; /* marks which fields in this structure are defined */ uint8_t input; /* does this application rely on the window manager - to get keyboard input? */ - int32_t initial_state; /* see below */ + to get keyboard input? */ + int32_t initial_state; /* see below */ xcb_pixmap_t icon_pixmap; /* pixmap to be used as icon */ xcb_window_t icon_window; /* window to be used as icon */ - int32_t icon_x; /* initial position of icon */ - int32_t icon_y; + int32_t icon_x; /* initial position of icon */ + int32_t icon_y; xcb_pixmap_t icon_mask; /* icon mask bitmap */ xcb_window_t window_group; /* id of related window group */ /* this structure may be extended in the future */ }; typedef enum { - xcb_wm_input_hint_t = (1L << 0), - xcb_wm_state_hint_t = (1L << 1), - xcb_wm_icon_pixmap_hint_t = (1L << 2), - xcb_wm_icon_window_hint_t = (1L << 3), - xcb_wm_icon_position_hint_t = (1L << 4), - xcb_wm_icon_mask_hint_t = (1L << 5), - xcb_wm_window_group_hint_t = (1L << 6), - xcb_wmx_urgency_hint_t = (1L << 8) + XCB_WM_INPUT_HINT = (1L << 0), + XCB_WM_STATE_HINT = (1L << 1), + XCB_WM_ICON_PIXMAP_HINT = (1L << 2), + XCB_WM_ICON_WINDOW_HINT = (1L << 3), + XCB_WM_ICON_POSITION_HINT = (1L << 4), + XCB_WM_ICON_MASK_HINT = (1L << 5), + XCB_WM_WINDOW_GROUP_HINT = (1L << 6), + XCB_WM_X_URGENCY_HINT = (1L << 8) } xcb_wm_t; -#define xcb_wm_all_hints (InputHint | StateHint | IconPixmapHint | \ - IconWindowHint| IconPositionHint | IconMaskHint | \ - WindowGroupHint) +#define XCB_WM_ALL_HINTS (XCB_WM_INPUT_HINT | XCB_WM_STATE_HINT | XCB_WM_ICON_PIXMAP_HINT | \ + XCB_WM_ICON_WINDOW_HINT | XCB_WM_ICON_POSITION_HINT | XCB_WM_ICON_MASK_HINT | \ + XCB_WM_WINDOW_GROUP_HINT) -wm_hints_t * -alloc_wm_hints() +xcb_wm_hints_t * +xcb_alloc_wm_hints() { - return calloc(1, sizeof(wm_hints_t)); + return calloc(1, sizeof(xcb_wm_hints_t)); } uint8_t -wm_hints_get_input(wm_hints_t *hints) +xcb_wm_hints_get_input(xcb_wm_hints_t *hints) { return hints->input; } xcb_pixmap_t -wm_hints_get_icon_pixmap(wm_hints_t *hints) +xcb_wm_hints_get_icon_pixmap(xcb_wm_hints_t *hints) { return hints->icon_pixmap; } xcb_pixmap_t -wm_hints_get_icon_mask(wm_hints_t *hints) +xcb_wm_hints_get_icon_mask(xcb_wm_hints_t *hints) { return hints->icon_mask; } xcb_window_t -wm_hints_get_icon_window(wm_hints_t *hints) +xcb_wm_hints_get_icon_window(xcb_wm_hints_t *hints) { return hints->icon_window; } xcb_window_t -wm_hints_get_window_group(wm_hints_t *hints) +xcb_wm_hints_get_window_group(xcb_wm_hints_t *hints) { return hints->window_group; } uint8_t -wm_hints_is_input_hint(wm_hints_t *hints) +xcb_wm_hints_is_input_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_input_hint_t); + return (hints->flags & XCB_WM_INPUT_HINT); } uint8_t -wm_hints_is_state_hint(wm_hints_t *hints) +xcb_wm_hints_is_state_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_state_hint_t); + return (hints->flags & XCB_WM_STATE_HINT); } uint8_t -wm_hints_is_icon_pixmap_hint(wm_hints_t *hints) +xcb_wm_hints_is_icon_pixmap_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_icon_pixmap_hint_t); + return (hints->flags & XCB_WM_ICON_PIXMAP_HINT); } uint8_t -wm_hints_is_icon_window_hint(wm_hints_t *hints) +xcb_wm_hints_is_icon_window_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_icon_window_hint_t); + return (hints->flags & XCB_WM_ICON_WINDOW_HINT); } uint8_t -wm_hints_is_icon_position_hint(wm_hints_t *hints) +xcb_wm_hints_is_icon_position_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_icon_position_hint_t); + return (hints->flags & XCB_WM_ICON_POSITION_HINT); } uint8_t -wm_hints_is_icon_mask_hint(wm_hints_t *hints) +xcb_wm_hints_is_icon_mask_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_icon_mask_hint_t); + return (hints->flags & XCB_WM_ICON_MASK_HINT); } uint8_t -wm_hints_is_window_group_hint(wm_hints_t *hints) +xcb_wm_hints_is_window_group_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wm_window_group_hint_t); + return (hints->flags & XCB_WM_WINDOW_GROUP_HINT); } uint8_t -wm_hints_is_xu_hint(wm_hints_t *hints) +xcb_wm_hints_is_x_urgency_hint(xcb_wm_hints_t *hints) { - return (hints->flags & xcb_wmx_urgency_hint_t); + return (hints->flags & XCB_WM_X_URGENCY_HINT); } uint8_t -wm_hints_state_is_withdrawn(wm_hints_t *hints) +xcb_wm_hints_state_is_withdrawn(xcb_wm_hints_t *hints) { - return (hints->initial_state == xcb_wm_withdrawn_state_t); + return (hints->initial_state == XCB_WM_WITHDRAWN_STATE); } uint8_t -wm_hints_state_is_normal(wm_hints_t *hints) +xcb_wm_hints_state_is_normal(xcb_wm_hints_t *hints) { - return (hints->initial_state == xcb_wm_normal_state_t); + return (hints->initial_state == XCB_WM_NORMAL_STATE); } uint8_t -wm_hints_state_is_iconic(wm_hints_t *hints) +xcb_wm_hints_state_is_iconic(xcb_wm_hints_t *hints) { - return (hints->initial_state == xcb_wm_iconic_state_t); + return (hints->initial_state == XCB_WM_ICONIC_STATE); } void -wm_hints_set_input(wm_hints_t *hints, uint8_t input) +xcb_wm_hints_set_input(xcb_wm_hints_t *hints, uint8_t input) { hints->input = input; - hints->flags |= xcb_wm_input_hint_t; + hints->flags |= XCB_WM_INPUT_HINT; } void -wm_hints_set_iconic(wm_hints_t *hints) +xcb_wm_hints_set_iconic(xcb_wm_hints_t *hints) { - hints->initial_state = xcb_wm_iconic_state_t; - hints->flags |= xcb_wm_state_hint_t; + hints->initial_state = XCB_WM_ICONIC_STATE; + hints->flags |= XCB_WM_STATE_HINT; } void -wm_hints_set_normal(wm_hints_t *hints) +xcb_wm_hints_set_normal(xcb_wm_hints_t *hints) { - hints->initial_state = xcb_wm_normal_state_t; - hints->flags |= xcb_wm_state_hint_t; + hints->initial_state = XCB_WM_NORMAL_STATE; + hints->flags |= XCB_WM_STATE_HINT; } void -wm_hints_set_withdrawn(wm_hints_t *hints) +xcb_wm_hints_set_withdrawn(xcb_wm_hints_t *hints) { - hints->initial_state = xcb_wm_withdrawn_state_t; - hints->flags |= xcb_wm_state_hint_t; + hints->initial_state = XCB_WM_WITHDRAWN_STATE; + hints->flags |= XCB_WM_STATE_HINT; } void -wm_hints_set_none(wm_hints_t *hints) +xcb_wm_hints_set_none(xcb_wm_hints_t *hints) { - hints->flags &= ~xcb_wm_state_hint_t; + hints->flags &= ~XCB_WM_STATE_HINT; } void -wm_hints_set_urgent(wm_hints_t *hints) +xcb_wm_hints_set_urgent(xcb_wm_hints_t *hints) { - hints->flags |= xcb_wmx_urgency_hint_t; + hints->flags |= XCB_WM_X_URGENCY_HINT; } void -wm_hints_set_icon_pixmap(wm_hints_t *hints, xcb_pixmap_t icon_pixmap) +xcb_wm_hints_set_icon_pixmap(xcb_wm_hints_t *hints, xcb_pixmap_t icon_pixmap) { hints->icon_pixmap = icon_pixmap; - hints->flags |= xcb_wm_icon_pixmap_hint_t; + hints->flags |= XCB_WM_ICON_PIXMAP_HINT; } void -wm_hints_set_icon_mask(wm_hints_t *hints, xcb_pixmap_t icon_mask) +xcb_wm_hints_set_icon_mask(xcb_wm_hints_t *hints, xcb_pixmap_t icon_mask) { hints->icon_mask = icon_mask; - hints->flags |= xcb_wm_icon_mask_hint_t; + hints->flags |= XCB_WM_ICON_MASK_HINT; } void -wm_hints_set_icon_window(wm_hints_t *hints, xcb_window_t icon_window) +xcb_wm_hints_set_icon_window(xcb_wm_hints_t *hints, xcb_window_t icon_window) { hints->icon_window = icon_window; - hints->flags |= xcb_wm_icon_window_hint_t; + hints->flags |= XCB_WM_ICON_WINDOW_HINT; } void -wm_hints_set_window_group(wm_hints_t *hints, xcb_window_t window_group) +xcb_wm_hints_set_window_group(xcb_wm_hints_t *hints, xcb_window_t window_group) { hints->window_group = window_group; - hints->flags |= xcb_wm_window_group_hint_t; + hints->flags |= XCB_WM_WINDOW_GROUP_HINT; } void -set_wm_hints (xcb_connection_t *c, - xcb_window_t window, - wm_hints_t *hints) +xcb_set_wm_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_wm_hints_t *hints) { xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, WM_HINTS, WM_HINTS, 32, sizeof(*hints) / 4, hints); } -wm_hints_t * -get_wm_hints (xcb_connection_t *c, - xcb_window_t window) +xcb_wm_hints_t * +xcb_get_wm_hints (xcb_connection_t *c, + xcb_window_t window) { xcb_get_property_cookie_t cookie; - xcb_get_property_reply_t *rep; - wm_hints_t *hints; - char *prop; - long length; + xcb_get_property_reply_t *rep; + xcb_wm_hints_t *hints; + char *prop; + long length; cookie = xcb_get_property (c, 0, window, WM_HINTS, WM_HINTS, - 0L, NumWMHintsElements); + 0L, XCB_NUM_WM_HINTS_ELEMENTS); rep = xcb_get_property_reply (c, cookie, 0); if (!rep) return NULL; if ((rep->type != WM_HINTS) || - (rep->value_len < (NumWMHintsElements - 1)) || + (rep->value_len < (XCB_NUM_WM_HINTS_ELEMENTS - 1)) || (rep->format != 32)) { free (rep); return NULL; } - hints = (wm_hints_t *)calloc (1, (unsigned)sizeof (wm_hints_t)); + hints = (xcb_wm_hints_t *)calloc (1, (unsigned)sizeof (xcb_wm_hints_t)); if (!hints) { free (rep); @@ -798,8 +798,8 @@ get_wm_hints (xcb_connection_t *c, length = xcb_get_property_value_length (rep); prop = (char *) xcb_get_property_value (rep); prop[length] = '\0'; - hints = (wm_hints_t *)strdup (prop); - if (rep->value_len < NumWMHintsElements) + hints = (xcb_wm_hints_t *)strdup (prop); + if (rep->value_len < XCB_NUM_WM_HINTS_ELEMENTS) hints->window_group = XCB_NONE; return hints; @@ -808,10 +808,10 @@ get_wm_hints (xcb_connection_t *c, /* WM_PROTOCOLS */ void -set_wm_protocols (xcb_connection_t *c, - xcb_window_t window, - uint32_t list_len, - xcb_atom_t *list) +xcb_set_wm_protocols (xcb_connection_t *c, + xcb_window_t window, + uint32_t list_len, + xcb_atom_t *list) { intern_atom_fast_cookie_t proto; xcb_atom_t WM_PROTOCOLS; @@ -823,10 +823,10 @@ set_wm_protocols (xcb_connection_t *c, } int -get_wm_protocols (xcb_connection_t *c, - xcb_window_t window, - uint32_t *list_len, - xcb_atom_t **list) +xcb_get_wm_protocols (xcb_connection_t *c, + xcb_window_t window, + uint32_t *list_len, + xcb_atom_t **list) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *rep; diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h index 09e2e76..a8e7575 100644 --- a/icccm/xcb_icccm.h +++ b/icccm/xcb_icccm.h @@ -12,238 +12,238 @@ extern "C" { /* WM_NAME */ -void set_wm_name (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name); - -int get_wm_name (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name); - -void watch_wm_name (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data); +void xcb_set_wm_name (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name); + +int xcb_get_wm_name (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name); + +void xcb_watch_wm_name (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data); /* WM_ICON_NAME */ -void set_wm_icon_name (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name); +void xcb_set_wm_icon_name (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name); -int get_wm_icon_name (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name); +int xcb_get_wm_icon_name (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name); -void watch_wm_icon_name (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data); +void xcb_watch_wm_icon_name (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data); /* WM_CLIENT_MACHINE */ -void set_wm_client_machine (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t encoding, - uint32_t name_len, - const char *name); +void xcb_set_wm_client_machine (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t encoding, + uint32_t name_len, + const char *name); -int get_wm_client_machine (xcb_connection_t *c, - xcb_window_t window, - uint8_t *format, - xcb_atom_t *encoding, - uint32_t *name_len, - char **name); +int xcb_get_wm_client_machine (xcb_connection_t *c, + xcb_window_t window, + uint8_t *format, + xcb_atom_t *encoding, + uint32_t *name_len, + char **name); -void watch_wm_client_machine (property_handlers_t *prophs, - uint32_t long_len, - generic_property_handler handler, - void *data); +void xcb_watch_wm_client_machine (xcb_property_handlers_t *prophs, + uint32_t long_len, + xcb_generic_property_handler_t handler, + void *data); /* WM_SIZE_HINTS */ -typedef struct size_hints_t size_hints_t; - -size_hints_t *alloc_size_hints (); - -void free_size_hints (size_hints_t *hints); - -void size_hints_get_position (size_hints_t *hints, - int32_t *x, - int32_t *y); -void size_hints_get_size (size_hints_t *hints, - int32_t *width, - int32_t *height); -void size_hints_get_min_size (size_hints_t *hints, - int32_t *min_width, - int32_t *min_height); -void size_hints_get_max_size (size_hints_t *hints, - int32_t *max_width, - int32_t *max_height); -void size_hints_get_increase (size_hints_t *hints, - int32_t *width_inc, - int32_t *height_inc); -void size_hints_get_min_aspect (size_hints_t *hints, - int32_t *min_aspect_num, - int32_t *min_aspect_den); -void size_hints_get_max_aspect (size_hints_t *hints, - int32_t *max_aspect_num, - int32_t *max_aspect_den); -void size_hints_get_base_size (size_hints_t *hints, - int32_t *base_width, - int32_t *base_height); -uint32_t size_hints_get_win_gravity (size_hints_t *hints); - -uint8_t size_hints_is_us_position (size_hints_t *hints); -uint8_t size_hints_is_us_size (size_hints_t *hints); -uint8_t size_hints_is_p_position (size_hints_t *hints); -uint8_t size_hints_is_p_size (size_hints_t *hints); -uint8_t size_hints_is_p_min_size (size_hints_t *hints); -uint8_t size_hints_is_p_max_size (size_hints_t *hints); -uint8_t size_hints_is_p_resize_inc (size_hints_t *hints); -uint8_t size_hints_is_p_aspect (size_hints_t *hints); -uint8_t size_hints_is_p_base_size (size_hints_t *hints); -uint8_t size_hints_is_p_win_gravity (size_hints_t *hints); - -void size_hints_set_flag_none (size_hints_t *hints); -void size_hints_set_flag_us_position (size_hints_t *hints); -void size_hints_set_flag_us_size (size_hints_t *hints); -void size_hints_set_flag_p_position (size_hints_t *hints); -void size_hints_set_flag_p_size (size_hints_t *hints); -void size_hints_set_flag_p_min_size (size_hints_t *hints); -void size_hints_set_flag_p_max_size (size_hints_t *hints); -void size_hints_set_flag_p_resize_inc (size_hints_t *hints); -void size_hints_set_flag_p_aspect (size_hints_t *hints); -void size_hints_set_flag_p_base_size (size_hints_t *hints); -void size_hints_set_flag_p_win_gravity (size_hints_t *hints); - -void size_hints_set_position (size_hints_t *hints, - int user_specified, - int32_t x, - int32_t y); - -void size_hints_set_size (size_hints_t *hints, - int user_specified, - int32_t width, - int32_t height); - -void size_hints_set_min_size (size_hints_t *hints, - int32_t min_width, - int32_t min_height); - -void size_hints_set_max_size (size_hints_t *hints, - int32_t max_width, - int32_t max_height); - -void size_hints_set_resize_inc (size_hints_t *hints, - int32_t width_inc, - int32_t height_inc); - -void size_hints_set_aspect (size_hints_t *hints, - int32_t min_aspect_num, - int32_t min_aspect_den, - int32_t max_aspect_num, - int32_t max_aspect_den); - -void size_hints_set_base_size (size_hints_t *hints, - int32_t base_width, - int32_t base_height); - -void size_hints_set_win_gravity (size_hints_t *hints, - uint8_t win_gravity); - -void set_wm_size_hints (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t property, - size_hints_t *hints); - -int get_wm_size_hints (xcb_connection_t *c, - xcb_window_t window, - xcb_atom_t property, - size_hints_t *hints, - long *supplied); +typedef struct xcb_size_hints_t xcb_size_hints_t; + +xcb_size_hints_t *xcb_alloc_size_hints (); + +void xcb_free_size_hints (xcb_size_hints_t *hints); + +void xcb_size_hints_get_position (xcb_size_hints_t *hints, + int32_t *x, + int32_t *y); +void xcb_size_hints_get_size (xcb_size_hints_t *hints, + int32_t *width, + int32_t *height); +void xcb_size_hints_get_min_size (xcb_size_hints_t *hints, + int32_t *min_width, + int32_t *min_height); +void xcb_size_hints_get_max_size (xcb_size_hints_t *hints, + int32_t *max_width, + int32_t *max_height); +void xcb_size_hints_get_increase (xcb_size_hints_t *hints, + int32_t *width_inc, + int32_t *height_inc); +void xcb_size_hints_get_min_aspect (xcb_size_hints_t *hints, + int32_t *min_aspect_num, + int32_t *min_aspect_den); +void xcb_size_hints_get_max_aspect (xcb_size_hints_t *hints, + int32_t *max_aspect_num, + int32_t *max_aspect_den); +void xcb_size_hints_get_base_size (xcb_size_hints_t *hints, + int32_t *base_width, + int32_t *base_height); +uint32_t xcb_size_hints_get_win_gravity (xcb_size_hints_t *hints); + +uint8_t xcb_size_hints_is_us_position (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_us_size (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_position (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_size (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_min_size (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_max_size (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_resize_inc (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_aspect (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_base_size (xcb_size_hints_t *hints); +uint8_t xcb_size_hints_is_p_win_gravity (xcb_size_hints_t *hints); + +void xcb_size_hints_set_flag_none (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_us_position (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_us_size (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_position (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_size (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_min_size (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_max_size (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_resize_inc (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_aspect (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_base_size (xcb_size_hints_t *hints); +void xcb_size_hints_set_flag_p_win_gravity (xcb_size_hints_t *hints); + +void xcb_size_hints_set_position (xcb_size_hints_t *hints, + int user_specified, + int32_t x, + int32_t y); + +void xcb_size_hints_set_size (xcb_size_hints_t *hints, + int user_specified, + int32_t width, + int32_t height); + +void xcb_size_hints_set_min_size (xcb_size_hints_t *hints, + int32_t min_width, + int32_t min_height); + +void xcb_size_hints_set_max_size (xcb_size_hints_t *hints, + int32_t max_width, + int32_t max_height); + +void xcb_size_hints_set_resize_inc (xcb_size_hints_t *hints, + int32_t width_inc, + int32_t height_inc); + +void xcb_size_hints_set_aspect (xcb_size_hints_t *hints, + int32_t min_aspect_num, + int32_t min_aspect_den, + int32_t max_aspect_num, + int32_t max_aspect_den); + +void xcb_size_hints_set_base_size (xcb_size_hints_t *hints, + int32_t base_width, + int32_t base_height); + +void xcb_size_hints_set_win_gravity (xcb_size_hints_t *hints, + uint8_t win_gravity); + +void xcb_set_wm_size_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t property, + xcb_size_hints_t *hints); + +int xcb_get_wm_size_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_atom_t property, + xcb_size_hints_t *hints, + long *supplied); /* WM_NORMAL_HINTS */ -void set_wm_normal_hints (xcb_connection_t *c, - xcb_window_t window, - size_hints_t *hints); +void xcb_set_wm_normal_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_size_hints_t *hints); -int get_wm_normal_hints (xcb_connection_t *c, - xcb_window_t window, - size_hints_t *hints, - long *supplied); +int xcb_get_wm_normal_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_size_hints_t *hints, + long *supplied); /* WM_HINTS */ -typedef struct wm_hints_t wm_hints_t; -#define NumWMHintsElements 9 /* number of elements in this structure */ +typedef struct xcb_wm_hints_t xcb_wm_hints_t; +#define XCB_NUM_WM_HINTS_ELEMENTS 9 /* number of elements in this structure */ typedef enum { - xcb_wm_withdrawn_state_t = 0, - xcb_wm_normal_state_t = 1, - xcb_wm_iconic_state_t = 3 + XCB_WM_WITHDRAWN_STATE = 0, + XCB_WM_NORMAL_STATE = 1, + XCB_WM_ICONIC_STATE = 3 } xcb_wm_state_t; -wm_hints_t *alloc_wm_hints(); - -uint8_t wm_hints_get_input (wm_hints_t *hints); -xcb_pixmap_t wm_hints_get_icon_pixmap (wm_hints_t *hints); -xcb_pixmap_t wm_hints_get_icon_mask (wm_hints_t *hints); -xcb_window_t wm_hints_get_icon_window (wm_hints_t *hints); -xcb_window_t wm_hints_get_window_group (wm_hints_t *hints); - -uint8_t wm_hints_is_input_hint (wm_hints_t *hints); -uint8_t wm_hints_is_state_hint (wm_hints_t *hints); -uint8_t wm_hints_is_icon_pixmap_hint (wm_hints_t *hints); -uint8_t wm_hints_is_icon_window_hint (wm_hints_t *hints); -uint8_t wm_hints_is_icon_position_hint (wm_hints_t *hints); -uint8_t wm_hints_is_icon_mask_hint (wm_hints_t *hints); -uint8_t wm_hints_is_window_group_hint (wm_hints_t *hints); -uint8_t wm_hints_is_xu_hint (wm_hints_t *hints); - -uint8_t wm_hints_state_is_withdrawn (wm_hints_t *hints); -uint8_t wm_hints_state_is_normal (wm_hints_t *hints); -uint8_t wm_hints_state_is_iconic (wm_hints_t *hints); - -void wm_hints_set_input (wm_hints_t *hints, uint8_t input); -void wm_hints_set_iconic (wm_hints_t *hints); -void wm_hints_set_normal (wm_hints_t *hints); -void wm_hints_set_withdrawn (wm_hints_t *hints); -void wm_hints_set_none (wm_hints_t *hints); -void wm_hints_set_urgent (wm_hints_t *hints); -void wm_hints_set_icon_pixmap (wm_hints_t *hints, xcb_pixmap_t icon_pixmap); -void wm_hints_set_icon_mask (wm_hints_t *hints, xcb_pixmap_t icon_mask); -void wm_hints_set_icon_window (wm_hints_t *hints, xcb_window_t icon_window); -void wm_hints_set_window_group (wm_hints_t *hints, xcb_window_t window_group); - -void set_wm_hints (xcb_connection_t *c, - xcb_window_t window, - wm_hints_t *hints); - -wm_hints_t *get_wm_hints (xcb_connection_t *c, - xcb_window_t window); +xcb_wm_hints_t *alloc_wm_hints(); + +uint8_t xcb_wm_hints_get_input (xcb_wm_hints_t *hints); +xcb_pixmap_t xcb_wm_hints_get_icon_pixmap (xcb_wm_hints_t *hints); +xcb_pixmap_t xcb_wm_hints_get_icon_mask (xcb_wm_hints_t *hints); +xcb_window_t xcb_wm_hints_get_icon_window (xcb_wm_hints_t *hints); +xcb_window_t xcb_wm_hints_get_window_group (xcb_wm_hints_t *hints); + +uint8_t xcb_wm_hints_is_input_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_state_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_icon_pixmap_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_icon_window_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_icon_position_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_icon_mask_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_window_group_hint (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_is_x_urgency_hint (xcb_wm_hints_t *hints); + +uint8_t xcb_wm_hints_state_is_withdrawn (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_state_is_normal (xcb_wm_hints_t *hints); +uint8_t xcb_wm_hints_state_is_iconic (xcb_wm_hints_t *hints); + +void xcb_wm_hints_set_input (xcb_wm_hints_t *hints, uint8_t input); +void xcb_wm_hints_set_iconic (xcb_wm_hints_t *hints); +void xcb_wm_hints_set_normal (xcb_wm_hints_t *hints); +void xcb_wm_hints_set_withdrawn (xcb_wm_hints_t *hints); +void xcb_wm_hints_set_none (xcb_wm_hints_t *hints); +void xcb_wm_hints_set_urgent (xcb_wm_hints_t *hints); +void xcb_wm_hints_set_icon_pixmap (xcb_wm_hints_t *hints, xcb_pixmap_t icon_pixmap); +void xcb_wm_hints_set_icon_mask (xcb_wm_hints_t *hints, xcb_pixmap_t icon_mask); +void xcb_wm_hints_set_icon_window (xcb_wm_hints_t *hints, xcb_window_t icon_window); +void xcb_wm_hints_set_window_group (xcb_wm_hints_t *hints, xcb_window_t window_group); + +void xcb_set_wm_hints (xcb_connection_t *c, + xcb_window_t window, + xcb_wm_hints_t *hints); + +xcb_wm_hints_t *xcb_get_wm_hints (xcb_connection_t *c, + xcb_window_t window); /* WM_PROTOCOLS */ -void set_wm_protocols (xcb_connection_t *c, - xcb_window_t window, - uint32_t list_len, - xcb_atom_t *list); -int get_wm_protocols (xcb_connection_t *c, - xcb_window_t window, - uint32_t *list_len, - xcb_atom_t **list); +void xcb_set_wm_protocols (xcb_connection_t *c, + xcb_window_t window, + uint32_t list_len, + xcb_atom_t *list); +int xcb_get_wm_protocols (xcb_connection_t *c, + xcb_window_t window, + uint32_t *list_len, + xcb_atom_t **list); #define HAS_DISCRIMINATED_NAME 0 #if HAS_DISCRIMINATED_NAME diff --git a/property/prop.c b/property/prop.c index 174c420..d6b8986 100644 --- a/property/prop.c +++ b/property/prop.c @@ -4,37 +4,39 @@ #include "xcb_property.h" typedef struct { - uint32_t long_len; - generic_property_handler handler; - void *data; + uint32_t long_len; + xcb_generic_property_handler_t handler; + void *data; } prop_handler_t; typedef struct node node; struct node { - node *next; - xcb_atom_t name; + node *next; + xcb_atom_t name; prop_handler_t h; }; -struct property_handlers { - node *head; - prop_handler_t *def; - event_handlers_t *evenths; +struct xcb_property_handlers { + node *head; + prop_handler_t *def; + xcb_event_handlers_t *evenths; }; -xcb_get_property_cookie_t get_any_property(xcb_connection_t *c, uint8_t del, xcb_window_t window, xcb_atom_t name, uint32_t long_len) +xcb_get_property_cookie_t xcb_get_any_property(xcb_connection_t *c, uint8_t del, xcb_window_t window, xcb_atom_t name, uint32_t long_len) { - static const xcb_atom_t type = { XCB_GET_PROPERTY_TYPE_ANY }; + static const xcb_atom_t type = XCB_GET_PROPERTY_TYPE_ANY; + return xcb_get_property(c, del, window, name, type, 0, long_len); } static int call_handler(xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, prop_handler_t *h) { xcb_get_property_reply_t *propr = 0; - int ret; + int ret; + if(state != XCB_PROPERTY_DELETE) { - xcb_get_property_cookie_t cookie = get_any_property(c, 0, window, atom, h->long_len); + xcb_get_property_cookie_t cookie = xcb_get_any_property(c, 0, window, atom, h->long_len); propr = xcb_get_property_reply(c, cookie, 0); } ret = h->handler(h->data, c, state, window, atom, propr); @@ -42,10 +44,11 @@ static int call_handler(xcb_connection_t *c, uint8_t state, xcb_window_t window, return ret; } -int property_changed(property_handlers_t *prophs, uint8_t state, xcb_window_t window, xcb_atom_t atom) +int xcb_property_changed(xcb_property_handlers_t *prophs, uint8_t state, xcb_window_t window, xcb_atom_t atom) { - xcb_connection_t *c = get_xcb_connection(get_property_event_handlers(prophs)); - node *cur; + xcb_connection_t *c = xcb_get_xcb_connection(xcb_get_property_event_handlers(prophs)); + node *cur; + for(cur = prophs->head; cur; cur = cur->next) if(cur->name == atom) return call_handler(c, state, window, atom, &cur->h); @@ -56,17 +59,18 @@ int property_changed(property_handlers_t *prophs, uint8_t state, xcb_window_t wi static int handle_property_notify_event(void *data, xcb_connection_t *c, xcb_property_notify_event_t *e) { - property_handlers_t *prophs = data; - uint8_t state = e->state; - xcb_window_t window = e->window; - xcb_atom_t atom = e->atom; + xcb_property_handlers_t *prophs = data; + uint8_t state = e->state; + xcb_window_t window = e->window; + xcb_atom_t atom = e->atom; - return property_changed(prophs, state, window, atom); + return xcb_property_changed(prophs, state, window, atom); } -property_handlers_t *alloc_property_handlers(event_handlers_t *evenths) +xcb_property_handlers_t *xcb_alloc_property_handlers(xcb_event_handlers_t *evenths) { - property_handlers_t *prophs = malloc(sizeof(property_handlers_t)); + xcb_property_handlers_t *prophs = malloc(sizeof(xcb_property_handlers_t)); + if(prophs) { prophs->head = 0; @@ -77,24 +81,24 @@ property_handlers_t *alloc_property_handlers(event_handlers_t *evenths) return prophs; } -void free_property_handlers(property_handlers_t *prophs) +void xcb_free_property_handlers(xcb_property_handlers_t *prophs) { free(prophs); } -event_handlers_t *get_property_event_handlers(property_handlers_t *prophs) +xcb_event_handlers_t *xcb_get_property_event_handlers(xcb_property_handlers_t *prophs) { return prophs->evenths; } -static inline void set_prop_handler(prop_handler_t *cur, uint32_t long_len, generic_property_handler handler, void *data) +static inline void set_prop_handler(prop_handler_t *cur, uint32_t long_len, xcb_generic_property_handler_t handler, void *data) { cur->long_len = long_len; cur->handler = handler; cur->data = data; } -int set_property_handler(property_handlers_t *prophs, xcb_atom_t name, uint32_t long_len, generic_property_handler handler, void *data) +int xcb_set_property_handler(xcb_property_handlers_t *prophs, xcb_atom_t name, uint32_t long_len, xcb_generic_property_handler_t handler, void *data) { node *cur = malloc(sizeof(node)); if(!cur) @@ -106,7 +110,7 @@ int set_property_handler(property_handlers_t *prophs, xcb_atom_t name, uint32_t return 1; } -int set_default_property_handler(property_handlers_t *prophs, uint32_t long_len, generic_property_handler handler, void *data) +int xcb_set_default_property_handler(xcb_property_handlers_t *prophs, uint32_t long_len, xcb_generic_property_handler_t handler, void *data) { assert(!prophs->def); prophs->def = malloc(sizeof(prop_handler_t)); diff --git a/property/xcb_property.h b/property/xcb_property.h index 411c2a8..6c90d92 100644 --- a/property/xcb_property.h +++ b/property/xcb_property.h @@ -9,20 +9,20 @@ extern "C" { #endif -xcb_get_property_cookie_t get_any_property(xcb_connection_t *c, uint8_t del, xcb_window_t window, xcb_atom_t name, uint32_t long_len); +xcb_get_property_cookie_t xcb_get_any_property(xcb_connection_t *c, uint8_t del, xcb_window_t window, xcb_atom_t name, uint32_t long_len); -typedef struct property_handlers property_handlers_t; +typedef struct xcb_property_handlers xcb_property_handlers_t; -property_handlers_t *alloc_property_handlers(event_handlers_t *evenths); -void free_property_handlers(property_handlers_t *prophs); -event_handlers_t *get_property_event_handlers(property_handlers_t *prophs); +xcb_property_handlers_t *xcb_alloc_property_handlers(xcb_event_handlers_t *evenths); +void xcb_free_property_handlers(xcb_property_handlers_t *prophs); +xcb_event_handlers_t *xcb_get_property_event_handlers(xcb_property_handlers_t *prophs); -typedef int (*generic_property_handler)(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property); +typedef int (*xcb_generic_property_handler_t)(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property); -int set_property_handler(property_handlers_t *prophs, xcb_atom_t name, uint32_t long_len, generic_property_handler handler, void *data); -int set_default_property_handler(property_handlers_t *prophs, uint32_t long_len, generic_property_handler handler, void *data); +int xcb_set_property_handler(xcb_property_handlers_t *prophs, xcb_atom_t name, uint32_t long_len, xcb_generic_property_handler_t handler, void *data); +int xcb_set_default_property_handler(xcb_property_handlers_t *prophs, uint32_t long_len, xcb_generic_property_handler_t handler, void *data); -int property_changed(property_handlers_t *prophs, uint8_t state, xcb_window_t window, xcb_atom_t atom); +int xcb_property_changed(xcb_property_handlers_t *prophs, uint8_t state, xcb_window_t window, xcb_atom_t atom); #ifdef __cplusplus diff --git a/wm/manage.c b/wm/manage.c index bd10d22..bbae308 100644 --- a/wm/manage.c +++ b/wm/manage.c @@ -5,7 +5,7 @@ table_t *byChild = 0; table_t *byParent = 0; -void manage_window(property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa) +void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa) { xcb_drawable_t d = { window }; xcb_get_geometry_cookie_t geomc; @@ -48,7 +48,7 @@ void manage_window(property_handlers_t *prophs, xcb_connection_t *c, xcb_window_ if(attr && geom) { reparent_window(c, window, attr->visual, geom->root, geom->depth, geom->x, geom->y, geom->width, geom->height); - property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NAME); + xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NAME); } free(attr); free(geom); @@ -84,7 +84,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_ return 1; } -void manage_existing_windows(xcb_connection_t *c, property_handlers_t *prophs, xcb_window_t root) +void manage_existing_windows(xcb_connection_t *c, xcb_property_handlers_t *prophs, xcb_window_t root) { xcb_query_tree_cookie_t wintree; xcb_query_tree_reply_t *rep; diff --git a/wm/xcb_wm.h b/wm/xcb_wm.h index 4d1c0c6..8446071 100644 --- a/wm/xcb_wm.h +++ b/wm/xcb_wm.h @@ -31,10 +31,10 @@ typedef struct { } u; } window_attributes_t; -void manage_window(property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa); +void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *c, xcb_window_t window, window_attributes_t wa); int handle_map_notify_event(void *prophs, xcb_connection_t *c, xcb_map_notify_event_t *e); int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_event_t *e); -void manage_existing_windows(xcb_connection_t *c, property_handlers_t *prophs, xcb_window_t root); +void manage_existing_windows(xcb_connection_t *c, xcb_property_handlers_t *prophs, xcb_window_t root); typedef struct table_t table_t; diff --git a/wm/xcbwm-test.c b/wm/xcbwm-test.c index a596f75..4d8be5d 100644 --- a/wm/xcbwm-test.c +++ b/wm/xcbwm-test.c @@ -176,8 +176,8 @@ static int handleWMNameChange(void *data, xcb_connection_t *c, uint8_t state, xc int main(int argc, char **argv) { xcb_connection_t *c; - event_handlers_t *evenths; - property_handlers_t *prophs; + xcb_event_handlers_t *evenths; + xcb_property_handlers_t *prophs; xcb_window_t root; pthread_t event_thread; int screen_nbr; @@ -188,24 +188,24 @@ int main(int argc, char **argv) c = xcb_connect(NULL, &screen_nbr); - evenths = alloc_event_handlers(c); + evenths = xcb_alloc_event_handlers(c); for(i = 2; i < 128; ++i) - set_event_handler(evenths, i, handleEvent, 0); + xcb_set_event_handler(evenths, i, handleEvent, 0); for(i = 0; i < 256; ++i) - set_error_handler(evenths, i, (generic_error_handler) handleEvent, 0); + xcb_set_error_handler(evenths, i, (xcb_generic_error_handler_t) handleEvent, 0); set_button_press_event_handler(evenths, handleButtonPressEvent, 0); set_button_release_event_handler(evenths, handleButtonReleaseEvent, 0); set_unmap_notify_event_handler(evenths, handle_unmap_notify_event, 0); set_expose_event_handler(evenths, handleExposeEvent, 0); - prophs = alloc_property_handlers(evenths); + prophs = xcb_alloc_property_handlers(evenths); set_map_notify_event_handler(evenths, handle_map_notify_event, prophs); - watch_wm_name(prophs, 40, handleWMNameChange, 0); + xcb_watch_wm_name(prophs, 40, handleWMNameChange, 0); if(TEST_THREADS) { - pthread_create(&event_thread, 0, (void *(*)(void *))event_loop, evenths); + pthread_create(&event_thread, 0, (void *(*)(void *))xcb_event_loop, evenths); } root = xcb_aux_get_screen(c, screen_nbr)->root; @@ -223,7 +223,7 @@ int main(int argc, char **argv) if(TEST_THREADS) pthread_join(event_thread, 0); else - event_loop(evenths); + xcb_event_loop(evenths); exit(0); /*NOTREACHED*/ |