diff --git a/.builds/alpine.yml b/.builds/alpine.yml index fa693906d..c3b80390d 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -25,16 +25,16 @@ packages: - hwdata-dev sources: - https://github.com/swaywm/sway - - https://gitlab.freedesktop.org/wlroots/wlroots.git + - https://gitlab.freedesktop.org/wlroots/wlroots.git#0.18 tasks: - wlroots: | cd wlroots - meson setup --prefix=/usr build -Dexamples=false + meson --prefix=/usr build -Dexamples=false ninja -C build sudo ninja -C build install - setup: | cd sway - meson setup build --fatal-meson-warnings -Dauto_features=enabled -Dtray=disabled + meson build --fatal-meson-warnings -Dauto_features=enabled -Dtray=disabled - build: | cd sway ninja -C build @@ -52,5 +52,5 @@ tasks: mkdir subprojects ln -s ../../wlroots subprojects/wlroots rm -rf build - meson setup build --fatal-meson-warnings --default-library=static --force-fallback-for=wlroots + meson build --fatal-meson-warnings --default-library=static --force-fallback-for=wlroots ninja -C build diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index 2c8ffcf45..cbc4e545b 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -22,16 +22,16 @@ packages: - hwdata sources: - https://github.com/swaywm/sway - - https://gitlab.freedesktop.org/wlroots/wlroots.git + - https://gitlab.freedesktop.org/wlroots/wlroots.git#0.18 tasks: - wlroots: | cd wlroots - meson setup --prefix=/usr build -Dexamples=false + meson --prefix=/usr build -Dexamples=false ninja -C build sudo ninja -C build install - setup: | cd sway - meson setup build --fatal-meson-warnings -Dauto_features=enabled -Dsd-bus-provider=libsystemd + meson build --fatal-meson-warnings -Dauto_features=enabled -Dsd-bus-provider=libsystemd - build: | cd sway ninja -C build diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index a3df06e6d..5276ee8e2 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -31,7 +31,7 @@ packages: - misc/hwdata sources: - https://github.com/swaywm/sway -- https://gitlab.freedesktop.org/wlroots/wlroots.git +- https://gitlab.freedesktop.org/wlroots/wlroots.git#0.18 tasks: - setup: | cd sway @@ -39,7 +39,7 @@ tasks: cd subprojects ln -s ../../wlroots wlroots cd .. - meson setup build --fatal-meson-warnings -Dtray=enabled -Dsd-bus-provider=basu + meson build --fatal-meson-warnings -Dtray=enabled -Dsd-bus-provider=basu - build: | cd sway ninja -C build diff --git a/README.ar.md b/README.ar.md index 2f64f2b53..4f9bf828a 100644 --- a/README.ar.md +++ b/README.ar.md @@ -37,7 +37,7 @@ _\* Compile-time dep_ نفذ هذه الأوامر: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.az.md b/README.az.md deleted file mode 100644 index 50c8b0dec..000000000 --- a/README.az.md +++ /dev/null @@ -1,66 +0,0 @@ -# sway - -sway [i3]-ə uyğun [Wayland] kompozitorudur. [Tez-tez verilən sualları] oxuyun. -[IRC kanalına] qoşulun ("irc.libera.chat"-da #sway). - -## Buraxılış İmzaları - -Buraxılışlar [E88F5E48] ilə imzalanıb və [GitHub-da][GitHub releases] dərc edilib. - -## Quraşdırma - -### Paketlərdən - -Sway bir çox distributivdə mövcuddur. Öz distributiviniz üçün -"sway" paketini quraşdırmağa çalışın. - -### Mənbə kodundan kompilyasiya - -Test və ya inkişaf üçün sway və wlroots-un HEAD-ini qurmaq istəyirsinizsə, -[bu viki səhifəsini][Development setup] nəzərdən keçirin. - -Asılılıqları quraşdırın: - -* meson \* -* [wlroots] -* wayland -* wayland-protocols \* -* pcre2 -* json-c -* pango -* cairo -* gdk-pixbuf2 (ixtiyari: sistem trayı üçün əlavə şəkil formatları) -* [swaybg] (ixtiyari: divar kağızı) -* [scdoc] (ixtiyari: man səhifələri) \* -* git (ixtiyari: versiya məlumatı) \* - -_\* Kompilyasiya asılılıqları_ - -Bu əmrləri icra edin: - - meson setup build/ - ninja -C build/ - sudo ninja -C build/ install - -## Konfiqurasiya - -Əgər artıq i3-dən istifadə edirsinizsə, i3 konfiqurasiyanızı `~/.config/sway/config` -ünvanına köçürün və o, dərhal işləyəcək. Əks halda, nümunə konfiqurasiya faylını -`~/.config/sway/config` ünvanına köçürün. O, adətən `/etc/sway/config` ünvanında yerləşir. -Konfiqurasiya haqqında məlumat üçün `man 5 sway` əmrini icra edin. - -## İşə Salma - -TTY-dan `sway`-ı işə salın. Bəzi ekran menecerləri işləyə bilər, lakin sway tərəfindən -dəstəklənmir (gdm-in kifayət qədər yaxşı işlədiyi məlumdur). - -[i3]: https://i3wm.org/ -[Wayland]: http://wayland.freedesktop.org/ -[Tez-tez verilən sualları]: https://github.com/swaywm/sway/wiki -[IRC kanalına]: https://web.libera.chat/gamja/?channels=#sway -[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://gitlab.freedesktop.org/wlroots/wlroots -[swaybg]: https://github.com/swaywm/swaybg/ -[scdoc]: https://git.sr.ht/~sircmpwn/scdoc diff --git a/README.cs.md b/README.cs.md index 0b4085e7f..fbb23b34e 100644 --- a/README.cs.md +++ b/README.cs.md @@ -1,24 +1,25 @@ # sway -sway je [waylandový][Wayland] kompozitor kompatibilní s [i3]. Přečtěte si -[FAQ (anglicky)][FAQ]. Připojte se na [IRC kanál (anglicky)][IRC channel] -\(#sway na irc.libera.chat). +[English][en] - [عربي][ar] - **[Česky][cs]** - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [ქართული][ge] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Norsk][no] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Svenska][sv] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW] + +sway je s [i3] kompatibilní [Wayland] kompozitor. Přečtěte si [FAQ]. Připojte se na +[IRC kanál][IRC channel] \(#sway na irc.libera.chat). ## Podpisy vydání -Vydané verze jsou podepsány klíčem [E88F5E48] a publikovány -[na GitHubu][GitHub releases]. +Vydání jsou podepsána [E88F5E48] a publikována [na GitHubu][GitHub releases]. ## Instalace -### Z balíků +### Z balíčků -Sway je dostupný v mnoha distribucích. Zkuste v té vaší nainstalovat balík "sway". +Sway je dostupný ve spoustě distribucí. Zkuste nainstalovat balíček "sway" ve vaší +distribuci. ### Kompilace ze zdrojových kódů -Pokud chcete sestavit HEAD repozitáře sway a wlroots pro testování nebo vývoj, -použijte návod na [této stránce na wiki (anglicky)][Development setup]. +Podívejte se na [tuto stránku wiki][Development setup], pokud chcete sestavit HEAD +sway a wlroots pro testování nebo vývoj. Nainstalujte závislosti: @@ -30,16 +31,16 @@ Nainstalujte závislosti: * json-c * pango * cairo -* gdk-pixbuf2 (volitelné: dodatečné formáty ikon pro oznamovací oblast) -* [swaybg] (volitelné: tapeta plochy) -* [scdoc] (volitelné: man stránky) \* +* gdk-pixbuf2 (volitelné: oznamovací oblast) +* [swaybg] (volitelné: tapeta) +* [scdoc] (volitelné: manuálové stránky) \* * git (volitelné: informace o verzi) \* _\* Závislost pouze pro kompilaci_ Spusťte tyto příkazy: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install @@ -52,7 +53,8 @@ Pro více informací o konfiguraci spusťte `man 5 sway`. ## Spuštění -Spusťte `sway` z TTY nebo ze správce displeje. +Spusťte `sway` z TTY. Některé správce zobrazení mohou fungovat, ale nejsou +podporovány sway (je známo, že gdm funguje docela dobře). [en]: https://github.com/swaywm/sway#readme [ar]: README.ar.md diff --git a/README.de.md b/README.de.md index 0c0b18637..68b411d95 100644 --- a/README.de.md +++ b/README.de.md @@ -1,21 +1,21 @@ # Sway -Sway ist ein [i3]-kompatibler [Wayland]-Compositor. Lies die [FAQ]. Tritt dem [IRC Channel] bei (#sway on irc.libera.chat; Englisch). +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 -Jeder Release wird mit dem PGP-Schlüssel [E88F5E48] signiert und [auf GitHub][GitHub releases] 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 ### Über die Paketverwaltung -Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Versuche einfach das Paket "sway" zu installieren. +Sway kann in vielen Distributionen direkt durch die Paketverwaltung installiert werden. Versuche einfach das Packet "sway" zu installieren. ### Quellcode selbst kompilieren sway benötigt die folgenden Pakete: -* meson \* -* [wlroots] +* meson\* +* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) * wayland * wayland-protocols\* * pcre2 @@ -23,34 +23,21 @@ sway benötigt die folgenden Pakete: * pango * cairo * gdk-pixbuf2 (Optional, wird für das Benachrichtigungsfeld (System Tray) benötigt) -* [swaybg] (Optional, wird für das Setzen von Desktophintergrundbildern benötigt) -* [scdoc] (Optional, wird für die Dokumentation (Man Pages) benötigt)\* +* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Optional, wird für die Dokumentation (Man Pages) benötigt)\* * git (Optional: Versionsinfo)\* -_\*Werden nur für das Kompilieren benötigt_ +_\*Werden nur während des Kompilierens benötigt_ Führe die folgenden Befehle aus: - meson setup build/ - ninja -C build/ - sudo ninja -C build/ install - -Schaue in das [Wiki][Development setup] (Englisch) für Informationen, falls du zum Testen oder Entwickeln den neuesten Stand (HEAD) von sway und wlroots kompilieren willst. + meson build + ninja -C build + sudo ninja -C build install ## Konfiguration Falls du von i3 migrierst, kannst du deine Konfigurationsdatei nach `~/.config/sway/config` kopieren und die Einstellungen sollten ohne Weiteres funktionieren. Ansonsten kannst du die Beispielkonfiguration, die normalerweise in `/etc/sway/config` liegt, nach `~/.config/sway/config` kopieren. Die Dokumentation zur Konfigurationsdatei findest du in `man 5 sway`. ## Sway starten -Sway kann einfach mit dem Befehl `sway` vom TTY oder mithilfe eines Displaymanagers gestartet werden. - -[i3]: https://i3wm.org/ -[Wayland]: http://wayland.freedesktop.org/ -[FAQ]: https://github.com/swaywm/sway/wiki -[IRC channel]: https://web.libera.chat/gamja/?channels=#sway -[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://gitlab.freedesktop.org/wlroots/wlroots -[swaybg]: https://github.com/swaywm/swaybg -[scdoc]: https://git.sr.ht/~sircmpwn/scdoc +Sway kann einfach mit dem Befehl `sway` vom TTY gestartet werden. +Display-Manager werden nicht offiziell unterstützt. Es gibt aber durchaus einige, die mit Sway funktionieren (z.B. gdm). diff --git a/README.dk.md b/README.dk.md index 8e4cc3724..5ce94cdef 100644 --- a/README.dk.md +++ b/README.dk.md @@ -41,7 +41,7 @@ _\*Kompileringsafhængighed_ Kør følgende kommandoer: - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -54,7 +54,8 @@ Hvis du allerede bruger i3 kan du bare kopiere din i3 konfiguration til ## Eksekvering -Kør `sway` fra en TTY eller fra en display manager. +Kør `sway` fra en TTY. Nogle display managers kan fungere, men Sway yder ikke +support til dem (gdm er kendt for at fungere temmelig godt). [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ diff --git a/README.es.md b/README.es.md index 3ad8e29e3..1f1657dfa 100644 --- a/README.es.md +++ b/README.es.md @@ -40,7 +40,7 @@ _\*Compile-time dep_ Desde su consola, ejecute las órdenes: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.fr.md b/README.fr.md index c4ef699a4..7752fc70f 100644 --- a/README.fr.md +++ b/README.fr.md @@ -47,7 +47,7 @@ _\* Requis uniquement pour la compilation_ Exécutez ces commandes : - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -61,7 +61,9 @@ documentation pour la configuration de sway. ## Exécution -Exécutez `sway` à partir d'un TTY ou d'un gestionnaires d'affichage. +Exécutez `sway` à partir d'un TTY. Certains gestionnaires d'affichage peuvent +fonctionner, mais ne sont pas supportés par Sway (gdm est réputé pour assez +bien fonctionner). [Wayland]: http://wayland.freedesktop.org/ [i3]: https://i3wm.org/ diff --git a/README.ge.md b/README.ge.md index de75be837..bb8b9a34c 100644 --- a/README.ge.md +++ b/README.ge.md @@ -35,7 +35,7 @@ _\* Compile-time dep_ გაუშვით ეს ბრძანებები: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.gr.md b/README.gr.md index 629465846..d697f78e3 100644 --- a/README.gr.md +++ b/README.gr.md @@ -40,7 +40,7 @@ _\*Compile-time dep_ Τρέξτε αυτά τα commands: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.hi.md b/README.hi.md index eb792b790..eae5e90a5 100644 --- a/README.hi.md +++ b/README.hi.md @@ -44,7 +44,7 @@ _\* Compilation के समय आवश्यक_ ये commands चलाएं: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.hu.md b/README.hu.md index b66a24b23..82ca6785b 100644 --- a/README.hu.md +++ b/README.hu.md @@ -1,10 +1,10 @@ # 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.libera.chat`-en). +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.libera.chat`-en). -## Csomagaláírások +## Csomag aláírások -A kiadott csomagok az [E88F5E48] kulccsal vannak aláírva, és [GitHubon][GitHub releases] publikálva. +A kiadott csomagok az [E88F5E48] kulccsal vannak aláírva és [GitHub-on][GitHub releases] publikálva. ## Telepítés @@ -13,12 +13,12 @@ A kiadott csomagok az [E88F5E48] kulccsal vannak aláírva, és [GitHubon][GitHu 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- +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 wikioldalt][Development setup], ha szeretnéd tesztelési vagy +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. @@ -40,13 +40,13 @@ _\*Fordításidejű függőség_ Futtasd ezeket a parancsokat: - meson setup build + meson build ninja -C build sudo ninja -C build install ## Konfiguráció -Ha előzőleg i3-at használtál, akkor átmásolhatod az i3-beállításaidat a +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ó. @@ -55,7 +55,7 @@ kapcsolatban. ## Futtatás -Futtasd a `sway` parancsot egy TTY-felületről. Néhány bejelentkezéskezelő +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.) diff --git a/README.ir.md b/README.ir.md index f7d00e803..a485a4059 100644 --- a/README.ir.md +++ b/README.ir.md @@ -41,7 +41,7 @@ _\*نیازمندی‌های زمان کامپایل برنامه_ این فرمان‌ها را اجرا کنید: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.it.md b/README.it.md index 30cdc21e0..82bb57837 100644 --- a/README.it.md +++ b/README.it.md @@ -1,7 +1,7 @@ # sway sway è un compositore di [Wayland] compatibile con [i3]. Leggi le [FAQ]. -Unisciti al [canale IRC] \(#sway su irc.libera.chat). +Unisciti al [canale di IRC] \(#sway su irc.libera.chat). ## Firma delle versioni @@ -38,7 +38,7 @@ _\* Dipendenza necessaria per la compilazione_ Esegui questi comandi: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install @@ -52,12 +52,13 @@ configurazione. ## Esecuzione -Lancia `sway` da un TTY o da un display manager. +Lancia `sway` da un TTY. Alcuni gestori d'accesso potrebbero funzionare ma non +sono supportati da sway (gdm funziona abbastanza bene). [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ [FAQ]: https://github.com/swaywm/sway/wiki -[canale IRC]: https://web.libera.chat/gamja/?channels=#sway +[canale di IRC]: https://web.libera.chat/gamja/?channels=#sway [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 diff --git a/README.ja.md b/README.ja.md index d6a8202e3..4e9a9971d 100644 --- a/README.ja.md +++ b/README.ja.md @@ -42,7 +42,7 @@ _\*コンパイル時の依存_ 次のコマンドを実行してください: - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -52,4 +52,5 @@ _\*コンパイル時の依存_ ## 実行 -`sway`をTTYまたはディスプレイマネージャから実行してください。 +`sway`をTTYから実行してください。いくつかのディスプレイマネージャは動くかもしれませんが、Swayからサポートされていません(gdmは非常に良く動作することが知られています)。 + diff --git a/README.ko.md b/README.ko.md index c9f31beff..e086c174c 100644 --- a/README.ko.md +++ b/README.ko.md @@ -39,7 +39,7 @@ _\*컴파일 떄 필요_ 다음 명령을 실행하세요: - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -52,4 +52,4 @@ i3를 이미 사용 중이라면, i3 config을 `~/.config/sway/config`로 복사 ## 실행 -TTY나 display manager에서 `sway`를 실행하세요. +TTY에서 `sway`를 실행하세요. 일부 display manager는 작동하지만, sway로 부터 지원되지 않습니다(gdm은 상당히 잘 작동한다고 알려져 있습니다). diff --git a/README.md b/README.md index 882db57ee..15c7c0999 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # sway -**[English][en]** - [عربي][ar] - [Azərbaycanca][az] - [Česky][cs] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [ქართული][ge] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Norsk][no] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Српски][sr] - [Svenska][sv] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW] +**[English][en]** - [عربي][ar] - [Česky][cs] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [ქართული][ge] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Norsk][no] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Svenska][sv] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW] sway is an [i3]-compatible [Wayland] compositor. Read the [FAQ]. Join the [IRC channel] \(#sway on irc.libera.chat). @@ -40,7 +40,7 @@ _\* Compile-time dep_ Run these commands: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install @@ -53,11 +53,11 @@ Run `man 5 sway` for information on the configuration. ## Running -Run `sway` from a TTY or from a display manager. +Run `sway` from a TTY. Some display managers may work but are not supported by +sway (gdm is known to work fairly well). [en]: https://github.com/swaywm/sway#readme [ar]: README.ar.md -[az]: README.az.md [cs]: README.cs.md [de]: README.de.md [dk]: README.dk.md @@ -77,7 +77,6 @@ Run `sway` from a TTY or from a display manager. [pt]: README.pt.md [ro]: README.ro.md [ru]: README.ru.md -[sr]: README.sr.md [sv]: README.sv.md [tr]: README.tr.md [uk]: README.uk.md diff --git a/README.nl.md b/README.nl.md index f2f7bb497..bf1ea9750 100644 --- a/README.nl.md +++ b/README.nl.md @@ -40,7 +40,7 @@ _\* Compileerafhankelijkheden_ Voer deze opdrachten uit: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.no.md b/README.no.md index 77676062d..35d6e320f 100644 --- a/README.no.md +++ b/README.no.md @@ -1,25 +1,29 @@ # Sway -Sway er en [i3]-kompatibel [Wayland]-compositor. Les [Ofte stilte spørsmål]. -Delta på [IRC-kanalen][IRC-kanal] \(#sway på irc.libera.chat). +Sway er en [i3]-kompatibel [Wayland] compositor. Les [Ofte stilte spørsmål]. +Delta på [IRC kanalen][IRC kanal] \(#sway på irc.libera.chat). -## Signaturer +## Utgivelses Signaturer -Utgivelser er signert med [E88F5E48] og publisert [på GitHub][GitHub releases]. +Utgivelser er signert med [E88F5E48] og publisert [på GitHub][GitHub +releases]. ## Installasjon -### Fra systempakker +### Fra system pakker -Sway er tilgjengelig i mange distribusjoner. Prøv å installere pakken "sway" +Sway er tilgjengelig i mange distribusjoner. Prøv å installere "sway" pakken fra din distro sine repoer. +Er du interessert i å pakke Sway for din distribusjon kan du ta turen innom +IRC-kanalen eller send en e-post til sir@cmpwn.com for råd. + ### Kompilering fra kildekode -Se [denne wiki-siden][Oppsetting for utvikling] hvis du vil bygge fra HEAD-grenen av -sway og wlroots for testing eller utvikling. +Se [denne wiki-siden][Oppsetting for utvikling] hvis du vil bygge fra HEAD grenen av sway og +wlroots for testing eller utvikling. -Installer avhengigheter: +Installasjonsavhengigheter: * meson \* * [wlroots] @@ -29,37 +33,36 @@ Installer avhengigheter: * json-c * pango * cairo -* gdk-pixbuf2 (valgfritt: støtte for ekstra bildeformater i system tray) -* [swaybg] (valgfritt: bakgrunnsbilde) +* gdk-pixbuf2 (valgfritt: system tray) * [scdoc] (valgfritt: man pages) \* -* git (valgfritt: versjonsinformasjon) \* +* git \* -_\* Kompileringsavhengigheter_ +_\*Kompileringsavhengigheter_ Kjør følgende kommandoer: - meson setup build/ - ninja -C build/ - sudo ninja -C build/ install + meson build + ninja -C build + sudo ninja -C build install ## Konfigurasjon -Hvis du allerede bruker i3 kan du bare kopiere din i3-konfigurasjon til -`~/.config/sway/config`. Ellers skal du kopiere eksempelkonfigurasjonsfilen til -`~/.config/sway/config`. Eksempelfilen er normalt plasert i `/etc/sway/config`. -Kjør `man 5 sway` for å få opplysninger om konfigurasjonen. +Hvis du allerede bruker i3 kan du bare kopiere din i3 konfigurasjon til +`~/.config/sway/config`. Ellers skal du kopiere eksempel konfigurasjonsfilen til +`~/.config/sway/config`. Eksempel filen er normalt plasert i `/etc/sway/config`. Kjør +`man 5 sway` for å få oplysninger om konfigurasjonen. -## Kjøring +## Utførelse -Kjør `sway` fra en TTY eller fra en display manager. +Kjør `sway` fra en TTY. Noen display managers kan fungere, men Sway har ikke +støtte for dem (gdm er kjent for å fungere ganske bra). [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ [Ofte stilte spørsmål]: https://github.com/swaywm/sway/wiki -[IRC-kanal]: https://web.libera.chat/gamja/?channels=#sway +[IRC kanal]: https://web.libera.chat/gamja/?channels=#sway [E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48 [GitHub releases]: https://github.com/swaywm/sway/releases [Oppsetting for utvikling]: https://github.com/swaywm/sway/wiki/Development-Setup [wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots -[swaybg]: https://github.com/swaywm/swaybg/ [scdoc]: https://git.sr.ht/~sircmpwn/scdoc diff --git a/README.pl.md b/README.pl.md index 0c12a2b86..65b3c3a1b 100644 --- a/README.pl.md +++ b/README.pl.md @@ -40,7 +40,7 @@ _\*zależności kompilacji_ Wykonaj następujące polecenia: - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -53,4 +53,5 @@ Wykonaj polecenie `man 5 sway` aby uzyskać informacje dotyczące konfiguracji. ## Uruchamianie -Wykonaj polecenie `sway` z poziomu TTY lub menedżera wyświetlania. +Wykonaj polecenie `sway` z poziomu TTY. Niektóre menedżery wyświetlania mogą umożliwiać rozruch z ich +poziomu, ale nie jest to wspierane przez sway (w gdm podobno działa to całkiem nieźle). diff --git a/README.pt.md b/README.pt.md index 4660e0bed..c1611a31c 100644 --- a/README.pt.md +++ b/README.pt.md @@ -42,7 +42,7 @@ _\*Dependência de tempo de compilação_ Execute esses comandos: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.ro.md b/README.ro.md index 1f63b5955..a3559a8bb 100644 --- a/README.ro.md +++ b/README.ro.md @@ -38,7 +38,7 @@ Dependențe pentru instalare: Rulați aceste comenzi: ``` - meson setup build + meson build ninja -C build sudo ninja -C build install ``` diff --git a/README.ru.md b/README.ru.md index 5eee59efa..edc0eda78 100644 --- a/README.ru.md +++ b/README.ru.md @@ -41,7 +41,7 @@ _\*Зависимости для сборки_ Выполните эти команды: - meson setup build + meson build ninja -C build sudo ninja -C build install @@ -54,7 +54,8 @@ _\*Зависимости для сборки_ ## Запуск -Выполните команду `sway` прямо из TTY или дисплейного менеджера. +Выполните команду `sway` прямо из TTY. Некоторые дисплейные менеджеры могут работать, но они не поддерживаются со стороны +sway (gdm работает довольно неплохо). [i3]: https://i3wm.org/ [Wayland]: http://wayland.freedesktop.org/ diff --git a/README.sr.md b/README.sr.md deleted file mode 100644 index bd573566a..000000000 --- a/README.sr.md +++ /dev/null @@ -1,65 +0,0 @@ -# sway - -sway је [i3]-компатибилан [Wayland] композитор. Прочитајте [FAQ]. Придружите се -[IRC каналу] \(#sway на irc.libera.chat). - -## Потписи Издања - -Издања су потписана са [E88F5E48] и објављена [на GitHub-у][GitHub releases]. - -## Инсталација - -### Из пакета - -Sway је доступан у многим дистрибуцијама. Покушајте да инсталирате "sway" пакет за -вашу. - -### Компајлирање из Извора - -Погледајте [ову вики страницу][Development setup], ако желите да компајлирате HEAD верзију -sway-а и wlroots-а за тестирање или развој. - -Инсталирајте зависности: - -* meson \* -* [wlroots] -* wayland -* wayland-protocols \* -* pcre2 -* json-c -* pango -* cairo -* gdk-pixbuf2 (опционо: додатни формати слика за системску траку) -* [swaybg] (опционо: позадина) -* [scdoc] (опционо: man странице) \* -* git (опционо: информације о верзији) \* - -_\* Потребно само за компајлирање_ - -Покрените следеће команде: - - meson setup build/ - ninja -C build/ - sudo ninja -C build/ install - -## Конфигурација - -Ако већ користите i3, копирајте вашу i3 конфигурацију у `~/.config/sway/config` и -радиће одмах. У супротном, копирајте пример конфигурационе датотеке у -`~/.config/sway/config`. Обично се налази у `/etc/sway/config`. -Покрените `man 5 sway` за информације о конфигурацији. - -## Покретање - -Покрените `sway` из TTY-a или из менаџера приказа. - -[i3]: https://i3wm.org/ -[Wayland]: http://wayland.freedesktop.org/ -[FAQ]: https://github.com/swaywm/sway/wiki -[IRC каналу]: https://web.libera.chat/gamja/?channels=#sway -[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://gitlab.freedesktop.org/wlroots/wlroots -[swaybg]: https://github.com/swaywm/swaybg/ -[scdoc]: https://git.sr.ht/~sircmpwn/scdoc diff --git a/README.sv.md b/README.sv.md index bff9d4a85..c50ca068c 100644 --- a/README.sv.md +++ b/README.sv.md @@ -1,5 +1,7 @@ # sway +[English][en] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - **[Svenska][sv]** - [Ελληνικά][gr] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW] + sway är en [i3]-kompatibel [Wayland] compositor. Läs våran [FAQ]-sida. Gå med i vår [IRC-kanal] \(#sway på irc.libera.chat). @@ -35,7 +37,7 @@ _\* Krav för kompilering_ Kör dessa kommandon: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.tr.md b/README.tr.md index 3769ee755..40de14748 100644 --- a/README.tr.md +++ b/README.tr.md @@ -38,7 +38,7 @@ _\*Derleme-anı bağımlılıkları_ Şu komutları çalıştırın: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.uk.md b/README.uk.md index 01c43afee..33359cffc 100644 --- a/README.uk.md +++ b/README.uk.md @@ -51,7 +51,7 @@ _\*Лише для компіляції_ Виконайте ці команди: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/README.zh-CN.md b/README.zh-CN.md index b733c71ab..a6f4518ae 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -35,7 +35,7 @@ _\*编译时依赖_ 运行如下命令: - meson setup build/ + meson build/ ninja -C build/ sudo ninja -C build/ install diff --git a/README.zh-TW.md b/README.zh-TW.md index 7cf848ea3..2de2f63fc 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -40,7 +40,7 @@ _\*編譯時相依_ 執行這些指令: - meson setup build + meson build ninja -C build sudo ninja -C build install diff --git a/common/stringop.c b/common/stringop.c index dcbd16564..16d04917e 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -360,7 +360,3 @@ char *format_str(const char *fmt, ...) { va_end(args); return str; } - -bool has_prefix(const char *str, const char *prefix) { - return strncmp(str, prefix, strlen(prefix)) == 0; -} diff --git a/common/util.c b/common/util.c index ae1fe4431..7c492bcbf 100644 --- a/common/util.c +++ b/common/util.c @@ -141,9 +141,3 @@ bool sway_set_cloexec(int fd, bool cloexec) { } return true; } - -uint32_t get_current_time_in_msec(void) { - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - return now.tv_sec * 1000 + now.tv_nsec / 1000000; -} diff --git a/config.in b/config.in index d71bc628b..a2a01dda9 100644 --- a/config.in +++ b/config.in @@ -46,18 +46,14 @@ output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill # # Example configuration: # -# input type:touchpad { +# input "2:14:SynPS/2_Synaptics_TouchPad" { # dwt enabled # tap enabled # natural_scroll enabled # middle_emulation enabled # } # -# input type:keyboard { -# xkb_layout "eu" -# } -# -# You can also configure each device individually. +# You can get the names of your inputs by running: swaymsg -t get_inputs # Read `man 5 sway-input` for more information about this section. ### Key bindings @@ -205,18 +201,9 @@ bindsym $mod+r mode "resize" bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume \@DEFAULT_SINK@ -5% bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume \@DEFAULT_SINK@ +5% bindsym --locked XF86AudioMicMute exec pactl set-source-mute \@DEFAULT_SOURCE@ toggle - - # Special keys to control media via playerctl - bindsym --locked XF86AudioPlay exec playerctl play-pause - bindsym --locked XF86AudioPause exec playerctl play-pause - bindsym --locked XF86AudioPrev exec playerctl previous - bindsym --locked XF86AudioNext exec playerctl next - bindsym --locked XF86AudioStop exec playerctl stop - # Special keys to adjust brightness via brightnessctl bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%- bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+ - # Special key to take a screenshot with grim bindsym Print exec grim diff --git a/include/stringop.h b/include/stringop.h index ffc355cf0..19a50f237 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -40,6 +40,4 @@ bool expand_path(char **path); char *vformat_str(const char *fmt, va_list args) _SWAY_ATTRIB_PRINTF(1, 0); char *format_str(const char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); -bool has_prefix(const char *str, const char *prefix); - #endif diff --git a/include/sway/commands.h b/include/sway/commands.h index 389c382eb..5210d3ba7 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -290,7 +290,6 @@ sway_cmd output_cmd_color_profile; sway_cmd output_cmd_disable; sway_cmd output_cmd_dpms; sway_cmd output_cmd_enable; -sway_cmd output_cmd_hdr; sway_cmd output_cmd_max_render_time; sway_cmd output_cmd_mode; sway_cmd output_cmd_modeline; diff --git a/include/sway/config.h b/include/sway/config.h index 3c380933e..71721393e 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -261,7 +261,7 @@ enum scale_filter_mode { }; enum render_bit_depth { - RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8 for SDR, 10 for HDR + RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8 RENDER_BIT_DEPTH_6, RENDER_BIT_DEPTH_8, RENDER_BIT_DEPTH_10, @@ -291,7 +291,6 @@ struct output_config { bool set_color_transform; struct wlr_color_transform *color_transform; int allow_tearing; - int hdr; char *background; char *background_option; @@ -706,8 +705,6 @@ struct output_config *find_output_config(struct sway_output *output); void free_output_config(struct output_config *oc); void request_modeset(void); -void force_modeset(void); -bool modeset_is_pending(void); bool spawn_swaybg(void); diff --git a/include/sway/criteria.h b/include/sway/criteria.h index fad278e02..ae546821c 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h @@ -53,10 +53,6 @@ struct criteria { char urgent; // 'l' for latest or 'o' for oldest struct pattern *workspace; pid_t pid; - struct pattern *sandbox_engine; - struct pattern *sandbox_app_id; - struct pattern *sandbox_instance_id; - struct pattern *tag; }; bool criteria_is_empty(struct criteria *criteria); diff --git a/include/sway/desktop/idle_inhibit_v1.h b/include/sway/desktop/idle_inhibit_v1.h index 447ac8708..84cc666d0 100644 --- a/include/sway/desktop/idle_inhibit_v1.h +++ b/include/sway/desktop/idle_inhibit_v1.h @@ -13,7 +13,6 @@ enum sway_idle_inhibit_mode { struct sway_idle_inhibit_manager_v1 { struct wlr_idle_inhibit_manager_v1 *wlr_manager; struct wl_listener new_idle_inhibitor_v1; - struct wl_listener manager_destroy; struct wl_list inhibitors; }; diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 5113844d8..b014e18f8 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -39,8 +39,6 @@ struct sway_input_manager { struct sway_input_manager *input_manager_create(struct sway_server *server); -void input_manager_finish(struct sway_input_manager *input); - bool input_manager_has_focus(struct sway_node *node); void input_manager_set_focus(struct sway_node *node); diff --git a/include/sway/input/text_input.h b/include/sway/input/text_input.h index 1818749ad..1993f928f 100644 --- a/include/sway/input/text_input.h +++ b/include/sway/input/text_input.h @@ -25,10 +25,8 @@ struct sway_input_method_relay { struct wlr_input_method_v2 *input_method; // doesn't have to be present struct wl_listener text_input_new; - struct wl_listener text_input_manager_destroy; struct wl_listener input_method_new; - struct wl_listener input_method_manager_destroy; struct wl_listener input_method_commit; struct wl_listener input_method_new_popup_surface; struct wl_listener input_method_grab_keyboard; diff --git a/include/sway/layers.h b/include/sway/layers.h index 27b5dde1b..fd6384e0e 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h @@ -9,6 +9,7 @@ struct sway_layer_surface { struct wl_listener map; struct wl_listener unmap; struct wl_listener surface_commit; + struct wl_listener output_destroy; struct wl_listener node_destroy; struct wl_listener new_popup; @@ -18,8 +19,6 @@ struct sway_layer_surface { struct sway_popup_desc desc; struct sway_output *output; - struct wl_list link; // sway_output.layer_surfaces - struct wlr_scene_layer_surface_v1 *scene; struct wlr_scene_tree *tree; struct wlr_layer_surface_v1 *layer_surface; @@ -42,6 +41,4 @@ struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( void arrange_layers(struct sway_output *output); -void destroy_layers(struct sway_output *output); - #endif diff --git a/include/sway/output.h b/include/sway/output.h index 787527ee7..2a92be999 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -52,25 +52,28 @@ struct sway_output { bool enabled; list_t *workspaces; - struct wl_list layer_surfaces; // sway_layer_surface.link struct sway_output_state current; struct wl_listener layout_destroy; struct wl_listener destroy; + struct wl_listener commit; struct wl_listener present; struct wl_listener frame; struct wl_listener request_state; + struct { + struct wl_signal disable; + } events; + struct wlr_color_transform *color_transform; struct timespec last_presentation; uint32_t refresh_nsec; int max_render_time; // In milliseconds struct wl_event_source *repaint_timer; - + bool gamma_lut_changed; bool allow_tearing; - bool hdr; }; struct sway_output_non_desktop { @@ -90,9 +93,6 @@ struct sway_output *output_from_wlr_output(struct wlr_output *output); struct sway_output *output_get_in_direction(struct sway_output *reference, enum wlr_direction direction); -void output_configure_scene(struct sway_output *output, - struct wlr_scene_node *node, float opacity); - void output_add_workspace(struct sway_output *output, struct sway_workspace *workspace); @@ -131,13 +131,14 @@ struct sway_container *output_find_container(struct sway_output *output, void output_get_box(struct sway_output *output, struct wlr_box *box); -bool output_supports_hdr(struct wlr_output *output, const char **unsupported_reason_ptr); - enum sway_container_layout output_get_default_layout( struct sway_output *output); enum wlr_direction opposite_direction(enum wlr_direction d); + +void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data); + void handle_output_manager_apply(struct wl_listener *listener, void *data); void handle_output_manager_test(struct wl_listener *listener, void *data); diff --git a/include/sway/server.h b/include/sway/server.h index f50d48f05..ccf4a9cc2 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -27,7 +27,7 @@ struct sway_session_lock { struct sway_server { struct wl_display *wl_display; struct wl_event_loop *wl_event_loop; - char *socket; + const char *socket; struct wlr_backend *backend; struct wlr_session *session; @@ -46,7 +46,6 @@ struct sway_server { struct wl_listener new_output; struct wl_listener renderer_lost; - struct wl_event_source *recreating_renderer; struct wlr_idle_notifier_v1 *idle_notifier_v1; struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; @@ -105,24 +104,17 @@ struct sway_server { struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list; 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 *wlr_data_control_manager_v1; - struct wlr_ext_data_control_manager_v1 *ext_data_control_manager_v1; + struct wlr_data_control_manager_v1 *data_control_manager_v1; struct wlr_screencopy_manager_v1 *screencopy_manager_v1; - struct wlr_ext_image_copy_capture_manager_v1 *ext_image_copy_capture_manager_v1; struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1; struct wlr_security_context_manager_v1 *security_context_manager_v1; - struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1 *ext_foreign_toplevel_image_capture_source_manager_v1; - struct wl_listener new_foreign_toplevel_capture_request; - struct wlr_xdg_activation_v1 *xdg_activation_v1; struct wl_listener xdg_activation_v1_request_activate; struct wl_listener xdg_activation_v1_new_token; - struct wl_listener xdg_toplevel_tag_manager_v1_set_tag; - struct wl_listener request_set_cursor_shape; - + struct wlr_tearing_control_manager_v1 *tearing_control_v1; struct wl_listener tearing_control_new_object; struct wl_list tearing_controllers; // sway_tearing_controller::link @@ -156,19 +148,20 @@ struct sway_debug { bool noatomic; // Ignore atomic layout updates bool txn_timings; // Log verbose messages about transactions bool txn_wait; // Always wait for the timeout before applying + bool legacy_wl_drm; // Enable the legacy wl_drm interface }; extern struct sway_debug debug; extern bool allow_unsupported_gpu; -void sway_terminate(int exit_code); - bool server_init(struct sway_server *server); void server_fini(struct sway_server *server); bool server_start(struct sway_server *server); void server_run(struct sway_server *server); +void restore_nofile_limit(void); + void handle_new_output(struct wl_listener *listener, void *data); void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e18fd00ac..4608b8ac2 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -95,7 +95,6 @@ struct sway_container { struct wl_listener output_enter; struct wl_listener output_leave; - struct wl_listener output_handler_destroy; struct sway_container_state current; struct sway_container_state pending; @@ -103,7 +102,7 @@ struct sway_container { char *title; // The view's title (unformatted) char *formatted_title; // The title displayed in the title bar int title_width; - + char *title_format; enum sway_container_layout prev_split_layout; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index ae81c5bbf..f60322212 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -25,7 +25,6 @@ enum sway_view_type { enum sway_view_prop { VIEW_PROP_TITLE, VIEW_PROP_APP_ID, - VIEW_PROP_TAG, VIEW_PROP_CLASS, VIEW_PROP_INSTANCE, VIEW_PROP_WINDOW_TYPE, @@ -70,9 +69,6 @@ struct sway_view { struct wlr_scene_tree *content_tree; struct wlr_scene_tree *saved_surface_tree; - struct wlr_scene *image_capture_scene; - struct wlr_ext_image_capture_source_v1 *image_capture_source; - struct sway_container *container; // NULL if unmapped and transactions finished struct wlr_surface *surface; // NULL for unmapped views struct sway_xdg_decoration *xdg_decoration; @@ -128,9 +124,6 @@ struct sway_view { struct sway_xdg_shell_view { struct sway_view view; - struct wlr_scene_tree *image_capture_tree; - char *tag; - struct wl_listener commit; struct wl_listener request_move; struct wl_listener request_resize; @@ -149,8 +142,6 @@ struct sway_xwayland_view { struct wlr_scene_tree *surface_tree; - struct wlr_scene_surface *image_capture_scene_surface; - struct wl_listener commit; struct wl_listener request_move; struct wl_listener request_resize; @@ -201,12 +192,10 @@ struct sway_popup_desc { struct sway_xdg_popup { struct sway_view *view; - struct wlr_xdg_popup *wlr_xdg_popup; struct wlr_scene_tree *scene_tree; struct wlr_scene_tree *xdg_surface_tree; - - struct wlr_scene_tree *image_capture_tree; + struct wlr_xdg_popup *wlr_xdg_popup; struct sway_popup_desc desc; @@ -232,14 +221,6 @@ const char *view_get_window_role(struct sway_view *view); uint32_t view_get_window_type(struct sway_view *view); -const char *view_get_sandbox_engine(struct sway_view *view); - -const char *view_get_sandbox_app_id(struct sway_view *view); - -const char *view_get_sandbox_instance_id(struct sway_view *view); - -const char *view_get_tag(struct sway_view *view); - const char *view_get_shell(struct sway_view *view); void view_get_constraints(struct sway_view *view, double *min_width, @@ -364,6 +345,4 @@ void view_send_frame_done(struct sway_view *view); bool view_can_tear(struct sway_view *view); -void xdg_toplevel_tag_manager_v1_handle_set_tag(struct wl_listener *listener, void *data); - #endif diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 27ed649fd..58bde20cb 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -96,7 +96,7 @@ void workspace_output_add_priority(struct sway_workspace *workspace, struct sway_output *output); struct sway_output *workspace_output_get_highest_available( - struct sway_workspace *ws); + struct sway_workspace *ws, struct sway_output *exclude); void workspace_detect_urgent(struct sway_workspace *workspace); diff --git a/include/swaybar/config.h b/include/swaybar/config.h index ad58b3c3c..361acd991 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h @@ -14,11 +14,6 @@ struct box_colors { uint32_t text; }; -struct box_size { - uint32_t width; - uint32_t height; -}; - struct config_output { struct wl_list link; // swaybar_config::outputs char *name; diff --git a/include/util.h b/include/util.h index 92f5916cf..f887d4895 100644 --- a/include/util.h +++ b/include/util.h @@ -61,6 +61,4 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel); bool sway_set_cloexec(int fd, bool cloexec); -uint32_t get_current_time_in_msec(void); - #endif diff --git a/meson.build b/meson.build index de5a620c4..61981f45a 100644 --- a/meson.build +++ b/meson.build @@ -1,14 +1,13 @@ project( 'sway', 'c', - version: '1.12-dev', + version: '1.10-rc3', license: 'MIT', - meson_version: '>=1.3', + meson_version: '>=0.60.0', default_options: [ 'c_std=c11', 'warning_level=2', 'werror=true', - 'wrap_mode=nodownload', ], ) @@ -39,14 +38,14 @@ if is_freebsd endif # Execute the wlroots subproject, if any -wlroots_version = ['>=0.20.0', '<0.21.0'] +wlroots_version = ['>=0.18.0', '<0.19.0'] subproject( 'wlroots', default_options: ['examples=false'], required: false, version: wlroots_version, ) -wlroots = dependency('wlroots-0.20', version: wlroots_version, fallback: 'wlroots') +wlroots = dependency('wlroots-0.18', version: wlroots_version, fallback: 'wlroots') wlroots_features = { 'xwayland': false, 'libinput_backend': false, @@ -65,7 +64,7 @@ pcre2 = dependency('libpcre2-8') wayland_server = dependency('wayland-server', version: '>=1.21.0') wayland_client = dependency('wayland-client') wayland_cursor = dependency('wayland-cursor') -wayland_protos = dependency('wayland-protocols', version: '>=1.41', default_options: ['tests=false']) +wayland_protos = dependency('wayland-protocols', version: '>=1.24', default_options: ['tests=false']) xkbcommon = dependency('xkbcommon', version: '>=1.5.0') cairo = dependency('cairo') pango = dependency('pango') @@ -80,7 +79,7 @@ libudev = wlroots_features['libinput_backend'] ? dependency('libudev') : null_de math = cc.find_library('m') rt = cc.find_library('rt') xcb_icccm = wlroots_features['xwayland'] ? dependency('xcb-icccm') : null_dep -threads = dependency('threads') # for pthread_setschedparam and pthread_atfork +threads = dependency('threads') # for pthread_setschedparam if get_option('sd-bus-provider') == 'auto' if not get_option('tray').disabled() @@ -110,9 +109,11 @@ conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind') conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu') conf_data.set10('HAVE_TRAY', have_tray) -foreach sym : ['LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM', 'LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY'] - conf_data.set10('HAVE_' + sym, cc.has_header_symbol('libinput.h', sym, dependencies: libinput)) -endforeach +conf_data.set10('HAVE_LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM', cc.has_header_symbol( + 'libinput.h', + 'LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM', + dependencies: libinput, +)) scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages')) if scdoc.found() @@ -171,10 +172,31 @@ if git.found() endif add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') -fs = import('fs') +# Compute the relative path used by compiler invocations. +source_root = meson.current_source_dir().split('/') +build_root = meson.global_build_root().split('/') +relative_dir_parts = [] +i = 0 +in_prefix = true +foreach p : build_root + if i >= source_root.length() or not in_prefix or p != source_root[i] + in_prefix = false + relative_dir_parts += '..' + endif + i += 1 +endforeach +i = 0 +in_prefix = true +foreach p : source_root + if i >= build_root.length() or not in_prefix or build_root[i] != p + in_prefix = false + relative_dir_parts += p + endif + i += 1 +endforeach +relative_dir = join_paths(relative_dir_parts) + '/' # Strip relative path prefixes from the code if possible, otherwise hide them. -relative_dir = fs.relative_to(meson.current_source_dir(), meson.global_build_root()) + '/' if cc.has_argument('-fmacro-prefix-map=/prefix/to/hide=') add_project_arguments( '-fmacro-prefix-map=@0@='.format(relative_dir), diff --git a/protocols/meson.build b/protocols/meson.build index e7ada59b8..d96f87575 100644 --- a/protocols/meson.build +++ b/protocols/meson.build @@ -9,8 +9,12 @@ wayland_scanner = find_program( protocols = [ wl_protocol_dir / 'stable/tablet/tablet-v2.xml', wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', - wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', wl_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml', + wl_protocol_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml', + wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', + wl_protocol_dir / 'staging/content-type/content-type-v1.xml', + wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml', + wl_protocol_dir / 'staging/tearing-control/tearing-control-v1.xml', 'wlr-layer-shell-unstable-v1.xml', 'idle.xml', 'wlr-output-power-management-unstable-v1.xml', diff --git a/release.sh b/release.sh index 6ad8f2c5e..c5644cfd0 100755 --- a/release.sh +++ b/release.sh @@ -1,7 +1,7 @@ #!/bin/sh -eu prev=$(git describe --tags --abbrev=0) -next=$(meson rewrite kwargs info project / | jq -r '.kwargs["project#/"].version') +next=$(meson rewrite kwargs info project / 2>&1 >/dev/null | jq -r '.kwargs["project#/"].version') case "$next" in *-dev) diff --git a/sway.desktop b/sway.desktop index cc7fcee73..420db5aa1 100644 --- a/sway.desktop +++ b/sway.desktop @@ -3,4 +3,3 @@ Name=Sway Comment=An i3-compatible Wayland compositor Exec=sway Type=Application -DesktopNames=sway;wlroots diff --git a/sway/commands/assign.c b/sway/commands/assign.c index 5bcbb1644..bf95cf002 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c @@ -23,7 +23,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) { --argc; ++argv; - if (has_prefix(*argv, "→")) { + if (strncmp(*argv, "→", strlen("→")) == 0) { if (argc < 2) { free(criteria); return cmd_results_new(CMD_INVALID, "Missing workspace"); diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c index 51ca20ed5..0c074679a 100644 --- a/sway/commands/bar/font.c +++ b/sway/commands/bar/font.c @@ -11,7 +11,7 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) { char *font = join_args(argv, argc); free(config->current_bar->font); - if (has_prefix(font, "pango:")) { + if (strncmp(font, "pango:", 6) == 0) { if (config->current_bar->pango_markup == PANGO_MARKUP_DEFAULT) { config->current_bar->pango_markup = true; } diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 15373d5a8..268f28553 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -367,7 +367,8 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, } } else if (strcmp("--exclude-titlebar", argv[0]) == 0) { exclude_titlebar = true; - } else if (has_prefix(argv[0], "--input-device=")) { + } else if (strncmp("--input-device=", argv[0], + strlen("--input-device=")) == 0) { free(binding->input); binding->input = strdup(argv[0] + strlen("--input-device=")); strip_quotes(binding->input); @@ -398,7 +399,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, list_t *split = split_string(argv[0], "+"); for (int i = 0; i < split->length; ++i) { // Check for group - if (has_prefix(split->items[i], "Group")) { + if (strncmp(split->items[i], "Group", strlen("Group")) == 0) { if (binding->group != XKB_LAYOUT_INVALID) { free_sway_binding(binding); list_free_items_and_destroy(split); diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index a966696c5..8bc1048cd 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -25,6 +25,16 @@ struct cmd_results *cmd_exec_validate(int argc, char **argv) { return error; } +static void export_xdga_token(struct launcher_ctx *ctx) { + const char *token = launcher_ctx_get_token_name(ctx); + setenv("XDG_ACTIVATION_TOKEN", token, 1); +} + +static void export_startup_id(struct launcher_ctx *ctx) { + const char *token = launcher_ctx_get_token_name(ctx); + setenv("DESKTOP_STARTUP_ID", token, 1); +} + struct cmd_results *cmd_exec_process(int argc, char **argv) { struct cmd_results *error = NULL; char *cmd = NULL; @@ -46,37 +56,67 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { sway_log(SWAY_DEBUG, "Executing %s", cmd); + int fd[2]; + if (pipe(fd) != 0) { + sway_log(SWAY_ERROR, "Unable to create pipe for fork"); + } + + pid_t pid, child; struct launcher_ctx *ctx = launcher_ctx_create_internal(); - // Fork process - pid_t child = fork(); - if (child == 0) { + if ((pid = fork()) == 0) { + // Fork child process again + restore_nofile_limit(); setsid(); - - if (ctx) { - const char *token = launcher_ctx_get_token_name(ctx); - setenv("XDG_ACTIVATION_TOKEN", token, 1); - if (!no_startup_id) { - setenv("DESKTOP_STARTUP_ID", token, 1); + sigset_t set; + sigemptyset(&set); + sigprocmask(SIG_SETMASK, &set, NULL); + signal(SIGPIPE, SIG_DFL); + close(fd[0]); + if ((child = fork()) == 0) { + close(fd[1]); + if (ctx) { + export_xdga_token(ctx); } + if (ctx && !no_startup_id) { + export_startup_id(ctx); + } + execlp("sh", "sh", "-c", cmd, (void *)NULL); + sway_log_errno(SWAY_ERROR, "execlp failed"); + _exit(1); } - - execlp("sh", "sh", "-c", cmd, (void*)NULL); - sway_log_errno(SWAY_ERROR, "execve failed"); + ssize_t s = 0; + while ((size_t)s < sizeof(pid_t)) { + s += write(fd[1], ((uint8_t *)&child) + s, sizeof(pid_t) - s); + } + close(fd[1]); _exit(0); // Close child process - } else if (child < 0) { - launcher_ctx_destroy(ctx); + } else if (pid < 0) { free(cmd); + close(fd[0]); + close(fd[1]); return cmd_results_new(CMD_FAILURE, "fork() failed"); } - - sway_log(SWAY_DEBUG, "Child process created with pid %d", child); - if (ctx != NULL) { - sway_log(SWAY_DEBUG, "Recording workspace for process %d", child); - ctx->pid = child; + free(cmd); + close(fd[1]); // close write + ssize_t s = 0; + while ((size_t)s < sizeof(pid_t)) { + s += read(fd[0], ((uint8_t *)&child) + s, sizeof(pid_t) - s); + } + close(fd[0]); + // cleanup child process + waitpid(pid, NULL, 0); + if (child > 0) { + sway_log(SWAY_DEBUG, "Child process created with pid %d", child); + if (ctx != NULL) { + sway_log(SWAY_DEBUG, "Recording workspace for process %d", child); + ctx->pid = child; + } + } else { + launcher_ctx_destroy(ctx); + return cmd_results_new(CMD_FAILURE, "Second fork() failed"); } - free(cmd); return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/exit.c b/sway/commands/exit.c index 0f326cea6..10cde640c 100644 --- a/sway/commands/exit.c +++ b/sway/commands/exit.c @@ -1,7 +1,8 @@ #include #include "sway/commands.h" #include "sway/config.h" -#include "sway/server.h" + +void sway_terminate(int exit_code); struct cmd_results *cmd_exit(int argc, char **argv) { struct cmd_results *error = NULL; diff --git a/sway/commands/font.c b/sway/commands/font.c index 842e8ae61..9920d03eb 100644 --- a/sway/commands/font.c +++ b/sway/commands/font.c @@ -13,9 +13,9 @@ struct cmd_results *cmd_font(int argc, char **argv) { char *font = join_args(argv, argc); free(config->font); - if (has_prefix(font, "pango:")) { + if (strncmp(font, "pango:", 6) == 0) { config->pango_markup = true; - config->font = strdup(font + strlen("pango:")); + config->font = strdup(font + 6); free(font); } else { config->pango_markup = false; diff --git a/sway/commands/gesture.c b/sway/commands/gesture.c index 8dff29a34..90a20716d 100644 --- a/sway/commands/gesture.c +++ b/sway/commands/gesture.c @@ -121,7 +121,8 @@ static struct cmd_results *cmd_bind_or_unbind_gesture(int argc, char **argv, boo binding->flags |= BINDING_EXACT; } else if (strcmp("--no-warn", argv[0]) == 0) { warn = false; - } else if (has_prefix(argv[0], "--input-device=")) { + } else if (strncmp("--input-device=", argv[0], + strlen("--input-device=")) == 0) { free(binding->input); binding->input = strdup(argv[0] + strlen("--input-device=")); } else { diff --git a/sway/commands/include.c b/sway/commands/include.c index e0d0c0640..d4c14c35f 100644 --- a/sway/commands/include.c +++ b/sway/commands/include.c @@ -3,12 +3,12 @@ struct cmd_results *cmd_include(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "include", EXPECTED_AT_LEAST, 1))) { + if ((error = checkarg(argc, "include", EXPECTED_EQUAL_TO, 1))) { return error; } - char *files = join_args(argv, argc); + // We don't care if the included config(s) fails to load. - load_include_configs(files, config, &config->swaynag_config_errors); + load_include_configs(argv[0], config, &config->swaynag_config_errors); return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c index 915a7ada1..24c548e2d 100644 --- a/sway/commands/input/drag_lock.c +++ b/sway/commands/input/drag_lock.c @@ -15,11 +15,6 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, "No input device defined."); } -#if HAVE_LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY - if (strcmp(argv[0], "enabled_sticky") == 0) { - ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY; - } else -#endif if (parse_boolean(argv[0], true)) { ic->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; } else { diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c index 4650108a1..3cea026ec 100644 --- a/sway/commands/input/events.c +++ b/sway/commands/input/events.c @@ -86,7 +86,7 @@ static void toggle_select_send_events_for_device(struct input_config *ic, static void toggle_send_events(int argc, char **argv) { struct input_config *ic = config->handler_context.input_config; bool wildcard = strcmp(ic->identifier, "*") == 0; - const char *type = has_prefix(ic->identifier, "type:") + const char *type = strncmp(ic->identifier, "type:", strlen("type:")) == 0 ? ic->identifier + strlen("type:") : NULL; struct sway_input_device *device = NULL; wl_list_for_each(device, &server.input->devices, link) { @@ -146,7 +146,8 @@ struct cmd_results *input_cmd_events(int argc, char **argv) { toggle_send_events(argc - 1, argv + 1); - if (strcmp(ic->identifier, "*") == 0 || has_prefix(ic->identifier, "type:")) { + if (strcmp(ic->identifier, "*") == 0 || + strncmp(ic->identifier, "type:", strlen("type:")) == 0) { // Update the device input configs and then reset the type/wildcard // config send events mode so that is does not override the device // ones. The device ones will be applied when attempting to apply diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 22dfdf3d7..12ce48398 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -134,19 +134,6 @@ struct cmd_results *cmd_layout(int argc, char **argv) { // Operate on parent container, like i3. if (container) { container = container->pending.parent; - // If parent has only a singe child operate on its parent and - // flatten once, like i3 - if (container && container->pending.children->length == 1) { - // Also check grandparent to avoid restricting layouts - struct sway_container *parent = container->pending.parent; - if (parent && parent->pending.children->length == 1) { - struct sway_container *child = container->pending.children->items[0]; - struct sway_container *parent = container->pending.parent; - container_replace(container, child); - container_begin_destroy(container); - container = parent; - } - } } // We could be working with a container OR a workspace. These are different diff --git a/sway/commands/mark.c b/sway/commands/mark.c index 77c8d2394..2bfc86b30 100644 --- a/sway/commands/mark.c +++ b/sway/commands/mark.c @@ -23,7 +23,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) { } bool add = false, toggle = false; - while (argc > 0 && has_prefix(*argv, "--")) { + while (argc > 0 && strncmp(*argv, "--", 2) == 0) { if (strcmp(*argv, "--add") == 0) { add = true; } else if (strcmp(*argv, "--replace") == 0) { diff --git a/sway/commands/move.c b/sway/commands/move.c index 90e8585b4..8891514ce 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -222,7 +222,6 @@ static void container_move_to_workspace(struct sway_container *container, container_detach(container); if (workspace_is_empty(workspace) && container->pending.children) { workspace_unwrap_children(workspace, container); - container_reap_empty(container); } else { container->pending.width = container->pending.height = 0; container->width_fraction = container->height_fraction = 0; diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index de058c6b8..610cecc6d 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c @@ -2,8 +2,7 @@ #include #include #include "sway/commands.h" -#include "sway/tree/container.h" -#include "sway/output.h" +#include "sway/tree/view.h" #include "log.h" struct cmd_results *cmd_opacity(int argc, char **argv) { @@ -38,7 +37,6 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { } con->alpha = val; - output_configure_scene(NULL, &con->scene_tree->node, 1); container_update(con); return cmd_results_new(CMD_SUCCESS, NULL); diff --git a/sway/commands/output.c b/sway/commands/output.c index afff23f6a..9d58413f2 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -15,7 +15,6 @@ static const struct cmd_handler output_handlers[] = { { "disable", output_cmd_disable }, { "dpms", output_cmd_dpms }, { "enable", output_cmd_enable }, - { "hdr", output_cmd_hdr }, { "max_render_time", output_cmd_max_render_time }, { "mode", output_cmd_mode }, { "modeline", output_cmd_modeline }, diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index fe1621626..55bd7671f 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c @@ -3,8 +3,10 @@ #include #include #include +#include #include "sway/commands.h" #include "sway/config.h" +#include "sway/swaynag.h" #include "log.h" #include "stringop.h" @@ -40,14 +42,14 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { } struct output_config *output = config->handler_context.output_config; - char *src = NULL; + if (strcasecmp(argv[1], "solid_color") == 0) { if (!validate_color(argv[0])) { return cmd_results_new(CMD_INVALID, "Colors should be of the form #RRGGBB"); } - if (!(output->background = strdup(argv[0]))) goto cleanup; - if (!(output->background_option = strdup("solid_color"))) goto cleanup; + output->background = strdup(argv[0]); + output->background_option = strdup("solid_color"); output->background_fallback = NULL; argc -= 2; argv += 2; } else { @@ -75,25 +77,37 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Missing background file"); } - if (!(src = join_args(argv, j))) goto cleanup; + char *src = join_args(argv, j); if (!expand_path(&src)) { struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "Invalid syntax (%s)", src); free(src); return cmd_res; } + if (!src) { + sway_log(SWAY_ERROR, "Failed to allocate expanded path"); + return cmd_results_new(CMD_FAILURE, "Unable to allocate resource"); + } if (config->reading && *src != '/') { // src file is inside configuration dir char *conf = strdup(config->current_config_path); - if (!conf) goto cleanup; + if (!conf) { + sway_log(SWAY_ERROR, "Failed to duplicate string"); + free(src); + return cmd_results_new(CMD_FAILURE, + "Unable to allocate resources"); + } char *conf_path = dirname(conf); char *real_src = malloc(strlen(conf_path) + strlen(src) + 2); if (!real_src) { + free(src); free(conf); - goto cleanup; + sway_log(SWAY_ERROR, "Unable to allocate memory"); + return cmd_results_new(CMD_FAILURE, + "Unable to allocate resources"); } snprintf(real_src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, src); @@ -103,48 +117,40 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { } bool can_access = access(src, F_OK) != -1; - argc -= j + 1; argv += j + 1; - free(output->background_option); - free(output->background_fallback); - free(output->background); - output->background = output->background_option = output->background_fallback = NULL; - char *fallback = NULL; - - if (argc && *argv[0] == '#') { - if (validate_color(argv[0])) { - if (!(fallback = strdup(argv[0]))) goto cleanup; - output->background_fallback = fallback; - } else { - sway_log(SWAY_ERROR, "fallback '%s' should be of the form #RRGGBB", argv[0]); - config_add_swaynag_warning("fallback '%s' should be of the form #RRGGBB\n", argv[0]); - } - argc--; argv++; - } - if (!can_access) { - if (!fallback) { - sway_log(SWAY_ERROR, "Unable to access background file '%s' " - "and no valid fallback provided", src); - struct cmd_results *res = cmd_results_new(CMD_FAILURE, "Unable to access " - "background file '%s' and no valid fallback provided", src); - free(src); - return res; - } - sway_log(SWAY_DEBUG, "Cannot access file '%s', using fallback '%s'", src, fallback); - output->background = fallback; - if (!(output->background_option = strdup("solid_color"))) goto cleanup; - output->background_fallback = NULL; + sway_log_errno(SWAY_ERROR, "Unable to access background file '%s'", + src); + config_add_swaynag_warning("Unable to access background file '%s'", + src); + struct cmd_results *result = cmd_results_new(CMD_FAILURE, + "unable to access background file '%s'", src); + free(src); + return result; } else { output->background = src; - if (!(output->background_option = strdup(mode))) goto cleanup; + output->background_option = strdup(mode); + } + argc -= j + 1; argv += j + 1; + + output->background_fallback = NULL; + if (argc && *argv[0] == '#') { + if (!validate_color(argv[0])) { + return cmd_results_new(CMD_INVALID, + "fallback color should be of the form #RRGGBB"); + } + + output->background_fallback = strdup(argv[0]); + argc--; argv++; + + if (!can_access) { + output->background = output->background_fallback; + output->background_option = strdup("solid_color"); + output->background_fallback = NULL; + } } } + config->handler_context.leftovers.argc = argc; config->handler_context.leftovers.argv = argv; return NULL; - -cleanup: - free(src); - sway_log(SWAY_ERROR, "Failed to allocate resources"); - return cmd_results_new(CMD_FAILURE, "Unable to allocate resources"); } diff --git a/sway/commands/output/hdr.c b/sway/commands/output/hdr.c deleted file mode 100644 index 26d202216..000000000 --- a/sway/commands/output/hdr.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include "sway/commands.h" -#include "sway/config.h" -#include "sway/output.h" -#include "util.h" - -struct cmd_results *output_cmd_hdr(int argc, char **argv) { - if (!config->handler_context.output_config) { - return cmd_results_new(CMD_FAILURE, "Missing output config"); - } - if (argc == 0) { - return cmd_results_new(CMD_INVALID, "Missing hdr argument"); - } - - bool current = false; - 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 *output = all_output_by_name_or_id(oc_name); - if (!output) { - return cmd_results_new(CMD_FAILURE, - "Cannot apply toggle to unknown output %s", oc_name); - } - - current = output->hdr; - } - - config->handler_context.output_config->hdr = parse_boolean(argv[0], current); - - config->handler_context.leftovers.argc = argc - 1; - config->handler_context.leftovers.argv = argv + 1; - return NULL; -} diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 3530ee5a8..32b746eaf 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -80,46 +80,61 @@ void container_resize_tiled(struct sway_container *con, } // For HORIZONTAL or VERTICAL, we are growing in two directions so select - // all adjacent siblings. For RIGHT or DOWN or LEFT or UP select just the - // previous or next sibling. - list_t *resize = create_list(); + // both adjacent siblings. For RIGHT or DOWN, just select the next sibling. + // For LEFT or UP, convert it to a RIGHT or DOWN resize and reassign con to + // the previous sibling. + struct sway_container *prev = NULL; + struct sway_container *next = NULL; list_t *siblings = container_get_siblings(con); int index = container_sibling_index(con); if (axis == AXIS_HORIZONTAL || axis == AXIS_VERTICAL) { - list_cat(resize, siblings); + if (index == 0) { + next = siblings->items[1]; + } else if (index == siblings->length - 1) { + // Convert edge to top/left + next = con; + con = siblings->items[index - 1]; + amount = -amount; + } else { + prev = siblings->items[index - 1]; + next = siblings->items[index + 1]; + } } else if (axis == WLR_EDGE_TOP || axis == WLR_EDGE_LEFT) { if (!sway_assert(index > 0, "Didn't expect first child")) { - goto cleanup; + return; } - list_add(resize, siblings->items[index - 1]); - list_add(resize, con); + next = con; + con = siblings->items[index - 1]; + amount = -amount; } else { if (!sway_assert(index < siblings->length - 1, "Didn't expect last child")) { - goto cleanup; + return; } - list_add(resize, con); - list_add(resize, siblings->items[index + 1]); + next = siblings->items[index + 1]; } // Apply new dimensions - int sibling_amount = ceil((double)amount / (double)(resize->length - 1)); + int sibling_amount = prev ? ceil((double)amount / 2.0) : amount; if (is_horizontal(axis)) { - for (int i = 0; i < resize->length; i++) { - struct sway_container *sibling = resize->items[i]; - double change = sibling == con ? amount : -sibling_amount; - if (sibling->pending.width + change < MIN_SANE_W) { - goto cleanup; - } + if (con->pending.width + amount < MIN_SANE_W) { + return; + } + if (next->pending.width - sibling_amount < MIN_SANE_W) { + return; + } + if (prev && prev->pending.width - sibling_amount < MIN_SANE_W) { + return; } if (con->child_total_width <= 0) { - goto cleanup; + return; } // We're going to resize so snap all the width fractions to full pixels // to avoid rounding issues + list_t *siblings = container_get_siblings(con); for (int i = 0; i < siblings->length; ++i) { struct sway_container *con = siblings->items[i]; con->width_fraction = con->pending.width / con->child_total_width; @@ -127,27 +142,30 @@ void container_resize_tiled(struct sway_container *con, double amount_fraction = (double)amount / con->child_total_width; double sibling_amount_fraction = - amount_fraction / (double)(resize->length - 1); + prev ? amount_fraction / 2.0 : amount_fraction; - for (int i = 0; i < resize->length; i++) { - struct sway_container *sibling = resize->items[i]; - sibling->width_fraction += - sibling == con ? amount_fraction : -sibling_amount_fraction; + con->width_fraction += amount_fraction; + next->width_fraction -= sibling_amount_fraction; + if (prev) { + prev->width_fraction -= sibling_amount_fraction; } } else { - for (int i = 0; i < resize->length; i++) { - struct sway_container *sibling = resize->items[i]; - double change = sibling == con ? amount : -sibling_amount; - if (sibling->pending.height + change < MIN_SANE_H) { - goto cleanup; - } + if (con->pending.height + amount < MIN_SANE_H) { + return; + } + if (next->pending.height - sibling_amount < MIN_SANE_H) { + return; + } + if (prev && prev->pending.height - sibling_amount < MIN_SANE_H) { + return; } if (con->child_total_height <= 0) { - goto cleanup; + return; } // We're going to resize so snap all the height fractions to full pixels // to avoid rounding issues + list_t *siblings = container_get_siblings(con); for (int i = 0; i < siblings->length; ++i) { struct sway_container *con = siblings->items[i]; con->height_fraction = con->pending.height / con->child_total_height; @@ -155,12 +173,12 @@ void container_resize_tiled(struct sway_container *con, double amount_fraction = (double)amount / con->child_total_height; double sibling_amount_fraction = - amount_fraction / (double)(resize->length - 1); + prev ? amount_fraction / 2.0 : amount_fraction; - for (int i = 0; i < resize->length; i++) { - struct sway_container *sibling = resize->items[i]; - sibling->height_fraction += - sibling == con ? amount_fraction : -sibling_amount_fraction; + con->height_fraction += amount_fraction; + next->height_fraction -= sibling_amount_fraction; + if (prev) { + prev->height_fraction -= sibling_amount_fraction; } } @@ -169,9 +187,6 @@ void container_resize_tiled(struct sway_container *con, } else { arrange_workspace(con->pending.workspace); } - -cleanup: - list_free(resize); } /** @@ -442,7 +457,7 @@ static struct cmd_results *cmd_resize_set(int argc, char **argv) { if (argc > num_consumed_args) { return cmd_results_new(CMD_INVALID, "%s", usage); } - if (height.unit == MOVEMENT_UNIT_INVALID) { + if (width.unit == MOVEMENT_UNIT_INVALID) { return cmd_results_new(CMD_INVALID, "%s", usage); } } diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index 8a63740c3..c995f2f08 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -118,10 +118,10 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { // If using criteria, this command is executed for every container which // matches the criteria. If this container isn't in the scratchpad, - // we'll return an error. The same is true if the + // we'll just silently return a success. The same is true if the // overridden node is not a container. if (!con || !con->scratchpad) { - return cmd_results_new(CMD_INVALID, "Container is not in scratchpad."); + return cmd_results_new(CMD_SUCCESS, NULL); } scratchpad_toggle_container(con); } else { diff --git a/sway/commands/ws_auto_back_and_forth.c b/sway/commands/ws_auto_back_and_forth.c index 5827c389d..e4411c8ed 100644 --- a/sway/commands/ws_auto_back_and_forth.c +++ b/sway/commands/ws_auto_back_and_forth.c @@ -8,7 +8,7 @@ struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { if ((error = checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1))) { return error; } - config->auto_back_and_forth = + config->auto_back_and_forth = parse_boolean(argv[0], config->auto_back_and_forth); return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/config.c b/sway/config.c index d579022d3..1090edc5c 100644 --- a/sway/config.c +++ b/sway/config.c @@ -552,12 +552,28 @@ bool load_main_config(const char *file, bool is_active, bool validating) { return success; } -static bool load_include_config(const char *path, struct sway_config *config, - struct swaynag_instance *swaynag) { +static bool load_include_config(const char *path, const char *parent_dir, + struct sway_config *config, struct swaynag_instance *swaynag) { // save parent config const char *parent_config = config->current_config_path; - char *real_path = realpath(path, NULL); + char *full_path; + int len = strlen(path); + if (len >= 1 && path[0] != '/') { + len = len + strlen(parent_dir) + 2; + full_path = malloc(len * sizeof(char)); + if (!full_path) { + sway_log(SWAY_ERROR, + "Unable to allocate full path to included config"); + return false; + } + snprintf(full_path, len, "%s/%s", parent_dir, path); + } else { + full_path = strdup(path); + } + + char *real_path = realpath(full_path, NULL); + free(full_path); if (real_path == NULL) { sway_log(SWAY_DEBUG, "%s not found.", path); @@ -609,7 +625,7 @@ void load_include_configs(const char *path, struct sway_config *config, char **w = p.we_wordv; size_t i; for (i = 0; i < p.we_wordc; ++i) { - load_include_config(w[i], config, swaynag); + load_include_config(w[i], parent_dir, config, swaynag); } wordfree(&p); } @@ -909,8 +925,8 @@ char *do_var_replacement(char *str) { // Find matching variable for (i = 0; i < config->symbols->length; ++i) { struct sway_variable *var = config->symbols->items[i]; - if (has_prefix(find, var->name)) { - int vnlen = strlen(var->name); + int vnlen = strlen(var->name); + if (strncmp(find, var->name, vnlen) == 0) { int vvlen = strlen(var->value); char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); if (!newstr) { diff --git a/sway/config/bar.c b/sway/config/bar.c index f4efb276c..ecefb61af 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -213,21 +213,36 @@ static void invoke_swaybar(struct bar_config *bar) { sway_log(SWAY_ERROR, "Failed to create fork for swaybar"); return; } else if (pid == 0) { - if (!sway_set_cloexec(sockets[1], false)) { + // Remove the SIGUSR1 handler that wlroots adds for xwayland + sigset_t set; + sigemptyset(&set); + sigprocmask(SIG_SETMASK, &set, NULL); + signal(SIGPIPE, SIG_DFL); + + restore_nofile_limit(); + + pid = fork(); + if (pid < 0) { + sway_log_errno(SWAY_ERROR, "fork failed"); + _exit(EXIT_FAILURE); + } else if (pid == 0) { + if (!sway_set_cloexec(sockets[1], false)) { + _exit(EXIT_FAILURE); + } + + char wayland_socket_str[16]; + snprintf(wayland_socket_str, sizeof(wayland_socket_str), + "%d", sockets[1]); + setenv("WAYLAND_SOCKET", wayland_socket_str, true); + + // run custom swaybar + char *const cmd[] = { + bar->swaybar_command ? bar->swaybar_command : "swaybar", + "-b", bar->id, NULL}; + execvp(cmd[0], cmd); _exit(EXIT_FAILURE); } - - char wayland_socket_str[16]; - snprintf(wayland_socket_str, sizeof(wayland_socket_str), - "%d", sockets[1]); - setenv("WAYLAND_SOCKET", wayland_socket_str, true); - - // run custom swaybar - char *const cmd[] = { - bar->swaybar_command ? bar->swaybar_command : "swaybar", - "-b", bar->id, NULL}; - execvp(cmd[0], cmd); - _exit(EXIT_FAILURE); + _exit(EXIT_SUCCESS); } if (close(sockets[1]) != 0) { @@ -235,6 +250,11 @@ static void invoke_swaybar(struct bar_config *bar) { return; } + if (waitpid(pid, NULL, 0) < 0) { + sway_log_errno(SWAY_ERROR, "waitpid failed"); + return; + } + sway_log(SWAY_DEBUG, "Spawned swaybar %s", bar->id); } diff --git a/sway/config/input.c b/sway/config/input.c index 1fb737b65..e5694effc 100644 --- a/sway/config/input.c +++ b/sway/config/input.c @@ -300,7 +300,7 @@ struct input_config *store_input_config(struct input_config *ic, return NULL; } - bool type = has_prefix(ic->identifier, "type:"); + bool type = strncmp(ic->identifier, "type:", strlen("type:")) == 0; if (type && error && !validate_type_on_existing(ic, error)) { return NULL; } diff --git a/sway/config/output.c b/sway/config/output.c index ed8147b8b..8e2528c80 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -67,7 +66,7 @@ struct output_config *new_output_config(const char *name) { oc->refresh_rate = -1; oc->custom_mode = -1; oc->drm_mode.type = -1; - oc->x = oc->y = INT_MAX; + oc->x = oc->y = -1; oc->scale = -1; oc->scale_filter = SCALE_FILTER_DEFAULT; oc->transform = -1; @@ -79,7 +78,6 @@ struct output_config *new_output_config(const char *name) { oc->color_transform = NULL; oc->power = -1; oc->allow_tearing = -1; - oc->hdr = -1; return oc; } @@ -94,11 +92,11 @@ static void supersede_output_config(struct output_config *dst, struct output_con if (src->height != -1) { dst->height = -1; } - if (src->x != INT_MAX) { - dst->x = INT_MAX; + if (src->x != -1) { + dst->x = -1; } - if (src->y != INT_MAX) { - dst->y = INT_MAX; + if (src->y != -1) { + dst->y = -1; } if (src->scale != -1) { dst->scale = -1; @@ -130,13 +128,6 @@ static void supersede_output_config(struct output_config *dst, struct output_con if (src->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { dst->render_bit_depth = RENDER_BIT_DEPTH_DEFAULT; } - if (src->set_color_transform) { - if (dst->color_transform) { - wlr_color_transform_unref(dst->color_transform); - dst->color_transform = NULL; - } - dst->set_color_transform = false; - } if (src->background) { free(dst->background); dst->background = NULL; @@ -152,12 +143,6 @@ static void supersede_output_config(struct output_config *dst, struct output_con if (src->power != -1) { dst->power = -1; } - if (src->allow_tearing != -1) { - dst->allow_tearing = -1; - } - if (src->hdr != -1) { - dst->hdr = -1; - } } // merge_output_config sets all fields in dst that were set in src @@ -171,10 +156,10 @@ static void merge_output_config(struct output_config *dst, struct output_config if (src->height != -1) { dst->height = src->height; } - if (src->x != INT_MAX) { + if (src->x != -1) { dst->x = src->x; } - if (src->y != INT_MAX) { + if (src->y != -1) { dst->y = src->y; } if (src->scale != -1) { @@ -233,9 +218,6 @@ static void merge_output_config(struct output_config *dst, struct output_config if (src->allow_tearing != -1) { dst->allow_tearing = src->allow_tearing; } - if (src->hdr != -1) { - dst->hdr = src->hdr; - } } void store_output_config(struct output_config *oc) { @@ -278,11 +260,11 @@ void store_output_config(struct output_config *oc) { sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) " - "(max render time: %d) (allow tearing: %d) (hdr: %d)", + "(max render time: %d) (allow tearing: %d)", oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel), oc->transform, oc->background, oc->background_option, oc->power, - oc->max_render_time, oc->allow_tearing, oc->hdr); + oc->max_render_time, oc->allow_tearing); // If the configuration was not merged into an existing configuration, add // it to the list. Otherwise we're done with it and can free it. @@ -303,6 +285,7 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending mhz = mhz <= 0 ? INT_MAX : mhz; if (wl_list_empty(&output->modes) || custom) { + sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); wlr_output_state_set_custom_mode(pending, width, height, refresh_rate > 0 ? mhz : 0); return; @@ -322,7 +305,10 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending } } } - if (!best) { + if (best) { + sway_log(SWAY_INFO, "Assigning configured mode (%dx%d@%.3fHz) to %s", + best->width, best->height, best->refresh / 1000.f, output->name); + } else { best = wlr_output_preferred_mode(output); sway_log(SWAY_INFO, "Configured mode (%dx%d@%.3fHz) not available, " "applying preferred mode (%dx%d@%.3fHz)", @@ -339,6 +325,7 @@ static void set_modeline(struct wlr_output *output, sway_log(SWAY_ERROR, "Modeline can only be set to DRM output"); return; } + sway_log(SWAY_DEBUG, "Assigning custom modeline to %s", output->name); struct wlr_output_mode *mode = wlr_drm_connector_add_mode(output, drm_mode); if (mode) { wlr_output_state_set_mode(pending, mode); @@ -348,45 +335,6 @@ static void set_modeline(struct wlr_output *output, #endif } -bool output_supports_hdr(struct wlr_output *output, const char **unsupported_reason_ptr) { - const char *unsupported_reason = NULL; - if (!(output->supported_primaries & WLR_COLOR_NAMED_PRIMARIES_BT2020)) { - unsupported_reason = "BT2020 primaries not supported by output"; - } else if (!(output->supported_transfer_functions & WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ)) { - unsupported_reason = "PQ transfer function not supported by output"; - } else if (!server.renderer->features.output_color_transform) { - unsupported_reason = "renderer doesn't support output color transforms"; - } - if (unsupported_reason_ptr != NULL) { - *unsupported_reason_ptr = unsupported_reason; - } - return unsupported_reason == NULL; -} - -static void set_hdr(struct wlr_output *output, struct wlr_output_state *pending, bool enabled) { - const char *unsupported_reason = NULL; - if (enabled && !output_supports_hdr(output, &unsupported_reason)) { - sway_log(SWAY_ERROR, "Cannot enable HDR on output %s: %s", - output->name, unsupported_reason); - enabled = false; - } - - if (!enabled) { - if (output->supported_primaries != 0 || output->supported_transfer_functions != 0) { - sway_log(SWAY_DEBUG, "Disabling HDR on output %s", output->name); - wlr_output_state_set_image_description(pending, NULL); - } - return; - } - - sway_log(SWAY_DEBUG, "Enabling HDR on output %s", output->name); - const struct wlr_output_image_description image_desc = { - .primaries = WLR_COLOR_NAMED_PRIMARIES_BT2020, - .transfer_function = WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ, - }; - wlr_output_state_set_image_description(pending, &image_desc); -} - /* Some manufacturers hardcode the aspect-ratio of the output in the physical * size field. */ static bool phys_size_is_aspect_ratio(struct wlr_output *output) { @@ -443,6 +391,7 @@ static int compute_default_scale(struct wlr_output *output, double dpi_x = (double) width / (output->phys_width / MM_PER_INCH); double dpi_y = (double) height / (output->phys_height / MM_PER_INCH); + sway_log(SWAY_DEBUG, "Output DPI: %fx%f", dpi_x, dpi_y); if (dpi_x <= HIDPI_DPI_LIMIT || dpi_y <= HIDPI_DPI_LIMIT) { return 1; } @@ -461,16 +410,6 @@ static enum render_bit_depth bit_depth_from_format(uint32_t render_format) { return RENDER_BIT_DEPTH_DEFAULT; } -static enum render_bit_depth get_config_render_bit_depth(const struct output_config *oc) { - if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { - return oc->render_bit_depth; - } - if (oc && oc->hdr == 1) { - return RENDER_BIT_DEPTH_10; - } - return RENDER_BIT_DEPTH_8; -} - static bool render_format_is_bgr(uint32_t fmt) { return fmt == DRM_FORMAT_XBGR2101010 || fmt == DRM_FORMAT_XBGR8888; } @@ -488,82 +427,96 @@ static void queue_output_config(struct output_config *oc, struct wlr_output *wlr_output = output->wlr_output; if (output_config_is_disabling(oc)) { + sway_log(SWAY_DEBUG, "Turning off output %s", wlr_output->name); wlr_output_state_set_enabled(pending, false); return; } + + sway_log(SWAY_DEBUG, "Turning on output %s", wlr_output->name); wlr_output_state_set_enabled(pending, true); if (oc && oc->drm_mode.type != 0 && oc->drm_mode.type != (uint32_t) -1) { + sway_log(SWAY_DEBUG, "Set %s modeline", + wlr_output->name); set_modeline(wlr_output, pending, &oc->drm_mode); } else if (oc && oc->width > 0 && oc->height > 0) { + sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)", + wlr_output->name, oc->width, oc->height, oc->refresh_rate); set_mode(wlr_output, pending, oc->width, oc->height, oc->refresh_rate, oc->custom_mode == 1); } else if (!wl_list_empty(&wlr_output->modes)) { + sway_log(SWAY_DEBUG, "Set preferred mode"); struct wlr_output_mode *preferred_mode = wlr_output_preferred_mode(wlr_output); wlr_output_state_set_mode(pending, preferred_mode); } - if (oc && oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) { + if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) { + sway_log(SWAY_DEBUG, "Set %s subpixel to %s", oc->name, + sway_wl_output_subpixel_to_string(oc->subpixel)); wlr_output_state_set_subpixel(pending, oc->subpixel); - } else { - wlr_output_state_set_subpixel(pending, output->detected_subpixel); } + enum wl_output_transform tr = WL_OUTPUT_TRANSFORM_NORMAL; if (oc && oc->transform >= 0) { - wlr_output_state_set_transform(pending, oc->transform); + tr = oc->transform; #if WLR_HAS_DRM_BACKEND } else if (wlr_output_is_drm(wlr_output)) { - wlr_output_state_set_transform(pending, - wlr_drm_connector_get_panel_orientation(wlr_output)); + tr = wlr_drm_connector_get_panel_orientation(wlr_output); + sway_log(SWAY_DEBUG, "Auto-detected output transform: %d", tr); #endif - } else { - wlr_output_state_set_transform(pending, WL_OUTPUT_TRANSFORM_NORMAL); + } + if (wlr_output->transform != tr) { + sway_log(SWAY_DEBUG, "Set %s transform to %d", wlr_output->name, tr); + wlr_output_state_set_transform(pending, tr); } - // Apply the scale after sorting out the mode, because the scale - // auto-detection reads the pending output size + // Apply the scale last before the commit, because the scale auto-detection + // reads the pending output size + float scale; if (oc && oc->scale > 0) { + scale = oc->scale; + // The factional-scale-v1 protocol uses increments of 120ths to send // the scale factor to the client. Adjust the scale so that we use the // same value as the clients'. - wlr_output_state_set_scale(pending, round(oc->scale * 120) / 120); + float adjusted_scale = round(scale * 120) / 120; + if (scale != adjusted_scale) { + sway_log(SWAY_INFO, "Adjusting output scale from %f to %f", + scale, adjusted_scale); + scale = adjusted_scale; + } } else { - wlr_output_state_set_scale(pending, - compute_default_scale(wlr_output, pending)); + scale = compute_default_scale(wlr_output, pending); + sway_log(SWAY_DEBUG, "Auto-detected output scale: %f", scale); + } + if (scale != wlr_output->scale) { + sway_log(SWAY_DEBUG, "Set %s scale to %f", wlr_output->name, scale); + wlr_output_state_set_scale(pending, scale); } - if (wlr_output->adaptive_sync_supported) { - if (oc && oc->adaptive_sync != -1) { - wlr_output_state_set_adaptive_sync_enabled(pending, oc->adaptive_sync == 1); + if (oc && oc->adaptive_sync != -1 && wlr_output->adaptive_sync_supported) { + sway_log(SWAY_DEBUG, "Set %s adaptive sync to %d", wlr_output->name, + oc->adaptive_sync); + wlr_output_state_set_adaptive_sync_enabled(pending, oc->adaptive_sync == 1); + } + + if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { + if (oc->render_bit_depth == RENDER_BIT_DEPTH_10 && + bit_depth_from_format(output->wlr_output->render_format) == oc->render_bit_depth) { + // 10-bit was set successfully before, try to save some tests by reusing the format + wlr_output_state_set_render_format(pending, output->wlr_output->render_format); + } else if (oc->render_bit_depth == RENDER_BIT_DEPTH_10) { + wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB2101010); + } else if (oc->render_bit_depth == RENDER_BIT_DEPTH_6){ + wlr_output_state_set_render_format(pending, DRM_FORMAT_RGB565); } else { - wlr_output_state_set_adaptive_sync_enabled(pending, false); + wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB8888); } } - - enum render_bit_depth render_bit_depth = get_config_render_bit_depth(oc); - if (render_bit_depth == RENDER_BIT_DEPTH_10 && - bit_depth_from_format(output->wlr_output->render_format) == render_bit_depth) { - // 10-bit was set successfully before, try to save some tests by reusing the format - wlr_output_state_set_render_format(pending, output->wlr_output->render_format); - } else if (render_bit_depth == RENDER_BIT_DEPTH_10) { - wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB2101010); - } else if (render_bit_depth == RENDER_BIT_DEPTH_6) { - wlr_output_state_set_render_format(pending, DRM_FORMAT_RGB565); - } else { - wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB8888); - } - - bool hdr = oc && oc->hdr == 1; - if (hdr && oc->color_transform != NULL) { - sway_log(SWAY_ERROR, "Cannot HDR on output %s: output has an ICC profile set", wlr_output->name); - hdr = false; - } - set_hdr(wlr_output, pending, hdr); } -static bool finalize_output_config(struct output_config *oc, struct sway_output *output, - const struct wlr_output_state *applied) { +static bool finalize_output_config(struct output_config *oc, struct sway_output *output) { if (output == root->fallback_output) { return false; } @@ -578,64 +531,69 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output return true; } - enum scale_filter_mode scale_filter_old = output->scale_filter; - enum scale_filter_mode scale_filter_new = oc ? oc->scale_filter : SCALE_FILTER_DEFAULT; - switch (scale_filter_new) { - case SCALE_FILTER_DEFAULT: - case SCALE_FILTER_SMART: - output->scale_filter = ceilf(wlr_output->scale) == wlr_output->scale ? - SCALE_FILTER_NEAREST : SCALE_FILTER_LINEAR; - break; - case SCALE_FILTER_LINEAR: - case SCALE_FILTER_NEAREST: - output->scale_filter = scale_filter_new; - break; - } - if (scale_filter_old != output->scale_filter) { - sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, - sway_output_scale_filter_to_string(output->scale_filter)); - wlr_damage_ring_add_whole(&output->scene_output->damage_ring); + if (oc) { + enum scale_filter_mode scale_filter_old = output->scale_filter; + switch (oc->scale_filter) { + case SCALE_FILTER_DEFAULT: + case SCALE_FILTER_SMART: + output->scale_filter = ceilf(wlr_output->scale) == wlr_output->scale ? + SCALE_FILTER_NEAREST : SCALE_FILTER_LINEAR; + break; + case SCALE_FILTER_LINEAR: + case SCALE_FILTER_NEAREST: + output->scale_filter = oc->scale_filter; + break; + } + if (scale_filter_old != output->scale_filter) { + sway_log(SWAY_DEBUG, "Set %s scale_filter to %s", oc->name, + sway_output_scale_filter_to_string(output->scale_filter)); + wlr_damage_ring_add_whole(&output->scene_output->damage_ring); + } } // Find position for it - if (oc && oc->x != INT_MAX && oc->y != INT_MAX) { + if (oc && (oc->x != -1 || oc->y != -1)) { sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y); } else { wlr_output_layout_add_auto(root->output_layout, wlr_output); } + // Update output->{lx, ly, width, height} + struct wlr_box output_box; + wlr_output_layout_get_box(root->output_layout, wlr_output, &output_box); + output->lx = output_box.x; + output->ly = output_box.y; + output->width = output_box.width; + output->height = output_box.height; + if (!output->enabled) { output_enable(output); } + if (oc && oc->max_render_time >= 0) { + sway_log(SWAY_DEBUG, "Set %s max render time to %d", + oc->name, oc->max_render_time); + output->max_render_time = oc->max_render_time; + } + if (oc && oc->set_color_transform) { if (oc->color_transform) { wlr_color_transform_ref(oc->color_transform); } wlr_color_transform_unref(output->color_transform); output->color_transform = oc->color_transform; - } else { - wlr_color_transform_unref(output->color_transform); - output->color_transform = NULL; } - output->max_render_time = oc && oc->max_render_time > 0 ? oc->max_render_time : 0; - output->allow_tearing = oc && oc->allow_tearing > 0; - output->hdr = applied->image_description != NULL; + if (oc && oc->allow_tearing >= 0) { + sway_log(SWAY_DEBUG, "Set %s allow tearing to %d", + oc->name, oc->allow_tearing); + output->allow_tearing = oc->allow_tearing; + } return true; } -static void output_update_position(struct sway_output *output) { - struct wlr_box output_box; - wlr_output_layout_get_box(root->output_layout, output->wlr_output, &output_box); - output->lx = output_box.x; - output->ly = output_box.y; - output->width = output_box.width; - output->height = output_box.height; -} - // find_output_config_from_list returns a merged output_config containing all // stored configuration that applies to the specified output. static struct output_config *find_output_config_from_list( @@ -647,6 +605,15 @@ static struct output_config *find_output_config_from_list( return NULL; } + // Set output defaults for the "base" configuration + result->enabled = 1; + result->power = 1; + result->scale = 0; // auto + result->subpixel = sway_output->detected_subpixel; + result->transform = WL_OUTPUT_TRANSFORM_NORMAL; + result->max_render_time = 0; + result->allow_tearing = 0; + char id[128]; output_get_identifier(id, sizeof(id), sway_output); @@ -725,13 +692,6 @@ static void dump_output_state(struct wlr_output *wlr_output, struct wlr_output_s sway_log(SWAY_DEBUG, " adaptive_sync: %s", state->adaptive_sync_enabled ? "enabled": "disabled"); } - if (state->committed & WLR_OUTPUT_STATE_SCALE) { - sway_log(SWAY_DEBUG, " scale: %f", state->scale); - } - if (state->committed & WLR_OUTPUT_STATE_SUBPIXEL) { - sway_log(SWAY_DEBUG, " subpixel: %s", - sway_wl_output_subpixel_to_string(state->subpixel)); - } } static bool search_valid_config(struct search_context *ctx, size_t output_idx); @@ -846,15 +806,17 @@ static bool search_render_format(struct search_context *ctx, size_t output_idx) } const struct wlr_drm_format_set *primary_formats = - wlr_output_get_primary_formats(wlr_output, server.allocator->buffer_caps); - enum render_bit_depth needed_bits = get_config_render_bit_depth(cfg->config); + wlr_output_get_primary_formats(wlr_output, WLR_BUFFER_CAP_DMABUF); + enum render_bit_depth needed_bits = RENDER_BIT_DEPTH_8; + if (cfg->config && cfg->config->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { + needed_bits = cfg->config->render_bit_depth; + } for (size_t idx = 0; fmts[idx] != DRM_FORMAT_INVALID; idx++) { enum render_bit_depth format_bits = bit_depth_from_format(fmts[idx]); if (needed_bits < format_bits) { continue; } - // If primary_formats is NULL, all formats are supported - if (primary_formats && !wlr_drm_format_set_get(primary_formats, fmts[idx])) { + if (!wlr_drm_format_set_get(primary_formats, fmts[idx])) { // This is not a supported format for this output continue; } @@ -944,8 +906,9 @@ static bool apply_resolved_output_configs(struct matched_output_config *configs, backend_state->output = cfg->output->wlr_output; wlr_output_state_init(&backend_state->base); + sway_log(SWAY_DEBUG, "Preparing config for %s", + cfg->output->wlr_output->name); queue_output_config(cfg->config, cfg->output, &backend_state->base); - dump_output_state(cfg->output->wlr_output, &backend_state->base); } struct wlr_output_swapchain_manager swapchain_mgr; @@ -1002,17 +965,9 @@ static bool apply_resolved_output_configs(struct matched_output_config *configs, for (size_t idx = 0; idx < configs_len; idx++) { struct matched_output_config *cfg = &configs[idx]; - struct wlr_backend_output_state *backend_state = &states[idx]; sway_log(SWAY_DEBUG, "Finalizing config for %s", cfg->output->wlr_output->name); - finalize_output_config(cfg->config, cfg->output, &backend_state->base); - } - - // Output layout being applied in finalize_output_config can shift outputs - // around, so we do a second pass to update positions and arrange. - for (size_t idx = 0; idx < configs_len; idx++) { - struct matched_output_config *cfg = &configs[idx]; - output_update_position(cfg->output); + finalize_output_config(cfg->config, cfg->output); arrange_layers(cfg->output); } @@ -1088,7 +1043,6 @@ void free_output_config(struct output_config *oc) { free(oc->name); free(oc->background); free(oc->background_option); - free(oc->background_fallback); wlr_color_transform_unref(oc->color_transform); free(oc); } @@ -1130,27 +1084,42 @@ static bool _spawn_swaybg(char **command) { sway_log_errno(SWAY_ERROR, "fork failed"); return false; } else if (pid == 0) { - if (!sway_set_cloexec(sockets[1], false)) { + restore_nofile_limit(); + + pid = fork(); + if (pid < 0) { + sway_log_errno(SWAY_ERROR, "fork failed"); + _exit(EXIT_FAILURE); + } else if (pid == 0) { + if (!sway_set_cloexec(sockets[1], false)) { + _exit(EXIT_FAILURE); + } + + char wayland_socket_str[16]; + snprintf(wayland_socket_str, sizeof(wayland_socket_str), + "%d", sockets[1]); + setenv("WAYLAND_SOCKET", wayland_socket_str, true); + + execvp(command[0], command); + sway_log_errno(SWAY_ERROR, "failed to execute '%s' " + "(background configuration probably not applied)", + command[0]); _exit(EXIT_FAILURE); } - - char wayland_socket_str[16]; - snprintf(wayland_socket_str, sizeof(wayland_socket_str), - "%d", sockets[1]); - setenv("WAYLAND_SOCKET", wayland_socket_str, true); - - execvp(command[0], command); - sway_log_errno(SWAY_ERROR, "failed to execute '%s' " - "(background configuration probably not applied)", - command[0]); - _exit(EXIT_FAILURE); + _exit(EXIT_SUCCESS); } if (close(sockets[1]) != 0) { sway_log_errno(SWAY_ERROR, "close failed"); return false; } - return true; + int fork_status = 0; + if (waitpid(pid, &fork_status, 0) < 0) { + sway_log_errno(SWAY_ERROR, "waitpid failed"); + return false; + } + + return WIFEXITED(fork_status) && WEXITSTATUS(fork_status) == EXIT_SUCCESS; } bool spawn_swaybg(void) { diff --git a/sway/criteria.c b/sway/criteria.c index e200d4c8f..2b7290c0e 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -34,11 +34,7 @@ bool criteria_is_empty(struct criteria *criteria) { && !criteria->tiling && !criteria->urgent && !criteria->workspace - && !criteria->pid - && !criteria->sandbox_engine - && !criteria->sandbox_app_id - && !criteria->sandbox_instance_id - && !criteria->tag; + && !criteria->pid; } // The error pointer is used for parsing functions, and saves having to pass it @@ -102,10 +98,6 @@ void criteria_destroy(struct criteria *criteria) { #endif pattern_destroy(criteria->con_mark); pattern_destroy(criteria->workspace); - pattern_destroy(criteria->sandbox_engine); - pattern_destroy(criteria->sandbox_app_id); - pattern_destroy(criteria->sandbox_instance_id); - pattern_destroy(criteria->tag); free(criteria->target); free(criteria->cmdlist); free(criteria->raw); @@ -256,86 +248,6 @@ static bool criteria_matches_view(struct criteria *criteria, } } - if (criteria->sandbox_engine) { - const char *sandbox_engine = view_get_sandbox_engine(view); - if (!sandbox_engine) { - return false; - } - - switch (criteria->sandbox_engine->match_type) { - case PATTERN_FOCUSED: - if (focused && lenient_strcmp(sandbox_engine, view_get_sandbox_engine(focused))) { - return false; - } - break; - case PATTERN_PCRE2: - if (regex_cmp(sandbox_engine, criteria->sandbox_engine->regex) < 0) { - return false; - } - break; - } - } - - if (criteria->sandbox_app_id) { - const char *sandbox_app_id = view_get_sandbox_app_id(view); - if (!sandbox_app_id) { - return false; - } - - switch (criteria->sandbox_app_id->match_type) { - case PATTERN_FOCUSED: - if (focused && lenient_strcmp(sandbox_app_id, view_get_sandbox_app_id(focused))) { - return false; - } - break; - case PATTERN_PCRE2: - if (regex_cmp(sandbox_app_id, criteria->sandbox_app_id->regex) < 0) { - return false; - } - break; - } - } - - if (criteria->sandbox_instance_id) { - const char *sandbox_instance_id = view_get_sandbox_instance_id(view); - if (!sandbox_instance_id) { - return false; - } - - switch (criteria->sandbox_instance_id->match_type) { - case PATTERN_FOCUSED: - if (focused && lenient_strcmp(sandbox_instance_id, view_get_sandbox_instance_id(focused))) { - return false; - } - break; - case PATTERN_PCRE2: - if (regex_cmp(sandbox_instance_id, criteria->sandbox_instance_id->regex) < 0) { - return false; - } - break; - } - } - - if (criteria->tag) { - const char *tag = view_get_tag(view); - if (!tag) { - return false; - } - - switch (criteria->tag->match_type) { - case PATTERN_FOCUSED: - if (focused && lenient_strcmp(tag, view_get_tag(focused))) { - return false; - } - break; - case PATTERN_PCRE2: - if (regex_cmp(tag, criteria->tag->regex) < 0) { - return false; - } - break; - } - } - if (!criteria_matches_container(criteria, view->container)) { return false; } @@ -563,10 +475,6 @@ enum criteria_token { T_URGENT, T_WORKSPACE, T_PID, - T_SANDBOX_ENGINE, - T_SANDBOX_APP_ID, - T_SANDBOX_INSTANCE_ID, - T_TAG, T_INVALID, }; @@ -606,14 +514,6 @@ static enum criteria_token token_from_name(char *name) { return T_FLOATING; } else if (strcmp(name, "pid") == 0) { return T_PID; - } else if (strcmp(name, "sandbox_engine") == 0) { - return T_SANDBOX_ENGINE; - } else if (strcmp(name, "sandbox_app_id") == 0) { - return T_SANDBOX_APP_ID; - } else if (strcmp(name, "sandbox_instance_id") == 0) { - return T_SANDBOX_INSTANCE_ID; - } else if (strcmp(name, "tag") == 0) { - return T_TAG; } return T_INVALID; } @@ -655,7 +555,8 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { if (strcmp(value, "__focused__") == 0) { struct sway_seat *seat = input_manager_current_seat(); struct sway_container *focus = seat_get_focused_container(seat); - criteria->con_id = focus ? focus->node.id : 0; + struct sway_view *view = focus ? focus->view : NULL; + criteria->con_id = view ? view->container->node.id : 0; } else { criteria->con_id = strtoul(value, &endptr, 10); if (*endptr != 0) { @@ -716,18 +617,6 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { error = strdup("The value for 'pid' should be numeric"); } break; - case T_SANDBOX_ENGINE: - pattern_create(&criteria->sandbox_engine, value); - break; - case T_SANDBOX_APP_ID: - pattern_create(&criteria->sandbox_app_id, value); - break; - case T_SANDBOX_INSTANCE_ID: - pattern_create(&criteria->sandbox_instance_id, value); - break; - case T_TAG: - pattern_create(&criteria->tag, value); - break; case T_INVALID: break; } diff --git a/sway/desktop/idle_inhibit_v1.c b/sway/desktop/idle_inhibit_v1.c index 6b2761fcd..f3af7aa1b 100644 --- a/sway/desktop/idle_inhibit_v1.c +++ b/sway/desktop/idle_inhibit_v1.c @@ -1,6 +1,5 @@ #include #include -#include #include "log.h" #include "sway/desktop/idle_inhibit_v1.h" #include "sway/input/seat.h" @@ -45,14 +44,6 @@ void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data) { sway_idle_inhibit_v1_check_active(); } -void handle_manager_destroy(struct wl_listener *listener, void *data) { - struct sway_idle_inhibit_manager_v1 *manager = - wl_container_of(listener, manager, manager_destroy); - - wl_list_remove(&manager->manager_destroy.link); - wl_list_remove(&manager->new_idle_inhibitor_v1.link); -} - void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view, enum sway_idle_inhibit_mode mode) { struct sway_idle_inhibit_manager_v1 *manager = &server.idle_inhibit_manager_v1; @@ -112,34 +103,11 @@ void sway_idle_inhibit_v1_user_inhibitor_destroy( } bool sway_idle_inhibit_v1_is_active(struct sway_idle_inhibitor_v1 *inhibitor) { - if (server.session_lock.lock) { - // A session lock is active. In this case, only application inhibitors - // on the session lock surface can have any effect. - if (inhibitor->mode != INHIBIT_IDLE_APPLICATION) { - return false; - } - struct wlr_surface *wlr_surface = inhibitor->wlr_inhibitor->surface; - if (!wlr_session_lock_surface_v1_try_from_wlr_surface(wlr_surface)) { - return false; - } - return wlr_surface->mapped; - } - switch (inhibitor->mode) { case INHIBIT_IDLE_APPLICATION:; - struct wlr_surface *wlr_surface = inhibitor->wlr_inhibitor->surface; - struct wlr_layer_surface_v1 *layer_surface = - wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface); - if (layer_surface) { - // Layer surfaces can be occluded but are always on screen after - // they have been mapped. - return layer_surface->output && layer_surface->output->enabled && - wlr_surface->mapped; - } - - // If there is no view associated with the inhibitor, assume invisible - struct sway_view *view = view_from_wlr_surface(wlr_surface); - return view && view->container && view_is_visible(view); + // If there is no view associated with the inhibitor, assume visible + struct sway_view *view = view_from_wlr_surface(inhibitor->wlr_inhibitor->surface); + return !view || !view->container || view_is_visible(view); case INHIBIT_IDLE_FOCUS:; struct sway_seat *seat = NULL; wl_list_for_each(seat, &server.input->seats, link) { @@ -185,9 +153,6 @@ bool sway_idle_inhibit_manager_v1_init(void) { wl_signal_add(&manager->wlr_manager->events.new_inhibitor, &manager->new_idle_inhibitor_v1); manager->new_idle_inhibitor_v1.notify = handle_idle_inhibitor_v1; - wl_signal_add(&manager->wlr_manager->events.destroy, - &manager->manager_destroy); - manager->manager_destroy.notify = handle_manager_destroy; wl_list_init(&manager->inhibitors); return true; diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 8c54d71aa..b136a24e7 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -54,7 +54,7 @@ struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( } static void arrange_surface(struct sway_output *output, const struct wlr_box *full_area, - struct wlr_box *usable_area, struct wlr_scene_tree *tree, bool exclusive) { + struct wlr_box *usable_area, struct wlr_scene_tree *tree) { struct wlr_scene_node *node; wl_list_for_each(node, &tree->children, link) { struct sway_layer_surface *surface = scene_descriptor_try_get(node, @@ -68,10 +68,6 @@ static void arrange_surface(struct sway_output *output, const struct wlr_box *fu continue; } - if ((surface->scene->layer_surface->current.exclusive_zone > 0) != exclusive) { - continue; - } - wlr_scene_layer_surface_v1_configure(surface->scene, full_area, usable_area); } } @@ -82,15 +78,10 @@ void arrange_layers(struct sway_output *output) { &usable_area.width, &usable_area.height); const struct wlr_box full_area = usable_area; - arrange_surface(output, &full_area, &usable_area, output->layers.shell_overlay, true); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_top, true); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_bottom, true); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_background, true); - - arrange_surface(output, &full_area, &usable_area, output->layers.shell_overlay, false); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_top, false); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_bottom, false); - arrange_surface(output, &full_area, &usable_area, output->layers.shell_background, false); + arrange_surface(output, &full_area, &usable_area, output->layers.shell_background); + arrange_surface(output, &full_area, &usable_area, output->layers.shell_bottom); + arrange_surface(output, &full_area, &usable_area, output->layers.shell_top); + arrange_surface(output, &full_area, &usable_area, output->layers.shell_overlay); if (!wlr_box_equal(&usable_area, &output->usable_area)) { sway_log(SWAY_DEBUG, "Usable area changed, rearranging output"); @@ -216,6 +207,14 @@ static struct sway_layer_surface *find_mapped_layer_by_client( return NULL; } +static void handle_output_destroy(struct wl_listener *listener, void *data) { + struct sway_layer_surface *layer = + wl_container_of(listener, layer, output_destroy); + + layer->output = NULL; + wlr_scene_node_destroy(&layer->scene->tree->node); +} + static void handle_node_destroy(struct wl_listener *listener, void *data) { struct sway_layer_surface *layer = wl_container_of(listener, layer, node_destroy); @@ -248,11 +247,10 @@ static void handle_node_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&layer->unmap.link); wl_list_remove(&layer->surface_commit.link); wl_list_remove(&layer->node_destroy.link); - wl_list_remove(&layer->new_popup.link); + wl_list_remove(&layer->output_destroy.link); layer->layer_surface->data = NULL; - wl_list_remove(&layer->link); free(layer); } @@ -261,8 +259,12 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, surface, surface_commit); struct wlr_layer_surface_v1 *layer_surface = surface->layer_surface; + if (!layer_surface->initialized) { + return; + } + uint32_t committed = layer_surface->current.committed; - if (layer_surface->initialized && committed & WLR_LAYER_SURFACE_V1_STATE_LAYER) { + if (committed & WLR_LAYER_SURFACE_V1_STATE_LAYER) { enum zwlr_layer_shell_v1_layer layer_type = layer_surface->current.layer; struct wlr_scene_tree *output_layer = sway_layer_get_scene( surface->output, layer_type); @@ -467,7 +469,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { } surface->output = output; - wl_list_insert(&output->layer_surfaces, &surface->link); // now that the surface's output is known, we can advertise its scale wlr_fractional_scale_v1_notify_scale(surface->layer_surface->surface, @@ -485,14 +486,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { surface->new_popup.notify = handle_new_popup; wl_signal_add(&layer_surface->events.new_popup, &surface->new_popup); + surface->output_destroy.notify = handle_output_destroy; + wl_signal_add(&output->events.disable, &surface->output_destroy); + surface->node_destroy.notify = handle_node_destroy; wl_signal_add(&scene_surface->tree->node.events.destroy, &surface->node_destroy); } - -void destroy_layers(struct sway_output *output) { - struct sway_layer_surface *layer, *layer_tmp; - wl_list_for_each_safe(layer, layer_tmp, &output->layer_surfaces, link) { - layer->output = NULL; - wlr_layer_surface_v1_destroy(layer->layer_surface); - } -} diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 12dc9cc7a..35a61bd0f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -97,11 +98,11 @@ struct buffer_timer { }; static int handle_buffer_timer(void *data) { - struct wlr_scene_surface *scene_surface = data; + struct wlr_scene_buffer *buffer = data; struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - wlr_scene_surface_send_frame_done(scene_surface, &now); + wlr_scene_buffer_send_frame_done(buffer, &now); return 0; } @@ -114,9 +115,7 @@ static void handle_buffer_timer_destroy(struct wl_listener *listener, free(timer); } -static struct buffer_timer *buffer_timer_get_or_create(struct wlr_scene_surface *scene_surface) { - struct wlr_scene_buffer *buffer = scene_surface->buffer; - +static struct buffer_timer *buffer_timer_get_or_create(struct wlr_scene_buffer *buffer) { struct buffer_timer *timer = scene_descriptor_try_get(&buffer->node, SWAY_SCENE_DESC_BUFFER_TIMER); if (timer) { @@ -129,7 +128,7 @@ static struct buffer_timer *buffer_timer_get_or_create(struct wlr_scene_surface } timer->frame_done_timer = wl_event_loop_add_timer(server.wl_event_loop, - handle_buffer_timer, scene_surface); + handle_buffer_timer, buffer); if (!timer->frame_done_timer) { free(timer); return NULL; @@ -153,11 +152,6 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer, return; } - struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(buffer); - if (scene_surface == NULL) { - return; - } - struct wlr_scene_node *current = &buffer->node; while (true) { struct sway_view *view = scene_descriptor_try_get(current, @@ -180,13 +174,13 @@ static void send_frame_done_iterator(struct wlr_scene_buffer *buffer, struct buffer_timer *timer = NULL; if (output->max_render_time != 0 && view_max_render_time != 0 && delay > 0) { - timer = buffer_timer_get_or_create(scene_surface); + timer = buffer_timer_get_or_create(buffer); } if (timer) { wl_event_source_timer_update(timer->frame_done_timer, delay); } else { - wlr_scene_surface_send_frame_done(scene_surface, &data->when); + wlr_scene_buffer_send_frame_done(buffer, &data->when); } } @@ -194,8 +188,8 @@ static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output, struct wlr_scene_buffer *buffer) { // if we are scaling down, we should always choose linear if (buffer->dst_width > 0 && buffer->dst_height > 0 && ( - buffer->dst_width < buffer->WLR_PRIVATE.buffer_width || - buffer->dst_height < buffer->WLR_PRIVATE.buffer_height)) { + buffer->dst_width < buffer->buffer_width || + buffer->dst_height < buffer->buffer_height)) { return WLR_SCALE_FILTER_BILINEAR; } @@ -209,7 +203,7 @@ static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output, } } -void output_configure_scene(struct sway_output *output, +static void output_configure_scene(struct sway_output *output, struct wlr_scene_node *node, float opacity) { if (!node->enabled) { return; @@ -236,9 +230,7 @@ void output_configure_scene(struct sway_output *output, // hack: don't call the scene setter because that will damage all outputs // We don't want to damage outputs that aren't our current output that // we're configuring - if (output) { - buffer->filter_mode = get_scale_filter(output, buffer); - } + buffer->filter_mode = get_scale_filter(output, buffer); wlr_scene_buffer_set_opacity(buffer, opacity); } else if (node->type == WLR_SCENE_NODE_TREE) { @@ -270,29 +262,47 @@ static bool output_can_tear(struct sway_output *output) { static int output_repaint_timer_handler(void *data) { struct sway_output *output = data; - output->wlr_output->frame_pending = false; - if (!output->wlr_output->enabled) { + if (!output->enabled) { return 0; } + output->wlr_output->frame_pending = false; + output_configure_scene(output, &root->root_scene->tree.node, 1.0f); struct wlr_scene_output_state_options opts = { .color_transform = output->color_transform, }; + struct wlr_output *wlr_output = output->wlr_output; struct wlr_scene_output *scene_output = output->scene_output; - if (!wlr_scene_output_needs_frame(scene_output)) { + if (!wlr_output->needs_frame && !output->gamma_lut_changed && + !pixman_region32_not_empty(&scene_output->pending_commit_damage)) { return 0; } struct wlr_output_state pending; wlr_output_state_init(&pending); if (!wlr_scene_output_build_state(output->scene_output, &pending, &opts)) { - wlr_output_state_finish(&pending); return 0; } + if (output->gamma_lut_changed) { + output->gamma_lut_changed = false; + struct wlr_gamma_control_v1 *gamma_control = + wlr_gamma_control_manager_v1_get_control( + server.gamma_control_manager_v1, output->wlr_output); + if (!wlr_gamma_control_v1_apply(gamma_control, &pending)) { + wlr_output_state_finish(&pending); + return 0; + } + + if (!wlr_output_test_state(output->wlr_output, &pending)) { + wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); + wlr_output_state_set_gamma_lut(&pending, 0, NULL, NULL, NULL); + } + } + if (output_can_tear(output)) { pending.tearing_page_flip = true; @@ -416,43 +426,27 @@ void request_modeset(void) { } } -bool modeset_is_pending(void) { - return server.delayed_modeset != NULL; -} - -void force_modeset(void) { - if (server.delayed_modeset != NULL) { - wl_event_source_remove(server.delayed_modeset); - server.delayed_modeset = NULL; - } - apply_stored_output_configs(); -} - static void begin_destroy(struct sway_output *output) { + if (output->enabled) { + output_disable(output); + } + + output_begin_destroy(output); + + wl_list_remove(&output->link); wl_list_remove(&output->layout_destroy.link); wl_list_remove(&output->destroy.link); + wl_list_remove(&output->commit.link); wl_list_remove(&output->present.link); wl_list_remove(&output->frame.link); wl_list_remove(&output->request_state.link); - // Remove the scene_output first to ensure that the scene does not emit - // events for this output. wlr_scene_output_destroy(output->scene_output); output->scene_output = NULL; - - if (output->enabled) { - output_disable(output); - } - output_begin_destroy(output); - wl_list_remove(&output->link); - output->wlr_output->data = NULL; output->wlr_output = NULL; - wl_event_source_remove(output->repaint_timer); - output->repaint_timer = NULL; - request_modeset(); } @@ -466,6 +460,20 @@ static void handle_layout_destroy(struct wl_listener *listener, void *data) { begin_destroy(output); } +static void handle_commit(struct wl_listener *listener, void *data) { + struct sway_output *output = wl_container_of(listener, output, commit); + struct wlr_output_event_commit *event = data; + + if (!output->enabled) { + return; + } + + // Next time the output is enabled, try to re-apply the gamma LUT + if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) { + output->gamma_lut_changed = true; + } +} + static void handle_present(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, present); struct wlr_output_event_present *output_event = data; @@ -474,7 +482,7 @@ static void handle_present(struct wl_listener *listener, void *data) { return; } - output->last_presentation = output_event->when; + output->last_presentation = *output_event->when; output->refresh_nsec = output_event->refresh; } @@ -482,44 +490,20 @@ static void handle_request_state(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, request_state); const struct wlr_output_event_request_state *event = data; - const struct wlr_output_state *state = event->state; - // Store the requested changes so that the active configuration is - // consistent with the current state, and to avoid duplicate logic to apply - // the changes. - struct output_config *oc = new_output_config(output->wlr_output->name); - if (!oc) { - sway_log(SWAY_ERROR, "Allocation failed"); - return; - } + uint32_t committed = event->state->committed; + wlr_output_commit_state(output->wlr_output, event->state); - int committed = state->committed; - if (committed & WLR_OUTPUT_STATE_MODE) { - if (state->mode != NULL) { - oc->width = state->mode->width; - oc->height = state->mode->height; - oc->refresh_rate = state->mode->refresh / 1000.f; - } else { - oc->width = state->custom_mode.width; - oc->height = state->custom_mode.height; - oc->refresh_rate = state->custom_mode.refresh / 1000.f; - } - committed &= ~WLR_OUTPUT_STATE_MODE; - } - if (committed & WLR_OUTPUT_STATE_SCALE) { - oc->scale = state->scale; - committed &= ~WLR_OUTPUT_STATE_SCALE; - } - if (committed & WLR_OUTPUT_STATE_TRANSFORM) { - oc->transform = state->transform; - committed &= ~WLR_OUTPUT_STATE_TRANSFORM; - } + if (committed & ( + WLR_OUTPUT_STATE_MODE | + WLR_OUTPUT_STATE_TRANSFORM | + WLR_OUTPUT_STATE_SCALE)) { + arrange_layers(output); + arrange_output(output); + transaction_commit_dirty(); - // We do not expect or support any other changes here - assert(committed == 0); - store_output_config(oc); - - force_modeset(); + update_output_manager_config(output->server); + } } static unsigned int last_headless_num = 0; @@ -583,6 +567,8 @@ void handle_new_output(struct wl_listener *listener, void *data) { output->layout_destroy.notify = handle_layout_destroy; wl_signal_add(&wlr_output->events.destroy, &output->destroy); output->destroy.notify = handle_destroy; + wl_signal_add(&wlr_output->events.commit, &output->commit); + output->commit.notify = handle_commit; wl_signal_add(&wlr_output->events.present, &output->present); output->present.notify = handle_present; wl_signal_add(&wlr_output->events.frame, &output->frame); @@ -600,13 +586,24 @@ void handle_new_output(struct wl_listener *listener, void *data) { request_modeset(); } +void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data) { + struct sway_server *server = + wl_container_of(listener, server, gamma_control_set_gamma); + const struct wlr_gamma_control_manager_v1_set_gamma_event *event = data; + + struct sway_output *output = event->output->data; + + if(!output) { + return; + } + + output->gamma_lut_changed = true; + wlr_output_schedule_frame(output->wlr_output); +} + static struct output_config *output_config_for_config_head( struct wlr_output_configuration_head_v1 *config_head) { struct output_config *oc = new_output_config(config_head->state.output->name); - if (!oc) { - return NULL; - } - oc->enabled = config_head->state.enabled; if (!oc->enabled) { return oc; @@ -637,8 +634,7 @@ static void output_manager_apply(struct sway_server *server, size_t configs_len = config->output_configs->length + wl_list_length(&cfg->heads); struct output_config **configs = calloc(configs_len, sizeof(*configs)); if (!configs) { - sway_log(SWAY_ERROR, "Allocation failed"); - goto error; + goto done; } size_t start_new_configs = config->output_configs->length; for (size_t idx = 0; idx < start_new_configs; idx++) { @@ -651,10 +647,6 @@ static void output_manager_apply(struct sway_server *server, // Generate the configuration and store it as a temporary // config. We keep a record of it so we can remove it later. struct output_config *oc = output_config_for_config_head(config_head); - if (!oc) { - sway_log(SWAY_ERROR, "Allocation failed"); - goto error_config; - } configs[config_idx++] = oc; } @@ -662,8 +654,6 @@ static void output_manager_apply(struct sway_server *server, // if any output configured for enablement fails to be enabled, even if it // was not part of the config heads we were asked to configure. ok = apply_output_configs(configs, configs_len, test_only, false); - -error_config: for (size_t idx = start_new_configs; idx < configs_len; idx++) { struct output_config *cfg = configs[idx]; if (!test_only && ok) { @@ -674,7 +664,7 @@ error_config: } free(configs); -error: +done: if (ok) { wlr_output_configuration_v1_send_succeeded(cfg); if (server->delayed_modeset != NULL) { @@ -709,11 +699,6 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener, struct sway_output *output = event->output->data; struct output_config *oc = new_output_config(output->wlr_output->name); - if (!oc) { - sway_log(SWAY_ERROR, "Allocation failed"); - return; - } - switch (event->mode) { case ZWLR_OUTPUT_POWER_V1_MODE_OFF: oc->power = 0; diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 325a30226..8f12832a0 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -309,13 +309,12 @@ static void arrange_children(enum sway_container_layout layout, list_t *children arrange_title_bar(child, title_offset, -title_bar_height, next_title_offset - title_offset, title_bar_height); wlr_scene_node_set_enabled(&child->border.tree->node, activated); - wlr_scene_node_set_enabled(&child->scene_tree->node, true); wlr_scene_node_set_position(&child->scene_tree->node, 0, title_bar_height); wlr_scene_node_reparent(&child->scene_tree->node, content); - int net_height = height - title_bar_height; - if (activated && width > 0 && net_height > 0) { - arrange_container(child, width, net_height, title_bar_height == 0, 0); + if (activated) { + arrange_container(child, width, height - title_bar_height, + title_bar_height == 0, 0); } else { disable_container(child); } @@ -339,13 +338,12 @@ static void arrange_children(enum sway_container_layout layout, list_t *children arrange_title_bar(child, 0, y - title_height, width, title_bar_height); wlr_scene_node_set_enabled(&child->border.tree->node, activated); - wlr_scene_node_set_enabled(&child->scene_tree->node, true); wlr_scene_node_set_position(&child->scene_tree->node, 0, title_height); wlr_scene_node_reparent(&child->scene_tree->node, content); - int net_height = height - title_height; - if (activated && width > 0 && net_height > 0) { - arrange_container(child, width, net_height, title_bar_height == 0, 0); + if (activated) { + arrange_container(child, width, height - title_height, + title_bar_height == 0, 0); } else { disable_container(child); } @@ -361,12 +359,8 @@ static void arrange_children(enum sway_container_layout layout, list_t *children wlr_scene_node_set_enabled(&child->border.tree->node, true); wlr_scene_node_set_position(&child->scene_tree->node, 0, off); wlr_scene_node_reparent(&child->scene_tree->node, content); - if (width > 0 && cheight > 0) { - arrange_container(child, width, cheight, true, gaps); - off += cheight + gaps; - } else { - disable_container(child); - } + arrange_container(child, width, cheight, true, gaps); + off += cheight + gaps; } } else if (layout == L_HORIZ) { int off = 0; @@ -377,12 +371,8 @@ static void arrange_children(enum sway_container_layout layout, list_t *children wlr_scene_node_set_enabled(&child->border.tree->node, true); wlr_scene_node_set_position(&child->scene_tree->node, off, 0); wlr_scene_node_reparent(&child->scene_tree->node, content); - if (cwidth > 0 && height > 0) { - arrange_container(child, cwidth, height, true, gaps); - off += cwidth + gaps; - } else { - disable_container(child); - } + arrange_container(child, cwidth, height, true, gaps); + off += cwidth + gaps; } } else { sway_assert(false, "unreachable"); @@ -434,14 +424,13 @@ static void arrange_container(struct sway_container *con, int border_bottom = con->current.border_bottom ? border_width : 0; int border_left = con->current.border_left ? border_width : 0; int border_right = con->current.border_right ? border_width : 0; - int vert_border_height = MAX(0, height - border_top - border_bottom); wlr_scene_rect_set_size(con->border.top, width, border_top); wlr_scene_rect_set_size(con->border.bottom, width, border_bottom); wlr_scene_rect_set_size(con->border.left, - border_left, vert_border_height); + border_left, height - border_top - border_bottom); wlr_scene_rect_set_size(con->border.right, - border_right, vert_border_height); + border_right, height - border_top - border_bottom); wlr_scene_node_set_position(&con->border.top->node, 0, 0); wlr_scene_node_set_position(&con->border.bottom->node, @@ -534,7 +523,6 @@ static void arrange_workspace_floating(struct sway_workspace *ws) { wlr_scene_node_set_position(&floater->scene_tree->node, floater->current.x, floater->current.y); wlr_scene_node_set_enabled(&floater->scene_tree->node, true); - wlr_scene_node_set_enabled(&floater->border.tree->node, true); arrange_container(floater, floater->current.width, floater->current.height, true, ws->gaps_inner); @@ -587,16 +575,15 @@ static void arrange_output(struct sway_output *output, int width, int height) { wlr_scene_node_set_enabled(&child->layers.tiling->node, !fs); wlr_scene_node_set_enabled(&child->layers.fullscreen->node, fs); + arrange_workspace_floating(child); + wlr_scene_node_set_enabled(&output->layers.shell_background->node, !fs); wlr_scene_node_set_enabled(&output->layers.shell_bottom->node, !fs); wlr_scene_node_set_enabled(&output->layers.fullscreen->node, fs); if (fs) { - disable_workspace(child); - wlr_scene_rect_set_size(output->fullscreen_background, width, height); - arrange_workspace_floating(child); arrange_fullscreen(child->layers.fullscreen, fs, child, width, height); } else { @@ -609,7 +596,6 @@ static void arrange_output(struct sway_output *output, int width, int height) { arrange_workspace_tiling(child, area->width - gaps->left - gaps->right, area->height - gaps->top - gaps->bottom); - arrange_workspace_floating(child); } } else { wlr_scene_node_set_enabled(&child->layers.tiling->node, false); @@ -665,15 +651,6 @@ static void arrange_root(struct sway_root *root) { struct sway_output *output = root->outputs->items[i]; struct sway_workspace *ws = output->current.active_workspace; - wlr_scene_output_set_position(output->scene_output, output->lx, output->ly); - - // disable all workspaces to get to a known state - for (int j = 0; j < output->current.workspaces->length; j++) { - struct sway_workspace *workspace = output->current.workspaces->items[j]; - disable_workspace(workspace); - } - - // arrange the active workspace if (ws) { arrange_workspace_floating(ws); } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 696a45ada..fdfa7b652 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include "log.h" #include "sway/decoration.h" @@ -21,13 +20,13 @@ static struct sway_xdg_popup *popup_create( struct wlr_xdg_popup *wlr_popup, struct sway_view *view, - struct wlr_scene_tree *parent, struct wlr_scene_tree *image_capture_parent); + struct wlr_scene_tree *parent); 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->view, popup->xdg_surface_tree, popup->image_capture_tree); + popup_create(wlr_popup, popup->view, popup->xdg_surface_tree); } static void popup_handle_destroy(struct wl_listener *listener, void *data) { @@ -78,8 +77,7 @@ static void popup_handle_reposition(struct wl_listener *listener, void *data) { } static struct sway_xdg_popup *popup_create(struct wlr_xdg_popup *wlr_popup, - struct sway_view *view, struct wlr_scene_tree *parent, - struct wlr_scene_tree *image_capture_parent) { + struct sway_view *view, struct wlr_scene_tree *parent) { struct wlr_xdg_surface *xdg_surface = wlr_popup->base; struct sway_xdg_popup *popup = calloc(1, sizeof(struct sway_xdg_popup)); @@ -115,11 +113,6 @@ static struct sway_xdg_popup *popup_create(struct wlr_xdg_popup *wlr_popup, return NULL; } - popup->image_capture_tree = wlr_scene_xdg_surface_create(image_capture_parent, xdg_surface); - if (popup->image_capture_tree == NULL) { - return NULL; - } - popup->wlr_xdg_popup = xdg_surface->popup; struct sway_xdg_shell_view *shell_view = wl_container_of(view, shell_view, view); @@ -158,8 +151,7 @@ static void get_constraints(struct sway_view *view, double *min_width, static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { - struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); - if (xdg_shell_view == NULL) { + if (xdg_shell_view_from_view(view) == NULL) { return NULL; } switch (prop) { @@ -167,8 +159,6 @@ static const char *get_string_prop(struct sway_view *view, return view->wlr_xdg_toplevel->title; case VIEW_PROP_APP_ID: return view->wlr_xdg_toplevel->app_id; - case VIEW_PROP_TAG: - return xdg_shell_view->tag; default: return NULL; } @@ -269,7 +259,6 @@ static void destroy(struct sway_view *view) { if (xdg_shell_view == NULL) { return; } - free(xdg_shell_view->tag); free(xdg_shell_view); } @@ -301,7 +290,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { // XXX: https://github.com/swaywm/sway/issues/2176 wlr_xdg_surface_schedule_configure(xdg_surface); wlr_xdg_toplevel_set_wm_capabilities(view->wlr_xdg_toplevel, - WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); + XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); // TODO: wlr_xdg_toplevel_set_bounds() return; } @@ -310,17 +299,18 @@ static void handle_commit(struct wl_listener *listener, void *data) { return; } - struct wlr_box *new_geo = &xdg_surface->geometry; - bool new_size = new_geo->width != view->geometry.width || - new_geo->height != view->geometry.height || - new_geo->x != view->geometry.x || - new_geo->y != view->geometry.y; + struct wlr_box new_geo; + wlr_xdg_surface_get_geometry(xdg_surface, &new_geo); + bool new_size = new_geo.width != view->geometry.width || + new_geo.height != view->geometry.height || + new_geo.x != view->geometry.x || + new_geo.y != view->geometry.y; if (new_size) { // The client changed its surface size in this commit. For floating // containers, we resize the container to match. For tiling containers, // we only recenter the surface. - memcpy(&view->geometry, new_geo, sizeof(struct wlr_box)); + memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box)); if (container_is_floating(view->container)) { view_update_size(view); // Only set the toplevel size the current container actually has a size. @@ -370,7 +360,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { struct wlr_xdg_popup *wlr_popup = data; struct sway_xdg_popup *popup = popup_create(wlr_popup, - &xdg_shell_view->view, root->layers.popup, xdg_shell_view->image_capture_tree); + &xdg_shell_view->view, root->layers.popup); if (!popup) { return; } @@ -473,8 +463,12 @@ static void handle_map(struct wl_listener *listener, void *data) { struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel; - view->natural_width = toplevel->base->geometry.width; - view->natural_height = toplevel->base->geometry.height; + view->natural_width = toplevel->base->current.geometry.width; + view->natural_height = toplevel->base->current.geometry.height; + if (!view->natural_width && !view->natural_height) { + view->natural_width = toplevel->base->surface->current.width; + view->natural_height = toplevel->base->surface->current.height; + } bool csd = false; @@ -581,17 +575,6 @@ void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data) { wl_signal_add(&xdg_toplevel->events.destroy, &xdg_shell_view->destroy); wlr_scene_xdg_surface_create(xdg_shell_view->view.content_tree, xdg_toplevel->base); - xdg_shell_view->image_capture_tree = - wlr_scene_xdg_surface_create(&xdg_shell_view->view.image_capture_scene->tree, xdg_toplevel->base); xdg_toplevel->base->data = xdg_shell_view; } - -void xdg_toplevel_tag_manager_v1_handle_set_tag(struct wl_listener *listener, void *data) { - const struct wlr_xdg_toplevel_tag_manager_v1_set_tag_event *event = data; - struct sway_view *view = view_from_wlr_xdg_surface(event->toplevel->base); - struct sway_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view); - free(xdg_shell_view->tag); - xdg_shell_view->tag = strdup(event->tag); - view_execute_criteria(view); -} diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 76e63ce1f..9a6614056 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -71,7 +71,7 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { surface->set_geometry.notify = unmanaged_handle_set_geometry; } - if (wlr_xwayland_surface_override_redirect_wants_focus(xsurface)) { + if (wlr_xwayland_or_surface_wants_focus(xsurface)) { struct sway_seat *seat = input_manager_current_seat(); struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; wlr_xwayland_set_seat(xwayland, seat->wlr_seat); @@ -96,7 +96,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { // This simply returns focus to the parent surface if there's one available. // This seems to handle JetBrains issues. if (xsurface->parent && xsurface->parent->surface - && wlr_xwayland_surface_override_redirect_wants_focus(xsurface->parent)) { + && wlr_xwayland_or_surface_wants_focus(xsurface->parent)) { seat_set_focus_surface(seat, xsurface->parent->surface, false); return; } @@ -289,6 +289,9 @@ static void set_activated(struct sway_view *view, bool activated) { } wlr_xwayland_surface_activate(surface, activated); + if (activated) { + wlr_xwayland_surface_restack(surface, NULL, XCB_STACK_MODE_ABOVE); + } } static void set_tiled(struct sway_view *view, bool tiled) { @@ -296,7 +299,7 @@ static void set_tiled(struct sway_view *view, bool tiled) { return; } struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - wlr_xwayland_surface_set_maximized(surface, tiled, tiled); + wlr_xwayland_surface_set_maximized(surface, tiled); } static void set_fullscreen(struct sway_view *view, bool fullscreen) { @@ -497,9 +500,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) { wl_list_remove(&xwayland_view->commit.link); wl_list_remove(&xwayland_view->surface_tree_destroy.link); - wlr_scene_node_destroy(&xwayland_view->image_capture_scene_surface->buffer->node); - xwayland_view->image_capture_scene_surface = NULL; - if (xwayland_view->surface_tree) { wlr_scene_node_destroy(&xwayland_view->surface_tree->node); xwayland_view->surface_tree = NULL; @@ -540,9 +540,6 @@ static void handle_map(struct wl_listener *listener, void *data) { &xwayland_view->surface_tree_destroy); } - xwayland_view->image_capture_scene_surface = - wlr_scene_surface_create(&xwayland_view->view.image_capture_scene->tree, xsurface->surface); - transaction_commit_dirty(); } diff --git a/sway/input/cursor.c b/sway/input/cursor.c index df62ef41b..235951d4c 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -32,6 +32,12 @@ #include "sway/tree/workspace.h" #include "wlr-layer-shell-unstable-v1-protocol.h" +static uint32_t get_current_time_msec(void) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec * 1000 + now.tv_nsec / 1000000; +} + /** * Returns the node at the cursor's position. If there is a surface at that * location, it is stored in **surface (it may not be a view). @@ -138,7 +144,7 @@ struct sway_node *node_at_coords( } void cursor_rebase(struct sway_cursor *cursor) { - uint32_t time_msec = get_current_time_in_msec(); + uint32_t time_msec = get_current_time_msec(); seatop_rebase(cursor->seat, time_msec); } @@ -353,7 +359,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, enum wl_pointer_button_state state) { if (time_msec == 0) { - time_msec = get_current_time_in_msec(); + time_msec = get_current_time_msec(); } seatop_button(cursor->seat, time_msec, device, button, state); @@ -572,13 +578,12 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, // tablet events until the drag is released, even if we are now over a // non-tablet surface. if (!cursor->simulating_pointer_from_tool_tip && - ((surface && wlr_surface_accepts_tablet_v2(surface, tablet->tablet_v2)) || + ((surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) || wlr_tablet_tool_v2_has_implicit_grab(tool->tablet_v2_tool))) { seatop_tablet_tool_motion(seat, tool, time_msec); } else { wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool); pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy); - wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); } } @@ -659,7 +664,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) { dispatch_cursor_button(cursor, &event->tablet->base, event->time_msec, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED); wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); - } else if (!surface || !wlr_surface_accepts_tablet_v2(surface, tablet_v2)) { + } else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) { // If we started holding the tool tip down on a surface that accepts // tablet v2, we should notify that surface if it gets released over a // surface that doesn't support v2. @@ -744,7 +749,7 @@ static void handle_tool_button(struct wl_listener *listener, void *data) { bool mod_pressed = modifiers & config->floating_mod; bool surface_supports_tablet_events = - surface && wlr_surface_accepts_tablet_v2(surface, tablet_v2); + surface && wlr_surface_accepts_tablet_v2(tablet_v2, surface); // Simulate pointer when: // 1. The modifier key is pressed, OR @@ -1042,7 +1047,6 @@ void sway_cursor_destroy(struct sway_cursor *cursor) { wl_list_remove(&cursor->touch_frame.link); wl_list_remove(&cursor->tool_axis.link); wl_list_remove(&cursor->tool_tip.link); - wl_list_remove(&cursor->tool_proximity.link); wl_list_remove(&cursor->tool_button.link); wl_list_remove(&cursor->request_set_cursor.link); @@ -1208,7 +1212,7 @@ uint32_t get_mouse_bindsym(const char *name, char **error) { SWAY_SCROLL_UP, SWAY_SCROLL_DOWN, SWAY_SCROLL_LEFT, SWAY_SCROLL_RIGHT, BTN_SIDE, BTN_EXTRA}; return buttons[number - 1]; - } else if (has_prefix(name, "BTN_")) { + } else if (strncmp(name, "BTN_", strlen("BTN_")) == 0) { // Get event code from name int code = libevdev_event_code_from_name(EV_KEY, name); if (code == -1) { @@ -1233,7 +1237,7 @@ uint32_t get_mouse_bindcode(const char *name, char **error) { return 0; } const char *event = libevdev_event_code_get_name(EV_KEY, code); - if (!event || !has_prefix(event, "BTN_")) { + if (!event || strncmp(event, "BTN_", strlen("BTN_")) != 0) { *error = format_str("Event code %d (%s) is not a button", code, event ? event : "(null)"); return 0; diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index ffcf8fc52..ddfe14689 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -493,14 +493,6 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) { return input; } -void input_manager_finish(struct sway_input_manager *input) { - wl_list_remove(&input->new_input.link); - wl_list_remove(&input->virtual_keyboard_new.link); - wl_list_remove(&input->virtual_pointer_new.link); - wl_list_remove(&input->keyboard_shortcuts_inhibit_new_inhibitor.link); - wl_list_remove(&input->transient_seat_create.link); -} - bool input_manager_has_focus(struct sway_node *node) { struct sway_seat *seat = NULL; wl_list_for_each(seat, &server.input->seats, link) { @@ -585,7 +577,7 @@ void input_manager_configure_all_input_mappings(void) { void input_manager_apply_input_config(struct input_config *input_config) { struct sway_input_device *input_device = NULL; bool wildcard = strcmp(input_config->identifier, "*") == 0; - bool type_wildcard = has_prefix(input_config->identifier, "type:"); + bool type_wildcard = strncmp(input_config->identifier, "type:", 5) == 0; wl_list_for_each(input_device, &server.input->devices, link) { bool type_matches = type_wildcard && strcmp(input_device_get_type(input_device), input_config->identifier + 5) == 0; diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index d18237375..1a73df014 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -268,7 +267,6 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard, const xkb_keysym_t *pressed_keysyms, uint32_t modifiers, size_t keysyms_len) { for (size_t i = 0; i < keysyms_len; ++i) { xkb_keysym_t keysym = pressed_keysyms[i]; - if (keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12) { #if WLR_HAS_SESSION @@ -284,36 +282,6 @@ static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard, return false; } -static bool keyboard_execute_pointer_keysyms(struct sway_keyboard *keyboard, - uint32_t time, const xkb_keysym_t *pressed_keysyms, size_t keysyms_len, - enum wl_keyboard_key_state state) { - struct sway_cursor *cursor = keyboard->seat_device->sway_seat->cursor; - - for (size_t i = 0; i < keysyms_len; ++i) { - xkb_keysym_t keysym = pressed_keysyms[i]; - - uint32_t button = wlr_keyboard_keysym_to_pointer_button(keysym); - if (button != 0) { - dispatch_cursor_button(cursor, &keyboard->wlr->base, time, button, - (enum wl_pointer_button_state)state); - wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); - return true; - } - - int dx, dy; - wlr_keyboard_keysym_to_pointer_motion(keysym, &dx, &dy); - if (state == WL_KEYBOARD_KEY_STATE_PRESSED && (dx != 0 || dy != 0)) { - dx *= 10; - dy *= 10; - pointer_motion(cursor, time, &keyboard->wlr->base, dx, dy, dx, dy); - wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); - return true; - } - } - - return false; -} - /** * Get keysyms and modifiers from the keyboard as xkb sees them. * @@ -539,11 +507,6 @@ static void handle_key_event(struct sway_keyboard *keyboard, keyboard, keyinfo.raw_keysyms, keyinfo.raw_modifiers, keyinfo.raw_keysyms_len); } - if (!handled) { - handled = keyboard_execute_pointer_keysyms(keyboard, event->time_msec, - keyinfo.translated_keysyms, keyinfo.translated_keysyms_len, - event->state); - } if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) { // If the pressed event was sent to a client and we have a focused @@ -980,10 +943,10 @@ static void sway_keyboard_group_add(struct sway_keyboard *keyboard) { wl_signal_add(&sway_group->wlr_group->keyboard.events.modifiers, &sway_group->keyboard_modifiers); sway_group->keyboard_modifiers.notify = handle_keyboard_group_modifiers; - + wl_signal_add(&sway_group->wlr_group->events.enter, &sway_group->enter); sway_group->enter.notify = handle_keyboard_group_enter; - + wl_signal_add(&sway_group->wlr_group->events.leave, &sway_group->leave); sway_group->leave.notify = handle_keyboard_group_leave; return; diff --git a/sway/input/libinput.c b/sway/input/libinput.c index fd7533d99..2fec290e7 100644 --- a/sway/input/libinput.c +++ b/sway/input/libinput.c @@ -391,19 +391,6 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) { } } -static bool sway_udev_device_is_builtin(struct udev_device *udev_device) { - const char *id_path = udev_device_get_property_value(udev_device, "ID_PATH"); - if (!id_path) { - return false; - } - - if (has_prefix(id_path, "platform-")) { - return true; - } - - return has_prefix(id_path, "pci-") && strstr(id_path, "-platform-"); -} - bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) { if (!wlr_input_device_is_libinput(sway_device->wlr_device)) { return false; @@ -417,7 +404,18 @@ bool sway_libinput_device_is_builtin(struct sway_input_device *sway_device) { return false; } - bool is_builtin = sway_udev_device_is_builtin(udev_device); - udev_device_unref(udev_device); - return is_builtin; + const char *id_path = udev_device_get_property_value(udev_device, "ID_PATH"); + if (!id_path) { + return false; + } + + const char prefix_platform[] = "platform-"; + if (strncmp(id_path, prefix_platform, strlen(prefix_platform)) != 0) { + return false; + } + + const char prefix_pci[] = "pci-"; + const char infix_platform[] = "-platform-"; + return (strncmp(id_path, prefix_pci, strlen(prefix_pci)) == 0) && + strstr(id_path, infix_platform); } diff --git a/sway/input/seat.c b/sway/input/seat.c index 1b63f625b..9a00a3e24 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -647,6 +647,10 @@ static void seat_reset_input_config(struct sway_seat *seat, sway_device->input_device->wlr_device, NULL); } +static bool has_prefix(const char *str, const char *prefix) { + return strncmp(str, prefix, strlen(prefix)) == 0; +} + /** * Get the name of the built-in output, if any. Returns NULL if there isn't * exactly one built-in output. @@ -1090,7 +1094,6 @@ static void seat_send_unfocus(struct sway_node *node, struct sway_seat *seat) { static int handle_urgent_timeout(void *data) { struct sway_view *view = data; view_set_urgent(view, false); - container_update_itself_and_parents(view->container); return 0; } diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index df8232afc..52984818c 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -16,7 +16,6 @@ #include "sway/tree/view.h" #include "sway/tree/workspace.h" #include "log.h" -#include "util.h" #if WLR_HAS_XWAYLAND #include "sway/xwayland.h" #endif @@ -274,7 +273,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, // Handle tapping on an xwayland unmanaged view else if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(surface)) && xsurface->override_redirect && - wlr_xwayland_surface_override_redirect_wants_focus(xsurface)) { + wlr_xwayland_or_surface_wants_focus(xsurface)) { struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; wlr_xwayland_set_seat(xwayland, seat->wlr_seat); seat_set_focus_surface(seat, xsurface->surface, false); @@ -356,13 +355,6 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; - bool mod_pressed = modifiers & config->floating_mod; - uint32_t mod_move_btn = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; - uint32_t mod_resize_btn = config->floating_mod_inverse ? BTN_LEFT : BTN_RIGHT; - bool mod_move_btn_pressed = mod_pressed && button == mod_move_btn; - bool mod_resize_btn_pressed = mod_pressed && button == mod_resize_btn; - bool titlebar_left_btn_pressed = on_titlebar && button == BTN_LEFT; - // Handle mouse bindings if (trigger_pointer_button_binding(seat, device, button, state, modifiers, on_titlebar, on_border, on_contents, on_workspace)) { @@ -411,28 +403,33 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Handle tiling resize via mod - if (cont && !is_floating_or_child && mod_pressed && mod_resize_btn_pressed && + bool mod_pressed = modifiers & config->floating_mod; + if (cont && !is_floating_or_child && mod_pressed && state == WL_POINTER_BUTTON_STATE_PRESSED) { - edge = 0; - edge |= cursor->cursor->x > cont->pending.x + cont->pending.width / 2 ? - WLR_EDGE_RIGHT : WLR_EDGE_LEFT; - edge |= cursor->cursor->y > cont->pending.y + cont->pending.height / 2 ? - WLR_EDGE_BOTTOM : WLR_EDGE_TOP; + uint32_t btn_resize = config->floating_mod_inverse ? + BTN_LEFT : BTN_RIGHT; + if (button == btn_resize) { + edge = 0; + edge |= cursor->cursor->x > cont->pending.x + cont->pending.width / 2 ? + WLR_EDGE_RIGHT : WLR_EDGE_LEFT; + edge |= cursor->cursor->y > cont->pending.y + cont->pending.height / 2 ? + WLR_EDGE_BOTTOM : WLR_EDGE_TOP; - const char *image = NULL; - if (edge == (WLR_EDGE_LEFT | WLR_EDGE_TOP)) { - image = "nw-resize"; - } else if (edge == (WLR_EDGE_TOP | WLR_EDGE_RIGHT)) { - image = "ne-resize"; - } else if (edge == (WLR_EDGE_RIGHT | WLR_EDGE_BOTTOM)) { - image = "se-resize"; - } else if (edge == (WLR_EDGE_BOTTOM | WLR_EDGE_LEFT)) { - image = "sw-resize"; + const char *image = NULL; + if (edge == (WLR_EDGE_LEFT | WLR_EDGE_TOP)) { + image = "nw-resize"; + } else if (edge == (WLR_EDGE_TOP | WLR_EDGE_RIGHT)) { + image = "ne-resize"; + } else if (edge == (WLR_EDGE_RIGHT | WLR_EDGE_BOTTOM)) { + image = "se-resize"; + } else if (edge == (WLR_EDGE_BOTTOM | WLR_EDGE_LEFT)) { + image = "sw-resize"; + } + cursor_set_image(seat->cursor, image, NULL); + seat_set_focus_container(seat, cont); + seatop_begin_resize_tiling(seat, cont, edge); + return; } - cursor_set_image(seat->cursor, image, NULL); - seat_set_focus_container(seat, cont); - seatop_begin_resize_tiling(seat, cont, edge); - return; } // Handle changing focus when clicking on a container @@ -457,10 +454,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, // Handle beginning floating move if (cont && is_floating_or_child && !is_fullscreen_or_child && - state == WL_POINTER_BUTTON_STATE_PRESSED && - (mod_move_btn_pressed || titlebar_left_btn_pressed)) { - seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); - return; + state == WL_POINTER_BUTTON_STATE_PRESSED) { + uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; + if (button == btn_move && (mod_pressed || on_titlebar)) { + seatop_begin_move_floating(seat, container_toplevel_ancestor(cont)); + return; + } } // Handle beginning floating resize @@ -474,7 +473,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Via mod+click - if (mod_resize_btn_pressed) { + uint32_t btn_resize = config->floating_mod_inverse ? + BTN_LEFT : BTN_RIGHT; + if (mod_pressed && button == btn_resize) { struct sway_container *floater = container_toplevel_ancestor(cont); edge = 0; edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ? @@ -488,15 +489,18 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Handle moving a tiling container - if (config->tiling_drag && (mod_move_btn_pressed || titlebar_left_btn_pressed) && + if (config->tiling_drag && (mod_pressed || on_titlebar) && state == WL_POINTER_BUTTON_STATE_PRESSED && !is_floating_or_child && - cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) { + cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE && + button == (config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT)) { + // If moving a container by its title bar, use a threshold for the drag if (!mod_pressed && config->tiling_drag_threshold > 0) { seatop_begin_move_tiling_threshold(seat, cont); } else { seatop_begin_move_tiling(seat, cont); } + return; } @@ -519,7 +523,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, if (surface && (xsurface = wlr_xwayland_surface_try_from_wlr_surface(surface)) && xsurface->override_redirect && - wlr_xwayland_surface_override_redirect_wants_focus(xsurface)) { + wlr_xwayland_or_surface_wants_focus(xsurface)) { struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; wlr_xwayland_set_seat(xwayland, seat->wlr_seat); seat_set_focus_surface(seat, xsurface->surface, false); @@ -665,7 +669,7 @@ static void handle_touch_down(struct sway_seat *seat, double sx, sy; node_at_coords(seat, seat->touch_x, seat->touch_y, &surface, &sx, &sy); - if (surface && wlr_surface_accepts_touch(surface, wlr_seat)) { + if (surface && wlr_surface_accepts_touch(wlr_seat, surface)) { if (seat_is_input_allowed(seat, surface)) { cursor->simulating_pointer_from_touch = false; seatop_begin_touch_down(seat, surface, event, sx, sy, lx, ly); @@ -794,7 +798,7 @@ static void handle_pointer_axis(struct sway_seat *seat, if (!handled) { wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, - event->orientation, scroll_factor * event->delta, + event->orientation, scroll_factor * event->delta, roundf(scroll_factor * event->delta_discrete), event->source, event->relative_direction); } @@ -1111,7 +1115,7 @@ static void handle_rebase(struct sway_seat *seat, uint32_t time_msec) { cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); if (surface) { - if (seat_is_input_allowed(seat, surface) && !cursor->hidden) { + if (seat_is_input_allowed(seat, surface)) { wlr_seat_pointer_notify_enter(seat->wlr_seat, surface, sx, sy); wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); } @@ -1149,7 +1153,5 @@ void seatop_begin_default(struct sway_seat *seat) { seat->seatop_impl = &seatop_impl; seat->seatop_data = e; - - uint32_t time_msec = get_current_time_in_msec(); - seatop_rebase(seat, time_msec); + seatop_rebase(seat, 0); } diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index f64e5a4f2..340e334bf 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c @@ -100,7 +100,6 @@ static void handle_touch_down(struct sway_seat *seat, if (focused_node) { seat_set_focus(seat, focused_node); - transaction_commit_dirty(); } } diff --git a/sway/input/tablet.c b/sway/input/tablet.c index 19d5debf9..ec1e4f682 100644 --- a/sway/input/tablet.c +++ b/sway/input/tablet.c @@ -363,7 +363,7 @@ void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad, } if (surface == NULL || - !wlr_surface_accepts_tablet_v2(surface, tablet_pad->tablet->tablet_v2)) { + !wlr_surface_accepts_tablet_v2(tablet_pad->tablet->tablet_v2, surface)) { return; } diff --git a/sway/input/text_input.c b/sway/input/text_input.c index e496bff1b..e16724671 100644 --- a/sway/input/text_input.c +++ b/sway/input/text_input.c @@ -10,7 +10,6 @@ #include "sway/input/text_input_popup.h" #include "sway/layers.h" #include "sway/server.h" -#include static struct sway_text_input *relay_get_focusable_text_input( struct sway_input_method_relay *relay) { @@ -42,21 +41,23 @@ static void handle_im_commit(struct wl_listener *listener, void *data) { if (!text_input) { return; } - if (relay->input_method->current.preedit.text) { + struct wlr_input_method_v2 *context = data; + assert(context == relay->input_method); + if (context->current.preedit.text) { wlr_text_input_v3_send_preedit_string(text_input->input, - relay->input_method->current.preedit.text, - relay->input_method->current.preedit.cursor_begin, - relay->input_method->current.preedit.cursor_end); + context->current.preedit.text, + context->current.preedit.cursor_begin, + context->current.preedit.cursor_end); } - if (relay->input_method->current.commit_text) { + if (context->current.commit_text) { wlr_text_input_v3_send_commit_string(text_input->input, - relay->input_method->current.commit_text); + context->current.commit_text); } - if (relay->input_method->current.delete.before_length - || relay->input_method->current.delete.after_length) { + if (context->current.delete.before_length + || context->current.delete.after_length) { wlr_text_input_v3_send_delete_surrounding_text(text_input->input, - relay->input_method->current.delete.before_length, - relay->input_method->current.delete.after_length); + context->current.delete.before_length, + context->current.delete.after_length); } wlr_text_input_v3_send_done(text_input->input); } @@ -64,7 +65,7 @@ static void handle_im_commit(struct wl_listener *listener, void *data) { static void handle_im_keyboard_grab_destroy(struct wl_listener *listener, void *data) { struct sway_input_method_relay *relay = wl_container_of(listener, relay, input_method_keyboard_grab_destroy); - struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = relay->input_method->keyboard_grab; + struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data; struct wlr_seat *wlr_seat = keyboard_grab->input_method->seat; wl_list_remove(&relay->input_method_keyboard_grab_destroy.link); @@ -108,6 +109,8 @@ static void text_input_set_pending_focused_surface( static void handle_im_destroy(struct wl_listener *listener, void *data) { struct sway_input_method_relay *relay = wl_container_of(listener, relay, input_method_destroy); + struct wlr_input_method_v2 *context = data; + assert(context == relay->input_method); wl_list_remove(&relay->input_method_commit.link); wl_list_remove(&relay->input_method_grab_keyboard.link); wl_list_remove(&relay->input_method_destroy.link); @@ -244,10 +247,6 @@ static void relay_send_im_state(struct sway_input_method_relay *relay, static void handle_text_input_enable(struct wl_listener *listener, void *data) { struct sway_text_input *text_input = wl_container_of(listener, text_input, text_input_enable); - if (text_input->input->focused_surface == NULL) { - sway_log(SWAY_DEBUG, "Enabling text input, but no longer focused"); - return; - } if (text_input->relay->input_method == NULL) { sway_log(SWAY_INFO, "Enabling text input when input method is gone"); return; @@ -260,10 +259,6 @@ static void handle_text_input_commit(struct wl_listener *listener, void *data) { struct sway_text_input *text_input = wl_container_of(listener, text_input, text_input_commit); - if (text_input->input->focused_surface == NULL) { - sway_log(SWAY_DEBUG, "Unfocused text input tried to commit an update"); - return; - } if (!text_input->input->current_enabled) { sway_log(SWAY_INFO, "Inactive text input tried to commit an update"); return; @@ -318,6 +313,8 @@ static void handle_pending_focused_surface_destroy(struct wl_listener *listener, void *data) { struct sway_text_input *text_input = wl_container_of(listener, text_input, pending_focused_surface_destroy); + struct wlr_surface *surface = data; + assert(text_input->pending_focused_surface == surface); text_input->pending_focused_surface = NULL; wl_list_remove(&text_input->pending_focused_surface_destroy.link); wl_list_init(&text_input->pending_focused_surface_destroy.link); @@ -388,8 +385,6 @@ static void input_popup_set_focus(struct sway_input_popup *popup, struct wlr_layer_surface_v1 *layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(surface); - struct wlr_session_lock_surface_v1 *lock_surface = - wlr_session_lock_surface_v1_try_from_wlr_surface(surface); struct wlr_scene_tree *relative_parent; if (layer_surface) { @@ -409,30 +404,8 @@ static void input_popup_set_focus(struct sway_input_popup *popup, // surface. Layer surfaces get destroyed as part of the output being // destroyed, thus also trickling down to popups. popup->fixed_output = layer->layer_surface->output; - } else if (lock_surface) { - wl_signal_add(&lock_surface->surface->events.unmap, - &popup->focused_surface_unmap); - - struct sway_layer_surface *lock = lock_surface->data; - if (lock == NULL) { - return; - } - - relative_parent = lock->scene->tree; - popup->desc.view = NULL; - - // we don't need to add an event here to NULL out this field because - // this field will only be initialized if the popup is part of a layer - // surface. Layer surfaces get destroyed as part of the output being - // destroyed, thus also trickling down to popups. - popup->fixed_output = lock->layer_surface->output; } else { struct sway_view *view = view_from_wlr_surface(surface); - // In the future there may be other shells been added, so we also need to check here. - if (view == NULL) { - sway_log(SWAY_DEBUG, "Unsupported IME focus surface"); - return; - } wl_signal_add(&view->events.unmap, &popup->focused_surface_unmap); relative_parent = view->scene_tree; popup->desc.view = view; @@ -599,34 +572,6 @@ static void relay_handle_input_method(struct wl_listener *listener, } } -static void sway_input_method_relay_finish_text_input(struct sway_input_method_relay *relay) { - wl_list_remove(&relay->text_input_new.link); - wl_list_remove(&relay->text_input_manager_destroy.link); - wl_list_init(&relay->text_input_new.link); - wl_list_init(&relay->text_input_manager_destroy.link); -} - -static void relay_handle_text_input_manager_destroy(struct wl_listener *listener, void *data) { - struct sway_input_method_relay *relay = wl_container_of(listener, relay, - text_input_manager_destroy); - - sway_input_method_relay_finish_text_input(relay); -} - -static void sway_input_method_relay_finish_input_method(struct sway_input_method_relay *relay) { - wl_list_remove(&relay->input_method_new.link); - wl_list_remove(&relay->input_method_manager_destroy.link); - wl_list_init(&relay->input_method_new.link); - wl_list_init(&relay->input_method_manager_destroy.link); -} - -static void relay_handle_input_method_manager_destroy(struct wl_listener *listener, void *data) { - struct sway_input_method_relay *relay = wl_container_of(listener, relay, - input_method_manager_destroy); - - sway_input_method_relay_finish_input_method(relay); -} - void sway_input_method_relay_init(struct sway_seat *seat, struct sway_input_method_relay *relay) { relay->seat = seat; @@ -634,24 +579,18 @@ void sway_input_method_relay_init(struct sway_seat *seat, wl_list_init(&relay->input_popups); relay->text_input_new.notify = relay_handle_text_input; - wl_signal_add(&server.text_input->events.new_text_input, + wl_signal_add(&server.text_input->events.text_input, &relay->text_input_new); - relay->text_input_manager_destroy.notify = relay_handle_text_input_manager_destroy; - wl_signal_add(&server.text_input->events.destroy, - &relay->text_input_manager_destroy); relay->input_method_new.notify = relay_handle_input_method; wl_signal_add( - &server.input_method->events.new_input_method, + &server.input_method->events.input_method, &relay->input_method_new); - relay->input_method_manager_destroy.notify = relay_handle_input_method_manager_destroy; - wl_signal_add(&server.input_method->events.destroy, - &relay->input_method_manager_destroy); } void sway_input_method_relay_finish(struct sway_input_method_relay *relay) { - sway_input_method_relay_finish_text_input(relay); - sway_input_method_relay_finish_input_method(relay); + wl_list_remove(&relay->input_method_new.link); + wl_list_remove(&relay->text_input_new.link); } void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay, diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 3b69ad384..571338a4f 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include "config.h" #include "log.h" @@ -318,14 +317,6 @@ static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, json_obj json_object_array_add(modes_array, mode_object); } json_object_object_add(object, "modes", modes_array); - - json_object *features_object = json_object_new_object(); - json_object_object_add(features_object, "adaptive_sync", - json_object_new_boolean(wlr_output->adaptive_sync_supported || - wlr_output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)); - json_object_object_add(features_object, "hdr", - json_object_new_boolean(output_supports_hdr(wlr_output, NULL))); - json_object_object_add(object, "features", features_object); } static void ipc_json_describe_output(struct sway_output *output, @@ -408,8 +399,8 @@ static void ipc_json_describe_enabled_output(struct sway_output *output, } json_object_object_add(object, "max_render_time", json_object_new_int(output->max_render_time)); + json_object_object_add(object, "allow_tearing", json_object_new_boolean(output->allow_tearing)); - json_object_object_add(object, "hdr", json_object_new_boolean(output->hdr)); } json_object *ipc_json_describe_disabled_output(struct sway_output *output) { @@ -586,10 +577,6 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_object_add(object, "app_id", app_id ? json_object_new_string(app_id) : NULL); - json_object_object_add(object, "foreign_toplevel_identifier", - c->view->ext_foreign_toplevel ? - json_object_new_string(c->view->ext_foreign_toplevel->identifier) : NULL); - bool visible = view_is_visible(c->view); json_object_object_add(object, "visible", json_object_new_boolean(visible)); @@ -615,21 +602,6 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_object_add(object, "inhibit_idle", json_object_new_boolean(view_inhibit_idle(c->view))); - const char *sandbox_engine = view_get_sandbox_engine(c->view); - json_object_object_add(object, "sandbox_engine", - sandbox_engine ? json_object_new_string(sandbox_engine) : NULL); - - const char *sandbox_app_id = view_get_sandbox_app_id(c->view); - json_object_object_add(object, "sandbox_app_id", - sandbox_app_id ? json_object_new_string(sandbox_app_id) : NULL); - - const char *sandbox_instance_id = view_get_sandbox_instance_id(c->view); - json_object_object_add(object, "sandbox_instance_id", - sandbox_instance_id ? json_object_new_string(sandbox_instance_id) : NULL); - - const char *tag = view_get_tag(c->view); - json_object_object_add(object, "tag", tag ? json_object_new_string(tag) : NULL); - json_object *idle_inhibitors = json_object_new_object(); struct sway_idle_inhibitor_v1 *user_inhibitor = @@ -959,11 +931,6 @@ static json_object *describe_libinput_device(struct libinput_device *device) { case LIBINPUT_CONFIG_DRAG_LOCK_DISABLED: drag_lock = "disabled"; break; -#if HAVE_LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY - case LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY: - drag_lock = "enabled_sticky"; - break; -#endif } json_object_object_add(object, "tap_drag_lock", json_object_new_string(drag_lock)); diff --git a/sway/ipc-server.c b/sway/ipc-server.c index b934bb568..7f353c0ec 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -648,12 +648,6 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt } list_t *res_list = execute_command(buf, NULL, NULL); - if (modeset_is_pending()) { - // IPC expects commands to have taken immediate effect, so we need - // to force a modeset after output commands. We do a single modeset - // here to avoid modesetting for every output command in sequence. - force_modeset(); - } transaction_commit_dirty(); char *json = cmd_results_to_json(res_list); int length = strlen(json); diff --git a/sway/lock.c b/sway/lock.c index c8975c747..43f313308 100644 --- a/sway/lock.c +++ b/sway/lock.c @@ -234,9 +234,6 @@ static void handle_unlock(struct wl_listener *listener, void *data) { struct sway_output *output = root->outputs->items[i]; arrange_layers(output); } - - // Views are now visible, so check if we need to activate inhibition again. - sway_idle_inhibit_v1_check_active(); } static void handle_abandon(struct wl_listener *listener, void *data) { @@ -300,10 +297,6 @@ static void handle_session_lock(struct wl_listener *listener, void *data) { wlr_session_lock_v1_send_locked(lock); server.session_lock.lock = sway_lock; - - // The lock screen covers everything, so check if any active inhibition got - // deactivated due to lost visibility. - sway_idle_inhibit_v1_check_active(); } static void handle_session_lock_destroy(struct wl_listener *listener, void *data) { diff --git a/sway/main.c b/sway/main.c index 44d07679e..1c4939aa0 100644 --- a/sway/main.c +++ b/sway/main.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -45,6 +44,10 @@ void sway_terminate(int exit_code) { } } +void sig_handler(int signal) { + sway_terminate(EXIT_SUCCESS); +} + void run_as_ipc_client(char *command, char *socket_path) { int socketfd = ipc_open_socket(socket_path); uint32_t len = strlen(command); @@ -108,14 +111,18 @@ static void log_kernel(void) { pclose(f); } -static void restore_nofile_limit(void) { - if (original_nofile_rlimit.rlim_cur == 0) { - return; +static bool detect_suid(void) { + if (geteuid() != 0 && getegid() != 0) { + return false; } - if (setrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) { - sway_log_errno(SWAY_ERROR, "Failed to restore max open files limit: " - "setrlimit(NOFILE) failed"); + + if (getuid() == geteuid() && getgid() == getegid()) { + return false; } + + sway_log(SWAY_ERROR, "SUID operation is no longer supported, refusing to start. " + "This check will be removed in a future release."); + return true; } static void increase_nofile_limit(void) { @@ -132,38 +139,17 @@ static void increase_nofile_limit(void) { "setrlimit(NOFILE) failed"); sway_log(SWAY_INFO, "Running with %d max open files", (int)original_nofile_rlimit.rlim_cur); + } +} + +void restore_nofile_limit(void) { + if (original_nofile_rlimit.rlim_cur == 0) { return; } - - pthread_atfork(NULL, NULL, restore_nofile_limit); -} - -static int term_signal(int signal, void *data) { - sway_terminate(EXIT_SUCCESS); - return 0; -} - -static void restore_signals(void) { - sigset_t set; - sigemptyset(&set); - sigprocmask(SIG_SETMASK, &set, NULL); - - struct sigaction sa_dfl = { .sa_handler = SIG_DFL }; - sigaction(SIGCHLD, &sa_dfl, NULL); - sigaction(SIGPIPE, &sa_dfl, NULL); -} - -static void init_signals(void) { - wl_event_loop_add_signal(server.wl_event_loop, SIGTERM, term_signal, NULL); - wl_event_loop_add_signal(server.wl_event_loop, SIGINT, term_signal, NULL); - - struct sigaction sa_ign = { .sa_handler = SIG_IGN }; - // avoid need to reap children - sigaction(SIGCHLD, &sa_ign, NULL); - // prevent ipc write errors from crashing sway - sigaction(SIGPIPE, &sa_ign, NULL); - - pthread_atfork(NULL, NULL, restore_signals); + if (setrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) { + sway_log_errno(SWAY_ERROR, "Failed to restore max open files limit: " + "setrlimit(NOFILE) failed"); + } } void enable_debug_flag(const char *flag) { @@ -173,8 +159,10 @@ void enable_debug_flag(const char *flag) { debug.txn_wait = true; } else if (strcmp(flag, "txn-timings") == 0) { debug.txn_timings = true; - } else if (has_prefix(flag, "txn-timeout=")) { - server.txn_timeout_ms = atoi(&flag[strlen("txn-timeout=")]); + } else if (strncmp(flag, "txn-timeout=", 12) == 0) { + server.txn_timeout_ms = atoi(&flag[12]); + } else if (strcmp(flag, "legacy-wl-drm") == 0) { + debug.legacy_wl_drm = true; } else { sway_log(SWAY_ERROR, "Unknown debug flag: %s", flag); } @@ -278,6 +266,11 @@ int main(int argc, char **argv) { } } + // SUID operation is deprecated, so block it for now. + if (detect_suid()) { + exit(EXIT_FAILURE); + } + // Since wayland requires XDG_RUNTIME_DIR to be set, abort with just the // clear error message (when not running as an IPC client). if (!getenv("XDG_RUNTIME_DIR") && optind == argc) { @@ -329,14 +322,19 @@ int main(int argc, char **argv) { increase_nofile_limit(); + // handle SIGTERM signals + signal(SIGTERM, sig_handler); + signal(SIGINT, sig_handler); + + // prevent ipc from crashing sway + signal(SIGPIPE, SIG_IGN); + sway_log(SWAY_INFO, "Starting sway version " SWAY_VERSION); if (!server_init(&server)) { return 1; } - init_signals(); - if (server.linux_dmabuf_v1) { wlr_scene_set_linux_dmabuf_v1(root->root_scene, server.linux_dmabuf_v1); } @@ -363,7 +361,6 @@ int main(int argc, char **argv) { } config->active = true; - force_modeset(); load_swaybars(); run_deferred_commands(); run_deferred_bindings(); diff --git a/sway/meson.build b/sway/meson.build index cb03a4d28..8042c89be 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -195,7 +195,6 @@ sway_sources = files( 'commands/output/disable.c', 'commands/output/dpms.c', 'commands/output/enable.c', - 'commands/output/hdr.c', 'commands/output/max_render_time.c', 'commands/output/mode.c', 'commands/output/position.c', diff --git a/sway/server.c b/sway/server.c index 063b96331..7c17fdf11 100644 --- a/sway/server.c +++ b/sway/server.c @@ -10,25 +10,20 @@ #include #include #include -#include #include #include #include #include -#include #include +#include #include #include -#include #include -#include -#include #include #include #include #include #include -#include #include #include #include @@ -50,7 +45,6 @@ #include #include #include -#include #include #include "config.h" #include "list.h" @@ -75,7 +69,6 @@ #define SWAY_XDG_SHELL_VERSION 5 #define SWAY_LAYER_SHELL_VERSION 4 #define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1 -#define SWAY_PRESENTATION_VERSION 2 bool allow_unsupported_gpu = false; @@ -111,10 +104,8 @@ static bool is_privileged(const struct wl_global *global) { global == server.input_method->global || global == server.foreign_toplevel_list->global || global == server.foreign_toplevel_manager->global || - global == server.wlr_data_control_manager_v1->global || - global == server.ext_data_control_manager_v1->global || + global == server.data_control_manager_v1->global || global == server.screencopy_manager_v1->global || - global == server.ext_image_copy_capture_manager_v1->global || global == server.export_dmabuf_manager_v1->global || global == server.security_context_manager_v1->global || global == server.gamma_control_manager_v1->global || @@ -184,11 +175,11 @@ static void detect_proprietary(struct wlr_backend *backend, void *data) { drmFreeVersion(version); } -static void do_renderer_recreate(void *data) { - struct sway_server *server = data; - server->recreating_renderer = NULL; +static void handle_renderer_lost(struct wl_listener *listener, void *data) { + struct sway_server *server = wl_container_of(listener, server, renderer_lost); sway_log(SWAY_INFO, "Re-creating renderer after GPU reset"); + struct wlr_renderer *renderer = wlr_renderer_autocreate(server->backend); if (renderer == NULL) { sway_log(SWAY_ERROR, "Unable to create renderer"); @@ -223,42 +214,13 @@ static void do_renderer_recreate(void *data) { wlr_renderer_destroy(old_renderer); } -static void handle_renderer_lost(struct wl_listener *listener, void *data) { - struct sway_server *server = wl_container_of(listener, server, renderer_lost); - - if (server->recreating_renderer != NULL) { - sway_log(SWAY_DEBUG, "Re-creation of renderer already scheduled"); - return; - } - - sway_log(SWAY_INFO, "Scheduling re-creation of renderer after GPU reset"); - server->recreating_renderer = wl_event_loop_add_idle(server->wl_event_loop, do_renderer_recreate, server); -} - -static void handle_new_foreign_toplevel_capture_request(struct wl_listener *listener, void *data) { - struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data; - struct sway_view *view = request->toplevel_handle->data; - - if (view->image_capture_source == NULL) { - view->image_capture_source = wlr_ext_image_capture_source_v1_create_with_scene_node( - &view->image_capture_scene->tree.node, server.wl_event_loop, server.allocator, server.renderer); - if (view->image_capture_source == NULL) { - return; - } - } - - wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(request, view->image_capture_source); -} - bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Initializing Wayland server"); server->wl_display = wl_display_create(); server->wl_event_loop = wl_display_get_event_loop(server->wl_display); wl_display_set_global_filter(server->wl_display, filter_global, NULL); - wl_display_set_default_max_buffer_size(server->wl_display, 1024 * 1024); - wlr_fixes_create(server->wl_display, 1); root = root_create(server->wl_display); server->backend = wlr_backend_autocreate(server->wl_event_loop, &server->session); @@ -283,12 +245,9 @@ bool server_init(struct sway_server *server) { if (wlr_renderer_get_texture_formats(server->renderer, WLR_BUFFER_CAP_DMABUF) != NULL) { server->linux_dmabuf_v1 = wlr_linux_dmabuf_v1_create_with_renderer( server->wl_display, 4, server->renderer); - } - if (wlr_renderer_get_drm_fd(server->renderer) >= 0 && - server->renderer->features.timeline && - server->backend->features.timeline) { - wlr_linux_drm_syncobj_manager_v1_create(server->wl_display, 1, - wlr_renderer_get_drm_fd(server->renderer)); + if (debug.legacy_wl_drm) { + wlr_drm_create(server->wl_display, server->renderer); + } } server->allocator = wlr_allocator_autocreate(server->backend, @@ -308,8 +267,9 @@ bool server_init(struct sway_server *server) { server->gamma_control_manager_v1 = wlr_gamma_control_manager_v1_create(server->wl_display); - wlr_scene_set_gamma_control_manager_v1(root->root_scene, - server->gamma_control_manager_v1); + server->gamma_control_set_gamma.notify = handle_gamma_control_set_gamma; + wl_signal_add(&server->gamma_control_manager_v1->events.set_gamma, + &server->gamma_control_set_gamma); server->new_output.notify = handle_new_output; wl_signal_add(&server->backend->events.new_output, &server->new_output); @@ -361,7 +321,7 @@ bool server_init(struct sway_server *server) { wl_signal_add(&server->pointer_constraints->events.new_constraint, &server->pointer_constraint); - wlr_presentation_create(server->wl_display, server->backend, SWAY_PRESENTATION_VERSION); + wlr_presentation_create(server->wl_display, server->backend); wlr_alpha_modifier_v1_create(server->wl_display); server->output_manager_v1 = @@ -403,10 +363,7 @@ bool server_init(struct sway_server *server) { 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->ext_image_copy_capture_manager_v1 = wlr_ext_image_copy_capture_manager_v1_create(server->wl_display, 1); - wlr_ext_output_image_capture_source_manager_v1_create(server->wl_display, 1); - server->wlr_data_control_manager_v1 = wlr_data_control_manager_v1_create(server->wl_display); - server->ext_data_control_manager_v1 = wlr_ext_data_control_manager_v1_create(server->wl_display, 1); + 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); @@ -414,12 +371,6 @@ bool server_init(struct sway_server *server) { wlr_content_type_manager_v1_create(server->wl_display, 1); wlr_fractional_scale_manager_v1_create(server->wl_display, 1); - server->ext_foreign_toplevel_image_capture_source_manager_v1 = - wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(server->wl_display, 1); - server->new_foreign_toplevel_capture_request.notify = handle_new_foreign_toplevel_capture_request; - wl_signal_add(&server->ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request, - &server->new_foreign_toplevel_capture_request); - server->tearing_control_v1 = wlr_tearing_control_manager_v1_create(server->wl_display, 1); server->tearing_control_new_object.notify = handle_new_tearing_hint; @@ -442,49 +393,11 @@ bool server_init(struct sway_server *server) { wl_signal_add(&server->xdg_activation_v1->events.new_token, &server->xdg_activation_v1_new_token); - struct wlr_xdg_toplevel_tag_manager_v1 *xdg_toplevel_tag_manager_v1 = - wlr_xdg_toplevel_tag_manager_v1_create(server->wl_display, 1); - server->xdg_toplevel_tag_manager_v1_set_tag.notify = - xdg_toplevel_tag_manager_v1_handle_set_tag; - wl_signal_add(&xdg_toplevel_tag_manager_v1->events.set_tag, - &server->xdg_toplevel_tag_manager_v1_set_tag); - struct wlr_cursor_shape_manager_v1 *cursor_shape_manager = wlr_cursor_shape_manager_v1_create(server->wl_display, 1); server->request_set_cursor_shape.notify = handle_request_set_cursor_shape; wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape); - if (server->renderer->features.input_color_transform) { - const enum wp_color_manager_v1_render_intent render_intents[] = { - WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL, - }; - const enum wp_color_manager_v1_transfer_function transfer_functions[] = { - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB, - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ, - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR, - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22, - WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT1886, - }; - const enum wp_color_manager_v1_primaries primaries[] = { - WP_COLOR_MANAGER_V1_PRIMARIES_SRGB, - WP_COLOR_MANAGER_V1_PRIMARIES_BT2020, - }; - struct wlr_color_manager_v1 *cm = wlr_color_manager_v1_create( - server->wl_display, 1, &(struct wlr_color_manager_v1_options){ - .features = { - .parametric = true, - .set_mastering_display_primaries = true, - }, - .render_intents = render_intents, - .render_intents_len = sizeof(render_intents) / sizeof(render_intents[0]), - .transfer_functions = transfer_functions, - .transfer_functions_len = sizeof(transfer_functions) / sizeof(transfer_functions[0]), - .primaries = primaries, - .primaries_len = sizeof(primaries) / sizeof(primaries[0]), - }); - wlr_scene_set_color_manager_v1(root->root_scene, cm); - } - wl_list_init(&server->pending_launcher_ctxs); // Avoid using "wayland-0" as display socket @@ -531,43 +444,14 @@ bool server_init(struct sway_server *server) { } void server_fini(struct sway_server *server) { - // remove listeners - wl_list_remove(&server->renderer_lost.link); - wl_list_remove(&server->new_output.link); - wl_list_remove(&server->layer_shell_surface.link); - wl_list_remove(&server->xdg_shell_toplevel.link); - wl_list_remove(&server->server_decoration.link); - wl_list_remove(&server->xdg_decoration.link); - wl_list_remove(&server->pointer_constraint.link); - wl_list_remove(&server->output_manager_apply.link); - wl_list_remove(&server->output_manager_test.link); - wl_list_remove(&server->output_power_manager_set_mode.link); -#if WLR_HAS_DRM_BACKEND - if (server->drm_lease_manager) { - wl_list_remove(&server->drm_lease_request.link); - } -#endif - wl_list_remove(&server->tearing_control_new_object.link); - wl_list_remove(&server->xdg_activation_v1_request_activate.link); - wl_list_remove(&server->xdg_activation_v1_new_token.link); - wl_list_remove(&server->xdg_toplevel_tag_manager_v1_set_tag.link); - wl_list_remove(&server->request_set_cursor_shape.link); - wl_list_remove(&server->new_foreign_toplevel_capture_request.link); - input_manager_finish(server->input); - // TODO: free sway-specific resources #if WLR_HAS_XWAYLAND - if (server->xwayland.wlr_xwayland != NULL) { - wl_list_remove(&server->xwayland_surface.link); - wl_list_remove(&server->xwayland_ready.link); - wlr_xwayland_destroy(server->xwayland.wlr_xwayland); - } + wlr_xwayland_destroy(server->xwayland.wlr_xwayland); #endif wl_display_destroy_clients(server->wl_display); wlr_backend_destroy(server->backend); wl_display_destroy(server->wl_display); list_free(server->dirty_nodes); - free(server->socket); } bool server_start(struct sway_server *server) { diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd index a1733aa2b..42e59d57d 100644 --- a/sway/sway-bar.5.scd +++ b/sway/sway-bar.5.scd @@ -143,12 +143,6 @@ runtime. This setting also applies to the current binding mode indicator. -The following commands may only be used at runtime. - -*mode* toggle [] - Toggles the current mode between _hide_ and _dock_. Any other mode - is treated as _hide_. - ## TRAY Swaybar provides a system tray where third-party applications may place icons. diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd index 18744a22a..fbef2a321 100644 --- a/sway/sway-input.5.scd +++ b/sway/sway-input.5.scd @@ -152,9 +152,8 @@ The following commands may only be used in the configuration file. *input* drag enabled|disabled Enables or disables tap-and-drag for specified input device. -*input* drag_lock enabled|disabled|enabled_sticky - Enables or disables drag lock for specified input device. The default is - _enabled_sticky_. +*input* drag_lock enabled|disabled + Enables or disables drag lock for specified input device. *input* dwt enabled|disabled Enables or disables disable-while-typing for the specified input device. diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd index 4b0d5c962..e90abcbb8 100644 --- a/sway/sway-ipc.7.scd +++ b/sway/sway-ipc.7.scd @@ -138,7 +138,7 @@ has the following properties: : Whether the workspace is currently focused by the default seat (_seat0_) |- urgent : boolean -: Whether a window on the workspace has the urgent flag set +: Whether a view on the workspace has the urgent flag set |- rect : object : The bounds of the workspace. It consists of _x_, _y_, _width_, and _height_ @@ -244,9 +244,6 @@ following properties: |- rect : object : The bounds for the output consisting of _x_, _y_, _width_, and _height_ -|- hdr -: boolean -: Whether HDR is enabled *Example Reply:* @@ -377,7 +374,7 @@ node and will have the following properties: that can be used as an aid in submitting reproduction steps for bug reports |- fullscreen_mode : integer -: (Only containers and windows) The fullscreen mode of the node. 0 means none, 1 means +: (Only containers and views) The fullscreen mode of the node. 0 means none, 1 means full workspace, and 2 means global fullscreen |- floating : string @@ -387,49 +384,32 @@ node and will have the following properties: : Whether the window is in the scratchpad. Can be either "none" or "fresh" |- app_id : string -: (Only windows) For an xdg-shell window, the name of the application, if set. +: (Only views) For an xdg-shell view, the name of the application, if set. Otherwise, _null_ |- pid : integer -: (Only windows) The PID of the application that owns the window -|- foreign_toplevel_identifier -: string -: (Only windows) The ext-foreign-toplevel-list-v1 toplevel identifier of this node. +: (Only views) The PID of the application that owns the view |- visible : boolean -: (Only windows) Whether the node is visible +: (Only views) Whether the node is visible |- shell : string -: (Only windows) The shell of the window, such as _xdg\_shell_ or _xwayland_ +: (Only views) The shell of the view, such as _xdg\_shell_ or _xwayland_ |- inhibit_idle : boolean -: (Only windows) Whether the window is inhibiting the idle state +: (Only views) Whether the view is inhibiting the idle state |- idle_inhibitors : object -: (Only windows) An object containing the state of the _application_ and _user_ idle inhibitors. +: (Only views) An object containing the state of the _application_ and _user_ idle inhibitors. _application_ can be _enabled_ or _none_. _user_ can be _focus_, _fullscreen_, _open_, _visible_ or _none_. -|- sandbox_engine -: string -: (Only windows) The associated sandbox engine (or _null_) -|- sandbox_app_id -: string -: (Only windows) The app ID provided by the associated sandbox engine (or _null_) -|- sandbox_instance_id -: string -: (Only windows) The instance ID provided by the associated sandbox engine (or - _null_) -|- tag -: string -: (Only windows) For an xdg-shell window, tag of the toplevel, if set. - Otherwise, _null_ |- window : integer -: (Only xwayland windows) The X11 window ID for the xwayland window +: (Only xwayland views) The X11 window ID for the xwayland view |- window_properties : object -: (Only xwayland windows) An object containing the _title_, _class_, _instance_, - _window\_role_, _window\_type_, and _transient\_for_ for the window +: (Only xwayland views) An object containing the _title_, _class_, _instance_, + _window\_role_, _window\_type_, and _transient\_for_ for the view *Example Reply:* @@ -934,13 +914,13 @@ containing the _#RRGGBBAA_ representation of the color: that are not visible |- urgent_workspace_text : The color to use for the text of the workspace buttons for workspaces that - contain an urgent window + contain an urgent view |- urgent_workspace_bg : The color to use for the background of the workspace buttons for workspaces - that contain an urgent window + that contain an urgent view |- urgent_workspace_border : The color to use for the border of the workspace buttons for workspaces that - contain an urgent window + contain an urgent view |- binding_mode_text : The color to use for the text of the binding mode indicator |- binding_mode_bg @@ -1194,8 +1174,7 @@ following properties will be included for devices that support them: : Whether tap-and-drag is enabled. It can be _enabled_ or _disabled_ |- tap_drag_lock : string -: Whether drag-lock is enabled. It can be _enabled_, _disabled_ or - _enabled_sticky_ +: Whether drag-lock is enabled. It can be _enabled_ or _disabled_ |- accel_speed : double : The pointer-acceleration in use @@ -1487,7 +1466,7 @@ available: : Sent whenever the binding mode changes |- 0x80000003 : window -: Sent whenever an event involving a window occurs such as being reparented, +: Sent whenever an event involving a view occurs such as being reparented, focused, or closed |- 0x80000004 : barconfig_update @@ -1543,8 +1522,8 @@ The following change types are currently available: |- rename : The workspace was renamed |- urgent -: A window on the workspace has had their urgency hint set or all urgency hints - for windows on the workspace have been cleared +: A view on the workspace has had their urgency hint set or all urgency hints + for views on the workspace have been cleared |- reload : The configuration file has been reloaded @@ -1642,7 +1621,7 @@ with the following properties: ## 0x80000003. WINDOW -Sent whenever a change involving a window occurs. The event consists of a single +Sent whenever a change involving a view occurs. The event consists of a single object with the following properties: [- *PROPERTY* @@ -1653,30 +1632,30 @@ object with the following properties: :[ The type of change that occurred. See below for more information |- container : object -: An object representing the window effected +: An object representing the view effected The following change types are currently available: [- *TYPE* :- *DESCRIPTION* |- new -:[ The window was created +:[ The view was created |- close -: The window was closed +: The view was closed |- focus -: The window was focused +: The view was focused |- title -: The window's title has changed +: The view's title has changed |- fullscreen_mode -: The window's fullscreen mode has changed +: The view's fullscreen mode has changed |- move -: The window has been reparented in the tree +: The view has been reparented in the tree |- floating -: The window has become floating or is no longer floating +: The view has become floating or is no longer floating |- urgent -: The window's urgency hint has changed status +: The view's urgency hint has changed status |- mark -: A mark has been added or removed from the window +: A mark has been added or removed from the view *Example Event:* diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index cc48589c3..dc16c257b 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -196,9 +196,9 @@ must be separated by one space. For example: screen tearing is allowed. With immediate page flips, frames from the client are presented as soon - as possible instead of synchronizing with the monitor's vblank interval - (VSync). - + as possible instead of synchronizing with the monitor's vblank interval + (VSync). + It is recommended to set *max_render_time* to *off*. In that case a page flip happens as soon as a client updates. Otherwise, tearing will only happen if rendering takes longer than the configured milliseconds before the next @@ -210,17 +210,6 @@ must be separated by one space. For example: This setting only has effect when a window is fullscreen on the output. -*output* hdr on|off|toggle - Enables or disables HDR (High Dynamic Range). HDR enables a larger color - gamut and brightness range. HDR uses the BT2020 primaries and the PQ - transfer function. - - When HDR is enabled, _render_bit_depth_ is implicitly set to 10 unless - explicitly configured. Using a lower render bit depth may result in color - banding artifacts. - - HDR needs to be supported by the output and renderer to be enabled. - # SEE ALSO *sway*(5) *sway-input*(5) diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 53393bcc9..bb958ebfd 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -66,8 +66,8 @@ The following commands may only be used in the configuration file. *default_orientation* horizontal|vertical|auto Sets the default container layout for tiled containers. -*include* - Include files from _paths_. _paths_ can include either a full path or a +*include* + Includes another file from _path_. _path_ can be either a full path or a path relative to the parent config, and expands shell syntax (see *wordexp*(3) for details). The same include file can only be included once; subsequent attempts will be ignored. @@ -106,9 +106,9 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). *border* none|normal|csd|pixel [] Set border style for focused window. _normal_ includes a border of thickness _n_ and a title bar. _pixel_ is a border without title bar _n_ - pixels thick. The title bar always shows in stacking or tabbed layouts. - _csd_ is short for client-side-decorations, which allows the client to draw - its own decorations. Default is _normal_ with border thickness 2. + pixels thick. Default is _normal_ with border thickness 2. _csd_ is short + for client-side-decorations, which allows the client to draw its own + decorations. *border* toggle Cycles through the available border styles. @@ -117,7 +117,7 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). Exit sway and end your Wayland session. *floating* enable|disable|toggle - Make focused window floating, non-floating, or the opposite of what it is now. + Make focused view floating, non-floating, or the opposite of what it is now. *focus* Moves focus to the container that matches the specified criteria. @@ -152,9 +152,9 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). Moves focus between the floating and tiled layers. *fullscreen* [enable|disable|toggle] [global] - Makes focused window fullscreen, non-fullscreen, or the opposite of what it + Makes focused view fullscreen, non-fullscreen, or the opposite of what it is now. If no argument is given, it does the same as _toggle_. If _global_ - is specified, the window will be fullscreen across all outputs. + is specified, the view will be fullscreen across all outputs. *gaps* inner|outer|horizontal|vertical|top|right|bottom|left all|current set|plus|minus|toggle @@ -164,16 +164,16 @@ set|plus|minus|toggle _vertical_. *inhibit_idle* focus|fullscreen|open|none|visible - Set/unset an idle inhibitor for the window. _focus_ will inhibit idle when - the window is focused by any seat. _fullscreen_ will inhibit idle when the + Set/unset an idle inhibitor for the view. _focus_ will inhibit idle when + the view is focused by any seat. _fullscreen_ will inhibit idle when the view is fullscreen (or a descendant of a fullscreen container) and is - visible. _open_ will inhibit idle until the window is closed (or the - inhibitor is unset/changed). _visible_ will inhibit idle when the window is + visible. _open_ will inhibit idle until the view is closed (or the + inhibitor is unset/changed). _visible_ will inhibit idle when the view is visible on any output. _none_ will remove any existing idle inhibitor for - the window. + the view. This can also be used with criteria to set an idle inhibitor for any - existing window or with _for_window_ to set idle inhibitors for future windows. + existing view or with _for_window_ to set idle inhibitors for future views. *layout* default|splith|splitv|stacking|tabbed Sets the layout mode of the focused container. @@ -228,8 +228,8 @@ set|plus|minus|toggle regardless of the tearing hints. This setting only has an effect if tearing is allowed on the output through - the per-output *allow_tearing* setting. See *sway-output*(5) for further - details. + the per-output *allow_tearing* setting. See *sway-output*(5) + for further details. *move* left|right|up|down [ px] Moves the focused container in the direction specified. The optional _px_ @@ -302,34 +302,28 @@ set|plus|minus|toggle *rename* workspace [] to Rename either or the focused workspace to the -*resize* shrink|grow up|right|down|left|width|height [ [px|ppt]] +*resize* shrink|grow width|height [ [px|ppt]] Resizes the currently focused container by _amount_, specified in pixels or percentage points. If the units are omitted, floating containers are resized in px and tiled containers by ppt. _amount_ will default to 10 if omitted. - For tiling containers, space is taken/given from the container in the - specified direction. If _width_ or _height_ is specified, space will be - taken/given from all other containers. *resize* set height [px|ppt] Sets the height of the container to _height_, specified in pixels or percentage points. If the units are omitted, floating containers are resized in px and tiled containers by ppt. If _height_ is 0, the container - will not be resized. For tiling containers, space is taken/given from all - other containers. + will not be resized. *resize* set [width] [px|ppt] Sets the width of the container to _width_, specified in pixels or percentage points. If the units are omitted, floating containers are resized in px and tiled containers by ppt. If _width_ is 0, the container - will not be resized. For tiling containers, space is taken/given from all - other containers. + will not be resized. *resize* set [width] [px|ppt] [height] [px|ppt] Sets the width and height of the container to _width_ and _height_, specified in pixels or percentage points. If the units are omitted, floating containers are resized in px and tiled containers by ppt. If _width_ or _height_ is 0, the container will not be resized on that axis. - For tiling containers, space is taken/given from all other containers. *scratchpad* show Shows a window from the scratchpad. Repeatedly using this command will @@ -337,12 +331,12 @@ set|plus|minus|toggle *shortcuts_inhibitor* enable|disable Enables or disables the ability of clients to inhibit keyboard - shortcuts for a window. This is primarily useful for virtualization and - remote desktop software. It affects either the currently focused window - or a set of windows selected by criteria. Subcommand _disable_ - additionally deactivates any active inhibitors for the given window(s). + shortcuts for a view. This is primarily useful for virtualization and + remote desktop software. It affects either the currently focused view + or a set of views selected by criteria. Subcommand _disable_ + additionally deactivates any active inhibitors for the given view(s). Criteria are particularly useful with the *for_window* command to - configure a class of windows differently from the per-seat defaults + configure a class of views differently from the per-seat defaults established by the *seat* subcommand of the same name. See *sway-input*(5) for more ways to affect inhibitors. @@ -370,7 +364,7 @@ set|plus|minus|toggle Swaps the position, geometry, and fullscreen status of two containers. The first container can be selected either by criteria or focus. The second container can be selected by _id_, _con_id_, or _mark_. _id_ can only be - used with xwayland windows. If the first container has focus, it will retain + used with xwayland views. If the first container has focus, it will retain focus unless it is moved to a different workspace or the second container becomes fullscreen on the same workspace as the first container. In either of those cases, the second container will gain focus. @@ -378,29 +372,12 @@ set|plus|minus|toggle *title_format* Sets the format of window titles. The following placeholders may be used: - *%title* - The title supplied by the window - - *%app_id* - The wayland app ID (applicable to wayland windows only) - - *%class* - The X11 classname (applicable to xwayland windows only) - - *%instance* - The X11 instance (applicable to xwayland windows only) - - *%shell* - The protocol the window is using (typically xwayland or xdg_shell) - - *%sandbox_engine* - The associated sandbox engine - - *%sandbox_app_id* - The app ID provided by the associated sandbox engine - - *%sandbox_instance_id* - The instance ID provided by the associated sandbox engine + %title - The title supplied by the window ++ + %app_id - The wayland app ID (applicable to wayland windows only) ++ + %class - The X11 classname (applicable to xwayland windows only) ++ + %instance - The X11 instance (applicable to xwayland windows only) ++ + %shell - The protocol the window is using (typically xwayland or + xdg_shell) This command is typically used with *for_window* criteria. For example: @@ -415,14 +392,14 @@ The following commands may be used either in the configuration file or at runtime. *assign* [→] [workspace] [number] - Assigns windows matching _criteria_ (see *CRITERIA* for details) to + Assigns views matching _criteria_ (see *CRITERIA* for details) to _workspace_. The → (U+2192) is optional and cosmetic. This command is equivalent to: for_window move container to workspace *assign* [→] output left|right|up|down| - Assigns windows matching _criteria_ (see *CRITERIA* for details) to the + Assigns views matching _criteria_ (see *CRITERIA* for details) to the specified output. The → (U+2192) is optional and cosmetic. This command is equivalent to: @@ -605,10 +582,10 @@ runtime. The window that has focus. *client.focused_inactive* - The most recently focused window within a container which is not focused. + The most recently focused view within a container which is not focused. *client.focused_tab_title* - A window that has focused descendant container. + A view that has focused descendant container. Tab or stack container title that is the parent of the focused container but is not directly focused. Defaults to focused_inactive if not specified and does not use the indicator and child_border colors. @@ -617,10 +594,10 @@ runtime. Ignored (present for i3 compatibility). *client.unfocused* - A window that does not have focus. + A view that does not have focus. *client.urgent* - A window with an urgency hint. *Note*: Native Wayland windows do not + A view with an urgency hint. *Note*: Native Wayland windows do not support urgency. Urgency only works for Xwayland windows. The meaning of each color is: @@ -635,12 +612,12 @@ runtime. The text color of the title bar. _indicator_ - The color used to indicate where a new window will open. In a tiled - container, this would paint the right border of the current window if a - new window would be opened to the right. + The color used to indicate where a new view will open. In a tiled + container, this would paint the right border of the current view if a + new view would be opened to the right. _child_border_ - The border around the window itself. + The border around the view itself. The default colors are: @@ -778,7 +755,7 @@ The default colors are: *gaps* inner|outer|horizontal|vertical|top|right|bottom|left Sets default _amount_ pixels of _inner_ or _outer_ gap, where the inner - affects spacing around each window and outer affects the spacing around each + affects spacing around each view and outer affects the spacing around each workspace. Outer gaps are in addition to inner gaps. To reduce or remove outer gaps, outer gaps can be set to a negative value. _outer_ gaps can also be specified per side with _top_, _right_, _bottom_, and _left_ or @@ -850,9 +827,9 @@ The default colors are: A list of output names may be obtained via *swaymsg -t get_outputs*. *popup_during_fullscreen* smart|ignore|leave_fullscreen - Determines what to do when a fullscreen window opens a dialog. + Determines what to do when a fullscreen view opens a dialog. If _smart_ (the default), the dialog will be displayed. If _ignore_, the - dialog will not be rendered. If _leave_fullscreen_, the window will exit + dialog will not be rendered. If _leave_fullscreen_, the view will exit fullscreen mode and the dialog will be rendered. *primary_selection* enabled|disabled @@ -978,18 +955,18 @@ The default colors are: A criteria is a string in the form of, for example: ``` -[app_id="some-application" title="[Rr]egex.*"] +[class="[Rr]egex.*" title="some title"] ``` The string contains one or more (space separated) attribute/value pairs. They -are used by some commands to choose which windows to execute actions on. All +are used by some commands to choose which views to execute actions on. All attributes must match for the criteria to match. Criteria is retained across commands separated by a *,*, but will be reset (and allow for new criteria, if desired) for commands separated by a *;*. Criteria may be used with either the *for_window* or *assign* commands to -specify operations to perform on new windows. A criteria may also be used to -perform specific commands (ones that normally act upon one window) on all windows +specify operations to perform on new views. A criteria may also be used to +perform specific commands (ones that normally act upon one window) on all views that match that criteria. For example: Focus on a window with the mark "IRC": @@ -998,19 +975,10 @@ Focus on a window with the mark "IRC": [con_mark="IRC"] focus ``` -Kill all windows where the title contains "Emacs": +Kill all windows with the title "Emacs": ``` -[title="Emacs"] kill -``` - -Several attributes allow regular expressions. These use Perl-compatible regular -expressions (PCRE2), which are documented in *pcre2pattern*(3) and summarized in -*pcre2syntax*(3). For example, this moves all windows with titles ending in -"sway" or "Sway" to workspace 1: - -``` -[title="[Ss]way$"] move workspace 1 +[class="Emacs"] kill ``` You may like to use swaymsg -t get_tree for finding the values of these @@ -1061,9 +1029,6 @@ The following attributes may be matched with: Can be a regular expression. If value is \_\_focused\_\_, then the shell must be the same as that of the currently focused window. -*tag* - Compare value against the tag. _tag_ is specific to Wayland applications. - *tiling* Matches tiling windows. @@ -1089,27 +1054,10 @@ The following attributes may be matched with: applications and requires XWayland. *workspace* - Compare against the workspace name for this window. Can be a regular - expression. If the value is \_\_focused\_\_, then all the windows on the + Compare against the workspace name for this view. Can be a regular + expression. If the value is \_\_focused\_\_, then all the views on the currently focused workspace matches. -*sandbox_engine* - Compare against the associated sandbox engine. Can be a regular expression. - If the value is \_\_focused\_\_, then the sandbox engine must be the same as - that of the currently focused window. - -*sandbox_app_id* - Compare against the app ID provided by the associated sandbox engine. Can be - a regular expression. If the value is \_\_focused\_\_, then the sandbox app - ID must be the same as that of the currently focused window. - -*sandbox_instance_id* - Compare against the instance ID provided by the associated sandbox engine. - Can be a regular expression. If the value is \_\_focused\_\_, then the - sandbox instance ID must be the same as that of the currently focused - window. - # SEE ALSO *sway*(1) *sway-input*(5) *sway-output*(5) *sway-bar*(5) *sway-ipc*(7) -*pcre2pattern*(3) *pcre2syntax*(3) diff --git a/sway/sway_text_node.c b/sway/sway_text_node.c index 89ece91e2..7c7813559 100644 --- a/sway/sway_text_node.c +++ b/sway/sway_text_node.c @@ -64,6 +64,18 @@ static int get_text_width(struct sway_text_node *props) { return MAX(width, 0); } +static void update_source_box(struct text_buffer *buffer) { + struct sway_text_node *props = &buffer->props; + struct wlr_fbox source_box = { + .x = 0, + .y = 0, + .width = ceil(get_text_width(props) * buffer->scale), + .height = ceil(props->height * buffer->scale), + }; + + wlr_scene_buffer_set_source_box(buffer->buffer_node, &source_box); +} + static void render_backing_buffer(struct text_buffer *buffer) { if (!buffer->visible) { return; @@ -75,7 +87,7 @@ static void render_backing_buffer(struct text_buffer *buffer) { } float scale = buffer->scale; - int width = ceil(get_text_width(&buffer->props) * scale); + int width = ceil(buffer->props.width * scale); int height = ceil(buffer->props.height * scale); float *color = (float *)&buffer->props.color; float *background = (float *)&buffer->props.background; @@ -135,12 +147,13 @@ static void render_backing_buffer(struct text_buffer *buffer) { wlr_scene_buffer_set_buffer(buffer->buffer_node, &cairo_buffer->base); wlr_buffer_drop(&cairo_buffer->base); + update_source_box(buffer); pixman_region32_t opaque; pixman_region32_init(&opaque); if (background[3] == 1) { pixman_region32_union_rect(&opaque, &opaque, 0, 0, - get_text_width(&buffer->props), buffer->props.height); + buffer->props.width, buffer->props.height); } wlr_scene_buffer_set_opaque_region(buffer->buffer_node, &opaque); pixman_region32_fini(&opaque); @@ -287,6 +300,7 @@ void sway_text_node_set_max_width(struct sway_text_node *node, int max_width) { buffer->props.max_width = max_width; wlr_scene_buffer_set_dest_size(buffer->buffer_node, get_text_width(&buffer->props), buffer->props.height); + update_source_box(buffer); render_backing_buffer(buffer); } diff --git a/sway/swaynag.c b/sway/swaynag.c index 204a5791a..bc5e23ea4 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -63,27 +63,36 @@ bool swaynag_spawn(const char *swaynag_command, sway_log(SWAY_ERROR, "Failed to create fork for swaynag"); goto failed; } else if (pid == 0) { - if (!sway_set_cloexec(sockets[1], false)) { + restore_nofile_limit(); + + pid = fork(); + if (pid < 0) { + sway_log_errno(SWAY_ERROR, "fork failed"); + _exit(EXIT_FAILURE); + } else if (pid == 0) { + if (!sway_set_cloexec(sockets[1], false)) { + _exit(EXIT_FAILURE); + } + + if (swaynag->detailed) { + close(swaynag->fd[1]); + dup2(swaynag->fd[0], STDIN_FILENO); + close(swaynag->fd[0]); + } + + char wayland_socket_str[16]; + snprintf(wayland_socket_str, sizeof(wayland_socket_str), + "%d", sockets[1]); + setenv("WAYLAND_SOCKET", wayland_socket_str, true); + + size_t length = strlen(swaynag_command) + strlen(swaynag->args) + 2; + char *cmd = malloc(length); + snprintf(cmd, length, "%s %s", swaynag_command, swaynag->args); + execlp("sh", "sh", "-c", cmd, NULL); + sway_log_errno(SWAY_ERROR, "execlp failed"); _exit(EXIT_FAILURE); } - - if (swaynag->detailed) { - close(swaynag->fd[1]); - dup2(swaynag->fd[0], STDIN_FILENO); - close(swaynag->fd[0]); - } - - char wayland_socket_str[16]; - snprintf(wayland_socket_str, sizeof(wayland_socket_str), - "%d", sockets[1]); - setenv("WAYLAND_SOCKET", wayland_socket_str, true); - - size_t length = strlen(swaynag_command) + strlen(swaynag->args) + 2; - char *cmd = malloc(length); - snprintf(cmd, length, "%s %s", swaynag_command, swaynag->args); - execlp("sh", "sh", "-c", cmd, NULL); - sway_log_errno(SWAY_ERROR, "execlp failed"); - _exit(EXIT_FAILURE); + _exit(EXIT_SUCCESS); } if (swaynag->detailed) { @@ -98,6 +107,11 @@ bool swaynag_spawn(const char *swaynag_command, return false; } + if (waitpid(pid, NULL, 0) < 0) { + sway_log_errno(SWAY_ERROR, "waitpid failed"); + return false; + } + return true; failed: @@ -147,3 +161,4 @@ void swaynag_show(struct swaynag_instance *swaynag) { close(swaynag->fd[1]); } } + diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index faf54d02a..2b95a6dc9 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -29,7 +29,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { } } - // Calculate each width fraction + // Calculate each height fraction double total_width_fraction = 0; for (int i = 0; i < children->length; ++i) { struct sway_container *child = children->items[i]; @@ -82,18 +82,12 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { child->pending.y = parent->y; child->pending.width = round(child->width_fraction * child_total_width); child->pending.height = parent->height; + child_x += child->pending.width + inner_gap; // Make last child use remaining width of parent if (i == children->length - 1) { child->pending.width = parent->x + parent->width - child->pending.x; } - - // Arbitrary lower bound for window size - if (child->pending.width < 10 || child->pending.height < 10) { - child->pending.width = 0; - child->pending.height = 0; - } - child_x += child->pending.width + inner_gap; } } @@ -167,18 +161,12 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { child->pending.y = child_y; child->pending.width = parent->width; child->pending.height = round(child->height_fraction * child_total_height); + child_y += child->pending.height + inner_gap; // Make last child use remaining height of parent if (i == children->length - 1) { child->pending.height = parent->y + parent->height - child->pending.y; } - - // Arbitrary lower bound for window size - if (child->pending.width < 10 || child->pending.height < 10) { - child->pending.width = 0; - child->pending.height = 0; - } - child_y += child->pending.height + inner_gap; } } diff --git a/sway/tree/container.c b/sway/tree/container.c index c9ec852fc..f482b06bc 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -7,6 +7,7 @@ #include #include #include +#include "linux-dmabuf-unstable-v1-protocol.h" #include "sway/config.h" #include "sway/desktop/transaction.h" #include "sway/input/input-manager.h" @@ -49,14 +50,6 @@ static void handle_output_leave( } } -static void handle_destroy( - struct wl_listener *listener, void *data) { - struct sway_container *con = wl_container_of( - listener, con, output_handler_destroy); - - container_begin_destroy(con); -} - static bool handle_point_accepts_input( struct wlr_scene_buffer *buffer, double *x, double *y) { return false; @@ -142,9 +135,6 @@ struct sway_container *container_create(struct sway_view *view) { c->output_leave.notify = handle_output_leave; wl_signal_add(&c->output_handler->events.output_leave, &c->output_leave); - c->output_handler_destroy.notify = handle_destroy; - wl_signal_add(&c->output_handler->node.events.destroy, - &c->output_handler_destroy); c->output_handler->point_accepts_input = handle_point_accepts_input; } } @@ -359,7 +349,7 @@ void container_arrange_title_bar(struct sway_container *con) { h_padding = width - config->titlebar_h_padding - marks_buffer_width; } - h_padding = MAX(h_padding, config->titlebar_h_padding); + h_padding = MAX(h_padding, 0); int alloc_width = MIN((int)node->width, width - h_padding - config->titlebar_h_padding); @@ -385,7 +375,7 @@ void container_arrange_title_bar(struct sway_container *con) { h_padding = config->titlebar_h_padding; } - h_padding = MAX(h_padding, config->titlebar_h_padding); + h_padding = MAX(h_padding, 0); int alloc_width = MIN((int) node->width, width - h_padding - config->titlebar_h_padding); @@ -546,8 +536,8 @@ void container_begin_destroy(struct sway_container *con) { container_end_mouse_operation(con); - node_set_dirty(&con->node); con->node.destroying = true; + node_set_dirty(&con->node); if (con->scratchpad) { root_scratchpad_remove_container(con); @@ -560,12 +550,6 @@ void container_begin_destroy(struct sway_container *con) { if (con->pending.parent || con->pending.workspace) { container_detach(con); } - - if (con->view && con->view->container == con) { - wl_list_remove(&con->output_enter.link); - wl_list_remove(&con->output_leave.link); - wl_list_remove(&con->output_handler_destroy.link); - } } void container_reap_empty(struct sway_container *con) { @@ -710,35 +694,26 @@ size_t parse_title_format(struct sway_container *container, char *buffer) { len += next - format; format = next; - if (has_prefix(next, "%title")) { + if (strncmp(next, "%title", 6) == 0) { if (container->view) { len += append_prop(buffer, view_get_title(container->view)); } else { len += container_build_representation(container->pending.layout, container->pending.children, buffer); } - format += strlen("%title"); + format += 6; } else if (container->view) { - if (has_prefix(next, "%app_id")) { + if (strncmp(next, "%app_id", 7) == 0) { len += append_prop(buffer, view_get_app_id(container->view)); - format += strlen("%app_id"); - } else if (has_prefix(next, "%class")) { + format += 7; + } else if (strncmp(next, "%class", 6) == 0) { len += append_prop(buffer, view_get_class(container->view)); - format += strlen("%class"); - } else if (has_prefix(next, "%instance")) { + format += 6; + } else if (strncmp(next, "%instance", 9) == 0) { len += append_prop(buffer, view_get_instance(container->view)); - format += strlen("%instance"); - } else if (has_prefix(next, "%shell")) { + format += 9; + } else if (strncmp(next, "%shell", 6) == 0) { len += append_prop(buffer, view_get_shell(container->view)); - format += strlen("%shell"); - } else if (has_prefix(next, "%sandbox_engine")) { - len += append_prop(buffer, view_get_sandbox_engine(container->view)); - format += strlen("%sandbox_engine"); - } else if (has_prefix(next, "%sandbox_app_id")) { - len += append_prop(buffer, view_get_sandbox_app_id(container->view)); - format += strlen("%sandbox_app_id"); - } else if (has_prefix(next, "%sandbox_instance_id")) { - len += append_prop(buffer, view_get_sandbox_instance_id(container->view)); - format += strlen("%sandbox_instance_id"); + format += 6; } else { lenient_strcat(buffer, "%"); ++format; @@ -801,7 +776,7 @@ size_t container_build_representation(enum sway_container_layout layout, len += strlen(identifier); lenient_strcat(buffer, identifier); } else { - len += strlen("(null)"); + len += 6; lenient_strcat(buffer, "(null)"); } } diff --git a/sway/tree/node.c b/sway/tree/node.c index 48ae325e4..7aaf97627 100644 --- a/sway/tree/node.c +++ b/sway/tree/node.c @@ -29,7 +29,7 @@ const char *node_type_to_str(enum sway_node_type type) { } void node_set_dirty(struct sway_node *node) { - if (node->dirty || node->destroying) { + if (node->dirty) { return; } node->dirty = true; diff --git a/sway/tree/output.c b/sway/tree/output.c index 90ec9331d..44b941ca2 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -37,7 +37,7 @@ static void restore_workspaces(struct sway_output *output) { for (int j = 0; j < other->workspaces->length; j++) { struct sway_workspace *ws = other->workspaces->items[j]; struct sway_output *highest = - workspace_output_get_highest_available(ws); + workspace_output_get_highest_available(ws, NULL); if (highest == output) { workspace_detach(ws); output_add_workspace(output, ws); @@ -136,11 +136,12 @@ struct sway_output *output_create(struct wlr_output *wlr_output) { output->detected_subpixel = wlr_output->subpixel; output->scale_filter = SCALE_FILTER_NEAREST; + wl_signal_init(&output->events.disable); + wl_list_insert(&root->all_outputs, &output->link); output->workspaces = create_list(); output->current.workspaces = create_list(); - wl_list_init(&output->layer_surfaces); return output; } @@ -204,8 +205,11 @@ static void output_evacuate(struct sway_output *output) { return; } struct sway_output *fallback_output = NULL; - if (root->outputs->length > 0) { + if (root->outputs->length > 1) { fallback_output = root->outputs->items[0]; + if (fallback_output == output) { + fallback_output = root->outputs->items[1]; + } } while (output->workspaces->length) { @@ -214,7 +218,7 @@ static void output_evacuate(struct sway_output *output) { workspace_detach(workspace); struct sway_output *new_output = - workspace_output_get_highest_available(workspace); + workspace_output_get_highest_available(workspace, output); if (!new_output) { new_output = fallback_output; } @@ -269,6 +273,7 @@ void output_destroy(struct sway_output *output) { destroy_scene_layers(output); list_free(output->workspaces); list_free(output->current.workspaces); + wl_event_source_remove(output->repaint_timer); wlr_color_transform_unref(output->color_transform); free(output); } @@ -283,15 +288,13 @@ void output_disable(struct sway_output *output) { } sway_log(SWAY_DEBUG, "Disabling output '%s'", output->wlr_output->name); + wl_signal_emit_mutable(&output->events.disable, output); - // Remove the output now to avoid interacting with it during e.g., - // transactions, as the output might be physically removed with the scene - // output destroyed. - list_del(root->outputs, index); - output->enabled = false; - - destroy_layers(output); output_evacuate(output); + + list_del(root->outputs, index); + + output->enabled = false; } void output_begin_destroy(struct sway_output *output) { @@ -301,8 +304,8 @@ void output_begin_destroy(struct sway_output *output) { sway_log(SWAY_DEBUG, "Destroying output '%s'", output->wlr_output->name); wl_signal_emit_mutable(&output->node.events.destroy, &output->node); - node_set_dirty(&output->node); output->node.destroying = true; + node_set_dirty(&output->node); } struct sway_output *output_from_wlr_output(struct wlr_output *output) { diff --git a/sway/tree/root.c b/sway/tree/root.c index cf7170a48..19d072b5c 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -199,8 +199,6 @@ void root_scratchpad_show(struct sway_container *con) { if (old_ws) { workspace_consider_destroy(old_ws); } - - container_raise_floating(con); } static void disable_fullscreen(struct sway_container *con, void *data) { @@ -214,7 +212,9 @@ void root_scratchpad_hide(struct sway_container *con) { struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); struct sway_workspace *ws = con->pending.workspace; - if (!con->pending.workspace) { + if (con->pending.fullscreen_mode == FULLSCREEN_GLOBAL && !con->pending.workspace) { + // If the container was made fullscreen global while in the scratchpad, + // it should be shown until fullscreen has been disabled return; } diff --git a/sway/tree/view.c b/sway/tree/view.c index 3d6211249..ebf98faaa 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -8,11 +8,9 @@ #include #include #include -#include #include #include #include -#include #if WLR_HAS_XWAYLAND #include #endif @@ -49,11 +47,6 @@ bool view_init(struct sway_view *view, enum sway_view_type type, failed = true; } - view->image_capture_scene = wlr_scene_create(); - if (view->image_capture_scene == NULL) { - failed = true; - } - if (failed) { wlr_scene_node_destroy(&view->scene_tree->node); return false; @@ -86,7 +79,6 @@ void view_destroy(struct sway_view *view) { list_free(view->executed_criteria); view_assign_ctx(view, NULL); - wlr_scene_node_destroy(&view->image_capture_scene->tree.node); wlr_scene_node_destroy(&view->scene_tree->node); if (view->impl->destroy) { view->impl->destroy(view); @@ -162,41 +154,6 @@ uint32_t view_get_window_type(struct sway_view *view) { return 0; } -static const struct wlr_security_context_v1_state *security_context_from_view( - struct sway_view *view) { - const struct wl_client *client = - wl_resource_get_client(view->surface->resource); - const struct wlr_security_context_v1_state *security_context = - wlr_security_context_manager_v1_lookup_client( - server.security_context_manager_v1, client); - return security_context; -} - -const char *view_get_sandbox_engine(struct sway_view *view) { - const struct wlr_security_context_v1_state *security_context = - security_context_from_view(view); - return security_context ? security_context->sandbox_engine : NULL; -} - -const char *view_get_sandbox_app_id(struct sway_view *view) { - const struct wlr_security_context_v1_state *security_context = - security_context_from_view(view); - return security_context ? security_context->app_id : NULL; -} - -const char *view_get_sandbox_instance_id(struct sway_view *view) { - const struct wlr_security_context_v1_state *security_context = - security_context_from_view(view); - return security_context ? security_context->instance_id : NULL; -} - -const char *view_get_tag(struct sway_view *view) { - if (view->impl->get_string_prop) { - return view->impl->get_string_prop(view, VIEW_PROP_TAG); - } - return NULL; -} - const char *view_get_shell(struct sway_view *view) { switch(view->type) { case SWAY_VIEW_XDG_SHELL: @@ -231,10 +188,6 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, } bool view_inhibit_idle(struct sway_view *view) { - if (server.session_lock.lock) { - return false; - } - struct sway_idle_inhibitor_v1 *user_inhibitor = sway_idle_inhibit_v1_user_inhibitor_for_view(view); @@ -530,12 +483,10 @@ void view_execute_criteria(struct sway_view *view) { sway_log(SWAY_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", criteria->raw, view, criteria->cmdlist); list_add(view->executed_criteria, criteria); - list_t *res_list = execute_command(criteria->cmdlist, NULL, view->container); + list_t *res_list = execute_command( + criteria->cmdlist, NULL, view->container); while (res_list->length) { struct cmd_results *res = res_list->items[0]; - if (res->status != CMD_SUCCESS) { - sway_log(SWAY_ERROR, "for_window '%s' failed: %s", criteria->raw, res->error); - } free_cmd_results(res); list_del(res_list, 0); } @@ -828,7 +779,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, }; view->ext_foreign_toplevel = wlr_ext_foreign_toplevel_handle_v1_create(server.foreign_toplevel_list, &foreign_toplevel_state); - view->ext_foreign_toplevel->data = view; view->foreign_toplevel = wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager); @@ -898,7 +848,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, #if WLR_HAS_XWAYLAND struct wlr_xwayland_surface *xsurface; if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface))) { - set_focus &= wlr_xwayland_surface_icccm_input_model(xsurface) != + set_focus &= wlr_xwayland_icccm_input_model(xsurface) != WLR_ICCCM_INPUT_MODEL_NONE; } #endif @@ -1031,9 +981,6 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { if (wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) { return NULL; } - if (wlr_session_lock_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) { - return NULL; - } const char *role = wlr_surface->role ? wlr_surface->role->name : NULL; sway_log(SWAY_DEBUG, "Surface of unknown type (role %s): %p", @@ -1206,10 +1153,6 @@ static void view_save_buffer_iterator(struct wlr_scene_buffer *buffer, wlr_scene_buffer_set_dest_size(sbuf, buffer->dst_width, buffer->dst_height); wlr_scene_buffer_set_opaque_region(sbuf, &buffer->opaque_region); - wlr_scene_buffer_set_opacity(sbuf, buffer->opacity); - wlr_scene_buffer_set_filter_mode(sbuf, buffer->filter_mode); - wlr_scene_buffer_set_transfer_function(sbuf, buffer->transfer_function); - wlr_scene_buffer_set_primaries(sbuf, buffer->primaries); wlr_scene_buffer_set_source_box(sbuf, &buffer->src_box); wlr_scene_node_set_position(&sbuf->node, sx, sy); wlr_scene_buffer_set_transform(sbuf, buffer->transform); @@ -1260,11 +1203,7 @@ bool view_can_tear(struct sway_view *view) { static void send_frame_done_iterator(struct wlr_scene_buffer *scene_buffer, int x, int y, void *data) { struct timespec *when = data; - struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(scene_buffer); - if (scene_surface == NULL) { - return; - } - wlr_surface_send_frame_done(scene_surface->surface, when); + wl_signal_emit_mutable(&scene_buffer->events.frame_done, when); } void view_send_frame_done(struct sway_view *view) { diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 733a002b4..f8709a4c7 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -166,8 +166,8 @@ void workspace_begin_destroy(struct sway_workspace *workspace) { if (workspace->output) { workspace_detach(workspace); } - node_set_dirty(&workspace->node); workspace->node.destroying = true; + node_set_dirty(&workspace->node); } void workspace_consider_destroy(struct sway_workspace *ws) { @@ -246,7 +246,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding, } // If the command is workspace number , isolate the name - if (has_prefix(_target, "number ")) { + if (strncmp(_target, "number ", strlen("number ")) == 0) { size_t length = strlen(_target) - strlen("number ") + 1; char *temp = malloc(length); strncpy(temp, _target + strlen("number "), length - 1); @@ -659,9 +659,13 @@ void workspace_output_add_priority(struct sway_workspace *workspace, } struct sway_output *workspace_output_get_highest_available( - struct sway_workspace *ws) { + struct sway_workspace *ws, struct sway_output *exclude) { for (int i = 0; i < ws->output_priority->length; i++) { const char *name = ws->output_priority->items[i]; + if (exclude && output_match_name_or_id(exclude, name)) { + continue; + } + struct sway_output *output = output_by_name_or_id(name); if (output) { return output; diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 68d8dd32d..71c9a4c5e 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -15,7 +15,6 @@ #include "list.h" #include "log.h" #include "loop.h" -#include "stringop.h" #include "util.h" void ipc_send_workspace_command(struct swaybar *bar, const char *ws) { @@ -46,8 +45,8 @@ void ipc_send_workspace_command(struct swaybar *bar, const char *ws) { char *parse_font(const char *font) { char *new_font = NULL; - if (has_prefix(font, "pango:")) { - font += strlen("pango:"); + if (strncmp("pango:", font, 6) == 0) { + font += 6; } new_font = strdup(font); return new_font; diff --git a/swaybar/main.c b/swaybar/main.c index e1b0cecac..3dc672334 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -93,9 +93,8 @@ int main(int argc, char **argv) { free(socket_path); - struct sigaction sa = { .sa_handler = sig_handler }; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); swaybar.running = true; bar_run(&swaybar); diff --git a/swaybar/render.c b/swaybar/render.c index c51321f18..879a4e42a 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -13,6 +13,7 @@ #include "swaybar/ipc.h" #include "swaybar/render.h" #include "swaybar/status_line.h" +#include "log.h" #if HAVE_TRAY #include "swaybar/tray/tray.h" #endif @@ -20,7 +21,7 @@ static const int WS_HORIZONTAL_PADDING = 5; static const double WS_VERTICAL_PADDING = 1.5; -static const int BORDER_WIDTH = 1; +static const double BORDER_WIDTH = 1; struct render_context { cairo_t *cairo; @@ -28,7 +29,6 @@ struct render_context { cairo_font_options_t *textaa_sharp; cairo_font_options_t *textaa_safe; uint32_t background_color; - bool has_transparency; }; static void choose_text_aa_mode(struct render_context *ctx, uint32_t fontcolor) { @@ -265,7 +265,6 @@ static uint32_t render_status_block(struct render_context *ctx, uint32_t bg_color = block->urgent ? config->colors.urgent_workspace.background : block->background; - ctx->has_transparency |= (bg_color & 0xFF) != 0xFF; if (bg_color) { render_sharp_rectangle(cairo, bg_color, x_pos, y_pos, block_width, render_height); @@ -292,11 +291,11 @@ static uint32_t render_status_block(struct render_context *ctx, } double offset = 0; - if (has_prefix(block->align, "left")) { + if (strncmp(block->align, "left", 4) == 0) { offset = x_pos; - } else if (has_prefix(block->align, "right")) { + } else if (strncmp(block->align, "right", 5) == 0) { offset = x_pos + width - text_width; - } else if (has_prefix(block->align, "center")) { + } else if (strncmp(block->align, "center", 6) == 0) { offset = x_pos + (width - text_width) / 2; } double text_y = height / 2.0 - text_height / 2.0; @@ -540,63 +539,6 @@ static uint32_t render_status_line(struct render_context *ctx, double *x) { return 0; } -static struct box_size render_box(struct render_context *ctx, double x, - struct box_colors colors, const char *label, bool pango_markup) { - struct swaybar_output *output = ctx->output; - struct swaybar_config *config = output->bar->config; - cairo_t *cairo = ctx->cairo; - - int text_width, text_height; - get_text_size(cairo, config->font_description, &text_width, &text_height, NULL, - 1, pango_markup, "%s", label); - - uint32_t width = text_width + WS_HORIZONTAL_PADDING * 2 + BORDER_WIDTH * 2; - if (width < config->workspace_min_width) { - width = config->workspace_min_width; - } - - uint32_t ideal_height = text_height + WS_VERTICAL_PADDING * 2 - + BORDER_WIDTH * 2; - uint32_t ideal_surface_height = ideal_height; - if (!output->bar->config->height && - output->height < ideal_surface_height) { - return (struct box_size) { - .width = width, - .height = ideal_surface_height, - }; - } - - uint32_t height = output->height; - cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); - cairo_set_source_u32(cairo, colors.background); - ctx->background_color = colors.background; - ctx->has_transparency |= (colors.background & 0xFF) != 0xFF; - cairo_rectangle(cairo, x, 0, width, height); - cairo_fill(cairo); - - cairo_set_source_u32(cairo, colors.border); - cairo_rectangle(cairo, x, 0, width, BORDER_WIDTH); - cairo_fill(cairo); - cairo_rectangle(cairo, x, 0, BORDER_WIDTH, height); - cairo_fill(cairo); - cairo_rectangle(cairo, x + width - BORDER_WIDTH, 0, BORDER_WIDTH, height); - cairo_fill(cairo); - cairo_rectangle(cairo, x, height - BORDER_WIDTH, width, BORDER_WIDTH); - cairo_fill(cairo); - - double text_y = height / 2.0 - text_height / 2.0; - cairo_set_source_u32(cairo, colors.text); - cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); - choose_text_aa_mode(ctx, colors.text); - render_text(cairo, config->font_description, 1, pango_markup, - "%s", label); - - return (struct box_size) { - .width = width, - .height = output->height, - }; -} - static uint32_t render_binding_mode_indicator(struct render_context *ctx, double x) { struct swaybar_output *output = ctx->output; @@ -605,9 +547,53 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx, return 0; } - struct box_size size = render_box(ctx, x, output->bar->config->colors.binding_mode, - mode, output->bar->mode_pango_markup); - return size.height; + cairo_t *cairo = ctx->cairo; + struct swaybar_config *config = output->bar->config; + int text_width, text_height; + get_text_size(cairo, config->font_description, &text_width, &text_height, NULL, + 1, output->bar->mode_pango_markup, + "%s", mode); + + int ws_vertical_padding = WS_VERTICAL_PADDING; + int ws_horizontal_padding = WS_HORIZONTAL_PADDING; + int border_width = BORDER_WIDTH; + + uint32_t ideal_height = text_height + ws_vertical_padding * 2 + + border_width * 2; + uint32_t ideal_surface_height = ideal_height; + if (!output->bar->config->height && + output->height < ideal_surface_height) { + return ideal_surface_height; + } + uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; + if (width < config->workspace_min_width) { + width = config->workspace_min_width; + } + + uint32_t height = output->height; + cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); + cairo_set_source_u32(cairo, config->colors.binding_mode.background); + ctx->background_color = config->colors.binding_mode.background; + cairo_rectangle(cairo, x, 0, width, height); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, config->colors.binding_mode.border); + cairo_rectangle(cairo, x, 0, width, border_width); + cairo_fill(cairo); + cairo_rectangle(cairo, x, 0, border_width, height); + cairo_fill(cairo); + cairo_rectangle(cairo, x + width - border_width, 0, border_width, height); + cairo_fill(cairo); + cairo_rectangle(cairo, x, height - border_width, width, border_width); + cairo_fill(cairo); + + double text_y = height / 2.0 - text_height / 2.0; + cairo_set_source_u32(cairo, config->colors.binding_mode.text); + cairo_move_to(cairo, x + width / 2 - text_width / 2, (int)floor(text_y)); + choose_text_aa_mode(ctx, config->colors.binding_mode.text); + render_text(cairo, config->font_description, 1, output->bar->mode_pango_markup, + "%s", mode); + return output->height; } static enum hotspot_event_handling workspace_hotspot_callback( @@ -629,7 +615,6 @@ static uint32_t render_workspace_button(struct render_context *ctx, struct swaybar_workspace *ws, double *x) { struct swaybar_output *output = ctx->output; struct swaybar_config *config = output->bar->config; - struct box_colors box_colors; if (ws->urgent) { box_colors = config->colors.urgent_workspace; @@ -641,21 +626,65 @@ static uint32_t render_workspace_button(struct render_context *ctx, box_colors = config->colors.inactive_workspace; } - struct box_size size = render_box(ctx, *x, box_colors, - ws->label, config->pango_markup); + uint32_t height = output->height; + + cairo_t *cairo = ctx->cairo; + int text_width, text_height; + get_text_size(cairo, config->font_description, &text_width, &text_height, NULL, + 1, config->pango_markup, "%s", ws->label); + + int ws_vertical_padding = WS_VERTICAL_PADDING; + int ws_horizontal_padding = WS_HORIZONTAL_PADDING; + int border_width = BORDER_WIDTH; + + uint32_t ideal_height = ws_vertical_padding * 2 + text_height + + border_width * 2; + uint32_t ideal_surface_height = ideal_height; + if (!output->bar->config->height && + output->height < ideal_surface_height) { + return ideal_surface_height; + } + + uint32_t width = text_width + ws_horizontal_padding * 2 + border_width * 2; + if (width < config->workspace_min_width) { + width = config->workspace_min_width; + } + + cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); + cairo_set_source_u32(cairo, box_colors.background); + ctx->background_color = box_colors.background; + cairo_rectangle(cairo, *x, 0, width, height); + cairo_fill(cairo); + + cairo_set_source_u32(cairo, box_colors.border); + cairo_rectangle(cairo, *x, 0, width, border_width); + cairo_fill(cairo); + cairo_rectangle(cairo, *x, 0, border_width, height); + cairo_fill(cairo); + cairo_rectangle(cairo, *x + width - border_width, 0, border_width, height); + cairo_fill(cairo); + cairo_rectangle(cairo, *x, height - border_width, width, border_width); + cairo_fill(cairo); + + double text_y = height / 2.0 - text_height / 2.0; + cairo_set_source_u32(cairo, box_colors.text); + cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y)); + choose_text_aa_mode(ctx, box_colors.text); + render_text(cairo, config->font_description, 1, config->pango_markup, + "%s", ws->label); struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); hotspot->x = *x; hotspot->y = 0; - hotspot->width = size.width; - hotspot->height = size.height; + hotspot->width = width; + hotspot->height = height; hotspot->callback = workspace_hotspot_callback; hotspot->destroy = free; hotspot->data = strdup(ws->name); wl_list_insert(&output->hotspots, &hotspot->link); - *x += size.width; - return size.height; + *x += width; + return output->height; } static uint32_t render_to_cairo(struct render_context *ctx) { @@ -731,12 +760,10 @@ void render_frame(struct swaybar_output *output) { background_color = output->bar->config->colors.background; } - struct render_context ctx = { - .output = output, - // initial background color used for deciding the best way to antialias text - .background_color = background_color, - .has_transparency = (background_color & 0xFF) != 0xFF, - }; + struct render_context ctx = { 0 }; + ctx.output = output; + // initial background color used for deciding the best way to antialias text + ctx.background_color = background_color; cairo_surface_t *recorder = cairo_recording_surface_create( CAIRO_CONTENT_COLOR_ALPHA, NULL); @@ -807,7 +834,8 @@ void render_frame(struct swaybar_output *output) { wl_surface_damage(output->surface, 0, 0, output->width, output->height); - if (!ctx.has_transparency) { + uint32_t bg_alpha = background_color & 0xFF; + if (bg_alpha == 0xFF) { struct wl_region *region = wl_compositor_create_region(output->bar->compositor); wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX); diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index 12929743b..ca6c03ad5 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c @@ -15,7 +15,6 @@ #include "cairo_util.h" #include "list.h" #include "log.h" -#include "stringop.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" // TODO menu @@ -162,7 +161,7 @@ static int get_property_callback(sd_bus_message *msg, void *data, } if (strcmp(prop, "Status") == 0 || (sni->status && (sni->status[0] == 'N' ? - prop[0] == 'A' : has_prefix(prop, "Icon")))) { + prop[0] == 'A' : strncmp(prop, "Icon", 4) == 0))) { set_sni_dirty(sni); } cleanup: @@ -365,7 +364,7 @@ static void handle_click(struct swaybar_sni *sni, int x, int y, method = "ContextMenu"; } - if (has_prefix(method, "Scroll")) { + if (strncmp(method, "Scroll", strlen("Scroll")) == 0) { char dir = method[strlen("Scroll")]; char *orientation = (dir == 'U' || dir == 'D') ? "vertical" : "horizontal"; int sign = (dir == 'U' || dir == 'L') ? -1 : 1; diff --git a/swaybar/tray/watcher.c b/swaybar/tray/watcher.c index 284964030..3cfea8d8e 100644 --- a/swaybar/tray/watcher.c +++ b/swaybar/tray/watcher.c @@ -31,15 +31,13 @@ static int handle_lost_service(sd_bus_message *msg, struct swaybar_watcher *watcher = data; for (int idx = 0; idx < watcher->items->length; ++idx) { char *id = watcher->items->items[idx]; - bool cmp_res = using_standard_protocol(watcher) ? - cmp_id(id, service) == 0 : has_prefix(id, service); - if (cmp_res) { + int cmp_res = using_standard_protocol(watcher) ? + cmp_id(id, service) : strncmp(id, service, strlen(service)); + if (cmp_res == 0) { sway_log(SWAY_DEBUG, "Unregistering Status Notifier Item '%s'", id); list_del(watcher->items, idx--); sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface, "StatusNotifierItemUnregistered", "s", id); - sd_bus_emit_properties_changed(watcher->bus, obj_path, watcher->interface, - "RegisteredStatusNotifierItems", NULL); free(id); if (using_standard_protocol(watcher)) { break; @@ -52,10 +50,6 @@ static int handle_lost_service(sd_bus_message *msg, sway_log(SWAY_DEBUG, "Unregistering Status Notifier Host '%s'", service); free(watcher->hosts->items[idx]); list_del(watcher->hosts, idx); - if (watcher->hosts->length == 0) { - sd_bus_emit_properties_changed(watcher->bus, obj_path, watcher->interface, - "IsStatusNotifierHostRegistered", NULL); - } } } @@ -88,8 +82,6 @@ static int register_sni(sd_bus_message *msg, void *data, sd_bus_error *error) { if (list_seq_find(watcher->items, cmp_id, id) == -1) { sway_log(SWAY_DEBUG, "Registering Status Notifier Item '%s'", id); list_add(watcher->items, id); - sd_bus_emit_properties_changed(watcher->bus, obj_path, watcher->interface, - "RegisteredStatusNotifierItems", NULL); sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface, "StatusNotifierItemRegistered", "s", id); } else { @@ -112,10 +104,6 @@ static int register_host(sd_bus_message *msg, void *data, sd_bus_error *error) { if (list_seq_find(watcher->hosts, cmp_id, service) == -1) { sway_log(SWAY_DEBUG, "Registering Status Notifier Host '%s'", service); list_add(watcher->hosts, strdup(service)); - if (watcher->hosts->length == 1) { - sd_bus_emit_properties_changed(watcher->bus, obj_path, watcher->interface, - "IsStatusNotifierHostRegistered", NULL); - } sd_bus_emit_signal(watcher->bus, obj_path, watcher->interface, "StatusNotifierHostRegistered", ""); } else { diff --git a/swaymsg/main.c b/swaymsg/main.c index d58f29e2c..5c57171e7 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -16,6 +16,10 @@ #include "ipc-client.h" #include "log.h" +void sway_terminate(int exit_code) { + exit(exit_code); +} + static bool success_object(json_object *result) { json_object *success; @@ -95,7 +99,7 @@ static const char *pretty_type_name(const char *name) { const char *b; } type_names[] = { { "keyboard", "Keyboard" }, - { "pointer", "Pointer" }, + { "pointer", "Mouse" }, { "touchpad", "Touchpad" }, { "tablet_pad", "Tablet pad" }, { "tablet_tool", "Tablet tool" }, @@ -189,8 +193,7 @@ static void pretty_print_output(json_object *o) { json_object_object_get_ex(o, "current_workspace", &ws); json_object_object_get_ex(o, "non_desktop", &non_desktop); json_object *make, *model, *serial, *scale, *scale_filter, *subpixel, - *transform, *max_render_time, *adaptive_sync_status, *allow_tearing, - *hdr; + *transform, *max_render_time, *adaptive_sync_status, *allow_tearing; json_object_object_get_ex(o, "make", &make); json_object_object_get_ex(o, "model", &model); json_object_object_get_ex(o, "serial", &serial); @@ -201,7 +204,6 @@ static void pretty_print_output(json_object *o) { json_object_object_get_ex(o, "max_render_time", &max_render_time); json_object_object_get_ex(o, "adaptive_sync_status", &adaptive_sync_status); json_object_object_get_ex(o, "allow_tearing", &allow_tearing); - json_object_object_get_ex(o, "hdr", &hdr); json_object *x, *y; json_object_object_get_ex(rect, "x", &x); json_object_object_get_ex(rect, "y", &y); @@ -212,10 +214,6 @@ static void pretty_print_output(json_object *o) { json_object_object_get_ex(current_mode, "width", &width); json_object_object_get_ex(current_mode, "height", &height); json_object_object_get_ex(current_mode, "refresh", &refresh); - json_object *features, *features_adaptive_sync, *features_hdr; - json_object_object_get_ex(o, "features", &features); - json_object_object_get_ex(features, "adaptive_sync", &features_adaptive_sync); - json_object_object_get_ex(features, "hdr", &features_hdr); if (json_object_get_boolean(non_desktop)) { printf( @@ -258,18 +256,10 @@ static void pretty_print_output(json_object *o) { printf(max_render_time_int == 0 ? "off\n" : "%d ms\n", max_render_time_int); printf(" Adaptive sync: %s\n", - json_object_get_boolean(features_adaptive_sync) ? - json_object_get_string(adaptive_sync_status) : - "unsupported"); + json_object_get_string(adaptive_sync_status)); printf(" Allow tearing: %s\n", json_object_get_boolean(allow_tearing) ? "yes" : "no"); - - const char *hdr_str = "unsupported"; - if (json_object_get_boolean(features_hdr)) { - hdr_str = json_object_get_boolean(hdr) ? "on" : "off"; - } - printf(" HDR: %s\n", hdr_str); } else { printf( "Output %s '%s %s %s' (disabled)\n", @@ -340,10 +330,6 @@ static void pretty_print_tree(json_object *obj, int indent) { const char *instance = json_object_get_string(json_object_object_get(window_props_obj, "instance")); const char *class = json_object_get_string(json_object_object_get(window_props_obj, "class")); int x11_id = json_object_get_int(json_object_object_get(obj, "window")); - const char *foreign_toplevel_id = json_object_get_string(json_object_object_get(obj, "foreign_toplevel_identifier")); - const char *sandbox_engine = json_object_get_string(json_object_object_get(obj, "sandbox_engine")); - const char *sandbox_app_id = json_object_get_string(json_object_object_get(obj, "sandbox_app_id")); - const char *sandbox_instance_id = json_object_get_string(json_object_object_get(obj, "sandbox_instance_id")); printf(" (%s, pid: %d", shell, pid); if (app_id != NULL) { @@ -358,18 +344,6 @@ static void pretty_print_tree(json_object *obj, int indent) { if (x11_id != 0) { printf(", X11 window: 0x%X", x11_id); } - if (foreign_toplevel_id != NULL) { - printf(", foreign_toplevel_id: \"%s\"", foreign_toplevel_id); - } - if (sandbox_engine != NULL) { - printf(", sandbox_engine: \"%s\"", sandbox_engine); - } - if (sandbox_app_id != NULL) { - printf(", sandbox_app_id: \"%s\"", sandbox_app_id); - } - if (sandbox_instance_id != NULL) { - printf(", sandbox_instance_id: \"%s\"", sandbox_instance_id); - } printf(")"); } diff --git a/swaynag/main.c b/swaynag/main.c index b68157ff2..634bddbfc 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -13,6 +13,11 @@ void sig_handler(int signal) { exit(EXIT_FAILURE); } +void sway_terminate(int code) { + swaynag_destroy(&swaynag); + exit(code); +} + int main(int argc, char **argv) { int status = EXIT_SUCCESS; @@ -102,8 +107,7 @@ int main(int argc, char **argv) { sway_log(SWAY_DEBUG, "\t[%s] `%s`", button->text, button->action); } - struct sigaction sa = { .sa_handler = sig_handler }; - sigaction(SIGTERM, &sa, NULL); + signal(SIGTERM, sig_handler); swaynag_setup(&swaynag); swaynag_run(&swaynag); diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index da32eeb76..50eea1483 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -324,9 +324,7 @@ static void output_scale(void *data, struct wl_output *output, swaynag_output->scale = factor; if (swaynag_output->swaynag->output == swaynag_output) { swaynag_output->swaynag->scale = swaynag_output->scale; - if (!swaynag_output->swaynag->cursor_shape_manager) { - update_all_cursors(swaynag_output->swaynag); - } + update_all_cursors(swaynag_output->swaynag); render_frame(swaynag_output->swaynag); } }