diff --git a/Makefile.am b/Makefile.am index 1a28c7fcc..2e7231d78 100644 --- a/Makefile.am +++ b/Makefile.am @@ -378,7 +378,7 @@ i3_nagbar_i3_nagbar_LDADD = \ $(XCB_UTIL_CURSOR_LIBS) i3_nagbar_i3_nagbar_SOURCES = \ - i3-nagbar/atoms.xmacro \ + i3-nagbar/i3-nagbar-atoms.xmacro.h \ i3-nagbar/main.c i3bar_i3bar_CPPFLAGS = \ @@ -437,7 +437,7 @@ i3_config_wizard_i3_config_wizard_LDADD = \ $(XKBCOMMON_LIBS) i3_config_wizard_i3_config_wizard_SOURCES = \ - i3-config-wizard/atoms.xmacro \ + i3-config-wizard/i3-config-wizard-atoms.xmacro.h \ i3-config-wizard/main.c \ i3-config-wizard/xcb.h @@ -500,9 +500,8 @@ BUILT_SOURCES = $(command_parser_SOURCES) $(config_parser_SOURCES) i3_SOURCES = \ include/all.h \ include/assignments.h \ - include/atoms_NET_SUPPORTED.xmacro \ - include/atoms_rest.xmacro \ - include/atoms.xmacro \ + include/i3-atoms_NET_SUPPORTED.xmacro.h \ + include/i3-atoms_rest.xmacro.h \ include/bindings.h \ include/click.h \ include/cmdparse.h \ diff --git a/docs/hacking-howto b/docs/hacking-howto index ff3c89bca..16b9a5516 100644 --- a/docs/hacking-howto +++ b/docs/hacking-howto @@ -254,7 +254,7 @@ src/window.c:: Handlers to update X11 window properties like +WM_CLASS+, +_NET_WM_NAME+, +CLIENT_LEADER+, etc. -include/atoms.xmacro:: +include/*.xmacro.*:: A file containing all X11 atoms which i3 uses. This file will be included various times (for defining, requesting and receiving the atoms), each time with a different definition of xmacro(). diff --git a/i3-config-wizard/i3-config-wizard-atoms.xmacro.h b/i3-config-wizard/i3-config-wizard-atoms.xmacro.h new file mode 100644 index 000000000..2d504678f --- /dev/null +++ b/i3-config-wizard/i3-config-wizard-atoms.xmacro.h @@ -0,0 +1,8 @@ +// clang-format off +#define CONFIG_WIZARD_ATOMS_XMACRO \ +xmacro(_NET_WM_NAME) \ +xmacro(_NET_WM_WINDOW_TYPE) \ +xmacro(_NET_WM_WINDOW_TYPE_DIALOG) \ +xmacro(ATOM) \ +xmacro(CARDINAL) \ +xmacro(UTF8_STRING) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 9e07d1f7d..25117f2b5 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -51,6 +51,8 @@ #include #include +#include "i3-config-wizard-atoms.xmacro.h" + /* We need SYSCONFDIR for the path to the keycode config template, so raise an * error if it’s not defined for whatever reason */ #ifndef SYSCONFDIR @@ -843,7 +845,7 @@ int main(int argc, char *argv[]) { /* Place requests for the atoms we need as soon as possible */ #define xmacro(atom) \ xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); -#include "atoms.xmacro" + CONFIG_WIZARD_ATOMS_XMACRO #undef xmacro /* Init startup notification. */ @@ -900,7 +902,7 @@ int main(int argc, char *argv[]) { A_##name = reply->atom; \ free(reply); \ } while (0); -#include "atoms.xmacro" + CONFIG_WIZARD_ATOMS_XMACRO #undef xmacro /* Set dock mode */ diff --git a/i3-config-wizard/xcb.h b/i3-config-wizard/xcb.h index f3e204e8e..dc8568a74 100644 --- a/i3-config-wizard/xcb.h +++ b/i3-config-wizard/xcb.h @@ -3,6 +3,8 @@ /* from X11/keysymdef.h */ #define XCB_NUM_LOCK 0xff7f +#include "i3-config-wizard-atoms.xmacro.h" + #define xmacro(atom) xcb_atom_t A_##atom; -#include "atoms.xmacro" +CONFIG_WIZARD_ATOMS_XMACRO #undef xmacro diff --git a/i3-nagbar/i3-nagbar-atoms.xmacro.h b/i3-nagbar/i3-nagbar-atoms.xmacro.h new file mode 100644 index 000000000..c430b59a8 --- /dev/null +++ b/i3-nagbar/i3-nagbar-atoms.xmacro.h @@ -0,0 +1,8 @@ +// clang-format off +#define NAGBAR_ATOMS_XMACRO \ +xmacro(_NET_WM_WINDOW_TYPE) \ +xmacro(_NET_WM_WINDOW_TYPE_DOCK) \ +xmacro(_NET_WM_STRUT_PARTIAL) \ +xmacro(I3_SOCKET_PATH) \ +xmacro(ATOM) \ +xmacro(CARDINAL) diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index 51e5475c9..b13ee1343 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -35,6 +35,8 @@ xcb_visualtype_t *visual_type = NULL; #define SN_API_NOT_YET_FROZEN 1 #include +#include "i3-nagbar-atoms.xmacro.h" + #define MSG_PADDING logical_px(8) #define BTN_PADDING logical_px(3) #define BTN_BORDER logical_px(3) @@ -43,7 +45,7 @@ xcb_visualtype_t *visual_type = NULL; #define BAR_BORDER logical_px(2) #define xmacro(atom) xcb_atom_t A_##atom; -#include "atoms.xmacro" +NAGBAR_ATOMS_XMACRO #undef xmacro #define die(...) errx(EXIT_FAILURE, __VA_ARGS__); @@ -426,7 +428,7 @@ int main(int argc, char *argv[]) { /* Place requests for the atoms we need as soon as possible */ #define xmacro(atom) \ xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); -#include "atoms.xmacro" + NAGBAR_ATOMS_XMACRO #undef xmacro /* Init startup notification. */ @@ -508,7 +510,7 @@ int main(int argc, char *argv[]) { A_##name = reply->atom; \ free(reply); \ } while (0); -#include "atoms.xmacro" + NAGBAR_ATOMS_XMACRO #undef xmacro /* Set dock mode */ diff --git a/include/atoms.xmacro b/include/atoms.xmacro deleted file mode 100644 index 730e569a1..000000000 --- a/include/atoms.xmacro +++ /dev/null @@ -1,2 +0,0 @@ -#include "atoms_NET_SUPPORTED.xmacro" -#include "atoms_rest.xmacro" diff --git a/include/atoms_NET_SUPPORTED.xmacro b/include/atoms_NET_SUPPORTED.xmacro deleted file mode 100644 index a81948a98..000000000 --- a/include/atoms_NET_SUPPORTED.xmacro +++ /dev/null @@ -1,35 +0,0 @@ -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_FOCUSED) -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_MOVERESIZE_WINDOW) diff --git a/include/atoms_rest.xmacro b/include/atoms_rest.xmacro deleted file mode 100644 index b65a81d81..000000000 --- a/include/atoms_rest.xmacro +++ /dev/null @@ -1,20 +0,0 @@ -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(I3_FLOATING_WINDOW) -xmacro(_NET_REQUEST_FRAME_EXTENTS) -xmacro(_NET_FRAME_EXTENTS) -xmacro(_MOTIF_WM_HINTS) -xmacro(WM_CHANGE_STATE) diff --git a/include/i3-atoms_NET_SUPPORTED.xmacro.h b/include/i3-atoms_NET_SUPPORTED.xmacro.h new file mode 100644 index 000000000..b491da98a --- /dev/null +++ b/include/i3-atoms_NET_SUPPORTED.xmacro.h @@ -0,0 +1,37 @@ +// clang-format off +#define I3_NET_SUPPORTED_ATOMS_XMACRO \ +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_FOCUSED) \ +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_MOVERESIZE_WINDOW) diff --git a/include/i3-atoms_rest.xmacro.h b/include/i3-atoms_rest.xmacro.h new file mode 100644 index 000000000..75a5f2300 --- /dev/null +++ b/include/i3-atoms_rest.xmacro.h @@ -0,0 +1,22 @@ +// clang-format off +#define I3_REST_ATOMS_XMACRO \ +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(I3_FLOATING_WINDOW) \ +xmacro(_NET_REQUEST_FRAME_EXTENTS) \ +xmacro(_NET_FRAME_EXTENTS) \ +xmacro(_MOTIF_WM_HINTS) \ +xmacro(WM_CHANGE_STATE) diff --git a/include/xcb.h b/include/xcb.h index 151326098..ba4ff2f34 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -49,8 +49,12 @@ XCB_EVENT_MASK_FOCUS_CHANGE | \ XCB_EVENT_MASK_ENTER_WINDOW) +#include "i3-atoms_rest.xmacro.h" +#include "i3-atoms_NET_SUPPORTED.xmacro.h" + #define xmacro(atom) extern xcb_atom_t A_##atom; -#include "atoms.xmacro" +I3_NET_SUPPORTED_ATOMS_XMACRO +I3_REST_ATOMS_XMACRO #undef xmacro extern unsigned int xcb_numlock_mask; diff --git a/src/ewmh.c b/src/ewmh.c index 1cdf89471..c61fb5f39 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -9,6 +9,8 @@ */ #include "all.h" +#include "i3-atoms_NET_SUPPORTED.xmacro.h" + xcb_window_t ewmh_window; #define FOREACH_NONINTERNAL \ @@ -305,7 +307,7 @@ void ewmh_update_focused(xcb_window_t window, bool is_focused) { void ewmh_setup_hints(void) { xcb_atom_t supported_atoms[] = { #define xmacro(atom) A_##atom, -#include "atoms_NET_SUPPORTED.xmacro" + I3_NET_SUPPORTED_ATOMS_XMACRO #undef xmacro }; diff --git a/src/main.c b/src/main.c index 4f4c3fd6d..cb17de361 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,9 @@ #include "sd-daemon.h" +#include "i3-atoms_NET_SUPPORTED.xmacro.h" +#include "i3-atoms_rest.xmacro.h" + /* The original value of RLIMIT_CORE when i3 was started. We need to restore * this before starting any other process, since we set RLIMIT_CORE to * RLIM_INFINITY for i3 debugging versions. */ @@ -98,7 +101,8 @@ bool force_xinerama = false; /* Define all atoms as global variables */ #define xmacro(atom) xcb_atom_t A_##atom; -#include "atoms.xmacro" +I3_NET_SUPPORTED_ATOMS_XMACRO +I3_REST_ATOMS_XMACRO #undef xmacro /* @@ -559,7 +563,8 @@ int main(int argc, char *argv[]) { /* Place requests for the atoms we need as soon as possible */ #define xmacro(atom) \ xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); -#include "atoms.xmacro" + I3_NET_SUPPORTED_ATOMS_XMACRO + I3_REST_ATOMS_XMACRO #undef xmacro root_depth = root_screen->root_depth; @@ -605,7 +610,8 @@ int main(int argc, char *argv[]) { A_##name = reply->atom; \ free(reply); \ } while (0); -#include "atoms.xmacro" + I3_NET_SUPPORTED_ATOMS_XMACRO + I3_REST_ATOMS_XMACRO #undef xmacro load_configuration(override_configpath, C_LOAD);