xmacro: declare in header files, instantiate instead of include
This works better with meson, where .h files can be declared as being part of an
executable easily, but I couldn’t find a way to declare
e.g. include/atoms.xmacro as a dependency.
related to #4086
Michael Stapelberg
3 years ago
377 | 377 | $(XCB_UTIL_CURSOR_LIBS) |
378 | 378 | |
379 | 379 | i3_nagbar_i3_nagbar_SOURCES = \ |
380 | i3-nagbar/atoms.xmacro \ | |
380 | i3-nagbar/i3-nagbar-atoms.xmacro.h \ | |
381 | 381 | i3-nagbar/main.c |
382 | 382 | |
383 | 383 | i3bar_i3bar_CPPFLAGS = \ |
436 | 436 | $(XKBCOMMON_LIBS) |
437 | 437 | |
438 | 438 | i3_config_wizard_i3_config_wizard_SOURCES = \ |
439 | i3-config-wizard/atoms.xmacro \ | |
439 | i3-config-wizard/i3-config-wizard-atoms.xmacro.h \ | |
440 | 440 | i3-config-wizard/main.c \ |
441 | 441 | i3-config-wizard/xcb.h |
442 | 442 | |
499 | 499 | i3_SOURCES = \ |
500 | 500 | include/all.h \ |
501 | 501 | include/assignments.h \ |
502 | include/atoms_NET_SUPPORTED.xmacro \ | |
503 | include/atoms_rest.xmacro \ | |
504 | include/atoms.xmacro \ | |
502 | include/i3-atoms_NET_SUPPORTED.xmacro.h \ | |
503 | include/i3-atoms_rest.xmacro.h \ | |
505 | 504 | include/bindings.h \ |
506 | 505 | include/click.h \ |
507 | 506 | include/cmdparse.h \ |
253 | 253 | Handlers to update X11 window properties like +WM_CLASS+, +_NET_WM_NAME+, |
254 | 254 | +CLIENT_LEADER+, etc. |
255 | 255 | |
256 | include/atoms.xmacro:: | |
256 | include/*.xmacro.*:: | |
257 | 257 | A file containing all X11 atoms which i3 uses. This file will be included |
258 | 258 | various times (for defining, requesting and receiving the atoms), each time |
259 | 259 | with a different definition of xmacro(). |
0 | // clang-format off | |
1 | #define CONFIG_WIZARD_ATOMS_XMACRO \ | |
2 | xmacro(_NET_WM_NAME) \ | |
3 | xmacro(_NET_WM_WINDOW_TYPE) \ | |
4 | xmacro(_NET_WM_WINDOW_TYPE_DIALOG) \ | |
5 | xmacro(ATOM) \ | |
6 | xmacro(CARDINAL) \ | |
7 | xmacro(UTF8_STRING) |
49 | 49 | #include <X11/XKBlib.h> |
50 | 50 | #include <X11/Xlib.h> |
51 | 51 | #include <X11/keysym.h> |
52 | ||
53 | #include "i3-config-wizard-atoms.xmacro.h" | |
52 | 54 | |
53 | 55 | /* We need SYSCONFDIR for the path to the keycode config template, so raise an |
54 | 56 | * error if it’s not defined for whatever reason */ |
842 | 844 | /* Place requests for the atoms we need as soon as possible */ |
843 | 845 | #define xmacro(atom) \ |
844 | 846 | xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); |
845 | #include "atoms.xmacro" | |
847 | CONFIG_WIZARD_ATOMS_XMACRO | |
846 | 848 | #undef xmacro |
847 | 849 | |
848 | 850 | /* Init startup notification. */ |
899 | 901 | A_##name = reply->atom; \ |
900 | 902 | free(reply); \ |
901 | 903 | } while (0); |
902 | #include "atoms.xmacro" | |
904 | CONFIG_WIZARD_ATOMS_XMACRO | |
903 | 905 | #undef xmacro |
904 | 906 | |
905 | 907 | /* Set dock mode */ |
2 | 2 | /* from X11/keysymdef.h */ |
3 | 3 | #define XCB_NUM_LOCK 0xff7f |
4 | 4 | |
5 | #include "i3-config-wizard-atoms.xmacro.h" | |
6 | ||
5 | 7 | #define xmacro(atom) xcb_atom_t A_##atom; |
6 | #include "atoms.xmacro" | |
8 | CONFIG_WIZARD_ATOMS_XMACRO | |
7 | 9 | #undef xmacro |
0 | // clang-format off | |
1 | #define NAGBAR_ATOMS_XMACRO \ | |
2 | xmacro(_NET_WM_WINDOW_TYPE) \ | |
3 | xmacro(_NET_WM_WINDOW_TYPE_DOCK) \ | |
4 | xmacro(_NET_WM_STRUT_PARTIAL) \ | |
5 | xmacro(I3_SOCKET_PATH) \ | |
6 | xmacro(ATOM) \ | |
7 | xmacro(CARDINAL) |
34 | 34 | #define SN_API_NOT_YET_FROZEN 1 |
35 | 35 | #include <libsn/sn-launchee.h> |
36 | 36 | |
37 | #include "i3-nagbar-atoms.xmacro.h" | |
38 | ||
37 | 39 | #define MSG_PADDING logical_px(8) |
38 | 40 | #define BTN_PADDING logical_px(3) |
39 | 41 | #define BTN_BORDER logical_px(3) |
42 | 44 | #define BAR_BORDER logical_px(2) |
43 | 45 | |
44 | 46 | #define xmacro(atom) xcb_atom_t A_##atom; |
45 | #include "atoms.xmacro" | |
47 | NAGBAR_ATOMS_XMACRO | |
46 | 48 | #undef xmacro |
47 | 49 | |
48 | 50 | #define die(...) errx(EXIT_FAILURE, __VA_ARGS__); |
425 | 427 | /* Place requests for the atoms we need as soon as possible */ |
426 | 428 | #define xmacro(atom) \ |
427 | 429 | xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); |
428 | #include "atoms.xmacro" | |
430 | NAGBAR_ATOMS_XMACRO | |
429 | 431 | #undef xmacro |
430 | 432 | |
431 | 433 | /* Init startup notification. */ |
507 | 509 | A_##name = reply->atom; \ |
508 | 510 | free(reply); \ |
509 | 511 | } while (0); |
510 | #include "atoms.xmacro" | |
512 | NAGBAR_ATOMS_XMACRO | |
511 | 513 | #undef xmacro |
512 | 514 | |
513 | 515 | /* Set dock mode */ |
0 | xmacro(_NET_SUPPORTED) | |
1 | xmacro(_NET_SUPPORTING_WM_CHECK) | |
2 | xmacro(_NET_WM_NAME) | |
3 | xmacro(_NET_WM_VISIBLE_NAME) | |
4 | xmacro(_NET_WM_MOVERESIZE) | |
5 | xmacro(_NET_WM_STATE_STICKY) | |
6 | xmacro(_NET_WM_STATE_FULLSCREEN) | |
7 | xmacro(_NET_WM_STATE_DEMANDS_ATTENTION) | |
8 | xmacro(_NET_WM_STATE_MODAL) | |
9 | xmacro(_NET_WM_STATE_HIDDEN) | |
10 | xmacro(_NET_WM_STATE_FOCUSED) | |
11 | xmacro(_NET_WM_STATE) | |
12 | xmacro(_NET_WM_WINDOW_TYPE) | |
13 | xmacro(_NET_WM_WINDOW_TYPE_NORMAL) | |
14 | xmacro(_NET_WM_WINDOW_TYPE_DOCK) | |
15 | xmacro(_NET_WM_WINDOW_TYPE_DIALOG) | |
16 | xmacro(_NET_WM_WINDOW_TYPE_UTILITY) | |
17 | xmacro(_NET_WM_WINDOW_TYPE_TOOLBAR) | |
18 | xmacro(_NET_WM_WINDOW_TYPE_SPLASH) | |
19 | xmacro(_NET_WM_WINDOW_TYPE_MENU) | |
20 | xmacro(_NET_WM_WINDOW_TYPE_DROPDOWN_MENU) | |
21 | xmacro(_NET_WM_WINDOW_TYPE_POPUP_MENU) | |
22 | xmacro(_NET_WM_WINDOW_TYPE_TOOLTIP) | |
23 | xmacro(_NET_WM_WINDOW_TYPE_NOTIFICATION) | |
24 | xmacro(_NET_WM_DESKTOP) | |
25 | xmacro(_NET_WM_STRUT_PARTIAL) | |
26 | xmacro(_NET_CLIENT_LIST) | |
27 | xmacro(_NET_CLIENT_LIST_STACKING) | |
28 | xmacro(_NET_CURRENT_DESKTOP) | |
29 | xmacro(_NET_NUMBER_OF_DESKTOPS) | |
30 | xmacro(_NET_DESKTOP_NAMES) | |
31 | xmacro(_NET_DESKTOP_VIEWPORT) | |
32 | xmacro(_NET_ACTIVE_WINDOW) | |
33 | xmacro(_NET_CLOSE_WINDOW) | |
34 | xmacro(_NET_MOVERESIZE_WINDOW) |
0 | xmacro(_NET_WM_USER_TIME) | |
1 | xmacro(_NET_STARTUP_ID) | |
2 | xmacro(_NET_WORKAREA) | |
3 | xmacro(WM_PROTOCOLS) | |
4 | xmacro(WM_DELETE_WINDOW) | |
5 | xmacro(UTF8_STRING) | |
6 | xmacro(WM_STATE) | |
7 | xmacro(WM_CLIENT_LEADER) | |
8 | xmacro(WM_TAKE_FOCUS) | |
9 | xmacro(WM_WINDOW_ROLE) | |
10 | xmacro(I3_SOCKET_PATH) | |
11 | xmacro(I3_CONFIG_PATH) | |
12 | xmacro(I3_SYNC) | |
13 | xmacro(I3_SHMLOG_PATH) | |
14 | xmacro(I3_PID) | |
15 | xmacro(I3_FLOATING_WINDOW) | |
16 | xmacro(_NET_REQUEST_FRAME_EXTENTS) | |
17 | xmacro(_NET_FRAME_EXTENTS) | |
18 | xmacro(_MOTIF_WM_HINTS) | |
19 | xmacro(WM_CHANGE_STATE) |
0 | // clang-format off | |
1 | #define I3_NET_SUPPORTED_ATOMS_XMACRO \ | |
2 | xmacro(_NET_SUPPORTED) \ | |
3 | xmacro(_NET_SUPPORTING_WM_CHECK) \ | |
4 | xmacro(_NET_WM_NAME) \ | |
5 | xmacro(_NET_WM_VISIBLE_NAME) \ | |
6 | xmacro(_NET_WM_MOVERESIZE) \ | |
7 | xmacro(_NET_WM_STATE_STICKY) \ | |
8 | xmacro(_NET_WM_STATE_FULLSCREEN) \ | |
9 | xmacro(_NET_WM_STATE_DEMANDS_ATTENTION) \ | |
10 | xmacro(_NET_WM_STATE_MODAL) \ | |
11 | xmacro(_NET_WM_STATE_HIDDEN) \ | |
12 | xmacro(_NET_WM_STATE_FOCUSED) \ | |
13 | xmacro(_NET_WM_STATE) \ | |
14 | xmacro(_NET_WM_WINDOW_TYPE) \ | |
15 | xmacro(_NET_WM_WINDOW_TYPE_NORMAL) \ | |
16 | xmacro(_NET_WM_WINDOW_TYPE_DOCK) \ | |
17 | xmacro(_NET_WM_WINDOW_TYPE_DIALOG) \ | |
18 | xmacro(_NET_WM_WINDOW_TYPE_UTILITY) \ | |
19 | xmacro(_NET_WM_WINDOW_TYPE_TOOLBAR) \ | |
20 | xmacro(_NET_WM_WINDOW_TYPE_SPLASH) \ | |
21 | xmacro(_NET_WM_WINDOW_TYPE_MENU) \ | |
22 | xmacro(_NET_WM_WINDOW_TYPE_DROPDOWN_MENU) \ | |
23 | xmacro(_NET_WM_WINDOW_TYPE_POPUP_MENU) \ | |
24 | xmacro(_NET_WM_WINDOW_TYPE_TOOLTIP) \ | |
25 | xmacro(_NET_WM_WINDOW_TYPE_NOTIFICATION) \ | |
26 | xmacro(_NET_WM_DESKTOP) \ | |
27 | xmacro(_NET_WM_STRUT_PARTIAL) \ | |
28 | xmacro(_NET_CLIENT_LIST) \ | |
29 | xmacro(_NET_CLIENT_LIST_STACKING) \ | |
30 | xmacro(_NET_CURRENT_DESKTOP) \ | |
31 | xmacro(_NET_NUMBER_OF_DESKTOPS) \ | |
32 | xmacro(_NET_DESKTOP_NAMES) \ | |
33 | xmacro(_NET_DESKTOP_VIEWPORT) \ | |
34 | xmacro(_NET_ACTIVE_WINDOW) \ | |
35 | xmacro(_NET_CLOSE_WINDOW) \ | |
36 | xmacro(_NET_MOVERESIZE_WINDOW) |
0 | // clang-format off | |
1 | #define I3_REST_ATOMS_XMACRO \ | |
2 | xmacro(_NET_WM_USER_TIME) \ | |
3 | xmacro(_NET_STARTUP_ID) \ | |
4 | xmacro(_NET_WORKAREA) \ | |
5 | xmacro(WM_PROTOCOLS) \ | |
6 | xmacro(WM_DELETE_WINDOW) \ | |
7 | xmacro(UTF8_STRING) \ | |
8 | xmacro(WM_STATE) \ | |
9 | xmacro(WM_CLIENT_LEADER) \ | |
10 | xmacro(WM_TAKE_FOCUS) \ | |
11 | xmacro(WM_WINDOW_ROLE) \ | |
12 | xmacro(I3_SOCKET_PATH) \ | |
13 | xmacro(I3_CONFIG_PATH) \ | |
14 | xmacro(I3_SYNC) \ | |
15 | xmacro(I3_SHMLOG_PATH) \ | |
16 | xmacro(I3_PID) \ | |
17 | xmacro(I3_FLOATING_WINDOW) \ | |
18 | xmacro(_NET_REQUEST_FRAME_EXTENTS) \ | |
19 | xmacro(_NET_FRAME_EXTENTS) \ | |
20 | xmacro(_MOTIF_WM_HINTS) \ | |
21 | xmacro(WM_CHANGE_STATE) |
48 | 48 | XCB_EVENT_MASK_FOCUS_CHANGE | \ |
49 | 49 | XCB_EVENT_MASK_ENTER_WINDOW) |
50 | 50 | |
51 | #include "i3-atoms_rest.xmacro.h" | |
52 | #include "i3-atoms_NET_SUPPORTED.xmacro.h" | |
53 | ||
51 | 54 | #define xmacro(atom) extern xcb_atom_t A_##atom; |
52 | #include "atoms.xmacro" | |
55 | I3_NET_SUPPORTED_ATOMS_XMACRO | |
56 | I3_REST_ATOMS_XMACRO | |
53 | 57 | #undef xmacro |
54 | 58 | |
55 | 59 | extern unsigned int xcb_numlock_mask; |
7 | 7 | * |
8 | 8 | */ |
9 | 9 | #include "all.h" |
10 | ||
11 | #include "i3-atoms_NET_SUPPORTED.xmacro.h" | |
10 | 12 | |
11 | 13 | xcb_window_t ewmh_window; |
12 | 14 | |
304 | 306 | void ewmh_setup_hints(void) { |
305 | 307 | xcb_atom_t supported_atoms[] = { |
306 | 308 | #define xmacro(atom) A_##atom, |
307 | #include "atoms_NET_SUPPORTED.xmacro" | |
309 | I3_NET_SUPPORTED_ATOMS_XMACRO | |
308 | 310 | #undef xmacro |
309 | 311 | }; |
310 | 312 |
30 | 30 | |
31 | 31 | #include "sd-daemon.h" |
32 | 32 | |
33 | #include "i3-atoms_NET_SUPPORTED.xmacro.h" | |
34 | #include "i3-atoms_rest.xmacro.h" | |
35 | ||
33 | 36 | /* The original value of RLIMIT_CORE when i3 was started. We need to restore |
34 | 37 | * this before starting any other process, since we set RLIMIT_CORE to |
35 | 38 | * RLIM_INFINITY for i3 debugging versions. */ |
97 | 100 | |
98 | 101 | /* Define all atoms as global variables */ |
99 | 102 | #define xmacro(atom) xcb_atom_t A_##atom; |
100 | #include "atoms.xmacro" | |
103 | I3_NET_SUPPORTED_ATOMS_XMACRO | |
104 | I3_REST_ATOMS_XMACRO | |
101 | 105 | #undef xmacro |
102 | 106 | |
103 | 107 | /* |
558 | 562 | /* Place requests for the atoms we need as soon as possible */ |
559 | 563 | #define xmacro(atom) \ |
560 | 564 | xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); |
561 | #include "atoms.xmacro" | |
565 | I3_NET_SUPPORTED_ATOMS_XMACRO | |
566 | I3_REST_ATOMS_XMACRO | |
562 | 567 | #undef xmacro |
563 | 568 | |
564 | 569 | root_depth = root_screen->root_depth; |
604 | 609 | A_##name = reply->atom; \ |
605 | 610 | free(reply); \ |
606 | 611 | } while (0); |
607 | #include "atoms.xmacro" | |
612 | I3_NET_SUPPORTED_ATOMS_XMACRO | |
613 | I3_REST_ATOMS_XMACRO | |
608 | 614 | #undef xmacro |
609 | 615 | |
610 | 616 | load_configuration(override_configpath, C_LOAD); |