From 795144584907ab048f3bb2909334b33195042ee6 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 17 Aug 2011 01:41:19 +0200 Subject: [PATCH] =?utf8?q?xcb:=20use=20predefined=20XCB=5FATOM=5F=20atoms,?= =?utf8?q?=20don=E2=80=99t=20request=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- include/atoms.xmacro | 9 --------- include/xcb_compat.h | 10 ++++++++++ src/con.c | 2 +- src/ewmh.c | 8 ++++---- src/handlers.c | 12 ++++++------ src/main.c | 4 ++-- src/manage.c | 6 +++--- src/x.c | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/atoms.xmacro b/include/atoms.xmacro index 9b5a132c..300a8aba 100644 --- a/include/atoms.xmacro +++ b/include/atoms.xmacro @@ -21,14 +21,5 @@ xmacro(UTF8_STRING) xmacro(WM_STATE) xmacro(WM_CLIENT_LEADER) xmacro(WM_TAKE_FOCUS) -xmacro(WM_HINTS) -xmacro(WM_NORMAL_HINTS) -xmacro(WM_TRANSIENT_FOR) -xmacro(ATOM) -xmacro(WINDOW) -xmacro(WM_NAME) -xmacro(WM_CLASS) -xmacro(STRING) -xmacro(CARDINAL) xmacro(I3_SOCKET_PATH) xmacro(I3_CONFIG_PATH) diff --git a/include/xcb_compat.h b/include/xcb_compat.h index c00e2663..ec872a3a 100644 --- a/include/xcb_compat.h +++ b/include/xcb_compat.h @@ -22,4 +22,14 @@ #define xcb_icccm_wm_hints_get_urgency xcb_wm_hints_get_urgency #define xcb_icccm_get_wm_transient_for_from_reply xcb_get_wm_transient_for_from_reply +#define XCB_ATOM_CARDINAL CARDINAL +#define XCB_ATOM_WINDOW WINDOW +#define XCB_ATOM_WM_TRANSIENT_FOR WM_TRANSIENT_FOR +#define XCB_ATOM_WM_NAME WM_NAME +#define XCB_ATOM_WM_CLASS WM_CLASS +#define XCB_ATOM_WM_HINTS WM_HINTS +#define XCB_ATOM_ATOM ATOM +#define XCB_ATOM_WM_NORMAL_HINTS WM_NORMAL_HINTS +#define XCB_ATOM_STRING STRING + #endif diff --git a/src/con.c b/src/con.c index b867e964..5c5099c4 100644 --- a/src/con.c +++ b/src/con.c @@ -534,7 +534,7 @@ update_netwm_state: values[num++] = A__NET_WM_STATE_FULLSCREEN; xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id, - A__NET_WM_STATE, A_ATOM, 32, num, values); + A__NET_WM_STATE, XCB_ATOM_ATOM, 32, num, values); } /* diff --git a/src/ewmh.c b/src/ewmh.c index 1736523d..0c1b6941 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -31,7 +31,7 @@ void ewmh_update_current_desktop() { TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) { if (ws == focused_ws) { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, - A__NET_CURRENT_DESKTOP, A_CARDINAL, 32, 1, &idx); + A__NET_CURRENT_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &idx); return; } ++idx; @@ -48,7 +48,7 @@ void ewmh_update_current_desktop() { */ void ewmh_update_active_window(xcb_window_t window) { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, - A__NET_ACTIVE_WINDOW, A_WINDOW, 32, 1, &window); + A__NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1, &window); } /* @@ -104,7 +104,7 @@ void ewmh_update_workarea() { } } xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, - A__NET_WORKAREA, A_CARDINAL, 32, + A__NET_WORKAREA, XCB_ATOM_CARDINAL, 32, num_workspaces * (sizeof(Rect) / sizeof(uint32_t)), workarea); free(workarea); @@ -122,7 +122,7 @@ void ewmh_update_client_list_stacking(xcb_window_t *stack, int num_windows) { XCB_PROP_MODE_REPLACE, root, A__NET_CLIENT_LIST_STACKING, - A_WINDOW, + XCB_ATOM_WINDOW, 32, num_windows, stack); diff --git a/src/handlers.c b/src/handlers.c index f19b53c8..02c37283 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -856,7 +856,7 @@ static bool handle_transient_for(void *data, xcb_connection_t *conn, uint8_t sta if (prop == NULL) { prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, - false, window, A_WM_TRANSIENT_FOR, A_WINDOW, 0, 32), NULL); + false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32), NULL); if (prop == NULL) return false; } @@ -887,7 +887,7 @@ static bool handle_clientleader_change(void *data, xcb_connection_t *conn, uint8 if (prop == NULL) { prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn, - false, window, A_WM_CLIENT_LEADER, A_WINDOW, 0, 32), NULL); + false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32), NULL); if (prop == NULL) return false; } @@ -961,11 +961,11 @@ static struct property_handler_t property_handlers[] = { */ void property_handlers_init() { property_handlers[0].atom = A__NET_WM_NAME; - property_handlers[1].atom = A_WM_HINTS; - property_handlers[2].atom = A_WM_NAME; - property_handlers[3].atom = A_WM_NORMAL_HINTS; + property_handlers[1].atom = XCB_ATOM_WM_HINTS; + property_handlers[2].atom = XCB_ATOM_WM_NAME; + property_handlers[3].atom = XCB_ATOM_WM_NORMAL_HINTS; property_handlers[4].atom = A_WM_CLIENT_LEADER; - property_handlers[5].atom = A_WM_TRANSIENT_FOR; + property_handlers[5].atom = XCB_ATOM_WM_TRANSIENT_FOR; } static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) { diff --git a/src/main.c b/src/main.c index 69598b35..39b9ec9a 100644 --- a/src/main.c +++ b/src/main.c @@ -396,9 +396,9 @@ int main(int argc, char *argv[]) { #include "atoms.xmacro" #undef xmacro }; - xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, A_ATOM, 32, 16, supported_atoms); + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 16, supported_atoms); /* Set up the window manager’s name */ - xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, A_WINDOW, 32, 1, &root); + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &root); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3"); keysyms = xcb_key_symbols_alloc(conn); diff --git a/src/manage.c b/src/manage.c index 68c91e72..18f38228 100644 --- a/src/manage.c +++ b/src/manage.c @@ -142,9 +142,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki state_cookie = GET_PROPERTY(A__NET_WM_STATE, UINT32_MAX); utf8_title_cookie = GET_PROPERTY(A__NET_WM_NAME, 128); leader_cookie = GET_PROPERTY(A_WM_CLIENT_LEADER, UINT32_MAX); - transient_cookie = GET_PROPERTY(A_WM_TRANSIENT_FOR, UINT32_MAX); - title_cookie = GET_PROPERTY(A_WM_NAME, 128); - class_cookie = GET_PROPERTY(A_WM_CLASS, 128); + transient_cookie = GET_PROPERTY(XCB_ATOM_WM_TRANSIENT_FOR, UINT32_MAX); + title_cookie = GET_PROPERTY(XCB_ATOM_WM_NAME, 128); + class_cookie = GET_PROPERTY(XCB_ATOM_WM_CLASS, 128); /* TODO: also get wm_normal_hints here. implement after we got rid of xcb-event */ DLOG("reparenting!\n"); diff --git a/src/x.c b/src/x.c index 11e9456c..6235cfbc 100644 --- a/src/x.c +++ b/src/x.c @@ -518,7 +518,7 @@ void x_push_node(Con *con) { DLOG("pushing name %s for con %p\n", state->name, con); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->frame, - A_WM_NAME, A_STRING, 8, strlen(state->name), state->name); + XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, strlen(state->name), state->name); FREE(state->name); } -- 2.39.5