From 3c522d9f2f2b7a58952f219598d5e2df4e0e5334 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 19 Apr 2020 09:43:48 +0200 Subject: [PATCH 01/11] Sort includes in *.c files Not enabling in .clang-format because it breaks headers files. Used: IncludeCategories: - Regex: '^ -#include -#include -#include -#include -#include +#include #include -#include #include -#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include #include #include #include #include - -#include #include +#include #define SN_API_NOT_YET_FROZEN 1 #include +#include #include #include -#include /* We need SYSCONFDIR for the path to the keycode config template, so raise an * error if it’s not defined for whatever reason */ diff --git a/i3-dump-log/main.c b/i3-dump-log/main.c index ba60d396e..e55f1d3c9 100644 --- a/i3-dump-log/main.c +++ b/i3-dump-log/main.c @@ -9,27 +9,27 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "libi3.h" +#include "shmlog.h" + #include -#include +#include +#include #include +#include #include -#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include - -#include "libi3.h" -#include "shmlog.h" -#include +#include +#include +#include #if !defined(__OpenBSD__) static uint32_t offset_next_write; diff --git a/i3-input/keysym2ucs.c b/i3-input/keysym2ucs.c index 52bdc0444..80375099c 100644 --- a/i3-input/keysym2ucs.c +++ b/i3-input/keysym2ucs.c @@ -31,9 +31,10 @@ * This software is in the public domain. Share and enjoy! */ -#include #include "keysym2ucs.h" +#include + struct codepair { unsigned short keysym; unsigned short ucs; diff --git a/i3-input/main.c b/i3-input/main.c index e495fe10a..1a4cbc7d1 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -8,17 +8,17 @@ * to i3. * */ -#include -#include -#include -#include -#include -#include -#include #include -#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -26,14 +26,12 @@ #include xcb_visualtype_t *visual_type = NULL; +#include "i3-input.h" +#include "keysym2ucs.h" #include "libi3.h" #include -#include "keysym2ucs.h" - -#include "i3-input.h" - #define MAX_WIDTH logical_px(500) #define BORDER logical_px(2) #define PADDING logical_px(2) diff --git a/i3-msg/main.c b/i3-msg/main.c index 3a8974161..dd72bd561 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -16,27 +16,25 @@ */ #include "libi3.h" -#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include +#include #include -#include #include -#include -#include -#include -#include -#include -#include - -#include -#include #include #include - -#include +#include +#include /* * Having verboselog() and errorlog() is necessary when using libi3. diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index e59f5a6a3..5558865b3 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -8,36 +8,36 @@ * when the user has an error in their configuration file. * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include #include +#include xcb_visualtype_t *visual_type = NULL; #include "libi3.h" #define SN_API_NOT_YET_FROZEN 1 -#include - #include "i3-nagbar.h" +#include + #define MSG_PADDING logical_px(8) #define BTN_PADDING logical_px(3) #define BTN_BORDER logical_px(3) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index e56145fac..4723dbc57 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -10,25 +10,25 @@ #include "common.h" #include "yajl_utils.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include #include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include + +#include #include +#include #include #include -#include -#include - -#include /* Global variables for child_*() */ i3bar_child child; diff --git a/i3bar/src/config.c b/i3bar/src/config.c index 29b0908b0..48f49b898 100644 --- a/i3bar/src/config.c +++ b/i3bar/src/config.c @@ -9,15 +9,15 @@ */ #include "common.h" -#include -#include -#include #include #include -#include -#include +#include +#include +#include #include +#include +#include config_t config; static char *cur_key; diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index 37bdbac2b..d2edfe787 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -9,16 +9,16 @@ */ #include "common.h" -#include -#include -#include +#include +#include +#include #include +#include +#include #include -#include #include #include -#include -#include +#include #ifdef I3_ASAN_ENABLED #include #endif diff --git a/i3bar/src/main.c b/i3bar/src/main.c index 65cb00ff5..b3e23cda7 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -7,15 +7,15 @@ */ #include "common.h" -#include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include struct ev_loop *main_loop; diff --git a/i3bar/src/mode.c b/i3bar/src/mode.c index 97087ce09..1f0e22fa8 100644 --- a/i3bar/src/mode.c +++ b/i3bar/src/mode.c @@ -9,10 +9,11 @@ */ #include "common.h" -#include -#include -#include #include +#include +#include +#include + #include #include diff --git a/i3bar/src/outputs.c b/i3bar/src/outputs.c index 6ebb7cc6b..f1dab9f16 100644 --- a/i3bar/src/outputs.c +++ b/i3bar/src/outputs.c @@ -9,11 +9,12 @@ */ #include "common.h" -#include -#include -#include #include #include +#include +#include +#include + #include #include diff --git a/i3bar/src/parse_json_header.c b/i3bar/src/parse_json_header.c index 3d4c2a67f..cd857d917 100644 --- a/i3bar/src/parse_json_header.c +++ b/i3bar/src/parse_json_header.c @@ -10,19 +10,20 @@ */ #include "common.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include +#include +#include #include #include +#include +#include +#include +#include +#include +#include + #include #include #include diff --git a/i3bar/src/workspaces.c b/i3bar/src/workspaces.c index 68686611a..51b863ca4 100644 --- a/i3bar/src/workspaces.c +++ b/i3bar/src/workspaces.c @@ -9,10 +9,11 @@ */ #include "common.h" -#include -#include -#include #include +#include +#include +#include + #include #include diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index ecb41a603..0b0e23b09 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -9,26 +9,25 @@ */ #include "common.h" -#include -#include -#include -#include -#include - -#include -#include -#include +#include +#include +#include #include -#include #include -#include -#include #include -#include +#include +#include +#include +#include -#include #include +#include #include +#include +#include +#include +#include +#include #ifdef I3_ASAN_ENABLED #include diff --git a/libi3/dpi.c b/libi3/dpi.c index d15e35be7..dec38bc86 100644 --- a/libi3/dpi.c +++ b/libi3/dpi.c @@ -9,6 +9,7 @@ #include #include + #include static long dpi; diff --git a/libi3/draw_util.c b/libi3/draw_util.c index 092ac967b..710c536a3 100644 --- a/libi3/draw_util.c +++ b/libi3/draw_util.c @@ -8,12 +8,13 @@ */ #include "libi3.h" -#include +#include #include +#include #include + #include #include -#include /* The default visual_type to use if none is specified when creating the surface. Must be defined globally. */ extern xcb_visualtype_t *visual_type; diff --git a/libi3/fake_configure_notify.c b/libi3/fake_configure_notify.c index 145f45122..e79a748b2 100644 --- a/libi3/fake_configure_notify.c +++ b/libi3/fake_configure_notify.c @@ -7,8 +7,8 @@ */ #include "libi3.h" -#include #include +#include #include #include diff --git a/libi3/font.c b/libi3/font.c index 7b10edf02..e89455240 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -8,14 +8,13 @@ #include "libi3.h" #include +#include +#include +#include +#include #include #include #include -#include -#include - -#include -#include static const i3Font *savedFont = NULL; diff --git a/libi3/format_placeholders.c b/libi3/format_placeholders.c index 770e383d7..99fa3055a 100644 --- a/libi3/format_placeholders.c +++ b/libi3/format_placeholders.c @@ -7,8 +7,8 @@ */ #include "libi3.h" -#include #include +#include #include #ifndef CS_STARTS_WITH diff --git a/libi3/g_utf8_make_valid.c b/libi3/g_utf8_make_valid.c index b15873b37..71beafd30 100644 --- a/libi3/g_utf8_make_valid.c +++ b/libi3/g_utf8_make_valid.c @@ -19,8 +19,8 @@ #include "libi3.h" -#include #include +#include /* Copied from: * https://gitlab.gnome.org/GNOME/glib/blob/f928dfdf57bf92c883b53b16d7a9d49add504f52/glib/gutf8.c#L1752-1815 */ diff --git a/libi3/get_colorpixel.c b/libi3/get_colorpixel.c index 459310516..b60ffbac3 100644 --- a/libi3/get_colorpixel.c +++ b/libi3/get_colorpixel.c @@ -6,12 +6,11 @@ * */ #include "libi3.h" +#include "queue.h" -#include #include +#include #include - -#include "queue.h" struct Colorpixel { char hex[8]; uint32_t pixel; diff --git a/libi3/get_exe_path.c b/libi3/get_exe_path.c index 430fb2e07..762b4965e 100644 --- a/libi3/get_exe_path.c +++ b/libi3/get_exe_path.c @@ -7,12 +7,12 @@ */ #include "libi3.h" -#include -#include -#include +#include #include +#include #include -#include +#include +#include /* * This function returns the absolute path to the executable it is running in. diff --git a/libi3/get_mod_mask.c b/libi3/get_mod_mask.c index 98031d4ce..92af456df 100644 --- a/libi3/get_mod_mask.c +++ b/libi3/get_mod_mask.c @@ -9,6 +9,7 @@ #include #include + #include #include diff --git a/libi3/get_process_filename.c b/libi3/get_process_filename.c index 7e2ecbd24..6e155ea8a 100644 --- a/libi3/get_process_filename.c +++ b/libi3/get_process_filename.c @@ -8,16 +8,15 @@ #include "libi3.h" #include +#include +#include +#include #include #include #include -#include -#include #include #include -#include #include -#include /* * Returns the name of a temporary file with the specified prefix. diff --git a/libi3/ipc_connect.c b/libi3/ipc_connect.c index f659a1a47..614ccdf38 100644 --- a/libi3/ipc_connect.c +++ b/libi3/ipc_connect.c @@ -7,14 +7,14 @@ */ #include "libi3.h" -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include -#include /* * Connects to the i3 IPC socket and returns the file descriptor for the diff --git a/libi3/ipc_recv_message.c b/libi3/ipc_recv_message.c index 84da5aa36..6364b16d0 100644 --- a/libi3/ipc_recv_message.c +++ b/libi3/ipc_recv_message.c @@ -7,15 +7,14 @@ */ #include "libi3.h" -#include -#include -#include -#include -#include #include -#include - #include +#include +#include +#include +#include +#include +#include /* * Reads a message from the given socket file descriptor and stores its length diff --git a/libi3/ipc_send_message.c b/libi3/ipc_send_message.c index c2cc0127d..106db348e 100644 --- a/libi3/ipc_send_message.c +++ b/libi3/ipc_send_message.c @@ -7,14 +7,13 @@ */ #include "libi3.h" -#include -#include -#include -#include #include #include - #include +#include +#include +#include +#include /* * Formats a message (payload) of the given size and type and sends it to i3 via diff --git a/libi3/is_debug_build.c b/libi3/is_debug_build.c index 52187bdae..afd06237c 100644 --- a/libi3/is_debug_build.c +++ b/libi3/is_debug_build.c @@ -7,8 +7,8 @@ */ #include "libi3.h" -#include #include +#include /* * Returns true if this version of i3 is a debug build (anything which is not a diff --git a/libi3/root_atom_contents.c b/libi3/root_atom_contents.c index d6394d4bf..134733a2d 100644 --- a/libi3/root_atom_contents.c +++ b/libi3/root_atom_contents.c @@ -7,12 +7,12 @@ */ #include "libi3.h" -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include #include diff --git a/libi3/safewrappers.c b/libi3/safewrappers.c index fdea636ee..d4225ffe0 100644 --- a/libi3/safewrappers.c +++ b/libi3/safewrappers.c @@ -7,13 +7,13 @@ */ #include "libi3.h" -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include /* * The s* functions (safe) are wrappers around malloc, strdup, …, which exits if one of diff --git a/libi3/string.c b/libi3/string.c index 9efa36903..da18c550b 100644 --- a/libi3/string.c +++ b/libi3/string.c @@ -11,11 +11,10 @@ */ #include "libi3.h" +#include #include #include -#include - struct _i3String { char *utf8; xcb_char2b_t *ucs2; diff --git a/libi3/strndup.c b/libi3/strndup.c index e215a76fd..533958d2e 100644 --- a/libi3/strndup.c +++ b/libi3/strndup.c @@ -7,8 +7,8 @@ */ #include "libi3.h" -#include #include +#include #ifndef HAVE_strndup /* diff --git a/src/bindings.c b/src/bindings.c index 03dc23065..74d70c5c0 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -8,8 +8,8 @@ */ #include "all.h" -#include #include +#include static struct xkb_context *xkb_context; static struct xkb_keymap *xkb_keymap; diff --git a/src/click.c b/src/click.c index 12e391b53..7cd32e111 100644 --- a/src/click.c +++ b/src/click.c @@ -9,12 +9,11 @@ */ #include "all.h" -#include #include - -#include +#include #include +#include typedef enum { CLICK_BORDER = 0, CLICK_DECORATION = 1, diff --git a/src/commands.c b/src/commands.c index d20246522..c96651d09 100644 --- a/src/commands.c +++ b/src/commands.c @@ -8,14 +8,13 @@ * */ #include "all.h" +#include "shmlog.h" -#include +#include #include #include +#include #include -#include - -#include "shmlog.h" // Macros to make the YAJL API a bit easier to use. #define y(x, ...) (cmd_output->json_gen != NULL ? yajl_gen_##x(cmd_output->json_gen, ##__VA_ARGS__) : 0) diff --git a/src/commands_parser.c b/src/commands_parser.c index 2fd763095..35005d0e1 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -25,12 +25,12 @@ */ #include "all.h" +#include +#include #include #include #include #include -#include -#include // Macros to make the YAJL API a bit easier to use. #define y(x, ...) (command_output.json_gen != NULL ? yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__) : 0) diff --git a/src/con.c b/src/con.c index 08bb7e4ed..d9a792214 100644 --- a/src/con.c +++ b/src/con.c @@ -10,7 +10,6 @@ * */ #include "all.h" - #include "yajl_utils.h" static void con_on_remove_child(Con *con); diff --git a/src/config_parser.c b/src/config_parser.c index f120cfa36..f78e75f83 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -25,16 +25,17 @@ */ #include "all.h" +#include +#include +#include #include #include #include -#include -#include -#include +#include #include #include -#include -#include +#include + #include // Macros to make the YAJL API a bit easier to use. diff --git a/src/display_version.c b/src/display_version.c index e44540e08..1fff8b8e4 100644 --- a/src/display_version.c +++ b/src/display_version.c @@ -10,12 +10,12 @@ */ #include "all.h" -#include -#include -#include +#include #include +#include +#include #include -#include +#include #include static bool human_readable_key, loaded_config_file_name_key; diff --git a/src/handlers.c b/src/handlers.c index d6d6e20bc..c49ebf77c 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -10,9 +10,10 @@ */ #include "all.h" -#include #include #include +#include + #include #define SN_API_NOT_YET_FROZEN 1 #include diff --git a/src/ipc.c b/src/ipc.c index 75fa8ee74..7e62b1024 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -7,16 +7,17 @@ * ipc.c: UNIX domain socket IPC (initialization, client handling, protocol). * */ -#include "all.h" +#include "all.h" #include "yajl_utils.h" +#include +#include +#include #include #include #include -#include -#include -#include + #include #include diff --git a/src/log.c b/src/log.c index 31db8b33c..73093da1f 100644 --- a/src/log.c +++ b/src/log.c @@ -9,27 +9,27 @@ */ #include +#include "i3.h" +#include "libi3.h" +#include "log.h" +#include "shmlog.h" +#include "util.h" + +#include +#include #include -#include -#include #include +#include #include -#include -#include -#include +#include #include #include -#include +#include +#include #if !defined(__OpenBSD__) #include #endif -#include "util.h" -#include "log.h" -#include "i3.h" -#include "libi3.h" -#include "shmlog.h" - #if defined(__APPLE__) #include #endif diff --git a/src/main.c b/src/main.c index 369f2f66d..c64bf43d7 100644 --- a/src/main.c +++ b/src/main.c @@ -8,18 +8,18 @@ * */ #include "all.h" +#include "shmlog.h" #include #include -#include -#include -#include -#include -#include +#include #include +#include +#include #include -#include -#include "shmlog.h" +#include +#include +#include #ifdef I3_ASAN_ENABLED #include diff --git a/src/manage.c b/src/manage.c index eecba95c5..da5751dc6 100644 --- a/src/manage.c +++ b/src/manage.c @@ -8,7 +8,6 @@ * */ #include "all.h" - #include "yajl_utils.h" #include diff --git a/src/randr.c b/src/randr.c index b163eca7d..56b0707fc 100644 --- a/src/randr.c +++ b/src/randr.c @@ -12,6 +12,7 @@ #include "all.h" #include + #include /* Pointer to the result of the query for primary output */ diff --git a/src/sd-daemon.c b/src/sd-daemon.c index 28a88bfd7..84761025b 100644 --- a/src/sd-daemon.c +++ b/src/sd-daemon.c @@ -28,21 +28,21 @@ #define _GNU_SOURCE #endif -#include -#include -#include -#include -#include -#include -#include +#include "sd-daemon.h" + #include -#include -#include +#include #include -#include #include - -#include "sd-daemon.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include int sd_listen_fds(int unset_environment) { int r, fd; diff --git a/src/sighandler.c b/src/sighandler.c index 86921b400..90e6c798d 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -12,9 +12,8 @@ #include #include -#include - #include +#include typedef struct dialog_t { xcb_window_t id; diff --git a/src/startup.c b/src/startup.c index e994e0a8d..759b373c7 100644 --- a/src/startup.c +++ b/src/startup.c @@ -11,12 +11,11 @@ * */ #include "all.h" - #include "sd-daemon.h" +#include #include #include -#include #define SN_API_NOT_YET_FROZEN 1 #include diff --git a/src/util.c b/src/util.c index 3544297c9..a21c7e5fb 100644 --- a/src/util.c +++ b/src/util.c @@ -10,16 +10,17 @@ */ #include "all.h" -#include #include +#include #if defined(__OpenBSD__) #include #endif +#include #include +#include #include + #include -#include -#include #define SN_API_NOT_YET_FROZEN 1 #include diff --git a/src/xcursor.c b/src/xcursor.c index cffb094b1..9b4996ea8 100644 --- a/src/xcursor.c +++ b/src/xcursor.c @@ -9,13 +9,13 @@ */ #include +#include "i3.h" +#include "xcb.h" + #include #include -#include -#include "i3.h" -#include "xcb.h" -#include "xcursor.h" +#include static xcb_cursor_context_t *ctx; static xcb_cursor_t cursors[XCURSOR_CURSOR_MAX]; diff --git a/testcases/inject_randr1.5.c b/testcases/inject_randr1.5.c index 819c029ba..0b7512280 100644 --- a/testcases/inject_randr1.5.c +++ b/testcases/inject_randr1.5.c @@ -16,15 +16,15 @@ #include #include -#include -#include -#include -#include -#include +#include #include +#include +#include #include +#include +#include +#include #include -#include static void uds_connection_cb(EV_P_ ev_io *w, int revents); static void read_client_setup_request_cb(EV_P_ ev_io *w, int revents); From 0b621292246f2736eeed82ef106f64749c058f68 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 19 Apr 2020 11:12:39 +0200 Subject: [PATCH 02/11] Remove unused headers With help from https://github.com/include-what-you-use/include-what-you-use/ --- i3-config-wizard/main.c | 8 ++------ i3-dump-log/main.c | 5 ----- i3-input/main.c | 4 ---- i3-msg/main.c | 8 -------- i3bar/include/common.h | 2 -- i3bar/src/child.c | 4 ---- i3bar/src/config.c | 3 --- i3bar/src/ipc.c | 3 --- i3bar/src/main.c | 2 -- i3bar/src/mode.c | 3 --- i3bar/src/outputs.c | 2 -- i3bar/src/parse_json_header.c | 13 ------------- i3bar/src/workspaces.c | 3 --- i3bar/src/xcb.c | 10 ---------- libi3/draw_util.c | 2 -- libi3/fake_configure_notify.c | 1 - libi3/font.c | 1 - libi3/format_placeholders.c | 1 - libi3/get_exe_path.c | 2 -- libi3/get_process_filename.c | 5 ----- libi3/ipc_connect.c | 2 -- libi3/ipc_recv_message.c | 2 -- libi3/ipc_send_message.c | 5 ----- libi3/is_debug_build.c | 1 - libi3/root_atom_contents.c | 3 --- libi3/safewrappers.c | 2 -- libi3/strndup.c | 1 - libi3/ucs2_conversion.c | 1 - src/click.c | 4 ---- src/commands.c | 2 -- src/commands_parser.c | 7 ------- src/config_directives.c | 3 --- src/display_version.c | 5 ----- src/handlers.c | 1 - src/load_layout.c | 3 --- src/main.c | 1 + src/manage.c | 3 --- src/sighandler.c | 5 ----- src/util.c | 7 ------- 39 files changed, 3 insertions(+), 137 deletions(-) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 61db75ecd..9e07d1f7d 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -10,6 +10,8 @@ */ #include +#include "libi3.h" + #if defined(__FreeBSD__) #include #endif @@ -23,17 +25,12 @@ #define _WITH_GETLINE #endif -#include #include #include #include #include #include -#include #include -#include -#include -#include #include #include #include @@ -68,7 +65,6 @@ #include "xcb.h" xcb_visualtype_t *visual_type = NULL; -#include "libi3.h" #define TEXT_PADDING logical_px(4) #define WIN_POS_X logical_px(490) diff --git a/i3-dump-log/main.c b/i3-dump-log/main.c index e55f1d3c9..e58b0c379 100644 --- a/i3-dump-log/main.c +++ b/i3-dump-log/main.c @@ -13,11 +13,9 @@ #include "shmlog.h" #include -#include #include #include #include -#include #include #include #include @@ -25,10 +23,7 @@ #include #include #include -#include #include -#include -#include #include #if !defined(__OpenBSD__) diff --git a/i3-input/main.c b/i3-input/main.c index 1a4cbc7d1..dc38b8a6a 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -8,10 +8,7 @@ * to i3. * */ -#include -#include #include -#include #include #include #include @@ -22,7 +19,6 @@ #include #include -#include #include xcb_visualtype_t *visual_type = NULL; diff --git a/i3-msg/main.c b/i3-msg/main.c index dd72bd561..0b0ef4e39 100644 --- a/i3-msg/main.c +++ b/i3-msg/main.c @@ -17,24 +17,16 @@ #include "libi3.h" #include -#include #include #include -#include #include #include #include #include #include -#include -#include -#include #include -#include -#include #include -#include /* * Having verboselog() and errorlog() is necessary when using libi3. diff --git a/i3bar/include/common.h b/i3bar/include/common.h index 222f42dd9..2d763133b 100644 --- a/i3bar/include/common.h +++ b/i3bar/include/common.h @@ -9,7 +9,6 @@ #include -#include #include #include #include "libi3.h" @@ -94,5 +93,4 @@ extern TAILQ_HEAD(statusline_head, status_block) #include "trayclients.h" #include "xcb.h" #include "configuration.h" -#include "libi3.h" #include "parse_json_header.h" diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 4723dbc57..871c23052 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -20,15 +20,11 @@ #include #include #include -#include #include #include -#include -#include #include #include -#include /* Global variables for child_*() */ i3bar_child child; diff --git a/i3bar/src/config.c b/i3bar/src/config.c index 48f49b898..5d4bf88a4 100644 --- a/i3bar/src/config.c +++ b/i3bar/src/config.c @@ -9,15 +9,12 @@ */ #include "common.h" -#include -#include #include #include #include #include #include -#include config_t config; static char *cur_key; diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index d2edfe787..f2c105ac3 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -13,11 +13,8 @@ #include #include #include -#include #include #include -#include -#include #include #ifdef I3_ASAN_ENABLED #include diff --git a/i3bar/src/main.c b/i3bar/src/main.c index b3e23cda7..4e729341b 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -7,7 +7,6 @@ */ #include "common.h" -#include #include #include #include @@ -15,7 +14,6 @@ #include #include #include -#include struct ev_loop *main_loop; diff --git a/i3bar/src/mode.c b/i3bar/src/mode.c index 1f0e22fa8..13d02110a 100644 --- a/i3bar/src/mode.c +++ b/i3bar/src/mode.c @@ -9,13 +9,10 @@ */ #include "common.h" -#include -#include #include #include #include -#include /* A datatype to pass through the callbacks to save the state */ struct mode_json_params { diff --git a/i3bar/src/outputs.c b/i3bar/src/outputs.c index f1dab9f16..46b9c9548 100644 --- a/i3bar/src/outputs.c +++ b/i3bar/src/outputs.c @@ -10,13 +10,11 @@ #include "common.h" #include -#include #include #include #include #include -#include /* A datatype to pass through the callbacks to save the state */ struct outputs_json_params { diff --git a/i3bar/src/parse_json_header.c b/i3bar/src/parse_json_header.c index cd857d917..c74a62fee 100644 --- a/i3bar/src/parse_json_header.c +++ b/i3bar/src/parse_json_header.c @@ -10,23 +10,10 @@ */ #include "common.h" -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include static enum { KEY_VERSION, diff --git a/i3bar/src/workspaces.c b/i3bar/src/workspaces.c index 51b863ca4..bd56f5d09 100644 --- a/i3bar/src/workspaces.c +++ b/i3bar/src/workspaces.c @@ -9,13 +9,10 @@ */ #include "common.h" -#include -#include #include #include #include -#include /* A datatype to pass through the callbacks to save the state */ struct workspaces_json_params { diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 0b0e23b09..5241f1410 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -10,24 +10,14 @@ #include "common.h" #include -#include #include -#include #include -#include -#include #include #include -#include -#include -#include -#include -#include #include #include #include -#include #ifdef I3_ASAN_ENABLED #include diff --git a/libi3/draw_util.c b/libi3/draw_util.c index 710c536a3..313dc29ac 100644 --- a/libi3/draw_util.c +++ b/libi3/draw_util.c @@ -8,8 +8,6 @@ */ #include "libi3.h" -#include -#include #include #include diff --git a/libi3/fake_configure_notify.c b/libi3/fake_configure_notify.c index e79a748b2..5d87c3dac 100644 --- a/libi3/fake_configure_notify.c +++ b/libi3/fake_configure_notify.c @@ -7,7 +7,6 @@ */ #include "libi3.h" -#include #include #include diff --git a/libi3/font.c b/libi3/font.c index e89455240..5ed58b8d7 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/libi3/format_placeholders.c b/libi3/format_placeholders.c index 99fa3055a..71870a7b1 100644 --- a/libi3/format_placeholders.c +++ b/libi3/format_placeholders.c @@ -7,7 +7,6 @@ */ #include "libi3.h" -#include #include #include diff --git a/libi3/get_exe_path.c b/libi3/get_exe_path.c index 762b4965e..3b46ef82f 100644 --- a/libi3/get_exe_path.c +++ b/libi3/get_exe_path.c @@ -8,8 +8,6 @@ #include "libi3.h" #include -#include -#include #include #include #include diff --git a/libi3/get_process_filename.c b/libi3/get_process_filename.c index 6e155ea8a..21429ec36 100644 --- a/libi3/get_process_filename.c +++ b/libi3/get_process_filename.c @@ -7,15 +7,10 @@ */ #include "libi3.h" -#include #include #include -#include -#include #include -#include #include -#include #include /* diff --git a/libi3/ipc_connect.c b/libi3/ipc_connect.c index 614ccdf38..871fe083b 100644 --- a/libi3/ipc_connect.c +++ b/libi3/ipc_connect.c @@ -12,9 +12,7 @@ #include #include #include -#include #include -#include /* * Connects to the i3 IPC socket and returns the file descriptor for the diff --git a/libi3/ipc_recv_message.c b/libi3/ipc_recv_message.c index 6364b16d0..516405b00 100644 --- a/libi3/ipc_recv_message.c +++ b/libi3/ipc_recv_message.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include diff --git a/libi3/ipc_send_message.c b/libi3/ipc_send_message.c index 106db348e..4faeea7fd 100644 --- a/libi3/ipc_send_message.c +++ b/libi3/ipc_send_message.c @@ -7,13 +7,8 @@ */ #include "libi3.h" -#include -#include #include #include -#include -#include -#include /* * Formats a message (payload) of the given size and type and sends it to i3 via diff --git a/libi3/is_debug_build.c b/libi3/is_debug_build.c index afd06237c..cb53407ec 100644 --- a/libi3/is_debug_build.c +++ b/libi3/is_debug_build.c @@ -7,7 +7,6 @@ */ #include "libi3.h" -#include #include /* diff --git a/libi3/root_atom_contents.c b/libi3/root_atom_contents.c index 134733a2d..6feb31bc8 100644 --- a/libi3/root_atom_contents.c +++ b/libi3/root_atom_contents.c @@ -7,10 +7,7 @@ */ #include "libi3.h" -#include #include -#include -#include #include #include diff --git a/libi3/safewrappers.c b/libi3/safewrappers.c index d4225ffe0..767a0f05e 100644 --- a/libi3/safewrappers.c +++ b/libi3/safewrappers.c @@ -9,8 +9,6 @@ #include #include -#include -#include #include #include #include diff --git a/libi3/strndup.c b/libi3/strndup.c index 533958d2e..a0e87cf6e 100644 --- a/libi3/strndup.c +++ b/libi3/strndup.c @@ -8,7 +8,6 @@ #include "libi3.h" #include -#include #ifndef HAVE_strndup /* diff --git a/libi3/ucs2_conversion.c b/libi3/ucs2_conversion.c index c651cdb32..c74672395 100644 --- a/libi3/ucs2_conversion.c +++ b/libi3/ucs2_conversion.c @@ -8,7 +8,6 @@ #include "libi3.h" #include -#include #include #include #include diff --git a/src/click.c b/src/click.c index 7cd32e111..64d78315d 100644 --- a/src/click.c +++ b/src/click.c @@ -9,12 +9,8 @@ */ #include "all.h" -#include #include -#include -#include - typedef enum { CLICK_BORDER = 0, CLICK_DECORATION = 1, CLICK_INSIDE = 2 } click_destination_t; diff --git a/src/commands.c b/src/commands.c index c96651d09..fa15c33ff 100644 --- a/src/commands.c +++ b/src/commands.c @@ -11,8 +11,6 @@ #include "shmlog.h" #include -#include -#include #include #include diff --git a/src/commands_parser.c b/src/commands_parser.c index 35005d0e1..6c7914151 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -25,13 +25,6 @@ */ #include "all.h" -#include -#include -#include -#include -#include -#include - // Macros to make the YAJL API a bit easier to use. #define y(x, ...) (command_output.json_gen != NULL ? yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__) : 0) #define ystr(str) (command_output.json_gen != NULL ? yajl_gen_string(command_output.json_gen, (unsigned char *)str, strlen(str)) : 0) diff --git a/src/config_directives.c b/src/config_directives.c index 4f9e415fc..c039e35f2 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -9,9 +9,6 @@ */ #include "all.h" -#include -#include - /******************************************************************************* * Criteria functions. ******************************************************************************/ diff --git a/src/display_version.c b/src/display_version.c index 1fff8b8e4..0185d1ed0 100644 --- a/src/display_version.c +++ b/src/display_version.c @@ -11,11 +11,6 @@ #include "all.h" #include -#include -#include -#include -#include -#include #include static bool human_readable_key, loaded_config_file_name_key; diff --git a/src/handlers.c b/src/handlers.c index c49ebf77c..fa892cc47 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -10,7 +10,6 @@ */ #include "all.h" -#include #include #include diff --git a/src/load_layout.c b/src/load_layout.c index b69b388c8..ccf965daa 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -10,10 +10,7 @@ */ #include "all.h" -#include -#include #include -#include /* TODO: refactor the whole parsing thing */ diff --git a/src/main.c b/src/main.c index c64bf43d7..95781d0cb 100644 --- a/src/main.c +++ b/src/main.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/manage.c b/src/manage.c index da5751dc6..5f860d4ae 100644 --- a/src/manage.c +++ b/src/manage.c @@ -8,9 +8,6 @@ * */ #include "all.h" -#include "yajl_utils.h" - -#include /* * Match frame and window depth. This is needed because X will refuse to reparent a diff --git a/src/sighandler.c b/src/sighandler.c index 90e6c798d..a55c505b2 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -7,14 +7,9 @@ */ #include "all.h" -#include -#include #include #include -#include -#include - typedef struct dialog_t { xcb_window_t id; xcb_colormap_t colormap; diff --git a/src/util.c b/src/util.c index a21c7e5fb..734018d4c 100644 --- a/src/util.c +++ b/src/util.c @@ -10,7 +10,6 @@ */ #include "all.h" -#include #include #if defined(__OpenBSD__) #include @@ -18,12 +17,6 @@ #include #include #include -#include - -#include - -#define SN_API_NOT_YET_FROZEN 1 -#include int min(int a, int b) { return (a < b ? a : b); From 2954125324431c3d5605e2490769b54410d41110 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 19 Apr 2020 11:14:20 +0200 Subject: [PATCH 03/11] nagbar: Remove i3-nagbar.h --- Makefile.am | 1 - i3-config-wizard/main.c | 1 + i3-nagbar/i3-nagbar.h | 18 ------------------ i3-nagbar/main.c | 22 ++++++++++++---------- 4 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 i3-nagbar/i3-nagbar.h diff --git a/Makefile.am b/Makefile.am index 089c4a227..e52fe2cb5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -379,7 +379,6 @@ i3_nagbar_i3_nagbar_LDADD = \ i3_nagbar_i3_nagbar_SOURCES = \ i3-nagbar/atoms.xmacro \ - i3-nagbar/i3-nagbar.h \ i3-nagbar/main.c i3bar_i3bar_CPPFLAGS = \ diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 9e07d1f7d..e857f1b4c 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -9,6 +9,7 @@ * */ #include +#include "libi3.h" #include "libi3.h" diff --git a/i3-nagbar/i3-nagbar.h b/i3-nagbar/i3-nagbar.h deleted file mode 100644 index cb672bead..000000000 --- a/i3-nagbar/i3-nagbar.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include - -#include - -#define die(...) errx(EXIT_FAILURE, __VA_ARGS__); -#define FREE(pointer) \ - do { \ - free(pointer); \ - pointer = NULL; \ - } while (0) - -#define xmacro(atom) xcb_atom_t A_##atom; -#include "atoms.xmacro" -#undef xmacro - -extern xcb_window_t root; diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index 5558865b3..be29aa0f1 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -8,15 +8,15 @@ * when the user has an error in their configuration file. * */ +#include +#include "libi3.h" + #include -#include #include #include #include #include -#include #include -#include #include #include #include @@ -28,14 +28,10 @@ #include #include #include -#include xcb_visualtype_t *visual_type = NULL; -#include "libi3.h" #define SN_API_NOT_YET_FROZEN 1 -#include "i3-nagbar.h" - #include #define MSG_PADDING logical_px(8) @@ -45,6 +41,12 @@ xcb_visualtype_t *visual_type = NULL; #define CLOSE_BTN_GAP logical_px(15) #define BAR_BORDER logical_px(2) +#define xmacro(atom) xcb_atom_t A_##atom; +#include "atoms.xmacro" +#undef xmacro + +#define die(...) errx(EXIT_FAILURE, __VA_ARGS__); + static char *argv0 = NULL; typedef struct { @@ -314,8 +316,8 @@ static xcb_rectangle_t get_window_position(void) { goto free_resources; free_resources: - FREE(res); - FREE(primary); + free(res); + free(primary); return result; } @@ -598,7 +600,7 @@ int main(int argc, char *argv[]) { free(event); } - FREE(pattern); + free(pattern); draw_util_surface_free(conn, &bar); return 0; From af7c4ae76b2b4a88af52d77a2ffecb5da2ad051f Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Mon, 20 Apr 2020 04:14:26 +0200 Subject: [PATCH 04/11] generate-command-parser: Add '#pragma once' --- generate-command-parser.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generate-command-parser.pl b/generate-command-parser.pl index a017edab2..77502db7e 100755 --- a/generate-command-parser.pl +++ b/generate-command-parser.pl @@ -117,6 +117,7 @@ sub slurp { open(my $enumfh, '>', "GENERATED_${prefix}_enums.h"); my %statenum; +say $enumfh '#pragma once'; say $enumfh 'typedef enum {'; my $cnt = 0; for my $state (@keys, '__CALL') { @@ -131,6 +132,7 @@ sub slurp { # Third step: Generate the call function. open(my $callfh, '>', "GENERATED_${prefix}_call.h"); my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR'; +say $callfh '#pragma once'; say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {"; say $callfh ' switch (call_identifier) {'; my $call_id = 0; @@ -206,6 +208,7 @@ sub slurp { # Fourth step: Generate the token datastructures. open(my $tokfh, '>', "GENERATED_${prefix}_tokens.h"); +say $tokfh '#pragma once'; for my $state (@keys) { my $tokens = $states{$state}; From 38f28186ec91799d4280ee4f6bfafd1a8c8a9801 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 19 Apr 2020 11:22:59 +0200 Subject: [PATCH 05/11] Remove some includes from all.h Also removes duplicates from other headers All used std* imports are included once in all.h for easy use - getopt: Only used in main.c and inject_randr1.5.c - glob: Not used in i3, only in i3bar & libi3 - inttypes: Only used in util.c - locale: A bit specific for all.h - math: Slow according to #4022 - unistd: I feel it's good to explicitly include per file that needs it - yajl: Specific to yajl_utils.h and ipc.h Related to #4022 Timing before: ``` Analyzing build trace from ... **** Time summary: Compilation (81 times): Parsing (frontend): 51.3 s Codegen & opts (backend): 7.7 s **** Files that took longest to parse (compiler frontend): 1254 ms: build/src/i3-commands.o 972 ms: build/src/i3-resize.o 945 ms: build/src/i3-con.o 921 ms: build/src/i3-scratchpad.o 907 ms: build/src/i3-main.o 904 ms: build/src/i3-handlers.o 904 ms: build/src/i3-config_directives.o 893 ms: build/src/i3-restore_layout.o 875 ms: build/src/i3-x.o 854 ms: build/src/i3-ipc.o **** Files that took longest to codegen (compiler backend): 863 ms: build/src/i3-commands.o 471 ms: build/i3bar/src/i3bar-xcb.o 377 ms: build/src/i3-con.o 360 ms: build/src/i3-ipc.o 306 ms: build/src/i3-x.o 290 ms: build/src/i3-main.o 238 ms: build/src/i3-config_parser.o 237 ms: build/src/i3-handlers.o 220 ms: build/i3-config-wizard/i3_config_wizard-main.o 214 ms: build/src/i3-bindings.o **** Functions that took longest to compile: 209 ms: main (../../i3/src/main.c) 95 ms: manage_window (../../i3/src/manage.c) 57 ms: reconfig_windows (../../i3/i3bar/src/xcb.c) 55 ms: x_draw_decoration (../../i3/src/x.c) 49 ms: x_push_node (../../i3/src/x.c) 48 ms: handle_client_message (../../i3/src/handlers.c) 48 ms: dump_node (../../i3/src/ipc.c) 47 ms: GENERATED_call (../../i3/src/config_parser.c) 45 ms: config_string_cb (../../i3/i3bar/src/config.c) 44 ms: GENERATED_call (../../i3/src/commands_parser.c) 42 ms: floating_check_size (../../i3/src/floating.c) 40 ms: con_swap (../../i3/src/con.c) 40 ms: parse_config (../../i3/src/config_parser.c) 39 ms: main (../../i3/i3-nagbar/main.c) 39 ms: cmd_rename_workspace (../../i3/src/commands.c) 38 ms: window_update_normal_hints (../../i3/src/window.c) 38 ms: cmd_swap (../../i3/src/commands.c) 37 ms: dump_bar_config (../../i3/src/ipc.c) 36 ms: translate_keysyms (../../i3/src/bindings.c) 35 ms: tree_close_internal (../../i3/src/tree.c) 34 ms: match_matches_window (../../i3/src/match.c) 34 ms: floating_enable (../../i3/src/floating.c) 34 ms: json_string (../../i3/src/load_layout.c) 33 ms: x_push_changes (../../i3/src/x.c) 33 ms: main (../../i3/i3-config-wizard/main.c) 31 ms: free_configuration (../../i3/src/config.c) 30 ms: parse_file (../../i3/src/config_parser.c) 28 ms: load_font (../../i3/libi3/font.c) 28 ms: handle_configure_request (../../i3/src/handlers.c) 28 ms: parse_command (../../i3/src/commands_parser.c) **** Function sets that took longest to compile / optimize: *** Expensive headers: 29287 ms: ../../i3/include/libi3.h (included 78 times, avg 375 ms), included via: i3-resize.o all.h data.h (576 ms) a-g_utf8_make_valid.o (491 ms) a-dpi.o (491 ms) a-get_colorpixel.o (483 ms) a-is_debug_build.o (478 ms) a-strndup.o (478 ms) ... 29221 ms: ../../i3/include/all.h (included 39 times, avg 749 ms), included via: i3-resize.o (946 ms) i3-scratchpad.o (895 ms) i3-restore_layout.o (865 ms) i3-handlers.o (839 ms) i3-drag.o (830 ms) i3-config_directives.o (793 ms) ... 5195 ms: /usr/include/xcb/xcb.h (included 79 times, avg 65 ms), included via: i3-handlers.o all.h (113 ms) i3-restore_layout.o all.h (108 ms) a-g_utf8_make_valid.o libi3.h (108 ms) i3bar-xcb.o common.h (105 ms) i3-scratchpad.o all.h (95 ms) a-get_colorpixel.o libi3.h (89 ms) ... 4100 ms: /usr/include/math.h (included 41 times, avg 100 ms), included via: i3-scratchpad.o all.h (180 ms) i3-fake_outputs.o all.h (138 ms) i3-regex.o all.h (130 ms) i3-restore_layout.o all.h (128 ms) i3-xcb.o all.h (121 ms) i3-move.o all.h (119 ms) ... 4046 ms: ../../i3/i3bar/include/common.h (included 9 times, avg 449 ms), included via: i3bar-main.o (503 ms) i3bar-xcb.o (501 ms) i3bar-workspaces.o (472 ms) i3bar-parse_json_header.o (446 ms) i3bar-child.o (438 ms) i3bar-ipc.o (434 ms) ... 2713 ms: ../../i3/include/i3.h (included 41 times, avg 66 ms), included via: i3-xcursor.o (450 ms) i3-config_directives.o all.h ipc.h configuration.h (87 ms) i3-config.o all.h ipc.h configuration.h (71 ms) i3-manage.o all.h ipc.h configuration.h (70 ms) i3-window.o all.h ipc.h configuration.h (68 ms) i3-x.o all.h ipc.h configuration.h (61 ms) ... 1492 ms: /usr/include/xcb/xkb.h (included 42 times, avg 35 ms), included via: i3-config_directives.o all.h ipc.h configuration.h i3.h (50 ms) i3-config.o all.h ipc.h configuration.h i3.h (45 ms) i3-window.o all.h ipc.h configuration.h i3.h (43 ms) i3-x.o all.h ipc.h configuration.h i3.h (42 ms) i3-manage.o all.h ipc.h configuration.h i3.h (41 ms) i3-config_parser.o all.h ipc.h configuration.h i3.h (38 ms) ... 1432 ms: /usr/include/stdlib.h (included 79 times, avg 18 ms), included via: i3-scratchpad.o all.h (48 ms) i3-restore_layout.o all.h (36 ms) i3-regex.o all.h (32 ms) i3-key_press.o all.h (28 ms) i3-commands.o all.h (28 ms) i3-bindings.o all.h (24 ms) ... 1349 ms: /usr/include/pthread.h (included 79 times, avg 17 ms), included via: i3bar-xcb.o common.h xcb.h (33 ms) a-ucs2_conversion.o libi3.h xcb.h (32 ms) i3-match.o all.h xcb.h (27 ms) i3-scratchpad.o all.h xcb.h (25 ms) a-g_utf8_make_valid.o libi3.h xcb.h (25 ms) i3_config_wizard-main.o xcb.h (24 ms) ... 1151 ms: /usr/include/X11/Xlib.h (included 45 times, avg 25 ms), included via: i3-output.o all.h data.h sn-launcher.h sn-common.h (50 ms) i3-config_parser.o all.h data.h sn-launcher.h sn-common.h (43 ms) i3-x.o all.h data.h sn-launcher.h sn-common.h (34 ms) i3-config_directives.o all.h data.h sn-launcher.h sn-common.h (32 ms) i3_config_wizard-main.o sn-launchee.h sn-common.h (30 ms) i3-drag.o all.h data.h sn-launcher.h sn-common.h (29 ms) ... ``` Timing after: ``` Analyzing build trace from ... **** Time summary: Compilation (81 times): Parsing (frontend): 47.6 s Codegen & opts (backend): 7.6 s **** Files that took longest to parse (compiler frontend): 1154 ms: build/src/i3-commands.o 929 ms: build/src/i3-display_version.o 852 ms: build/src/i3-bindings.o 847 ms: build/src/i3-con.o 806 ms: build/src/i3-ipc.o 801 ms: build/src/i3-floating.o 792 ms: build/src/i3-main.o 792 ms: build/src/i3-drag.o 792 ms: build/src/i3-window.o 776 ms: build/src/i3-config_directives.o **** Files that took longest to codegen (compiler backend): 885 ms: build/src/i3-commands.o 422 ms: build/i3bar/src/i3bar-xcb.o 382 ms: build/src/i3-con.o 348 ms: build/src/i3-x.o 288 ms: build/src/i3-ipc.o 268 ms: build/src/i3-handlers.o 254 ms: build/src/i3-main.o 251 ms: build/src/i3-floating.o 249 ms: build/src/i3-config_parser.o 194 ms: build/src/i3-randr.o **** Functions that took longest to compile: 186 ms: main (../../i3/src/main.c) 95 ms: manage_window (../../i3/src/manage.c) 65 ms: floating_check_size (../../i3/src/floating.c) 63 ms: x_draw_decoration (../../i3/src/x.c) 58 ms: handle_client_message (../../i3/src/handlers.c) 55 ms: x_push_node (../../i3/src/x.c) 54 ms: match_matches_window (../../i3/src/match.c) 51 ms: parse_config (../../i3/src/config_parser.c) 49 ms: dump_node (../../i3/src/ipc.c) 47 ms: reconfig_windows (../../i3/i3bar/src/xcb.c) 47 ms: config_string_cb (../../i3/i3bar/src/config.c) 45 ms: GENERATED_call (../../i3/src/config_parser.c) 45 ms: GENERATED_call (../../i3/src/commands_parser.c) 43 ms: floating_enable (../../i3/src/floating.c) 42 ms: handle_configure_request (../../i3/src/handlers.c) 40 ms: con_swap (../../i3/src/con.c) 36 ms: main (../../i3/i3-input/main.c) 36 ms: main (../../i3/i3-msg/main.c) 36 ms: main (../../i3/i3-nagbar/main.c) 36 ms: cmd_move_con_to_workspace_number (../../i3/src/commands.c) 35 ms: json_string (../../i3/src/load_layout.c) 35 ms: tree_restore (../../i3/src/tree.c) 35 ms: cmd_swap (../../i3/src/commands.c) 34 ms: x_push_changes (../../i3/src/x.c) 32 ms: main (../../i3/i3-config-wizard/main.c) 32 ms: ewmh_setup_hints (../../i3/src/ewmh.c) 31 ms: match_parse_property (../../i3/src/match.c) 30 ms: cmd_mark (../../i3/src/commands.c) 30 ms: translate_keysyms (../../i3/src/bindings.c) 30 ms: window_update_normal_hints (../../i3/src/window.c) **** Function sets that took longest to compile / optimize: *** Expensive headers: 29596 ms: ../../i3/include/libi3.h (included 78 times, avg 379 ms), included via: a-get_config_path.o (539 ms) i3_dump_log-main.o (522 ms) i3_config_wizard-main.o (501 ms) a-fake_configure_notify.o (500 ms) a-root_atom_contents.o (488 ms) i3-display_version.o all.h (466 ms) ... 26054 ms: ../../i3/include/all.h (included 41 times, avg 635 ms), included via: i3-display_version.o (901 ms) i3-drag.o (775 ms) i3-ewmh.o (703 ms) i3-startup.o (693 ms) i3-commands.o (687 ms) i3-xcb.o (680 ms) ... 5345 ms: /usr/include/xcb/xcb.h (included 79 times, avg 67 ms), included via: i3-display_version.o all.h (173 ms) i3_input-keysym2ucs.o keysym2ucs.h (106 ms) i3-ewmh.o all.h (106 ms) a-fake_configure_notify.o libi3.h (103 ms) a-get_config_path.o libi3.h (95 ms) i3bar-parse_json_header.o common.h (93 ms) ... 4127 ms: ../../i3/i3bar/include/common.h (included 9 times, avg 458 ms), included via: i3bar-child.o (524 ms) i3bar-mode.o (486 ms) i3bar-outputs.o (464 ms) i3bar-parse_json_header.o (463 ms) i3bar-config.o (457 ms) i3bar-ipc.o (448 ms) ... 1542 ms: /usr/include/xcb/xkb.h (included 42 times, avg 36 ms), included via: i3-con.o all.h ipc.h configuration.h i3.h (60 ms) i3-render.o all.h ipc.h configuration.h i3.h (56 ms) i3-bindings.o all.h ipc.h configuration.h i3.h (56 ms) i3-sighandler.o all.h ipc.h configuration.h i3.h (48 ms) i3-xcb.o all.h ipc.h configuration.h i3.h (47 ms) i3-resize.o all.h ipc.h configuration.h i3.h (39 ms) ... 1456 ms: /usr/include/stdlib.h (included 79 times, avg 18 ms), included via: i3-drag.o all.h (60 ms) i3-display_version.o all.h (55 ms) i3-fake_outputs.o all.h (39 ms) i3-config_directives.o all.h (33 ms) i3-xcursor.o all.h (30 ms) i3bar-mode.o common.h libi3.h pango.h pango-attributes.h pango-font.h pango-coverage.h glib-object.h gbinding.h glib.h gasyncqueue.h gthread.h gutils.h (29 ms) ... 1136 ms: /usr/include/X11/Xlib.h (included 44 times, avg 25 ms), included via: i3-con.o all.h data.h sn-launcher.h sn-common.h (35 ms) i3-resize.o all.h data.h sn-launcher.h sn-common.h (34 ms) i3-util.o all.h data.h sn-launcher.h sn-common.h (33 ms) i3-assignments.o all.h data.h sn-launcher.h sn-common.h (33 ms) i3-sighandler.o all.h data.h sn-launcher.h sn-common.h (31 ms) i3-xcb.o all.h data.h sn-launcher.h sn-common.h (31 ms) ... 808 ms: /usr/include/stdio.h (included 79 times, avg 10 ms), included via: i3-drag.o all.h (19 ms) i3-fake_outputs.o all.h (18 ms) a-font.o libi3.h (16 ms) i3bar-child.o common.h libi3.h (15 ms) a-safewrappers.o libi3.h (15 ms) a-ipc_send_message.o libi3.h (13 ms) ... 770 ms: /usr/include/xcb/randr.h (included 42 times, avg 18 ms), included via: i3-click.o all.h data.h (29 ms) i3-commands.o all.h data.h (27 ms) i3-assignments.o all.h data.h (25 ms) i3-xcb.o all.h data.h (21 ms) i3-resize.o all.h data.h (21 ms) i3-sighandler.o all.h data.h (20 ms) ... 688 ms: /usr/include/math.h (included 6 times, avg 114 ms), included via: a-dpi.o (145 ms) i3-render.o (127 ms) i3-floating.o (106 ms) a-root_atom_contents.o (106 ms) i3-window.o (102 ms) i3-bindings.o (99 ms) ... ``` --- i3-config-wizard/main.c | 1 - i3-nagbar/main.c | 1 + include/all.h | 24 ++++++++---------------- include/configuration.h | 3 --- include/data.h | 3 --- include/ipc.h | 1 - include/log.h | 3 --- include/shmlog.h | 1 - include/xinerama.h | 2 -- src/bindings.c | 2 ++ src/display_version.c | 1 + src/floating.c | 2 ++ src/ipc.c | 2 ++ src/load_layout.c | 2 ++ src/log.c | 5 +---- src/main.c | 3 +++ src/render.c | 2 ++ src/sighandler.c | 1 + src/startup.c | 1 + src/util.c | 9 ++++++--- src/window.c | 2 ++ src/x.c | 2 ++ src/xcursor.c | 3 +-- testcases/inject_randr1.5.c | 2 ++ 24 files changed, 39 insertions(+), 39 deletions(-) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index e857f1b4c..9e07d1f7d 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -9,7 +9,6 @@ * */ #include -#include "libi3.h" #include "libi3.h" diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index be29aa0f1..51e5475c9 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -9,6 +9,7 @@ * */ #include + #include "libi3.h" #include diff --git a/include/all.h b/include/all.h index aa2b5b250..551119441 100644 --- a/include/all.h +++ b/include/all.h @@ -15,31 +15,24 @@ #include #include +#include +#include +#include +#include #include -#include +#include #include +#include #include -#include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include +#include -#include -#include - +#include "libi3.h" #include "data.h" #include "util.h" #include "ipc.h" @@ -72,7 +65,6 @@ #include "ewmh.h" #include "assignments.h" #include "regex.h" -#include "libi3.h" #include "startup.h" #include "scratchpad.h" #include "commands.h" diff --git a/include/configuration.h b/include/configuration.h index d7c2ab8b7..eae360579 100644 --- a/include/configuration.h +++ b/include/configuration.h @@ -12,9 +12,6 @@ */ #pragma once -#include "libi3.h" - -#include #include "queue.h" #include "i3.h" diff --git a/include/data.h b/include/data.h index e686d2c72..494dbe0a6 100644 --- a/include/data.h +++ b/include/data.h @@ -9,13 +9,10 @@ */ #pragma once -#include "libi3.h" - #define SN_API_NOT_YET_FROZEN 1 #include #include -#include #include #include diff --git a/include/ipc.h b/include/ipc.h index 8ea9fd2e4..bc5929ecf 100644 --- a/include/ipc.h +++ b/include/ipc.h @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/include/log.h b/include/log.h index 5c530231d..d3c3e3f3e 100644 --- a/include/log.h +++ b/include/log.h @@ -11,9 +11,6 @@ #include -#include -#include - /* We will include libi3.h which define its own version of LOG, ELOG. * We want *our* version, so we undef the libi3 one. */ #if defined(LOG) diff --git a/include/shmlog.h b/include/shmlog.h index dc8081f13..7b7e133a6 100644 --- a/include/shmlog.h +++ b/include/shmlog.h @@ -12,7 +12,6 @@ #include -#include #if !defined(__OpenBSD__) #include #endif diff --git a/include/xinerama.h b/include/xinerama.h index f01ee568c..52a5db335 100644 --- a/include/xinerama.h +++ b/include/xinerama.h @@ -13,8 +13,6 @@ #include -#include "data.h" - /** * We have just established a connection to the X server and need the initial * Xinerama information to setup workspaces for each screen. diff --git a/src/bindings.c b/src/bindings.c index 74d70c5c0..e29f2c2dc 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -8,6 +8,8 @@ */ #include "all.h" +#include + #include #include diff --git a/src/display_version.c b/src/display_version.c index 0185d1ed0..32250c155 100644 --- a/src/display_version.c +++ b/src/display_version.c @@ -12,6 +12,7 @@ #include #include +#include static bool human_readable_key, loaded_config_file_name_key; static char *human_readable_version, *loaded_config_file_name; diff --git a/src/floating.c b/src/floating.c index 4fed43e44..5e60aa829 100644 --- a/src/floating.c +++ b/src/floating.c @@ -9,6 +9,8 @@ */ #include "all.h" +#include + #ifndef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif diff --git a/src/ipc.c b/src/ipc.c index 7e62b1024..e616a53e1 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -14,9 +14,11 @@ #include #include #include +#include #include #include #include +#include #include #include diff --git a/src/load_layout.c b/src/load_layout.c index ccf965daa..c0be3f26a 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -10,6 +10,8 @@ */ #include "all.h" +#include + #include /* TODO: refactor the whole parsing thing */ diff --git a/src/log.c b/src/log.c index 73093da1f..326f82b8c 100644 --- a/src/log.c +++ b/src/log.c @@ -9,11 +9,8 @@ */ #include -#include "i3.h" -#include "libi3.h" -#include "log.h" +#include "all.h" #include "shmlog.h" -#include "util.h" #include #include diff --git a/src/main.c b/src/main.c index 95781d0cb..4f4c3fd6d 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,9 @@ #include #include +#include #include +#include #include #include #include @@ -21,6 +23,7 @@ #include #include #include +#include #ifdef I3_ASAN_ENABLED #include diff --git a/src/render.c b/src/render.c index 40704f521..bf96e4df7 100644 --- a/src/render.c +++ b/src/render.c @@ -10,6 +10,8 @@ */ #include "all.h" +#include + /* Forward declarations */ static int *precalculate_sizes(Con *con, render_params *p); static void render_root(Con *con, Con *fullscreen); diff --git a/src/sighandler.c b/src/sighandler.c index a55c505b2..c1e6094f2 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -9,6 +9,7 @@ #include #include +#include typedef struct dialog_t { xcb_window_t id; diff --git a/src/startup.c b/src/startup.c index 759b373c7..9b0576e8a 100644 --- a/src/startup.c +++ b/src/startup.c @@ -16,6 +16,7 @@ #include #include #include +#include #define SN_API_NOT_YET_FROZEN 1 #include diff --git a/src/util.c b/src/util.c index 734018d4c..6d8d2ee75 100644 --- a/src/util.c +++ b/src/util.c @@ -10,13 +10,16 @@ */ #include "all.h" +#include +#include +#include +#include +#include #include +#include #if defined(__OpenBSD__) #include #endif -#include -#include -#include int min(int a, int b) { return (a < b ? a : b); diff --git a/src/window.c b/src/window.c index d84f8869a..bee3fa668 100644 --- a/src/window.c +++ b/src/window.c @@ -9,6 +9,8 @@ */ #include "all.h" +#include + /* * Frees an i3Window and all its members. * diff --git a/src/x.c b/src/x.c index 712cf89c2..e89f52132 100644 --- a/src/x.c +++ b/src/x.c @@ -10,6 +10,8 @@ */ #include "all.h" +#include + #ifndef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif diff --git a/src/xcursor.c b/src/xcursor.c index 9b4996ea8..cb98399fa 100644 --- a/src/xcursor.c +++ b/src/xcursor.c @@ -9,8 +9,7 @@ */ #include -#include "i3.h" -#include "xcb.h" +#include "all.h" #include #include diff --git a/testcases/inject_randr1.5.c b/testcases/inject_randr1.5.c index 0b7512280..9c0b73d41 100644 --- a/testcases/inject_randr1.5.c +++ b/testcases/inject_randr1.5.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include static void uds_connection_cb(EV_P_ ev_io *w, int revents); static void read_client_setup_request_cb(EV_P_ ev_io *w, int revents); From f9ed0db69420e37f9f812514d74b0ca2ca8b45d1 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Apr 2020 09:21:16 +0200 Subject: [PATCH 06/11] Update debian/changelog --- debian/changelog | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index bfc6115ca..02b406492 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,14 @@ +i3-wm (4.18.2-1) unstable; urgency=medium + + * New upstream release. + + -- Michael Stapelberg Wed, 22 Apr 2020 09:04:42 +0200 + i3-wm (4.18.1-1) unstable; urgency=medium * New upstream release. - -- Michael Stapelberg Mon, 17 Feb 2020 18:25:47 +0100 + -- Michael Stapelberg Wed, 22 Apr 2020 09:04:42 +0200 i3-wm (4.18-1) unstable; urgency=medium From f5ab2c919f5cb8d9f5bef0b4ee09252c37a821cb Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Apr 2020 09:32:22 +0200 Subject: [PATCH 07/11] release.sh: use diff --color colordiff is no longer necessary, and not installed on many systems. --- release.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/release.sh b/release.sh index 095bc50b5..c581d2923 100755 --- a/release.sh +++ b/release.sh @@ -69,11 +69,9 @@ cp build/i3-${RELEASE_VERSION}.tar.bz2 . echo "Differences in the release tarball file lists:" -diff -u \ +diff --color -u \ <(tar tf ../i3-${PREVIOUS_VERSION}.tar.bz2 | sed "s,i3-${PREVIOUS_VERSION}/,,g" | sort) \ - <(tar tf i3-${RELEASE_VERSION}.tar.bz2 | sed "s,i3-${RELEASE_VERSION}/,,g" | sort) \ - | colordiff - + <(tar tf i3-${RELEASE_VERSION}.tar.bz2 | sed "s,i3-${RELEASE_VERSION}/,,g" | sort) gpg --armor -b i3-${RELEASE_VERSION}.tar.bz2 From c4ffc0f5e14bccdb54572e137b054415fc010af2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Apr 2020 09:32:38 +0200 Subject: [PATCH 08/11] release.sh: docker build: use --no-cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids issues with stale caches. We rather don’t use caching at all: release.sh is only run once per release. --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index c581d2923..3a2210fb4 100755 --- a/release.sh +++ b/release.sh @@ -128,7 +128,7 @@ RUN dpkg-buildpackage -S -sa -j8 EOT CONTAINER_NAME=$(echo "i3-${TMPDIR}" | sed 's,/,,g') -docker build -t i3 . +docker build --no-cache -t i3 . for file in $(docker run --name "${CONTAINER_NAME}" i3 /bin/sh -c "ls /usr/src/i3*_${RELEASE_VERSION}*") do docker cp "${CONTAINER_NAME}:${file}" ${TMPDIR}/debian/ From 8f0b92cae2d38bc7e604b3bb3948bf83959934f5 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Apr 2020 09:33:11 +0200 Subject: [PATCH 09/11] release.sh: update versions --- release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 3a2210fb4..3335aa4a0 100755 --- a/release.sh +++ b/release.sh @@ -1,8 +1,8 @@ #!/bin/zsh # This script is used to prepare a new release of i3. -export RELEASE_VERSION="4.17" -export PREVIOUS_VERSION="4.16" +export RELEASE_VERSION="4.19" +export PREVIOUS_VERSION="4.18" export RELEASE_BRANCH="next" if [ ! -e "../i3.github.io" ] From 5e2f13a28c4fd7348914dfd999026d0e30424cd5 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Mon, 27 Apr 2020 13:10:15 +0200 Subject: [PATCH 10/11] Only set FLOATING_AUTO_ON when floating_enable succeeds Fixes #4039 Crash with docking clients where the floating field is set even though floating_enable refuses to make them floating. See issue for example with logs. --- include/floating.h | 2 +- src/floating.c | 9 ++-- src/handlers.c | 11 ++-- src/manage.c | 5 +- testcases/t/310-client-message-sticky.t | 70 +++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 testcases/t/310-client-message-sticky.t diff --git a/include/floating.h b/include/floating.h index 8e60f78c7..612874fcf 100644 --- a/include/floating.h +++ b/include/floating.h @@ -25,7 +25,7 @@ typedef enum { BORDER_LEFT = (1 << 0), * floating_windows list of the workspace. * */ -void floating_enable(Con *con, bool automatic); +bool floating_enable(Con *con, bool automatic); /** * Disables floating mode for the given container by re-attaching the container diff --git a/src/floating.c b/src/floating.c index 4fed43e44..7302f6447 100644 --- a/src/floating.c +++ b/src/floating.c @@ -221,22 +221,22 @@ void floating_check_size(Con *floating_con, bool prefer_height) { } } -void floating_enable(Con *con, bool automatic) { +bool floating_enable(Con *con, bool automatic) { bool set_focus = (con == focused); if (con_is_docked(con)) { LOG("Container is a dock window, not enabling floating mode.\n"); - return; + return false; } if (con_is_floating(con)) { LOG("Container is already in floating mode, not doing anything.\n"); - return; + return false; } if (con->type == CT_WORKSPACE) { LOG("Container is a workspace, not enabling floating mode.\n"); - return; + return false; } Con *focus_head_placeholder = NULL; @@ -419,6 +419,7 @@ void floating_enable(Con *con, bool automatic) { floating_set_hint_atom(nc, true); ipc_send_window_event("floating", con); + return true; } void floating_disable(Con *con) { diff --git a/src/handlers.c b/src/handlers.c index d6d6e20bc..f54489545 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -841,12 +841,13 @@ static void handle_client_message(xcb_client_message_event_t *event) { * let's float it and make it sticky. */ DLOG("The window was requested to be visible on all workspaces, making it sticky and floating.\n"); - floating_enable(con, false); - con->floating = FLOATING_AUTO_ON; + if (floating_enable(con, false)) { + con->floating = FLOATING_AUTO_ON; - con->sticky = true; - ewmh_update_sticky(con->window->id, true); - output_push_sticky_windows(focused); + con->sticky = true; + ewmh_update_sticky(con->window->id, true); + output_push_sticky_windows(focused); + } } else { Con *ws = ewmh_get_workspace_by_index(index); if (ws == NULL) { diff --git a/src/manage.c b/src/manage.c index eecba95c5..19ce87755 100644 --- a/src/manage.c +++ b/src/manage.c @@ -537,8 +537,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki * was not specified */ bool automatic_border = (motif_border_style == BS_NORMAL); - floating_enable(nc, automatic_border); - nc->floating = FLOATING_AUTO_ON; + if (floating_enable(nc, automatic_border)) { + nc->floating = FLOATING_AUTO_ON; + } } /* explicitly set the border width to the default */ diff --git a/testcases/t/310-client-message-sticky.t b/testcases/t/310-client-message-sticky.t new file mode 100644 index 000000000..0e7d8b7c3 --- /dev/null +++ b/testcases/t/310-client-message-sticky.t @@ -0,0 +1,70 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Please read the following documents before working on tests: +# • https://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • https://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • https://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# +# Verify that _NET_WM_DESKTOP sticky requests do not conflict with dock +# clients, resulting in a crash +# Ticket: #4039 +# Bug still in: 4.18-238-g4d55bba7f +use i3test; + +sub send_sticky_request { + my ($win) = @_; + + my $msg = pack "CCSLLLLLL", + X11::XCB::CLIENT_MESSAGE, # response_type + 32, # format + 0, # sequence + $win->id, # window + $x->atom(name => '_NET_WM_DESKTOP')->id, # message type + hex '0xFFFFFFFF', # data32[0] = NET_WM_DESKTOP_ALL + 0, # data32[1] + 0, # data32[2] + 0, # data32[3] + 0; # data32[4] + + $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg); +} + +# Test the normal functionality first +my $ws = fresh_workspace; +my $win = open_window; + +is(@{get_ws($ws)->{floating_nodes}}, 0, 'No floating windows yet'); +send_sticky_request($win); +sync_with_i3; + +is(@{get_ws($ws)->{floating_nodes}}, 1, 'One floating (sticky) window'); +$ws = fresh_workspace; +is(@{get_ws($ws)->{floating_nodes}}, 1, 'Sticky window in new workspace'); + +# See #4039 +kill_all_windows; +$win = open_window({ + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK') +}); + +send_sticky_request($win); +sync_with_i3; +is(@{get_ws($ws)->{floating_nodes}}, 0, 'Dock client did not get sticky/floating'); + +# Cause a ConfigureRequest by setting the window’s position/size. +my ($a, $t) = $win->rect; +$win->rect(X11::XCB::Rect->new(x => 0, y => 0, width => $a->width, height => $a->height)); + +does_i3_live; +is(@{get_ws($ws)->{floating_nodes}}, 0, 'Dock client still not sticky/floating'); + +done_testing; From 0c9c9fb35fab76836f1d5910d08c0dc4713f2050 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Tue, 28 Apr 2020 21:41:13 +0200 Subject: [PATCH 11/11] con.c: Reorder use after free This shows up in various static analysis tools. I doubt that it is dangerous in any way but the end result is the same. --- src/con.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/con.c b/src/con.c index d9a792214..c2da3cbb0 100644 --- a/src/con.c +++ b/src/con.c @@ -91,8 +91,8 @@ void con_free(Con *con) { FREE(mark->name); FREE(mark); } - free(con); DLOG("con %p freed\n", con); + free(con); } static void _con_attach(Con *con, Con *parent, Con *previous, bool ignore_focus) {