From d79ea9a0db11abbdad1e751326a06d6d48332f07 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Wed, 24 Mar 2021 00:49:13 +0100 Subject: [PATCH 01/42] view: subsurface NULL check in view_from_wlr_surface Necessary NULL checks had been added to xdg_shell and xwayland surfaces, but subsurfaces had been missed. --- sway/tree/view.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sway/tree/view.c b/sway/tree/view.c index 395b9fac2..c762fa228 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -1157,6 +1157,9 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { if (wlr_surface_is_subsurface(wlr_surface)) { struct wlr_subsurface *subsurface = wlr_subsurface_from_wlr_surface(wlr_surface); + if (subsurface == NULL) { + return NULL; + } return view_from_wlr_surface(subsurface->parent); } if (wlr_surface_is_layer_surface(wlr_surface)) { From a9563a37101e022d5e9c14f8244b1f8a109b4536 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 24 Mar 2021 09:47:39 +0100 Subject: [PATCH 02/42] build: update version to v1.6-rc2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 22cec4cfe..b7a29660e 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'sway', 'c', - version: '1.6-rc1', + version: '1.6-rc2', license: 'MIT', meson_version: '>=0.53.0', default_options: [ From 346f5a9d14e260405598fc530fb260c894db397f Mon Sep 17 00:00:00 2001 From: Ivan Fedotov <17356208+ivanfed0t0v@users.noreply.github.com> Date: Mon, 15 Mar 2021 19:06:46 +0300 Subject: [PATCH 03/42] Add toggle logic inside DPMS handler Logic that obtains current DPMS state is put inside the handler. sway_output from which the current DPMS state will be obtained is selected by the following logic: * For '-' and '--' the focused output is used; * For '*' error "Cannot apply toggle to all outputs" is reported; * For everything else all_output_by_name_or_id() is used. Fixes #5929. --- sway/commands/output/dpms.c | 25 ++++++++++++++++++++++++- sway/sway-output.5.scd | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c index 9d75a80e8..638c0aded 100644 --- a/sway/commands/output/dpms.c +++ b/sway/commands/output/dpms.c @@ -1,6 +1,8 @@ #include "sway/commands.h" #include "sway/config.h" +#include "sway/output.h" #include "util.h" +#include struct cmd_results *output_cmd_dpms(int argc, char **argv) { if (!config->handler_context.output_config) { @@ -10,7 +12,28 @@ struct cmd_results *output_cmd_dpms(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Missing dpms argument."); } - if (parse_boolean(argv[0], true)) { + enum config_dpms current_dpms = DPMS_ON; + + if (strcasecmp(argv[0], "toggle") == 0) { + + const char *oc_name = config->handler_context.output_config->name; + if (strcmp(oc_name, "*") == 0) { + return cmd_results_new(CMD_INVALID, + "Cannot apply toggle to all outputs."); + } + + struct sway_output *sway_output = all_output_by_name_or_id(oc_name); + if (!sway_output || !sway_output->wlr_output) { + return cmd_results_new(CMD_FAILURE, + "Cannot apply toggle to unknown output %s", oc_name); + } + + if (sway_output->enabled && !sway_output->wlr_output->enabled) { + current_dpms = DPMS_OFF; + } + } + + if (parse_boolean(argv[0], current_dpms == DPMS_ON)) { config->handler_context.output_config->dpms_state = DPMS_ON; } else { config->handler_context.output_config->dpms_state = DPMS_OFF; diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index 69f529fe3..7927a609e 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -112,7 +112,7 @@ must be separated by one space. For example: *output* toggle Toggle the specified output. -*output* dpms on|off +*output* dpms on|off|toggle Enables or disables the specified output via DPMS. To turn an output off (ie. blank the screen but keep workspaces as-is), one can set DPMS to off. From 1d62d6bfa09860d7a59640dcb20d5273a55401c4 Mon Sep 17 00:00:00 2001 From: columbarius Date: Thu, 25 Mar 2021 17:22:26 +0100 Subject: [PATCH 04/42] config: allow whitespaces in config path --- sway/config.c | 69 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/sway/config.c b/sway/config.c index 6e665434f..76b9ec084 100644 --- a/sway/config.c +++ b/sway/config.c @@ -338,35 +338,60 @@ static bool file_exists(const char *path) { return path && access(path, R_OK) != -1; } +static char *config_path(const char *prefix, const char *config_folder) { + if (!prefix || !prefix[0] || !config_folder || !config_folder[0]) { + return NULL; + } + + const char *filename = "config"; + + size_t size = 3 + strlen(prefix) + strlen(config_folder) + strlen(filename); + char *path = calloc(size, sizeof(char)); + snprintf(path, size, "%s/%s/%s", prefix, config_folder, filename); + return path; +} + static char *get_config_path(void) { - static const char *config_paths[] = { - "$HOME/.sway/config", - "$XDG_CONFIG_HOME/sway/config", - "$HOME/.i3/config", - "$XDG_CONFIG_HOME/i3/config", - SYSCONFDIR "/sway/config", - SYSCONFDIR "/i3/config", + char *path = NULL; + const char *home = getenv("HOME"); + size_t size_fallback = 1 + strlen(home) + strlen("/.config"); + char *config_home_fallback = calloc(size_fallback, sizeof(char)); + snprintf(config_home_fallback, size_fallback, "%s/.config", home); + + const char *config_home = getenv("XDG_CONFIG_HOME"); + if (config_home == NULL || config_home[0] == '\0') { + config_home = config_home_fallback; + } + + struct config_path { + const char *prefix; + const char *config_folder; }; - char *config_home = getenv("XDG_CONFIG_HOME"); - if (!config_home || !*config_home) { - config_paths[1] = "$HOME/.config/sway/config"; - config_paths[3] = "$HOME/.config/i3/config"; - } + struct config_path config_paths[] = { + { .prefix = home, .config_folder = ".sway"}, + { .prefix = config_home, .config_folder = "sway"}, + { .prefix = home, .config_folder = ".i3"}, + { .prefix = config_home, .config_folder = "i3"}, + { .prefix = SYSCONFDIR, .config_folder = "sway"}, + { .prefix = SYSCONFDIR, .config_folder = "i3"} + }; - for (size_t i = 0; i < sizeof(config_paths) / sizeof(char *); ++i) { - wordexp_t p; - if (wordexp(config_paths[i], &p, WRDE_UNDEF) == 0) { - char *path = strdup(p.we_wordv[0]); - wordfree(&p); - if (file_exists(path)) { - return path; - } - free(path); + size_t num_config_paths = sizeof(config_paths)/sizeof(config_paths[0]); + for (size_t i = 0; i < num_config_paths; i++) { + path = config_path(config_paths[i].prefix, config_paths[i].config_folder); + if (!path) { + continue; } + if (file_exists(path)) { + break; + } + free(path); + path = NULL; } - return NULL; + free(config_home_fallback); + return path; } static bool load_config(const char *path, struct sway_config *config, From 276a37a605867ceef136d2444182d8190463c74d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 30 Mar 2021 18:22:01 +0200 Subject: [PATCH 05/42] ci: add xcb-util-wm dependency for wlroots This is now a mandatory dependency for wlroots. --- .builds/alpine.yml | 1 + .builds/archlinux.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 1da8c0b8a..a2549df1b 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -16,6 +16,7 @@ packages: - wayland-dev - wayland-protocols - xcb-util-image-dev + - xcb-util-wm-dev - xwayland sources: - https://github.com/swaywm/sway diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index c0f70186c..e1a6bff7d 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -13,6 +13,7 @@ packages: - wayland - wayland-protocols - xcb-util-image + - xcb-util-wm - xorg-xwayland sources: - https://github.com/swaywm/sway From db0d63313dec8a3036d06ef9a69271bac6bfa531 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 30 Mar 2021 17:52:23 +0200 Subject: [PATCH 06/42] Remove advice about Firefox from issue template Firefox got a lot better. I think now would be a good time to remove the advice from the issue template. We can always add it back if we start getting invalid bug reports again. --- .github/ISSUE_TEMPLATE/bug_report.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index a3f74e617..a360c9b1c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,7 +8,6 @@ labels: 'bug' ### Please read the following before submitting: - Please do NOT submit bug reports for questions. Ask questions on IRC at #sway on irc.freenode.net. - Proprietary graphics drivers, including nvidia, are not supported. Please use the open source equivalents, such as nouveau, if you would like to use Sway. -- Problems with the Wayland version of Firefox are likely to be Firefox bugs. Start by submitting your issue to the Firefox Bugzilla and come back here only after they confirm otherwise. - Please do NOT submit issues for information from the github wiki. The github wiki is community maintained and therefore may contain outdated information, scripts that don't work or obsolete workarounds. If you fix a script or find outdated information, don't hesitate to adjust the wiki page. From 62fbf33ce2a39373a5d122a99c04cc61272f122a Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Thu, 1 Apr 2021 02:52:31 -0700 Subject: [PATCH 07/42] output: damage whole output when exiting scanout --- sway/desktop/output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index cf4a96072..6d4f53423 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -553,6 +553,7 @@ static int output_repaint_timer_handler(void *data) { if (last_scanned_out && !scanned_out) { sway_log(SWAY_DEBUG, "Stopping fullscreen view scan out on %s", output->wlr_output->name); + output_damage_whole(output); } last_scanned_out = scanned_out; From 4402507b7bfe8f036973b715355202c284ba9535 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 3 Apr 2021 14:24:53 +0200 Subject: [PATCH 08/42] readme: make it clearer that meson takes a dir as argument "build" can easily be misinterpreted as a Meson subcommand. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4698afbe0..dc4210f3e 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ _\*Compile-time dep_ Run these commands: - meson build - ninja -C build - sudo ninja -C build install + meson build/ + ninja -C build/ + sudo ninja -C build/ install On systems without logind, you need to suid the sway binary: From 6e34aac2f19607d106cbd024dedf11fa7a5c0b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Donk=C3=B3?= Date: Sat, 3 Apr 2021 14:26:53 +0200 Subject: [PATCH 09/42] Add Hungarian translation for the README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tamás Táncos --- README.hu.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 README.hu.md diff --git a/README.hu.md b/README.hu.md new file mode 100644 index 000000000..0ca1a666f --- /dev/null +++ b/README.hu.md @@ -0,0 +1,77 @@ +# sway + +A Sway egy [i3]-kompatibilis [Wayland] kompozitor. Olvasd el a [Gyarkan Ismételt Kérdéseket][FAQ]. Csatlakozz az [IRC csatornához][IRC channel] \(`#sway` az `irc.freenode.net`-en). + +## Csomag aláírások + +A kiadott csomagok az [E88F5E48] kulccsal vannak aláírva és [GitHub-on][GitHub releases] publikálva. + +## Telepítés + +### Csomagból + +A Sway sok disztribúció csomagkezelőjéből elérhető, próbáld meg a "sway" +csomagot telepíteni az általad használt eszközzel. + +Ha szeretnél csomagot készíteni a saját disztribúciódhoz, ugorj be az IRC +csatornára, vagy küldj levelet a sir@cmpwn.com címre tanácsokért. + +### Fordítás forráskódból + +Olvasd el [ezt a wiki oldalt][Development setup], ha szeretnéd tesztelési vagy +fejlesztési célokból lefordítani az aktuális (HEAD) állapotát a `sway`-nek és a +`wlroots`-nak. + +Telepítsd a függőségeket: + +* meson \* +* [wlroots] +* wayland +* wayland-protocols \* +* pcre +* json-c +* pango +* cairo +* gdk-pixbuf2 (opcionális: system tray) +* [scdoc] (opcionális: man pages) \* +* git (opcionális: version info) \* + +_\*Fordításidejű függőség_ + +Futtasd ezeket a parancsokat: + + meson build + ninja -C build + sudo ninja -C build install + +Ha `logind` nélküli rendszert használsz, akkor be kell állítanod a `suid` bitet +a futtaható állományon: + + sudo chmod a+s /usr/local/bin/sway + +A Sway indulás után nem sokkal el fogja engedni a root jogosultságait. + +## Konfiguráció + +Ha előzőleg i3-mat használtál, akkor átmásolhatod az i3 beállításaidat a +`~/.config/sway/config` file-ba és ugyanúgy működni fognak. Egyéb esetben másold +le kiindulási alapnak a mintát, ami általában az `etc/sway/config` elérési +útvonalon található. +Futtasd a `man 5 sway` parancsot további információért a konfigurációval +kapcsolatban. + +## Futtatás + +Futtasd a `sway` parancsot egy TTY felületről. Néhány bejelentkezéskezelő +(display manager) működhet, de alapvetően nem támogatottak a sway által. (A +gdm-ről ismeretes, hogy egész jól működik.) + +[i3]: https://i3wm.org/ +[Wayland]: http://wayland.freedesktop.org/ +[FAQ]: https://github.com/swaywm/sway/wiki +[IRC channel]: http://webchat.freenode.net/?channels=sway&uio=d4 +[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48 +[GitHub releases]: https://github.com/swaywm/sway/releases +[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup +[wlroots]: https://github.com/swaywm/wlroots +[scdoc]: https://git.sr.ht/~sircmpwn/scdoc diff --git a/README.md b/README.md index dc4210f3e..d9aa06089 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # sway -**[English][en]** - [日本語][ja] - [Français][fr] - [Українська][uk] - [Español][es] - [Polski][pl] - [中文-简体][zh-CN] - [Deutsch][de] - [Nederlands][nl] - [Русский][ru] - [中文-繁體][zh-TW] - [Português][pt] - [Danish][dk] - [한국어][ko] - [Română][ro] +**[English][en]** - [日本語][ja] - [Français][fr] - [Українська][uk] - [Español][es] - [Polski][pl] - [中文-简体][zh-CN] - [Deutsch][de] - [Nederlands][nl] - [Русский][ru] - [中文-繁體][zh-TW] - [Português][pt] - [Danish][dk] - [한국어][ko] - [Română][ro] - [Magyar][hu] sway is an [i3]-compatible [Wayland] compositor. Read the [FAQ]. Join the [IRC channel] \(#sway on irc.freenode.net). @@ -79,6 +79,7 @@ sway (gdm is known to work fairly well). [dk]: https://github.com/swaywm/sway/blob/master/README.dk.md [ko]: https://github.com/swaywm/sway/blob/master/README.ko.md [ro]: https://github.com/swaywm/sway/blob/master/README.ro.md +[hu]: https://github.com/swaywm/sway/blob/master/README.hu.md [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ [FAQ]: https://github.com/swaywm/sway/wiki From 8cd014cab756e06f8553169900a9c54ca38e005b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 7 Apr 2021 21:44:21 +0200 Subject: [PATCH 10/42] build: bump version to 1.6 --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index b7a29660e..e179552b4 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'sway', 'c', - version: '1.6-rc2', + version: '1.6', license: 'MIT', meson_version: '>=0.53.0', default_options: [ @@ -61,7 +61,7 @@ math = cc.find_library('m') rt = cc.find_library('rt') # Try first to find wlroots as a subproject, then as a system dependency -wlroots_version = ['>=0.12.0', '<0.13.0'] +wlroots_version = ['>=0.13.0', '<0.14.0'] wlroots_proj = subproject( 'wlroots', default_options: ['examples=false'], From 7a68a28475bfefd65d618b053b566e0877abcc75 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 8 Apr 2021 08:54:38 +0200 Subject: [PATCH 11/42] build: update wlroots dependency version to 0.14.x The latest commit of Sway always requires the latest commit of wlroots. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e179552b4..d2c8d3adf 100644 --- a/meson.build +++ b/meson.build @@ -61,7 +61,7 @@ math = cc.find_library('m') rt = cc.find_library('rt') # Try first to find wlroots as a subproject, then as a system dependency -wlroots_version = ['>=0.13.0', '<0.14.0'] +wlroots_version = ['>=0.14.0', '<0.15.0'] wlroots_proj = subproject( 'wlroots', default_options: ['examples=false'], From 61df9eb62a6610361d42a7d5552cdddb3063db8a Mon Sep 17 00:00:00 2001 From: Aljaz Gantar Date: Wed, 24 Mar 2021 00:21:18 +0100 Subject: [PATCH 12/42] fix type error when class_name none --- contrib/autoname-workspaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/autoname-workspaces.py b/contrib/autoname-workspaces.py index 297d91b2a..2b634eee9 100755 --- a/contrib/autoname-workspaces.py +++ b/contrib/autoname-workspaces.py @@ -31,7 +31,7 @@ def icon_for_window(window): else: # xwayland support class_name = window.window_class - if len(class_name) > 0: + if class_name is not None and len(class_name) > 0: class_name = class_name.lower() if class_name in WINDOW_ICONS: return WINDOW_ICONS[class_name] From 1a0f86be4eb23b76ab8384db0b61879ab51d5096 Mon Sep 17 00:00:00 2001 From: Aljaz Gantar Date: Wed, 31 Mar 2021 13:47:36 +0200 Subject: [PATCH 13/42] refactor icon_for_window function --- contrib/autoname-workspaces.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/contrib/autoname-workspaces.py b/contrib/autoname-workspaces.py index 2b634eee9..3ec399280 100755 --- a/contrib/autoname-workspaces.py +++ b/contrib/autoname-workspaces.py @@ -22,24 +22,17 @@ DEFAULT_ICON = "󰀏" def icon_for_window(window): - app_id = window.app_id - if app_id is not None and len(app_id) > 0: - app_id = app_id.lower() - if app_id in WINDOW_ICONS: - return WINDOW_ICONS[app_id] - logging.info("No icon available for window with app_id: %s" % str(app_id)) - else: - # xwayland support - class_name = window.window_class - if class_name is not None and len(class_name) > 0: - class_name = class_name.lower() - if class_name in WINDOW_ICONS: - return WINDOW_ICONS[class_name] - logging.info( - "No icon available for window with class_name: %s" % str(class_name) - ) - return DEFAULT_ICON + name = None + if window.app_id is not None and len(window.app_id) > 0: + name = window.app_id.lower() + elif window.window_class is not None and len(window.window_class) > 0: + name = window.window_class.lower() + if name in WINDOW_ICONS: + return WINDOW_ICONS[name] + + logging.info("No icon available for window with name: %s" % str(name)) + return DEFAULT_ICON def rename_workspaces(ipc): for workspace in ipc.get_tree().workspaces(): @@ -128,3 +121,4 @@ if __name__ == "__main__": rename_workspaces(ipc) ipc.main() + From e49a98fcb3613d0505ce731ed6dc99b9f2c6fc8a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 11 Apr 2021 12:14:40 +0200 Subject: [PATCH 14/42] build: stop checking for logind wlroots has removed its logind session backend [1]. It now relies on libseat only. [1]: https://github.com/swaywm/wlroots/pull/2786 --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index d2c8d3adf..b0aa3200d 100644 --- a/meson.build +++ b/meson.build @@ -76,8 +76,6 @@ endif wlroots_features = { 'xwayland': false, - 'systemd': false, - 'elogind': false, 'libseat': false, } foreach name, _ : wlroots_features @@ -318,7 +316,7 @@ summary({ 'man-pages': scdoc.found(), }, bool_yn: true) -if not wlroots_features['systemd'] and not wlroots_features['elogind'] and not wlroots_features['libseat'] +if not wlroots_features['libseat'] warning('The sway binary must be setuid when compiled without (e)logind or libseat') warning('You must do this manually post-install: chmod a+s /path/to/sway') endif From 86b08e3257a4e3e204740f6252c5b1180ead8467 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 11 Apr 2021 12:15:51 +0200 Subject: [PATCH 15/42] desktop/render: remove unused wlr_gles2_texture_attribs We were calling wlr_gles2_texture_get_attribs, but we were never using the result. --- sway/desktop/render.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 466222240..56936d539 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -105,9 +105,6 @@ static void render_texture(struct wlr_output *wlr_output, wlr_backend_get_renderer(wlr_output->backend); struct sway_output *output = wlr_output->data; - struct wlr_gles2_texture_attribs attribs; - wlr_gles2_texture_get_attribs(texture, &attribs); - pixman_region32_t damage; pixman_region32_init(&damage); pixman_region32_union_rect(&damage, &damage, dst_box->x, dst_box->y, From 1a72049c04b8c6e1a30f80b3887fc7808a717935 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 11 Apr 2021 19:14:05 +0200 Subject: [PATCH 16/42] Remove WLR_HAS_XDG_FOREIGN checks References: https://github.com/swaywm/wlroots/pull/2833 --- sway/server.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sway/server.c b/sway/server.c index 278afd19d..418f33706 100644 --- a/sway/server.c +++ b/sway/server.c @@ -26,11 +26,9 @@ #include #include #include -#if WLR_HAS_XDG_FOREIGN #include #include #include -#endif #include #include "config.h" #include "list.h" @@ -156,12 +154,10 @@ bool server_init(struct sway_server *server) { wlr_primary_selection_v1_device_manager_create(server->wl_display); wlr_viewporter_create(server->wl_display); -#if WLR_HAS_XDG_FOREIGN struct wlr_xdg_foreign_registry *foreign_registry = wlr_xdg_foreign_registry_create(server->wl_display); wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry); wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry); -#endif // Avoid using "wayland-0" as display socket char name_candidate[16]; From a558866f42de74f7dc0500c3fe29bb506cf03cf6 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Sun, 11 Apr 2021 17:02:55 -0700 Subject: [PATCH 17/42] container: retain focus position on floating enable When a tiling container is floated, the focus stack needs to be appropraitely modified to return the container to its original position in the tree upon floating disable, like i3. --- sway/tree/container.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 68fbec2fd..67e69d9dc 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -821,6 +821,8 @@ void container_set_floating(struct sway_container *container, bool enable) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *workspace = container->pending.workspace; + struct sway_container *focus = seat_get_focused_container(seat); + bool set_focus = focus == container; if (enable) { struct sway_container *old_parent = container->pending.parent; @@ -835,6 +837,10 @@ void container_set_floating(struct sway_container *container, bool enable) { container_floating_set_default_size(container); container_floating_resize_and_center(container); if (old_parent) { + if (set_focus) { + seat_set_raw_focus(seat, &old_parent->node); + seat_set_raw_focus(seat, &container->node); + } container_reap_empty(old_parent); } } else { @@ -846,7 +852,11 @@ void container_set_floating(struct sway_container *container, bool enable) { struct sway_container *reference = seat_get_focus_inactive_tiling(seat, workspace); if (reference) { - container_add_sibling(reference, container, 1); + if (reference->view) { + container_add_sibling(reference, container, 1); + } else { + container_add_child(reference, container); + } container->pending.width = reference->pending.width; container->pending.height = reference->pending.height; } else { From 78fc9d0d2d4fae0565b115f5ee4b0296b4e993f2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 12 Apr 2021 09:47:16 +0200 Subject: [PATCH 18/42] Log wlroots version on startup Can be useful to make sure a bugfix is included. In the future maybe the wlroots version string could include a commit hash when built from source, too. --- sway/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sway/main.c b/sway/main.c index 84f8eb6e7..cd949e1e3 100644 --- a/sway/main.c +++ b/sway/main.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/server.h" @@ -344,6 +345,7 @@ int main(int argc, char **argv) { } sway_log(SWAY_INFO, "Sway version " SWAY_VERSION); + sway_log(SWAY_INFO, "wlroots version " WLR_VERSION_STR); log_kernel(); log_distro(); log_env(); From b40c6448e6492df5763b77204bdfa1b16936c9d3 Mon Sep 17 00:00:00 2001 From: Elyes HAOUAS Date: Mon, 12 Apr 2021 18:03:37 +0200 Subject: [PATCH 19/42] desktop/layer_shell.c: Fix misspelled "exclusive" Signed-off-by: Elyes HAOUAS --- sway/desktop/layer_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index c5b6d19ca..91e113a73 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -191,7 +191,7 @@ void arrange_layers(struct sway_output *output) { arrange_output(output); } - // Arrange non-exlusive surfaces from top->bottom + // Arrange non-exclusive surfaces from top->bottom arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &usable_area, false); arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], From 8106f01c176a61f2683b02672e29197b20b23fc2 Mon Sep 17 00:00:00 2001 From: fwsmit Date: Tue, 6 Apr 2021 10:24:11 +0200 Subject: [PATCH 20/42] desktop/layer_shell: fix centering for opposing anchors --- sway/desktop/layer_shell.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 91e113a73..197189910 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -115,9 +115,10 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list, // Horizontal axis const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; - if ((state->anchor & both_horiz) && box.width == 0) { + if (box.width == 0) { box.x = bounds.x; - box.width = bounds.width; + } else if ((state->anchor & both_horiz) == both_horiz) { + box.x = bounds.x + ((bounds.width / 2) - (box.width / 2)); } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) { box.x = bounds.x; } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { @@ -128,9 +129,10 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list, // Vertical axis const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; - if ((state->anchor & both_vert) && box.height == 0) { + if (box.height == 0) { box.y = bounds.y; - box.height = bounds.height; + } else if ((state->anchor & both_vert) == both_vert) { + box.y = bounds.y + ((bounds.height / 2) - (box.height / 2)); } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) { box.y = bounds.y; } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) { @@ -139,17 +141,23 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list, box.y = bounds.y + ((bounds.height / 2) - (box.height / 2)); } // Margin - if ((state->anchor & both_horiz) == both_horiz) { + if (box.width == 0) { box.x += state->margin.left; - box.width -= state->margin.left + state->margin.right; + box.width = bounds.width - + (state->margin.left + state->margin.right); + } else if ((state->anchor & both_horiz) == both_horiz) { + // don't apply margins } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) { box.x += state->margin.left; } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { box.x -= state->margin.right; } - if ((state->anchor & both_vert) == both_vert) { + if (box.height == 0) { box.y += state->margin.top; - box.height -= state->margin.top + state->margin.bottom; + box.height = bounds.height - + (state->margin.top + state->margin.bottom); + } else if ((state->anchor & both_vert) == both_vert) { + // don't apply margins } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) { box.y += state->margin.top; } else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) { From fcfe52de294f1998cdcf4e147bf34127c4b9dd40 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Wed, 14 Apr 2021 21:41:38 +0200 Subject: [PATCH 21/42] ci: Install libseat --- .builds/alpine.yml | 1 + .builds/archlinux.yml | 1 + .builds/freebsd.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index a2549df1b..855383196 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -6,6 +6,7 @@ packages: - json-c-dev - libevdev-dev - libinput-dev + - libseat-dev - libxcb-dev - libxkbcommon-dev - mesa-dev diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index e1a6bff7d..05ceef8de 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -15,6 +15,7 @@ packages: - xcb-util-image - xcb-util-wm - xorg-xwayland + - seatd sources: - https://github.com/swaywm/sway - https://github.com/swaywm/wlroots diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index 273badbcf..4698dbc7f 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -19,6 +19,7 @@ packages: - devel/libudev-devd - graphics/libdrm - graphics/mesa-libs +- sysutils/seatd - x11/libinput - x11/libX11 - x11/pixman From 4e77bc293515ea2f00ebbc4395cb0eb4446d0195 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Wed, 14 Apr 2021 21:42:26 +0200 Subject: [PATCH 22/42] meson: libseat is no longer optional See: https://github.com/swaywm/wlroots/pull/2839 --- meson.build | 5 ----- 1 file changed, 5 deletions(-) diff --git a/meson.build b/meson.build index b0aa3200d..d204f54a5 100644 --- a/meson.build +++ b/meson.build @@ -76,7 +76,6 @@ endif wlroots_features = { 'xwayland': false, - 'libseat': false, } foreach name, _ : wlroots_features var_name = 'have_' + name.underscorify() @@ -316,7 +315,3 @@ summary({ 'man-pages': scdoc.found(), }, bool_yn: true) -if not wlroots_features['libseat'] - warning('The sway binary must be setuid when compiled without (e)logind or libseat') - warning('You must do this manually post-install: chmod a+s /path/to/sway') -endif From eb9e77f4eae292da483191dcac18dbdfa50b984e Mon Sep 17 00:00:00 2001 From: ash lea Date: Fri, 2 Apr 2021 20:14:01 -0700 Subject: [PATCH 23/42] container: don't set fullscreen on children the original behavior set fullscreen for all descendents of a container, which causes issues when firefox is one of those children because it sends its own set_fullscreen request in response to being fullscreened. --- sway/tree/container.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 67e69d9dc..43fe6944d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1039,16 +1039,15 @@ void container_end_mouse_operation(struct sway_container *container) { } } -static void set_fullscreen_iterator(struct sway_container *con, void *data) { +static void set_fullscreen(struct sway_container *con, bool enable) { if (!con->view) { return; } if (con->view->impl->set_fullscreen) { - bool *enable = data; - con->view->impl->set_fullscreen(con->view, *enable); + con->view->impl->set_fullscreen(con->view, enable); if (con->view->foreign_toplevel) { wlr_foreign_toplevel_handle_v1_set_fullscreen( - con->view->foreign_toplevel, *enable); + con->view->foreign_toplevel, enable); } } } @@ -1058,9 +1057,7 @@ static void container_fullscreen_workspace(struct sway_container *con) { "Expected a non-fullscreen container")) { return; } - bool enable = true; - set_fullscreen_iterator(con, &enable); - container_for_each_child(con, set_fullscreen_iterator, &enable); + set_fullscreen(con, true); con->pending.fullscreen_mode = FULLSCREEN_WORKSPACE; con->saved_x = con->pending.x; @@ -1094,9 +1091,7 @@ static void container_fullscreen_global(struct sway_container *con) { "Expected a non-fullscreen container")) { return; } - bool enable = true; - set_fullscreen_iterator(con, &enable); - container_for_each_child(con, set_fullscreen_iterator, &enable); + set_fullscreen(con, true); root->fullscreen_global = con; con->saved_x = con->pending.x; @@ -1122,9 +1117,7 @@ void container_fullscreen_disable(struct sway_container *con) { "Expected a fullscreen container")) { return; } - bool enable = false; - set_fullscreen_iterator(con, &enable); - container_for_each_child(con, set_fullscreen_iterator, &enable); + set_fullscreen(con, false); if (container_is_floating(con)) { con->pending.x = con->saved_x; @@ -1388,10 +1381,6 @@ void container_add_child(struct sway_container *parent, child->pending.parent = parent; child->pending.workspace = parent->pending.workspace; container_for_each_child(child, set_workspace, NULL); - bool fullscreen = child->pending.fullscreen_mode != FULLSCREEN_NONE || - parent->pending.fullscreen_mode != FULLSCREEN_NONE; - set_fullscreen_iterator(child, &fullscreen); - container_for_each_child(child, set_fullscreen_iterator, &fullscreen); container_handle_fullscreen_reparent(child); container_update_representation(parent); node_set_dirty(&child->node); From ecfd687977ec210bf22f1a73852bee2df0af0709 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Thu, 15 Apr 2021 17:01:27 -0700 Subject: [PATCH 24/42] cmd_fullscreen: allow fullscreen on fullscreen split containers Using the fullscreen command on a child of a fullscreen split container will now fullscreen the child instead of unfullscreening the parent. --- sway/commands/fullscreen.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index a5d30d0e1..bc59201c2 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c @@ -33,15 +33,7 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { } } - bool is_fullscreen = false; - for (struct sway_container *curr = container; curr; curr = curr->pending.parent) { - if (curr->pending.fullscreen_mode != FULLSCREEN_NONE) { - container = curr; - is_fullscreen = true; - break; - } - } - + bool is_fullscreen = container->pending.fullscreen_mode != FULLSCREEN_NONE; bool global = false; bool enable = !is_fullscreen; From 730efbc89c40a534f5463b5d872ca856fe7cedc4 Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Sun, 18 Apr 2021 23:45:01 +0200 Subject: [PATCH 25/42] Prevent use-after-free on first bar subcommand error If any error is encountered during execution of the first subcommand of a freshly created bar configuration, parsing apparently is to be aborted and the current bar config is freed. The pointer to that memory is left dangling though, leading to a use-after-free on successive bar subcommands. This quite reliably ends in a crash like so: sway -c reproducer.config 00:00:00.083 [sway/config.c:865] Error on line 2 'foo bar': Unknown/invalid command 'foo' (s) free(): double free detected in tcache 2 00:00:00.608 [swaynag/swaynag.c:451] failed to register with the wayland display Aborted (core dumped) Minimal reproducer config: bar { foo bar position top } Other messages: malloc(): unaligned fastbin chunk detected double free or corruption (fasttop) The invalid command has to be the first for a newly created bar config. Removing the command or switching order so it's not the first one masks the problem. Prevent this from occuring by resetting the pointer to NULL after freeing the memory. Signed-off-by: Michael Weiser --- sway/commands/bar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/commands/bar.c b/sway/commands/bar.c index a58f5438a..8571d282c 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c @@ -116,6 +116,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) { if (res && res->status != CMD_SUCCESS) { if (id) { free_bar_config(config->current_bar); + config->current_bar = NULL; id = NULL; } return res; From 6327f1b36196d5b6e22be9c9f839f29d5f23f346 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 20 Apr 2021 17:21:05 +0200 Subject: [PATCH 26/42] Avoid creating zero-sized textures for titlebars Creating a zero-sized wlr_texture is incorrect. --- sway/tree/container.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/tree/container.c b/sway/tree/container.c index 43fe6944d..47772b62f 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -531,6 +531,10 @@ static void update_title_texture(struct sway_container *con, cairo_surface_destroy(dummy_surface); cairo_destroy(c); + if (width == 0 || height == 0) { + return; + } + cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); cairo_t *cairo = cairo_create(surface); From 3173a4f353f990e96a49e5a24f0d8cf57b21176c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 20 Apr 2021 17:26:39 +0200 Subject: [PATCH 27/42] Use cairo_image_surface_get_stride instead of guessing it --- sway/tree/container.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 47772b62f..438ff157a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -554,7 +554,7 @@ static void update_title_texture(struct sway_container *con, cairo_surface_flush(surface); unsigned char *data = cairo_image_surface_get_data(surface); - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); + int stride = cairo_image_surface_get_stride(surface); struct wlr_renderer *renderer = wlr_backend_get_renderer( output->wlr_output->backend); *texture = wlr_texture_from_pixels( @@ -1639,7 +1639,7 @@ static void update_marks_texture(struct sway_container *con, cairo_surface_flush(surface); unsigned char *data = cairo_image_surface_get_data(surface); - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); + int stride = cairo_image_surface_get_stride(surface); struct wlr_renderer *renderer = wlr_backend_get_renderer( output->wlr_output->backend); *texture = wlr_texture_from_pixels( From e3e99d961dc445258c08ec47b22ec83af38197f6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 20 Apr 2021 17:29:16 +0200 Subject: [PATCH 28/42] Avoid creating zero-sized textures for marks Same as 6327f1b36196 ("Avoid creating zero-sized textures for titlebars") but for marks. --- sway/tree/container.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/tree/container.c b/sway/tree/container.c index 438ff157a..bec17d95d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1623,6 +1623,10 @@ static void update_marks_texture(struct sway_container *con, "%s", buffer); cairo_destroy(c); + if (width == 0 || height == 0) { + return; + } + cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); cairo_t *cairo = cairo_create(surface); From 7beeb9e61b7f18a8c2e9aa015958cffde9b76c05 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 16 Apr 2021 10:31:30 +0200 Subject: [PATCH 29/42] Use execlp("sh") instead of execl("/bin/sh") This stops assuming the POSIX shell command is located in /bin. --- sway/commands/exec_always.c | 2 +- sway/swaynag.c | 4 ++-- swaynag/swaynag.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 39e48a446..3786bfb70 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -65,7 +65,7 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { close(fd[0]); if ((child = fork()) == 0) { close(fd[1]); - execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); + execlp("sh", "sh", "-c", cmd, (void *)NULL); _exit(0); } ssize_t s = 0; diff --git a/sway/swaynag.c b/sway/swaynag.c index db5a919a1..ba582989b 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -87,8 +87,8 @@ bool swaynag_spawn(const char *swaynag_command, size_t length = strlen(swaynag_command) + strlen(swaynag->args) + 2; char *cmd = malloc(length); snprintf(cmd, length, "%s %s", swaynag_command, swaynag->args); - execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); - sway_log_errno(SWAY_ERROR, "execl failed"); + execlp("sh", "sh", "-c", cmd, NULL); + sway_log_errno(SWAY_ERROR, "execlp failed"); _exit(EXIT_FAILURE); } _exit(EXIT_SUCCESS); diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 1d1dbee25..609e48318 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -30,8 +30,8 @@ static bool terminal_execute(char *terminal, char *command) { chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); sprintf(cmd, "%s -e %s", terminal, fname); - execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); - sway_log_errno(SWAY_ERROR, "Failed to run command, execl() returned."); + execlp("sh", "sh", "-c", cmd, NULL); + sway_log_errno(SWAY_ERROR, "Failed to run command, execlp() returned."); free(cmd); return false; } @@ -69,8 +69,8 @@ static void swaynag_button_execute(struct swaynag *swaynag, sway_log(SWAY_DEBUG, "$TERMINAL not found. Running directly"); } - execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); - sway_log_errno(SWAY_DEBUG, "execl failed"); + execlp("sh", "sh", "-c", button->action, NULL); + sway_log_errno(SWAY_DEBUG, "execlp failed"); _exit(EXIT_FAILURE); } } From 31a2252e83a39ae9be8f9572179fe161c54f715d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 16 Apr 2021 10:32:32 +0200 Subject: [PATCH 30/42] commands/exec_always: log error on execlp failure And exit(1) instead of indicating success. --- sway/commands/exec_always.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 3786bfb70..781c86c9d 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -66,7 +66,8 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { if ((child = fork()) == 0) { close(fd[1]); execlp("sh", "sh", "-c", cmd, (void *)NULL); - _exit(0); + sway_log_errno(SWAY_ERROR, "execlp failed"); + _exit(1); } ssize_t s = 0; while ((size_t)s < sizeof(pid_t)) { From 8529141150ef2d9a07b9c0fad193bdbc12d3ad42 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sun, 18 Apr 2021 09:11:59 +0900 Subject: [PATCH 31/42] view_destroy: fix use-after-free with subsurface_destroy remove view from its own unmap event listener so when subsurfaces link try to remove themselves they won't run into it. This fixes the following ASAN use-after-free error on a build slightly modified to instrument wl_list operations: ==71705==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000829a0 at pc 0x000000508eb7 bp 0x7ffec8fd8030 sp 0x7ffec8fd8028 WRITE of size 8 at 0x6160000829a0 thread T0 #0 0x508eb6 in wl_list_remove ../common/list.c:181 #1 0x4f4998 in view_child_destroy ../sway/tree/view.c:1131 #2 0x4f38fa in subsurface_handle_destroy ../sway/tree/view.c:946 #3 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #4 0x7fda5072f0dd in subsurface_destroy ../types/wlr_surface.c:649 #5 0x7fda507312c4 in subsurface_handle_surface_destroy ../types/wlr_surface.c:1094 #6 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #7 0x7fda5072f305 in surface_handle_resource_destroy ../types/wlr_surface.c:677 #8 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce) #9 0x7fda508187f2 in wl_client_destroy (/lib64/libwayland-server.so.0+0xc7f2) #10 0x7fda50818e5f in wl_client_connection_data (/lib64/libwayland-server.so.0+0xce5f) #11 0x7fda50818219 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0xc219) #12 0x7fda50818984 in wl_display_run (/lib64/libwayland-server.so.0+0xc984) #13 0x43122c in server_run ../sway/server.c:254 #14 0x42f47c in main ../sway/main.c:433 #15 0x7fda503cab74 in __libc_start_main (/lib64/libc.so.6+0x27b74) #16 0x40f6fd in _start (/opt/wayland/bin/sway+0x40f6fd) 0x6160000829a0 is located 288 bytes inside of 592-byte region [0x616000082880,0x616000082ad0) freed by thread T0 here: #0 0x7fda50f01a27 in free (/lib64/libasan.so.6+0xaea27) #1 0x4532d8 in destroy ../sway/desktop/xdg_shell.c:262 #2 0x4ed17b in view_destroy ../sway/tree/view.c:67 #3 0x4ed300 in view_begin_destroy ../sway/tree/view.c:83 #4 0x454a3f in handle_destroy ../sway/desktop/xdg_shell.c:507 #5 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #6 0x7fda506e2c87 in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:481 #7 0x7fda506e3018 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:516 #8 0x7fda506dfbe5 in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71 #9 0x7fda508180ce in destroy_resource (/lib64/libwayland-server.so.0+0xc0ce) previously allocated by thread T0 here: #0 0x7fda50f01ed7 in calloc (/lib64/libasan.so.6+0xaeed7) #1 0x454bc8 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:528 #2 0x7fda50744892 in wlr_signal_emit_safe ../util/signal.c:29 #3 0x7fda506e2363 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:378 #4 0x7fda5072e368 in surface_commit_state ../types/wlr_surface.c:455 #5 0x7fda5072e51d in surface_commit_pending ../types/wlr_surface.c:474 #6 0x7fda5072ea58 in surface_commit ../types/wlr_surface.c:542 #7 0x7fda4fb3ac03 in ffi_call_unix64 (/lib64/libffi.so.6+0x6c03) Fixes #5168 --- sway/tree/view.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sway/tree/view.c b/sway/tree/view.c index c762fa228..43c37bda0 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -56,6 +56,7 @@ void view_destroy(struct sway_view *view) { "(might have a pending transaction?)")) { return; } + wl_list_remove(&view->events.unmap.listener_list); if (!wl_list_empty(&view->saved_buffers)) { view_remove_saved_buffer(view); } From 80128d23ba9f0a6a92284b2c6077e304f35e7a76 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sat, 24 Apr 2021 13:06:40 -0400 Subject: [PATCH 32/42] tree/view: don't give focus to views mapped under fullscreen views Fixes #6211. --- sway/tree/view.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index 43c37bda0..32df19e58 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -600,6 +600,11 @@ static bool should_focus(struct sway_view *view) { return true; } + // View opened "under" fullscreen view should not be given focus. + if (root->fullscreen_global || map_ws->fullscreen) { + return false; + } + // Views can only take focus if they are mapped into the active workspace if (prev_ws != map_ws) { return false; @@ -758,7 +763,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, view_init_subsurfaces(view, wlr_surface); wl_signal_add(&wlr_surface->events.new_subsurface, - &view->surface_new_subsurface); + &view->surface_new_subsurface); view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; if (decoration) { @@ -806,9 +811,9 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, #if HAVE_XWAYLAND if (wlr_surface_is_xwayland_surface(wlr_surface)) { struct wlr_xwayland_surface *xsurface = - wlr_xwayland_surface_from_wlr_surface(wlr_surface); - set_focus = (wlr_xwayland_icccm_input_model(xsurface) != - WLR_ICCCM_INPUT_MODEL_NONE) && set_focus; + wlr_xwayland_surface_from_wlr_surface(wlr_surface); + set_focus &= wlr_xwayland_icccm_input_model(xsurface) != + WLR_ICCCM_INPUT_MODEL_NONE; } #endif @@ -819,11 +824,9 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, const char *app_id; const char *class; if ((app_id = view_get_app_id(view)) != NULL) { - wlr_foreign_toplevel_handle_v1_set_app_id( - view->foreign_toplevel, app_id); + wlr_foreign_toplevel_handle_v1_set_app_id(view->foreign_toplevel, app_id); } else if ((class = view_get_class(view)) != NULL) { - wlr_foreign_toplevel_handle_v1_set_app_id( - view->foreign_toplevel, class); + wlr_foreign_toplevel_handle_v1_set_app_id(view->foreign_toplevel, class); } } From 7ec9d07fc597c739760df5223469e9f15340db78 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 25 Apr 2021 23:19:51 +0200 Subject: [PATCH 33/42] Remove usage of surface->sx|sy These coordinates contain the all-time accumulated buffer attach point, which is a way to perform incremental client-side initiated movement of windows, intended as a way to maintain logical window positioning while compensating for layout changes such as folding in a left side panel. This value is not useful for implementing this feature, and break things if they ever become non-zero. Their inclusion in calculations also tend to cause confusion. Remove usage of these coordinates, removing the ability for clients to move themselves. This may again be supported if a better API is made available from wlroots. --- sway/desktop/output.c | 4 ++-- sway/desktop/render.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 6d4f53423..ab8fd7e85 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -99,8 +99,8 @@ static bool get_surface_box(struct surface_iterator_data *data, int sw = surface->current.width; int sh = surface->current.height; - double _sx = sx + surface->sx; - double _sy = sy + surface->sy; + double _sx = sx; + double _sy = sy; rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height, data->rotation); diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 56936d539..42d62b901 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -159,8 +159,8 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view struct wlr_box dst_box = *_box; struct sway_container *container = data->container; if (container != NULL) { - dst_box.width = fmin(dst_box.width, container->current.content_width - surface->sx); - dst_box.height = fmin(dst_box.height, container->current.content_height - surface->sy); + dst_box.width = fmin(dst_box.width, container->current.content_width); + dst_box.height = fmin(dst_box.height, container->current.content_height); } scale_box(&dst_box, wlr_output->scale); From 4e6f51525308a8883bf998a360a192edc0822cdd Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 25 Apr 2021 23:25:23 +0200 Subject: [PATCH 34/42] desktop/render: Pass explicit clip box to render render_surface_iterator previously deduced the clip box from an optional container passed with render data. This causes problems when offsets in view geometry need to be compensated for in the clip dimensions. Instead, prepare the clip box in render_view_toplevels where the offsets are being applied, and compensate for them immediately. A similar compensation is applied to render_saved_view. Closes: https://github.com/swaywm/sway/issues/6223 --- sway/desktop/render.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 42d62b901..8f1e9c52d 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -32,7 +32,7 @@ struct render_data { pixman_region32_t *damage; float alpha; - struct sway_container *container; + struct wlr_box *clip_box; }; /** @@ -157,10 +157,10 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view wlr_output->transform_matrix); struct wlr_box dst_box = *_box; - struct sway_container *container = data->container; - if (container != NULL) { - dst_box.width = fmin(dst_box.width, container->current.content_width); - dst_box.height = fmin(dst_box.height, container->current.content_height); + struct wlr_box *clip_box = data->clip_box; + if (clip_box != NULL) { + dst_box.width = fmin(dst_box.width, clip_box->width); + dst_box.height = fmin(dst_box.height, clip_box->height); } scale_box(&dst_box, wlr_output->scale); @@ -262,8 +262,13 @@ static void render_view_toplevels(struct sway_view *view, .damage = damage, .alpha = alpha, }; + struct wlr_box clip_box; if (!container_is_current_floating(view->container)) { - data.container = view->container; + // As we pass the geometry offsets to the surface iterator, we will + // need to account for the offsets in the clip dimensions. + clip_box.width = view->container->current.content_width + view->geometry.x; + clip_box.height = view->container->current.content_height + view->geometry.y; + data.clip_box = &clip_box; } // Render all toplevels without descending into popups double ox = view->container->surface_x - @@ -329,10 +334,10 @@ static void render_saved_view(struct sway_view *view, if (!floating) { dst_box.width = fmin(dst_box.width, view->container->current.content_width - - (saved_buf->x - view->container->current.content_x)); + (saved_buf->x - view->container->current.content_x) + view->saved_geometry.x); dst_box.height = fmin(dst_box.height, view->container->current.content_height - - (saved_buf->y - view->container->current.content_y)); + (saved_buf->y - view->container->current.content_y) + view->saved_geometry.y); } scale_box(&dst_box, wlr_output->scale); From fd36289faa86e92583f014af358f5eca99a3d4aa Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 26 Apr 2021 09:32:26 +0200 Subject: [PATCH 35/42] Remove support for arbitrary rotations There was some unused code-paths for rendering surfaces with an arbitrary rotation applied. This was imported from rootston. Since we don't have plans to make use of this, remove it. --- include/sway/output.h | 4 +-- sway/desktop/output.c | 66 +++++++++---------------------------------- sway/desktop/render.c | 8 +++--- 3 files changed, 19 insertions(+), 59 deletions(-) diff --git a/include/sway/output.h b/include/sway/output.h index 969867000..0ebcc77da 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -72,8 +72,8 @@ struct sway_output *output_get_in_direction(struct sway_output *reference, void output_add_workspace(struct sway_output *output, struct sway_workspace *workspace); -typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *box, float rotation, +typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box, void *user_data); void output_damage_whole(struct sway_output *output); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index ab8fd7e85..aa1482907 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -56,26 +56,6 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id) { return NULL; } -/** - * Rotate a child's position relative to a parent. The parent size is (pw, ph), - * the child position is (*sx, *sy) and its size is (sw, sh). - */ -static void rotate_child_position(double *sx, double *sy, double sw, double sh, - double pw, double ph, float rotation) { - if (rotation == 0.0f) { - return; - } - - // Coordinates relative to the center of the subsurface - double ox = *sx - pw/2 + sw/2, - oy = *sy - ph/2 + sh/2; - // Rotated coordinates - double rx = cos(-rotation)*ox - sin(-rotation)*oy, - ry = cos(-rotation)*oy + sin(-rotation)*ox; - *sx = rx + pw/2 - sw/2; - *sy = ry + ph/2 - sh/2; -} - struct surface_iterator_data { sway_surface_iterator_func_t user_iterator; void *user_data; @@ -84,7 +64,6 @@ struct surface_iterator_data { struct sway_view *view; double ox, oy; int width, height; - float rotation; }; static bool get_surface_box(struct surface_iterator_data *data, @@ -99,14 +78,9 @@ static bool get_surface_box(struct surface_iterator_data *data, int sw = surface->current.width; int sh = surface->current.height; - double _sx = sx; - double _sy = sy; - rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height, - data->rotation); - struct wlr_box box = { - .x = floor(data->ox + _sx), - .y = floor(data->oy + _sy), + .x = floor(data->ox + sx), + .y = floor(data->oy + sy), .width = sw, .height = sh, }; @@ -114,16 +88,13 @@ static bool get_surface_box(struct surface_iterator_data *data, memcpy(surface_box, &box, sizeof(struct wlr_box)); } - struct wlr_box rotated_box; - wlr_box_rotated_bounds(&rotated_box, &box, data->rotation); - struct wlr_box output_box = { .width = output->width, .height = output->height, }; struct wlr_box intersection; - return wlr_box_intersection(&intersection, &output_box, &rotated_box); + return wlr_box_intersection(&intersection, &output_box, &box); } static void output_for_each_surface_iterator(struct wlr_surface *surface, @@ -136,7 +107,7 @@ static void output_for_each_surface_iterator(struct wlr_surface *surface, return; } - data->user_iterator(data->output, data->view, surface, &box, data->rotation, + data->user_iterator(data->output, data->view, surface, &box, data->user_data); } @@ -152,7 +123,6 @@ void output_surface_for_each_surface(struct sway_output *output, .oy = oy, .width = surface->current.width, .height = surface->current.height, - .rotation = 0, }; wlr_surface_for_each_surface(surface, @@ -173,7 +143,6 @@ void output_view_for_each_surface(struct sway_output *output, - view->geometry.y, .width = view->container->current.content_width, .height = view->container->current.content_height, - .rotation = 0, // TODO }; view_for_each_surface(view, output_for_each_surface_iterator, &data); @@ -193,7 +162,6 @@ void output_view_for_each_popup_surface(struct sway_output *output, - view->geometry.y, .width = view->container->current.content_width, .height = view->container->current.content_height, - .rotation = 0, // TODO }; view_for_each_popup_surface(view, output_for_each_surface_iterator, &data); @@ -216,7 +184,6 @@ void output_layer_for_each_surface(struct sway_output *output, .oy = layer_surface->geo.y, .width = surface->current.width, .height = surface->current.height, - .rotation = 0, }; wlr_layer_surface_v1_for_each_surface(wlr_layer_surface_v1, output_for_each_surface_iterator, &data); @@ -254,7 +221,6 @@ void output_layer_for_each_popup_surface(struct sway_output *output, .oy = layer_surface->geo.y, .width = surface->current.width, .height = surface->current.height, - .rotation = 0, }; wlr_layer_surface_v1_for_each_popup_surface(wlr_layer_surface_v1, output_for_each_surface_iterator, &data); @@ -426,9 +392,9 @@ struct send_frame_done_data { int msec_until_refresh; }; -static void send_frame_done_iterator(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *box, float rotation, - void *user_data) { +static void send_frame_done_iterator(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, + struct wlr_box *box, void *user_data) { int view_max_render_time = 0; if (view != NULL) { view_max_render_time = view->max_render_time; @@ -451,9 +417,9 @@ static void send_frame_done(struct sway_output *output, struct send_frame_done_d output_for_each_surface(output, send_frame_done_iterator, data); } -static void count_surface_iterator(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *_box, float rotation, - void *data) { +static void count_surface_iterator(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, + struct wlr_box *box, void *data) { size_t *n = data; (*n)++; } @@ -657,18 +623,15 @@ void output_damage_whole(struct sway_output *output) { } } -static void damage_surface_iterator(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *_box, float rotation, - void *_data) { +static void damage_surface_iterator(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, + struct wlr_box *_box, void *_data) { bool *data = _data; bool whole = *data; struct wlr_box box = *_box; scale_box(&box, output->wlr_output->scale); - int center_x = box.x + box.width/2; - int center_y = box.y + box.height/2; - if (pixman_region32_not_empty(&surface->buffer_damage)) { pixman_region32_t damage; pixman_region32_init(&damage); @@ -681,14 +644,11 @@ static void damage_surface_iterator(struct sway_output *output, struct sway_view ceil(output->wlr_output->scale) - surface->current.scale); } pixman_region32_translate(&damage, box.x, box.y); - wlr_region_rotated_bounds(&damage, &damage, rotation, - center_x, center_y); wlr_output_damage_add(output->damage, &damage); pixman_region32_fini(&damage); } if (whole) { - wlr_box_rotated_bounds(&box, &box, rotation); wlr_output_damage_add_box(output->damage, &box); } diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 8f1e9c52d..4ce5654ed 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -131,9 +131,9 @@ damage_finish: pixman_region32_fini(&damage); } -static void render_surface_iterator(struct sway_output *output, struct sway_view *view, - struct wlr_surface *surface, struct wlr_box *_box, float rotation, - void *_data) { +static void render_surface_iterator(struct sway_output *output, + struct sway_view *view, struct wlr_surface *surface, + struct wlr_box *_box, void *_data) { struct render_data *data = _data; struct wlr_output *wlr_output = output->wlr_output; pixman_region32_t *output_damage = data->damage; @@ -153,7 +153,7 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view float matrix[9]; enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform); - wlr_matrix_project_box(matrix, &proj_box, transform, rotation, + wlr_matrix_project_box(matrix, &proj_box, transform, 0.0, wlr_output->transform_matrix); struct wlr_box dst_box = *_box; From c12169953abd393506367b949a63de5928ad9518 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Sun, 18 Apr 2021 15:15:43 -0700 Subject: [PATCH 36/42] workspace: reap empty parents when adding tiles --- sway/tree/workspace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 4e7350640..c0da9c934 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -794,7 +794,11 @@ void workspace_detach(struct sway_workspace *workspace) { struct sway_container *workspace_add_tiling(struct sway_workspace *workspace, struct sway_container *con) { if (con->pending.workspace) { + struct sway_container *old_parent = con->pending.parent; container_detach(con); + if (old_parent) { + container_reap_empty(old_parent); + } } if (config->default_layout != L_NONE) { con = container_split(con, config->default_layout); From a6dc829ed00585755adeb25a18373b163f9a94c9 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Sun, 18 Apr 2021 15:08:09 -0700 Subject: [PATCH 37/42] xdg-shell: ignore unecessary fullscreen request ouput hints --- sway/desktop/xdg_shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 843ff90a0..d34654fd4 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -358,7 +358,8 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) if (e->fullscreen && e->output && e->output->data) { struct sway_output *output = e->output->data; struct sway_workspace *ws = output_get_active_workspace(output); - if (ws && !container_is_scratchpad_hidden(container)) { + if (ws && !container_is_scratchpad_hidden(container) && + container->pending.workspace != ws) { if (container_is_floating(container)) { workspace_add_floating(ws, container); } else { From 30e400c0a3d5d11ba15dc4ab6cdcfe2e71cfce01 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Thu, 29 Apr 2021 08:49:04 +0200 Subject: [PATCH 38/42] view: handle case where map_ws is NULL When a criteria places the view into the scratchpad, map_ws is NULL and trying to access map_ws->fullscreen will result in SIGSEGFAULT with: #0 0x0000000000455327 in should_focus (view=0x15a6a70) at ../sway/tree/view.c:604 prev_con = 0x0 len = seat = 0x12233c0 prev_ws = 0x1264c80 map_ws = 0x0 criterias = seat = prev_con = prev_ws = map_ws = criterias = len = num_children = #1 view_map (view=view@entry=0x15a6a70, wlr_surface=0x15a5cb0, fullscreen=, fullscreen_output=, decoration=) at ../sway/tree/view.c:809 __PRETTY_FUNCTION__ = "view_map" ws = seat = node = target_sibling = container = 0x1625400 set_focus = app_id = class = #2 0x0000000000423a7e in handle_map (listener=0x15a6c78, data=) at ../sway/desktop/xdg_shell.c:454 xdg_shell_view = 0x15a6a70 view = 0x15a6a70 xdg_surface = 0x15a6620 csd = #3 0x00007f508bd3674c in wlr_signal_emit_safe (signal=signal@entry=0x15a6718, data=data@entry=0x15a6620) at ../subprojects/wlroots/util/signal.c:29 pos = 0x15a6c78 l = 0x15a6c78 cursor = {link = {prev = 0x15a6c78, next = 0x7fff53d58190}, notify = 0x7f508bd366c0 } end = {link = {prev = 0x7fff53d58170, next = 0x15a6718}, notify = 0x7f508bd366c0 } #4 0x00007f508bd15b29 in handle_xdg_surface_commit (wlr_surface=) at ../subprojects/wlroots/types/xdg_shell/wlr_xdg_surface.c:384 surface = 0x15a6620 #5 0x00007f508bd2e981 in surface_commit_state (surface=surface@entry=0x15a5cb0, next=next@entry=0x15a5e18) at ../subprojects/wlroots/types/wlr_surface.c:455 __PRETTY_FUNCTION__ = "surface_commit_state" invalid_buffer = subsurface = 0x15a6038 #6 0x00007f508bd2f53b in surface_commit_pending (surface=0x15a5cb0) at ../subprojects/wlroots/types/wlr_surface.c:474 next_seq = 3 next_seq = #7 surface_commit (client=, resource=) at ../subprojects/wlroots/types/wlr_surface.c:542 surface = 0x15a5cb0 subsurface = If map_ws is NULL we assume the view is places into the scratchpad and return false as well. --- sway/tree/view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index 32df19e58..49e6f5993 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -601,7 +601,7 @@ static bool should_focus(struct sway_view *view) { } // View opened "under" fullscreen view should not be given focus. - if (root->fullscreen_global || map_ws->fullscreen) { + if (root->fullscreen_global || !map_ws || map_ws->fullscreen) { return false; } From 7c74f01f0ae9d5b3f92d3e6fc64cb9abe95b4c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Burdukiewicz?= Date: Thu, 29 Apr 2021 16:52:54 +0200 Subject: [PATCH 39/42] main: removed vc4 detection code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bartłomiej Burdukiewicz --- sway/main.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/sway/main.c b/sway/main.c index cd949e1e3..0611e80bf 100644 --- a/sway/main.c +++ b/sway/main.c @@ -47,43 +47,6 @@ void sig_handler(int signal) { sway_terminate(EXIT_SUCCESS); } -void detect_raspi(void) { - bool raspi = false; - FILE *f = fopen("/sys/firmware/devicetree/base/model", "r"); - if (!f) { - return; - } - char *line = NULL; - size_t line_size = 0; - while (getline(&line, &line_size, f) != -1) { - if (strstr(line, "Raspberry Pi")) { - raspi = true; - break; - } - } - fclose(f); - FILE *g = fopen("/proc/modules", "r"); - if (!g) { - free(line); - return; - } - bool vc4 = false; - while (getline(&line, &line_size, g) != -1) { - if (strstr(line, "vc4")) { - vc4 = true; - break; - } - } - free(line); - fclose(g); - if (!vc4 && raspi) { - fprintf(stderr, "\x1B[1;31mWarning: You have a " - "Raspberry Pi, but the vc4 Module is " - "not loaded! Set 'dtoverlay=vc4-kms-v3d'" - "in /boot/config.txt and reboot.\x1B[0m\n"); - } -} - void detect_proprietary(int allow_unsupported_gpu) { FILE *f = fopen("/proc/modules", "r"); if (!f) { @@ -350,7 +313,6 @@ int main(int argc, char **argv) { log_distro(); log_env(); detect_proprietary(allow_unsupported_gpu); - detect_raspi(); if (optind < argc) { // Behave as IPC client if (optind != 1) { From f8d7c170cd9aa0bf12e4096588c397a8bc383ed1 Mon Sep 17 00:00:00 2001 From: Elyesa <60751519+04ELY@users.noreply.github.com> Date: Mon, 3 May 2021 12:58:18 +0300 Subject: [PATCH 40/42] Add Turkish README --- README.md | 3 ++- README.tr.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 README.tr.md diff --git a/README.md b/README.md index d9aa06089..5edefe565 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # sway -**[English][en]** - [日本語][ja] - [Français][fr] - [Українська][uk] - [Español][es] - [Polski][pl] - [中文-简体][zh-CN] - [Deutsch][de] - [Nederlands][nl] - [Русский][ru] - [中文-繁體][zh-TW] - [Português][pt] - [Danish][dk] - [한국어][ko] - [Română][ro] - [Magyar][hu] +**[English][en]** - [日本語][ja] - [Français][fr] - [Українська][uk] - [Español][es] - [Polski][pl] - [中文-简体][zh-CN] - [Deutsch][de] - [Nederlands][nl] - [Русский][ru] - [中文-繁體][zh-TW] - [Português][pt] - [Danish][dk] - [한국어][ko] - [Română][ro] - [Magyar][hu] - [Türkçe][tr] sway is an [i3]-compatible [Wayland] compositor. Read the [FAQ]. Join the [IRC channel] \(#sway on irc.freenode.net). @@ -80,6 +80,7 @@ sway (gdm is known to work fairly well). [ko]: https://github.com/swaywm/sway/blob/master/README.ko.md [ro]: https://github.com/swaywm/sway/blob/master/README.ro.md [hu]: https://github.com/swaywm/sway/blob/master/README.hu.md +[tr]: https://github.com/swaywm/sway/blob/master/README.tr.md [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ [FAQ]: https://github.com/swaywm/sway/wiki diff --git a/README.tr.md b/README.tr.md new file mode 100644 index 000000000..7d63de563 --- /dev/null +++ b/README.tr.md @@ -0,0 +1,68 @@ +# sway + + +Sway, [i3]-uyumlu bir [Wayland] dizgicisidir. [SSS][FAQ]'yi okuyun. +[IRC kanalı][IRC channel]na katılın \(irc.freenode.net'te #sway (İngilizce)). + +## Sürüm imzaları + +Sürümler [E88F5E48] ile imzalandı ve [GitHub][GitHub releases]'da yayınlandı. + +## Kurulum + +### Paketler ile + +Sway birçok dağıtımda mevcuttur. Sizinki için "sway" paketini yüklemeyi deneyin. + +Dağıtımınız için sway'i paketlemekle ilgileniyorsanız, IRC kanalına uğrayın veya tavsiye için sir@cmpwn.com adresine bir e-posta gönderin. + +### Kaynak koddan derleme + +Test veya geliştirme için sway ve wlroots'un HEAD'ini oluşturmak istiyorsanız [bu wiki sayfası][Development setup]na göz atın. + +Aşağıdaki bağımlılıkları yükleyin: + +* meson \* +* [wlroots] +* wayland +* wayland-protocols \* +* pcre +* json-c +* pango +* cairo +* gdk-pixbuf2 (isteğe bağlı: system tray) +* [scdoc] (isteğe bağlı: man pages) \* +* git (isteğe bağlı: version info) \* + +_\*Derleme-anı bağımlılıkları_ + +Şu komutları çalıştırın: + + meson build + ninja -C build + sudo ninja -C build install + +logind olmayan sistemlerde, sway ikilisine (binary) izin vermeniz (suid) gerekir: + + sudo chmod a+s /usr/local/bin/sway + +Sway, başlangıçtan kısa bir süre sonra kök(root) izinlerini bırakacaktır. + +## Yapılandırma + +Zaten i3 kullanıyorsanız, i3 yapılandırmanızı `~/.config/sway/config` konumuna kopyalayın ve kutudan çıktığı gibi çalışacaktır. Aksi takdirde, örnek yapılandırma dosyasını `~/.config/sway/config` konumuna kopyalayın. Genellikle `/etc/sway/config` konumunda bulunur. +Yapılandırma hakkında bilgi almak için `man 5 sway` komutunu çalıştırın. + +## Çalıştırma + +TTY'den `sway` çalıştırın. Bazı görüntü yöneticileriyle(display manager) çalışabilir ama Sway tarafından desteklenmez. (gdm'nin oldukça iyi çalıştığı bilinmektedir.) + +[i3]: https://i3wm.org/ +[Wayland]: http://wayland.freedesktop.org/ +[FAQ]: https://github.com/swaywm/sway/wiki +[IRC channel]: http://webchat.freenode.net/?channels=sway&uio=d4 +[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48 +[GitHub releases]: https://github.com/swaywm/sway/releases +[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup +[wlroots]: https://github.com/swaywm/wlroots +[scdoc]: https://git.sr.ht/~sircmpwn/scdoc From d7ec66d563adcc069c3ba09c4cdeaf1281f1670c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 4 May 2021 21:07:04 +0200 Subject: [PATCH 41/42] build: remove sd-bus status item sd-bus == tray, no need to print the same thing twice. --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index d204f54a5..3681547d3 100644 --- a/meson.build +++ b/meson.build @@ -310,7 +310,6 @@ endif summary({ 'xwayland': have_xwayland, 'gdk-pixbuf': gdk_pixbuf.found(), - 'sd-bus': sdbus.found(), 'tray': have_tray, 'man-pages': scdoc.found(), }, bool_yn: true) From d65e67face1f826ea7dec06a9d56b1a0c46c22b8 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+erikreider@users.noreply.github.com> Date: Wed, 5 May 2021 19:23:15 +0200 Subject: [PATCH 42/42] Added scroll_factor input variable to ipc output --- sway/ipc-json.c | 12 ++++++++++++ sway/sway-ipc.7.scd | 3 +++ 2 files changed, 15 insertions(+) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2c4c52a39..34adfc74b 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -1002,6 +1003,17 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { } } + if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { + struct input_config *ic = input_device_get_config(device); + float scroll_factor = 1.0f; + if (ic != NULL && !isnan(ic->scroll_factor) && + ic->scroll_factor != FLT_MIN) { + scroll_factor = ic->scroll_factor; + } + json_object_object_add(object, "scroll_factor", + json_object_new_double(scroll_factor)); + } + if (wlr_input_device_is_libinput(device->wlr_device)) { struct libinput_device *libinput_dev; libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index 1b855959c..373e9dce1 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -1131,6 +1131,9 @@ following properties: |- xkb_active_layout_index : integer : (Only keyboards) The index of the active keyboard layout in use +|- scroll_factor +: floating +: (Only pointers) Multiplier applied on scroll event values. |- libinput : object : (Only libinput devices) An object describing the current device settings.