From 07b059852673cd9e148c2adfc6bb4f8a0d0ff315 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 17 Feb 2024 14:47:42 +0100 Subject: [PATCH 01/40] input/text_input: fix dangling listeners --- sway/input/text_input.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sway/input/text_input.c b/sway/input/text_input.c index ad760a6f..5e96c3a8 100644 --- a/sway/input/text_input.c +++ b/sway/input/text_input.c @@ -109,6 +109,9 @@ static void handle_im_destroy(struct wl_listener *listener, void *data) { input_method_destroy); struct wlr_input_method_v2 *context = data; assert(context == relay->input_method); + wl_list_remove(&relay->input_method_commit.link); + wl_list_remove(&relay->input_method_grab_keyboard.link); + wl_list_remove(&relay->input_method_destroy.link); wl_list_remove(&relay->input_method_new_popup_surface.link); relay->input_method = NULL; struct sway_text_input *text_input = relay_get_focused_text_input(relay); From fc640d5f6c82883c35e90a64f0098486e6091293 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 16 Feb 2024 15:17:18 +0100 Subject: [PATCH 02/40] Define _POSIX_C_SOURCE globally See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555 --- client/pool-buffer.c | 1 - common/gesture.c | 1 - common/ipc-client.c | 1 - common/log.c | 1 - common/loop.c | 1 - common/stringop.c | 1 - common/util.c | 1 - meson.build | 1 + sway/commands.c | 1 - sway/commands/assign.c | 1 - sway/commands/bar.c | 1 - sway/commands/bar/font.c | 1 - sway/commands/bar/hidden_state.c | 1 - sway/commands/bar/icon_theme.c | 1 - sway/commands/bar/id.c | 1 - sway/commands/bar/mode.c | 1 - sway/commands/bar/output.c | 1 - sway/commands/bar/position.c | 1 - sway/commands/bar/separator_symbol.c | 1 - sway/commands/bar/tray_output.c | 1 - sway/commands/bind.c | 1 - sway/commands/exec_always.c | 1 - sway/commands/font.c | 1 - sway/commands/gesture.c | 1 - sway/commands/input/calibration_matrix.c | 1 - sway/commands/input/map_from_region.c | 1 - sway/commands/input/map_to_output.c | 1 - sway/commands/input/map_to_region.c | 1 - sway/commands/input/xkb_file.c | 1 - sway/commands/input/xkb_layout.c | 1 - sway/commands/input/xkb_model.c | 1 - sway/commands/input/xkb_numlock.c | 1 - sway/commands/input/xkb_options.c | 1 - sway/commands/input/xkb_rules.c | 1 - sway/commands/input/xkb_switch_layout.c | 1 - sway/commands/input/xkb_variant.c | 1 - sway/commands/mark.c | 1 - sway/commands/mode.c | 1 - sway/commands/move.c | 1 - sway/commands/output/background.c | 1 - sway/commands/reload.c | 1 - sway/commands/seat/attach.c | 1 - sway/commands/seat/cursor.c | 1 - sway/commands/seat/hide_cursor.c | 1 - sway/commands/seat/idle.c | 1 - sway/commands/seat/xcursor_theme.c | 1 - sway/commands/set.c | 1 - sway/commands/show_marks.c | 1 - sway/commands/swap.c | 1 - sway/commands/title_format.c | 1 - sway/commands/unmark.c | 1 - sway/commands/workspace.c | 1 - sway/config.c | 1 + sway/config/bar.c | 1 - sway/config/input.c | 1 - sway/config/output.c | 1 - sway/config/seat.c | 1 - sway/criteria.c | 1 - sway/desktop/launcher.c | 1 - sway/desktop/output.c | 1 - sway/desktop/transaction.c | 1 - sway/desktop/xdg_shell.c | 1 - sway/desktop/xwayland.c | 1 - sway/input/cursor.c | 1 - sway/input/input-manager.c | 1 - sway/input/seat.c | 1 - sway/input/seatop_default.c | 1 - sway/input/seatop_down.c | 1 - sway/input/seatop_move_floating.c | 1 - sway/input/seatop_move_tiling.c | 1 - sway/input/seatop_resize_floating.c | 1 - sway/input/seatop_resize_tiling.c | 1 - sway/input/tablet.c | 1 - sway/ipc-server.c | 1 - sway/lock.c | 1 - sway/main.c | 1 - sway/server.c | 1 - sway/sway_text_node.c | 1 - sway/swaynag.c | 1 - sway/tree/arrange.c | 1 - sway/tree/container.c | 1 - sway/tree/node.c | 1 - sway/tree/output.c | 1 - sway/tree/root.c | 1 - sway/tree/view.c | 1 - sway/tree/workspace.c | 1 - swaybar/bar.c | 1 - swaybar/config.c | 1 - swaybar/i3bar.c | 1 - swaybar/ipc.c | 1 - swaybar/main.c | 1 - swaybar/render.c | 1 - swaybar/status_line.c | 1 - swaybar/tray/host.c | 1 - swaybar/tray/icon.c | 1 - swaybar/tray/item.c | 1 - swaybar/tray/watcher.c | 1 - swaymsg/main.c | 1 - swaynag/config.c | 1 - swaynag/main.c | 1 - swaynag/swaynag.c | 1 - swaynag/types.c | 1 - 102 files changed, 2 insertions(+), 100 deletions(-) diff --git a/client/pool-buffer.c b/client/pool-buffer.c index 3546b897..c47c40eb 100644 --- a/client/pool-buffer.c +++ b/client/pool-buffer.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809 #include #include #include diff --git a/common/gesture.c b/common/gesture.c index 58170443..272aa837 100644 --- a/common/gesture.c +++ b/common/gesture.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "gesture.h" #include diff --git a/common/ipc-client.c b/common/ipc-client.c index d30212d2..a0be2b2d 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/common/log.c b/common/log.c index 483420e7..3eacdb34 100644 --- a/common/log.c +++ b/common/log.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200112L #include #include #include diff --git a/common/loop.c b/common/loop.c index 80fe18ea..b99c6d55 100644 --- a/common/loop.c +++ b/common/loop.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200112L #include #include #include diff --git a/common/stringop.c b/common/stringop.c index c503143a..16d04917 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/common/util.c b/common/util.c index 5d4c0673..7c492bcb 100644 --- a/common/util.c +++ b/common/util.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/meson.build b/meson.build index f8bf4f80..1043e4ba 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ project( add_project_arguments( [ '-DWLR_USE_UNSTABLE', + '-D_POSIX_C_SOURCE=200809L', '-Wno-unused-parameter', '-Wno-unused-result', diff --git a/sway/commands.c b/sway/commands.c index 6becf3c8..8d003dfa 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809 #include #include #include diff --git a/sway/commands/assign.c b/sway/commands/assign.c index f7d911f7..bf95cf00 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/bar.c b/sway/commands/bar.c index 22756acb..635e895b 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809 #include #include #include diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c index 891c87af..0c074679 100644 --- a/sway/commands/bar/font.c +++ b/sway/commands/bar/font.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 8b661e3a..7b38831e 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/bar/icon_theme.c b/sway/commands/bar/icon_theme.c index 6ac07843..fee21709 100644 --- a/sway/commands/bar/icon_theme.c +++ b/sway/commands/bar/icon_theme.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "config.h" #include "sway/commands.h" diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c index a9a61743..46cf4ca9 100644 --- a/sway/commands/bar/id.c +++ b/sway/commands/bar/id.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 7c2f423b..d69e910b 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c index cac1d056..51730176 100644 --- a/sway/commands/bar/output.c +++ b/sway/commands/bar/output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c index b207de0b..94f530ec 100644 --- a/sway/commands/bar/position.c +++ b/sway/commands/bar/position.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/bar/separator_symbol.c b/sway/commands/bar/separator_symbol.c index 6737d4d2..50e9a873 100644 --- a/sway/commands/bar/separator_symbol.c +++ b/sway/commands/bar/separator_symbol.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/tray_output.c b/sway/commands/bar/tray_output.c index eb3b486e..679facf7 100644 --- a/sway/commands/bar/tray_output.c +++ b/sway/commands/bar/tray_output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "config.h" #include "sway/commands.h" diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 979e178f..268f2855 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 8fca1909..8bc1048c 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/font.c b/sway/commands/font.c index 74bb6b9f..9920d03e 100644 --- a/sway/commands/font.c +++ b/sway/commands/font.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/gesture.c b/sway/commands/gesture.c index d4442cc3..90a20716 100644 --- a/sway/commands/gesture.c +++ b/sway/commands/gesture.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "gesture.h" diff --git a/sway/commands/input/calibration_matrix.c b/sway/commands/input/calibration_matrix.c index 38749fbb..53fe2c35 100644 --- a/sway/commands/input/calibration_matrix.c +++ b/sway/commands/input/calibration_matrix.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/config.h" diff --git a/sway/commands/input/map_from_region.c b/sway/commands/input/map_from_region.c index 4400e111..2f8f753d 100644 --- a/sway/commands/input/map_from_region.c +++ b/sway/commands/input/map_from_region.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/input/map_to_output.c b/sway/commands/input/map_to_output.c index f60fb7d5..a7266baa 100644 --- a/sway/commands/input/map_to_output.c +++ b/sway/commands/input/map_to_output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/config.h" diff --git a/sway/commands/input/map_to_region.c b/sway/commands/input/map_to_region.c index ad535db2..9087c589 100644 --- a/sway/commands/input/map_to_region.c +++ b/sway/commands/input/map_to_region.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/input/xkb_file.c b/sway/commands/input/xkb_file.c index 493f94fb..056f00e5 100644 --- a/sway/commands/input/xkb_file.c +++ b/sway/commands/input/xkb_file.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/config.h" diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c index 22626517..1d01886c 100644 --- a/sway/commands/input/xkb_layout.c +++ b/sway/commands/input/xkb_layout.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c index f4a33de3..a9144a8a 100644 --- a/sway/commands/input/xkb_model.c +++ b/sway/commands/input/xkb_model.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/input/xkb_numlock.c b/sway/commands/input/xkb_numlock.c index 87d3e60c..bbe848fe 100644 --- a/sway/commands/input/xkb_numlock.c +++ b/sway/commands/input/xkb_numlock.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "util.h" diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c index d609293f..7ca20777 100644 --- a/sway/commands/input/xkb_options.c +++ b/sway/commands/input/xkb_options.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c index 3b59622c..8fbd26fb 100644 --- a/sway/commands/input/xkb_rules.c +++ b/sway/commands/input/xkb_rules.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/input/xkb_switch_layout.c b/sway/commands/input/xkb_switch_layout.c index 3cce4ec8..ecac8e6c 100644 --- a/sway/commands/input/xkb_switch_layout.c +++ b/sway/commands/input/xkb_switch_layout.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/config.h" diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c index d0e21d77..2d14ea9c 100644 --- a/sway/commands/input/xkb_variant.c +++ b/sway/commands/input/xkb_variant.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/config.h" #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/mark.c b/sway/commands/mark.c index 30cf458c..2bfc86b3 100644 --- a/sway/commands/mark.c +++ b/sway/commands/mark.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/mode.c b/sway/commands/mode.c index 7263efcb..b3216967 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/commands/move.c b/sway/commands/move.c index 69ed06c0..bcbdaa2d 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index d691295f..55bd7671 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 82967ca7..6c0aac26 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c index 00bfdab6..47d18546 100644 --- a/sway/commands/seat/attach.c +++ b/sway/commands/seat/attach.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 5a8a3bc8..85c5edca 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c index e09b82d9..f5177a47 100644 --- a/sway/commands/seat/hide_cursor.c +++ b/sway/commands/seat/hide_cursor.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/seat/idle.c b/sway/commands/seat/idle.c index 62b94db2..2974453e 100644 --- a/sway/commands/seat/idle.c +++ b/sway/commands/seat/idle.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/seat/xcursor_theme.c b/sway/commands/seat/xcursor_theme.c index 202f35b9..61322a57 100644 --- a/sway/commands/seat/xcursor_theme.c +++ b/sway/commands/seat/xcursor_theme.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/set.c b/sway/commands/set.c index c539e9fc..ba384c7c 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c index fecb5ade..60cef9fa 100644 --- a/sway/commands/show_marks.c +++ b/sway/commands/show_marks.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/swap.c b/sway/commands/swap.c index d44eb006..e142eede 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "config.h" #include "log.h" diff --git a/sway/commands/title_format.c b/sway/commands/title_format.c index a2446b7e..0b2ea265 100644 --- a/sway/commands/title_format.c +++ b/sway/commands/title_format.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c index c3a6ac4b..4aba5bae 100644 --- a/sway/commands/unmark.c +++ b/sway/commands/unmark.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/commands.h" #include "sway/config.h" diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 03e488ba..a14ebb20 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/config.c b/sway/config.c index e91c0c8b..568c8b53 100644 --- a/sway/config.c +++ b/sway/config.c @@ -1,3 +1,4 @@ +#undef _POSIX_C_SOURCE #define _XOPEN_SOURCE 700 // for realpath #include #include diff --git a/sway/config/bar.c b/sway/config/bar.c index a8389244..908b2865 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/config/input.c b/sway/config/input.c index 44c2be28..de3b21ed 100644 --- a/sway/config/input.c +++ b/sway/config/input.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/config/output.c b/sway/config/output.c index 54ebaa17..55779771 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/config/seat.c b/sway/config/seat.c index 6d5d91ae..f2326189 100644 --- a/sway/config/seat.c +++ b/sway/config/seat.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/criteria.c b/sway/criteria.c index 78ea8b8a..e16b4fa8 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c index 0c02b997..28043d19 100644 --- a/sway/desktop/launcher.c +++ b/sway/desktop/launcher.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 81290ccb..600423bc 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index fd1c3d3a..042141ab 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index f4a25cf4..27a73f8a 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 199309L #include #include #include diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 9f3f4d5f..270cf08f 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 199309L #include #include #include diff --git a/sway/input/cursor.c b/sway/input/cursor.c index b00f81a9..e8cd8112 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index c1bbdde0..9ee635af 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seat.c b/sway/input/seat.c index 75fea484..9dd078c6 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index c56330fd..f2a9c2cd 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index b4421fe6..12d7ae7a 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index 21d048ce..7de3f4d8 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include "sway/desktop/transaction.h" #include "sway/input/cursor.h" diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 7de39ff6..4f4d6e41 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index df683026..168dfffe 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/input/seatop_resize_tiling.c b/sway/input/seatop_resize_tiling.c index 869d11b5..9ce4ff8b 100644 --- a/sway/input/seatop_resize_tiling.c +++ b/sway/input/seatop_resize_tiling.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "sway/commands.h" diff --git a/sway/input/tablet.c b/sway/input/tablet.c index 902cb7ed..2863642a 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 9692a77f..7f353c0e 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -1,5 +1,4 @@ // See https://i3wm.org/docs/ipc.html for protocol information -#define _POSIX_C_SOURCE 200112L #include #include #include diff --git a/sway/lock.c b/sway/lock.c index d267de4f..289e8ca4 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/main.c b/sway/main.c index 73254dc2..1c4939aa 100644 --- a/sway/main.c +++ b/sway/main.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/server.c b/sway/server.c index 5b389f69..684b1dbd 100644 --- a/sway/server.c +++ b/sway/server.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index 664db40e..5eba53ba 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/swaynag.c b/sway/swaynag.c index 6031174d..bc5e23ea 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index af925d05..d4003fe6 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/container.c b/sway/tree/container.c index 78448090..9224b4fb 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/node.c b/sway/tree/node.c index 213cf0a6..7aaf9762 100644 --- a/sway/tree/node.c +++ b/sway/tree/node.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include "sway/output.h" #include "sway/server.h" #include "sway/tree/container.h" diff --git a/sway/tree/output.c b/sway/tree/output.c index cd7bf0c2..2d11195e 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/root.c b/sway/tree/root.c index e9cea5e2..ae3c3cb2 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/view.c b/sway/tree/view.c index 4a0d8069..35b4b73f 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 40d33435..a68dc927 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809 #include #include #include diff --git a/swaybar/bar.c b/swaybar/bar.c index 021fc3bd..5b1213a8 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/config.c b/swaybar/config.c index 5e828773..55bfcb72 100644 --- a/swaybar/config.c +++ b/swaybar/config.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "swaybar/config.h" diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index ccd5a076..62c22d43 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 33ae6544..03500bdf 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809 #include #include #include diff --git a/swaybar/main.c b/swaybar/main.c index a44c1e63..3dc67233 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/render.c b/swaybar/render.c index 1113ca44..879a4e42 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/status_line.c b/swaybar/status_line.c index 2e9bb7f1..e542e606 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/tray/host.c b/swaybar/tray/host.c index eea2caa5..79b54606 100644 --- a/swaybar/tray/host.c +++ b/swaybar/tray/host.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c index b513dca5..659edd86 100644 --- a/swaybar/tray/icon.c +++ b/swaybar/tray/icon.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index d5fe50b1..ca6c03ad 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaybar/tray/watcher.c b/swaybar/tray/watcher.c index 2458a8c2..3cfea8d8 100644 --- a/swaybar/tray/watcher.c +++ b/swaybar/tray/watcher.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaymsg/main.c b/swaymsg/main.c index db9346c4..573a7b16 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include diff --git a/swaynag/config.c b/swaynag/config.c index cff3930f..efd71ce7 100644 --- a/swaynag/config.c +++ b/swaynag/config.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaynag/main.c b/swaynag/main.c index 20390207..634bddbf 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include "log.h" diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 6ea739e3..50eea148 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/swaynag/types.c b/swaynag/types.c index 409cc668..821e5b21 100644 --- a/swaynag/types.c +++ b/swaynag/types.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include From 829c75b9c95e6cf7c7a1e02528966ef842ea3d4c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 24 Feb 2024 14:48:25 +0100 Subject: [PATCH 03/40] Add release script --- release.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 release.sh diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..62baf415 --- /dev/null +++ b/release.sh @@ -0,0 +1,31 @@ +#!/bin/sh -eu + +prev=$(git describe --tags --abbrev=0) +next=$(meson rewrite kwargs info project / 2>&1 >/dev/null | jq -r '.kwargs["project#/"].version') + +case "$next" in +*-dev) + echo "This is a development version" + exit 1 + ;; +esac + +if [ "$prev" = "$next" ]; then + echo "Version not bumped in meson.build" + exit 1 +fi + +if ! git diff-index --quiet HEAD -- meson.build; then + echo "meson.build not committed" + exit 1 +fi + +shortlog="$(git shortlog --no-merges "$prev..")" +(echo "sway $next"; echo ""; echo "$shortlog") | git tag "$next" -ase -F - + +prefix=sway-$next +archive=$prefix.tar.gz +git archive --prefix="$prefix/" -o "$archive" "$next" +gpg --output "$archive".sig --detach-sig "$archive" + +gh release create "sway $next" -t "$next" -n "" -d "$archive" "$archive.sig" From 469411d4842e265295de5897cbcf879487cb46e8 Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 28 Feb 2024 01:57:56 +0530 Subject: [PATCH 04/40] text_input: don't destroy scene_node twice --- sway/input/text_input.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sway/input/text_input.c b/sway/input/text_input.c index 5e96c3a8..c38a3bb2 100644 --- a/sway/input/text_input.c +++ b/sway/input/text_input.c @@ -293,10 +293,6 @@ static void input_popup_update(struct sway_input_popup *popup) { return; } - wlr_scene_node_destroy(&popup->scene_tree->node); - wlr_scene_node_destroy(popup->desc.relative); - popup->scene_tree = NULL; - bool cursor_rect = text_input->input->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE; struct wlr_surface *focused_surface = text_input->input->focused_surface; From fca8474e9bd64bff8df16fdaf409d5f575ba9501 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 28 Feb 2024 17:49:58 +0100 Subject: [PATCH 05/40] Convert to new pointer enums References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4575 --- include/sway/input/cursor.h | 2 +- include/sway/input/seat.h | 6 ++--- sway/commands/seat/cursor.c | 14 ++++++------ sway/input/cursor.c | 16 +++++++------- sway/input/seat.c | 4 ++-- sway/input/seatop_default.c | 34 ++++++++++++++--------------- sway/input/seatop_down.c | 2 +- sway/input/seatop_move_floating.c | 2 +- sway/input/seatop_move_tiling.c | 2 +- sway/input/seatop_resize_floating.c | 2 +- sway/input/seatop_resize_tiling.c | 2 +- 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 1e21c66f..527d0350 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h @@ -114,7 +114,7 @@ void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, - enum wlr_button_state state); + enum wl_pointer_button_state state); void dispatch_cursor_axis(struct sway_cursor *cursor, struct wlr_pointer_axis_event *event); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e5aa8478..475753d8 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -17,7 +17,7 @@ struct sway_seat; struct sway_seatop_impl { void (*button)(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state); + enum wl_pointer_button_state state); void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); void (*pointer_axis)(struct sway_seat *seat, struct wlr_pointer_axis_event *event); @@ -286,13 +286,13 @@ struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, struct sway_workspace *workspace); void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, - uint32_t button, enum wlr_button_state state); + uint32_t button, enum wl_pointer_button_state state); void seat_consider_warp_to_focus(struct sway_seat *seat); void seatop_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state); + enum wl_pointer_button_state state); void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 85c5edca..df7c379d 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c @@ -84,12 +84,12 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { static struct cmd_results *press_or_release(struct sway_cursor *cursor, char *action, char *button_str) { - enum wlr_button_state state; + enum wl_pointer_button_state state; uint32_t button; if (strcasecmp(action, "press") == 0) { - state = WLR_BUTTON_PRESSED; + state = WL_POINTER_BUTTON_STATE_PRESSED; } else if (strcasecmp(action, "release") == 0) { - state = WLR_BUTTON_RELEASED; + state = WL_POINTER_BUTTON_STATE_RELEASED; } else { return cmd_results_new(CMD_INVALID, "%s", expected_syntax); } @@ -104,16 +104,16 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor, } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN || button == SWAY_SCROLL_LEFT || button == SWAY_SCROLL_RIGHT) { // Dispatch axis event - enum wlr_axis_orientation orientation = + enum wl_pointer_axis orientation = (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN) - ? WLR_AXIS_ORIENTATION_VERTICAL - : WLR_AXIS_ORIENTATION_HORIZONTAL; + ? WL_POINTER_AXIS_VERTICAL_SCROLL + : WL_POINTER_AXIS_HORIZONTAL_SCROLL; double delta = (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_LEFT) ? -1 : 1; struct wlr_pointer_axis_event event = { .pointer = NULL, .time_msec = 0, - .source = WLR_AXIS_SOURCE_WHEEL, + .source = WL_POINTER_AXIS_SOURCE_WHEEL, .orientation = orientation, .delta = delta * 15, .delta_discrete = delta diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e8cd8112..7d66a89d 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -356,7 +356,7 @@ static void handle_pointer_motion_absolute( void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { if (time_msec == 0) { time_msec = get_current_time_msec(); } @@ -368,7 +368,7 @@ static void handle_pointer_button(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of(listener, cursor, button); struct wlr_pointer_button_event *event = data; - if (event->state == WLR_BUTTON_PRESSED) { + if (event->state == WL_POINTER_BUTTON_STATE_PRESSED) { cursor->pressed_button_count++; } else { if (cursor->pressed_button_count > 0) { @@ -430,7 +430,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { if (cursor->pointer_touch_id == cursor->seat->touch_id) { cursor->pointer_touch_up = true; dispatch_cursor_button(cursor, &event->touch->base, - event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED); + event->time_msec, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); } } else { seatop_touch_up(seat, event); @@ -448,7 +448,7 @@ static void handle_touch_cancel(struct wl_listener *listener, void *data) { if (cursor->pointer_touch_id == cursor->seat->touch_id) { cursor->pointer_touch_up = true; dispatch_cursor_button(cursor, &event->touch->base, - event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED); + event->time_msec, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); } } else { seatop_touch_cancel(seat, event); @@ -661,7 +661,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) { event->state == WLR_TABLET_TOOL_TIP_UP) { cursor->simulating_pointer_from_tool_tip = false; dispatch_cursor_button(cursor, &event->tablet->base, event->time_msec, - BTN_LEFT, WLR_BUTTON_RELEASED); + BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); } else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) { // If we started holding the tool tip down on a surface that accepts @@ -673,7 +673,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) { } else { cursor->simulating_pointer_from_tool_tip = true; dispatch_cursor_button(cursor, &event->tablet->base, - event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED); + event->time_msec, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); } } else { @@ -776,13 +776,13 @@ static void handle_tool_button(struct wl_listener *listener, void *data) { case WLR_BUTTON_PRESSED: if (cursor->tool_buttons == 0) { dispatch_cursor_button(cursor, &event->tablet->base, - event->time_msec, BTN_RIGHT, event->state); + event->time_msec, BTN_RIGHT, WL_POINTER_BUTTON_STATE_PRESSED); } break; case WLR_BUTTON_RELEASED: if (cursor->tool_buttons <= 1) { dispatch_cursor_button(cursor, &event->tablet->base, - event->time_msec, BTN_RIGHT, event->state); + event->time_msec, BTN_RIGHT, WL_POINTER_BUTTON_STATE_RELEASED); } break; } diff --git a/sway/input/seat.c b/sway/input/seat.c index 9dd078c6..7ae29828 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1520,7 +1520,7 @@ struct seat_config *seat_get_config_by_name(const char *name) { } void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, - uint32_t button, enum wlr_button_state state) { + uint32_t button, enum wl_pointer_button_state state) { seat->last_button_serial = wlr_seat_pointer_notify_button(seat->wlr_seat, time_msec, button, state); } @@ -1557,7 +1557,7 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con) { void seatop_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { if (seat->seatop_impl->button) { seat->seatop_impl->button(seat, time_msec, device, button, state); } diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index f2a9c2cd..0c6f7c5e 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -290,7 +290,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, static bool trigger_pointer_button_binding(struct sway_seat *seat, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state, uint32_t modifiers, + enum wl_pointer_button_state state, uint32_t modifiers, bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) { // We can reach this for non-pointer devices if we're currently emulating // pointer input for one. Emulated input should not trigger bindings. The @@ -304,7 +304,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat, char *device_identifier = device ? input_device_get_identifier(device) : strdup("*"); struct sway_binding *binding = NULL; - if (state == WLR_BUTTON_PRESSED) { + if (state == WL_POINTER_BUTTON_STATE_PRESSED) { state_add_button(e, button); binding = get_active_mouse_binding(e, config->current_mode->mouse_bindings, modifiers, false, @@ -329,7 +329,7 @@ static bool trigger_pointer_button_binding(struct sway_seat *seat, static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { struct sway_cursor *cursor = seat->cursor; // Determine what's under the cursor @@ -362,7 +362,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle clicking an empty workspace if (node && node->type == N_WORKSPACE) { - if (state == WLR_BUTTON_PRESSED) { + if (state == WL_POINTER_BUTTON_STATE_PRESSED) { seat_set_focus(seat, node); transaction_commit_dirty(); } @@ -377,7 +377,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, seat_set_focus_layer(seat, layer); transaction_commit_dirty(); } - if (state == WLR_BUTTON_PRESSED) { + if (state == WL_POINTER_BUTTON_STATE_PRESSED) { seatop_begin_down_on_surface(seat, surface, sx, sy); } seat_pointer_notify_button(seat, time_msec, button, state); @@ -386,7 +386,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle tiling resize via border if (cont && resize_edge && button == BTN_LEFT && - state == WLR_BUTTON_PRESSED && !is_floating) { + state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating) { // If a resize is triggered on a tabbed or stacked container, change // focus to the tab which already had inactive focus -- otherwise, we'd // change the active tab when the user probably just wanted to resize. @@ -404,7 +404,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle tiling resize via mod bool mod_pressed = modifiers & config->floating_mod; if (cont && !is_floating_or_child && mod_pressed && - state == WLR_BUTTON_PRESSED) { + state == WL_POINTER_BUTTON_STATE_PRESSED) { uint32_t btn_resize = config->floating_mod_inverse ? BTN_LEFT : BTN_RIGHT; if (button == btn_resize) { @@ -432,7 +432,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Handle changing focus when clicking on a container - if (cont && state == WLR_BUTTON_PRESSED) { + if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) { // Default case: focus the container that was just clicked. node = &cont->node; @@ -453,7 +453,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle beginning floating move if (cont && is_floating_or_child && !is_fullscreen_or_child && - state == WLR_BUTTON_PRESSED) { + state == WL_POINTER_BUTTON_STATE_PRESSED) { uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; if (button == btn_move && (mod_pressed || on_titlebar)) { seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); @@ -463,7 +463,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle beginning floating resize if (cont && is_floating_or_child && !is_fullscreen_or_child && - state == WLR_BUTTON_PRESSED) { + state == WL_POINTER_BUTTON_STATE_PRESSED) { // Via border if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) { seat_set_focus_container(seat, cont); @@ -489,7 +489,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle moving a tiling container if (config->tiling_drag && (mod_pressed || on_titlebar) && - state == WLR_BUTTON_PRESSED && !is_floating_or_child && + state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating_or_child && cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) { // If moving a container by its title bar, use a threshold for the drag if (!mod_pressed && config->tiling_drag_threshold > 0) { @@ -502,14 +502,14 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Handle mousedown on a container surface - if (surface && cont && state == WLR_BUTTON_PRESSED) { + if (surface && cont && state == WL_POINTER_BUTTON_STATE_PRESSED) { seatop_begin_down(seat, cont, sx, sy); - seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED); + seat_pointer_notify_button(seat, time_msec, button, WL_POINTER_BUTTON_STATE_PRESSED); return; } // Handle clicking a container surface or decorations - if (cont && state == WLR_BUTTON_PRESSED) { + if (cont && state == WL_POINTER_BUTTON_STATE_PRESSED) { seat_pointer_notify_button(seat, time_msec, button, state); return; } @@ -684,7 +684,7 @@ static void handle_touch_down(struct sway_seat *seat, pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy, dx, dy); dispatch_cursor_button(cursor, &event->touch->base, event->time_msec, - BTN_LEFT, WLR_BUTTON_PRESSED); + BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); } } @@ -694,9 +694,9 @@ static void handle_touch_down(struct sway_seat *seat, static uint32_t wl_axis_to_button(struct wlr_pointer_axis_event *event) { switch (event->orientation) { - case WLR_AXIS_ORIENTATION_VERTICAL: + case WL_POINTER_AXIS_VERTICAL_SCROLL: return event->delta < 0 ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN; - case WLR_AXIS_ORIENTATION_HORIZONTAL: + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: return event->delta < 0 ? SWAY_SCROLL_LEFT : SWAY_SCROLL_RIGHT; default: sway_log(SWAY_DEBUG, "Unknown axis orientation"); diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index 12d7ae7a..35fd3bcb 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c @@ -142,7 +142,7 @@ static void handle_pointer_axis(struct sway_seat *seat, static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { seat_pointer_notify_button(seat, time_msec, button, state); if (seat->cursor->pressed_button_count == 0) { diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index 7de3f4d8..83668d88 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c @@ -21,7 +21,7 @@ static void finalize_move(struct sway_seat *seat) { static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { if (seat->cursor->pressed_button_count == 0) { finalize_move(seat); } diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 4f4d6e41..c525b77a 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c @@ -405,7 +405,7 @@ static void finalize_move(struct sway_seat *seat) { static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { if (seat->cursor->pressed_button_count == 0) { finalize_move(seat); } diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index 168dfffe..bec86e33 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c @@ -20,7 +20,7 @@ struct seatop_resize_floating_event { static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { struct seatop_resize_floating_event *e = seat->seatop_data; struct sway_container *con = e->con; diff --git a/sway/input/seatop_resize_tiling.c b/sway/input/seatop_resize_tiling.c index 9ce4ff8b..15fd333b 100644 --- a/sway/input/seatop_resize_tiling.c +++ b/sway/input/seatop_resize_tiling.c @@ -45,7 +45,7 @@ static struct sway_container *container_get_resize_sibling( static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_input_device *device, uint32_t button, - enum wlr_button_state state) { + enum wl_pointer_button_state state) { struct seatop_resize_tiling_event *e = seat->seatop_data; if (seat->cursor->pressed_button_count == 0) { From 2867ef646b67138a796b7d5ae46428c255cc928f Mon Sep 17 00:00:00 2001 From: llyyr Date: Tue, 27 Feb 2024 01:40:22 +0530 Subject: [PATCH 06/40] ipc: add `floating` property to GET_TREE i3 has had this property for over a decade but it wasn't documented until a couple of years ago, so it was likely missed when developing sway. Add the property to get us closer to ipc parity with i3. --- sway/ipc-json.c | 8 +++++++- sway/sway-ipc.7.scd | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 58356d4e..84e164e4 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -288,6 +288,7 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name, json_object_object_add(object, "focus", focus); json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); json_object_object_add(object, "sticky", json_object_new_boolean(false)); + json_object_object_add(object, "floating", NULL); return object; } @@ -675,7 +676,8 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object static void ipc_json_describe_container(struct sway_container *c, json_object *object) { json_object_object_add(object, "name", c->title ? json_object_new_string(c->title) : NULL); - if (container_is_floating(c)) { + bool floating = container_is_floating(c); + if (floating) { json_object_object_add(object, "type", json_object_new_string("floating_con")); } @@ -693,6 +695,10 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o json_object_object_add(object, "urgent", json_object_new_boolean(urgent)); json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); + // sway doesn't track the floating reason, so we can't use "auto_on" or "user_off" + json_object_object_add(object, "floating", + json_object_new_string(floating ? "user_on" : "auto_off")); + json_object_object_add(object, "fullscreen_mode", json_object_new_int(c->pending.fullscreen_mode)); diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index f4a5ccff..5859558f 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -376,6 +376,9 @@ node and will have the following properties: : integer : (Only containers and views) The fullscreen mode of the node. 0 means none, 1 means full workspace, and 2 means global fullscreen +|- floating +: string +: Floating state of container. Can be either "auto_off" or "user_on" |- app_id : string : (Only views) For an xdg-shell view, the name of the application, if set. From 0b84d82b9aad05010479140774ac5ee1fea8ea97 Mon Sep 17 00:00:00 2001 From: llyyr Date: Tue, 27 Feb 2024 02:06:27 +0530 Subject: [PATCH 07/40] ipc: add `scratchpad_state` property to GET_TREE See previous commit. This restores ipc parity with i3. --- sway/ipc-json.c | 5 +++++ sway/sway-ipc.7.scd | 3 +++ 2 files changed, 8 insertions(+) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 84e164e4..dfbb7a6e 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -289,6 +289,7 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name, json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); json_object_object_add(object, "sticky", json_object_new_boolean(false)); json_object_object_add(object, "floating", NULL); + json_object_object_add(object, "scratchpad_state", NULL); return object; } @@ -702,6 +703,10 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o json_object_object_add(object, "fullscreen_mode", json_object_new_int(c->pending.fullscreen_mode)); + // sway doesn't track if window was resized in scratchpad, so we can't use "changed" + json_object_object_add(object, "scratchpad_state", + json_object_new_string(!c->scratchpad ? "none" : "fresh")); + struct sway_node *parent = node_get_parent(&c->node); struct wlr_box parent_box = {0, 0, 0, 0}; diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index 5859558f..c9895e52 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -379,6 +379,9 @@ node and will have the following properties: |- floating : string : Floating state of container. Can be either "auto_off" or "user_on" +|- scratchpad_state +: string +: Whether the window is in the scratchpad. Can be either "none" or "fresh" |- app_id : string : (Only views) For an xdg-shell view, the name of the application, if set. From 2058209a130f5051b59d8ebb24196409695deaaf Mon Sep 17 00:00:00 2001 From: Luofan Chen Date: Fri, 1 Mar 2024 11:43:14 +0800 Subject: [PATCH 08/40] input: Rename WLR_INPUT_DEVICE_TABLET_TOOL to WLR_INPUT_DEVICE_TABLET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wlroots has changed the naming, causing the following build errors when building: error: ‘WLR_INPUT_DEVICE_TABLET_TOOL’ undeclared --- sway/input/cursor.c | 4 ++-- sway/input/input-manager.c | 2 +- sway/input/seat.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 7d66a89d..3d04826c 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -243,7 +243,7 @@ static enum sway_input_idle_source idle_source_from_device( return IDLE_SOURCE_POINTER; case WLR_INPUT_DEVICE_TOUCH: return IDLE_SOURCE_TOUCH; - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: return IDLE_SOURCE_TABLET_TOOL; case WLR_INPUT_DEVICE_TABLET_PAD: return IDLE_SOURCE_TABLET_PAD; @@ -518,7 +518,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device, double x1 = region->x1, x2 = region->x2; double y1 = region->y1, y2 = region->y2; - if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { + if (region->mm && device->type == WLR_INPUT_DEVICE_TABLET) { struct wlr_tablet *tablet = wlr_tablet_from_input_device(device); if (tablet->width_mm == 0 || tablet->height_mm == 0) { return; diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 9ee635af..056cc3ea 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -111,7 +111,7 @@ const char *input_device_get_type(struct sway_input_device *device) { return "keyboard"; case WLR_INPUT_DEVICE_TOUCH: return "touch"; - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: return "tablet_tool"; case WLR_INPUT_DEVICE_TABLET_PAD: return "tablet_pad"; diff --git a/sway/input/seat.c b/sway/input/seat.c index 7ae29828..f2486893 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -607,7 +607,7 @@ static void seat_update_capabilities(struct sway_seat *seat) { case WLR_INPUT_DEVICE_TOUCH: caps |= WL_SEAT_CAPABILITY_TOUCH; break; - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: caps |= WL_SEAT_CAPABILITY_POINTER; break; case WLR_INPUT_DEVICE_SWITCH: @@ -665,7 +665,7 @@ static const char *get_builtin_output_name(void) { static bool is_touch_or_tablet_tool(struct sway_seat_device *seat_device) { switch (seat_device->input_device->wlr_device->type) { case WLR_INPUT_DEVICE_TOUCH: - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: return true; default: return false; @@ -680,7 +680,7 @@ static void seat_apply_input_mapping(struct sway_seat *seat, switch (sway_device->input_device->wlr_device->type) { case WLR_INPUT_DEVICE_POINTER: case WLR_INPUT_DEVICE_TOUCH: - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: break; default: return; // these devices don't support mappings @@ -873,7 +873,7 @@ void seat_configure_device(struct sway_seat *seat, case WLR_INPUT_DEVICE_TOUCH: seat_configure_touch(seat, seat_device); break; - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: seat_configure_tablet_tool(seat, seat_device); break; case WLR_INPUT_DEVICE_TABLET_PAD: @@ -912,7 +912,7 @@ void seat_reset_device(struct sway_seat *seat, case WLR_INPUT_DEVICE_TOUCH: seat_reset_input_config(seat, seat_device); break; - case WLR_INPUT_DEVICE_TABLET_TOOL: + case WLR_INPUT_DEVICE_TABLET: seat_reset_input_config(seat, seat_device); break; case WLR_INPUT_DEVICE_TABLET_PAD: From 5e18ed3cf03eee9e83909fede46dd98dff652647 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Wed, 28 Feb 2024 17:51:03 -0700 Subject: [PATCH 09/40] commands/move: do not force focus on the moved container My code archaeology isn't good enough to determine what this is here for, but it isn't correct. We should be able to move containers in a direction without focusing them. AFAICT i3 doesn't do this, so we shouldn't either. This fixes ipc commands like move with criteria that apply to containers which are not the current focus. --- sway/commands/move.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index bcbdaa2d..8addf26e 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -769,15 +769,6 @@ static struct cmd_results *cmd_move_in_direction( ipc_event_window(container, "move"); } - // Hack to re-focus container - seat_set_raw_focus(config->handler_context.seat, &new_ws->node); - seat_set_focus_container(config->handler_context.seat, container); - - if (old_ws != new_ws) { - ipc_event_workspace(old_ws, new_ws, "focus"); - workspace_detect_urgent(old_ws); - workspace_detect_urgent(new_ws); - } container_end_mouse_operation(container); return cmd_results_new(CMD_SUCCESS, NULL); From fd9ab9ee0659d5b4c2bd148e25b8bc6378f604d6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 5 Mar 2024 08:44:04 +0100 Subject: [PATCH 10/40] config: error out on keysym translation XKB state failure If we can't create the XKB keymap used for keysym translation, gracefully error out instead of crashing. This can happen if the XKB_DEFAULT_LAYOUT is set to an invalid value, for instance. Closes: https://github.com/swaywm/sway/issues/7789 --- sway/config.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sway/config.c b/sway/config.c index 568c8b53..d46b81ee 100644 --- a/sway/config.c +++ b/sway/config.c @@ -43,13 +43,20 @@ static struct xkb_state *keysym_translation_state_create( context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); - xkb_context_unref(context); + if (xkb_keymap == NULL) { + sway_log(SWAY_ERROR, "Failed to compile keysym translation XKB keymap"); + return NULL; + } + return xkb_state_new(xkb_keymap); } static void keysym_translation_state_destroy( struct xkb_state *state) { + if (state == NULL) { + return; + } xkb_keymap_unref(xkb_state_get_keymap(state)); xkb_state_unref(state); } @@ -339,6 +346,9 @@ static void config_defaults(struct sway_config *config) { struct xkb_rule_names rules = {0}; config->keysym_translation_state = keysym_translation_state_create(rules); + if (config->keysym_translation_state == NULL) { + goto cleanup; + } return; cleanup: @@ -987,6 +997,11 @@ void translate_keysyms(struct input_config *input_config) { input_config_fill_rule_names(input_config, &rules); config->keysym_translation_state = keysym_translation_state_create(rules); + if (config->keysym_translation_state == NULL) { + sway_log(SWAY_ERROR, "Failed to create keysym translation XKB state " + "for device '%s'", input_config->identifier); + return; + } for (int i = 0; i < config->modes->length; ++i) { struct sway_mode *mode = config->modes->items[i]; From 59f629238309e230b0e353e73d4f37a7de7fe820 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 5 Mar 2024 08:47:21 +0100 Subject: [PATCH 11/40] config: add fallback without env vars for keysym translation XKB keymap --- sway/config.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sway/config.c b/sway/config.c index d46b81ee..72fc41e7 100644 --- a/sway/config.c +++ b/sway/config.c @@ -37,8 +37,8 @@ struct sway_config *config = NULL; static struct xkb_state *keysym_translation_state_create( - struct xkb_rule_names rules) { - struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_SECURE_GETENV); + struct xkb_rule_names rules, uint32_t context_flags) { + struct xkb_context *context = xkb_context_new(context_flags | XKB_CONTEXT_NO_SECURE_GETENV); struct xkb_keymap *xkb_keymap = xkb_keymap_new_from_names( context, &rules, @@ -344,8 +344,11 @@ static void config_defaults(struct sway_config *config) { // The keysym to keycode translation struct xkb_rule_names rules = {0}; - config->keysym_translation_state = - keysym_translation_state_create(rules); + config->keysym_translation_state = keysym_translation_state_create(rules, 0); + if (config->keysym_translation_state == NULL) { + config->keysym_translation_state = keysym_translation_state_create(rules, + XKB_CONTEXT_NO_ENVIRONMENT_NAMES); + } if (config->keysym_translation_state == NULL) { goto cleanup; } @@ -995,8 +998,7 @@ void translate_keysyms(struct input_config *input_config) { struct xkb_rule_names rules = {0}; input_config_fill_rule_names(input_config, &rules); - config->keysym_translation_state = - keysym_translation_state_create(rules); + config->keysym_translation_state = keysym_translation_state_create(rules, 0); if (config->keysym_translation_state == NULL) { sway_log(SWAY_ERROR, "Failed to create keysym translation XKB state " "for device '%s'", input_config->identifier); From f2a0e81b2438853e12a2b8fe9bddde154852d85d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 7 Mar 2024 12:16:11 +0100 Subject: [PATCH 12/40] Fetch input device vendor/product from libinput References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4582 --- sway/input/input-manager.c | 11 +++++++++-- sway/ipc-json.c | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 056cc3ea..089e1e71 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -65,8 +65,15 @@ struct sway_seat *input_manager_sway_seat_from_wlr_seat(struct wlr_seat *wlr_sea } char *input_device_get_identifier(struct wlr_input_device *device) { - int vendor = device->vendor; - int product = device->product; + int vendor = 0, product = 0; +#if WLR_HAS_LIBINPUT_BACKEND + if (wlr_input_device_is_libinput(device)) { + struct libinput_device *libinput_dev = wlr_libinput_get_device_handle(device); + vendor = libinput_device_get_id_vendor(libinput_dev); + product = libinput_device_get_id_product(libinput_dev); + } +#endif + char *name = strdup(device->name ? device->name : ""); strip_whitespace(name); diff --git a/sway/ipc-json.c b/sway/ipc-json.c index dfbb7a6e..81ca3483 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -1097,10 +1097,6 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { json_object_new_string(device->identifier)); json_object_object_add(object, "name", json_object_new_string(device->wlr_device->name)); - json_object_object_add(object, "vendor", - json_object_new_int(device->wlr_device->vendor)); - json_object_object_add(object, "product", - json_object_new_int(device->wlr_device->product)); json_object_object_add(object, "type", json_object_new_string( input_device_get_type(device))); @@ -1154,6 +1150,10 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); json_object_object_add(object, "libinput", describe_libinput_device(libinput_dev)); + json_object_object_add(object, "vendor", + json_object_new_int(libinput_device_get_id_vendor(libinput_dev))); + json_object_object_add(object, "product", + json_object_new_int(libinput_device_get_id_product(libinput_dev))); } #endif From 4e6d7612ffbd8e29713ae063937c8460e091bb75 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 27 Feb 2024 15:04:31 +0100 Subject: [PATCH 13/40] xdg-shell: implement popup repositioning --- include/sway/tree/view.h | 1 + sway/desktop/xdg_shell.c | 8 ++++++++ sway/server.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index ef1a26b8..7faacdcc 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -192,6 +192,7 @@ struct sway_xdg_popup { struct wl_listener surface_commit; struct wl_listener new_popup; + struct wl_listener reposition; struct wl_listener destroy; }; diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 27a73f8a..47ab902e 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -35,6 +35,7 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&popup->new_popup.link); wl_list_remove(&popup->destroy.link); wl_list_remove(&popup->surface_commit.link); + wl_list_remove(&popup->reposition.link); wlr_scene_node_destroy(&popup->scene_tree->node); free(popup); } @@ -70,6 +71,11 @@ static void popup_handle_surface_commit(struct wl_listener *listener, void *data } } +static void popup_handle_reposition(struct wl_listener *listener, void *data) { + struct sway_xdg_popup *popup = wl_container_of(listener, popup, reposition); + popup_unconstrain(popup); +} + static struct sway_xdg_popup *popup_create(struct wlr_xdg_popup *wlr_popup, struct sway_view *view, struct wlr_scene_tree *parent) { struct wlr_xdg_surface *xdg_surface = wlr_popup->base; @@ -116,6 +122,8 @@ static struct sway_xdg_popup *popup_create(struct wlr_xdg_popup *wlr_popup, popup->surface_commit.notify = popup_handle_surface_commit; wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup); popup->new_popup.notify = popup_handle_new_popup; + wl_signal_add(&wlr_popup->events.reposition, &popup->reposition); + popup->reposition.notify = popup_handle_reposition; wl_signal_add(&wlr_popup->events.destroy, &popup->destroy); popup->destroy.notify = popup_handle_destroy; diff --git a/sway/server.c b/sway/server.c index 684b1dbd..cb8bdbf9 100644 --- a/sway/server.c +++ b/sway/server.c @@ -65,7 +65,7 @@ #include #endif -#define SWAY_XDG_SHELL_VERSION 2 +#define SWAY_XDG_SHELL_VERSION 3 #define SWAY_LAYER_SHELL_VERSION 4 #define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1 From 3ef5abd405a6fd32aeeffb2f48a6cadd9fc14574 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 27 Feb 2024 15:10:09 +0100 Subject: [PATCH 14/40] xdg-shell: send WM capabilities --- sway/desktop/xdg_shell.c | 4 ++++ sway/server.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 47ab902e..7c417891 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -289,6 +289,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { } // XXX: https://github.com/swaywm/sway/issues/2176 wlr_xdg_surface_schedule_configure(xdg_surface); + // TODO: wlr_xdg_toplevel_set_bounds() return; } @@ -574,4 +575,7 @@ void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data) { wlr_scene_xdg_surface_create(xdg_shell_view->view.content_tree, xdg_toplevel->base); xdg_toplevel->base->data = xdg_shell_view; + + wlr_xdg_toplevel_set_wm_capabilities(xdg_toplevel, + XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); } diff --git a/sway/server.c b/sway/server.c index cb8bdbf9..2a0dc1e7 100644 --- a/sway/server.c +++ b/sway/server.c @@ -65,7 +65,7 @@ #include #endif -#define SWAY_XDG_SHELL_VERSION 3 +#define SWAY_XDG_SHELL_VERSION 5 #define SWAY_LAYER_SHELL_VERSION 4 #define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1 From 23389ebd1f301403e4b2331855a224dff89e1ad1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 8 Mar 2024 12:35:10 +0100 Subject: [PATCH 15/40] config/output: drop enabling flag This was useful when wlroots backends were updating the current mode on their own. This is no longer the case. --- include/sway/output.h | 2 +- sway/config/output.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/sway/output.h b/include/sway/output.h index 30595f54..d546d488 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -50,7 +50,7 @@ struct sway_output { enum wl_output_subpixel detected_subpixel; enum scale_filter_mode scale_filter; - bool enabling, enabled; + bool enabled; list_t *workspaces; struct sway_output_state current; diff --git a/sway/config/output.c b/sway/config/output.c index 55779771..1b2332e9 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -510,9 +510,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { struct wlr_output *wlr_output = output->wlr_output; - // Flag to prevent the output mode event handler from calling us - output->enabling = (!oc || oc->enabled); - struct wlr_output_state pending = {0}; queue_output_config(oc, output, &pending); @@ -522,12 +519,9 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { // Leave the output disabled for now and try again when the output gets // the mode we asked for. sway_log(SWAY_ERROR, "Failed to commit output %s", wlr_output->name); - output->enabling = false; return false; } - output->enabling = false; - if (oc && !oc->enabled) { sway_log(SWAY_DEBUG, "Disabling output %s", oc->name); if (output->enabled) { From 2e951163c5a5f24fe9cf7ee348e56b09719a99a9 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 7 Mar 2024 18:03:40 -0500 Subject: [PATCH 16/40] Force bilinear scaling when scaling down --- sway/desktop/output.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 600423bc..b8f2d32d 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -183,7 +183,15 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer, } } -static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output) { +static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output, + struct wlr_scene_buffer *buffer) { + // if we are scaling down, we should always choose linear + if (buffer->dst_width > 0 && buffer->dst_height > 0 && ( + buffer->dst_width < buffer->buffer_width || + buffer->dst_height < buffer->buffer_height)) { + return WLR_SCALE_FILTER_BILINEAR; + } + switch (output->scale_filter) { case SCALE_FILTER_LINEAR: return WLR_SCALE_FILTER_BILINEAR; @@ -212,7 +220,7 @@ static void output_configure_scene(struct sway_output *output, // hack: don't call the scene setter because that will damage all outputs // We don't want to damage outputs that aren't our current output that // we're configuring - buffer->filter_mode = get_scale_filter(output); + buffer->filter_mode = get_scale_filter(output, buffer); wlr_scene_buffer_set_opacity(buffer, opacity); } else if (node->type == WLR_SCENE_NODE_TREE) { From 2b08e79061db583d0ffe46114c48f958a0d3e6ed Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 4 Mar 2024 13:51:27 +0100 Subject: [PATCH 17/40] server: fix wlr_seat use-after-free on exit Same as [1]. I originally tried to properly handle seat destruction, but that turned out to be a can of worms [2]. [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4590 [2]: https://github.com/swaywm/sway/pull/8034 --- sway/server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/server.c b/sway/server.c index 2a0dc1e7..94d0fae2 100644 --- a/sway/server.c +++ b/sway/server.c @@ -399,6 +399,7 @@ void server_fini(struct sway_server *server) { wlr_xwayland_destroy(server->xwayland.wlr_xwayland); #endif wl_display_destroy_clients(server->wl_display); + wlr_backend_destroy(server->backend); wl_display_destroy(server->wl_display); list_free(server->dirty_nodes); } From 3bc75221bc0074b2e96e14cb88140c95406472c3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 14 Mar 2024 13:54:08 +0100 Subject: [PATCH 18/40] Re-create renderer when lost --- include/sway/server.h | 1 + sway/server.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/sway/server.h b/include/sway/server.h index b2eb2c36..c71851f6 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -46,6 +46,7 @@ struct sway_server { struct wl_listener new_output; struct wl_listener output_layout_change; + struct wl_listener renderer_lost; struct wlr_idle_notifier_v1 *idle_notifier_v1; struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; diff --git a/sway/server.c b/sway/server.c index 94d0fae2..51bde794 100644 --- a/sway/server.c +++ b/sway/server.c @@ -172,6 +172,45 @@ static void detect_proprietary(struct wlr_backend *backend, void *data) { drmFreeVersion(version); } +static void handle_renderer_lost(struct wl_listener *listener, void *data) { + struct sway_server *server = wl_container_of(listener, server, renderer_lost); + + sway_log(SWAY_INFO, "Re-creating renderer after GPU reset"); + + struct wlr_renderer *renderer = wlr_renderer_autocreate(server->backend); + if (renderer == NULL) { + sway_log(SWAY_ERROR, "Unable to create renderer"); + return; + } + + struct wlr_allocator *allocator = + wlr_allocator_autocreate(server->backend, renderer); + if (allocator == NULL) { + sway_log(SWAY_ERROR, "Unable to create allocator"); + wlr_renderer_destroy(renderer); + return; + } + + struct wlr_renderer *old_renderer = server->renderer; + struct wlr_allocator *old_allocator = server->allocator; + server->renderer = renderer; + server->allocator = allocator; + + wl_list_remove(&server->renderer_lost.link); + wl_signal_add(&server->renderer->events.lost, &server->renderer_lost); + + wlr_compositor_set_renderer(server->compositor, renderer); + + for (int i = 0; i < root->outputs->length; ++i) { + struct sway_output *output = root->outputs->items[i]; + wlr_output_init_render(output->wlr_output, + server->allocator, server->renderer); + } + + wlr_allocator_destroy(old_allocator); + wlr_renderer_destroy(old_renderer); +} + bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Initializing Wayland server"); server->wl_display = wl_display_create(); @@ -195,6 +234,9 @@ bool server_init(struct sway_server *server) { return false; } + server->renderer_lost.notify = handle_renderer_lost; + wl_signal_add(&server->renderer->events.lost, &server->renderer_lost); + wlr_renderer_init_wl_shm(server->renderer, server->wl_display); if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL) { From 9139da6149ad4e5bff6cc67d4f2abc2126a66c25 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 11 Mar 2024 19:20:17 +0100 Subject: [PATCH 19/40] man: drop fractional scale warning With the fractional-scale protocol, clients can render without being downscaled. --- sway/sway-output.5.scd | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index 028cb7ab..727b4028 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -72,13 +72,10 @@ must be separated by one space. For example: *output* scale Scales the specified output by the specified scale _factor_. An integer is - recommended, but fractional values are also supported. If a fractional - value are specified, be warned that it is not possible to faithfully - represent the contents of your windows - they will be rendered at the next - highest integer scale factor and downscaled. You may be better served by - setting an integer scale factor and adjusting the font size of your - applications to taste. HiDPI isn't supported with Xwayland clients (windows - will blur). + recommended, but fractional values are also supported. You may be better + served by setting an integer scale factor and adjusting the font size of + your applications to taste. HiDPI isn't supported with Xwayland clients + (windows will blur). *output* scale_filter linear|nearest|smart Indicates how to scale application buffers that are rendered at a scale From dc9f21730735a8700d972e096dc5ec58aec82a3b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 11 Mar 2024 19:22:36 +0100 Subject: [PATCH 20/40] man: document that the scale might be adjusted fractional-scale only supports representing fractions of 120. References: https://github.com/swaywm/sway/issues/8057 --- sway/sway-output.5.scd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index 727b4028..7d088d5d 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -75,7 +75,8 @@ must be separated by one space. For example: recommended, but fractional values are also supported. You may be better served by setting an integer scale factor and adjusting the font size of your applications to taste. HiDPI isn't supported with Xwayland clients - (windows will blur). + (windows will blur). A fractional scale may be slightly adjusted to match + requirements of the protocol. *output* scale_filter linear|nearest|smart Indicates how to scale application buffers that are rendered at a scale From 5a7477cb8f568ce4aeb852215ad40899f18f3d91 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 8 Feb 2020 18:17:42 +0000 Subject: [PATCH 21/40] Implement transient seat management --- include/sway/input/input-manager.h | 3 +++ include/sway/input/seat.h | 1 + sway/input/input-manager.c | 25 +++++++++++++++++++++++++ sway/input/seat.c | 11 ++++++++++- sway/server.c | 3 ++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 145edd4b..45c75199 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "sway/server.h" #include "sway/config.h" #include "list.h" @@ -24,6 +25,7 @@ struct sway_input_manager { struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_virtual_pointer_manager_v1 *virtual_pointer; struct wlr_pointer_gestures_v1 *pointer_gestures; + struct wlr_transient_seat_manager_v1 *transient_seat_manager; struct wl_listener new_input; struct wl_listener inhibit_activate; @@ -31,6 +33,7 @@ struct sway_input_manager { struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor; struct wl_listener virtual_keyboard_new; struct wl_listener virtual_pointer_new; + struct wl_listener transient_seat_create; }; struct sway_input_manager *input_manager_create(struct sway_server *server); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 475753d8..428f9679 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -124,6 +124,7 @@ struct sway_seat { struct wl_listener start_drag; struct wl_listener request_set_selection; struct wl_listener request_set_primary_selection; + struct wl_listener destroy; struct wl_list devices; // sway_seat_device::link struct wl_list keyboard_groups; // sway_keyboard_group::link diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 089e1e71..248ca34e 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -2,7 +2,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -431,6 +433,20 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) { } } +static void handle_transient_seat_manager_create_seat( + struct wl_listener *listener, void *data) { + struct wlr_transient_seat_v1 *transient_seat = data; + static uint64_t i; + char name[256]; + snprintf(name, sizeof(name), "transient-%"PRIx64, i++); + struct sway_seat *seat = seat_create(name); + if (seat && seat->wlr_seat) { + wlr_transient_seat_v1_ready(transient_seat, seat->wlr_seat); + } else { + wlr_transient_seat_v1_deny(transient_seat); + } +} + struct sway_input_manager *input_manager_create(struct sway_server *server) { struct sway_input_manager *input = calloc(1, sizeof(struct sway_input_manager)); @@ -466,6 +482,15 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) { input->pointer_gestures = wlr_pointer_gestures_v1_create(server->wl_display); + input->transient_seat_manager = + wlr_transient_seat_manager_v1_create(server->wl_display); + assert(input->transient_seat_manager); + + input->transient_seat_create.notify = + handle_transient_seat_manager_create_seat; + wl_signal_add(&input->transient_seat_manager->events.create_seat, + &input->transient_seat_create); + return input; } diff --git a/sway/input/seat.c b/sway/input/seat.c index f2486893..0c5672bc 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -67,6 +67,12 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) { } void seat_destroy(struct sway_seat *seat) { + wlr_seat_destroy(seat->wlr_seat); +} + +static void handle_seat_destroy(struct wl_listener *listener, void *data) { + struct sway_seat *seat = wl_container_of(listener, seat, destroy); + if (seat == config->handler_context.seat) { config->handler_context.seat = input_manager_get_default_seat(); } @@ -87,7 +93,7 @@ void seat_destroy(struct sway_seat *seat) { wl_list_remove(&seat->request_set_selection.link); wl_list_remove(&seat->request_set_primary_selection.link); wl_list_remove(&seat->link); - wlr_seat_destroy(seat->wlr_seat); + wl_list_remove(&seat->destroy.link); for (int i = 0; i < seat->deferred_bindings->length; i++) { free_sway_binding(seat->deferred_bindings->items[i]); } @@ -534,6 +540,9 @@ struct sway_seat *seat_create(const char *seat_name) { return NULL; } + seat->destroy.notify = handle_seat_destroy; + wl_signal_add(&seat->wlr_seat->events.destroy, &seat->destroy); + seat->idle_inhibit_sources = seat->idle_wake_sources = IDLE_SOURCE_KEYBOARD | IDLE_SOURCE_POINTER | diff --git a/sway/server.c b/sway/server.c index 51bde794..d159dc9b 100644 --- a/sway/server.c +++ b/sway/server.c @@ -112,7 +112,8 @@ static bool is_privileged(const struct wl_global *global) { global == server.session_lock.manager->global || global == server.input->keyboard_shortcuts_inhibit->global || global == server.input->virtual_keyboard->global || - global == server.input->virtual_pointer->global; + global == server.input->virtual_pointer->global || + global == server.input->transient_seat_manager->global; } static bool filter_global(const struct wl_client *client, From 125c74338ac8bf8c15323a49730352b82d6d51bd Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 24 Mar 2024 12:20:05 +0100 Subject: [PATCH 22/40] man: document supported modifier names --- sway/sway.5.scd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 7e58b528..f73db3ba 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -400,6 +400,12 @@ runtime. only be available for that group. By default, if you overwrite a binding, swaynag will give you a warning. To silence this, use the _--no-warn_ flag. + For specifying modifier keys, you can use the XKB modifier names _Shift_, + _Lock_ (for Caps Lock), _Control_, _Mod1_ (for Alt), _Mod2_ (for Num Lock), + _Mod3_ (for XKB modifier Mod3), _Mod4_ (for the Logo key), and _Mod5_ (for + AltGr). In addition, you can use the aliases _Ctrl_ (for Control) and _Alt_ + (for Alt). + Unless the flag _--locked_ is set, the command will not be run when a screen locking program is active. If there is a matching binding with and without _--locked_, the one with will be preferred when locked and the From e2f3ebad8c1943800dd5f017d547d9d98bfb8bb1 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 00:37:06 +0100 Subject: [PATCH 23/40] config/output: Split apply_output_config Applying an output config has two stages: Atomic application of wlr_output_state, and applicaiton of non-atomic state like output layout. Split the latter out into finalize_output_config for use in a later commit. --- sway/config/output.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index 1b2332e9..fd1d6e3c 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -503,25 +503,12 @@ static void queue_output_config(struct output_config *oc, } } -bool apply_output_config(struct output_config *oc, struct sway_output *output) { +static bool finalize_output_config(struct output_config *oc, struct sway_output *output) { if (output == root->fallback_output) { return false; } struct wlr_output *wlr_output = output->wlr_output; - - struct wlr_output_state pending = {0}; - queue_output_config(oc, output, &pending); - - sway_log(SWAY_DEBUG, "Committing output %s", wlr_output->name); - if (!wlr_output_commit_state(wlr_output, &pending)) { - // Failed to commit output changes, maybe the output is missing a CRTC. - // Leave the output disabled for now and try again when the output gets - // the mode we asked for. - sway_log(SWAY_ERROR, "Failed to commit output %s", wlr_output->name); - return false; - } - if (oc && !oc->enabled) { sway_log(SWAY_DEBUG, "Disabling output %s", oc->name); if (output->enabled) { @@ -577,6 +564,30 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { output->max_render_time = oc->max_render_time; } + return true; +} + +bool apply_output_config(struct output_config *oc, struct sway_output *output) { + if (output == root->fallback_output) { + return false; + } + + struct wlr_output_state pending = {0}; + queue_output_config(oc, output, &pending); + + sway_log(SWAY_DEBUG, "Committing output %s", output->wlr_output->name); + if (!wlr_output_commit_state(output->wlr_output, &pending)) { + // Failed to commit output changes, maybe the output is missing a CRTC. + // Leave the output disabled for now and try again when the output gets + // the mode we asked for. + sway_log(SWAY_ERROR, "Failed to commit output %s", output->wlr_output->name); + return false; + } + + if (!finalize_output_config(oc, output)) { + return false; + } + // Reconfigure all devices, since input config may have been applied before // this output came online, and some config items (like map_to_output) are // dependent on an output being present. From 3e03eb3a017d144137dbe6591891f3a51a61dea0 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 00:48:56 +0100 Subject: [PATCH 24/40] config/output: Introduce apply_output_configs Introduce apply_output_configs, which applies the specified matched output configs as a single backend commit. Reimplement apply_output_config_to_outputs using apply_output_configs. --- include/sway/config.h | 11 ++++ sway/config/output.c | 148 +++++++++++++++++++++++++++++++++++------- 2 files changed, 135 insertions(+), 24 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index f9da1967..d23fe578 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -291,6 +291,14 @@ struct output_config { char *background_fallback; }; +/** + * An output config pre-matched to an output + */ +struct matched_output_config { + struct sway_output *output; + struct output_config *config; +}; + /** * Stores size of gaps for each side */ @@ -684,6 +692,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src); bool apply_output_config(struct output_config *oc, struct sway_output *output); +bool apply_output_configs(struct matched_output_config *configs, + size_t configs_len, bool test_only); + bool test_output_config(struct output_config *oc, struct sway_output *output); struct output_config *store_output_config(struct output_config *oc); diff --git a/sway/config/output.c b/sway/config/output.c index fd1d6e3c..de9515e2 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "sway/config.h" #include "sway/input/cursor.h" #include "sway/output.h" @@ -716,39 +717,138 @@ struct output_config *find_output_config(struct sway_output *output) { return get_output_config(id, output); } -void apply_output_config_to_outputs(struct output_config *oc) { - // Try to find the output container and apply configuration now. If - // this is during startup then there will be no container and config - // will be applied during normal "new output" event from wlroots. - bool wildcard = strcmp(oc->name, "*") == 0; - struct sway_output *sway_output, *tmp; - wl_list_for_each_safe(sway_output, tmp, &root->all_outputs, link) { - if (output_match_name_or_id(sway_output, oc->name)) { - char id[128]; - output_get_identifier(id, sizeof(id), sway_output); - struct output_config *current = get_output_config(id, sway_output); - if (!current) { - // No stored output config matched, apply oc directly - sway_log(SWAY_DEBUG, "Applying oc directly"); - current = new_output_config(oc->name); - merge_output_config(current, oc); - } - apply_output_config(current, sway_output); - free_output_config(current); +bool apply_output_configs(struct matched_output_config *configs, + size_t configs_len, bool test_only) { + struct wlr_backend_output_state *states = calloc(configs_len, sizeof(*states)); + if (!states) { + return false; + } - if (!wildcard) { - // Stop looking if the output config isn't applicable to all - // outputs - break; - } + sway_log(SWAY_DEBUG, "Committing %zd outputs", configs_len); + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; + struct wlr_backend_output_state *backend_state = &states[idx]; + + backend_state->output = cfg->output->wlr_output; + wlr_output_state_init(&backend_state->base); + + sway_log(SWAY_DEBUG, "Preparing config for %s", + cfg->output->wlr_output->name); + queue_output_config(cfg->config, cfg->output, &backend_state->base); + } + + struct wlr_output_swapchain_manager swapchain_mgr; + wlr_output_swapchain_manager_init(&swapchain_mgr, server.backend); + + bool ok = wlr_output_swapchain_manager_prepare(&swapchain_mgr, states, configs_len); + if (!ok) { + sway_log(SWAY_ERROR, "Swapchain prepare failed"); + goto out; + } + + if (test_only) { + // The swapchain manager already did a test for us + goto out; + } + + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; + struct wlr_backend_output_state *backend_state = &states[idx]; + + struct wlr_scene_output_state_options opts = { + .swapchain = wlr_output_swapchain_manager_get_swapchain( + &swapchain_mgr, backend_state->output), + }; + struct wlr_scene_output *scene_output = cfg->output->scene_output; + struct wlr_output_state *state = &backend_state->base; + if (!wlr_scene_output_build_state(scene_output, state, &opts)) { + sway_log(SWAY_ERROR, "Building output state for '%s' failed", + backend_state->output->name); + goto out; } } + ok = wlr_backend_commit(server.backend, states, configs_len); + if (!ok) { + sway_log(SWAY_ERROR, "Backend commit failed"); + goto out; + } + + sway_log(SWAY_DEBUG, "Commit of %zd outputs succeeded", configs_len); + + wlr_output_swapchain_manager_apply(&swapchain_mgr); + + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; + sway_log(SWAY_DEBUG, "Finalizing config for %s", + cfg->output->wlr_output->name); + finalize_output_config(cfg->config, cfg->output); + } + +out: + wlr_output_swapchain_manager_finish(&swapchain_mgr); + for (size_t idx = 0; idx < configs_len; idx++) { + struct wlr_backend_output_state *backend_state = &states[idx]; + wlr_output_state_finish(&backend_state->base); + } + free(states); + + // Reconfigure all devices, since input config may have been applied before + // this output came online, and some config items (like map_to_output) are + // dependent on an output being present. + input_manager_configure_all_input_mappings(); + // Reconfigure the cursor images, since the scale may have changed. + input_manager_configure_xcursor(); + struct sway_seat *seat; wl_list_for_each(seat, &server.input->seats, link) { wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); cursor_rebase(seat->cursor); } + + return ok; +} + +void apply_output_config_to_outputs(struct output_config *oc) { + size_t configs_len = wl_list_length(&root->all_outputs); + struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); + if (!configs) { + return; + } + + // Try to find the output container and apply configuration now. If + // this is during startup then there will be no container and config + // will be applied during normal "new output" event from wlroots. + int config_idx = 0; + struct sway_output *sway_output; + wl_list_for_each(sway_output, &root->all_outputs, link) { + if (sway_output == root->fallback_output) { + configs_len--; + continue; + } + + struct matched_output_config *config = &configs[config_idx++]; + config->output = sway_output; + config->config = find_output_config(sway_output); + + if (!output_match_name_or_id(sway_output, oc->name)) { + continue; + } + + if (!config->config && oc) { + // No stored output config matched, apply oc directly + sway_log(SWAY_DEBUG, "Applying oc directly"); + config->config = new_output_config(oc->name); + merge_output_config(config->config, oc); + } + } + + apply_output_configs(configs, configs_len, false); + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; + free_output_config(cfg->config); + } + free(configs); } void reset_outputs(void) { From 923f642b704022442cc3245a2fa13278341c14e0 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 00:57:11 +0100 Subject: [PATCH 25/40] output/config: Add apply_all_output_configs Apply all output configs as they are. This differs from apply_output_config_to_outputs, which tries to apply a specific output config. --- include/sway/config.h | 2 ++ sway/config/output.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/sway/config.h b/include/sway/config.h index d23fe578..eff7cfbb 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -695,6 +695,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output); bool apply_output_configs(struct matched_output_config *configs, size_t configs_len, bool test_only); +void apply_all_output_configs(void); + bool test_output_config(struct output_config *oc, struct sway_output *output); struct output_config *store_output_config(struct output_config *oc); diff --git a/sway/config/output.c b/sway/config/output.c index de9515e2..5bf5bed5 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -809,6 +809,34 @@ out: return ok; } +void apply_all_output_configs(void) { + size_t configs_len = wl_list_length(&root->all_outputs); + struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); + if (!configs) { + return; + } + + int config_idx = 0; + struct sway_output *sway_output; + wl_list_for_each(sway_output, &root->all_outputs, link) { + if (sway_output == root->fallback_output) { + configs_len--; + continue; + } + + struct matched_output_config *config = &configs[config_idx++]; + config->output = sway_output; + config->config = find_output_config(sway_output); + } + + apply_output_configs(configs, configs_len, false); + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; + free_output_config(cfg->config); + } + free(configs); +} + void apply_output_config_to_outputs(struct output_config *oc) { size_t configs_len = wl_list_length(&root->all_outputs); struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); From 98be797356876153e74405dbef36e3e71875ca2e Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 01:00:46 +0100 Subject: [PATCH 26/40] Use apply_all_output_configs to light up outputs This allows us to test and if necessary degrade the entire backend configuration to light everything up. --- sway/commands/output.c | 4 ++-- sway/desktop/output.c | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sway/commands/output.c b/sway/commands/output.c index 462dffd2..5e5d31b3 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -103,13 +103,13 @@ struct cmd_results *cmd_output(int argc, char **argv) { bool background = output->background; - output = store_output_config(output); + store_output_config(output); // If reloading, the output configs will be applied after reading the // entire config and before the deferred commands so that an auto generated // workspace name is not given to re-enabled outputs. if (!config->reloading && !config->validating) { - apply_output_config_to_outputs(output); + apply_all_output_configs(); if (background) { if (!spawn_swaybg()) { return cmd_results_new(CMD_FAILURE, diff --git a/sway/desktop/output.c b/sway/desktop/output.c index b8f2d32d..b2647219 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -521,9 +521,7 @@ void handle_new_output(struct wl_listener *listener, void *data) { sway_session_lock_add_output(server->session_lock.lock, output); } - struct output_config *oc = find_output_config(output); - apply_output_config(oc, output); - free_output_config(oc); + apply_all_output_configs(); transaction_commit_dirty(); @@ -652,6 +650,6 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener, oc->power = 1; break; } - oc = store_output_config(oc); - apply_output_config(oc, output); + store_output_config(oc); + apply_all_output_configs(); } From 3b419020a32f4f8385e49d2137ceb4d9b8262176 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 01:01:56 +0100 Subject: [PATCH 27/40] desktop/output: Use apply_output_configs for output mgmt --- sway/desktop/output.c | 113 ++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index b2647219..bd3de3fe 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -550,63 +550,88 @@ void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data) { wlr_output_schedule_frame(output->wlr_output); } +static struct output_config *output_config_for_config_head( + struct wlr_output_configuration_head_v1 *config_head, + struct sway_output *output) { + struct output_config *oc = new_output_config(output->wlr_output->name); + oc->enabled = config_head->state.enabled; + if (!oc->enabled) { + return oc; + } + + if (config_head->state.mode != NULL) { + struct wlr_output_mode *mode = config_head->state.mode; + oc->width = mode->width; + oc->height = mode->height; + oc->refresh_rate = mode->refresh / 1000.f; + } else { + oc->width = config_head->state.custom_mode.width; + oc->height = config_head->state.custom_mode.height; + oc->refresh_rate = + config_head->state.custom_mode.refresh / 1000.f; + } + oc->x = config_head->state.x; + oc->y = config_head->state.y; + oc->transform = config_head->state.transform; + oc->scale = config_head->state.scale; + oc->adaptive_sync = config_head->state.adaptive_sync_enabled; + return oc; +} + static void output_manager_apply(struct sway_server *server, struct wlr_output_configuration_v1 *config, bool test_only) { - // TODO: perform atomic tests on the whole backend atomically + size_t configs_len = wl_list_length(&root->all_outputs); + struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); + if (!configs) { + return; + } - struct wlr_output_configuration_head_v1 *config_head; - // First disable outputs we need to disable - bool ok = true; - wl_list_for_each(config_head, &config->heads, link) { - struct wlr_output *wlr_output = config_head->state.output; - struct sway_output *output = wlr_output->data; - if (!output->enabled || config_head->state.enabled) { + int config_idx = 0; + struct sway_output *sway_output; + wl_list_for_each(sway_output, &root->all_outputs, link) { + if (sway_output == root->fallback_output) { + configs_len--; continue; } - struct output_config *oc = new_output_config(output->wlr_output->name); - oc->enabled = false; - if (test_only) { - ok &= test_output_config(oc, output); - } else { - oc = store_output_config(oc); - ok &= apply_output_config(oc, output); + struct matched_output_config *cfg = &configs[config_idx++]; + cfg->output = sway_output; + + struct wlr_output_configuration_head_v1 *config_head; + wl_list_for_each(config_head, &config->heads, link) { + if (config_head->state.output == sway_output->wlr_output) { + cfg->config = output_config_for_config_head(config_head, sway_output); + break; + } + } + if (!cfg->config) { + cfg->config = find_output_config(sway_output); } } - // Then enable outputs that need to - wl_list_for_each(config_head, &config->heads, link) { - struct wlr_output *wlr_output = config_head->state.output; - struct sway_output *output = wlr_output->data; - if (!config_head->state.enabled) { - continue; - } - struct output_config *oc = new_output_config(output->wlr_output->name); - oc->enabled = true; - if (config_head->state.mode != NULL) { - struct wlr_output_mode *mode = config_head->state.mode; - oc->width = mode->width; - oc->height = mode->height; - oc->refresh_rate = mode->refresh / 1000.f; - } else { - oc->width = config_head->state.custom_mode.width; - oc->height = config_head->state.custom_mode.height; - oc->refresh_rate = - config_head->state.custom_mode.refresh / 1000.f; - } - oc->x = config_head->state.x; - oc->y = config_head->state.y; - oc->transform = config_head->state.transform; - oc->scale = config_head->state.scale; - oc->adaptive_sync = config_head->state.adaptive_sync_enabled; + bool ok = apply_output_configs(configs, configs_len, test_only); + for (size_t idx = 0; idx < configs_len; idx++) { + struct matched_output_config *cfg = &configs[idx]; - if (test_only) { - ok &= test_output_config(oc, output); + // Only store new configs for successful non-test commits. Old configs, + // test-only and failed commits just get freed. + bool store_config = false; + if (!test_only && ok) { + struct wlr_output_configuration_head_v1 *config_head; + wl_list_for_each(config_head, &config->heads, link) { + if (config_head->state.output == sway_output->wlr_output) { + store_config = true; + break; + } + } + } + if (store_config) { + store_output_config(cfg->config); } else { - oc = store_output_config(oc); - ok &= apply_output_config(oc, output); + free_output_config(cfg->config); } } + free(configs); if (ok) { wlr_output_configuration_v1_send_succeeded(config); From 56e97b7d60e3723f79fd972061191117bf544f08 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 01:03:37 +0100 Subject: [PATCH 28/40] config/output: Remove apply_output_config --- include/sway/config.h | 2 -- sway/config/output.c | 30 ------------------------------ 2 files changed, 32 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index eff7cfbb..69b14446 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -690,8 +690,6 @@ struct output_config *new_output_config(const char *name); void merge_output_config(struct output_config *dst, struct output_config *src); -bool apply_output_config(struct output_config *oc, struct sway_output *output); - bool apply_output_configs(struct matched_output_config *configs, size_t configs_len, bool test_only); diff --git a/sway/config/output.c b/sway/config/output.c index 5bf5bed5..cb12683d 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -568,36 +568,6 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output return true; } -bool apply_output_config(struct output_config *oc, struct sway_output *output) { - if (output == root->fallback_output) { - return false; - } - - struct wlr_output_state pending = {0}; - queue_output_config(oc, output, &pending); - - sway_log(SWAY_DEBUG, "Committing output %s", output->wlr_output->name); - if (!wlr_output_commit_state(output->wlr_output, &pending)) { - // Failed to commit output changes, maybe the output is missing a CRTC. - // Leave the output disabled for now and try again when the output gets - // the mode we asked for. - sway_log(SWAY_ERROR, "Failed to commit output %s", output->wlr_output->name); - return false; - } - - if (!finalize_output_config(oc, output)) { - return false; - } - - // Reconfigure all devices, since input config may have been applied before - // this output came online, and some config items (like map_to_output) are - // dependent on an output being present. - input_manager_configure_all_input_mappings(); - // Reconfigure the cursor images, since the scale may have changed. - input_manager_configure_xcursor(); - return true; -} - bool test_output_config(struct output_config *oc, struct sway_output *output) { if (output == root->fallback_output) { return false; From 9becff0ba56ac7da8b1235aa5740fb04414636a2 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 01:11:35 +0100 Subject: [PATCH 29/40] output/config: Remove reset_outputs and co. apply_output_config_to_outputs uses the specified output config to check which outputs to apply to, and to use as backup when no config is found. If any config matches the output, the specified config will be disregarded. The only remaining user of apply_output_config_to_outputs is reset_outputs, which called apply_output_config_to_outputs with either the first stored wildcard config, or a new empty wildcard config. Providing a stored or empty wildcard config is practically the same as calling `apply_all_output_configs`. Replace uses of `reset_outputs` with `apply_all_output_configs` and remove the now unused functions. --- include/sway/config.h | 4 ---- sway/config.c | 2 +- sway/config/output.c | 53 ------------------------------------------- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 69b14446..7e67ba21 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -701,10 +701,6 @@ struct output_config *store_output_config(struct output_config *oc); struct output_config *find_output_config(struct sway_output *output); -void apply_output_config_to_outputs(struct output_config *oc); - -void reset_outputs(void); - void free_output_config(struct output_config *oc); bool spawn_swaybg(void); diff --git a/sway/config.c b/sway/config.c index 72fc41e7..f9131e0f 100644 --- a/sway/config.c +++ b/sway/config.c @@ -532,7 +532,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) { } sway_switch_retrigger_bindings_for_all(); - reset_outputs(); + apply_all_output_configs(); spawn_swaybg(); config->reloading = false; diff --git a/sway/config/output.c b/sway/config/output.c index cb12683d..a7c2f9b8 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -807,59 +807,6 @@ void apply_all_output_configs(void) { free(configs); } -void apply_output_config_to_outputs(struct output_config *oc) { - size_t configs_len = wl_list_length(&root->all_outputs); - struct matched_output_config *configs = calloc(configs_len, sizeof(*configs)); - if (!configs) { - return; - } - - // Try to find the output container and apply configuration now. If - // this is during startup then there will be no container and config - // will be applied during normal "new output" event from wlroots. - int config_idx = 0; - struct sway_output *sway_output; - wl_list_for_each(sway_output, &root->all_outputs, link) { - if (sway_output == root->fallback_output) { - configs_len--; - continue; - } - - struct matched_output_config *config = &configs[config_idx++]; - config->output = sway_output; - config->config = find_output_config(sway_output); - - if (!output_match_name_or_id(sway_output, oc->name)) { - continue; - } - - if (!config->config && oc) { - // No stored output config matched, apply oc directly - sway_log(SWAY_DEBUG, "Applying oc directly"); - config->config = new_output_config(oc->name); - merge_output_config(config->config, oc); - } - } - - apply_output_configs(configs, configs_len, false); - for (size_t idx = 0; idx < configs_len; idx++) { - struct matched_output_config *cfg = &configs[idx]; - free_output_config(cfg->config); - } - free(configs); -} - -void reset_outputs(void) { - struct output_config *oc = NULL; - int i = list_seq_find(config->output_configs, output_name_cmp, "*"); - if (i >= 0) { - oc = config->output_configs->items[i]; - } else { - oc = store_output_config(new_output_config("*")); - } - apply_output_config_to_outputs(oc); -} - void free_output_config(struct output_config *oc) { if (!oc) { return; From c3fca26d303617614bee67ad766fd3cb95609245 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 13:25:23 +0100 Subject: [PATCH 30/40] config/output: Make merge_output_config static --- include/sway/config.h | 2 -- sway/config/output.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 7e67ba21..5a303d9f 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -688,8 +688,6 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt struct output_config *new_output_config(const char *name); -void merge_output_config(struct output_config *dst, struct output_config *src); - bool apply_output_configs(struct matched_output_config *configs, size_t configs_len, bool test_only); diff --git a/sway/config/output.c b/sway/config/output.c index a7c2f9b8..72cbf261 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -79,7 +79,7 @@ struct output_config *new_output_config(const char *name) { return oc; } -void merge_output_config(struct output_config *dst, struct output_config *src) { +static void merge_output_config(struct output_config *dst, struct output_config *src) { if (src->enabled != -1) { dst->enabled = src->enabled; } From 26a9a6b4792a1b2b00406ae6c20ea88325e7c7aa Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 13:25:45 +0100 Subject: [PATCH 31/40] output/config: Remove unused test_output_config --- include/sway/config.h | 2 -- sway/config/output.c | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 5a303d9f..40710199 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -693,8 +693,6 @@ bool apply_output_configs(struct matched_output_config *configs, void apply_all_output_configs(void); -bool test_output_config(struct output_config *oc, struct sway_output *output); - struct output_config *store_output_config(struct output_config *oc); struct output_config *find_output_config(struct sway_output *output); diff --git a/sway/config/output.c b/sway/config/output.c index 72cbf261..3f1c3126 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -568,16 +568,6 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output return true; } -bool test_output_config(struct output_config *oc, struct sway_output *output) { - if (output == root->fallback_output) { - return false; - } - - struct wlr_output_state pending = {0}; - queue_output_config(oc, output, &pending); - return wlr_output_test_state(output->wlr_output, &pending); -} - static void default_output_config(struct output_config *oc, struct wlr_output *wlr_output) { oc->enabled = 1; From a4ef37752fd6ae9e84d60cbe4eaead07f71f9435 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 17:55:07 +0100 Subject: [PATCH 32/40] commands/output/toggle: Use free_output_config --- sway/commands/output/toggle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/commands/output/toggle.c b/sway/commands/output/toggle.c index 6342d526..c6b72845 100644 --- a/sway/commands/output/toggle.c +++ b/sway/commands/output/toggle.c @@ -29,7 +29,7 @@ struct cmd_results *output_cmd_toggle(int argc, char **argv) { config->handler_context.output_config->enabled = 1; } - free(oc); + free_output_config(oc); config->handler_context.leftovers.argc = argc; config->handler_context.leftovers.argv = argv; return NULL; From 9e1465107788af2c8ce93e2a288e9d32bc09711c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 28 Mar 2024 11:45:46 +0100 Subject: [PATCH 33/40] input: pass wlr_seat_client to wlr_seat_touch_notify_cancel() References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4613 --- sway/input/seatop_down.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index 35fd3bcb..340e334b 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c @@ -117,7 +117,11 @@ static void handle_touch_cancel(struct sway_seat *seat, } if (e->surface) { - wlr_seat_touch_notify_cancel(seat->wlr_seat, e->surface); + struct wl_client *client = wl_resource_get_client(e->surface->resource); + struct wlr_seat_client *seat_client = wlr_seat_client_for_wl_client(seat->wlr_seat, client); + if (seat_client != NULL) { + wlr_seat_touch_notify_cancel(seat->wlr_seat, seat_client); + } } if (wl_list_empty(&e->point_events)) { From dcb142bf5e390250939544075b5852ca21eaf721 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 29 Mar 2024 18:46:08 -0400 Subject: [PATCH 34/40] sway-ipc(7): Escape backslashes correctly in GET_CONFIG output Without this change, i see the following in the sway-ipc manpage: ``` 9. GET_CONFIG MESSAGE Retrieve the contents of the config that was last loaded REPLY An object with a single string property containing the contents of the config Example Reply: { "config": "set $mod Mod4nbindsym $mod+q exitn" } ``` --- sway/sway-ipc.7.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index c9895e52..2f697248 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -1046,7 +1046,7 @@ An object with a single string property containing the contents of the config *Example Reply:* ``` { - "config": "set $mod Mod4\nbindsym $mod+q exit\n" + "config": "set $mod Mod4\\nbindsym $mod+q exit\\n" } ``` From bc258a3be2f946c1c93bcbe40735b2db068e0ea8 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Fri, 5 Apr 2024 16:40:28 +0200 Subject: [PATCH 35/40] input: add Super as alternative for Mod4 This PR implements alternative human-readable names for the logo key (Mod4) as proposed in #8084. --- sway/input/keyboard.c | 1 + sway/sway.5.scd | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index b97f0152..f74d0658 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -32,6 +32,7 @@ static struct modifier_key { { XKB_MOD_NAME_NUM, WLR_MODIFIER_MOD2 }, { "Mod3", WLR_MODIFIER_MOD3 }, { XKB_MOD_NAME_LOGO, WLR_MODIFIER_LOGO }, + { "Super", WLR_MODIFIER_LOGO }, { "Mod5", WLR_MODIFIER_MOD5 }, }; diff --git a/sway/sway.5.scd b/sway/sway.5.scd index f73db3ba..9f823947 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -403,8 +403,8 @@ runtime. For specifying modifier keys, you can use the XKB modifier names _Shift_, _Lock_ (for Caps Lock), _Control_, _Mod1_ (for Alt), _Mod2_ (for Num Lock), _Mod3_ (for XKB modifier Mod3), _Mod4_ (for the Logo key), and _Mod5_ (for - AltGr). In addition, you can use the aliases _Ctrl_ (for Control) and _Alt_ - (for Alt). + AltGr). In addition, you can use the aliases _Ctrl_ (for Control), _Alt_ + (for Alt), and _Super_ (for the Logo key). Unless the flag _--locked_ is set, the command will not be run when a screen locking program is active. If there is a matching binding with From 1267e47de913d2cda2644ad89bba4e9c55842cd3 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sat, 16 Mar 2024 17:55:20 +0100 Subject: [PATCH 36/40] config/output: Refactor handling of tiered configs Output configuration can be applied to a particular output in three ways: As a wildcard, by connector name and by identifier. This in turn means that three different configurations must be handled at any given time. In the current model, this is managed by merging new configuration into every other matching configuration. At the same time, an additional synthetic configuration is made which matchehes both identifier and name at the same time, further complicating logic. Instead, manage and store each configuration independently and merge them in order when retrieving configuration for an output. When changes are made to a less specific configuration, clear these fields from more specific configurations to allow the change to take effect regardless of precedence. Fixes: https://github.com/swaywm/sway/issues/8048 --- include/sway/config.h | 9 +- sway/config/output.c | 294 +++++++++++++++++++----------------------- 2 files changed, 142 insertions(+), 161 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 40710199..0be1cd22 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -693,7 +693,14 @@ bool apply_output_configs(struct matched_output_config *configs, void apply_all_output_configs(void); -struct output_config *store_output_config(struct output_config *oc); +/** + * store_output_config stores a new output config. An output may be matched by + * three different config types, in order of precedence: Identifier, name and + * wildcard. When storing a config type of lower precedence, assume that the + * user wants the config to take immediate effect by superseding (clearing) the + * same values from higher presedence configuration. + */ +void store_output_config(struct output_config *oc); struct output_config *find_output_config(struct sway_output *output); diff --git a/sway/config/output.c b/sway/config/output.c index 3f1c3126..e5ff240a 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -79,6 +79,71 @@ struct output_config *new_output_config(const char *name) { return oc; } +// supersede_output_config clears all fields in dst that were set in src +static void supersede_output_config(struct output_config *dst, struct output_config *src) { + if (src->enabled != -1) { + dst->enabled = -1; + } + if (src->width != -1) { + dst->width = -1; + } + if (src->height != -1) { + dst->height = -1; + } + if (src->x != -1) { + dst->x = -1; + } + if (src->y != -1) { + dst->y = -1; + } + if (src->scale != -1) { + dst->scale = -1; + } + if (src->scale_filter != SCALE_FILTER_DEFAULT) { + dst->scale_filter = SCALE_FILTER_DEFAULT; + } + if (src->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) { + dst->subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; + } + if (src->refresh_rate != -1) { + dst->refresh_rate = -1; + } + if (src->custom_mode != -1) { + dst->custom_mode = -1; + } + if (src->drm_mode.type != (uint32_t) -1) { + dst->drm_mode.type = -1; + } + if (src->transform != -1) { + dst->transform = -1; + } + if (src->max_render_time != -1) { + dst->max_render_time = -1; + } + if (src->adaptive_sync != -1) { + dst->adaptive_sync = -1; + } + if (src->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { + dst->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT; + } + if (src->background) { + free(dst->background); + dst->background = NULL; + } + if (src->background_option) { + free(dst->background_option); + dst->background_option = NULL; + } + if (src->background_fallback) { + free(dst->background_fallback); + dst->background_fallback = NULL; + } + if (src->power != -1) { + dst->power = -1; + } +} + +// merge_output_config sets all fields in dst that were set in src static void merge_output_config(struct output_config *dst, struct output_config *src) { if (src->enabled != -1) { dst->enabled = src->enabled; @@ -142,96 +207,46 @@ static void merge_output_config(struct output_config *dst, struct output_config } } -static void merge_wildcard_on_all(struct output_config *wildcard) { - for (int i = 0; i < config->output_configs->length; i++) { - struct output_config *oc = config->output_configs->items[i]; - if (strcmp(wildcard->name, oc->name) != 0) { - sway_log(SWAY_DEBUG, "Merging output * config on %s", oc->name); - merge_output_config(oc, wildcard); - } - } -} - -static void merge_id_on_name(struct output_config *oc) { - struct sway_output *output = all_output_by_name_or_id(oc->name); - if (output == NULL) { - return; +void store_output_config(struct output_config *oc) { + bool merged = false; + bool wildcard = strcmp(oc->name, "*") == 0; + struct sway_output *output = wildcard ? NULL : output_by_name_or_id(oc->name); + if (!output && !wildcard) { + // There is no config by this name, just add it in + goto done; } - const char *name = output->wlr_output->name; char id[128]; output_get_identifier(id, sizeof(id), output); + for (int i = 0; i < config->output_configs->length; i++) { + struct output_config *old = config->output_configs->items[i]; - char *id_on_name = format_str("%s on %s", id, name); - if (!id_on_name) { - return; - } + // If the old config matches the new config's name, regardless of + // whether it was name or identifier, merge on top of the existing + // config. If the new config is a wildcard, this also merges on top of + // old wildcard configs. + if (strcmp(old->name, oc->name) == 0) { + merge_output_config(old, oc); + merged = true; + continue; + } - int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); - if (i >= 0) { - sway_log(SWAY_DEBUG, "Merging on top of existing id on name config"); - merge_output_config(config->output_configs->items[i], oc); - } else { - // If both a name and identifier config, exist generate an id on name - int ni = list_seq_find(config->output_configs, output_name_cmp, name); - int ii = list_seq_find(config->output_configs, output_name_cmp, id); - if ((ni >= 0 && ii >= 0) || (ni >= 0 && strcmp(oc->name, id) == 0) - || (ii >= 0 && strcmp(oc->name, name) == 0)) { - struct output_config *ion_oc = new_output_config(id_on_name); - if (ni >= 0) { - merge_output_config(ion_oc, config->output_configs->items[ni]); - } - if (ii >= 0) { - merge_output_config(ion_oc, config->output_configs->items[ii]); - } - merge_output_config(ion_oc, oc); - list_add(config->output_configs, ion_oc); - sway_log(SWAY_DEBUG, "Generated id on name output config \"%s\"" - " (enabled: %d) (%dx%d@%fHz position %d,%d scale %f " - "transform %d) (bg %s %s) (power %d) (max render time: %d)", - ion_oc->name, ion_oc->enabled, ion_oc->width, ion_oc->height, - ion_oc->refresh_rate, ion_oc->x, ion_oc->y, ion_oc->scale, - ion_oc->transform, ion_oc->background, - ion_oc->background_option, ion_oc->power, - ion_oc->max_render_time); + // If the new config is a wildcard config we supersede all non-wildcard + // configs. Old wildcard configs have already been handled above. + if (wildcard) { + supersede_output_config(old, oc); + continue; + } + + // If the new config matches an output's name, and the old config + // matches on that output's identifier, supersede it. + if (strcmp(old->name, id) == 0 && + strcmp(oc->name, output->wlr_output->name) == 0) { + supersede_output_config(old, oc); } } - free(id_on_name); -} - -struct output_config *store_output_config(struct output_config *oc) { - bool wildcard = strcmp(oc->name, "*") == 0; - if (wildcard) { - merge_wildcard_on_all(oc); - } else { - merge_id_on_name(oc); - } - - int i = list_seq_find(config->output_configs, output_name_cmp, oc->name); - if (i >= 0) { - sway_log(SWAY_DEBUG, "Merging on top of existing output config"); - struct output_config *current = config->output_configs->items[i]; - merge_output_config(current, oc); - free_output_config(oc); - oc = current; - } else if (!wildcard) { - sway_log(SWAY_DEBUG, "Adding non-wildcard output config"); - i = list_seq_find(config->output_configs, output_name_cmp, "*"); - if (i >= 0) { - sway_log(SWAY_DEBUG, "Merging on top of output * config"); - struct output_config *current = new_output_config(oc->name); - merge_output_config(current, config->output_configs->items[i]); - merge_output_config(current, oc); - free_output_config(oc); - oc = current; - } - list_add(config->output_configs, oc); - } else { - // New wildcard config. Just add it - sway_log(SWAY_DEBUG, "Adding output * config"); - list_add(config->output_configs, oc); - } +done: sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) " "(max render time: %d)", @@ -240,7 +255,13 @@ struct output_config *store_output_config(struct output_config *oc) { oc->transform, oc->background, oc->background_option, oc->power, oc->max_render_time); - return oc; + // If the configuration was not merged into an existing configuration, add + // it to the list. Otherwise we're done with it and can free it. + if (!merged) { + list_add(config->output_configs, oc); + } else { + free_output_config(oc); + } } static void set_mode(struct wlr_output *output, struct wlr_output_state *pending, @@ -587,94 +608,47 @@ static void default_output_config(struct output_config *oc, oc->max_render_time = 0; } -static struct output_config *get_output_config(char *identifier, - struct sway_output *sway_output) { +// find_output_config returns a merged output_config containing all stored +// configuration that applies to the specified output. +struct output_config *find_output_config(struct sway_output *sway_output) { const char *name = sway_output->wlr_output->name; + struct output_config *oc = NULL; - struct output_config *oc_id_on_name = NULL; - struct output_config *oc_name = NULL; - struct output_config *oc_id = NULL; - - char *id_on_name = format_str("%s on %s", identifier, name); - int i = list_seq_find(config->output_configs, output_name_cmp, id_on_name); - if (i >= 0) { - oc_id_on_name = config->output_configs->items[i]; - } else { - i = list_seq_find(config->output_configs, output_name_cmp, name); - if (i >= 0) { - oc_name = config->output_configs->items[i]; - } - - i = list_seq_find(config->output_configs, output_name_cmp, identifier); - if (i >= 0) { - oc_id = config->output_configs->items[i]; - } - } - - struct output_config *result = new_output_config("temp"); + struct output_config *result = new_output_config(name); if (config->reloading) { default_output_config(result, sway_output->wlr_output); } - if (oc_id_on_name) { - // Already have an identifier on name config, use that - free(result->name); - result->name = strdup(id_on_name); - merge_output_config(result, oc_id_on_name); - } else if (oc_name && oc_id) { - // Generate a config named ` on ` which contains a - // merged copy of the identifier on name. This will make sure that both - // identifier and name configs are respected, with identifier getting - // priority - struct output_config *temp = new_output_config(id_on_name); - merge_output_config(temp, oc_name); - merge_output_config(temp, oc_id); - list_add(config->output_configs, temp); - free(result->name); - result->name = strdup(id_on_name); - merge_output_config(result, temp); + char id[128]; + output_get_identifier(id, sizeof(id), sway_output); - sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)" - " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)" - " (power %d) (max render time: %d)", result->name, result->enabled, - result->width, result->height, result->refresh_rate, - result->x, result->y, result->scale, result->transform, - result->background, result->background_option, result->power, - result->max_render_time); - } else if (oc_name) { - // No identifier config, just return a copy of the name config - free(result->name); - result->name = strdup(name); - merge_output_config(result, oc_name); - } else if (oc_id) { - // No name config, just return a copy of the identifier config - free(result->name); - result->name = strdup(identifier); - merge_output_config(result, oc_id); - } else { - i = list_seq_find(config->output_configs, output_name_cmp, "*"); - if (i >= 0) { - // No name or identifier config, but there is a wildcard config - free(result->name); - result->name = strdup("*"); - merge_output_config(result, config->output_configs->items[i]); - } else if (!config->reloading) { - // No name, identifier, or wildcard config. Since we are not - // reloading with defaults, the output config will be empty, so - // just return NULL - free_output_config(result); - result = NULL; - } + int i; + bool match = false; + if ((i = list_seq_find(config->output_configs, output_name_cmp, "*")) >= 0) { + match = true; + oc = config->output_configs->items[i]; + merge_output_config(result, oc); + } + if ((i = list_seq_find(config->output_configs, output_name_cmp, name)) >= 0) { + match = true; + oc = config->output_configs->items[i]; + merge_output_config(result, oc); + } + if ((i = list_seq_find(config->output_configs, output_name_cmp, id)) >= 0) { + match = true; + oc = config->output_configs->items[i]; + merge_output_config(result, oc); } - free(id_on_name); - return result; -} + if (!match && !config->reloading) { + // No name, identifier, or wildcard config. Since we are not + // reloading with defaults, the output config will be empty, so + // just return NULL + free_output_config(result); + return NULL; + } -struct output_config *find_output_config(struct sway_output *output) { - char id[128]; - output_get_identifier(id, sizeof(id), output); - return get_output_config(id, output); + return result; } bool apply_output_configs(struct matched_output_config *configs, From f11c5d562e3507a5e8b21491d61a6e43e81e43ad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 12 Apr 2024 18:42:50 +0200 Subject: [PATCH 37/40] config/output: fix NULL derefs in store_output_config() ../sway/config/output.c:33:21: runtime error: member access within null pointer of type 'struct sway_output' AddressSanitizer:DEADLYSIGNAL ================================================================= ==7856==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000080 (pc 0x63da8558205c bp 0x7ffdc35881a0 sp 0x7ffdc3588160 T0) ==7856==The signal is caused by a READ memory access. ==7856==Hint: address points to the zero page. #0 0x63da8558205c in output_get_identifier ../sway/config/output.c:33 #1 0x63da855865c3 in store_output_config ../sway/config/output.c:220 #2 0x63da855d4066 in cmd_output ../sway/commands/output.c:106 #3 0x63da8547f2e3 in config_command ../sway/commands.c:425 #4 0x63da8548f3fc in read_config ../sway/config.c:822 #5 0x63da8548a224 in load_config ../sway/config.c:435 #6 0x63da8548b065 in load_main_config ../sway/config.c:507 #7 0x63da854bee8d in main ../sway/main.c:351 #8 0x77e2ea643ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) #9 0x77e2ea643d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) #10 0x63da8547ad64 in _start (/home/simon/src/sway/build/sway/sway+0x372d64) (BuildId: 3fa2e8838c1c32713b40aec6b1e84bbe4db5bde8) Fixes: 1267e47de913 ("config/output: Refactor handling of tiered configs") --- sway/config/output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index e5ff240a..aab3f0bd 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -217,7 +217,10 @@ void store_output_config(struct output_config *oc) { } char id[128]; - output_get_identifier(id, sizeof(id), output); + if (output) { + output_get_identifier(id, sizeof(id), output); + } + for (int i = 0; i < config->output_configs->length; i++) { struct output_config *old = config->output_configs->items[i]; @@ -240,7 +243,7 @@ void store_output_config(struct output_config *oc) { // If the new config matches an output's name, and the old config // matches on that output's identifier, supersede it. - if (strcmp(old->name, id) == 0 && + if (output && strcmp(old->name, id) == 0 && strcmp(oc->name, output->wlr_output->name) == 0) { supersede_output_config(old, oc); } From 087226d997c15f4df30542778854999c632642a3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 12 Apr 2024 18:44:07 +0200 Subject: [PATCH 38/40] config/output: drop fast path in store_output_config() If there is no output currently connected, we still want to merge to any existing config. It shouldn't matter to iterate over the list of outputs to do nothing anwyays. --- sway/config/output.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index aab3f0bd..54af5d8e 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -211,10 +211,6 @@ void store_output_config(struct output_config *oc) { bool merged = false; bool wildcard = strcmp(oc->name, "*") == 0; struct sway_output *output = wildcard ? NULL : output_by_name_or_id(oc->name); - if (!output && !wildcard) { - // There is no config by this name, just add it in - goto done; - } char id[128]; if (output) { @@ -249,7 +245,6 @@ void store_output_config(struct output_config *oc) { } } -done: sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) " "(max render time: %d)", From ffcde7a70c1341d1ec1d38c00ff87faa1a816892 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 21 Apr 2024 16:42:08 +0200 Subject: [PATCH 39/40] server: Use wlr_renderer_get_texture_formats wlr_renderer_get_{dmabuf|shm}_texture_formats have been replaced by a unified wlr_renderer_get_texture_formats interface using buffer caps. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4644 --- sway/server.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sway/server.c b/sway/server.c index d159dc9b..180d3a6b 100644 --- a/sway/server.c +++ b/sway/server.c @@ -240,13 +240,12 @@ bool server_init(struct sway_server *server) { wlr_renderer_init_wl_shm(server->renderer, server->wl_display); - if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL) { + if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF) != NULL) { server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer( server->wl_display, 4, server->renderer); - } - if (wlr_renderer_get_dmabuf_texture_formats(server->renderer) != NULL && - debug.legacy_wl_drm) { - wlr_drm_create(server->wl_display, server->renderer); + if (debug.legacy_wl_drm) { + wlr_drm_create(server->wl_display, server->renderer); + } } server->allocator = wlr_allocator_autocreate(server->backend, From 646019cad9e8a075911e960fc7645471d9c26bf6 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 23 Apr 2024 13:26:14 +0200 Subject: [PATCH 40/40] desktop/output: Fix check if config should be stored We want to check if a config_head existed for the current matched_output_config, so we should check cfg->output. sway_output is a temporary variable from a previous wl_list_for_each, and does not contain anything useful to us. Fixes: https://github.com/swaywm/sway/issues/8128 --- sway/desktop/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index bd3de3fe..70987feb 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -619,7 +619,7 @@ static void output_manager_apply(struct sway_server *server, if (!test_only && ok) { struct wlr_output_configuration_head_v1 *config_head; wl_list_for_each(config_head, &config->heads, link) { - if (config_head->state.output == sway_output->wlr_output) { + if (config_head->state.output == cfg->output->wlr_output) { store_config = true; break; }