From fdbbae56b2b5f8049380b9456c01c3966b3b18f2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 23 Feb 2016 21:47:00 +0100 Subject: [PATCH] split atoms.xmacro into 2 files to obtain _NET_SUPPORTED count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 53 ++---------------------------- include/atoms_NET_SUPPORTED.xmacro | 33 +++++++++++++++++++ include/atoms_rest.xmacro | 18 ++++++++++ src/ewmh.c | 5 ++- 4 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 include/atoms_NET_SUPPORTED.xmacro create mode 100644 include/atoms_rest.xmacro diff --git a/include/atoms.xmacro b/include/atoms.xmacro index 139b6efb..730e569a 100644 --- a/include/atoms.xmacro +++ b/include/atoms.xmacro @@ -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 index 00000000..1358e0f1 --- /dev/null +++ b/include/atoms_NET_SUPPORTED.xmacro @@ -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 index 00000000..12cb63fd --- /dev/null +++ b/include/atoms_rest.xmacro @@ -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) diff --git a/src/ewmh.c b/src/ewmh.c index 05f4d3cd..c4ae844e 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -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);