diff options
author | Jess VanDerwalker <washu@sonic.net> | 2012-07-25 13:49:03 -0700 |
---|---|---|
committer | Jess VanDerwalker <washu@sonic.net> | 2012-07-26 22:23:13 -0700 |
commit | 6433adaa86b8f3c187bf5cca5bd7789209881558 (patch) | |
tree | 7cacf23c4183b73745b61b933dee24962a2e644a | |
parent | dae084822ed137c854599e25ab1a660e29b98e56 (diff) |
libxcwm: Propery change notification for WM_DELETE handled.
Windows may set WM_DELETE after being mapped, so
XCB_EVENT_MASK_PROPERTY_CHANGE event mask set on all newly created
windows so we can get notification. XCB_PROPERTY_NOTIFY case added to
event loop to catch propery change events.
In window.c set_wm_delete_win_in_context changed to
_xcwm_window_set_wm_delete as it is now a function that is called
across modules.
XCB_PROPERTY_NOTIFY handles case where WM_PROTOCOLS has changed, then
calls _xcwm_window_set_wm_delete to determine if WM_DELETE atom has
changed.
Signed-off-by: Jess VanDerwalker <washu@sonic.net>
-rw-r--r-- | src/libxcwm/event_loop.c | 18 | ||||
-rw-r--r-- | src/libxcwm/window.c | 24 | ||||
-rw-r--r-- | src/libxcwm/xcwm_internal.h | 9 |
3 files changed, 45 insertions, 6 deletions
diff --git a/src/libxcwm/event_loop.c b/src/libxcwm/event_loop.c index cb3d2c1..6d55a71 100644 --- a/src/libxcwm/event_loop.c +++ b/src/libxcwm/event_loop.c @@ -353,6 +353,24 @@ run_event_loop(void *thread_arg_struct) break; } + case XCB_PROPERTY_NOTIFY: + { + xcb_property_notify_event_t *notify = + (xcb_property_notify_event_t *)evt; + xcwm_window_t *window = + _xcwm_get_window_node_by_window_id(notify->window); + if (!window) { + break; + } + + /* If this is WM_PROTOCOLS, do not send event, just + * handle internally */ + if (notify->atom == _wm_atoms->wm_protocols_atom) { + _xcwm_window_set_wm_delete(event_conn, window); + } + break; + } + case XCB_KEY_PRESS: { printf("X Key press from xserver-"); diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index 496f507..140673a 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -41,13 +41,13 @@ void set_icccm_properties(xcb_connection_t *conn, xcwm_window_t *window); -/* Set the WM_NAME property in context */ +/* Set the event masks on a window */ void -set_wm_name_in_context(xcb_connection_t *conn, xcwm_window_t *window); +set_window_event_masks(xcb_connection_t *conn, xcwm_window_t *window); -/* Find out of the WM_DELETE_WINDOW property is set */ +/* Set the WM_NAME property in context */ void -set_wm_delete_win_in_context(xcb_connection_t *conn, xcwm_window_t *window); +set_wm_name_in_context(xcb_connection_t *conn, xcwm_window_t *window); /* Determine values of window WM_SIZE_HINTS */ void @@ -153,6 +153,9 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window, } free(attrs); + /* Set the event masks for the window */ + set_window_event_masks(context->conn, window); + /* Set the ICCCM properties we care about */ set_icccm_properties(context->conn, window); @@ -414,6 +417,15 @@ _xcwm_map_window(xcb_connection_t *conn, xcwm_window_t *window) } void +set_window_event_masks(xcb_connection_t *conn, xcwm_window_t *window) +{ + uint32_t values[1] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; + + xcb_change_window_attributes(conn, window->window_id, + XCB_CW_EVENT_MASK, values); +} + +void set_icccm_properties(xcb_connection_t *conn, xcwm_window_t *window) { xcb_get_property_cookie_t cookie; @@ -422,7 +434,7 @@ set_icccm_properties(xcb_connection_t *conn, xcwm_window_t *window) uint8_t success; set_wm_name_in_context(conn, window); - set_wm_delete_win_in_context(conn, window); + _xcwm_window_set_wm_delete(conn, window); set_wm_size_hints_for_window(conn, window); /* Get the window this one is transient for */ @@ -461,7 +473,7 @@ set_wm_name_in_context(xcb_connection_t *conn, xcwm_window_t *window) } void -set_wm_delete_win_in_context(xcb_connection_t *conn, xcwm_window_t *window) +_xcwm_window_set_wm_delete(xcb_connection_t *conn, xcwm_window_t *window) { xcb_get_property_cookie_t cookie; xcb_icccm_get_wm_protocols_reply_t reply; diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h index ab149e5..19478df 100644 --- a/src/libxcwm/xcwm_internal.h +++ b/src/libxcwm/xcwm_internal.h @@ -285,4 +285,13 @@ _xcwm_resize_window(xcb_connection_t *conn, xcb_window_t window, int width, void _xcwm_map_window(xcb_connection_t *conn, xcwm_window_t *window); +/** + * Set the WM_DELETE ICCCM protocol for the window. + * @param conn The connection to xserver + * @param window The window to set wm_delete_set flag on. + */ +void +_xcwm_window_set_wm_delete(xcb_connection_t *conn, xcwm_window_t *window); + + #endif /* _XTOQ_INTERNAL_H_ */ |