diff options
-rw-r--r-- | include/xcwm/context.h | 1 | ||||
-rw-r--r-- | src/libxcwm/atoms.c | 72 | ||||
-rw-r--r-- | src/libxcwm/context.c | 3 | ||||
-rw-r--r-- | src/libxcwm/event_loop.c | 2 | ||||
-rw-r--r-- | src/libxcwm/window.c | 2 | ||||
-rw-r--r-- | src/libxcwm/xcwm_internal.h | 10 |
6 files changed, 70 insertions, 20 deletions
diff --git a/include/xcwm/context.h b/include/xcwm/context.h index 2385875..3d28131 100644 --- a/include/xcwm/context.h +++ b/include/xcwm/context.h @@ -47,6 +47,7 @@ typedef struct xcwm_wm_atoms_t xcwm_wm_atoms_t; /* Structure to hold connection data */ struct xcwm_context_t { xcb_connection_t *conn; + int conn_screen; xcwm_window_t *root_window; int damage_event_mask; xcwm_wm_atoms_t *atoms; diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c index 76c78ef..b1ba149 100644 --- a/src/libxcwm/atoms.c +++ b/src/libxcwm/atoms.c @@ -47,22 +47,52 @@ _xcwm_atoms_init(xcwm_context_t *context) { xcb_intern_atom_reply_t *atom_reply; xcb_intern_atom_cookie_t atom_cookie; - - /* WM_PROTOCOLS */ - atom_cookie = xcb_intern_atom(context->conn, - 0, - strlen("WM_PROTOCOLS"), - "WM_PROTOCOLS"); - atom_reply = xcb_intern_atom_reply(context->conn, - atom_cookie, - NULL); - if (!atom_reply) { - context->atoms->wm_protocols_atom = 0; - } - else { - context->atoms->wm_protocols_atom = atom_reply->atom; - free(atom_reply); - } + xcb_intern_atom_cookie_t *atom_cookies; + + /* Initialization for the xcb_ewmh connection and EWMH atoms */ + atom_cookies = xcb_ewmh_init_atoms(context->conn, + &context->atoms->ewmh_conn); + xcb_ewmh_init_atoms_replies(&context->atoms->ewmh_conn, + atom_cookies, + NULL); + + /* Set the _NET_SUPPORTED atom for this context + * Most of these are defined ast MUSTs in the + * EWMH standards for window managers. + * NOTE: Starting with only a limited set of _NET_WM_STATE. This + * may be expanded. */ + xcb_atom_t supported[] = + { + context->atoms->ewmh_conn.WM_PROTOCOLS, + context->atoms->ewmh_conn._NET_SUPPORTED, + context->atoms->ewmh_conn._NET_SUPPORTING_WM_CHECK, + context->atoms->ewmh_conn._NET_CLOSE_WINDOW, + context->atoms->ewmh_conn._NET_WM_NAME, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_TOOLBAR, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_MENU, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_UTILITY, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DROPDOWN_MENU, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_POPUP_MENU, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_TOOLTIP, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_NOTIFICATION, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_COMBO, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_DND, + context->atoms->ewmh_conn._NET_WM_WINDOW_TYPE_NORMAL, + context->atoms->ewmh_conn._NET_WM_STATE, + context->atoms->ewmh_conn._NET_WM_STATE_MODAL, + context->atoms->ewmh_conn._NET_WM_STATE_HIDDEN + }; + + xcb_ewmh_set_supported(&context->atoms->ewmh_conn, + context->conn_screen, + 21, /* Length of supported[] */ + supported); + + /* Get the ICCCM atoms we need that are not included in the + * xcb_ewmh_connetion_t. */ /* WM_DELETE_WINDOW atom */ atom_cookie = xcb_intern_atom(context->conn, @@ -146,7 +176,7 @@ _xcwm_atoms_set_wm_delete(xcwm_window_t *window) /* Get the WM_PROTOCOLS */ cookie = xcb_icccm_get_wm_protocols(window->context->conn, window->window_id, - window->context->atoms->wm_protocols_atom); + window->context->atoms->ewmh_conn.WM_PROTOCOLS); if (xcb_icccm_get_wm_protocols_reply(window->context->conn, cookie, &reply, &error) == 1) { @@ -186,3 +216,11 @@ set_window_size_hints(xcwm_window_t *window) window->sizing->width_inc = hints.width_inc; window->sizing->height_inc = hints.height_inc; } + +void +_xcwm_atoms_release(xcwm_context_t *context) +{ + + /* Free the xcb_ewmh_connection_t */ + xcb_ewmh_connection_wipe(&context->atoms->ewmh_conn); +} diff --git a/src/libxcwm/context.c b/src/libxcwm/context.c index 05a09c2..c04c02d 100644 --- a/src/libxcwm/context.c +++ b/src/libxcwm/context.c @@ -96,6 +96,7 @@ xcwm_context_open(char *display) assert(root_context->atoms); root_context->conn = conn; + root_context->conn_screen = conn_screen; root_context->root_window->parent = 0; root_context->root_window->window_id = root_window_id; /* FIXME: Should we have a circular assignment like this? */ @@ -141,6 +142,8 @@ xcwm_context_close(xcwm_context_t *context) head = _xcwm_window_list_head; } + /* Free atom related stuff */ + _xcwm_atoms_release(context); free(context->atoms); // Terminate the event loop diff --git a/src/libxcwm/event_loop.c b/src/libxcwm/event_loop.c index 8bc1bb7..6684221 100644 --- a/src/libxcwm/event_loop.c +++ b/src/libxcwm/event_loop.c @@ -366,7 +366,7 @@ run_event_loop(void *thread_arg_struct) /* If this is WM_PROTOCOLS, do not send event, just * handle internally */ - if (notify->atom == window->context->atoms->wm_protocols_atom) { + if (notify->atom == window->context->atoms->ewmh_conn.WM_PROTOCOLS) { _xcwm_atoms_set_wm_delete(window); } break; diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index cfc12f9..3aa7d94 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -260,7 +260,7 @@ xcwm_window_request_close(xcwm_window_t *window) event.response_type = XCB_CLIENT_MESSAGE; event.window = window->window_id; - event.type = window->context->atoms->wm_protocols_atom; + event.type = window->context->atoms->ewmh_conn.WM_PROTOCOLS; event.format = 32; event.data.data32[0] = window->context->atoms->wm_delete_window_atom; event.data.data32[1] = XCB_CURRENT_TIME; diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h index 1b6d414..5e083f7 100644 --- a/src/libxcwm/xcwm_internal.h +++ b/src/libxcwm/xcwm_internal.h @@ -35,6 +35,7 @@ #include <xcb/xcb.h> #include <xcb/xcb_image.h> #include <xcb/xcb_icccm.h> +#include <xcb/xcb_ewmh.h> #include <xcb/xcb_atom.h> #include <xcwm/xcwm.h> @@ -50,9 +51,9 @@ typedef struct xcwm_event_connetion { * Structure to hold WM_* atoms that we care about */ struct xcwm_wm_atoms_t { - xcb_atom_t wm_protocols_atom; xcb_atom_t wm_delete_window_atom; xcb_atom_t wm_transient_for_atom; + xcb_ewmh_connection_t ewmh_conn; }; /** @@ -309,4 +310,11 @@ _xcwm_atoms_set_window_name(xcwm_window_t *window); void _xcwm_atoms_set_wm_delete(xcwm_window_t *window); +/** + * Clean up any atom data necessary. + * @param context The context to clean up. + */ +void +_xcwm_atoms_release(xcwm_context_t *context); + #endif /* _XTOQ_INTERNAL_H_ */ |