]> git.sur5r.net Git - i3/i3/commitdiff
xcb: use predefined XCB_ATOM_ atoms, don’t request them
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 16 Aug 2011 23:41:19 +0000 (01:41 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 16 Aug 2011 23:41:19 +0000 (01:41 +0200)
include/atoms.xmacro
include/xcb_compat.h
src/con.c
src/ewmh.c
src/handlers.c
src/main.c
src/manage.c
src/x.c

index 9b5a132cbdc77f075da126d0a8d2846fbbb0656f..300a8abaea48ae0976b1feaacfd9730717e06742 100644 (file)
@@ -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)
index c00e266309a6e3103e0ded57ba429c003c4eef7b..ec872a3abeabf3eb9d4cfe4e39cc1f826680e887 100644 (file)
 #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
index b867e964b8018cc96651198910e948d77c3e3d83..5c5099c4e56dcf117a7712016d632c11a80d6216 100644 (file)
--- 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);
 }
 
 /*
index 1736523d7a176a6efe8fd709bec576e5086170dc..0c1b6941e1a4008d787812bbd0adcf95bfc134e0 100644 (file)
@@ -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);
index f19b53c8fce793bfda24034a18a8cad74fa9b3a9..02c37283bef4c90fc46c44dda88790a2e85e37c9 100644 (file)
@@ -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) {
index 69598b3540b5c726cf8b2c686b03e197a2ea061f..39b9ec9a6531df7885198105532aa4e1ef9498a8 100644 (file)
@@ -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);
index 68c91e72221904a66009d2fa26a42b52a8aebf2b..18f382288e1cf17a02ea5b2acd7d432e278411fa 100644 (file)
@@ -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 11e9456c90a5fd6a0817e838ff5b5d82ddda52ec..6235cfbcb7f3fedb9348379560e1dcbacc1a07a0 100644 (file)
--- 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);
     }