From 86f96a786bac957f5195e894c94b1ce7eb93ef09 Mon Sep 17 00:00:00 2001 From: EBADBEEF Date: Fri, 20 Oct 2023 10:29:06 -0700 Subject: [PATCH 01/16] view: re-apply criteria when window gets unmapped Remove any existing executed criteria items at unmap time. If a window gets unmapped but not destroyed, we want to reapply 'for_window' criteria. Fixes #6905. --- sway/tree/view.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sway/tree/view.c b/sway/tree/view.c index a9035de7e..00dc47215 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -882,6 +882,8 @@ void view_unmap(struct sway_view *view) { wl_list_remove(&view->surface_new_subsurface.link); + view->executed_criteria->length = 0; + if (view->urgent_timer) { wl_event_source_remove(view->urgent_timer); view->urgent_timer = NULL; From 5bdd6085148d8eddf0ae8f9a25ec32eb5bfd48ad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 5 Oct 2023 10:41:15 +0200 Subject: [PATCH 02/16] Apply gamma LUT when an output re-enabled References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3679 --- sway/desktop/output.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index f2bc4a678..53730073f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -964,6 +964,11 @@ static void handle_commit(struct wl_listener *listener, void *data) { wlr_damage_ring_set_bounds(&output->damage_ring, width, height); wlr_output_schedule_frame(output->wlr_output); } + + // Next time the output is enabled, try to re-apply the gamma LUT + if ((event->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { + output->gamma_lut_changed = true; + } } static void handle_present(struct wl_listener *listener, void *data) { From 072fa60cb401acb2e257a03baf41c8ae63f4753d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 22 Jun 2023 17:06:10 +0200 Subject: [PATCH 03/16] Add support for security-context-v1 As a first step, deny access to privileged protocols to sandboxed apps. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3589 --- include/sway/server.h | 4 ++++ sway/server.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/include/sway/server.h b/include/sway/server.h index 108561e65..be5c8d72c 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -114,6 +114,10 @@ struct sway_server { struct wlr_text_input_manager_v3 *text_input; struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; struct wlr_content_type_manager_v1 *content_type_manager_v1; + struct wlr_data_control_manager_v1 *data_control_manager_v1; + struct wlr_screencopy_manager_v1 *screencopy_manager_v1; + struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1; + struct wlr_security_context_manager_v1 *security_context_manager_v1; struct wlr_xdg_activation_v1 *xdg_activation_v1; struct wl_listener xdg_activation_v1_request_activate; diff --git a/sway/server.c b/sway/server.c index fd0ab585e..217c9ac94 100644 --- a/sway/server.c +++ b/sway/server.c @@ -24,8 +24,9 @@ #include #include #include -#include +#include #include +#include #include #include #include @@ -73,6 +74,25 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) { } #endif +static bool is_privileged(const struct wl_global *global) { + return + global == server.output_manager_v1->global || + global == server.output_power_manager_v1->global || + global == server.input_method->global || + global == server.foreign_toplevel_manager->global || + global == server.data_control_manager_v1->global || + global == server.screencopy_manager_v1->global || + global == server.export_dmabuf_manager_v1->global || + global == server.security_context_manager_v1->global || + global == server.gamma_control_manager_v1->global || + global == server.layer_shell->global || + global == server.session_lock.manager->global || + global == server.input->inhibit->global || + global == server.input->keyboard_shortcuts_inhibit->global || + global == server.input->virtual_keyboard->global || + global == server.input->virtual_pointer->global; +} + static bool filter_global(const struct wl_client *client, const struct wl_global *global, void *data) { #if HAVE_XWAYLAND @@ -82,6 +102,15 @@ static bool filter_global(const struct wl_client *client, } #endif + // Restrict usage of privileged protocols to unsandboxed clients + // TODO: add a way for users to configure an allow-list + const struct wlr_security_context_v1_state *security_context = + wlr_security_context_manager_v1_lookup_client( + server.security_context_manager_v1, (struct wl_client *)client); + if (is_privileged(global)) { + return security_context == NULL; + } + return true; } @@ -226,9 +255,10 @@ bool server_init(struct sway_server *server) { } #endif - wlr_export_dmabuf_manager_v1_create(server->wl_display); - wlr_screencopy_manager_v1_create(server->wl_display); - wlr_data_control_manager_v1_create(server->wl_display); + server->export_dmabuf_manager_v1 = wlr_export_dmabuf_manager_v1_create(server->wl_display); + server->screencopy_manager_v1 = wlr_screencopy_manager_v1_create(server->wl_display); + server->data_control_manager_v1 = wlr_data_control_manager_v1_create(server->wl_display); + server->security_context_manager_v1 = wlr_security_context_manager_v1_create(server->wl_display); wlr_viewporter_create(server->wl_display); wlr_single_pixel_buffer_manager_v1_create(server->wl_display); server->content_type_manager_v1 = From 9d666a08e1ec77680890a08f63e71ce6bb53b9a9 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 21 Nov 2023 16:52:19 +0100 Subject: [PATCH 04/16] Fix reference to wlr_output_event_commit.committed This has been dropped from wlroots. Previous commit missed that. --- 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 53730073f..e02ab32d0 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -966,7 +966,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { } // Next time the output is enabled, try to re-apply the gamma LUT - if ((event->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { + if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { output->gamma_lut_changed = true; } } From bff991dfdc63ca3785a810ff4d913ddfd71677a1 Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Mon, 23 Oct 2023 18:49:50 -0700 Subject: [PATCH 05/16] Use locale time format for default bar command --- config.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.in b/config.in index 48ba1f1e4..a5173165b 100644 --- a/config.in +++ b/config.in @@ -205,7 +205,7 @@ bar { # When the status_command prints a new line to stdout, swaybar updates. # The default just shows the current date and time. - status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done + status_command while date +'%Y-%m-%d %X'; do sleep 1; done colors { statusline #ffffff From 4ad15a4015feef2ecfba311c13e64e3976cc611c Mon Sep 17 00:00:00 2001 From: llyyr Date: Tue, 21 Nov 2023 23:55:19 +0530 Subject: [PATCH 06/16] meson: bump wlroots version after 0.17.0 release --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index eeee39cde..adf49c196 100644 --- a/meson.build +++ b/meson.build @@ -37,7 +37,7 @@ if is_freebsd endif # Execute the wlroots subproject, if any -wlroots_version = ['>=0.17.0', '<0.18.0'] +wlroots_version = ['>=0.18.0', '<0.19.0'] subproject( 'wlroots', default_options: ['examples=false'], From a946b1aecfa3f32a3bfae66d66df0bdf77440d69 Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 22 Nov 2023 00:05:03 +0530 Subject: [PATCH 07/16] Chase wlroots!4440 References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4440 --- include/sway/input/input-manager.h | 2 - protocols/meson.build | 1 - protocols/wlr-input-inhibitor-unstable-v1.xml | 67 ------------------- sway/input/input-manager.c | 37 ---------- sway/server.c | 1 - 5 files changed, 108 deletions(-) delete mode 100644 protocols/wlr-input-inhibitor-unstable-v1.xml diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 4bd517093..145edd4b6 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -1,7 +1,6 @@ #ifndef _SWAY_INPUT_INPUT_MANAGER_H #define _SWAY_INPUT_INPUT_MANAGER_H #include -#include #include #include #include @@ -21,7 +20,6 @@ struct sway_input_manager { struct wl_list devices; struct wl_list seats; - struct wlr_input_inhibit_manager *inhibit; struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit; struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_virtual_pointer_manager_v1 *virtual_pointer; diff --git a/protocols/meson.build b/protocols/meson.build index 2992ac585..81edb5841 100644 --- a/protocols/meson.build +++ b/protocols/meson.build @@ -16,7 +16,6 @@ protocols = [ wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', 'wlr-layer-shell-unstable-v1.xml', 'idle.xml', - 'wlr-input-inhibitor-unstable-v1.xml', 'wlr-output-power-management-unstable-v1.xml', ] diff --git a/protocols/wlr-input-inhibitor-unstable-v1.xml b/protocols/wlr-input-inhibitor-unstable-v1.xml deleted file mode 100644 index b62d1bb44..000000000 --- a/protocols/wlr-input-inhibitor-unstable-v1.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - Copyright © 2018 Drew DeVault - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that copyright notice and this permission - notice appear in supporting documentation, and that the name of - the copyright holders not be used in advertising or publicity - pertaining to distribution of the software without specific, - written prior permission. The copyright holders make no - representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied - warranty. - - THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY - SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - THIS SOFTWARE. - - - - - Clients can use this interface to prevent input events from being sent to - any surfaces but its own, which is useful for example in lock screen - software. It is assumed that access to this interface will be locked down - to whitelisted clients by the compositor. - - - - - Activates the input inhibitor. As long as the inhibitor is active, the - compositor will not send input events to other clients. - - - - - - - - - - - - While this resource exists, input to clients other than the owner of the - inhibitor resource will not receive input events. The client that owns - this resource will receive all input events normally. The compositor will - also disable all of its own input processing (such as keyboard shortcuts) - while the inhibitor is active. - - The compositor may continue to send input events to selected clients, - such as an on-screen keyboard (via the input-method protocol). - - - - - Destroy the inhibitor and allow other clients to receive input. - - - - diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index dcaeb056e..4febc3334 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include "sway/config.h" @@ -284,34 +283,6 @@ static void handle_new_input(struct wl_listener *listener, void *data) { } } -static void handle_inhibit_activate(struct wl_listener *listener, void *data) { - struct sway_input_manager *input_manager = wl_container_of( - listener, input_manager, inhibit_activate); - struct sway_seat *seat; - wl_list_for_each(seat, &input_manager->seats, link) { - seat_set_exclusive_client(seat, input_manager->inhibit->active_client); - } -} - -static void handle_inhibit_deactivate(struct wl_listener *listener, void *data) { - struct sway_input_manager *input_manager = wl_container_of( - listener, input_manager, inhibit_deactivate); - struct sway_seat *seat; - if (server.session_lock.locked) { - // Don't deactivate the grab of a screenlocker - return; - } - wl_list_for_each(seat, &input_manager->seats, link) { - seat_set_exclusive_client(seat, NULL); - struct sway_node *previous = seat_get_focus(seat); - if (previous) { - // Hack to get seat to re-focus the return value of get_focus - seat_set_focus(seat, NULL); - seat_set_focus(seat, previous); - } - } -} - static void handle_keyboard_shortcuts_inhibitor_destroy( struct wl_listener *listener, void *data) { struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = @@ -480,14 +451,6 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) { &input->virtual_pointer_new); input->virtual_pointer_new.notify = handle_virtual_pointer; - input->inhibit = wlr_input_inhibit_manager_create(server->wl_display); - input->inhibit_activate.notify = handle_inhibit_activate; - wl_signal_add(&input->inhibit->events.activate, - &input->inhibit_activate); - input->inhibit_deactivate.notify = handle_inhibit_deactivate; - wl_signal_add(&input->inhibit->events.deactivate, - &input->inhibit_deactivate); - input->keyboard_shortcuts_inhibit = wlr_keyboard_shortcuts_inhibit_v1_create(server->wl_display); input->keyboard_shortcuts_inhibit_new_inhibitor.notify = diff --git a/sway/server.c b/sway/server.c index 217c9ac94..de70e0abc 100644 --- a/sway/server.c +++ b/sway/server.c @@ -87,7 +87,6 @@ static bool is_privileged(const struct wl_global *global) { global == server.gamma_control_manager_v1->global || global == server.layer_shell->global || global == server.session_lock.manager->global || - global == server.input->inhibit->global || global == server.input->keyboard_shortcuts_inhibit->global || global == server.input->virtual_keyboard->global || global == server.input->virtual_pointer->global; From fd6d6f1d97deea2fc94aaeb58c85c99a498d905b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 23 Nov 2023 13:08:09 +0100 Subject: [PATCH 08/16] Add wlr/util/transform.h includes References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4097 Closes: https://github.com/swaywm/sway/issues/7830 --- sway/commands/output/transform.c | 1 + sway/desktop/output.c | 1 + sway/desktop/render.c | 1 + sway/tree/root.c | 1 + 4 files changed, 4 insertions(+) diff --git a/sway/commands/output/transform.c b/sway/commands/output/transform.c index f4fcc8c99..8db71bb30 100644 --- a/sway/commands/output/transform.c +++ b/sway/commands/output/transform.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/config.h" #include "log.h" diff --git a/sway/desktop/output.c b/sway/desktop/output.c index e02ab32d0..d9328701c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "config.h" #include "log.h" #include "sway/config.h" diff --git a/sway/desktop/render.c b/sway/desktop/render.c index c4c0004e7..9cfdea842 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "log.h" #include "config.h" #include "sway/config.h" diff --git a/sway/tree/root.c b/sway/tree/root.c index 831c75a58..66008d30d 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "sway/desktop/transaction.h" #include "sway/input/seat.h" #include "sway/ipc-server.h" From 128b6253a924c30e8e4fd1f09ce19e21a826c5ad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 23 Nov 2023 13:08:53 +0100 Subject: [PATCH 09/16] Pass wl_display to wlr_output_layout References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4310 --- include/sway/tree/root.h | 2 +- sway/main.c | 2 -- sway/server.c | 2 ++ sway/tree/root.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index a2c088e76..b3dda12f9 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h @@ -41,7 +41,7 @@ struct sway_root { } events; }; -struct sway_root *root_create(void); +struct sway_root *root_create(struct wl_display *display); void root_destroy(struct sway_root *root); diff --git a/sway/main.c b/sway/main.c index 85bc2f1c9..23689757e 100644 --- a/sway/main.c +++ b/sway/main.c @@ -375,8 +375,6 @@ int main(int argc, char **argv) { sway_log(SWAY_INFO, "Starting sway version " SWAY_VERSION); - root = root_create(); - if (!server_init(&server)) { return 1; } diff --git a/sway/server.c b/sway/server.c index de70e0abc..e4f8a7c8c 100644 --- a/sway/server.c +++ b/sway/server.c @@ -120,6 +120,8 @@ bool server_init(struct sway_server *server) { wl_display_set_global_filter(server->wl_display, filter_global, NULL); + root = root_create(server->wl_display); + server->backend = wlr_backend_autocreate(server->wl_display, &server->session); if (!server->backend) { sway_log(SWAY_ERROR, "Unable to create backend"); diff --git a/sway/tree/root.c b/sway/tree/root.c index 66008d30d..478df00cb 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -24,14 +24,14 @@ static void output_layout_handle_change(struct wl_listener *listener, transaction_commit_dirty(); } -struct sway_root *root_create(void) { +struct sway_root *root_create(struct wl_display *wl_display) { struct sway_root *root = calloc(1, sizeof(struct sway_root)); if (!root) { sway_log(SWAY_ERROR, "Unable to allocate sway_root"); return NULL; } node_init(&root->node, N_ROOT, root); - root->output_layout = wlr_output_layout_create(); + root->output_layout = wlr_output_layout_create(wl_display); wl_list_init(&root->all_outputs); #if HAVE_XWAYLAND wl_list_init(&root->xwayland_unmanaged); From 47e6a1164c25b5b49bfb919a681b88641d2ce37c Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Tue, 11 Jul 2023 15:09:14 +0300 Subject: [PATCH 10/16] xdg-shell: chase events update --- include/sway/server.h | 4 +- include/sway/tree/view.h | 1 + include/sway/xdg_decoration.h | 2 + sway/desktop/layer_shell.c | 65 +++++++++++++------------- sway/desktop/xdg_shell.c | 87 ++++++++++++++++++++--------------- sway/server.c | 6 +-- sway/xdg_decoration.c | 77 ++++++++++++++++--------------- 7 files changed, 133 insertions(+), 109 deletions(-) diff --git a/include/sway/server.h b/include/sway/server.h index be5c8d72c..1b3166cec 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -59,7 +59,7 @@ struct sway_server { struct wl_listener layer_shell_surface; struct wlr_xdg_shell *xdg_shell; - struct wl_listener xdg_shell_surface; + struct wl_listener xdg_shell_toplevel; struct wlr_tablet_manager_v2 *tablet_v2; @@ -176,7 +176,7 @@ void handle_new_output(struct wl_listener *listener, void *data); void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); void handle_layer_shell_surface(struct wl_listener *listener, void *data); void sway_session_lock_init(void); -void handle_xdg_shell_surface(struct wl_listener *listener, void *data); +void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data); #if HAVE_XWAYLAND void handle_xwayland_surface(struct wl_listener *listener, void *data); #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 960f9d71c..856651a52 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -226,6 +226,7 @@ struct sway_xdg_popup { struct wlr_xdg_popup *wlr_xdg_popup; + struct wl_listener surface_commit; struct wl_listener new_popup; struct wl_listener destroy; }; diff --git a/include/sway/xdg_decoration.h b/include/sway/xdg_decoration.h index 8bef4c6d4..2388ebcbb 100644 --- a/include/sway/xdg_decoration.h +++ b/include/sway/xdg_decoration.h @@ -16,4 +16,6 @@ struct sway_xdg_decoration { struct sway_xdg_decoration *xdg_decoration_from_surface( struct wlr_surface *surface); +void set_xdg_decoration_mode(struct sway_xdg_decoration *deco); + #endif diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 8c6cedfe9..979c44497 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -542,36 +542,6 @@ static void popup_damage(struct sway_layer_popup *layer_popup, bool whole) { output_damage_surface(output, ox, oy, surface, whole); } -static void popup_handle_map(struct wl_listener *listener, void *data) { - struct sway_layer_popup *popup = wl_container_of(listener, popup, map); - struct sway_layer_surface *layer = popup_get_layer(popup); - struct wlr_output *wlr_output = layer->layer_surface->output; - sway_assert(wlr_output, "wlr_layer_surface_v1 has null output"); - surface_enter_output(popup->wlr_popup->base->surface, wlr_output->data); - popup_damage(popup, true); -} - -static void popup_handle_unmap(struct wl_listener *listener, void *data) { - struct sway_layer_popup *popup = wl_container_of(listener, popup, unmap); - popup_damage(popup, true); -} - -static void popup_handle_commit(struct wl_listener *listener, void *data) { - struct sway_layer_popup *popup = wl_container_of(listener, popup, commit); - popup_damage(popup, false); -} - -static void popup_handle_destroy(struct wl_listener *listener, void *data) { - struct sway_layer_popup *popup = - wl_container_of(listener, popup, destroy); - - wl_list_remove(&popup->map.link); - wl_list_remove(&popup->unmap.link); - wl_list_remove(&popup->destroy.link); - wl_list_remove(&popup->commit.link); - free(popup); -} - static void popup_unconstrain(struct sway_layer_popup *popup) { struct sway_layer_surface *layer = popup_get_layer(popup); struct wlr_xdg_popup *wlr_popup = popup->wlr_popup; @@ -592,6 +562,39 @@ static void popup_unconstrain(struct sway_layer_popup *popup) { wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); } +static void popup_handle_map(struct wl_listener *listener, void *data) { + struct sway_layer_popup *popup = wl_container_of(listener, popup, map); + struct sway_layer_surface *layer = popup_get_layer(popup); + struct wlr_output *wlr_output = layer->layer_surface->output; + sway_assert(wlr_output, "wlr_layer_surface_v1 has null output"); + surface_enter_output(popup->wlr_popup->base->surface, wlr_output->data); + popup_damage(popup, true); +} + +static void popup_handle_unmap(struct wl_listener *listener, void *data) { + struct sway_layer_popup *popup = wl_container_of(listener, popup, unmap); + popup_damage(popup, true); +} + +static void popup_handle_commit(struct wl_listener *listener, void *data) { + struct sway_layer_popup *popup = wl_container_of(listener, popup, commit); + if (popup->wlr_popup->base->initial_commit) { + popup_unconstrain(popup); + } + popup_damage(popup, false); +} + +static void popup_handle_destroy(struct wl_listener *listener, void *data) { + struct sway_layer_popup *popup = + wl_container_of(listener, popup, destroy); + + wl_list_remove(&popup->map.link); + wl_list_remove(&popup->unmap.link); + wl_list_remove(&popup->destroy.link); + wl_list_remove(&popup->commit.link); + free(popup); +} + static void popup_handle_new_popup(struct wl_listener *listener, void *data); static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup, @@ -617,8 +620,6 @@ static struct sway_layer_popup *create_popup(struct wlr_xdg_popup *wlr_popup, popup->new_popup.notify = popup_handle_new_popup; wl_signal_add(&wlr_popup->base->events.new_popup, &popup->new_popup); - popup_unconstrain(popup); - return popup; } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 4c59b42a2..63a0835bf 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -38,6 +38,7 @@ static void popup_destroy(struct sway_view_child *child) { return; } struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child; + wl_list_remove(&popup->surface_commit.link); wl_list_remove(&popup->new_popup.link); wl_list_remove(&popup->destroy.link); free(popup); @@ -51,18 +52,6 @@ static const struct sway_view_child_impl popup_impl = { static struct sway_xdg_popup *popup_create( struct wlr_xdg_popup *wlr_popup, struct sway_view *view); -static void popup_handle_new_popup(struct wl_listener *listener, void *data) { - struct sway_xdg_popup *popup = - wl_container_of(listener, popup, new_popup); - struct wlr_xdg_popup *wlr_popup = data; - popup_create(wlr_popup, popup->child.view); -} - -static void popup_handle_destroy(struct wl_listener *listener, void *data) { - struct sway_xdg_popup *popup = wl_container_of(listener, popup, destroy); - view_child_destroy(&popup->child); -} - static void popup_unconstrain(struct sway_xdg_popup *popup) { struct sway_view *view = popup->child.view; struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup; @@ -87,6 +76,25 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) { wlr_xdg_popup_unconstrain_from_box(wlr_popup, &output_toplevel_sx_box); } +static void popup_handle_surface_commit(struct wl_listener *listener, void *data) { + struct sway_xdg_popup *popup = wl_container_of(listener, popup, surface_commit); + if (popup->wlr_xdg_popup->base->initial_commit) { + popup_unconstrain(popup); + } +} + +static void popup_handle_new_popup(struct wl_listener *listener, void *data) { + struct sway_xdg_popup *popup = + wl_container_of(listener, popup, new_popup); + struct wlr_xdg_popup *wlr_popup = data; + popup_create(wlr_popup, popup->child.view); +} + +static void popup_handle_destroy(struct wl_listener *listener, void *data) { + struct sway_xdg_popup *popup = wl_container_of(listener, popup, destroy); + view_child_destroy(&popup->child); +} + static struct sway_xdg_popup *popup_create( struct wlr_xdg_popup *wlr_popup, struct sway_view *view) { struct wlr_xdg_surface *xdg_surface = wlr_popup->base; @@ -97,22 +105,21 @@ static struct sway_xdg_popup *popup_create( return NULL; } view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface); - popup->wlr_xdg_popup = xdg_surface->popup; + popup->wlr_xdg_popup = wlr_popup; + wl_signal_add(&xdg_surface->surface->events.commit, &popup->surface_commit); + 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(&xdg_surface->events.destroy, &popup->destroy); + wl_signal_add(&wlr_popup->events.destroy, &popup->destroy); popup->destroy.notify = popup_handle_destroy; wl_signal_add(&xdg_surface->surface->events.map, &popup->child.surface_map); wl_signal_add(&xdg_surface->surface->events.unmap, &popup->child.surface_unmap); - popup_unconstrain(popup); - return popup; } - static struct sway_xdg_shell_view *xdg_shell_view_from_view( struct sway_view *view) { if (!sway_assert(view->type == SWAY_VIEW_XDG_SHELL, @@ -286,6 +293,19 @@ static void handle_commit(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_toplevel->base; + if (xdg_surface->initial_commit) { + if (view->xdg_decoration != NULL) { + set_xdg_decoration_mode(view->xdg_decoration); + } + // XXX: https://github.com/swaywm/sway/issues/2176 + wlr_xdg_surface_schedule_configure(xdg_surface); + return; + } + + if (!xdg_surface->surface->mapped) { + return; + } + struct wlr_box new_geo; wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); bool new_size = new_geo.width != view->geometry.width || @@ -421,7 +441,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) { view_unmap(view); - wl_list_remove(&xdg_shell_view->commit.link); wl_list_remove(&xdg_shell_view->new_popup.link); wl_list_remove(&xdg_shell_view->request_maximize.link); wl_list_remove(&xdg_shell_view->request_fullscreen.link); @@ -464,10 +483,6 @@ static void handle_map(struct wl_listener *listener, void *data) { transaction_commit_dirty(); - xdg_shell_view->commit.notify = handle_commit; - wl_signal_add(&toplevel->base->surface->events.commit, - &xdg_shell_view->commit); - xdg_shell_view->new_popup.notify = handle_new_popup; wl_signal_add(&toplevel->base->events.new_popup, &xdg_shell_view->new_popup); @@ -507,6 +522,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&xdg_shell_view->destroy.link); wl_list_remove(&xdg_shell_view->map.link); wl_list_remove(&xdg_shell_view->unmap.link); + wl_list_remove(&xdg_shell_view->commit.link); view->wlr_xdg_toplevel = NULL; if (view->xdg_decoration) { view->xdg_decoration->view = NULL; @@ -519,17 +535,12 @@ struct sway_view *view_from_wlr_xdg_surface( return xdg_surface->data; } -void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { - struct wlr_xdg_surface *xdg_surface = data; - - if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) { - sway_log(SWAY_DEBUG, "New xdg_shell popup"); - return; - } +void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data) { + struct wlr_xdg_toplevel *xdg_toplevel = data; sway_log(SWAY_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'", - xdg_surface->toplevel->title, xdg_surface->toplevel->app_id); - wlr_xdg_surface_ping(xdg_surface); + xdg_toplevel->title, xdg_toplevel->app_id); + wlr_xdg_surface_ping(xdg_toplevel->base); struct sway_xdg_shell_view *xdg_shell_view = calloc(1, sizeof(struct sway_xdg_shell_view)); @@ -538,16 +549,20 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { } view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl); - xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel; + xdg_shell_view->view.wlr_xdg_toplevel = xdg_toplevel; xdg_shell_view->map.notify = handle_map; - wl_signal_add(&xdg_surface->surface->events.map, &xdg_shell_view->map); + wl_signal_add(&xdg_toplevel->base->surface->events.map, &xdg_shell_view->map); xdg_shell_view->unmap.notify = handle_unmap; - wl_signal_add(&xdg_surface->surface->events.unmap, &xdg_shell_view->unmap); + wl_signal_add(&xdg_toplevel->base->surface->events.unmap, &xdg_shell_view->unmap); + + xdg_shell_view->commit.notify = handle_commit; + wl_signal_add(&xdg_toplevel->base->surface->events.commit, + &xdg_shell_view->commit); xdg_shell_view->destroy.notify = handle_destroy; - wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy); + wl_signal_add(&xdg_toplevel->events.destroy, &xdg_shell_view->destroy); - xdg_surface->data = xdg_shell_view; + xdg_toplevel->base->data = xdg_shell_view; } diff --git a/sway/server.c b/sway/server.c index e4f8a7c8c..be5216217 100644 --- a/sway/server.c +++ b/sway/server.c @@ -185,9 +185,9 @@ bool server_init(struct sway_server *server) { server->xdg_shell = wlr_xdg_shell_create(server->wl_display, SWAY_XDG_SHELL_VERSION); - wl_signal_add(&server->xdg_shell->events.new_surface, - &server->xdg_shell_surface); - server->xdg_shell_surface.notify = handle_xdg_shell_surface; + wl_signal_add(&server->xdg_shell->events.new_toplevel, + &server->xdg_shell_toplevel); + server->xdg_shell_toplevel.notify = handle_xdg_shell_toplevel; server->tablet_v2 = wlr_tablet_v2_create(server->wl_display); diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index f7f5f5ed8..fa8c6279c 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c @@ -23,6 +23,45 @@ static void xdg_decoration_handle_request_mode(struct wl_listener *listener, void *data) { struct sway_xdg_decoration *deco = wl_container_of(listener, deco, request_mode); + set_xdg_decoration_mode(deco); +} + +void handle_xdg_decoration(struct wl_listener *listener, void *data) { + struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; + struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->toplevel->base->data; + + struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); + if (deco == NULL) { + return; + } + + deco->view = &xdg_shell_view->view; + deco->view->xdg_decoration = deco; + deco->wlr_xdg_decoration = wlr_deco; + + wl_signal_add(&wlr_deco->events.destroy, &deco->destroy); + deco->destroy.notify = xdg_decoration_handle_destroy; + + wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode); + deco->request_mode.notify = xdg_decoration_handle_request_mode; + + wl_list_insert(&server.xdg_decorations, &deco->link); + + set_xdg_decoration_mode(deco); +} + +struct sway_xdg_decoration *xdg_decoration_from_surface( + struct wlr_surface *surface) { + struct sway_xdg_decoration *deco; + wl_list_for_each(deco, &server.xdg_decorations, link) { + if (deco->wlr_xdg_decoration->toplevel->base->surface == surface) { + return deco; + } + } + return NULL; +} + +void set_xdg_decoration_mode(struct sway_xdg_decoration *deco) { struct sway_view *view = deco->view; enum wlr_xdg_toplevel_decoration_v1_mode mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; @@ -47,41 +86,7 @@ static void xdg_decoration_handle_request_mode(struct wl_listener *listener, mode = client_mode; } - wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, - mode); -} - -void handle_xdg_decoration(struct wl_listener *listener, void *data) { - struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data; - struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->toplevel->base->data; - - struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco)); - if (deco == NULL) { - return; + if (view->wlr_xdg_toplevel->base->initialized) { + wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, mode); } - - deco->view = &xdg_shell_view->view; - deco->view->xdg_decoration = deco; - deco->wlr_xdg_decoration = wlr_deco; - - wl_signal_add(&wlr_deco->events.destroy, &deco->destroy); - deco->destroy.notify = xdg_decoration_handle_destroy; - - wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode); - deco->request_mode.notify = xdg_decoration_handle_request_mode; - - wl_list_insert(&server.xdg_decorations, &deco->link); - - xdg_decoration_handle_request_mode(&deco->request_mode, wlr_deco); -} - -struct sway_xdg_decoration *xdg_decoration_from_surface( - struct wlr_surface *surface) { - struct sway_xdg_decoration *deco; - wl_list_for_each(deco, &server.xdg_decorations, link) { - if (deco->wlr_xdg_decoration->toplevel->base->surface == surface) { - return deco; - } - } - return NULL; } From 39b9c0d6baeda0609dfe248fc5b86fb65ff69c2c Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Thu, 23 Nov 2023 07:54:23 -0500 Subject: [PATCH 11/16] common: Drop unused render_background_image And the associated background_mode enum. --- common/background-image.c | 88 +------------------------------------- include/background-image.h | 15 +------ 2 files changed, 3 insertions(+), 100 deletions(-) diff --git a/common/background-image.c b/common/background-image.c index 994a08052..d94346c8b 100644 --- a/common/background-image.c +++ b/common/background-image.c @@ -1,29 +1,12 @@ #include #include "background-image.h" -#include "cairo_util.h" +#include "config.h" #include "log.h" + #if HAVE_GDK_PIXBUF #include #endif -enum background_mode parse_background_mode(const char *mode) { - if (strcmp(mode, "stretch") == 0) { - return BACKGROUND_MODE_STRETCH; - } else if (strcmp(mode, "fill") == 0) { - return BACKGROUND_MODE_FILL; - } else if (strcmp(mode, "fit") == 0) { - return BACKGROUND_MODE_FIT; - } else if (strcmp(mode, "center") == 0) { - return BACKGROUND_MODE_CENTER; - } else if (strcmp(mode, "tile") == 0) { - return BACKGROUND_MODE_TILE; - } else if (strcmp(mode, "solid_color") == 0) { - return BACKGROUND_MODE_SOLID_COLOR; - } - sway_log(SWAY_ERROR, "Unsupported background mode: %s", mode); - return BACKGROUND_MODE_INVALID; -} - #if HAVE_GDK_PIXBUF static cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf( const GdkPixbuf *gdkbuf) { @@ -151,70 +134,3 @@ cairo_surface_t *load_background_image(const char *path) { } return image; } - -void render_background_image(cairo_t *cairo, cairo_surface_t *image, - enum background_mode mode, int buffer_width, int buffer_height) { - double width = cairo_image_surface_get_width(image); - double height = cairo_image_surface_get_height(image); - - cairo_save(cairo); - switch (mode) { - case BACKGROUND_MODE_STRETCH: - cairo_scale(cairo, - (double)buffer_width / width, - (double)buffer_height / height); - cairo_set_source_surface(cairo, image, 0, 0); - break; - case BACKGROUND_MODE_FILL: { - double window_ratio = (double)buffer_width / buffer_height; - double bg_ratio = width / height; - - if (window_ratio > bg_ratio) { - double scale = (double)buffer_width / width; - cairo_scale(cairo, scale, scale); - cairo_set_source_surface(cairo, image, - 0, (double)buffer_height / 2 / scale - height / 2); - } else { - double scale = (double)buffer_height / height; - cairo_scale(cairo, scale, scale); - cairo_set_source_surface(cairo, image, - (double)buffer_width / 2 / scale - width / 2, 0); - } - break; - } - case BACKGROUND_MODE_FIT: { - double window_ratio = (double)buffer_width / buffer_height; - double bg_ratio = width / height; - - if (window_ratio > bg_ratio) { - double scale = (double)buffer_height / height; - cairo_scale(cairo, scale, scale); - cairo_set_source_surface(cairo, image, - (double)buffer_width / 2 / scale - width / 2, 0); - } else { - double scale = (double)buffer_width / width; - cairo_scale(cairo, scale, scale); - cairo_set_source_surface(cairo, image, - 0, (double)buffer_height / 2 / scale - height / 2); - } - break; - } - case BACKGROUND_MODE_CENTER: - cairo_set_source_surface(cairo, image, - (double)buffer_width / 2 - width / 2, - (double)buffer_height / 2 - height / 2); - break; - case BACKGROUND_MODE_TILE: { - cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image); - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); - cairo_set_source(cairo, pattern); - break; - } - case BACKGROUND_MODE_SOLID_COLOR: - case BACKGROUND_MODE_INVALID: - assert(0); - break; - } - cairo_paint(cairo); - cairo_restore(cairo); -} diff --git a/include/background-image.h b/include/background-image.h index a97ef3752..5ecd4c536 100644 --- a/include/background-image.h +++ b/include/background-image.h @@ -1,20 +1,7 @@ #ifndef _SWAY_BACKGROUND_IMAGE_H #define _SWAY_BACKGROUND_IMAGE_H -#include "cairo_util.h" +#include -enum background_mode { - BACKGROUND_MODE_STRETCH, - BACKGROUND_MODE_FILL, - BACKGROUND_MODE_FIT, - BACKGROUND_MODE_CENTER, - BACKGROUND_MODE_TILE, - BACKGROUND_MODE_SOLID_COLOR, - BACKGROUND_MODE_INVALID, -}; - -enum background_mode parse_background_mode(const char *mode); cairo_surface_t *load_background_image(const char *path); -void render_background_image(cairo_t *cairo, cairo_surface_t *image, - enum background_mode mode, int buffer_width, int buffer_height); #endif From 439122e887d8d90991a06cf4877d5dd19bb21692 Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Thu, 23 Nov 2023 08:01:48 -0500 Subject: [PATCH 12/16] common: rename load_background_image to load_image --- common/background-image.c | 2 +- include/background-image.h | 2 +- swaybar/tray/item.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/background-image.c b/common/background-image.c index d94346c8b..2df10dd27 100644 --- a/common/background-image.c +++ b/common/background-image.c @@ -104,7 +104,7 @@ static cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf( } #endif // HAVE_GDK_PIXBUF -cairo_surface_t *load_background_image(const char *path) { +cairo_surface_t *load_image(const char *path) { cairo_surface_t *image; #if HAVE_GDK_PIXBUF GError *err = NULL; diff --git a/include/background-image.h b/include/background-image.h index 5ecd4c536..67c27c844 100644 --- a/include/background-image.h +++ b/include/background-image.h @@ -2,6 +2,6 @@ #define _SWAY_BACKGROUND_IMAGE_H #include -cairo_surface_t *load_background_image(const char *path); +cairo_surface_t *load_image(const char *path); #endif diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index 1f18b8bb3..c7938a350 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -431,7 +431,7 @@ static void reload_sni(struct swaybar_sni *sni, char *icon_theme, list_free(icon_search_paths); if (icon_path) { cairo_surface_destroy(sni->icon); - sni->icon = load_background_image(icon_path); + sni->icon = load_image(icon_path); free(icon_path); return; } From e633fe0b4081f249e9708f95da972138c86838ca Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Thu, 23 Nov 2023 08:40:41 -0500 Subject: [PATCH 13/16] common: move load_image to swaybar swaynag, swaymsg, and sway do not use this function and are unlikely to in the future. --- common/meson.build | 2 -- include/{background-image.h => swaybar/image.h} | 4 ++-- common/background-image.c => swaybar/image.c | 2 +- swaybar/meson.build | 1 + swaybar/tray/item.c | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) rename include/{background-image.h => swaybar/image.h} (53%) rename common/background-image.c => swaybar/image.c (99%) diff --git a/common/meson.build b/common/meson.build index 3756075a9..c0ce1f681 100644 --- a/common/meson.build +++ b/common/meson.build @@ -1,7 +1,6 @@ lib_sway_common = static_library( 'sway-common', files( - 'background-image.c', 'cairo.c', 'gesture.c', 'ipc-client.c', @@ -14,7 +13,6 @@ lib_sway_common = static_library( ), dependencies: [ cairo, - gdk_pixbuf, pango, pangocairo, wayland_client.partial_dependency(compile_args: true) diff --git a/include/background-image.h b/include/swaybar/image.h similarity index 53% rename from include/background-image.h rename to include/swaybar/image.h index 67c27c844..53a210dd7 100644 --- a/include/background-image.h +++ b/include/swaybar/image.h @@ -1,5 +1,5 @@ -#ifndef _SWAY_BACKGROUND_IMAGE_H -#define _SWAY_BACKGROUND_IMAGE_H +#ifndef _SWAYBAR_IMAGE_H +#define _SWAYBAR_IMAGE_H #include cairo_surface_t *load_image(const char *path); diff --git a/common/background-image.c b/swaybar/image.c similarity index 99% rename from common/background-image.c rename to swaybar/image.c index 2df10dd27..ed24b9f99 100644 --- a/common/background-image.c +++ b/swaybar/image.c @@ -1,7 +1,7 @@ #include -#include "background-image.h" #include "config.h" #include "log.h" +#include "swaybar/image.h" #if HAVE_GDK_PIXBUF #include diff --git a/swaybar/meson.build b/swaybar/meson.build index e5f1811eb..34bbdeea9 100644 --- a/swaybar/meson.build +++ b/swaybar/meson.build @@ -26,6 +26,7 @@ executable( 'bar.c', 'config.c', 'i3bar.c', + 'image.c', 'input.c', 'ipc.c', 'main.c', diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index c7938a350..d5fe50b15 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -7,12 +7,12 @@ #include #include "swaybar/bar.h" #include "swaybar/config.h" +#include "swaybar/image.h" #include "swaybar/input.h" #include "swaybar/tray/host.h" #include "swaybar/tray/icon.h" #include "swaybar/tray/item.h" #include "swaybar/tray/tray.h" -#include "background-image.h" #include "cairo_util.h" #include "list.h" #include "log.h" From bc7d15d64da1d8b97d52928b8f9ce5688c8dbdd0 Mon Sep 17 00:00:00 2001 From: apreiml Date: Fri, 24 Nov 2023 09:54:43 +0100 Subject: [PATCH 14/16] Update README.de.md to match the EN one --- README.de.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.de.md b/README.de.md index e2a1e8781..68b411d95 100644 --- a/README.de.md +++ b/README.de.md @@ -2,13 +2,13 @@ Sway ist ein [i3](https://i3wm.org/)-kompatibler [Wayland](http://wayland.freedesktop.org/)-Compositor. Lies die [FAQ](https://github.com/swaywm/sway/wiki). Tritt dem [IRC Channel](https://web.libera.chat/gamja/?channels=#sway) bei (#sway on irc.libera.chat; Englisch). ## Signaturen -Jedes Release wird mit dem PGP-Schlüssel [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) signiert und auf GitHub veröffentlicht. +Jedes Release wird mit dem PGP-Schlüssel [E88F5E48](https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48) signiert und [auf GitHub](https://github.com/swaywm/sway/releases) veröffentlicht. ## Installation -### Mit der Paketverwaltung -Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Das Paket sollte "sway" heißen. Falls es kein solches Paket gibt, kannst du im [Wiki](https://github.com/swaywm/sway/wiki/Unsupported-packages) (englisch) nach mehr Informationen bezüglich deiner Distribution suchen. -Falls du sway für deine eigene Distribution als Paket bereitstellen möchtest, solltest du die Entwickler per IRC oder E-Mail (sir@cmpwn.com) kontaktieren. +### Über die Paketverwaltung + +Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Versuche einfach das Packet "sway" zu installieren. ### Quellcode selbst kompilieren @@ -23,8 +23,8 @@ sway benötigt die folgenden Pakete: * pango * cairo * gdk-pixbuf2 (Optional, wird für das Benachrichtigungsfeld (System Tray) benötigt) -* [scdoc](https://git.sr.ht/~sircmpwn/scdoc)\* (Optional, wird für die Dokumentation (Man Pages) benötigt) -* git\* +* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Optional, wird für die Dokumentation (Man Pages) benötigt)\* +* git (Optional: Versionsinfo)\* _\*Werden nur während des Kompilierens benötigt_ From 2cd73a33c26ea6510a2f50359b1c550cd9b4fead Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 28 Nov 2023 22:17:21 +0000 Subject: [PATCH 15/16] sway/config.c: use `memcpy()` for known buffer size `gcc-14` added a new warning around dangerous use of `strncpy()` withi known overflow: ../sway/config.c: In function 'do_var_replacement': ../sway/config.c:983:33: error: '__builtin___strncpy_chk' specified bound depends on the length of the source argument [-Werror=stringop-truncation] 983 | strncpy(newptr, var->value, vvlen); | ^ ../sway/config.c:971:45: note: length computed here 971 | int vvlen = strlen(var->value); | ^~~~~~~~~~~~~~~~~~ It's a bit fishy to rely on truncating behaviour of `strncpy()`. The change uses `memcpy()` as more explicit way to express copy of `vvlen` bytes. --- sway/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/config.c b/sway/config.c index 8c8c148d9..4b51dc73f 100644 --- a/sway/config.c +++ b/sway/config.c @@ -975,7 +975,7 @@ char *do_var_replacement(char *str) { int offset = find - str; strncpy(newptr, str, offset); newptr += offset; - strncpy(newptr, var->value, vvlen); + memcpy(newptr, var->value, vvlen); newptr += vvlen; strcpy(newptr, find + vnlen); free(str); From f12023b1a26e30b7c041551a4713ab81014d138d Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 30 Nov 2023 19:53:14 -0500 Subject: [PATCH 16/16] Don't destroy output layout on exit wlroots will destroy this object itself. --- sway/tree/root.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sway/tree/root.c b/sway/tree/root.c index 478df00cb..dc51c3beb 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -53,7 +53,6 @@ void root_destroy(struct sway_root *root) { list_free(root->scratchpad); list_free(root->non_desktop_outputs); list_free(root->outputs); - wlr_output_layout_destroy(root->output_layout); free(root); }