]> git.sur5r.net Git - i3/i3/commitdiff
split atoms.xmacro into 2 files to obtain _NET_SUPPORTED count
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 23 Feb 2016 20:47:00 +0000 (21:47 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 23 Feb 2016 20:48:18 +0000 (21:48 +0100)
Manually updating a magic number doesn’t work in the long run.
With this change, the number of atoms contained in
include/atoms_NET_SUPPORTED.xmacro is used.

fixes #2230

include/atoms.xmacro
include/atoms_NET_SUPPORTED.xmacro [new file with mode: 0644]
include/atoms_rest.xmacro [new file with mode: 0644]
src/ewmh.c

index 139b6efb4530564d77fda464c4b8a5e1798752a3..730e569a11d9e8b6afcc621cfb02b962ec1d871e 100644 (file)
@@ -1,51 +1,2 @@
-xmacro(_NET_SUPPORTED)
-xmacro(_NET_SUPPORTING_WM_CHECK)
-xmacro(_NET_WM_NAME)
-xmacro(_NET_WM_VISIBLE_NAME)
-xmacro(_NET_WM_MOVERESIZE)
-xmacro(_NET_WM_STATE_STICKY)
-xmacro(_NET_WM_STATE_FULLSCREEN)
-xmacro(_NET_WM_STATE_DEMANDS_ATTENTION)
-xmacro(_NET_WM_STATE_MODAL)
-xmacro(_NET_WM_STATE_HIDDEN)
-xmacro(_NET_WM_STATE)
-xmacro(_NET_WM_WINDOW_TYPE)
-xmacro(_NET_WM_WINDOW_TYPE_NORMAL)
-xmacro(_NET_WM_WINDOW_TYPE_DOCK)
-xmacro(_NET_WM_WINDOW_TYPE_DIALOG)
-xmacro(_NET_WM_WINDOW_TYPE_UTILITY)
-xmacro(_NET_WM_WINDOW_TYPE_TOOLBAR)
-xmacro(_NET_WM_WINDOW_TYPE_SPLASH)
-xmacro(_NET_WM_WINDOW_TYPE_MENU)
-xmacro(_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)
-xmacro(_NET_WM_WINDOW_TYPE_POPUP_MENU)
-xmacro(_NET_WM_WINDOW_TYPE_TOOLTIP)
-xmacro(_NET_WM_WINDOW_TYPE_NOTIFICATION)
-xmacro(_NET_WM_DESKTOP)
-xmacro(_NET_WM_STRUT_PARTIAL)
-xmacro(_NET_CLIENT_LIST)
-xmacro(_NET_CLIENT_LIST_STACKING)
-xmacro(_NET_CURRENT_DESKTOP)
-xmacro(_NET_NUMBER_OF_DESKTOPS)
-xmacro(_NET_DESKTOP_NAMES)
-xmacro(_NET_DESKTOP_VIEWPORT)
-xmacro(_NET_ACTIVE_WINDOW)
-xmacro(_NET_CLOSE_WINDOW)
-xmacro(_NET_WM_USER_TIME)
-xmacro(_NET_STARTUP_ID)
-xmacro(_NET_WORKAREA)
-xmacro(WM_PROTOCOLS)
-xmacro(WM_DELETE_WINDOW)
-xmacro(UTF8_STRING)
-xmacro(WM_STATE)
-xmacro(WM_CLIENT_LEADER)
-xmacro(WM_TAKE_FOCUS)
-xmacro(WM_WINDOW_ROLE)
-xmacro(I3_SOCKET_PATH)
-xmacro(I3_CONFIG_PATH)
-xmacro(I3_SYNC)
-xmacro(I3_SHMLOG_PATH)
-xmacro(I3_PID)
-xmacro(_NET_REQUEST_FRAME_EXTENTS)
-xmacro(_NET_FRAME_EXTENTS)
-xmacro(_MOTIF_WM_HINTS)
+#include "atoms_NET_SUPPORTED.xmacro"
+#include "atoms_rest.xmacro"
diff --git a/include/atoms_NET_SUPPORTED.xmacro b/include/atoms_NET_SUPPORTED.xmacro
new file mode 100644 (file)
index 0000000..1358e0f
--- /dev/null
@@ -0,0 +1,33 @@
+xmacro(_NET_SUPPORTED)
+xmacro(_NET_SUPPORTING_WM_CHECK)
+xmacro(_NET_WM_NAME)
+xmacro(_NET_WM_VISIBLE_NAME)
+xmacro(_NET_WM_MOVERESIZE)
+xmacro(_NET_WM_STATE_STICKY)
+xmacro(_NET_WM_STATE_FULLSCREEN)
+xmacro(_NET_WM_STATE_DEMANDS_ATTENTION)
+xmacro(_NET_WM_STATE_MODAL)
+xmacro(_NET_WM_STATE_HIDDEN)
+xmacro(_NET_WM_STATE)
+xmacro(_NET_WM_WINDOW_TYPE)
+xmacro(_NET_WM_WINDOW_TYPE_NORMAL)
+xmacro(_NET_WM_WINDOW_TYPE_DOCK)
+xmacro(_NET_WM_WINDOW_TYPE_DIALOG)
+xmacro(_NET_WM_WINDOW_TYPE_UTILITY)
+xmacro(_NET_WM_WINDOW_TYPE_TOOLBAR)
+xmacro(_NET_WM_WINDOW_TYPE_SPLASH)
+xmacro(_NET_WM_WINDOW_TYPE_MENU)
+xmacro(_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)
+xmacro(_NET_WM_WINDOW_TYPE_POPUP_MENU)
+xmacro(_NET_WM_WINDOW_TYPE_TOOLTIP)
+xmacro(_NET_WM_WINDOW_TYPE_NOTIFICATION)
+xmacro(_NET_WM_DESKTOP)
+xmacro(_NET_WM_STRUT_PARTIAL)
+xmacro(_NET_CLIENT_LIST)
+xmacro(_NET_CLIENT_LIST_STACKING)
+xmacro(_NET_CURRENT_DESKTOP)
+xmacro(_NET_NUMBER_OF_DESKTOPS)
+xmacro(_NET_DESKTOP_NAMES)
+xmacro(_NET_DESKTOP_VIEWPORT)
+xmacro(_NET_ACTIVE_WINDOW)
+xmacro(_NET_CLOSE_WINDOW)
diff --git a/include/atoms_rest.xmacro b/include/atoms_rest.xmacro
new file mode 100644 (file)
index 0000000..12cb63f
--- /dev/null
@@ -0,0 +1,18 @@
+xmacro(_NET_WM_USER_TIME)
+xmacro(_NET_STARTUP_ID)
+xmacro(_NET_WORKAREA)
+xmacro(WM_PROTOCOLS)
+xmacro(WM_DELETE_WINDOW)
+xmacro(UTF8_STRING)
+xmacro(WM_STATE)
+xmacro(WM_CLIENT_LEADER)
+xmacro(WM_TAKE_FOCUS)
+xmacro(WM_WINDOW_ROLE)
+xmacro(I3_SOCKET_PATH)
+xmacro(I3_CONFIG_PATH)
+xmacro(I3_SYNC)
+xmacro(I3_SHMLOG_PATH)
+xmacro(I3_PID)
+xmacro(_NET_REQUEST_FRAME_EXTENTS)
+xmacro(_NET_FRAME_EXTENTS)
+xmacro(_MOTIF_WM_HINTS)
index 05f4d3cd0229e891af3515fcac569bfe7a16fb86..c4ae844ea0a1a523b54057ab248818636759f0eb 100644 (file)
@@ -284,7 +284,7 @@ void ewmh_update_sticky(xcb_window_t window, bool sticky) {
 void ewmh_setup_hints(void) {
     xcb_atom_t supported_atoms[] = {
 #define xmacro(atom) A_##atom,
-#include "atoms.xmacro"
+#include "atoms_NET_SUPPORTED.xmacro"
 #undef xmacro
     };
 
@@ -313,8 +313,7 @@ void ewmh_setup_hints(void) {
     /* I’m not entirely sure if we need to keep _NET_WM_NAME on root. */
     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
 
-    /* only send the first 32 atoms (last one is _NET_CLOSE_WINDOW) increment that number when adding supported atoms */
-    xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, /* number of atoms */ 32, supported_atoms);
+    xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, /* number of atoms */ sizeof(supported_atoms) / sizeof(xcb_atom_t), supported_atoms);
 
     /* We need to map this window to be able to set the input focus to it if no other window is available to be focused. */
     xcb_map_window(conn, ewmh_window);