Compare commits

..

658 Commits

Author SHA1 Message Date
vaxerski
e1d7a13333 unset fullscreen in onWindowRemoved 2022-12-07 18:57:02 +00:00
vaxerski
bf5844d607 add failsafe for dwindle windows 2022-12-07 18:57:02 +00:00
Mihai Fufezan
5b7fec481b nix: add cachix to nixos module 2022-12-07 19:18:15 +02:00
vaxerski
73b3bbe49b added nomaxsize rule 2022-12-07 16:08:44 +00:00
vaxerski
d8dcf670da fix lost windows clogging up memory 2022-12-07 14:32:24 +00:00
vaxerski
87b9313034 updated wlroots dep 2022-12-06 23:16:37 +00:00
vaxerski
993c382e74 minor fixes to special workspace behavior 2022-12-06 20:31:44 +00:00
vaxerski
3c9a7811b8 fix up moving to special workspace 2022-12-06 20:20:37 +00:00
vaxerski
6c8d993477 minor toplevel sharing fixups 2022-12-06 18:58:42 +00:00
vaxerski
dfa9277867 remove double semicolons 2022-12-06 15:06:27 +00:00
vaxerski
50e37419e9 fix the release CI 2022-12-06 13:25:24 +00:00
vaxerski
22978aa31e fix tarbomb with source tars 2022-12-06 13:15:18 +00:00
vaxerski
7ed401e5e0 fix group border oversaturation 2022-12-06 12:57:10 +00:00
vaxerski
da76a1ed9e block surface feedback on window sharing 2022-12-05 19:12:15 +00:00
vaxerski
9c67e08dbd ignore alpha when sharing window 2022-12-05 18:00:57 +00:00
vaxerski
6cf716f182 fix handle finding 2022-12-05 17:57:59 +00:00
vaxerski
9fb24ac1e9 avoid using wayland-0 as a socket name 2022-12-05 17:21:09 +00:00
Vaxry
66fb083003 Implement window sharing with the hl toplevel export proto (#1179)
* implement window sharing

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2022-12-05 17:05:15 +00:00
vaxerski
20b91f58f8 remove idiotic guard in processMouseDownNormal 2022-12-05 14:30:04 +00:00
vaxerski
ac0e675f3b better capability handling 2022-12-05 14:28:27 +00:00
Mihai Fufezan
f71f04db9e nix: add xdph to nixos module 2022-12-05 03:13:31 +02:00
vaxerski
9e4e98acfb fix crash in blurls remove 2022-12-04 22:34:30 +00:00
eriedaberrie
826e35f7a4 show groupings and swallowing in hyprctl (#1159)
* feat: show groupings and swallowing in hyprctl
2022-12-04 21:03:29 +00:00
Flafy
ffc580dda9 blur xray for layers (#1158)
* feat: apply blur_xray to non window surfaces

* don't blur optimize bottom and background layers
2022-12-04 20:57:41 +00:00
Mihai Fufezan
4557d13a32 nix: update nixpkgs (includes merged hwdata update) 2022-12-04 21:43:28 +02:00
Mihai Fufezan
215c7bd3cb nix: remove merged hwdata override 2022-12-04 21:24:34 +02:00
Flafy
ea2ef63de5 nix: add cmake and wlroots to devshell (#1155) 2022-12-04 19:58:45 +02:00
Paul
d9998f2ca5 Use internal device naming for Hyprctl devices (#1174)
* Use internal naming for Hyprctl devices

* Use c-strings rather than std::string
2022-12-04 17:32:55 +00:00
Flafy
686d6fc6d1 Fix wrong layout recalculate if statement (#1167)
* fix: wrong layout recalculate if statement

* change from find to contains
2022-12-04 17:32:27 +00:00
vaxerski
9e8df888eb fix warning 2022-12-04 00:03:48 +00:00
vaxerski
409ac12f23 avoid duplicate device names 2022-12-03 20:36:52 +00:00
vaxerski
6aa26582f6 added hyprctl switchxkblayout 2022-12-03 16:22:02 +00:00
vaxerski
056a45d035 fix shader destroy id unset 2022-12-03 14:45:10 +00:00
vaxerski
fbc839e8d9 reload shader on dynamic shader keyword 2022-12-03 14:45:10 +00:00
vaxerski
cb85eea261 [gha] build man pages 2022-12-02 20:15:25 +00:00
Hemish
439b827a08 Update wiki link in manpage (#1144)
As wiki is migrated to wiki.hyprland.org, I changed the github wiki link to wiki.hyprland.org in the manpage.
2022-12-02 20:15:03 +00:00
vaxerski
d39d6cc1e3 don't initial focus on LS keyboard grab 2022-12-02 20:10:15 +00:00
vaxerski
d6b3bfc48e don't attempt rendering on begin failure 2022-12-02 19:33:54 +00:00
vaxerski
70d4fadc39 schedule frames and reloads on session re-activate 2022-12-02 18:47:57 +00:00
vaxerski
a2a12018d9 minor changes to unsafe state handling 2022-12-02 18:45:45 +00:00
vaxerski
10d34ef818 added blur_xray 2022-12-02 18:37:11 +00:00
vaxerski
bf52545a91 [gha] bump flake inputs 2022-12-01 21:01:57 +00:00
vaxerski
c012e3d66b update wlroots dep 2022-12-01 21:00:54 +00:00
vaxerski
39a4f82460 fix crash with invalid frag dynamic shaders 2022-12-01 13:40:05 +00:00
vaxerski
7b020ffa84 Added screen shaders 2022-12-01 13:36:07 +00:00
Vaxry
b8ccf3dc3a updated the readme 2022-11-30 22:49:47 +00:00
vaxerski
869f0a0238 remove global var 2022-11-30 13:33:21 +00:00
vaxerski
ff4ea1a13a fix border inner offset in shader 2022-11-29 21:11:37 +00:00
vaxerski
51aebb2845 fix minor issues with blur w/o new optim 2022-11-29 11:21:03 +00:00
vaxerski
212f599412 fix AA on borders 2022-11-29 11:12:29 +00:00
vaxerski
55776df685 fix double free 2022-11-29 11:10:19 +00:00
vaxerski
3dd06b674a clean up blur code and fix minor issues 2022-11-28 19:19:07 +00:00
vaxerski
12df799572 recalculate layout only when needed on dynamic keywords 2022-11-28 19:05:50 +00:00
vaxerski
c341792092 fix minor issues with blur_new_optimize 2022-11-28 19:04:30 +00:00
Eric_Luo
afe12dc90b Fix a compiler warning (#1124)
Co-authored-by: hnboy <hnboy@users.noreply.github.com>
2022-11-28 19:04:24 +00:00
Jef
45d2d1e97d convert bordercolors to GradientValueData correctly (#1122)
Co-authored-by: Jef Steelant <jef.steelant_ext@softathome.com>
2022-11-28 11:44:31 +00:00
vaxerski
0a302901d2 Added handling more special workspaces 2022-11-27 22:42:22 +00:00
vaxerski
49063f949d find floating windows below closed one 2022-11-27 12:11:45 +00:00
vaxerski
7699d657d9 optimize border shader
Do not calculate gradient for discarded fragments
2022-11-27 00:30:44 +00:00
vaxerski
b2cb3b8bf2 use gradients in default configs 2022-11-27 00:26:13 +00:00
vaxerski
6cbaad896c use highp for pixcoord to fix nvidia border issues 2022-11-26 23:55:41 +00:00
vaxerski
9247f88d0c update readme 2022-11-26 20:56:18 +00:00
vaxerski
92f2e342a3 use unreachable instead of break on invalid cvd enum value 2022-11-26 20:46:39 +00:00
Dashie
e2f3f5fe63 Add nofullscreen to windowrules (#1107)
* feat: add windowrule to prevent fullscreen
2022-11-26 20:44:40 +00:00
vaxerski
0db75852f3 fix transformed border thickness 2022-11-26 20:36:05 +00:00
vaxerski
afe688e6ab allow 360 degrees of freedom in gradients 2022-11-26 19:37:20 +00:00
vaxerski
493fc00953 fix decorations missing after no_gaps_when_only toggle floating 2022-11-26 18:48:16 +00:00
vaxerski
c709dc5e8e fix fadeout with animated border 2022-11-26 18:41:30 +00:00
vaxerski
684c59e5bc optimize data feeding to gradient renderer 2022-11-26 18:09:57 +00:00
vaxerski
0948b078e1 added border gradients 2022-11-26 17:57:02 +00:00
vaxerski
52c0356900 monitor rule fixes 2022-11-26 15:41:08 +00:00
vaxerski
1c9a0be8c4 fix up the border shader 2022-11-26 13:51:30 +00:00
vaxerski
f45ec24977 don't focus back after dnd on follow mouse 1 2022-11-26 00:00:36 +00:00
vaxerski
75b7e661e7 damage windows after switch 2022-11-25 19:52:23 +00:00
vaxerski
381d7a4300 check for special workspace open in attemptDirectScanout 2022-11-25 18:25:04 +00:00
vaxerski
0e6e8461eb reset m_bEmptyFocusCursorSet on workspace switch 2022-11-25 11:34:52 +00:00
Mihai Fufezan
141456dd89 Nix & meson: 0.17.0 -> 0.18.0 2022-11-25 08:34:23 +02:00
vaxerski
9616dc7bd8 don't change alpha on special anims 2022-11-24 20:51:33 +00:00
vaxerski
379597e78f remove redundant strval_empty checks 2022-11-24 17:11:21 +00:00
vaxerski
f6067816fb skip covered windows on fullscreen workspaces in getWindowInDirection 2022-11-23 23:40:05 +00:00
vaxerski
750eb76df3 default blur new optimizations to 1 2022-11-23 15:41:19 +00:00
Julian Schuler
79a9bc9076 Add option for retrieving first empty workspace (#1085) 2022-11-23 14:10:26 +00:00
vaxerski
dcb6a0425c override force opaque rule on keybind 2022-11-23 09:55:52 +00:00
vaxerski
e15a9f3d7d damage monitor on group switch 2022-11-22 23:47:00 +00:00
vaxerski
b0f95c63c9 fix crash in setActiveMonitor null 2022-11-22 23:17:10 +00:00
vaxerski
5327565b33 remove resize transitions 2022-11-22 17:20:58 +00:00
vaxerski
95047fb083 return full monitor box for fullscreen windows in idealBB 2022-11-21 23:33:53 +00:00
CactiChameleon9
f00b2fd509 Fix swiping on the first workspace going to the last (#1067) 2022-11-21 23:30:26 +00:00
vaxerski
eb86e7967f add scroll_button libinput opt 2022-11-21 23:26:18 +00:00
Maks
88874fcfe2 Fix cmake error when using clang (#1009) 2022-11-21 21:20:51 +00:00
vaxerski
d504c1e5ab fix master resizes all 2022-11-21 18:14:25 +00:00
vaxerski
c78db1212b Unify rounding shaders 2022-11-21 18:09:47 +00:00
vaxerski
be03a6186c fix invisible windows on moving fullscreen out 2022-11-20 18:50:27 +00:00
Julian Schuler
41a8975bd1 Render focused window at last (#1060) 2022-11-20 18:50:01 +00:00
vaxerski
254c3d166f don't send motion events to lock constraints 2022-11-20 18:38:53 +00:00
vaxerski
137cf9e582 improve constraint handling 2022-11-20 17:35:13 +00:00
Mihai Fufezan
11e841580f Nix: add libdrm and wayland-protocols overlay
fixes #1055
2022-11-20 17:34:11 +02:00
vaxerski
f8b9138383 make focus/swap master layoutmsgs two-way 2022-11-20 11:55:50 +00:00
Narice
c03e4c36b0 Setting wayland environment variables at startup (#1045)
* Nix modules: removed GDK_BACKEND env variable

* setting wayland environment variables at startup

setting XDG_BACKEND and _JAVA_AWT_WM_NONREPARENTING in main.cpp
removed these variables from nix modules recommended environemnt
removed XCURSOR_SIZE from nix modules as it is already set

* Making _JAVA_AWT_WM_NONREPARENTING not overwritten
2022-11-19 19:37:16 +00:00
vaxerski
5530cf6e79 respect no_gaps_when_only in fullscreen 1 2022-11-19 17:35:37 +00:00
vaxerski
1f72237291 Fix incorrect layout positions in mirror re-add 2022-11-19 16:58:14 +00:00
vaxerski
e427d9f622 unify setting of the active monitor 2022-11-19 16:41:41 +00:00
vaxerski
f88feec02b [gha] bump flake inputs 2022-11-19 16:29:06 +00:00
vaxerski
df132e5ff3 update wlroots dep 2022-11-19 16:28:04 +00:00
vaxerski
0ffaa8d667 Fix minor issues with mirrors 2022-11-19 13:14:55 +00:00
vaxerski
e887149f25 minor fixes for mirrors & log more monitor events 2022-11-19 13:01:32 +00:00
vaxerski
250d61e0b3 find base surface if no subsurface found in ls 2022-11-18 20:35:15 +00:00
vaxerski
ba05c43ae3 minor monitor code fixups 2022-11-18 14:15:19 +00:00
vaxerski
82fe530045 don't set AS in onConnect 2022-11-18 14:08:34 +00:00
vaxerski
f91f3d1c81 Reset callbacks on remap 2022-11-18 13:53:54 +00:00
vaxerski
5d39223239 fix events in changeworkspace with bound ws-es 2022-11-17 21:58:22 +00:00
vaxerski
d2a7e22efd more memory safety around onDisconnect 2022-11-17 21:52:45 +00:00
vaxerski
724e411ffc avoid header clashes in make all 2022-11-17 18:27:50 +00:00
vaxerski
c02bfc3897 fix extents in shadow deco 2022-11-16 15:35:36 +00:00
vaxerski
878a20741b fix slide calcs for windows outside the viewport 2022-11-16 15:35:36 +00:00
vaxerski
d5eafe1926 set cursor to hand1 when moving a window 2022-11-15 10:39:05 +00:00
Mihai Fufezan
e2da4ff257 Nix CI: update actions (#1014) 2022-11-15 10:23:46 +00:00
Jef
dbb6732743 apply some rules dynamically when state of window changes (#1020)
Co-authored-by: Jef Steelant <jef.steelant_ext@softathome.com>
2022-11-15 10:21:26 +00:00
Jef
4034aa2c60 possible crash when current workspace does not exist (#1023)
Co-authored-by: Jef Steelant <jef.steelant_ext@softathome.com>
2022-11-15 10:18:04 +00:00
vaxerski
fcb5037a1d guard lastwindow in circlenext 2022-11-14 12:12:13 +00:00
vaxerski
0634abf168 remove quotes from commit messages in build 2022-11-13 20:01:30 +00:00
vaxerski
478fa7cafe Revert "Set child stdout and stderr to /dev/null (#1000)"
This reverts commit 1e5cab1ee7.

Breaks a bunch of stuff, e.g. Waybar.
2022-11-13 19:53:27 +00:00
Jef
549fdf63f6 Add bordercolor windowrule (#992)
* Add bordercolor windowrule

* remove spaces form bordercolor rule + typo

Co-authored-by: Jef Steelant <jef.steelant_ext@softathome.com>
2022-11-13 19:33:13 +00:00
Mihai Fufezan
1a14841a75 Nix: add hwdata overlay (#1010) 2022-11-13 19:32:15 +00:00
vaxerski
a7ed3a5e47 fix arch ci 2022-11-13 14:41:26 +00:00
vaxerski
884fc4f89c fix master window finding on closed 2022-11-13 14:31:12 +00:00
Thomas Voss
1e5cab1ee7 Set child stdout and stderr to /dev/null (#1000)
Some scripts or utilities check to see if stdout or stderr are connected
to a TTY or not to determine certain behaviors (for example, you might
want to prompt a user for input with fzf(1) if in a terminal but tofi(1)
or wofi(1) when spawned from your WM).  Since hyprland never closes
these output streams for spawned processes, they end up just spewing
their output onto the TTY while giving the user no real way to have a
script detect if it's being run from the shell or WM.

Instead of just closing stdout and stderr though, we close them and then
proceed to reopen them but connect them to /dev/null.  This allows
scripts and processes to not fail when attempting to write, but for that
writing to simply have no effect.
2022-11-13 11:58:20 +00:00
vaxerski
5a00f0c657 fix trailing comma in hyprctl activewindow 2022-11-13 11:12:11 +00:00
vaxerski
2cbb10d850 [gha] bump flake inputs 2022-11-13 11:05:51 +00:00
vaxerski
23cd1b8c66 update wlroots dep 2022-11-13 11:04:28 +00:00
vaxerski
be6f5ce831 fix commit message parsing in cmake 2022-11-13 10:58:46 +00:00
Jef
78a545112a streamline hypctl output of windows (#983)
Co-authored-by: Jef Steelant <jef.steelant_ext@softathome.com>
2022-11-13 00:39:21 +00:00
Vaxry
2cdabf581e Merge pull request #997 from leftas/main
Add keyboards' leds update on Key/Mod press
2022-11-12 21:00:38 +00:00
Leftas
34a7f17956 Add keyboard led update after keys/mod update 2022-11-12 13:12:37 +02:00
vaxerski
dd11434e90 notify idle on touch down 2022-11-11 23:41:04 +00:00
vaxerski
61995e3b4e guard empty str in isNumber 2022-11-11 14:04:35 +00:00
sioodmy
13befbd266 fix(nix): missing dependency 2022-11-11 14:43:45 +02:00
vaxerski
a5ffd44caf guard empty str in removeBeginEndSpacesTabs 2022-11-10 21:51:46 +00:00
vaxerski
0208dff574 fix invalid master slave pos calc on y != 0 2022-11-10 19:39:16 +00:00
vaxerski
3157bebed7 fix warning 2022-11-10 17:07:26 +00:00
vaxerski
c0bb4db15c add move cursor windowrule 2022-11-10 16:59:08 +00:00
Philip Jones
27cada2a02 Allow arguments to hyprctl dispatch exec commands. (#990) 2022-11-10 15:36:36 +00:00
vaxerski
153c99217d use spawn in config exec 2022-11-10 13:50:16 +00:00
vaxerski
851df11eb5 Added exec rules 2022-11-10 13:39:23 +00:00
vaxerski
5f2c741f49 remove spammy ime logs 2022-11-10 12:24:41 +00:00
vaxerski
9a9ecc25db added monitor cycling 2022-11-10 12:22:19 +00:00
vaxerski
34b145ee65 Added resizing individual master windows 2022-11-10 12:05:22 +00:00
vaxerski
f41fe59cb6 fix shadow extent & offset calculations 2022-11-09 22:39:19 +00:00
vaxerski
7ff1fd9d69 use goal values in changeWindowFloatingMode 2022-11-09 22:02:02 +00:00
vaxerski
d0b3cdc835 Fix crashes with DS and mirrors 2022-11-09 10:56:49 +00:00
vaxerski
1cf829c889 minor loose focus fixes 2022-11-08 20:28:41 +00:00
vaxerski
17992b633d minor fixes for follow_mouse 3 2022-11-08 14:48:17 +00:00
vaxerski
c545ab4993 Added multiple master layoutmsgs 2022-11-08 12:39:52 +00:00
vaxerski
1d2e4243dc clamp shadow scale to 1 2022-11-07 22:51:26 +00:00
vaxerski
aefc34b405 Minor fixes for virtual input devices 2022-11-07 22:22:13 +00:00
vaxerski
2a20cf5379 Added decoration:shadow_scale 2022-11-07 21:27:28 +00:00
vaxerski
e3a3837164 fix up formatting 2022-11-07 20:31:56 +00:00
Jan Beich
c86ab4694c meson: explicitly specify path for find(1) (#971)
src/meson.build:1:0: ERROR: Command "/usr/bin/find -name *.cpp" failed with status 1.
2022-11-07 20:27:06 +00:00
Jan Beich
5d5066570c helpers: implement getPPIDof on BSDs (#972)
Get PPID from `struct kinfo_proc` via sysctl for the specified PID.
Adjusted for minor differences between each BSD kernel.
2022-11-07 20:26:23 +00:00
abbadanor
1a55fb4170 Dispatcher to center floating window (#961)
Co-authored-by: Adam Nord <adam.nord@abbgymnasiet.se>
Co-authored-by: vaxerski <vaxry@vaxry.net>
2022-11-07 12:16:30 +00:00
vaxerski
efbc3f8194 resize transition fixes + default transitions to false 2022-11-06 18:10:53 +00:00
vaxerski
f755351511 Fix resize transitions on multimon + transformed 2022-11-06 18:04:30 +00:00
vaxerski
57817f7252 Added resize transitions 2022-11-06 17:52:09 +00:00
vaxerski
b4c45aa2e3 fix compiler warning 2022-11-06 14:28:15 +00:00
vaxerski
5295244026 Revert adding toggle for drm scanout flags
This reverts commit 12697d2b72.

Stupid idea.
2022-11-06 14:25:53 +00:00
vaxerski
082f439db2 fix issues with direct scanout's lack of surface frame feedback 2022-11-06 14:20:03 +00:00
vaxerski
12697d2b72 added toggle for drm scanout flags 2022-11-06 14:11:37 +00:00
vaxerski
976b44443a ignore constraints on exclusiveClient create 2022-11-05 18:34:26 +00:00
vaxerski
6553fb5a40 fix fullscreen maximize size 2022-11-05 18:25:32 +00:00
vaxerski
bee06f3507 add more wlroots flags for faster compile 2022-11-05 18:05:15 +00:00
vaxerski
5a750b485a Added creating / destroying outputs on a multi-backend + headless backend
See `hyprctl output`.
2022-11-05 18:04:44 +00:00
vaxerski
a71f44baa5 fix compiler warning 2022-11-05 13:49:55 +00:00
vaxerski
65db3a7bd3 fix relative protocol paths
CI fix
2022-11-05 13:46:58 +00:00
vaxerski
22384869a6 fix unregistering avars on sethidden 2022-11-05 13:37:57 +00:00
vaxerski
ff76fbe763 prevent double-registering of avars 2022-11-05 13:37:29 +00:00
vaxerski
cfbab453e8 move no_direct_scanout to misc 2022-11-05 13:22:18 +00:00
vaxerski
6a59b57ef8 remove spammy logs for DS 2022-11-05 13:06:48 +00:00
vaxerski
f50c786640 Added direct scanout 2022-11-05 12:50:47 +00:00
vaxerski
70aece8522 constraint focus simplifications 2022-11-04 18:09:40 +00:00
vaxerski
c9eb0f3aab fix missing stub for xwayland 2022-11-04 16:10:10 +00:00
vaxerski
206360177f Multiple animation optimization and xwayland wine fixes 2022-11-04 15:56:31 +00:00
vaxerski
34ad837fd9 don't update the env in session-less hl 2022-11-04 11:30:25 +00:00
vaxerski
e796157672 fix passing input to constrained windows without relative 2022-11-04 11:09:34 +00:00
vaxerski
b51222c004 fix ordering in mouse connect 2022-11-04 10:48:42 +00:00
vaxerski
9aad352789 automatically update dbus environment on start 2022-11-04 10:37:14 +00:00
vaxerski
ce8c20c1ed fix raw exec in configmanager 2022-11-04 10:33:05 +00:00
vaxerski
349afa0e7a guard header windows in layout messages 2022-11-03 22:55:44 +00:00
vaxerski
748a6965ca include utility in defines 2022-11-03 19:55:20 +00:00
vaxerski
97af7c416e added unset rules 2022-11-03 19:52:43 +00:00
vaxerski
47512dd6db remove redundant includes 2022-11-03 19:52:34 +00:00
vaxerski
653b9ed0e4 Fix missing focusedmon event on focusmonitor dispatcher 2022-11-03 19:34:26 +00:00
vaxerski
d0e47d9fe0 added workspace_swipe_forever 2022-11-03 13:35:34 +00:00
Mihai Fufezan
f978368a4e Nix HM: Fix invalid escapes
Fixes #949
2022-11-03 13:21:51 +02:00
vaxerski
c47581fc5a handle transforming displays in outputMgr 2022-11-03 09:06:44 +00:00
vaxerski
31aa357c17 fix safety over ls outputs 2022-11-03 08:56:47 +00:00
vaxerski
6ddfae0a07 remove ensureFDsValid, legacy 2022-11-02 21:28:08 +00:00
Mihai Fufezan
0d7176792b Nix HM: prevent race condition between dbus and systemd
Fixes #940
2022-11-02 21:36:07 +02:00
vaxerski
c1542da18a fix typo in focus 2022-11-02 18:54:41 +00:00
vaxerski
5b548f5bc3 update window values after map finish 2022-11-02 15:15:39 +00:00
vaxerski
5ac2005318 remove old comments 2022-11-02 14:52:36 +00:00
vaxerski
a2b8e3b34e fix the damageBox in damageMonitor 2022-11-02 11:04:17 +00:00
vaxerski
d78b53968f render the debug overlay only on visible monitors 2022-11-02 10:24:43 +00:00
abbadanor
61b950d942 Add focusmaster dispatcher (#942)
* added focusmaster dispatcher

* format

Co-authored-by: Adam Nord <adam.nord@abbgymnasiet.se>
Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
2022-11-02 10:15:11 +00:00
vaxerski
a16073a87b deprecate general:damage_tracking 2022-11-02 10:12:33 +00:00
vaxerski
603a90886f fix swipe on 2 detached workspaces 2022-11-02 10:01:13 +00:00
vaxerski
95bbac8791 remove redundant check in CShader 2022-11-01 18:46:51 +00:00
vaxerski
a69fd21a1a Add an idleinhibit windowrule 2022-10-31 12:26:07 +00:00
Mihai Fufezan
b6e33830af Nix & meson: 0.16.0 -> 0.17.0
Nix: make xwayland dependencies optional
2022-10-31 12:41:31 +02:00
wael
2c67c1c4f8 meson: use gl instead of GL
`/usr/lib/pkgconfig/gl.pc`
2022-10-31 12:39:04 +02:00
vaxerski
989deafd5e use lld instead of i in hyprctl getopt for accurate int reads 2022-10-30 22:45:03 +00:00
vaxerski
9f1d7f7fc7 properly scan for subsurfaces in fullscreen input refocus 2022-10-30 12:28:37 +00:00
vaxerski
6245c92bd0 avoid creating bound WS-es in moveWorkspaceToMonitor 2022-10-30 12:14:12 +00:00
vaxerski
2e32e202e9 set lastmonitor in onDisconnect 2022-10-29 22:45:01 +01:00
vaxerski
d994ad75e8 revert output smart layout reporting 2022-10-29 17:32:03 +01:00
vaxerski
2caebb3b10 fix default 0 in box passing test 2022-10-29 14:37:33 +01:00
vaxerski
05f3eebd96 avoid layout changes when unnecessary in applyMonitorRule 2022-10-29 12:24:44 +01:00
vaxerski
74d05d0adc ensure VRR for current display only in onConnect 2022-10-28 23:48:48 +01:00
vaxerski
341a0616aa avoid applying offset twice in onConnect 2022-10-28 23:23:23 +01:00
vaxerski
ea7f617df6 remove redundant check 2022-10-28 22:33:47 +01:00
vaxerski
644c64d79d lower IME errors to WARNs 2022-10-28 21:47:08 +01:00
vaxerski
d193d70ecf guard primaryFB tex in end() 2022-10-28 21:46:19 +01:00
vaxerski
9e227a52c0 allow cyclenext on null focus 2022-10-28 21:31:39 +01:00
vaxerski
1a767b021b fix minor focus oopsie 2022-10-28 20:12:17 +01:00
vaxerski
83e4006b16 properly find the constraint window 2022-10-28 19:35:02 +01:00
vaxerski
1759b0483c constrain mouse on focus change 2022-10-28 19:20:12 +01:00
vaxerski
f7174acc48 minor fixes for xwayland refocus 2022-10-28 19:18:10 +01:00
vaxerski
c2cd718e89 ignore pointer constraints in touch 2022-10-27 23:44:23 +01:00
Hilton Chain
c21808dd2d meson: Fallback to 'opengl' when 'GL' is not found.
This patch adds 'opengl' as a fallback to 'GL' for dependency lookup, to
link with libglvnd configured without X11 support.

For OpenGL, libglvnd provides two pkg-config files: `gl.pc' with GLX
support while `opengl.pc' not.  When building without X11 support, the
former won't be installed.
2022-10-28 00:50:58 +03:00
Vaxry
2c2e35eec1 Merge pull request #912 from riley-martin/hyprctl
Improve several hyprctl commands
2022-10-27 16:17:15 +01:00
Riley Martin
c064711d2a Improve hyprctl
Added better help for some hyprctl commands.
Failed commands should now 'fail' by returning a nonzero status to the shell

Fix typos
2022-10-27 10:39:21 -04:00
vaxerski
7d6ccca695 add 10bit support to displays 2022-10-27 13:26:47 +01:00
vaxerski
28c81fc71e add disabling pointer devices 2022-10-27 12:58:10 +01:00
Vaxry
d5a0610ea2 No xwayland overhaul (#920) 2022-10-27 11:26:35 +01:00
vaxerski
4aebb73de0 Added hyprctl cursorpos 2022-10-26 13:19:37 +01:00
vaxerski
46e51a81c4 unrestrict hyprctl message size 2022-10-26 13:11:05 +01:00
vaxerski
83ad59fae7 Allow 100%- for move rule 2022-10-26 12:34:26 +01:00
vaxerski
f9a7b6bf26 default focus_on_activate to false 2022-10-25 18:53:18 +01:00
vaxerski
cdb331076a allow # escaping in config 2022-10-25 14:32:25 +01:00
vaxerski
ba9a8a9ded unify LS unmap focus 2022-10-25 14:19:24 +01:00
vaxerski
34bd2cf803 respect wsbind in workspace silent rules 2022-10-25 10:30:25 +01:00
vaxerski
69f1d7b360 Rework workspace rules 2022-10-24 18:36:31 +01:00
vaxerski
e0bc952c83 minor fix to silent ws rules 2022-10-24 17:00:08 +01:00
vaxerski
cf869d9636 allow nofocus + workspace silent 2022-10-24 12:37:07 +01:00
vaxerski
077c1491a8 respect nofocus in candidate searching 2022-10-24 12:28:41 +01:00
vaxerski
c04563734e Rework candidate finding on close window 2022-10-24 12:25:36 +01:00
vaxerski
1d0d350fc3 fix silent + size windowrules 2022-10-24 12:03:15 +01:00
vaxerski
d55338a3f5 fix debug nest black screen 2022-10-24 11:58:07 +01:00
vaxerski
c6a3092b45 more safety around shutting down and mouse movements 2022-10-24 00:14:42 +01:00
vaxerski
10303259f7 always report sizes after a window unmap 2022-10-22 22:10:34 +01:00
Mihai Fufezan
3dca2fd61e Nix: override wayland-protocols 2022-10-23 00:01:55 +03:00
vaxerski
47eac4be1c disable adaptive sync with no_vfr off 2022-10-22 21:45:17 +01:00
vaxerski
2995867760 Transpose matrices on LEGACY_RENDERER 2022-10-22 21:10:49 +01:00
vaxerski
c132f5a91f [gha] bump flake inputs 2022-10-22 20:02:58 +00:00
vaxerski
24587492dd update wlroots dep 2022-10-22 21:01:45 +01:00
vaxerski
44cee0f5f8 more safety for focus requests 2022-10-22 16:45:33 +01:00
vaxerski
2c714eace5 handle activate requests 2022-10-22 16:43:47 +01:00
vaxerski
0d7d7a970d fix crash in event manager on hangup 2022-10-22 16:15:52 +01:00
Vaxry
3a27ef5e12 Merge pull request #893 from wael444/main
meson.build,CMakeLists.txt: use sh instead of bash
2022-10-22 11:57:36 +01:00
wael
6d273c8e44 CMakeLists.txt: use sh instead of bash 2022-10-22 09:23:52 +03:00
wael
c775153e01 meson.build: use sh instead of bash 2022-10-22 09:23:26 +03:00
vaxerski
b71d7c9007 minor workspace rule parsing fixes 2022-10-21 10:45:12 +01:00
vaxerski
ce5f025428 T1C: window dance compat 2022-10-20 22:38:49 +01:00
vaxerski
6df6aea1ba fix swipe with fullscreen maximized 2022-10-20 20:37:37 +01:00
Kainoa Kanter
ca2d2db0ef Add windowrules for noblur and noshadow (#884) 2022-10-20 20:36:27 +01:00
vaxerski
1ccb0b5f96 bump xdg ver to 5 2022-10-20 18:04:21 +01:00
vaxerski
c2545b3ae6 fix refocus on last window 2022-10-20 18:00:29 +01:00
vaxerski
dada872981 minor swipe on new fixes 2022-10-20 17:52:17 +01:00
vaxerski
1eec5161bd minor fix for swipes from empty workspaces 2022-10-20 15:47:35 +01:00
vaxerski
53c3644c29 fix minor anim issue with swipe new 2022-10-20 15:02:46 +01:00
vaxerski
6d66dde208 added swipe create new 2022-10-20 14:54:32 +01:00
vaxerski
1b349f79ac don't set custom mode in change 2022-10-19 22:12:02 +01:00
vaxerski
da8be82c9a Fix self-noding in changeWindowFloatingMode 2022-10-19 21:32:30 +01:00
vaxerski
8ffd244ef6 fix animate_manual_resizes with moves 2022-10-19 21:17:49 +01:00
vaxerski
bf9d31ce49 fix maximized windows not hiding tiled 2022-10-19 15:17:35 +01:00
vaxerski
98a32f5e52 render layer snapshot without blur 2022-10-19 11:00:59 +01:00
vaxerski
dc1737f128 allow glob wildcard in addreserved 2022-10-17 23:23:07 +01:00
Mihai Fufezan
48634d7e4a Nix & meson: 0.15.3 -> 0.16.0 2022-10-18 01:16:44 +03:00
vaxerski
ecf0cdaba4 a bit more default config nice addons 2022-10-17 16:59:52 +01:00
vaxerski
286cb90c48 ignore OR windows' size hints 2022-10-17 14:26:18 +01:00
vaxerski
3f77cde50e set XCURSOR_SIZE if not set in init 2022-10-17 14:01:04 +01:00
vaxerski
1145654987 default & example config overhaul 2022-10-17 13:48:21 +01:00
vaxerski
da4cfb9c32 use size hints when available in xwayland default geom 2022-10-17 11:18:45 +01:00
vaxerski
58375bc87a Add support for rgba() and rgb() colors in the config 2022-10-16 22:26:02 +01:00
Vaxry
83d99ce5bd Merge pull request #857 from K1llf0rce/max_size_rule
add maxsize window rule
2022-10-15 20:09:14 +01:00
K1llf0rce
dca30815b0 add maxsize window rule 2022-10-15 17:04:57 +02:00
vaxerski
edeb759bb1 add loose focus behavior 2022-10-15 14:13:21 +01:00
Mihai Fufezan
610d4d9473 Nix: update nixpkgs 2022-10-15 02:21:13 +03:00
Mihai Fufezan
f30e572e00 Nix & meson: 0.15.0beta -> 0.15.3beta
Nix: remove merged libdrm update
2022-10-15 01:40:25 +03:00
vaxerski
34cd8b125a rework focus system to be more safe and faster 2022-10-14 20:46:32 +01:00
vaxerski
b0544dbfff remove old log 2022-10-14 14:25:28 +01:00
vaxerski
a7bdfc06ca added bringactivetotop dispatcher 2022-10-14 14:22:31 +01:00
Narice
7e7cb40909 Nix modules: fix environment variables 2022-10-14 16:19:14 +03:00
vaxerski
724fa4a7d4 add touch binding to output 2022-10-14 12:38:44 +01:00
Vaxry
cee0645fd1 Merge pull request #813 from histausse/touch_dev_rotation
Add input:touchdevice:transform config
2022-10-14 12:26:31 +01:00
vaxerski
df9409b8a2 rename transform in DC to touch_transform 2022-10-14 12:23:11 +01:00
Vaxry
f274a70edf Merge pull request #852 from NotAShelf/patch-1
add `PKGBUILD` to ignored files
2022-10-14 11:11:28 +01:00
NotAShelf
ef24a27ade add PKGBUILD to ignored files 2022-10-14 11:46:34 +03:00
vaxerski
670d6ce8f4 fix windowsOut disabled with fadeOut enabled 2022-10-13 21:32:28 +01:00
Vaxry
f3917f2122 Merge pull request #844 from brodi1/hyprctl-json-fix
fix invalid json output by adding a missing comma
2022-10-13 15:32:46 +01:00
Brodi
5d6e56b67c fix invalid json output by adding a missing comma 2022-10-13 16:21:58 +02:00
vaxerski
624303bfb9 check for same workspace in workspace rule 2022-10-13 15:19:30 +01:00
vaxerski
eb3c132fc5 set workspace name in previous 2022-10-13 15:17:16 +01:00
vaxerski
170def35d7 simplify shouldRenderWindow and fix one cond 2022-10-12 18:37:11 +01:00
vaxerski
2ee9fb0675 don't recalc offset on monitor reload offset auto 2022-10-12 15:16:31 +01:00
vaxerski
1396d2a39b fix crash in renderWorkspaceWithFullscreenWindow 2022-10-11 20:29:51 +01:00
vaxerski
7ecc41db9c unsetenv on no XWayland 2022-10-11 12:00:06 +01:00
vaxerski
7ffe4eda12 [gha] build man pages 2022-10-11 10:58:53 +00:00
Simplykyle
25756afad5 Add debug coredump instructions (#812) 2022-10-11 11:58:26 +01:00
vaxerski
8880298f50 [gha] bump flake inputs 2022-10-11 09:33:36 +00:00
vaxerski
d89355f0a6 update wlroots 2022-10-11 10:32:11 +01:00
Vaxry
ae91f6610f Merge pull request #825 from Dickby/Fix_nproc_in_Makefile
Replace $(nproc) with $(shell nproc).
2022-10-10 22:36:10 +01:00
Felix Dick
6e7143e0f5 Replace $(nproc) with $(shell nproc). 2022-10-10 17:13:56 +02:00
Vaxry
f55f56f260 Merge pull request #823 from Dickby/simplify_matrix_calculations
Simplify matrix calculations
2022-10-10 15:59:25 +01:00
Histausse
6287f2b71b use static for transformation matrices 2022-10-10 12:52:12 +02:00
Felix Dick
7e781f24c5 Merge branch 'main' into simplify_matrix_calculations 2022-10-10 02:45:40 +02:00
Felix Dick
3bf7c5aea1 Change matrixProjection function stop use matrixFlip180 everywhere. 2022-10-10 01:35:42 +02:00
Felix Dick
092dbda88a Let openGL transpose the matrixes for us. 2022-10-10 01:32:04 +02:00
vaxerski
cb687c208c [gha] bump flake inputs 2022-10-09 20:30:56 +00:00
vaxerski
945b4d7139 update wlroots dep 2022-10-09 21:29:54 +01:00
vaxerski
881f828250 better subsurface handling on unmaps 2022-10-09 17:40:30 +01:00
vaxerski
0743dab3f0 use popup base surface instead of subsurface for addPopupGlobalCoords 2022-10-09 17:10:20 +01:00
vaxerski
496e37d044 ensure texture safety in clearWithTex() 2022-10-09 17:02:39 +01:00
Vaxry
1263bd5dcb Merge pull request #817 from Dickby/transform_box_in_renderRectWithDamage
inverse_transform the box in renderRectWithDamage.
2022-10-09 09:46:22 +01:00
Felix Dick
9ee78b1a92 inverse_transform the box in renderRectWithDamage. 2022-10-09 01:58:00 +02:00
Histausse
406b2fe6dc Add additionnal matrices and rename config var 2022-10-09 00:45:34 +02:00
vaxerski
90f2259f5e [gha] bump flake inputs 2022-10-08 17:01:31 +00:00
vaxerski
948f4978e7 update wlroots dep 2022-10-08 18:00:20 +01:00
Histausse
32ae0c51f0 Add input:touchdevice:td_rotation config
Add support for touch device roation. The rotation is
set globally with `input:touchdevice:td_rotation config` and by
device with `td_rotation` in a device block.
2022-10-08 15:25:46 +02:00
Vaxry
fe4a97f245 Merge pull request #794 from Dickby/pixman_early_outs
Check earlier if pixman_region is empty in some places.
2022-10-08 12:00:17 +01:00
Felix Dick
2f3528c076 Check earlier if pixman regions are empty. 2022-10-08 11:20:04 +02:00
vaxerski
1964bcb13f add open/close layer events 2022-10-07 22:25:00 +01:00
Vaxry
4b779ac142 Merge pull request #811 from Dickby/add_missing_pixman_region32_fini
Add missing pixman_region32_fini.
2022-10-07 22:20:35 +01:00
vaxerski
abc2d442dd fix a VRAM leak in destroyMonitorResources 2022-10-07 22:19:23 +01:00
Felix Dick
b64f1fc5c4 Add missing pixman_region32_fini. 2022-10-07 23:11:20 +02:00
vaxerski
33d264eaa7 release all fbs in destroyMonitorResources 2022-10-07 21:13:28 +01:00
Vaxry
5e3b8c3233 Merge pull request #807 from Dickby/fix_monitor_transforms
Transform the box data send to texture shaders.
2022-10-07 20:12:28 +01:00
Felix Dick
bbdfb7853d Transform the box data send to texture shaders. 2022-10-07 20:55:41 +02:00
vaxerski
a19b152e4a make swipe respect slidevert 2022-10-07 16:52:53 +01:00
vaxerski
1468001d3b offset floating windows out of bounds on ws anims 2022-10-07 12:34:54 +01:00
vaxerski
7faa3c367d Added clipping support, clip windows on slide anim 2022-10-07 10:43:51 +01:00
vaxerski
fd379db846 swallow improvements 2022-10-07 09:46:01 +01:00
vaxerski
28a6e0ce31 [gha] bump flake inputs 2022-10-06 21:09:10 +00:00
vaxerski
af7d60b3f8 revert wlroots ver to fix critical gpu issue 2022-10-06 22:08:08 +01:00
Vaxry
c4487534d2 Merge pull request #801 from fufexan/scrollfactor
Add input:touchpad:scroll_factor
2022-10-06 21:26:11 +01:00
Mihai Fufezan
e4820d1c71 Add input:touchpad:scroll_factor 2022-10-06 22:47:05 +03:00
vaxerski
b4a8efc1a7 fix naming when workspace back and forth 2022-10-06 20:40:58 +01:00
vaxerski
9480c0fb90 fix workspace previous with multi-mon ws moves 2022-10-06 20:18:49 +01:00
vaxerski
f901c60da5 return true on vt switch keysyms to avoid printing stuff 2022-10-06 19:31:32 +01:00
vaxerski
922e978f56 reset sigmask on fork 2022-10-06 19:02:03 +01:00
vaxerski
0508c7d384 more monitor checks for shutdown: 2022-10-06 18:43:50 +01:00
vaxerski
ee3b770cfd more checks in pid gathering 2022-10-06 17:58:38 +01:00
Vaxry
a29af89545 Merge pull request #793 from Dickby/fix_compiler_warnings
Fix compiler warnings.
2022-10-06 12:54:04 +01:00
Felix Dick
552c4b7361 Fix compiler warnings. 2022-10-06 13:42:52 +02:00
vaxerski
d7ef19e2e7 map touch to the correct output 2022-10-06 09:26:05 +01:00
vaxerski
190ddb5697 added a noanim rule 2022-10-06 09:16:40 +01:00
vaxerski
095688712d add minsize rule 2022-10-06 09:09:58 +01:00
vaxerski
d264fbd36a fix string corruption in hyprctl monitors -j 2022-10-06 09:04:46 +01:00
vaxerski
e4527c6b60 use goalv in clientsRequest 2022-10-06 08:54:09 +01:00
Vaxry
32e8eda40a Merge pull request #787 from fufexan/libinput
Add accel profile and scroll method
2022-10-05 21:58:40 +01:00
Mihai Fufezan
477ad2dd82 Add accel profile and scroll method 2022-10-05 23:51:08 +03:00
vaxerski
e90c5c6347 fix tty switch freeze 2022-10-05 21:41:27 +01:00
vaxerski
11ce468996 add dpms status info in hyprctl 2022-10-05 18:14:11 +01:00
vaxerski
9c5023ab1a monitor desc improvements 2022-10-05 17:38:36 +01:00
vaxerski
0e4a894edb add dpms per output 2022-10-05 10:31:47 +01:00
vaxerski
71e2562a41 add desc: to monitor rules 2022-10-05 10:22:33 +01:00
Vaxry
9153a81090 Merge pull request #781 from Dickby/fix_left_handed
Fix getDeviceInt string arg "input:left_handed"
2022-10-05 08:06:38 +01:00
Felix Dick
0d7f6eac9e Merge branch 'make_TTY_unsigned' into fix_left_handed 2022-10-05 04:51:48 +02:00
Felix Dick
6d46ed4011 Fix getDeviceInt string arg "input:left_handed" 2022-10-05 04:25:26 +02:00
Felix Dick
f825b87c2a Fix compiler warnig comparing signed and unsigned integers. 2022-10-05 02:42:51 +02:00
vaxerski
44da575ea8 [gha] bump flake inputs 2022-10-04 22:25:26 +00:00
vaxerski
a587909fd5 update wlroots dep 2022-10-04 23:24:31 +01:00
vaxerski
fd81ba5a4f [gha] bump flake inputs 2022-10-04 22:22:12 +00:00
Vaxry
934f81c93d Merge pull request #777 from Dickby/fix_shader_error
Remove texcoord from QUADFRAGSRC.
2022-10-04 23:20:52 +01:00
Felix Dick
e8be1507ef Remove texcoord from QUADFRAGSRC.
texcoord is unused in the rounding part of the textureshaders.
QUADFRAGSRC isn't using that variable inside the non rounding code.
Because of that opengl optimizes that variable out, and is complaining
if glGetAttribLocation is called on it.
2022-10-05 00:04:32 +02:00
vaxerski
60c414ccad add left_handed config for input 2022-10-04 21:46:41 +01:00
vaxerski
0d702b556d Add switch device handling and binds 2022-10-04 20:07:21 +01:00
vaxerski
9bbae5b8e2 ignore VT switches to current vt 2022-10-04 16:53:09 +01:00
vaxerski
719a5b4f0b use vectorToWindowIdeal in mouse binds 2022-10-04 16:08:55 +01:00
Vaxry
7bdfdaa28a Merge pull request #742 from Dickby/rework_rounding_shader
Rework rounding shader
2022-10-04 14:17:16 +01:00
vaxerski
a80e0cecfe fixes to window swallowing with same pid 2022-10-04 11:16:49 +01:00
vaxerski
3e3f6aef5e additional logic for identical pid swallowing 2022-10-04 10:17:10 +01:00
Vaxry
996938b7e7 Merge pull request #773 from lylac-1/main
focusedmon event check change
2022-10-04 10:04:10 +01:00
lylac
f9325b1655 focusedmon event check change
Compare PLASTWINDOW & PWINDOWTOCHANGETO m_iMonitorID's instead of PWINDOWTOCHANGETO->m_iMonitorID & g_pCompositor->m_pLastMonitor->ID
2022-10-04 18:19:14 +13:00
vaxerski
63dfe305dd log GPU info for debugging 2022-10-03 23:10:15 +01:00
Mihai Fufezan
ec0c6fa22a Nix & meson: 0.14.0 -> 0.15.0 2022-10-04 00:51:49 +03:00
vaxerski
ff5843bd85 anchor to proper quad in floating resize 2022-10-03 22:41:12 +01:00
vaxerski
3bb5971c2e [gha] bump flake inputs 2022-10-03 21:17:33 +00:00
vaxerski
a1d9404f9f update wlroots dep 2022-10-03 22:16:02 +01:00
vaxerski
ab82c4806d allow one less arg in bind 2022-10-03 21:01:08 +01:00
vaxerski
49ab3890aa remove polling from socket2, fully event based 2022-10-03 20:47:15 +01:00
vaxerski
85eea70be4 fix commas in free binds 2022-10-03 16:38:05 +01:00
vaxerski
174b593438 optimize removing trailing spaces 2022-10-03 14:36:56 +01:00
vaxerski
0a08830375 Unify arg lists, allow for trailing spaces in args 2022-10-03 14:29:45 +01:00
vaxerski
a97621b1cb Added window swallowing 2022-10-01 19:19:15 +01:00
vaxerski
355366714e minor OR XWayland fixes 2022-10-01 18:25:02 +01:00
vaxerski
590fbf808b send a focusedmon event on focus change mon 2022-10-01 10:38:53 +01:00
vaxerski
bbeed21e62 fix crash 2022-10-01 08:54:43 +01:00
Felix Dick
c6333ba796 Remove unused ignoreCorners variable from texture shaders. 2022-10-01 03:30:58 +02:00
Felix Dick
6fe103cf06 Cut the number of pixels that call length() in half. 2022-10-01 03:14:13 +02:00
Felix Dick
71733f68ef Merge branch 'fix_rounding_in_size_changing_windows' into rework_rounding_shader 2022-10-01 01:35:13 +02:00
vaxerski
e6c9e3f81d add case for empty strings in isNumber 2022-09-30 21:54:13 +01:00
vaxerski
7579e03b64 include shaders only in opengl.cpp 2022-09-30 18:38:10 +01:00
vaxerski
1ef23a304a remove redundant attrib setting 2022-09-30 17:04:33 +01:00
vaxerski
3c27d1ab13 optimize vector config value setting 2022-09-30 17:03:14 +01:00
vaxerski
59a3c43913 guard event in maximize request 2022-09-30 10:37:09 +01:00
Felix Dick
d867d42366 Merge branch 'main' into fix_rounding_in_size_changing_windows 2022-09-30 01:38:50 +02:00
Felix Dick
6eb7d00386 Send absolute screen coordinates to texture shaders. 2022-09-29 23:19:56 +02:00
vaxerski
2d73da1a79 enter outputs for non-interactive ls-es too 2022-09-29 22:16:43 +01:00
Vaxry
45fe185cb9 Merge pull request #736 from Dickby/fix_bordersize_again
Scale the border size, revert the window scaling according to border
2022-09-29 22:01:06 +01:00
Felix Dick
09268d756f Merge branch 'main' into rework_rounding_shader 2022-09-29 21:15:08 +02:00
Felix Dick
e5dced8b3f Merge branch 'main' into fix_rounding_in_size_changing_windows 2022-09-29 21:13:48 +02:00
Felix Dick
b38e7b596f Don't pass bottomRight to textureShaders compute it within. 2022-09-29 21:10:05 +02:00
vaxerski
da40bf823f apply new node data to all group windows on close 2022-09-29 19:46:33 +01:00
vaxerski
caeb0636fa fix crash on dwindle splitratio alter on single group 2022-09-29 19:41:49 +01:00
Felix Dick
1424539e4d Merge branch 'main' into rework_rounding_shader 2022-09-29 20:41:39 +02:00
vaxerski
bdd9680adf fix ipc event missing on silent movetoworkspace 2022-09-29 19:33:43 +01:00
vaxerski
ff4c22ca90 add fullscreen info to clients request 2022-09-29 19:30:49 +01:00
vaxerski
9f9129e536 focusable checks in nextWindow calls 2022-09-29 16:53:31 +01:00
Felix Dick
ab42e4bccf Merge branch 'main' into fix_bordersize_again 2022-09-29 14:29:03 +02:00
Felix Dick
425b07d1e5 Merge branch 'main' into rework_rounding_shader 2022-09-29 14:24:59 +02:00
vaxerski
2636abca2d use the event data for determining maximize status in requests 2022-09-29 10:24:54 +01:00
vaxerski
ead0e74471 handle maximize toplevel request 2022-09-29 10:20:17 +01:00
Vaxry
dcf5e34bfa Merge pull request #735 from Dickby/fix_splash_position
Splash position fix
2022-09-29 10:07:27 +01:00
Felix Dick
65fb526d5c Even less branching (taken more or less from the border shader). 2022-09-29 06:56:17 +02:00
Felix Dick
10c4f4ba35 Shift splash up if monitor has wider ratio than bgTexture. 2022-09-29 05:29:03 +02:00
Felix Dick
a1319e5110 Merge branch 'main' into fix_bordersize_again 2022-09-29 01:42:28 +02:00
Felix Dick
5233746ac5 Change scaledBorderSize to int. 2022-09-29 01:40:19 +02:00
Felix Dick
0549aa193f fixing your shit. 2022-09-28 23:33:18 +02:00
Felix Dick
168a326609 Merge branch 'main' into rework_rounding_shader 2022-09-28 23:11:11 +02:00
Vaxry
31cb4c49d9 Merge pull request #743 from Dickby/use_double_literals
Use double literals, don't cast integer or float literals to double.
2022-09-28 19:28:13 +01:00
Felix Dick
11ee78f88b Use double literals, don't cast a integer literal to double. 2022-09-28 20:08:41 +02:00
Felix Dick
7edbaea23d Make the rounding texture shaders smaller and more efficient. 2022-09-28 18:40:04 +02:00
vaxerski
ec5ffe8839 rewrite isNumber 2022-09-28 15:32:53 +01:00
vaxerski
e3b1d3c3c5 allow for pure workspace names in dispatchers 2022-09-28 15:26:41 +01:00
vaxerski
458ba3237b use goalv in movetoworkspace 2022-09-28 15:12:15 +01:00
Felix Dick
5ff44467d7 Avoid 38 files to compile every time a shader is modified. 2022-09-28 14:48:05 +02:00
Vaxry
7a775c0584 Merge pull request #737 from Dickby/use_max_instead_of_clamp_in_some_places
Replace clamp with max if there is no upper bound.
2022-09-26 20:49:56 +01:00
Felix Dick
87afc8c250 Replace clamp with max if there is no upper bound. 2022-09-26 21:10:24 +02:00
Felix Dick
cd2b2c4fba Scale the border size, revert the window scaling according to border 2022-09-26 17:38:08 +02:00
Felix Dick
c48336aac3 Scale the cairo matrix to fit the monitor dimensions. 2022-09-26 06:35:00 +02:00
Vaxry
f70b57f360 Merge pull request #732 from Dickby/main
Remove trailing whitespace.
2022-09-25 19:32:24 +01:00
Felix Dick
bf3f519eb7 Remove trailing whitespace. 2022-09-25 20:07:48 +02:00
Vaxry
190229942f Merge pull request #727 from Dickby/main
Scale border size in window size pos calculation
2022-09-25 17:21:31 +01:00
Dickby
e476382d08 scale border size in dwindle layout window sizes. 2022-09-25 18:12:42 +02:00
Dickby
c885afcbc6 Scale border size in calculations of windows 2022-09-25 12:42:39 +02:00
vaxerski
fad5fc587d guard kb settings in xkb translation state 2022-09-24 21:07:18 +01:00
vaxerski
73dbacd16d overwrite wsbind rules on existing 2022-09-24 13:42:18 +01:00
vaxerski
65fb0cf0f6 fix custom rules on null modelist 2022-09-24 13:10:11 +01:00
vaxerski
5101ddeff1 fix oopsies in rule code 2022-09-24 11:30:41 +01:00
Vaxry
959557ecc3 Merge pull request #716 from Dickby/main
Fixing my last change
2022-09-23 18:18:55 +01:00
Dickby
bccc81d306 Fixing my last change
It wasn't a problem with the bug i tried to fix.
But there  would be a problem if some function would dereference pPreviousGroupMember from the node that was PHEAD->pNextGroupMember.
Please don't be mean!
2022-09-23 19:13:05 +02:00
Vaxry
718de0d9fa Merge pull request #715 from Dickby/main
fix crash
2022-09-23 17:05:04 +01:00
vaxerski
fd6116c0cd style 2022-09-23 17:01:27 +01:00
Dickby
00b16888bf style fix 2022-09-23 17:59:33 +02:00
Vaxry
abee2da5bd Merge pull request #706 from DashieTM/main
Add "highest" mode to Monitor for autoconfiguration.
2022-09-23 16:50:24 +01:00
vaxerski
695411f1bd don't decorate on only no gaps 2022-09-23 16:47:58 +01:00
Dickby
f9d8b3096a fix crash
Fixes #711
2022-09-23 17:01:46 +02:00
vaxerski
e5d143b238 support more wlr_cursor events 2022-09-22 21:14:02 +01:00
vaxerski
37f2e1ddbe don't recalc pseudo on fullscreen 2022-09-22 20:57:09 +01:00
vaxerski
ef3eb37c7f support max in size rules 2022-09-22 18:13:23 +01:00
Mihai Fufezan
db551b8970 Nix & meson: bump to 0.14.0 2022-09-22 19:59:38 +03:00
vaxerski
c08218301b disallow pinning fullscreen 2022-09-22 16:48:40 +01:00
vaxerski
75aaf11a9c default pass_mouse_when_bound to 0 2022-09-22 16:33:45 +01:00
Fabio Lenherr
c4e782ca5d remove more silly mistakes 2022-09-22 00:50:23 +02:00
Fabio Lenherr
da2c2ddc21 remove empty line 2022-09-22 00:47:09 +02:00
Fabio Lenherr
5272588270 fix silly mistakes 2022-09-22 00:45:56 +02:00
Fabio Lenherr
215125bd66 add refreshrate or resolution preference 2022-09-22 00:22:39 +02:00
Fabio Lenherr
30d16373d0 fix Hz Log 2022-09-21 22:40:01 +02:00
Fabio Lenherr
c1feb683ce added high to monitor resolution 2022-09-21 22:29:52 +02:00
vaxerski
d3ffccd45f accept any case in binds 2022-09-21 17:41:26 +01:00
Mihai Fufezan
d49af1cc18 flake: add libdrm overlay until it gets updated 2022-09-21 18:10:35 +03:00
vaxerski
8b46d0b5a9 simplify some local vars 2022-09-21 15:11:09 +01:00
vaxerski
336883dda3 [gha] bump flake inputs 2022-09-21 14:09:05 +00:00
vaxerski
65ec8c7694 update wlroots dep 2022-09-21 15:07:57 +01:00
vaxerski
79c645f8cd handle touch devices internally as objects 2022-09-21 14:39:34 +01:00
vaxerski
d44cc9f112 [gha] bump flake inputs 2022-09-21 13:23:15 +00:00
vaxerski
1963da2d47 update wlroots dep 2022-09-21 14:22:05 +01:00
vaxerski
2b99dbb446 better cycling in fullscreen with pinned 2022-09-21 14:16:13 +01:00
vaxerski
d24f31de51 disallow fullscreen pinned 2022-09-21 14:09:26 +01:00
Fabio Lenherr / DashieTM
d51c7ca135 change Preferred mode to use highest refreshrate 2022-09-20 23:41:03 +02:00
vaxerski
8b11a2e1b1 minor mouse bind handling fixes 2022-09-20 22:23:02 +01:00
vaxerski
b4bcba935d disallow move/resize dispatchers on fullscreen windows 2022-09-20 19:58:08 +01:00
vaxerski
7f3750bd75 disable enabling groups on fullscreen windows 2022-09-20 18:08:10 +01:00
vaxerski
7a9423c782 better dwindle swapping with groups 2022-09-20 18:04:39 +01:00
vaxerski
6f98b3cbd8 fix pinned fade on fs 2022-09-20 15:33:53 +01:00
vaxerski
2dd1661aec fix groups with fullscreen 2022-09-20 12:17:34 +01:00
vaxerski
cde624ec6a fix moving between fullscreen workspaces 2022-09-20 10:16:58 +01:00
vaxerski
b82621c4ec fix mouse binds being stuck 2022-09-20 10:02:20 +01:00
vaxerski
5b6c8d5b0f fix misc fullscreen issues 2022-09-20 09:55:25 +01:00
vaxerski
4dca2b945b fix LS fading out on ws change 2022-09-20 09:46:55 +01:00
Vaxry
a8943246a7 Merge pull request #684 from tomahk/main
fix some bugs with attaching/disabling monitors
2022-09-19 21:08:48 +01:00
vaxerski
e42de0b778 export HYPRLAND_CMD for scripts 2022-09-19 21:06:44 +01:00
tomahk
5146165599 this is c++, use nullptr 2022-09-19 21:45:00 +02:00
tomahk
73e19aee6f prevent assert killing Hyprland after reenabling monitor 2022-09-19 20:44:33 +02:00
tomahk
3780361b95 fix hyprland freeze when undocking from docking station 2022-09-19 20:42:59 +02:00
vaxerski
ec6144e5da fix fadeout on unmap fullscreen 2022-09-19 19:09:21 +01:00
vaxerski
b6eaeffcf6 introduce new mouse binds in default and example cfgs 2022-09-19 19:06:22 +01:00
vaxerski
c24b45671a mouse binds overhaul 2022-09-19 19:04:48 +01:00
vaxerski
85c7aaf155 fade control for fullscreen action on windows 2022-09-19 17:26:11 +01:00
vaxerski
696253b348 fix special workspace dispatcher logic 2022-09-19 16:01:42 +01:00
vaxerski
abb6db9c37 don't apply alpha to fadingOut on setWindowFullscreen 2022-09-19 11:44:11 +01:00
vaxerski
18b483b8e1 fix ws switching with LS opacity 2022-09-19 10:40:42 +01:00
vaxerski
7c809a3059 fullscreen animation en-nice-ment 2022-09-19 10:23:13 +01:00
vaxerski
4070e1a148 fix wonky focus on movetoworkspace 2022-09-18 17:26:12 +01:00
vaxerski
dd61f88ed1 guard invalid FB allocs 2022-09-18 12:40:49 +01:00
vaxerski
29626989e7 fix focus follows mouse 0 event sending on wrong window 2022-09-18 12:35:05 +01:00
vaxerski
cf32d28082 fix groupbar being wonk on scaled 2022-09-18 12:13:16 +01:00
vaxerski
5131a4acaf fix special fullscreen 2022-09-17 15:07:03 +01:00
vaxerski
a72a39ebd5 minor swipe fixes 2022-09-17 15:05:12 +01:00
vaxerski
151e013241 fix refocus on same workspace 2022-09-17 12:10:06 +01:00
vaxerski
fa2d81b649 fix animation issues with workspace silent 2022-09-16 21:17:03 +01:00
vaxerski
037d4ed422 handle multi-ws swaps in layouts 2022-09-14 17:30:16 +02:00
vaxerski
9f82278d65 simplify dwindle swap 2022-09-14 17:24:45 +02:00
vaxerski
8e0f7b9b11 Various subsurface handling fixes 2022-09-14 16:34:41 +02:00
vaxerski
a96acc8fa4 only check for visible on xdg 2022-09-13 22:23:48 +02:00
vaxerski
5a146e9d90 guard surface in addsurfaceglobaloffset 2022-09-13 21:49:55 +02:00
vaxerski
da10022d84 fix an unholy memory safety issue 2022-09-13 20:27:07 +02:00
vaxerski
e518adf1ac don't iterate over subsurfaces in unmap 2022-09-13 15:44:50 +02:00
vaxerski
d8dbe26f31 tick config after reload request 2022-09-13 15:36:49 +02:00
vaxerski
e9f226797e Added monitor mirroring 2022-09-13 15:25:42 +02:00
vaxerski
7d4f0a3199 verify visibility of new geom in floating creation 2022-09-13 12:29:56 +02:00
vaxerski
0062281092 added wsbind 2022-09-12 21:05:52 +02:00
vaxerski
81f267dff9 add default speed to hyprctl devices mice 2022-09-12 17:09:04 +02:00
vaxerski
a09c614c2d more forceRendering checks in shouldRenderWindow 2022-09-12 15:33:25 +02:00
Vaxry
b49d7007b5 Merge pull request #659 from hyprwm/hyprctl-nopoll
hyprctl-nopoll
2022-09-11 20:48:22 +02:00
vaxerski
864e227f5d fix decos on pinned 2022-09-11 20:27:59 +02:00
vaxerski
82aa78916d hyprctl-nopoll 2022-09-10 21:21:28 +02:00
vaxerski
f024d7114f allow current in monitorfromstring 2022-09-10 19:57:57 +02:00
vaxerski
8808d40008 added misc:disable_autoreload 2022-09-10 17:28:41 +02:00
vaxerski
d94fe3d063 added window pinning 2022-09-10 13:11:02 +02:00
vaxerski
f663fa209c minor code styling fixes 2022-09-09 19:08:11 +02:00
Mihai Fufezan
9370c7aa8a Nix modules: add recommendedEnvironment option 2022-09-09 17:01:24 +03:00
vaxerski
928158bbfb prevent missed surface size updates on fullscreen window close 2022-09-08 23:02:29 +02:00
vaxerski
bacfae3084 guard drag in destroyDrag 2022-09-08 21:25:16 +02:00
vaxerski
0d95a0174c more guarding in cleanup pid gathering 2022-09-08 20:55:25 +02:00
vaxerski
0eb5ecafb9 consistent output of window addresses 2022-09-08 18:47:39 +02:00
vaxerski
49a55f136e fix addreserved lag 2022-09-08 14:11:32 +02:00
vaxerski
64be57b780 fix group decos on added windows 2022-09-07 20:36:39 +02:00
Vaxry
6e195a6b8c Merge pull request #636 from viperML/fix-man
docs: fix github workflow
2022-09-07 13:05:16 +02:00
Fernando Ayats
8d3f6c5d84 docs: fix github workflow 2022-09-07 12:44:20 +02:00
vaxerski
5c470d2e54 damage drag on destroy 2022-09-07 12:18:52 +02:00
Mihai Fufezan
26910a8b63 Nix HM module: fix build error
Apparently HM doesn't like having `lib.mkDefault` near strings.

Fixes #635
2022-09-07 13:11:03 +03:00
vaxerski
44a2d755c6 Added Xwayland and floating props to windowrulev2 2022-09-07 11:25:44 +02:00
Mars
cf5426f2d8 Fix typo in module.nix 2022-09-07 11:48:08 +03:00
Mihai Fufezan
1d631c8a23 Nix modules: add common environment variables 2022-09-07 01:24:09 +03:00
vaxerski
789eedd115 fix a minor bug with no gaps when only and groups 2022-09-06 19:59:59 +02:00
vaxerski
4a8274e5f0 fix dwindle no gaps when only when dissolving a group 2022-09-06 18:12:41 +02:00
vaxerski
4b7d28d2cb fix last partial commit 2022-09-06 18:12:25 +02:00
vaxerski
5fdd1dd60f simplify config monitor reloads and rearrange layers 2022-09-06 17:26:18 +02:00
vaxerski
e71a4d75de Added windowrulev2 2022-09-06 11:57:11 +02:00
vaxerski
f002bd1603 wrap lastwindow in quotes in hyprctl json 2022-09-05 23:07:56 +02:00
vaxerski
16f1d1b99b guard unsafe state in unmap ls 2022-09-05 22:35:41 +02:00
vaxerski
c1bc8d46e9 use lastMonitor in mapWindow 2022-09-05 22:04:49 +02:00
vaxerski
94ca386a8c set last monitor and dont refocus in some cases (changeworkspace) 2022-09-05 21:36:22 +02:00
vaxerski
2ba7cb2414 escape json strings in workspaces lastwindow title 2022-09-05 21:32:37 +02:00
vaxerski
5b5f36f494 fix transformed blur on new optimizations 2022-09-05 21:26:21 +02:00
vaxerski
a74b8033ca added a submap IPC event 2022-09-05 13:50:52 +02:00
vaxerski
41883e0522 fix wonky behavior with silent workspace rule 2022-09-05 11:44:43 +02:00
vaxerski
3ea89e6171 fix splash positioning 2022-09-05 11:31:54 +02:00
vaxerski
d6c06318af don't accumulate from virtual 2022-09-05 11:19:40 +02:00
vaxerski
cb839c9dcc guard pFoundWindow in CInputManager under fullscreen 2022-09-05 00:59:13 +02:00
vaxerski
3dd514a452 fix a damage issue with transformed blur 2022-09-04 23:08:04 +02:00
vaxerski
6afab12b91 fix blur on transformed displays 2022-09-04 19:27:38 +02:00
vaxerski
7a3b57c99c send accumulated modifiers to surfaces 2022-09-04 18:46:28 +02:00
vaxerski
ba0c5fe0bb fix mouse focus not returning from a LS on follow mouse 0 2022-09-04 18:42:11 +02:00
vaxerski
f6ecef0959 add lastwindow info to hyprctl workspaces 2022-09-04 18:32:03 +02:00
vaxerski
ff26531e11 use activateSurface in unconstrainMouse 2022-09-04 11:29:49 +02:00
vaxerski
fbd2b4799d Fix some more crimes against humanity 2022-09-03 22:49:52 +02:00
Mihai Fufezan
1664f81cae Nix: revert HM module import fix
fixes #619
2022-09-03 23:22:39 +03:00
vaxerski
c425e620af fix some minor crimes against humanity 2022-09-03 19:35:17 +02:00
vaxerski
f4add0ac6d refocus on reserved area 2022-09-03 15:35:53 +02:00
vaxerski
3c3f80c2fe simplify code and update monitor on warp 2022-09-03 11:55:19 +02:00
Mihai Fufezan
eee0cad4d0 Nix modules: fix imports 2022-09-03 02:20:20 +03:00
Mihai Fufezan
0ea96e87c0 flake: remove overlay warning 2022-09-03 01:55:28 +03:00
vaxerski
5d09bb647b fix up styling 2022-09-02 23:56:22 +02:00
vaxerski
f5697095bc unify monitor args 2022-09-02 11:53:12 +02:00
vaxerski
56203b1757 fix no_gaps_when_only with a group 2022-09-01 19:46:38 +02:00
Fernando Ayats
c0a7dffcdc nix: move wlroots and add nvidia patches (#608) 2022-09-01 20:35:50 +03:00
vaxerski
8581e71789 optimize calls in toggleSpecialWorkspace 2022-09-01 11:47:48 +02:00
vaxerski
bb90ff0461 sanity check on last window 2022-09-01 11:46:41 +02:00
vaxerski
1d4d2f4793 [gha] bump flake inputs 2022-09-01 09:25:26 +00:00
vaxerski
7f62cbc48a Update wlroots dep 2022-09-01 11:24:15 +02:00
vaxerski
f2d84a7e3a guard parent in X11TransientFor 2022-09-01 10:16:23 +02:00
vaxerski
095185cfe7 guard parent in X11TransientFor 2022-09-01 10:15:55 +02:00
vaxerski
f77fac9df9 warp only on another monitor in changeworkspace 2022-08-31 21:39:27 +02:00
vaxerski
dacaf72e02 remember last window on workspace 2022-08-31 17:02:49 +02:00
Mihai Fufezan
0ad261aa9c flake: formatting 2022-08-31 12:26:12 +03:00
Mihai Fufezan
7610c20761 Nix & meson: 0.11.1 -> 0.12.1
flake: add commit to wlroots version
2022-08-31 12:22:32 +03:00
vaxerski
4103bca056 default rounding to 0 2022-08-31 11:17:04 +02:00
vaxerski
21a1b62b6a remove tiling node when invalid 2022-08-31 11:14:33 +02:00
vaxerski
7f483dfdb0 guard psurface in activateSurface 2022-08-31 11:12:46 +02:00
vaxerski
1cf46fd6a2 added closewindow dispatcher 2022-08-30 21:35:27 +02:00
vaxerski
eb658dcb61 finally fixed transformed snapshots 2022-08-30 19:40:19 +02:00
vaxerski
195ec2b092 fix LS popup damage 2022-08-30 19:21:45 +02:00
vaxerski
dd6aba07e9 revert x11 size hints 2022-08-30 16:12:11 +02:00
vaxerski
d35d949bc5 use sizehints if existent for X11 default floating 2022-08-30 13:07:54 +02:00
vaxerski
48eb2e0d6f Added window dimming 2022-08-30 12:46:17 +02:00
vaxerski
179562b646 fix dwindle groupbars 2022-08-29 19:52:35 +02:00
vaxerski
20c050e890 set last monitor on move focus dispatcher 2022-08-29 18:50:10 +02:00
Mihai Fufezan
bdd20c401d Add HiDPI xwayland + wlroots patches (#591) 2022-08-29 16:51:39 +03:00
vaxerski
6865660e51 disable fullscreen and floating dispatchers on special 2022-08-29 14:55:11 +02:00
vaxerski
6c8ce734fb fix segfault in inactive sessions 2022-08-29 11:17:42 +02:00
vaxerski
09495375b5 ratelimit setting cursor 2022-08-28 22:45:05 +02:00
vaxerski
3c20ecb04d ignore oversized popups' dims in global coords 2022-08-28 21:20:18 +02:00
vaxerski
5da114477f move X11 transients to top on parent top 2022-08-28 19:47:06 +02:00
vaxerski
c757fa54e1 Allow passing the mouse as well in pass 2022-08-28 17:01:48 +02:00
vaxerski
16f8d46391 Force wlroots to not send leave events in pass to XWayland
Massive hack, kill me
2022-08-28 16:43:15 +02:00
vaxerski
5726f394b1 fix subsurface UV handling on oversized windows 2022-08-28 14:43:25 +02:00
vaxerski
f5f99c6700 reset uv on invalid buffer source box 2022-08-28 14:32:06 +02:00
vaxerski
cfa6c01df0 remove double drm and dmabuf creation 2022-08-28 12:32:26 +02:00
vaxerski
d413388761 Multiple improvements to the shutdown procedure 2022-08-28 11:19:08 +02:00
vaxerski
4203a61b69 minor fixes to the viewporter behavior 2022-08-28 10:41:47 +02:00
vaxerski
80b3a436d2 better find device cats 2022-08-28 10:25:48 +02:00
vaxerski
5d9d55a245 fix device closing 2022-08-28 10:20:26 +02:00
Vaxry
52c0ba544c Viewporter implementaion (#585)
Implementation of the `wp_viewporter` core protocol and some bugfixes
2022-08-28 10:14:43 +02:00
Vaxry
8b5c64c8fd Merge pull request #589 from alec-lefors/drm-leasing
fix more indents
2022-08-28 00:07:01 +02:00
Alec LeFors
2ea5f50f40 fix more indents, im sorry vaxry 2022-08-27 17:57:02 -04:00
Vaxry
1d97ad9856 Merge pull request #588 from alec-lefors/drm-leasing
implemented DRM leasing
2022-08-27 23:47:41 +02:00
Alec LeFors
1d43bb70d4 fix indents, change crit log to info 2022-08-27 17:24:36 -04:00
vaxerski
573cb0d4e0 fix parser in nested categories 2022-08-27 23:12:01 +02:00
Alec LeFors
59d7cfcd02 implemented DRM leasing for VR headsets 2022-08-27 17:10:13 -04:00
vaxerski
ed2cacc5d5 fix styling in const ptrs 2022-08-27 21:37:35 +02:00
Nicholas Cioli
df4c1c02a6 fix xwayland config option for nix (#587)
When building Hyprland in nix using the following home-manager recipe:

```nix
wayland.windowManager.hyprland = {
    enable = true;
    xwayland = false;
  };
```

The default nix configuration still makes reference to a compile argument `NO_XWAYLAND`, but the `meson_options.txt` only makes reference to `xwayland`. This causes the build to fail with:

```
meson.build:1:0: ERROR: Unknown options: "NO_XWAYLAND"
```

This change fixes that issue. This still doesn't allow you to build Hyprland without having XWayland installed (#178), but it should at least allow for valid nix configurations for when that issue gets resolved.
2022-08-27 21:45:48 +03:00
vaxerski
8122505825 pass press and release events separately 2022-08-27 19:29:28 +02:00
vaxerski
0964448f93 fix fullscreen in moving ws 2022-08-27 19:11:21 +02:00
vaxerski
5d63152219 added a forceinput rule 2022-08-27 13:01:55 +02:00
vaxerski
aaa834d0c3 fix logic in candidates on unmap 2022-08-27 12:02:25 +02:00
vaxerski
28966d85ae guard nullptr in unmap 2022-08-27 12:01:04 +02:00
vaxerski
a648b452dd fix internal keybinds 2022-08-26 19:19:34 +02:00
vaxerski
d53b0a6491 optimize options in dwindle 2022-08-26 19:07:33 +02:00
Mihai Fufezan
80d522cb26 nix & meson: update version to 0.11.1 2022-08-26 19:48:22 +03:00
vaxerski
dbd774fedb simplify a bit of code 2022-08-26 18:02:10 +02:00
Mihai Fufezan
bf00bf7963 Nix: add nixConfig 2022-08-26 18:58:42 +03:00
vaxerski
949655005a added an event for moving workspace 2022-08-26 16:05:02 +02:00
Vaxry
56caba5f01 updated readme previews 2022-08-26 11:41:07 +02:00
vaxerski
b09f157b93 fix fullscreen on workspace rule silent 2022-08-26 11:33:36 +02:00
vaxerski
10f529ada7 added a specialWorkspace anim leaf 2022-08-26 11:26:23 +02:00
vaxerski
f7c741317f fix shadows on silent rule 2022-08-26 01:08:11 +02:00
vaxerski
b16a57ceeb fix window rules 2022-08-26 00:38:20 +02:00
vaxerski
0eb86f4b0d fix silent workspaces with back and forth 2022-08-26 00:19:57 +02:00
vaxerski
7b01c3d028 allow specifying window for toggle floating 2022-08-25 22:34:53 +02:00
vaxerski
89018bfa95 remove leftover code that didnt work 2022-08-25 21:38:01 +02:00
vaxerski
0d1a9e4ba9 modify exit behaviour a bit 2022-08-25 21:35:47 +02:00
vaxerski
e327b0a835 added a swapactiveworkspaces dispatcher 2022-08-25 21:25:28 +02:00
vaxerski
de477a6ff5 don't focus silent windows 2022-08-25 16:47:33 +02:00
Vaxry
e92469121d Merge pull request #573 from NotAShelf/main
Add cleaninstall task
2022-08-24 22:05:27 +02:00
NotAShelf
a9761cb1c8 Merge branch 'hyprwm:main' into main 2022-08-24 23:05:22 +03:00
vaxerski
6c2175ed52 fixes to swapnext logic on dwindle 2022-08-24 22:01:25 +02:00
vaxerski
00ef40dda1 added swapnext and swapprev for master 2022-08-24 21:50:48 +02:00
vaxerski
9c3aeda9f9 added swapnext 2022-08-24 21:40:36 +02:00
NotAShelf
a4f7bd4bc2 fix typo
what is this, clash of clans?
2022-08-24 18:53:30 +03:00
NotAShelf
3fd903ee74 remove unintended whitespace 2022-08-24 18:51:57 +03:00
NotAShelf
83ef951c21 add clean install for those who build from source 2022-08-24 18:47:35 +03:00
NotAShelf
8bbb790d87 [gha] build man pages 2022-08-24 15:46:38 +00:00
vaxerski
ffaf14c19e minor damage fixes 2022-08-24 13:44:48 +02:00
vaxerski
9366c187dc don't find a new candidate to refocus on unfocused unmap 2022-08-24 11:14:11 +02:00
vaxerski
29696d046e remove general:sensitivity from the default config 2022-08-24 11:12:42 +02:00
vaxerski
09f3999b1e Unfocus first on non-internal ws changes 2022-08-23 23:34:36 +02:00
110 changed files with 9109 additions and 2822 deletions

View File

@@ -41,7 +41,7 @@ jobs:
cp ./LICENSE hyprland/ cp ./LICENSE hyprland/
cp build/Hyprland hyprland/ cp build/Hyprland hyprland/
cp hyprctl/hyprctl hyprland/ cp hyprctl/hyprctl hyprland/
cp subprojects/wlroots/build/libwlroots.so.11032 hyprland/ cp subprojects/wlroots/build/libwlroots.so.12032 hyprland/
cp build/Hyprland hyprland/ cp build/Hyprland hyprland/
cp -r example/ hyprland/ cp -r example/ hyprland/
cp -r assets/ hyprland/ cp -r assets/ hyprland/
@@ -62,7 +62,7 @@ jobs:
run: | run: |
sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers xcb-util-errors xcb-util-renderutil xcb-util-wm xorg-fonts-encodings xorg-server-common xorg-setxkbmap xorg-xkbcomp xorg-xwayland git go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers git go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd cmake
- name: Checkout Hyprland - name: Checkout Hyprland
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
@@ -73,13 +73,23 @@ jobs:
-Ddefault_library=static -Ddefault_library=static
- name: Compile - name: Compile
run: ninja -C obj-x86_64-pc-linux-gnu run: ninja -C obj-x86_64-pc-linux-gnu
# - name: Compress artifacts
# run: | noxwayland:
# mkdir x86_64-pc-linux-gnu name: "Build Hyprland in pure Wayland (Arch)"
# DESTDIR=$PWD/x86_64-pc-linux-gnu meson install -C obj-x86_64-pc-linux-gnu --tags runtime runs-on: ubuntu-latest
# tar -cvf x86_64-pc-linux-gnu.tar.xz x86_64-pc-linux-gnu container:
# - name: Upload artifacts image: archlinux
# uses: actions/upload-artifact@v3 steps:
# with: - name: Download dependencies
# name: Build artifacts (x86_64-pc-linux-gnu) run: |
# path: x86_64-pc-linux-gnu.tar.xz sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy glslang libepoxy libfontenc libxcvt libxfont2 libxkbfile vulkan-headers vulkan-validation-layers git cmake go clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd
- name: Checkout Hyprland
uses: actions/checkout@v3
with:
submodules: true
- name: Configure
run: mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DNO_XWAYLAND:STRING=true -H./ -B./build -G Ninja
- name: Compile
run: make config && make release

View File

@@ -5,6 +5,8 @@ on:
push: push:
paths: paths:
- docs/** - docs/**
branches:
- 'main'
jobs: jobs:
main: main:

View File

@@ -5,21 +5,26 @@ jobs:
nix: nix:
name: "Build Hyprland (Nix)" name: "Build Hyprland (Nix)"
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
package:
- default
- hyprland-no-hidpi
steps: steps:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Install nix - name: Install nix
uses: cachix/install-nix-action@v17 uses: cachix/install-nix-action@v18
with: with:
install_url: https://releases.nixos.org/nix/nix-2.10.3/install install_url: https://nixos.org/nix/install
extra_nix_config: | extra_nix_config: |
auto-optimise-store = true auto-optimise-store = true
experimental-features = nix-command flakes experimental-features = nix-command flakes
- uses: cachix/cachix-action@v10 - uses: cachix/cachix-action@v12
with: with:
name: hyprland name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build Hyprland with default settings - name: Build Hyprland with default settings
run: nix build --print-build-logs run: nix build .#${{ matrix.package }} --print-build-logs

View File

@@ -9,9 +9,9 @@ jobs:
- name: Clone repository - name: Clone repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install nix - name: Install nix
uses: cachix/install-nix-action@v17 uses: cachix/install-nix-action@v18
with: with:
install_url: https://releases.nixos.org/nix/nix-2.8.0/install install_url: https://nixos.org/nix/install
extra_nix_config: | extra_nix_config: |
auto-optimise-store = true auto-optimise-store = true
experimental-features = nix-command flakes experimental-features = nix-command flakes

View File

@@ -17,7 +17,7 @@ jobs:
- name: Create tarball with submodules - name: Create tarball with submodules
id: tar id: tar
run: tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz * run: mkdir hyprland-source; mv ./* ./hyprland-source || tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz *
- id: whatrelease - id: whatrelease
name: Get latest release name: Get latest release

2
.gitignore vendored
View File

@@ -25,3 +25,5 @@ hyprctl/hyprctl
gmon.out gmon.out
*.out *.out
*.tar.gz *.tar.gz
PKGBUILD

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "wlroots"] [submodule "wlroots"]
path = subprojects/wlroots path = subprojects/wlroots
url = https://gitlab.freedesktop.org/wlroots/wlroots.git url = https://gitlab.freedesktop.org/wlroots/wlroots.git
[submodule "subprojects/hyprland-protocols"]
path = subprojects/hyprland-protocols
url = https://github.com/hyprwm/hyprland-protocols

View File

@@ -5,7 +5,7 @@ project(Hyprland
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
message(STATUS "Configuring Hyprland!") message(STATUS "Gathering git info")
# Get git info # Get git info
# hash and branch # hash and branch
@@ -22,27 +22,39 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( execute_process(
COMMAND bash -c "git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1" COMMAND sh -c "git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -s 's/#|\"//g'"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_VARIABLE GIT_COMMIT_MESSAGE
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( execute_process(
COMMAND bash -c "git diff-index --quiet HEAD -- || echo \"dirty\"" COMMAND sh -c "git diff-index --quiet HEAD -- || echo \"dirty\""
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DIRTY OUTPUT_VARIABLE GIT_DIRTY
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
# #
# #
IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake")
add_definitions( -DHYPRLAND_DEBUG )
ELSE()
add_compile_options( -O3 )
message(STATUS "Configuring Hyprland in Release with CMake")
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
include_directories(. PRIVATE "subprojects/wlroots/include/") include_directories(. PRIVATE "subprojects/wlroots/include/")
include_directories(. PRIVATE "subprojects/wlroots/build/include/") include_directories(. PRIVATE "subprojects/wlroots/build/include/")
add_compile_options(-std=c++23 -DWLR_USE_UNSTABLE ) set(CMAKE_CXX_STANDARD 23)
add_compile_options(-DWLR_USE_UNSTABLE)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing) add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing)
message(STATUS "Checking deps...")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo pango pangocairo libdrm egl xkbcommon libinput xcb) # we do not check for wlroots, as we provide it ourselves pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo pango pangocairo libdrm egl xkbcommon libinput) # we do not check for wlroots, as we provide it ourselves
file(GLOB_RECURSE SRCFILES "src/*.cpp") file(GLOB_RECURSE SRCFILES "src/*.cpp")
@@ -56,15 +68,11 @@ ENDIF(LEGACY_RENDERER MATCHES true)
IF(NO_XWAYLAND MATCHES true) IF(NO_XWAYLAND MATCHES true)
message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!") message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!")
add_definitions( -DNO_XWAYLAND ) add_definitions( -DNO_XWAYLAND )
ENDIF(NO_XWAYLAND MATCHES true)
IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake!")
add_definitions( -DHYPRLAND_DEBUG )
ELSE() ELSE()
add_compile_options( -O3 ) message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
message(STATUS "Configuring Hyprland in Release with CMake!") pkg_check_modules(xcbdep REQUIRED xcb)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) target_link_libraries(Hyprland xcb)
ENDIF(NO_XWAYLAND MATCHES true)
target_compile_definitions(Hyprland PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"") target_compile_definitions(Hyprland PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
target_compile_definitions(Hyprland PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"") target_compile_definitions(Hyprland PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"")
@@ -77,19 +85,24 @@ set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack) include(CPack)
message(STATUS "Setting link libraries")
target_link_libraries(Hyprland PkgConfig::deps) target_link_libraries(Hyprland PkgConfig::deps)
target_link_libraries(Hyprland target_link_libraries(Hyprland
${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.11032 # wlroots is provided by us ${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.12032 # wlroots is provided by us
pixman-1 pixman-1
OpenGL OpenGL
GLESv2 GLESv2
pthread pthread
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${CMAKE_SOURCE_DIR}/ext-workspace-unstable-v1-protocol.o ${CMAKE_SOURCE_DIR}/ext-workspace-unstable-v1-protocol.o
${CMAKE_SOURCE_DIR}/hyprland-toplevel-export-v1-protocol.o
) )
IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) IF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Setting debug flags")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -no-pie -fno-builtin") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -no-pie -fno-builtin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg -no-pie -fno-builtin") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg -no-pie -fno-builtin")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg -no-pie -fno-builtin") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg -no-pie -fno-builtin")

View File

@@ -91,21 +91,41 @@ wlr-output-power-management-unstable-v1-protocol.c:
wlr-output-power-management-unstable-v1-protocol.o: wlr-output-power-management-unstable-v1-protocol.h wlr-output-power-management-unstable-v1-protocol.o: wlr-output-power-management-unstable-v1-protocol.h
hyprland-toplevel-export-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml $@
hyprland-toplevel-export-v1-protocol.c:
$(WAYLAND_SCANNER) private-code \
subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml $@
hyprland-toplevel-export-v1-protocol.o: hyprland-toplevel-export-v1-protocol.h
linux-dmabuf-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml $@
linux-dmabuf-unstable-v1-protocol.c:
$(WAYLAND_SCANNER) private-code \
$(WAYLAND_PROTOCOLS)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml $@
linux-dmabuf-unstable-v1-protocol.o: linux-dmabuf-unstable-v1-protocol.h
legacyrenderer: legacyrenderer:
mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja
cmake --build ./build --config Release --target all -j $(nproc) cmake --build ./build --config Release --target all -j$(shell nproc)
legacyrendererdebug: legacyrendererdebug:
mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:STRING=true -H./ -B./build -G Ninja
cmake --build ./build --config Release --target all -j $(nproc) cmake --build ./build --config Release --target all -j$(shell nproc)
release: release:
mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -H./ -B./build -G Ninja mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -H./ -B./build -G Ninja
cmake --build ./build --config Release --target all -j $(nproc) cmake --build ./build --config Release --target all -j$(shell nproc)
debug: debug:
mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -H./ -B./build -G Ninja mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -H./ -B./build -G Ninja
cmake --build ./build --config Debug --target all -j $(nproc) cmake --build ./build --config Debug --target all -j$(shell nproc)
clear: clear:
rm -rf build rm -rf build
@@ -114,14 +134,17 @@ clear:
rm -rf ./subprojects/wlroots/build rm -rf ./subprojects/wlroots/build
all: all:
make config make clear
make fixwlr
cd ./subprojects/wlroots && meson build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.12032 /usr/lib/ && cd ../..
make protocols
make release make release
cd ./hyprctl && make all && cd .. cd hyprctl && make all && cd ..
install: install:
make clear make clear
make fixwlr make fixwlr
cd ./subprojects/wlroots && meson build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.11032 /usr/lib/ && cd ../.. cd ./subprojects/wlroots && meson build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.12032 /usr/lib/ && cd ../..
make protocols make protocols
make release make release
cd hyprctl && make all && cd .. cd hyprctl && make all && cd ..
@@ -138,19 +161,38 @@ install:
install -Dm644 -t ${PREFIX}/share/man/man1 ./docs/*.1 install -Dm644 -t ${PREFIX}/share/man/man1 ./docs/*.1
cleaninstall:
make clear
make fixwlr
cd ./subprojects/wlroots && meson build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.12032 /usr/lib/ && cd ../..
make protocols
make release
cd hyprctl && make all && cd ..
mkdir -p /usr/share/wayland-sessions
mkdir -p ${PREFIX}/bin
cp ./build/Hyprland ${PREFIX}/bin
cp ./hyprctl/hyprctl ${PREFIX}/bin
mkdir -p ${PREFIX}/share/hyprland
cp ./assets/wall_2K.png ${PREFIX}/share/hyprland
cp ./assets/wall_4K.png ${PREFIX}/share/hyprland
cp ./assets/wall_8K.png ${PREFIX}/share/hyprland
install -Dm644 -t ${PREFIX}/share/man/man1 ./docs/*.1
uninstall: uninstall:
rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop
rm -f ${PREFIX}/bin/Hyprland rm -f ${PREFIX}/bin/Hyprland
rm -f ${PREFIX}/bin/hyprctl rm -f ${PREFIX}/bin/hyprctl
rm -f /usr/lib/libwlroots.so.11032 rm -f /usr/lib/libwlroots.so.12032
rm -rf ${PREFIX}/share/hyprland rm -rf ${PREFIX}/share/hyprland
rm -f ${PREFIX}/share/man/man1/Hyprland.1 rm -f ${PREFIX}/share/man/man1/Hyprland.1
rm -f ${PREFIX}/share/man/man1/hyprctl.1 rm -f ${PREFIX}/share/man/man1/hyprctl.1
protocols: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o wlr-screencopy-unstable-v1-protocol.o idle-protocol.o ext-workspace-unstable-v1-protocol.o pointer-constraints-unstable-v1-protocol.o tablet-unstable-v2-protocol.o wlr-output-power-management-unstable-v1-protocol.o protocols: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o wlr-screencopy-unstable-v1-protocol.o idle-protocol.o ext-workspace-unstable-v1-protocol.o pointer-constraints-unstable-v1-protocol.o tablet-unstable-v2-protocol.o wlr-output-power-management-unstable-v1-protocol.o linux-dmabuf-unstable-v1-protocol.o hyprland-toplevel-export-v1-protocol.o
fixwlr: fixwlr:
sed -i -E 's/(soversion = 11)([^032]|$$)/soversion = 11032/g' subprojects/wlroots/meson.build sed -i -E 's/(soversion = 12)([^032]|$$)/soversion = 12032/g' subprojects/wlroots/meson.build
rm -rf ./subprojects/wlroots/build rm -rf ./subprojects/wlroots/build
@@ -159,7 +201,7 @@ config:
make fixwlr make fixwlr
cd subprojects/wlroots && meson ./build --prefix=/usr --buildtype=release cd subprojects/wlroots && meson ./build --prefix=/usr --buildtype=release -Dwerror=false -Dexamples=false
cd subprojects/wlroots && ninja -C build/ cd subprojects/wlroots && ninja -C build/
cd subprojects/wlroots && ninja -C build/ install cd subprojects/wlroots && ninja -C build/ install

View File

@@ -6,7 +6,6 @@
![Badge Workflow] ![Badge Workflow]
[![Badge License]][License] [![Badge License]][License]
![Badge Lines]
![Badge Language] ![Badge Language]
[![Badge Pull Requests]][Pull Requests] [![Badge Pull Requests]][Pull Requests]
[![Badge Issues]][Issues] [![Badge Issues]][Issues]
@@ -40,31 +39,28 @@ Hyprland is still in pretty early development compared to some other Wayland com
Although Hyprland is pretty stable, it may have some bugs. Although Hyprland is pretty stable, it may have some bugs.
### Help Wanted
Hyprland needs testers! <br/>
Try it out and report bugs / suggestions!
# Features # Features
- Easily expandable and readable codebase - Easily expandable and readable codebase
- Config reloaded instantly upon saving - Config reloaded instantly upon saving
- Custom bezier curve based animations - Custom bezier curve based animations
- `wlr_ext` workspaces protocol support
- Dual Kawase blur - Dual Kawase blur
- Drop shadows - Drop shadows
- Rounded corners
- Gradient borders
- Fully dynamic workspaces - Fully dynamic workspaces
- Closely follows `wlroots-git` - Closely follows `wlroots-git`
- Global keybinds passed to your apps of choice - Global keybinds passed to your apps of choice
- A lot of customization
- Bundled wlroots - Bundled wlroots
- Window/layer fade in/out - Window/layer fade in/out
- Tiling/pseudotiling/floating/fullscreen windows - Tiling/pseudotiling/floating/fullscreen windows
- Switching workspaces between window modes on the fly - Switching workspaces between window modes on the fly
- Special workspace (scratchpad) - Special workspaces (scratchpads)
- Window/monitor rules - Window/monitor rules
- Socket-based IPC - Socket-based IPC
- `wlr_ext` workspaces protocol support
- Event system for bash scripts - Event system for bash scripts
- Rounded corners
- Full damage tracking - Full damage tracking
- Docks support - Docks support
- Drawing tablet support - Drawing tablet support
@@ -150,9 +146,9 @@ Try it out and report bugs / suggestions!
<!----------------------------------{ Images }---------------------------------> <!----------------------------------{ Images }--------------------------------->
[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg [Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg
[Preview A]: https://i.imgur.com/sCafdKQ.png [Preview A]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png
[Preview B]: https://i.imgur.com/NbrTnZH.png [Preview B]: https://i.imgur.com/pC6YF1Y.png
[Preview C]: https://i.imgur.com/ZA4Fa8R.png [Preview C]: https://i.imgur.com/NbrTnZH.png
<!----------------------------------{ Badges }---------------------------------> <!----------------------------------{ Badges }--------------------------------->

View File

@@ -1,10 +1,10 @@
.\" Automatically generated by Pandoc 2.5 .\" Automatically generated by Pandoc 2.9.2.1
.\" .\"
.TH "Hyprland" "1" "22 Aug 2022" "" "Hyprland User Manual" .TH "Hyprland" "1" "02 Dec 2022" "" "Hyprland User Manual"
.hy .hy
.SH NAME .SH NAME
.PP .PP
Hyprland \- Dynamic tiling Wayland compositor Hyprland - Dynamic tiling Wayland compositor
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]Hyprland\f[R] [\f[I]arg [...]\f[R]]. \f[B]Hyprland\f[R] [\f[I]arg [...]\f[R]].
@@ -27,14 +27,14 @@ For configuration information please see
<\f[I]https://github.com/hyprwm/Hyprland/wiki\f[R]>. <\f[I]https://github.com/hyprwm/Hyprland/wiki\f[R]>.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B \f[B]\-h\f[R], \f[B]\-\-help\f[R] \f[B]-h\f[R], \f[B]--help\f[R]
Show command usage. Show command usage.
.TP .TP
.B \f[B]\-c\f[R], \f[B]\-\-config\f[R] \f[B]-c\f[R], \f[B]--config\f[R]
Specify config file to use. Specify config file to use.
.SH BUGS .SH BUGS
.TP .TP
.B Submit bug reports and request features online at: Submit bug reports and request features online at:
<\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]> <\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]>
.SH SEE ALSO .SH SEE ALSO
.PP .PP

View File

@@ -57,3 +57,15 @@ coredumpctl info [PID]
``` ```
where `[PID]` is the PID you remembered. where `[PID]` is the PID you remembered.
## Obtaining the debug Hyprland coredump
In very rare cases, the normal coredump would not be enough.
If that's the case, you could try obtaining the debug coredump.
1. [Compile Hyprland with debug mode](http://wiki.hyprland.org/Contributing-and-Debugging/#build-in-debug-mode)
> Note: The config file used will be `hyprlandd.conf` instead of `hyprland.conf`
2. Reproduce the crash in debug mode.
3. `env DEBUGINFOD_URLS="https://debuginfod.archlinux.org/" coredumpctl debug [PID]`(see section above)
4. Wait until the `(gdb)` appears
5. If gdb asks you `press y to continue without paging?` Type `y`
6. `bt -full`
7. copy the output of the command and provide that.

View File

@@ -1,10 +1,10 @@
.\" Automatically generated by Pandoc 2.5 .\" Automatically generated by Pandoc 2.9.2.1
.\" .\"
.TH "hyprctl" "1" "22 Aug 2022" "" "hyprctl User Manual" .TH "hyprctl" "1" "02 Dec 2022" "" "hyprctl User Manual"
.hy .hy
.SH NAME .SH NAME
.PP .PP
hyprctl \- Utility for controlling parts of Hyprland from a CLI or a hyprctl - Utility for controlling parts of Hyprland from a CLI or a
script script
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
@@ -26,7 +26,7 @@ For dispatchers without parameters it can be anything.
.PP .PP
Returns: \f[I]ok\f[R] on success, and an error message on failure. Returns: \f[I]ok\f[R] on success, and an error message on failure.
.TP .TP
.B Examples: Examples:
\f[B]hyprctl\f[R] \f[I]dispatch exec kitty\f[R] \f[B]hyprctl\f[R] \f[I]dispatch exec kitty\f[R]
.RS .RS
.PP .PP
@@ -41,7 +41,7 @@ Set a config keyword dynamically.
.PP .PP
Returns: \f[I]ok\f[R] on success, and an error message on failure. Returns: \f[I]ok\f[R] on success, and an error message on failure.
.TP .TP
.B Examples: Examples:
\f[B]hyprctl\f[R] \f[I]keyword bind SUPER,0,pseudo\f[R] \f[B]hyprctl\f[R] \f[I]keyword bind SUPER,0,pseudo\f[R]
.RS .RS
.PP .PP
@@ -112,13 +112,13 @@ Returns the current random splash.
.RE .RE
.SH OPTIONS .SH OPTIONS
.PP .PP
\f[B]\-\-batch\f[R] \f[B]--batch\f[R]
.RS .RS
.PP .PP
Specify a batch of commands to execute. Specify a batch of commands to execute.
.TP .TP
.B Example: Example:
\f[B]hyprctl\f[R] \f[I]\-\-batch \[dq]keyword general:border_size 2 ; \f[B]hyprctl\f[R] \f[I]--batch \[dq]keyword general:border_size 2 ;
keyword general:gaps_out 20\[dq]\f[R] keyword general:gaps_out 20\[dq]\f[R]
.RS .RS
.PP .PP
@@ -126,14 +126,14 @@ keyword general:gaps_out 20\[dq]\f[R]
.RE .RE
.RE .RE
.PP .PP
\f[B]\-j\f[R] \f[B]-j\f[R]
.RS .RS
.PP .PP
Outputs information in JSON. Outputs information in JSON.
.RE .RE
.SH BUGS .SH BUGS
.TP .TP
.B Submit bug reports and request features online at: Submit bug reports and request features online at:
<\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]> <\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]>
.SH SEE ALSO .SH SEE ALSO
.PP .PP

View File

@@ -1,114 +1,158 @@
# This is an example Hyprland config file. # This is an example Hyprland config file.
# Syntax is the same as in Hypr, but settings might differ.
# #
# Refer to the wiki for more information. # Refer to the wiki for more information.
# #
# Please note not all available settings / options are set here. # Please note not all available settings / options are set here.
# For a full list, see the wiki (basic and advanced configuring) # For a full list, see the wiki
# #
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,1 monitor=,preferred,auto,1
workspace=DP-1,1
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input { input {
kb_file= kb_layout = us
kb_layout= kb_variant =
kb_variant= kb_model =
kb_model= kb_options =
kb_options= kb_rules =
kb_rules=
follow_mouse=1 follow_mouse = 1
touchpad { touchpad {
natural_scroll=no natural_scroll = no
} }
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
} }
general { general {
sensitivity=1.0 # for mouse cursor # See https://wiki.hyprland.org/Configuring/Variables/ for more
main_mod=SUPER
gaps_in=5 gaps_in = 5
gaps_out=20 gaps_out = 20
border_size=2 border_size = 2
col.active_border=0x66ee1111 col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border=0x66333333 col.inactive_border = rgba(595959aa)
apply_sens_to_raw=0 # whether to apply the sensitivity to raw input (e.g. used by games where you aim using your mouse) layout = dwindle
damage_tracking=full # leave it on full unless you hate your GPU and want to make it suffer
} }
decoration { decoration {
rounding=10 # See https://wiki.hyprland.org/Configuring/Variables/ for more
blur=1
blur_size=3 # minimum 1 rounding = 10
blur_passes=1 # minimum 1 blur = yes
blur_new_optimizations=1 blur_size = 3
blur_passes = 1
blur_new_optimizations = on
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
} }
animations { animations {
enabled=1 enabled = yes
animation=windows,1,7,default
animation=border,1,10,default # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
animation=fade,1,10,default
animation=workspaces,1,6,default bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
} }
dwindle { dwindle {
pseudotile=0 # enable pseudotiling on dwindle # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
} }
gestures { gestures {
workspace_swipe=no # See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = off
} }
# example window rules # Example per-device config
# for windows named/classed as abc and xyz # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
#windowrule=move 69 420,abc device:epic mouse V1 {
#windowrule=size 420 69,abc sensitivity = -0.5
#windowrule=tile,xyz }
#windowrule=float,abc
#windowrule=pseudo,abc
#windowrule=monitor 0,xyz
# example binds # Example windowrule v1
bind=SUPER,Q,exec,kitty # windowrule = float, ^(kitty)$
bind=SUPER,C,killactive, # Example windowrule v2
bind=SUPER,M,exit, # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
bind=SUPER,E,exec,dolphin # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
bind=SUPER,V,togglefloating,
bind=SUPER,R,exec,wofi --show drun -o DP-3
bind=SUPER,P,pseudo,
bind=SUPER,left,movefocus,l
bind=SUPER,right,movefocus,r
bind=SUPER,up,movefocus,u
bind=SUPER,down,movefocus,d
bind=SUPER,1,workspace,1 # See https://wiki.hyprland.org/Configuring/Keywords/ for more
bind=SUPER,2,workspace,2 $mainMod = SUPER
bind=SUPER,3,workspace,3
bind=SUPER,4,workspace,4
bind=SUPER,5,workspace,5
bind=SUPER,6,workspace,6
bind=SUPER,7,workspace,7
bind=SUPER,8,workspace,8
bind=SUPER,9,workspace,9
bind=SUPER,0,workspace,10
bind=ALT,1,movetoworkspace,1 # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind=ALT,2,movetoworkspace,2 bind = $mainMod, Q, exec, kitty
bind=ALT,3,movetoworkspace,3 bind = $mainMod, C, killactive,
bind=ALT,4,movetoworkspace,4 bind = $mainMod, M, exit,
bind=ALT,5,movetoworkspace,5 bind = $mainMod, E, exec, dolphin
bind=ALT,6,movetoworkspace,6 bind = $mainMod, V, togglefloating,
bind=ALT,7,movetoworkspace,7 bind = $mainMod, R, exec, wofi --show drun
bind=ALT,8,movetoworkspace,8 bind = $mainMod, P, pseudo, # dwindle
bind=ALT,9,movetoworkspace,9 bind = $mainMod, J, togglesplit, # dwindle
bind=ALT,0,movetoworkspace,10
bind=SUPER,mouse_down,workspace,e+1 # Move focus with mainMod + arrow keys
bind=SUPER,mouse_up,workspace,e-1 bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, workspace, 1
bind = $mainMod, 2, workspace, 2
bind = $mainMod, 3, workspace, 3
bind = $mainMod, 4, workspace, 4
bind = $mainMod, 5, workspace, 5
bind = $mainMod, 6, workspace, 6
bind = $mainMod, 7, workspace, 7
bind = $mainMod, 8, workspace, 8
bind = $mainMod, 9, workspace, 9
bind = $mainMod, 0, workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, movetoworkspace, 1
bind = $mainMod SHIFT, 2, movetoworkspace, 2
bind = $mainMod SHIFT, 3, movetoworkspace, 3
bind = $mainMod SHIFT, 4, movetoworkspace, 4
bind = $mainMod SHIFT, 5, movetoworkspace, 5
bind = $mainMod SHIFT, 6, movetoworkspace, 6
bind = $mainMod SHIFT, 7, movetoworkspace, 7
bind = $mainMod SHIFT, 8, movetoworkspace, 8
bind = $mainMod SHIFT, 9, movetoworkspace, 9
bind = $mainMod SHIFT, 0, movetoworkspace, 10
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

16
example/screenShader.frag Normal file
View File

@@ -0,0 +1,16 @@
//
// Example blue light filter shader.
//
precision mediump float;
varying vec2 v_texcoord;
uniform sampler2D tex;
void main() {
vec4 pixColor = texture2D(tex, v_texcoord);
pixColor[2] *= 0.8;
gl_FragColor = pixColor;
}

69
flake.lock generated
View File

@@ -1,12 +1,44 @@
{ {
"nodes": { "nodes": {
"hyprland-protocols": {
"flake": false,
"locked": {
"lastModified": 1670258048,
"narHash": "sha256-Lm2sXnDVZNE+taHqsqVibvPmSdu65VHvXI507KVX4lg=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "0dcff94fc10df2bbb66d3e1b5a1d6cfd3ada5515",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-protocols",
"type": "github"
}
},
"hyprland-protocols_2": {
"flake": false,
"locked": {
"lastModified": 1670185345,
"narHash": "sha256-hxWGqlPecqEsE6nOHDV29KFBKePbY2Ipeac6lrChMKY=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "4623a404c091e64743ba310199bb380ec52f1936",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-protocols",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1660908602, "lastModified": 1670064435,
"narHash": "sha256-SwZ85IPWvC4NxxFhWhRMTJpApSHbY1u4YK2UFWEBWvY=", "narHash": "sha256-+ELoY30UN+Pl3Yn7RWRPabykwebsVK/kYE9JsIsUMxQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "495b19d5b3e62b4ec7e846bdfb6ef3d9c3b83492", "rev": "61a8a98e6d557e6dd7ed0cdb54c3a3e3bbc5e25c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -18,19 +50,21 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"hyprland-protocols": "hyprland-protocols",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"wlroots": "wlroots" "wlroots": "wlroots",
"xdph": "xdph"
} }
}, },
"wlroots": { "wlroots": {
"flake": false, "flake": false,
"locked": { "locked": {
"host": "gitlab.freedesktop.org", "host": "gitlab.freedesktop.org",
"lastModified": 1660930713, "lastModified": 1669925104,
"narHash": "sha256-bY7q1NqG/sjCUAWPn/Ne9NCigLlPlH5Lk1WCMqv3rTU=", "narHash": "sha256-xMHfW+/G9MieN/5tXHUA5/ztE8dkE093cNFTEUgcwxI=",
"owner": "wlroots", "owner": "wlroots",
"repo": "wlroots", "repo": "wlroots",
"rev": "7c575922c05e4d5fd9a403c2aa631a54c7531d44", "rev": "c8eb24d30e18c165728b8788a10716611c3b633d",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
@@ -39,6 +73,27 @@
"repo": "wlroots", "repo": "wlroots",
"type": "gitlab" "type": "gitlab"
} }
},
"xdph": {
"inputs": {
"hyprland-protocols": "hyprland-protocols_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1670202338,
"narHash": "sha256-StTfshdAoSxO+t0wRbq1I3YESLFIQWFjGJse5ICV8rk=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "af840a9e0947a79a37a95a9f62062653721e43fa",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@@ -7,6 +7,16 @@
url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org"; url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org";
flake = false; flake = false;
}; };
xdph = {
url = "github:hyprwm/xdg-desktop-portal-hyprland";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
flake = false;
};
}; };
outputs = inputs @ { outputs = inputs @ {
@@ -20,24 +30,50 @@
"aarch64-linux" "aarch64-linux"
"x86_64-linux" "x86_64-linux"
]; ];
pkgsFor = nixpkgs.legacyPackages;
pkgsFor = genSystems (system:
import nixpkgs {
inherit system;
overlays = [
(_: prev: {
libdrm = prev.libdrm.overrideAttrs (old: rec {
version = "2.4.114";
src = prev.fetchurl {
url = "https://dri.freedesktop.org/${old.pname}/${old.pname}-${version}.tar.xz";
sha256 = "sha256-MEnPhDpH0S5e7vvDvjSW14L6CfQjRr8Lfe/j0eWY0CY=";
};
});
wayland-protocols = prev.wayland-protocols.overrideAttrs (old: rec {
version = "1.29";
src = prev.fetchurl {
url = "https://gitlab.freedesktop.org/wayland/${old.pname}/-/releases/${version}/downloads/${old.pname}-${version}.tar.xz";
hash = "sha256-4l6at1rHNnBN3v6S6PmshzC+q29WTbYvetaVu6T/ntg=";
};
});
})
];
});
mkDate = longDate: (lib.concatStringsSep "-" [ mkDate = longDate: (lib.concatStringsSep "-" [
(__substring 0 4 longDate) (builtins.substring 0 4 longDate)
(__substring 4 2 longDate) (builtins.substring 4 2 longDate)
(__substring 6 2 longDate) (builtins.substring 6 2 longDate)
]); ]);
in { in {
overlays.default = _: prev: rec { overlays.default = _: prev: rec {
wlroots-hyprland = prev.wlroots.overrideAttrs (__: { wlroots-hyprland = prev.callPackage ./nix/wlroots.nix {
version = mkDate (inputs.wlroots.lastModifiedDate or "19700101"); version = mkDate (inputs.wlroots.lastModifiedDate or "19700101") + "_" + (inputs.wlroots.shortRev or "dirty");
src = inputs.wlroots; src = inputs.wlroots;
}); };
hyprland = prev.callPackage ./nix/default.nix { hyprland = prev.callPackage ./nix/default.nix {
stdenv = prev.gcc12Stdenv; stdenv = prev.gcc12Stdenv;
version = "0.11.0beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); version = "0.18.0beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
wlroots = wlroots-hyprland; wlroots = wlroots-hyprland;
inherit (inputs) hyprland-protocols;
}; };
hyprland-debug = hyprland.override {debug = true;}; hyprland-debug = hyprland.override {debug = true;};
hyprland-no-hidpi = hyprland.override {hidpiXWayland = false;};
waybar-hyprland = prev.waybar.overrideAttrs (oldAttrs: { waybar-hyprland = prev.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"]; mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
}); });
@@ -52,6 +88,12 @@
devShells = genSystems (system: { devShells = genSystems (system: {
default = pkgsFor.${system}.mkShell.override {stdenv = pkgsFor.${system}.gcc12Stdenv;} { default = pkgsFor.${system}.mkShell.override {stdenv = pkgsFor.${system}.gcc12Stdenv;} {
name = "hyprland-shell"; name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [
cmake
];
buildInputs = [
self.packages.${system}.wlroots-hyprland
];
inputsFrom = [ inputsFrom = [
self.packages.${system}.wlroots-hyprland self.packages.${system}.wlroots-hyprland
self.packages.${system}.hyprland self.packages.${system}.hyprland
@@ -61,9 +103,12 @@
formatter = genSystems (system: pkgsFor.${system}.alejandra); formatter = genSystems (system: pkgsFor.${system}.alejandra);
nixosModules.default = import ./nix/module.nix self; nixosModules.default = import ./nix/module.nix inputs;
homeManagerModules.default = import ./nix/hm-module.nix self; homeManagerModules.default = import ./nix/hm-module.nix self;
};
overlay = throw "Hyprland: .overlay output is deprecated, please use the .overlays.default output"; nixConfig = {
extra-substituters = ["https://hyprland.cachix.org"];
extra-trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
}; };
} }

View File

@@ -36,15 +36,24 @@ commands:
reload reload
setcursor setcursor
getoption getoption
cursorpos
switchxkblayout
flags: flags:
-j -> output in JSON -j -> output in JSON
--batch -> execute a batch of commands, separated by ';' --batch -> execute a batch of commands, separated by ';'
)#"; )#";
void request(std::string arg) { void request(std::string arg, int minArgs = 0) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
if (ARGS < minArgs) {
std::cout << "Not enough arguments, expected at least " << minArgs;
return;
}
if (SERVERSOCKET < 0) { if (SERVERSOCKET < 0) {
std::cout << "Couldn't open a socket (1)"; std::cout << "Couldn't open a socket (1)";
return; return;
@@ -80,6 +89,7 @@ void request(std::string arg) {
return; return;
} }
std::string reply = "";
char buffer[8192] = {0}; char buffer[8192] = {0};
sizeWritten = read(SERVERSOCKET, buffer, 8192); sizeWritten = read(SERVERSOCKET, buffer, 8192);
@@ -89,9 +99,20 @@ void request(std::string arg) {
return; return;
} }
reply += std::string(buffer, sizeWritten);
while (sizeWritten == 8192) {
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
std::cout << "Couldn't read (5)";
return;
}
reply += std::string(buffer, sizeWritten);
}
close(SERVERSOCKET); close(SERVERSOCKET);
std::cout << std::string(buffer); std::cout << reply;
} }
void requestHyprpaper(std::string arg) { void requestHyprpaper(std::string arg) {
@@ -145,25 +166,31 @@ void requestHyprpaper(std::string arg) {
std::cout << std::string(buffer); std::cout << std::string(buffer);
} }
void dispatchRequest(int argc, char** argv) { int dispatchRequest(int argc, char** argv) {
if (argc < 4) { if (argc < 4) {
std::cout << "dispatch requires 2 params"; std::cout << "Usage: hyprctl dispatch <dispatcher> <arg>\n\
return; Execute a hyprland keybind dispatcher with the given argument";
return 1;
} }
std::string rq = "/dispatch"; std::string rq = "/dispatch";
for(int i = 2; i < argc; i++) for(int i = 2; i < argc; i++) {
if (!strcmp(argv[i], "--"))
continue;
rq += " " + std::string(argv[i]); rq += " " + std::string(argv[i]);
}
request(rq); request(rq);
return 0;
} }
void keywordRequest(int argc, char** argv) { int keywordRequest(int argc, char** argv) {
if (argc < 4) { if (argc < 4) {
std::cout << "keyword requires 2 params"; std::cout << "Usage: hyprctl keyword <keyword> <arg>\n\
return; Execute a hyprland keyword with the given argument";
return 1;
} }
std::string rq = "/keyword"; std::string rq = "/keyword";
@@ -172,28 +199,48 @@ void keywordRequest(int argc, char** argv) {
rq += " " + std::string(argv[i]); rq += " " + std::string(argv[i]);
request(rq); request(rq);
return 0;
} }
void hyprpaperRequest(int argc, char** argv) { int hyprpaperRequest(int argc, char** argv) {
if (argc < 4) { if (argc < 4) {
std::cout << "hyprpaper requires 2 params"; std::cout << "Usage: hyprctl hyprpaper <command> <arg>\n\
return; Execute a hyprpaper command with the given argument";
return 1;
} }
std::string rq = std::string(argv[2]) + " " + std::string(argv[3]); std::string rq = std::string(argv[2]) + " " + std::string(argv[3]);
requestHyprpaper(rq); requestHyprpaper(rq);
return 0;
} }
void setcursorRequest(int argc, char** argv) { int setcursorRequest(int argc, char** argv) {
if (argc < 4) { if (argc < 4) {
std::cout << "setcursor requires 2 params"; std::cout << "Usage: hyprctl setcursor <theme> <size>\n\
return; Sets the cursor theme for everything except GTK and reloads the cursor";
return 1;
} }
std::string rq = "setcursor " + std::string(argv[2]) + " " + std::string(argv[3]); std::string rq = "setcursor " + std::string(argv[2]) + " " + std::string(argv[3]);
request(rq); request(rq);
return 0;
}
int outputRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "Usage: hyprctl output <mode> <name>\n\
creates / destroys a fake output\n\
with create, name is the backend name to use (available: auto, x11, wayland, headless)\n\
with destroy, name is the output name to destroy";
return 1;
}
std::string rq = "output " + std::string(argv[2]) + " " + std::string(argv[3]);
request(rq);
return 0;
} }
void batchRequest(std::string arg) { void batchRequest(std::string arg) {
@@ -212,11 +259,14 @@ std::deque<std::string> splitArgs(int argc, char** argv) {
} }
bool isNumber(const std::string& str, bool allowfloat) { bool isNumber(const std::string& str, bool allowfloat) {
if (str.empty())
return false;
return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); }); return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); });
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
int bflag = 0, sflag = 0, index, c; int bflag = 0, sflag = 0, index, c;
bool parseArgs = true;
if (argc < 2) { if (argc < 2) {
printf("%s\n", USAGE.c_str()); printf("%s\n", USAGE.c_str());
@@ -228,7 +278,12 @@ int main(int argc, char** argv) {
const auto ARGS = splitArgs(argc, argv); const auto ARGS = splitArgs(argc, argv);
for (auto i = 0; i < ARGS.size(); ++i) { for (auto i = 0; i < ARGS.size(); ++i) {
if (ARGS[i][0] == '-' && !isNumber(ARGS[i], true) /* For stuff like -2 */) { if (ARGS[i] == "--") {
// Stop parsing arguments after --
parseArgs = false;
continue;
}
if (parseArgs && (ARGS[i][0] == '-') && !isNumber(ARGS[i], true) /* For stuff like -2 */) {
// parse // parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) { if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j"; fullArgs += "j";
@@ -254,6 +309,8 @@ int main(int argc, char** argv) {
fullRequest = fullArgs + "/" + fullRequest; fullRequest = fullArgs + "/" + fullRequest;
int exitStatus = 0;
if (fullRequest.contains("/--batch")) batchRequest(fullRequest); if (fullRequest.contains("/--batch")) batchRequest(fullRequest);
else if (fullRequest.contains("/monitors")) request(fullRequest); else if (fullRequest.contains("/monitors")) request(fullRequest);
else if (fullRequest.contains("/clients")) request(fullRequest); else if (fullRequest.contains("/clients")) request(fullRequest);
@@ -266,10 +323,13 @@ int main(int argc, char** argv) {
else if (fullRequest.contains("/devices")) request(fullRequest); else if (fullRequest.contains("/devices")) request(fullRequest);
else if (fullRequest.contains("/reload")) request(fullRequest); else if (fullRequest.contains("/reload")) request(fullRequest);
else if (fullRequest.contains("/getoption")) request(fullRequest); else if (fullRequest.contains("/getoption")) request(fullRequest);
else if (fullRequest.contains("/setcursor")) setcursorRequest(argc, argv); else if (fullRequest.contains("/cursorpos")) request(fullRequest);
else if (fullRequest.contains("/dispatch")) dispatchRequest(argc, argv); else if (fullRequest.contains("/switchxkblayout")) request(fullRequest, 2);
else if (fullRequest.contains("/keyword")) keywordRequest(argc, argv); else if (fullRequest.contains("/output")) exitStatus = outputRequest(argc, argv);
else if (fullRequest.contains("/hyprpaper")) hyprpaperRequest(argc, argv); else if (fullRequest.contains("/setcursor")) exitStatus = setcursorRequest(argc, argv);
else if (fullRequest.contains("/dispatch")) exitStatus = dispatchRequest(argc, argv);
else if (fullRequest.contains("/keyword")) exitStatus = keywordRequest(argc, argv);
else if (fullRequest.contains("/hyprpaper")) exitStatus = hyprpaperRequest(argc, argv);
else if (fullRequest.contains("/--help")) printf("%s", USAGE.c_str()); else if (fullRequest.contains("/--help")) printf("%s", USAGE.c_str());
else { else {
printf("%s\n", USAGE.c_str()); printf("%s\n", USAGE.c_str());
@@ -277,5 +337,5 @@ int main(int argc, char** argv) {
} }
printf("\n"); printf("\n");
return 0; return exitStatus;
} }

View File

@@ -1,5 +1,5 @@
project('Hyprland', 'cpp', 'c', project('Hyprland', 'cpp', 'c',
version : '0.10.0beta', version : '0.18.0beta',
default_options : [ default_options : [
'warning_level=2', 'warning_level=2',
'default_library=static', 'default_library=static',
@@ -20,8 +20,8 @@ endif
GIT_BRANCH = run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD', check: false).stdout().strip() GIT_BRANCH = run_command('git', 'rev-parse', '--abbrev-ref', 'HEAD', check: false).stdout().strip()
GIT_COMMIT_HASH = run_command('git', 'rev-parse', 'HEAD', check: false).stdout().strip() GIT_COMMIT_HASH = run_command('git', 'rev-parse', 'HEAD', check: false).stdout().strip()
GIT_COMMIT_MESSAGE = run_command('bash', '-c', 'git show | head -n 5 | tail -n 1', check: false).stdout().strip() GIT_COMMIT_MESSAGE = run_command('sh', '-c', 'git show | head -n 5 | tail -n 1', check: false).stdout().strip()
GIT_DIRTY = run_command('bash', '-c', 'git diff-index --quiet HEAD -- || echo "dirty"', check: false).stdout().strip() GIT_DIRTY = run_command('sh', '-c', 'git diff-index --quiet HEAD -- || echo "dirty"', check: false).stdout().strip()
add_project_arguments( add_project_arguments(
[ [

View File

@@ -2,10 +2,12 @@
lib, lib,
stdenv, stdenv,
fetchFromGitHub, fetchFromGitHub,
fetchpatch,
pkg-config, pkg-config,
meson, meson,
ninja, ninja,
git, git,
hyprland-protocols,
libdrm, libdrm,
libinput, libinput,
libxcb, libxcb,
@@ -13,6 +15,7 @@
mesa, mesa,
mount, mount,
pango, pango,
pciutils,
wayland, wayland,
wayland-protocols, wayland-protocols,
wayland-scanner, wayland-scanner,
@@ -21,10 +24,17 @@
xwayland, xwayland,
debug ? false, debug ? false,
enableXWayland ? true, enableXWayland ? true,
hidpiXWayland ? true,
legacyRenderer ? false, legacyRenderer ? false,
nvidiaPatches ? false,
version ? "git", version ? "git",
}: }: let
stdenv.mkDerivation { assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) ''
Hyprland: cannot have hidpiXWayland when enableXWayland is false.
'';
in
assert assertXWayland;
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug"; pname = "hyprland" + lib.optionalString debug "-debug";
inherit version; inherit version;
@@ -54,17 +64,16 @@ stdenv.mkDerivation {
git git
libdrm libdrm
libinput libinput
libxcb
libxkbcommon libxkbcommon
mesa mesa
pango pango
wayland wayland
wayland-protocols wayland-protocols
wayland-scanner wayland-scanner
(wlroots.override {inherit enableXWayland;}) pciutils
xcbutilwm (wlroots.override {inherit enableXWayland hidpiXWayland nvidiaPatches;})
] ]
++ lib.optional enableXWayland xwayland; ++ lib.optionals enableXWayland [libxcb xcbutilwm xwayland];
mesonBuildType = mesonBuildType =
if debug if debug
@@ -72,7 +81,7 @@ stdenv.mkDerivation {
else "release"; else "release";
mesonFlags = builtins.concatLists [ mesonFlags = builtins.concatLists [
(lib.optional (!enableXWayland) "-DNO_XWAYLAND=true") (lib.optional (!enableXWayland) "-Dxwayland=disabled")
(lib.optional legacyRenderer "-DLEGACY_RENDERER:STRING=true") (lib.optional legacyRenderer "-DLEGACY_RENDERER:STRING=true")
]; ];
@@ -84,6 +93,10 @@ stdenv.mkDerivation {
# Fix hardcoded paths to /usr installation # Fix hardcoded paths to /usr installation
postPatch = '' postPatch = ''
sed -i "s#/usr#$out#" src/render/OpenGL.cpp sed -i "s#/usr#$out#" src/render/OpenGL.cpp
# for some reason rmdir doesn't work in a dirty tree
rmdir subprojects/hyprland-protocols || true
ln -s ${hyprland-protocols} subprojects/hyprland-protocols
''; '';
passthru.providedSessions = ["hyprland"]; passthru.providedSessions = ["hyprland"];
@@ -95,4 +108,4 @@ stdenv.mkDerivation {
platforms = platforms.linux; platforms = platforms.linux;
mainProgram = "Hyprland"; mainProgram = "Hyprland";
}; };
} }

View File

@@ -6,7 +6,8 @@ self: {
}: let }: let
cfg = config.wayland.windowManager.hyprland; cfg = config.wayland.windowManager.hyprland;
defaultHyprlandPackage = self.packages.${pkgs.system}.default.override { defaultHyprlandPackage = self.packages.${pkgs.system}.default.override {
enableXWayland = cfg.xwayland; enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
}; };
in { in {
options.wayland.windowManager.hyprland = { options.wayland.windowManager.hyprland = {
@@ -41,13 +42,22 @@ in {
</itemizedlist> </itemizedlist>
''; '';
}; };
xwayland = lib.mkOption { xwayland = {
enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Enable xwayland. Enable XWayland.
''; '';
}; };
hidpi = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable HiDPI XWayland.
'';
};
};
extraConfig = lib.mkOption { extraConfig = lib.mkOption {
type = lib.types.lines; type = lib.types.lines;
@@ -56,19 +66,39 @@ in {
Extra configuration lines to add to ~/.config/hypr/hyprland.conf. Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
''; '';
}; };
recommendedEnvironment = lib.mkOption {
type = lib.types.bool;
default = true;
defaultText = lib.literalExpression "true";
example = lib.literalExpression "false";
description = ''
Whether to set the recommended environment variables.
'';
};
imports = [
(
lib.mkRenamedOptionModule
["wayland" "windowManager" "hyprland" "xwayland"]
["wayland" "windowManager" "hyprland" "xwayland" "enable"]
)
];
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = home.packages =
lib.optional (cfg.package != null) cfg.package lib.optional (cfg.package != null) cfg.package
++ lib.optional cfg.xwayland pkgs.xwayland; ++ lib.optional cfg.xwayland.enable pkgs.xwayland;
home.sessionVariables = lib.mkIf cfg.recommendedEnvironment {
NIXOS_OZONE_WL = "1";
};
xdg.configFile."hypr/hyprland.conf" = { xdg.configFile."hypr/hyprland.conf" = {
text = text =
(lib.optionalString cfg.systemdIntegration '' (lib.optionalString cfg.systemdIntegration ''
exec-once=export XDG_SESSION_TYPE=wayland exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP && systemctl --user start hyprland-session.target
exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
exec-once=systemctl --user start hyprland-session.target
'') '')
+ cfg.extraConfig; + cfg.extraConfig;

View File

@@ -1,5 +1,5 @@
# Copied from https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/sway.nix # Copied from https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/sway.nix
self: { inputs: {
config, config,
lib, lib,
pkgs, pkgs,
@@ -8,6 +8,10 @@ self: {
with lib; let with lib; let
cfg = config.programs.hyprland; cfg = config.programs.hyprland;
in { in {
imports = [
(mkRemovedOptionModule ["programs" "hyprland" "extraPackages"] "extraPackages has been removed. Use environment.systemPackages instead.")
];
options.programs.hyprland = { options.programs.hyprland = {
enable = mkEnableOption '' enable = mkEnableOption ''
Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks. Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
@@ -19,7 +23,7 @@ in {
package = mkOption { package = mkOption {
type = types.nullOr types.package; type = types.nullOr types.package;
default = self.packages.${pkgs.system}.default; default = inputs.self.packages.${pkgs.system}.default;
defaultText = literalExpression "<Hyprland flake>.packages.<system>.default"; defaultText = literalExpression "<Hyprland flake>.packages.<system>.default";
example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }"; example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }";
description = '' description = ''
@@ -27,20 +31,46 @@ in {
''; '';
}; };
imports = [ recommendedEnvironment = mkOption {
(mkRemovedOptionModule ["programs" "hyprland" "extraPackages"] "extraPackages has been removed. Use environment.systemPackages instead.") type = types.bool;
]; default = true;
defaultText = literalExpression "true";
example = literalExpression "false";
description = ''
Whether to set the recommended environment variables.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = lib.optional (cfg.package != null) cfg.package; environment = {
security.polkit.enable = true; systemPackages = lib.optional (cfg.package != null) cfg.package;
hardware.opengl.enable = mkDefault true;
sessionVariables = mkIf cfg.recommendedEnvironment {
NIXOS_OZONE_WL = "1";
};
};
fonts.enableDefaultFonts = mkDefault true; fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true; hardware.opengl.enable = mkDefault true;
# enable cachix
nix.settings = {
substituters = ["https://hyprland.cachix.org"];
trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
};
programs = {
dconf.enable = mkDefault true;
xwayland.enable = mkDefault true;
};
security.polkit.enable = true;
services.xserver.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package; services.xserver.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
programs.xwayland.enable = mkDefault true; xdg.portal = {
xdg.portal.enable = mkDefault true; enable = mkDefault true;
xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-wlr]; # xdg-desktop-portal-hyprland
extraPortals = [inputs.xdph.packages.${pkgs.system}.default];
};
}; };
} }

66
nix/wlroots.nix Normal file
View File

@@ -0,0 +1,66 @@
{
version,
src,
#
wlroots,
xwayland,
fetchpatch,
lib,
hwdata,
hidpiXWayland ? true,
enableXWayland ? true,
nvidiaPatches ? false,
}:
assert (lib.assertMsg (hidpiXWayland -> enableXWayland) ''
wlroots-hyprland: cannot have hidpiXWayland when enableXWayland is false.
'');
(wlroots.overrideAttrs
(old: {
inherit version src;
pname =
old.pname
+ "-hyprland"
+ (
if hidpiXWayland
then "-hidpi"
else ""
)
+ (
if nvidiaPatches
then "-nvidia"
else ""
);
patches =
(old.patches or [])
++ (lib.optionals (enableXWayland && hidpiXWayland) [
(fetchpatch {
url = "https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7.diff";
sha256 = "sha256-Eo1pTa/PIiJsRZwIUnHGTIFFIedzODVf0ZeuXb0a3TQ=";
})
(fetchpatch {
url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff";
sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI=";
revert = true;
})
]);
postPatch =
(old.postPatch or "")
+ (
if nvidiaPatches
then ''
substituteInPlace render/gles2/renderer.c --replace "glFlush();" "glFinish();"
''
else ""
);
buildInputs = old.buildInputs ++ [hwdata];
}))
.override {
xwayland = xwayland.overrideAttrs (old: {
patches =
(old.patches or [])
++ (lib.optionals hidpiXWayland [
./xwayland-vsync.patch
./xwayland-hidpi.patch
]);
});
}

498
nix/xwayland-hidpi.patch Normal file
View File

@@ -0,0 +1,498 @@
diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index c4457cc2a61b2103b47f996b51dbbe9eb87bd715..4a33e1f33e73c35c1691564ef4852e7501b02245 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -171,6 +171,8 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
}
wl_surface_attach(xwl_cursor->surface, buffer, 0, 0);
+ wl_surface_set_buffer_scale(xwl_cursor->surface,
+ xwl_seat->xwl_screen->global_output_scale);
xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
xwl_seat->x_cursor->bits->width,
xwl_seat->x_cursor->bits->height);
@@ -190,6 +192,7 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
void
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
{
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_cursor *xwl_cursor = &xwl_seat->cursor;
PixmapPtr pixmap;
CursorPtr cursor;
@@ -220,8 +223,8 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
wl_pointer_set_cursor(xwl_seat->wl_pointer,
xwl_seat->pointer_enter_serial,
xwl_cursor->surface,
- xwl_seat->x_cursor->bits->xhot,
- xwl_seat->x_cursor->bits->yhot);
+ xwl_scale_to(xwl_screen, xwl_seat->x_cursor->bits->xhot),
+ xwl_scale_to(xwl_screen, xwl_seat->x_cursor->bits->yhot));
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
}
@@ -230,6 +233,7 @@ void
xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
{
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
struct xwl_cursor *xwl_cursor = &xwl_tablet_tool->cursor;
PixmapPtr pixmap;
CursorPtr cursor;
@@ -258,9 +262,9 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
xwl_tablet_tool->proximity_in_serial,
xwl_cursor->surface,
- xwl_seat->x_cursor->bits->xhot,
- xwl_seat->x_cursor->bits->yhot);
-
+ xwl_scale_to(xwl_screen, xwl_seat->x_cursor->bits->xhot),
+ xwl_scale_to(xwl_screen, xwl_seat->x_cursor->bits->yhot));
+ wl_surface_set_buffer_scale(xwl_cursor->surface, xwl_screen->global_output_scale);
xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
}
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 26b3630c73b62514fe3ba7824371f79868e953f3..55cd8d466a55db03948abe93ffa03bf129b5e17a 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -412,8 +412,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
DeviceIntPtr dev = get_pointer_device(xwl_seat);
DeviceIntPtr master;
int i;
- int sx = wl_fixed_to_int(sx_w);
- int sy = wl_fixed_to_int(sy_w);
+ int sx = wl_fixed_to_int(sx_w) * xwl_seat->xwl_screen->global_output_scale;
+ int sy = wl_fixed_to_int(sy_w) * xwl_seat->xwl_screen->global_output_scale;
int dx, dy;
ScreenPtr pScreen = xwl_seat->xwl_screen->screen;
ValuatorMask mask;
@@ -592,13 +592,14 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
{
struct xwl_seat *xwl_seat = data;
+ int32_t scale = xwl_seat->xwl_screen->global_output_scale;
if (!xwl_seat->focus_window)
return;
xwl_seat->pending_pointer_event.has_absolute = TRUE;
- xwl_seat->pending_pointer_event.x = sx_w;
- xwl_seat->pending_pointer_event.y = sy_w;
+ xwl_seat->pending_pointer_event.x = sx_w * scale;
+ xwl_seat->pending_pointer_event.y = sy_w * scale;
if (wl_proxy_get_version((struct wl_proxy *) xwl_seat->wl_pointer) < 5)
dispatch_pointer_motion_event(xwl_seat);
@@ -672,7 +673,8 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer,
xorg_list_del(&pending->l);
free(pending);
} else {
- valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor);
+ double scaled_value = wl_fixed_to_double(value);
+ valuator_mask_set_double(&mask, index, scaled_value / divisor);
}
QueuePointerEvents(get_pointer_device(xwl_seat),
@@ -740,12 +742,13 @@ relative_pointer_handle_relative_motion(void *data,
wl_fixed_t dy_unaccelf)
{
struct xwl_seat *xwl_seat = data;
+ int32_t scale = xwl_seat->xwl_screen->global_output_scale;
xwl_seat->pending_pointer_event.has_relative = TRUE;
- xwl_seat->pending_pointer_event.dx = wl_fixed_to_double(dxf);
- xwl_seat->pending_pointer_event.dy = wl_fixed_to_double(dyf);
- xwl_seat->pending_pointer_event.dx_unaccel = wl_fixed_to_double(dx_unaccelf);
- xwl_seat->pending_pointer_event.dy_unaccel = wl_fixed_to_double(dy_unaccelf);
+ xwl_seat->pending_pointer_event.dx = wl_fixed_to_double(dxf) * scale;
+ xwl_seat->pending_pointer_event.dy = wl_fixed_to_double(dyf) * scale;
+ xwl_seat->pending_pointer_event.dx_unaccel = wl_fixed_to_double(dx_unaccelf) * scale;
+ xwl_seat->pending_pointer_event.dy_unaccel = wl_fixed_to_double(dy_unaccelf) * scale;
if (!xwl_seat->focus_window)
return;
@@ -1057,8 +1060,8 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
xwl_touch->window = wl_surface_get_user_data(surface);
xwl_touch->id = id;
- xwl_touch->x = wl_fixed_to_int(sx_w);
- xwl_touch->y = wl_fixed_to_int(sy_w);
+ xwl_touch->x = wl_fixed_to_int(sx_w) * xwl_seat->xwl_screen->global_output_scale;
+ xwl_touch->y = wl_fixed_to_int(sy_w) * xwl_seat->xwl_screen->global_output_scale;
xorg_list_add(&xwl_touch->link_touch, &xwl_seat->touches);
xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchBegin);
@@ -1094,8 +1097,8 @@ touch_handle_motion(void *data, struct wl_touch *wl_touch,
if (!xwl_touch)
return;
- xwl_touch->x = wl_fixed_to_int(sx_w);
- xwl_touch->y = wl_fixed_to_int(sy_w);
+ xwl_touch->x = wl_fixed_to_int(sx_w) * xwl_seat->xwl_screen->global_output_scale;;
+ xwl_touch->y = wl_fixed_to_int(sy_w) * xwl_seat->xwl_screen->global_output_scale;;
xwl_touch_send_event(xwl_touch, xwl_seat, XI_TouchUpdate);
}
@@ -1726,8 +1729,8 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool,
struct xwl_tablet_tool *xwl_tablet_tool = data;
struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
int32_t dx, dy;
- double sx = wl_fixed_to_double(x);
- double sy = wl_fixed_to_double(y);
+ double sx = wl_fixed_to_double(x) * xwl_seat->xwl_screen->global_output_scale;
+ double sy = wl_fixed_to_double(y) * xwl_seat->xwl_screen->global_output_scale;
if (!xwl_seat->tablet_focus_window)
return;
@@ -2714,6 +2717,7 @@ xwl_pointer_warp_emulator_set_fake_pos(struct xwl_pointer_warp_emulator *warp_em
int x,
int y)
{
+ struct xwl_screen *xwl_screen;
struct zwp_locked_pointer_v1 *locked_pointer =
warp_emulator->locked_pointer;
WindowPtr window;
@@ -2725,6 +2729,7 @@ xwl_pointer_warp_emulator_set_fake_pos(struct xwl_pointer_warp_emulator *warp_em
if (!warp_emulator->xwl_seat->focus_window)
return;
+ xwl_screen = warp_emulator->xwl_seat->xwl_screen;
window = warp_emulator->xwl_seat->focus_window->window;
if (x >= window->drawable.x ||
y >= window->drawable.y ||
@@ -2733,8 +2738,8 @@ xwl_pointer_warp_emulator_set_fake_pos(struct xwl_pointer_warp_emulator *warp_em
sx = x - window->drawable.x;
sy = y - window->drawable.y;
zwp_locked_pointer_v1_set_cursor_position_hint(locked_pointer,
- wl_fixed_from_int(sx),
- wl_fixed_from_int(sy));
+ wl_fixed_from_int(xwl_scale_to(xwl_screen, sx)),
+ wl_fixed_from_int(xwl_scale_to(xwl_screen, sy)));
wl_surface_commit(warp_emulator->xwl_seat->focus_window->surface);
}
}
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index ef705bc01bf8c2d2f170cda9ba21ed8293f50559..b8f6cd51bd240ed5e16271eb4749db18868bea7b 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -191,6 +191,9 @@ update_screen_size(struct xwl_output *xwl_output, int width, int height)
{
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
+ width *= xwl_screen->global_output_scale;
+ height *= xwl_screen->global_output_scale;
+
if (xwl_screen->root_clip_mode == ROOT_CLIP_FULL)
SetRootClip(xwl_screen->screen, ROOT_CLIP_NONE);
@@ -497,14 +500,15 @@ xwl_output_set_emulated_mode(struct xwl_output *xwl_output, ClientPtr client,
xwl_output_set_randr_emu_props(xwl_output->xwl_screen, client);
}
-static void
-apply_output_change(struct xwl_output *xwl_output)
+void
+xwl_output_apply_changes(struct xwl_output *xwl_output)
{
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
struct xwl_output *it;
int mode_width, mode_height, count;
int width = 0, height = 0, has_this_output = 0;
RRModePtr *randr_modes;
+ int32_t scale = xwl_screen->global_output_scale;
/* Clear out the "done" received flags */
xwl_output->wl_output_done = FALSE;
@@ -523,10 +527,10 @@ apply_output_change(struct xwl_output *xwl_output)
}
/* Build a fresh modes array using the current refresh rate */
- randr_modes = output_get_rr_modes(xwl_output, mode_width, mode_height, &count);
+ randr_modes = output_get_rr_modes(xwl_output, mode_width * scale, mode_height * scale, &count);
RROutputSetModes(xwl_output->randr_output, randr_modes, count, 1);
RRCrtcNotify(xwl_output->randr_crtc, randr_modes[0],
- xwl_output->x, xwl_output->y,
+ xwl_output->x * scale, xwl_output->y * scale,
xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
/* RROutputSetModes takes ownership of the passed in modes, so we only
* have to free the pointer array.
@@ -567,7 +571,7 @@ output_handle_done(void *data, struct wl_output *wl_output)
*/
if (xwl_output->xdg_output_done || !xwl_output->xdg_output ||
zxdg_output_v1_get_version(xwl_output->xdg_output) >= 3)
- apply_output_change(xwl_output);
+ xwl_output_apply_changes(xwl_output);
}
static void
@@ -610,7 +614,7 @@ xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
xwl_output->xdg_output_done = TRUE;
if (xwl_output->wl_output_done &&
zxdg_output_v1_get_version(xdg_output) < 3)
- apply_output_change(xwl_output);
+ xwl_output_apply_changes(xwl_output);
}
static void
@@ -678,6 +682,8 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
RROutputSetConnection(xwl_output->randr_output, RR_Connected);
RRTellChanged(xwl_screen->screen);
+ xwl_output->scale = 1;
+
/* We want the output to be in the list as soon as created so we can
* use it when binding to the xdg-output protocol...
*/
diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h
index 02b9831083e82a33d85d4404e39d00f06f6c56fd..ec089757f44178dcd7f9c48907f790ce1b2a2729 100644
--- a/hw/xwayland/xwayland-output.h
+++ b/hw/xwayland/xwayland-output.h
@@ -53,7 +53,7 @@ struct xwl_output {
struct wl_output *output;
struct zxdg_output_v1 *xdg_output;
uint32_t server_output_id;
- int32_t x, y, width, height, refresh;
+ int32_t x, y, width, height, refresh, scale;
Rotation rotation;
Bool wl_output_done;
Bool xdg_output_done;
@@ -100,6 +100,8 @@ void xwl_output_set_emulated_mode(struct xwl_output *xwl_output,
void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
WindowPtr window);
+void xwl_output_apply_changes(struct xwl_output *xwl_output);
+
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
#endif /* XWAYLAND_OUTPUT_H */
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index c9cf8c2f569a319034e0789e7587414e50237065..5be0c208ca46b1a53a136885fdc8ab44251fe7ff 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -680,6 +680,8 @@ xwl_present_flip(WindowPtr present_window,
/* We can flip directly to the main surface (full screen window without clips) */
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
+ wl_surface_set_buffer_scale(xwl_window->surface,
+ xwl_window->xwl_screen->global_output_scale);
if (!xwl_window->frame_callback)
xwl_window_create_frame_callback(xwl_window);
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index bb18e5c94fbc7134c801e4e1979e8184079d352e..4ec2de7d123dd36315df07a1e95b1f417925f0f8 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -51,6 +51,7 @@
#include "xwayland-pixmap.h"
#include "xwayland-present.h"
#include "xwayland-shm.h"
+#include "xwayland-window-buffers.h"
#ifdef MITSHM
#include "shmint.h"
@@ -110,6 +111,12 @@ xwl_screen_has_resolution_change_emulation(struct xwl_screen *xwl_screen)
return xwl_screen->rootless && xwl_screen_has_viewport_support(xwl_screen);
}
+int
+xwl_scale_to(struct xwl_screen *xwl_screen, int value)
+{
+ return value / (double)xwl_screen->global_output_scale + 0.5;
+}
+
/* Return the output @ 0x0, falling back to the first output in the list */
struct xwl_output *
xwl_screen_get_first_output(struct xwl_screen *xwl_screen)
@@ -127,6 +134,37 @@ xwl_screen_get_first_output(struct xwl_screen *xwl_screen)
return xorg_list_first_entry(&xwl_screen->output_list, struct xwl_output, link);
}
+static void
+xwl_screen_set_global_scale_from_property(struct xwl_screen *screen,
+ PropertyPtr prop)
+{
+ CARD32 *propdata;
+
+ if (prop->type != XA_CARDINAL || prop->format != 32 || prop->size != 1) {
+ // TODO: handle warnings more cleanly.
+ LogMessageVerb(X_WARNING, 0, "Bad value for property %s.\n",
+ NameForAtom(prop->propertyName));
+ return;
+ }
+
+ propdata = prop->data;
+ xwl_screen_set_global_scale(screen, propdata[0]);
+}
+
+static void
+xwl_screen_update_property(struct xwl_screen *screen,
+ PropertyStateRec *propstate)
+{
+ switch (propstate->state) {
+ case PropertyNewValue:
+ xwl_screen_set_global_scale_from_property(screen, propstate->prop);
+ break;
+ case PropertyDelete:
+ xwl_screen_set_global_scale(screen, 1);
+ break;
+ }
+}
+
static void
xwl_property_callback(CallbackListPtr *pcbl, void *closure,
void *calldata)
@@ -134,19 +172,24 @@ xwl_property_callback(CallbackListPtr *pcbl, void *closure,
ScreenPtr screen = closure;
PropertyStateRec *rec = calldata;
struct xwl_screen *xwl_screen;
- struct xwl_window *xwl_window;
if (rec->win->drawable.pScreen != screen)
return;
- xwl_window = xwl_window_get(rec->win);
- if (!xwl_window)
- return;
-
xwl_screen = xwl_screen_get(screen);
- if (rec->prop->propertyName == xwl_screen->allow_commits_prop)
+ if (rec->prop->propertyName == xwl_screen->allow_commits_prop) {
+ struct xwl_window *xwl_window;
+
+ xwl_window = xwl_window_get(rec->win);
+ if (!xwl_window)
+ return;
+
xwl_window_update_property(xwl_window, rec);
+ }
+ else if (rec->prop->propertyName == xwl_screen->global_output_scale_prop) {
+ xwl_screen_update_property(xwl_screen, rec);
+ }
}
Bool
@@ -521,8 +564,14 @@ void xwl_surface_damage(struct xwl_screen *xwl_screen,
{
if (wl_surface_get_version(surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
wl_surface_damage_buffer(surface, x, y, width, height);
- else
+ else {
+ x = xwl_scale_to(xwl_screen, x);
+ y = xwl_scale_to(xwl_screen, y);
+ width = xwl_scale_to(xwl_screen, width);
+ height = xwl_scale_to(xwl_screen, height);
+
wl_surface_damage(surface, x, y, width, height);
+ }
}
void
@@ -538,10 +587,34 @@ xwl_screen_roundtrip(struct xwl_screen *xwl_screen)
xwl_give_up("could not connect to wayland server\n");
}
+void
+xwl_screen_set_global_scale(struct xwl_screen *xwl_screen, int32_t scale)
+{
+ struct xwl_output *it;
+ struct xwl_window *xwl_window;
+
+ xwl_screen->global_output_scale = scale;
+
+ /* change randr resolutions and positions */
+ xorg_list_for_each_entry(it, &xwl_screen->output_list, link) {
+ xwl_output_apply_changes(it);
+ }
+
+ if (!xwl_screen->rootless && xwl_screen->screen->root) {
+ /* Clear all the buffers, so that they'll be remade with the new sizes
+ * (this doesn't occur automatically because as far as Xorg is
+ * concerned, the window's size is the same) */
+ xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window) {
+ xwl_window_buffers_recycle(xwl_window);
+ }
+ }
+}
+
Bool
xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
{
static const char allow_commits[] = "_XWAYLAND_ALLOW_COMMITS";
+ static const char global_output_scale[] = "_XWAYLAND_GLOBAL_OUTPUT_SCALE";
struct xwl_screen *xwl_screen;
Pixel red_mask, blue_mask, green_mask;
int ret, bpc, green_bpc, i;
@@ -573,6 +646,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
#ifdef XWL_HAS_GLAMOR
xwl_screen->glamor = 1;
#endif
+ xwl_screen->global_output_scale = 1;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-rootless") == 0) {
@@ -743,6 +817,12 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
if (xwl_screen->allow_commits_prop == BAD_RESOURCE)
return FALSE;
+ xwl_screen->global_output_scale_prop = MakeAtom(global_output_scale,
+ strlen(global_output_scale),
+ TRUE);
+ if (xwl_screen->global_output_scale_prop == BAD_RESOURCE)
+ return FALSE;
+
AddCallback(&PropertyStateCallback, xwl_property_callback, pScreen);
xwl_screen_roundtrip(xwl_screen);
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index b965dddd7f964b1d100bbb9d10da1c35ab39810e..7446829d098fbe235e605084a016daff1a8eaea2 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -72,6 +72,8 @@ struct xwl_screen {
struct xorg_list damage_window_list;
struct xorg_list window_list;
+ int32_t global_output_scale;
+
int wayland_fd;
struct wl_display *display;
struct wl_registry *registry;
@@ -107,6 +109,7 @@ struct xwl_screen {
struct glamor_context *glamor_ctx;
Atom allow_commits_prop;
+ Atom global_output_scale_prop;
/* The preferred GLVND vendor. If NULL, "mesa" is assumed. */
const char *glvnd_vendor;
@@ -134,5 +137,7 @@ void xwl_screen_roundtrip (struct xwl_screen *xwl_screen);
void xwl_surface_damage(struct xwl_screen *xwl_screen,
struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
+int xwl_scale_to(struct xwl_screen *xwl_screen, int value);
+void xwl_screen_set_global_scale(struct xwl_screen *xwl_screen, int32_t scale);
#endif /* XWAYLAND_SCREEN_H */
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 00f161eda084e335ac07471a2198176d75d9fcf0..ed3903853f0dab1dad390cd8429639541546157d 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -470,7 +470,8 @@ ensure_surface_for_window(WindowPtr window)
}
wl_region_add(region, 0, 0,
- window->drawable.width, window->drawable.height);
+ xwl_scale_to(xwl_screen, window->drawable.width),
+ xwl_scale_to(xwl_screen, window->drawable.height));
wl_surface_set_opaque_region(xwl_window->surface, region);
wl_region_destroy(region);
}
@@ -820,6 +821,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
#endif
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
+ wl_surface_set_buffer_scale(xwl_window->surface, xwl_screen->global_output_scale);
/* Arbitrary limit to try to avoid flooding the Wayland
* connection. If we flood it too much anyway, this could

12
nix/xwayland-vsync.patch Normal file
View File

@@ -0,0 +1,12 @@
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -824,7 +824,8 @@
dixDestroyPixmap(vblank->pixmap, vblank->pixmap->drawable.id);
vblank->pixmap = NULL;
- if (xwl_present_queue_vblank(screen, window, vblank->crtc,
+ if (vblank->target_msc > crtc_msc &&
+ xwl_present_queue_vblank(screen, window, vblank->crtc,
vblank->event_id, crtc_msc + 1)
== Success)
return;

View File

@@ -3,7 +3,14 @@ wayland_protos = dependency('wayland-protocols',
fallback: 'wayland-protocols', fallback: 'wayland-protocols',
default_options: ['tests=false'], default_options: ['tests=false'],
) )
hyprland_protos = dependency('hyprland-protocols',
version: '>=0.1',
fallback: 'hyprland-protocols',
)
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir') wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
hl_protocol_dir = hyprland_protos.get_variable('pkgdatadir')
wayland_scanner_dep = dependency('wayland-scanner', native: true) wayland_scanner_dep = dependency('wayland-scanner', native: true)
wayland_scanner = find_program( wayland_scanner = find_program(
@@ -13,12 +20,14 @@ wayland_scanner = find_program(
protocols = [ protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'], ['wlr-layer-shell-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'], ['wlr-output-power-management-unstable-v1.xml'],
['ext-workspace-unstable-v1.xml'], ['ext-workspace-unstable-v1.xml'],
['pointer-constraints-unstable-v1.xml'], ['pointer-constraints-unstable-v1.xml'],
['tablet-unstable-v2.xml'], ['tablet-unstable-v2.xml'],
['idle.xml'] ['idle.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml']
] ]
wl_protos_src = [] wl_protos_src = []
wl_protos_headers = [] wl_protos_headers = []

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@
#include "managers/KeybindManager.hpp" #include "managers/KeybindManager.hpp"
#include "managers/AnimationManager.hpp" #include "managers/AnimationManager.hpp"
#include "managers/EventManager.hpp" #include "managers/EventManager.hpp"
#include "managers/ProtocolManager.hpp"
#include "debug/HyprDebugOverlay.hpp" #include "debug/HyprDebugOverlay.hpp"
#include "helpers/Monitor.hpp" #include "helpers/Monitor.hpp"
#include "helpers/Workspace.hpp" #include "helpers/Workspace.hpp"
@@ -38,6 +39,8 @@ public:
wlr_compositor* m_sWLRCompositor; wlr_compositor* m_sWLRCompositor;
wlr_subcompositor* m_sWLRSubCompositor; wlr_subcompositor* m_sWLRSubCompositor;
wlr_data_device_manager* m_sWLRDataDevMgr; wlr_data_device_manager* m_sWLRDataDevMgr;
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_xdg_activation_v1* m_sWLRXDGActivation; wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout; wlr_output_layout* m_sWLROutputLayout;
wlr_idle* m_sWLRIdle; wlr_idle* m_sWLRIdle;
@@ -54,7 +57,6 @@ public:
wlr_egl* m_sWLREGL; wlr_egl* m_sWLREGL;
int m_iDRMFD; int m_iDRMFD;
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr; wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
wlr_linux_dmabuf_v1* m_sWLRDmabuf;
wlr_pointer_constraints_v1* m_sWLRPointerConstraints; wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr; wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
wlr_server_decoration_manager* m_sWLRServerDecoMgr; wlr_server_decoration_manager* m_sWLRServerDecoMgr;
@@ -68,10 +70,13 @@ public:
wlr_output_power_manager_v1* m_sWLROutputPowerMgr; wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
wlr_input_method_manager_v2* m_sWLRIMEMgr; wlr_input_method_manager_v2* m_sWLRIMEMgr;
wlr_text_input_manager_v3* m_sWLRTextInputMgr; wlr_text_input_manager_v3* m_sWLRTextInputMgr;
wlr_xdg_activation_v1* m_sWLRActivation;
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
wlr_backend* m_sWLRHeadlessBackend;
// ------------------------------------------------- // // ------------------------------------------------- //
const char* m_szWLDisplaySocket; std::string m_szWLDisplaySocket = "";
std::string m_szInstanceSignature = ""; std::string m_szInstanceSignature = "";
std::string m_szCurrentSplash = "error"; std::string m_szCurrentSplash = "error";
@@ -98,6 +103,8 @@ public:
bool m_bSessionActive = true; bool m_bSessionActive = true;
bool m_bDPMSStateON = true; bool m_bDPMSStateON = true;
bool m_bUnsafeState = false; // unsafe state is when there is no monitors. bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bIsShuttingDown = false;
std::deque<uint64_t> m_dProcessPIDsOnShutdown; // stores PIDs of apps to kill later when shutting down
// ------------------------------------------------- // // ------------------------------------------------- //
@@ -120,6 +127,7 @@ public:
CMonitor* getMonitorFromOutput(wlr_output*); CMonitor* getMonitorFromOutput(wlr_output*);
CWindow* getWindowForPopup(wlr_xdg_popup*); CWindow* getWindowForPopup(wlr_xdg_popup*);
CWindow* getWindowFromSurface(wlr_surface*); CWindow* getWindowFromSurface(wlr_surface*);
CWindow* getWindowFromHandle(uint32_t);
bool isWorkspaceVisible(const int&); bool isWorkspaceVisible(const int&);
CWorkspace* getWorkspaceByID(const int&); CWorkspace* getWorkspaceByID(const int&);
CWorkspace* getWorkspaceByName(const std::string&); CWorkspace* getWorkspaceByName(const std::string&);
@@ -135,8 +143,8 @@ public:
void cleanupFadingOut(const int& monid); void cleanupFadingOut(const int& monid);
CWindow* getWindowInDirection(CWindow*, char); CWindow* getWindowInDirection(CWindow*, char);
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr); void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
CWindow* getNextWindowOnWorkspace(CWindow*); CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
CWindow* getPrevWindowOnWorkspace(CWindow*); CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
int getNextAvailableNamedWorkspace(); int getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&); bool isPointOnAnyMonitor(const Vector2D&);
CWindow* getConstraintWindow(SMouse*); CWindow* getConstraintWindow(SMouse*);
@@ -145,6 +153,8 @@ public:
void updateWindowAnimatedDecorationValues(CWindow*); void updateWindowAnimatedDecorationValues(CWindow*);
int getNextAvailableMonitorID(); int getNextAvailableMonitorID();
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*); void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int&); bool workspaceIDOutOfBounds(const int&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode); void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void moveUnmanagedX11ToWindows(CWindow*); void moveUnmanagedX11ToWindows(CWindow*);
@@ -159,15 +169,19 @@ public:
void closeWindow(CWindow*); void closeWindow(CWindow*);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&); Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&); void forceReportSizesToWindowsOnWorkspace(const int&);
bool cursorOnReservedArea();
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&);
int getNewSpecialID();
std::string explicitConfigPath; std::string explicitConfigPath;
void startHyprCtlTick();
private: private:
void initAllSignals(); void initAllSignals();
void setRandomSplash(); void setRandomSplash();
uint64_t m_iHyprlandPID = 0;
}; };

View File

@@ -3,12 +3,13 @@
#include "render/decorations/CHyprDropShadowDecoration.hpp" #include "render/decorations/CHyprDropShadowDecoration.hpp"
CWindow::CWindow() { CWindow::CWindow() {
m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*) this, AVARDAMAGE_ENTIRE); m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE); m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_cRealBorderColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER); m_fBorderAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE); m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), (void*)this, AVARDAMAGE_ENTIRE); m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), (void*)this, AVARDAMAGE_ENTIRE);
m_cRealShadowColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), (void*)this, AVARDAMAGE_SHADOW); m_cRealShadowColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), (void*)this, AVARDAMAGE_SHADOW);
m_fDimPercent.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeDim"), (void*)this, AVARDAMAGE_ENTIRE);
m_dWindowDecorations.emplace_back(std::make_unique<CHyprDropShadowDecoration>(this)); // put the shadow so it's the first deco (has to be rendered first) m_dWindowDecorations.emplace_back(std::make_unique<CHyprDropShadowDecoration>(this)); // put the shadow so it's the first deco (has to be rendered first)
} }
@@ -21,9 +22,9 @@ CWindow::~CWindow() {
} }
wlr_box CWindow::getFullWindowBoundingBox() { wlr_box CWindow::getFullWindowBoundingBox() {
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 1, *PBORDERSIZE + 1}, {*PBORDERSIZE + 1, *PBORDERSIZE + 1}}; SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 2, *PBORDERSIZE + 2}, {*PBORDERSIZE + 2, *PBORDERSIZE + 2}};
for (auto& wd : m_dWindowDecorations) { for (auto& wd : m_dWindowDecorations) {
@@ -58,6 +59,13 @@ wlr_box CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
auto POS = m_vPosition; auto POS = m_vPosition;
auto SIZE = m_vSize; auto SIZE = m_vSize;
if (m_bIsFullscreen) {
POS = PMONITOR->vecPosition;
SIZE = PMONITOR->vecSize;
return wlr_box{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y};
}
if (DELTALESSTHAN(POS.y - PMONITOR->vecPosition.y, PMONITOR->vecReservedTopLeft.y, 1)) { if (DELTALESSTHAN(POS.y - PMONITOR->vecPosition.y, PMONITOR->vecReservedTopLeft.y, 1)) {
POS.y = PMONITOR->vecPosition.y; POS.y = PMONITOR->vecPosition.y;
SIZE.y += PMONITOR->vecReservedTopLeft.y; SIZE.y += PMONITOR->vecReservedTopLeft.y;
@@ -96,8 +104,7 @@ void CWindow::updateWindowDecos() {
pid_t CWindow::getPID() { pid_t CWindow::getPID() {
pid_t PID = -1; pid_t PID = -1;
if (!m_bIsX11) { if (!m_bIsX11) {
const auto CLIENT = wl_resource_get_client(m_uSurface.xdg->resource); wl_client_get_credentials(wl_resource_get_client(m_uSurface.xdg->resource), &PID, nullptr, nullptr);
wl_client_get_credentials(CLIENT, &PID, nullptr, nullptr);
} else { } else {
PID = m_uSurface.xwayland->pid; PID = m_uSurface.xwayland->pid;
} }
@@ -211,9 +218,166 @@ void CWindow::moveToWorkspace(int workspaceID) {
if (m_iWorkspaceID != workspaceID) { if (m_iWorkspaceID != workspaceID) {
m_iWorkspaceID = workspaceID; m_iWorkspaceID = workspaceID;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); if (const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); PWORKSPACE) {
if (PWORKSPACE) {
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", this, PWORKSPACE->m_szName.c_str())}); g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", this, PWORKSPACE->m_szName.c_str())});
} }
} }
} }
CWindow* CWindow::X11TransientFor() {
if (!m_bIsX11)
return nullptr;
if (!m_uSurface.xwayland->parent)
return nullptr;
auto PPARENT = g_pCompositor->getWindowFromSurface(m_uSurface.xwayland->parent->surface);
while (g_pCompositor->windowValidMapped(PPARENT) && PPARENT->m_uSurface.xwayland->parent) {
PPARENT = g_pCompositor->getWindowFromSurface(PPARENT->m_uSurface.xwayland->parent->surface);
}
if (!g_pCompositor->windowValidMapped(PPARENT))
return nullptr;
return PPARENT;
}
void CWindow::removeDecorationByType(eDecorationType type) {
for (auto& wd : m_dWindowDecorations) {
if (wd->getDecorationType() == type)
m_vDecosToRemove.push_back(wd.get());
}
updateWindowDecos();
}
void unregisterVar(void* ptr) {
((CAnimatedVariable*)ptr)->unregister();
}
void CWindow::onUnmap() {
if (g_pCompositor->m_pLastWindow == this)
g_pCompositor->m_pLastWindow = nullptr;
m_vRealPosition.setCallbackOnEnd(unregisterVar);
m_vRealSize.setCallbackOnEnd(unregisterVar);
m_fBorderAnimationProgress.setCallbackOnEnd(unregisterVar);
m_fActiveInactiveAlpha.setCallbackOnEnd(unregisterVar);
m_fAlpha.setCallbackOnEnd(unregisterVar);
m_cRealShadowColor.setCallbackOnEnd(unregisterVar);
m_fDimPercent.setCallbackOnEnd(unregisterVar);
m_vRealSize.setCallbackOnBegin(nullptr);
}
void CWindow::onMap() {
// JIC, reset the callbacks. If any are set, we'll make sure they are cleared so we don't accidentally unset them. (In case a window got remapped)
m_vRealPosition.resetAllCallbacks();
m_vRealSize.resetAllCallbacks();
m_fBorderAnimationProgress.resetAllCallbacks();
m_fActiveInactiveAlpha.resetAllCallbacks();
m_fAlpha.resetAllCallbacks();
m_cRealShadowColor.resetAllCallbacks();
m_fDimPercent.resetAllCallbacks();
m_vRealPosition.registerVar();
m_vRealSize.registerVar();
m_fBorderAnimationProgress.registerVar();
m_fActiveInactiveAlpha.registerVar();
m_fAlpha.registerVar();
m_cRealShadowColor.registerVar();
m_fDimPercent.registerVar();
m_vRealSize.setCallbackOnEnd([&] (void* ptr) {
g_pHyprOpenGL->onWindowResizeEnd(this);
}, false);
m_vRealSize.setCallbackOnBegin([&] (void* ptr) {
g_pHyprOpenGL->onWindowResizeStart(this);
}, false);
}
void CWindow::setHidden(bool hidden) {
m_bHidden = hidden;
if (hidden && g_pCompositor->m_pLastWindow == this) {
g_pCompositor->m_pLastWindow = nullptr;
}
}
bool CWindow::isHidden() {
return m_bHidden;
}
void CWindow::applyDynamicRule(const SWindowRule& r) {
if (r.szRule == "noblur") {
m_sAdditionalConfigData.forceNoBlur = true;
} else if (r.szRule == "noborder") {
m_sAdditionalConfigData.forceNoBorder = true;
} else if (r.szRule == "noshadow") {
m_sAdditionalConfigData.forceNoShadow = true;
} else if (r.szRule == "opaque") {
if (!m_sAdditionalConfigData.forceOpaqueOverriden)
m_sAdditionalConfigData.forceOpaque = true;
} else if (r.szRule.find("rounding") == 0) {
try {
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
} catch (std::exception& e) {
Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
} else if (r.szRule.find("opacity") == 0) {
try {
std::string alphaPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
if (alphaPart.contains(' ')) {
// we have a space, 2 values
m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' ')));
m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1));
} else {
m_sSpecialRenderData.alpha = std::stof(alphaPart);
}
} catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
} else if (r.szRule == "noanim") {
m_sAdditionalConfigData.forceNoAnims = true;
} else if (r.szRule.find("animation") == 0) {
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
m_sAdditionalConfigData.animationStyle = STYLE;
} else if (r.szRule.find("bordercolor") == 0) {
try {
std::string colorPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
if (colorPart.contains(' ')) {
// we have a space, 2 values
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart.substr(0, colorPart.find_first_of(' ')));
m_sSpecialRenderData.inactiveBorderColor = configStringToInt(colorPart.substr(colorPart.find_first_of(' ') + 1));
} else {
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart);
}
} catch(std::exception& e) {
Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
}
}
void CWindow::updateDynamicRules() {
m_sSpecialRenderData.activeBorderColor = -1;
m_sSpecialRenderData.inactiveBorderColor = -1;
m_sSpecialRenderData.alpha = 1.f;
m_sSpecialRenderData.alphaInactive = -1.f;
m_sAdditionalConfigData.forceNoBlur = false;
m_sAdditionalConfigData.forceNoBorder = false;
m_sAdditionalConfigData.forceNoShadow = false;
if (!m_sAdditionalConfigData.forceOpaqueOverriden)
m_sAdditionalConfigData.forceOpaque = false;
m_sAdditionalConfigData.forceNoAnims = false;
m_sAdditionalConfigData.animationStyle = "";
m_sAdditionalConfigData.rounding = -1;
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(this);
for (auto& r : WINDOWRULES) {
applyDynamicRule(r);
}
}

View File

@@ -6,14 +6,26 @@
#include "helpers/AnimatedVariable.hpp" #include "helpers/AnimatedVariable.hpp"
#include "render/decorations/IHyprWindowDecoration.hpp" #include "render/decorations/IHyprWindowDecoration.hpp"
#include <deque> #include <deque>
#include "config/ConfigDataValues.hpp"
enum eIdleInhibitMode {
IDLEINHIBIT_NONE = 0,
IDLEINHIBIT_ALWAYS,
IDLEINHIBIT_FULLSCREEN,
IDLEINHIBIT_FOCUS
};
struct SWindowSpecialRenderData { struct SWindowSpecialRenderData {
float alpha = 1.f; float alpha = 1.f;
float alphaInactive = -1.f; // -1 means unset float alphaInactive = -1.f; // -1 means unset
int64_t activeBorderColor = -1; // -1 means unset
int64_t inactiveBorderColor = -1; // -1 means unset
// set by the layout // set by the layout
bool rounding = true; bool rounding = true;
bool border = true; bool border = true;
bool decorate = true;
}; };
struct SWindowAdditionalConfigData { struct SWindowAdditionalConfigData {
@@ -21,6 +33,26 @@ struct SWindowAdditionalConfigData {
int rounding = -1; // -1 means no int rounding = -1; // -1 means no
bool forceNoBlur = false; bool forceNoBlur = false;
bool forceOpaque = false; bool forceOpaque = false;
bool forceOpaqueOverriden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
bool forceAllowsInput = false;
bool forceNoAnims = false;
bool forceNoBorder = false;
bool forceNoShadow = false;
bool windowDanceCompat = false;
bool noMaxSize = false;
};
struct SWindowRule {
std::string szRule;
std::string szValue;
bool v2 = false;
std::string szTitle;
std::string szClass;
int bX11 = -1; // -1 means "ANY"
int bFloating = -1;
int bFullscreen = -1;
int bPinned = -1;
}; };
class CWindow { class CWindow {
@@ -100,13 +132,16 @@ public:
bool m_bNoFocus = false; bool m_bNoFocus = false;
bool m_bNoInitialFocus = false; bool m_bNoInitialFocus = false;
// initial fullscreen // initial fullscreen and fullscreen disabled
bool m_bWantsInitialFullscreen = false; bool m_bWantsInitialFullscreen = false;
bool m_bNoFullscreenRequest = false;
SSurfaceTreeNode* m_pSurfaceTree = nullptr; SSurfaceTreeNode* m_pSurfaceTree = nullptr;
// Animated border // Animated border
CAnimatedVariable m_cRealBorderColor; CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
CAnimatedVariable m_fBorderAnimationProgress;
// Fade in-out // Fade in-out
CAnimatedVariable m_fAlpha; CAnimatedVariable m_fAlpha;
@@ -115,8 +150,11 @@ public:
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
Vector2D m_vOriginalClosedSize; // drawing the closing animations Vector2D m_vOriginalClosedSize; // drawing the closing animations
// For hidden windows and stuff // For pinned (sticky) windows
bool m_bHidden = false; bool m_bPinned = false;
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
CWindow* m_pLastCycledWindow = nullptr;
// Foreign Toplevel proto // Foreign Toplevel proto
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr; wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
@@ -135,10 +173,19 @@ public:
// animated shadow color // animated shadow color
CAnimatedVariable m_cRealShadowColor; CAnimatedVariable m_cRealShadowColor;
// animated tint
CAnimatedVariable m_fDimPercent;
// swallowing
CWindow* m_pSwallowed = nullptr;
// for toplevel monitor events // for toplevel monitor events
uint64_t m_iLastToplevelMonitorID = -1; uint64_t m_iLastToplevelMonitorID = -1;
uint64_t m_iLastSurfaceMonitorID = -1; uint64_t m_iLastSurfaceMonitorID = -1;
// for idle inhibiting windows
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
// For the list lookup // For the list lookup
bool operator==(const CWindow& rhs) { bool operator==(const CWindow& rhs) {
return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize && m_bFadingOut == rhs.m_bFadingOut; return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize && m_bFadingOut == rhs.m_bFadingOut;
@@ -150,9 +197,22 @@ public:
void updateWindowDecos(); void updateWindowDecos();
pid_t getPID(); pid_t getPID();
IHyprWindowDecoration* getDecorationByType(eDecorationType); IHyprWindowDecoration* getDecorationByType(eDecorationType);
void removeDecorationByType(eDecorationType);
void createToplevelHandle(); void createToplevelHandle();
void destroyToplevelHandle(); void destroyToplevelHandle();
void updateToplevel(); void updateToplevel();
void updateSurfaceOutputs(); void updateSurfaceOutputs();
void moveToWorkspace(int); void moveToWorkspace(int);
CWindow* X11TransientFor();
void onUnmap();
void onMap();
void setHidden(bool hidden);
bool isHidden();
void applyDynamicRule(const SWindowRule& r);
void updateDynamicRules();
private:
// For hidden windows and stuff
bool m_bHidden = false;
}; };

View File

@@ -0,0 +1,48 @@
#pragma once
#include "../defines.hpp"
enum eConfigValueDataTypes {
CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0
};
interface ICustomConfigValueData {
public:
virtual ~ICustomConfigValueData() = 0;
virtual eConfigValueDataTypes getDataType() = 0;
};
class CGradientValueData : public ICustomConfigValueData {
public:
CGradientValueData(CColor col) {
m_vColors.push_back(col);
};
virtual ~CGradientValueData() { };
virtual eConfigValueDataTypes getDataType() {
return CVD_TYPE_GRADIENT;
}
void reset(CColor col) {
m_vColors.clear();
m_vColors.emplace_back(col);
m_fAngle = 0;
}
/* Vector containing the colors */
std::vector<CColor> m_vColors;
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;
bool operator==(const CGradientValueData& other) {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false;
for (size_t i = 0; i < m_vColors.size(); ++i)
if (m_vColors[i] != other.m_vColors[i]) return false;
return true;
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@
#include "../Window.hpp" #include "../Window.hpp"
#include "defaultConfig.hpp" #include "defaultConfig.hpp"
#include "ConfigDataValues.hpp"
#define STRVAL_EMPTY "[[EMPTY]]" #define STRVAL_EMPTY "[[EMPTY]]"
@@ -20,9 +21,11 @@
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]} #define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
struct SConfigValue { struct SConfigValue {
int64_t intValue = -1; int64_t intValue = -INT64_MAX;
float floatValue = -1; float floatValue = -__FLT_MAX__;
std::string strValue = ""; std::string strValue = "";
Vector2D vecValue = Vector2D(-__FLT_MAX__, -__FLT_MAX__);
std::shared_ptr<ICustomConfigValueData> data;
bool set = false; // used for device configs bool set = false; // used for device configs
}; };
@@ -36,6 +39,8 @@ struct SMonitorRule {
std::string defaultWorkspace = ""; std::string defaultWorkspace = "";
bool disabled = false; bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
bool enable10bit = false;
}; };
struct SMonitorAdditionalReservedArea { struct SMonitorAdditionalReservedArea {
@@ -45,11 +50,6 @@ struct SMonitorAdditionalReservedArea {
int right = 0; int right = 0;
}; };
struct SWindowRule {
std::string szRule;
std::string szValue;
};
struct SAnimationPropertyConfig { struct SAnimationPropertyConfig {
bool overriden = true; bool overriden = true;
@@ -62,6 +62,59 @@ struct SAnimationPropertyConfig {
SAnimationPropertyConfig* pParentAnimation = nullptr; SAnimationPropertyConfig* pParentAnimation = nullptr;
}; };
struct SExecRequestedRule {
std::string szRule = "";
uint64_t iPid = 0;
};
class CVarList {
public:
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
std::string curitem = "";
std::string argZ = in;
auto nextItem = [&]() {
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator);
if (idx != std::string::npos) {
curitem = argZ.substr(0, idx);
argZ = argZ.substr(idx + 1);
} else {
curitem = argZ;
argZ = STRVAL_EMPTY;
}
};
nextItem();
while (curitem != STRVAL_EMPTY) {
m_vArgs.push_back(removeBeginEndSpacesTabs(curitem));
nextItem();
}
};
~CVarList() = default;
int size() const {
return m_vArgs.size();
}
std::string operator[](const long unsigned int& idx) const {
if (idx >= m_vArgs.size())
return "";
return m_vArgs[idx];
}
// for range-based loops
std::vector<std::string>::iterator begin() { return m_vArgs.begin(); }
std::vector<std::string>::const_iterator begin() const { return m_vArgs.begin(); }
std::vector<std::string>::iterator end() { return m_vArgs.end(); }
std::vector<std::string>::const_iterator end() const { return m_vArgs.end(); }
private:
std::vector<std::string> m_vArgs;
};
class CConfigManager { class CConfigManager {
public: public:
CConfigManager(); CConfigManager();
@@ -85,7 +138,9 @@ public:
SConfigValue* getConfigValuePtr(std::string); SConfigValue* getConfigValuePtr(std::string);
SConfigValue* getConfigValuePtrSafe(std::string); SConfigValue* getConfigValuePtrSafe(std::string);
SMonitorRule getMonitorRuleFor(std::string); SMonitorRule getMonitorRuleFor(std::string, std::string displayName = "");
CMonitor* getBoundMonitorForWS(std::string);
std::vector<SWindowRule> getMatchingRules(CWindow*); std::vector<SWindowRule> getMatchingRules(CWindow*);
@@ -99,6 +154,7 @@ public:
bool m_bForceReload = false; bool m_bForceReload = false;
bool m_bNoMonitorReload = false; bool m_bNoMonitorReload = false;
void ensureDPMS(); void ensureDPMS();
void ensureVRR(CMonitor* pMonitor = nullptr);
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false); std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
@@ -106,6 +162,8 @@ public:
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&); SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
void addExecRule(SExecRequestedRule);
std::string configCurrentPath; std::string configCurrentPath;
private: private:
@@ -123,6 +181,10 @@ private:
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
std::vector<std::pair<std::string, std::string>> boundWorkspaces;
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
bool isFirstLaunch = true; // For exec-once bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules; std::deque<SMonitorRule> m_dMonitorRules;
@@ -151,12 +213,14 @@ private:
void handleBind(const std::string&, const std::string&); void handleBind(const std::string&, const std::string&);
void handleUnbind(const std::string&, const std::string&); void handleUnbind(const std::string&, const std::string&);
void handleWindowRule(const std::string&, const std::string&); void handleWindowRule(const std::string&, const std::string&);
void handleWindowRuleV2(const std::string&, const std::string&);
void handleDefaultWorkspace(const std::string&, const std::string&); void handleDefaultWorkspace(const std::string&, const std::string&);
void handleBezier(const std::string&, const std::string&); void handleBezier(const std::string&, const std::string&);
void handleAnimation(const std::string&, const std::string&); void handleAnimation(const std::string&, const std::string&);
void handleSource(const std::string&, const std::string&); void handleSource(const std::string&, const std::string&);
void handleSubmap(const std::string&, const std::string&); void handleSubmap(const std::string&, const std::string&);
void handleBlurLS(const std::string&, const std::string&); void handleBlurLS(const std::string&, const std::string&);
void handleBindWS(const std::string&, const std::string&);
}; };
inline std::unique_ptr<CConfigManager> g_pConfigManager; inline std::unique_ptr<CConfigManager> g_pConfigManager;

View File

@@ -9,116 +9,160 @@ PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT,
OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS. OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
######################################################################################## ########################################################################################
# #
# Please note not all available settings / options are set here. # Please note not all available settings / options are set here.
# For a full list, see the wiki (basic and advanced configuring) # For a full list, see the wiki
# #
autogenerated=1 # remove this line to get rid of the warning on top. autogenerated = 1 # remove this line to remove the warning
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,1 monitor=,preferred,auto,1
input {
kb_file=
kb_layout=
kb_variant=
kb_model=
kb_options=
kb_rules=
follow_mouse=1 # See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
touchpad { touchpad {
natural_scroll=no natural_scroll = no
} }
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
} }
general { general {
sensitivity=1.0 # for mouse cursor # See https://wiki.hyprland.org/Configuring/Variables/ for more
main_mod=SUPER
gaps_in=5 gaps_in = 5
gaps_out=20 gaps_out = 20
border_size=2 border_size = 2
col.active_border=0x66ee1111 col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border=0x66333333 col.inactive_border = rgba(595959aa)
apply_sens_to_raw=0 # whether to apply the sensitivity to raw input (e.g. used by games where you aim using your mouse) layout = dwindle
damage_tracking=full # leave it on full unless you hate your GPU and want to make it suffer
} }
decoration { decoration {
rounding=10 # See https://wiki.hyprland.org/Configuring/Variables/ for more
blur=1
blur_size=3 # minimum 1 rounding = 10
blur_passes=1 # minimum 1 blur = yes
blur_new_optimizations=1 blur_size = 3
blur_passes = 1
blur_new_optimizations = on
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
} }
animations { animations {
enabled=1 enabled = yes
animation=windows,1,7,default
animation=border,1,10,default # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
animation=fade,1,10,default
animation=workspaces,1,6,default bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
} }
dwindle { dwindle {
pseudotile=0 # enable pseudotiling on dwindle # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
} }
gestures { gestures {
workspace_swipe=no # See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = off
} }
# example window rules # Example per-device config
# for windows named/classed as abc and xyz # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
#windowrule=move 69 420,abc device:epic mouse V1 {
#windowrule=size 420 69,abc sensitivity = -0.5
#windowrule=tile,xyz }
#windowrule=float,abc
#windowrule=pseudo,abc
#windowrule=monitor 0,xyz
# example binds # Example windowrule v1
bind=SUPER,Q,exec,kitty # windowrule = float, ^(kitty)$
bind=SUPER,RETURN,exec,alacritty # Example windowrule v2
bind=SUPER,C,killactive, # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
bind=SUPER,M,exit, # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
bind=SUPER,E,exec,dolphin
bind=SUPER,V,togglefloating,
bind=SUPER,R,exec,wofi --show drun -o DP-3
bind=SUPER,P,pseudo,
bind=SUPER,left,movefocus,l
bind=SUPER,right,movefocus,r
bind=SUPER,up,movefocus,u
bind=SUPER,down,movefocus,d
bind=SUPER,1,workspace,1 # See https://wiki.hyprland.org/Configuring/Keywords/ for more
bind=SUPER,2,workspace,2 $mainMod = SUPER
bind=SUPER,3,workspace,3
bind=SUPER,4,workspace,4
bind=SUPER,5,workspace,5
bind=SUPER,6,workspace,6
bind=SUPER,7,workspace,7
bind=SUPER,8,workspace,8
bind=SUPER,9,workspace,9
bind=SUPER,0,workspace,10
bind=ALT,1,movetoworkspace,1 # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind=ALT,2,movetoworkspace,2 bind = $mainMod, Q, exec, kitty
bind=ALT,3,movetoworkspace,3 bind = $mainMod, C, killactive,
bind=ALT,4,movetoworkspace,4 bind = $mainMod, M, exit,
bind=ALT,5,movetoworkspace,5 bind = $mainMod, E, exec, dolphin
bind=ALT,6,movetoworkspace,6 bind = $mainMod, V, togglefloating,
bind=ALT,7,movetoworkspace,7 bind = $mainMod, R, exec, wofi --show drun
bind=ALT,8,movetoworkspace,8 bind = $mainMod, P, pseudo, # dwindle
bind=ALT,9,movetoworkspace,9 bind = $mainMod, J, togglesplit, # dwindle
bind=ALT,0,movetoworkspace,10
bind=SUPER,mouse_down,workspace,e+1 # Move focus with mainMod + arrow keys
bind=SUPER,mouse_up,workspace,e-1 bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, workspace, 1
bind = $mainMod, 2, workspace, 2
bind = $mainMod, 3, workspace, 3
bind = $mainMod, 4, workspace, 4
bind = $mainMod, 5, workspace, 5
bind = $mainMod, 6, workspace, 6
bind = $mainMod, 7, workspace, 7
bind = $mainMod, 8, workspace, 8
bind = $mainMod, 9, workspace, 9
bind = $mainMod, 0, workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, movetoworkspace, 1
bind = $mainMod SHIFT, 2, movetoworkspace, 2
bind = $mainMod SHIFT, 3, movetoworkspace, 3
bind = $mainMod SHIFT, 4, movetoworkspace, 4
bind = $mainMod SHIFT, 5, movetoworkspace, 5
bind = $mainMod SHIFT, 6, movetoworkspace, 6
bind = $mainMod SHIFT, 7, movetoworkspace, 7
bind = $mainMod SHIFT, 8, movetoworkspace, 8
bind = $mainMod SHIFT, 9, movetoworkspace, 9
bind = $mainMod SHIFT, 0, movetoworkspace, 10
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
)#"; )#";

View File

@@ -23,6 +23,7 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
R"#({ R"#({
"id": %i, "id": %i,
"name": "%s", "name": "%s",
"description": "%s",
"width": %i, "width": %i,
"height": %i, "height": %i,
"refreshRate": %f, "refreshRate": %f,
@@ -35,10 +36,12 @@ R"#({
"reserved": [%i, %i, %i, %i], "reserved": [%i, %i, %i, %i],
"scale": %.2f, "scale": %.2f,
"transform": %i, "transform": %i,
"focused": %s "focused": %s,
"dpmsStatus": %s
},)#", },)#",
m->ID, m->ID,
escapeJSONStrings(m->szName).c_str(), escapeJSONStrings(m->szName).c_str(),
escapeJSONStrings(m->output->description ? m->output->description : "").c_str(),
(int)m->vecPixelSize.x, (int)m->vecPixelSize.y, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y,
m->refreshRate, m->refreshRate,
(int)m->vecPosition.x, (int)m->vecPosition.y, (int)m->vecPosition.x, (int)m->vecPosition.y,
@@ -46,7 +49,8 @@ R"#({
(int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y,
m->scale, m->scale,
(int)m->transform, (int)m->transform,
(m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false") (m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"),
(m->dpmsStatus ? "true" : "false")
); );
} }
@@ -56,109 +60,43 @@ R"#({
result += "]"; result += "]";
} else { } else {
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\tfocused: %s\n\n", result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\tfocused: %s\n\tdpmsStatus: %i\n\n",
m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no")); m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, (m->output->description ? m->output->description : ""), m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus);
} }
} }
return result; return result;
} }
std::string clientsRequest(HyprCtl::eHyprCtlOutputFormat format) { static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat format) {
std::string result = ""; const bool isJson = format == HyprCtl::FORMAT_JSON;
if (format == HyprCtl::FORMAT_JSON) { if (g_pLayoutManager->getCurrentLayout()->getLayoutName() != "dwindle")
result += "["; return isJson ? "" : "0";
for (auto& w : g_pCompositor->m_vWindows) { SLayoutMessageHeader header;
if (w->m_bIsMapped) { header.pWindow = w;
result += getFormat( const auto groupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
R"#({ if (groupMembers.empty())
"address": "0x%x", return isJson ? "" : "0";
"at": [%i, %i],
"size": [%i, %i], const auto comma = isJson ? ", " : ",";
"workspace": { const auto fmt = isJson ? "\"0x%x\"" : "%x";
"id": %i, std::ostringstream result;
"name": "%s"
}, bool first = true;
"floating": %s, for (auto& gw : groupMembers) {
"monitor": %i, if (first)
"class": "%s", first = false;
"title": "%s", else
"pid": %i, result << comma;
"xwayland": %s
},)#", result << getFormat(fmt, gw);
w.get(),
(int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y,
(int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y,
w->m_iWorkspaceID, escapeJSONStrings(w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID))).c_str(),
((int)w->m_bIsFloating == 1 ? "true" : "false"),
w->m_iMonitorID,
escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w.get())).c_str(),
escapeJSONStrings(g_pXWaylandManager->getTitle(w.get())).c_str(),
w->getPID(),
((int)w->m_bIsX11 == 1 ? "true" : "false")
);
}
} }
// remove trailing comma return result.str();
if (result != "[")
result.pop_back();
result += "]";
} else {
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped) {
result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\n",
w.get(), w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), w->getPID(), (int)w->m_bIsX11);
}
}
}
return result;
} }
std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) { static std::string getWindowData(CWindow* w, HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& w : g_pCompositor->m_vWorkspaces) {
result += getFormat(
R"#({
"id": %i,
"name": "%s",
"monitor": "%s",
"windows": %i,
"hasfullscreen": %s
},)#",
w->m_iID,
escapeJSONStrings(w->m_szName).c_str(),
escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(),
g_pCompositor->getWindowsOnWorkspace(w->m_iID),
((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false")
);
}
// remove trailing comma
result.pop_back();
result += "]";
} else {
for (auto& w : g_pCompositor->m_vWorkspaces) {
result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\n",
w->m_iID, w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), (int)w->m_bHasFullscreenWindow);
}
}
return result;
}
std::string activeWindowRequest(HyprCtl::eHyprCtlOutputFormat format) {
const auto PWINDOW = g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW))
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
if (format == HyprCtl::FORMAT_JSON) { if (format == HyprCtl::FORMAT_JSON) {
return getFormat( return getFormat(
R"#({ R"#({
@@ -174,25 +112,117 @@ R"#({
"class": "%s", "class": "%s",
"title": "%s", "title": "%s",
"pid": %i, "pid": %i,
"xwayland": %s "xwayland": %s,
})#", "pinned": %s,
PWINDOW, "fullscreen": %s,
(int)PWINDOW->m_vRealPosition.vec().x, (int)PWINDOW->m_vRealPosition.vec().y, "fullscreenMode": %i,
(int)PWINDOW->m_vRealSize.vec().x, (int)PWINDOW->m_vRealSize.vec().y, "grouped": [%s],
PWINDOW->m_iWorkspaceID, escapeJSONStrings(PWINDOW->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_szName).c_str(), "swallowing": %s
((int)PWINDOW->m_bIsFloating == 1 ? "true" : "false"), },)#",
PWINDOW->m_iMonitorID, w,
escapeJSONStrings(g_pXWaylandManager->getAppIDClass(PWINDOW)).c_str(), (int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y,
escapeJSONStrings(g_pXWaylandManager->getTitle(PWINDOW)).c_str(), (int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y,
PWINDOW->getPID(), w->m_iWorkspaceID, escapeJSONStrings(w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID))).c_str(),
((int)PWINDOW->m_bIsX11 == 1 ? "true" : "false") ((int)w->m_bIsFloating == 1 ? "true" : "false"),
w->m_iMonitorID,
escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)).c_str(),
escapeJSONStrings(g_pXWaylandManager->getTitle(w)).c_str(),
w->getPID(),
((int)w->m_bIsX11 == 1 ? "true" : "false"),
(w->m_bPinned ? "true" : "false"),
(w->m_bIsFullscreen ? "true" : "false"),
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0),
getGroupedData(w, format).c_str(),
(w->m_pSwallowed ? getFormat("\"0x%x\"", w->m_pSwallowed).c_str() : "null")
); );
} else { } else {
return getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\n", return getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\tpinned: %i\n\tfullscreen: %i\n\tfullscreenmode: %i\n\tgrouped: %s\n\tswallowing: %x\n\n",
PWINDOW, PWINDOW->m_szTitle.c_str(), (int)PWINDOW->m_vRealPosition.vec().x, (int)PWINDOW->m_vRealPosition.vec().y, (int)PWINDOW->m_vRealSize.vec().x, (int)PWINDOW->m_vRealSize.vec().y, PWINDOW->m_iWorkspaceID, (PWINDOW->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_szName.c_str()), (int)PWINDOW->m_bIsFloating, (int)PWINDOW->m_iMonitorID, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), g_pXWaylandManager->getTitle(PWINDOW).c_str(), PWINDOW->getPID(), (int)PWINDOW->m_bIsX11); w, w->m_szTitle.c_str(), (int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y, (int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w).c_str(), g_pXWaylandManager->getTitle(w).c_str(), w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (int)w->m_bIsFullscreen, (w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0), getGroupedData(w, format).c_str(), w->m_pSwallowed);
} }
} }
std::string clientsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped) {
result += getWindowData(w.get(), format);
}
}
// remove trailing comma
if (result != "[")
result.pop_back();
result += "]";
} else {
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped) {
result += getWindowData(w.get(), format);
}
}
}
return result;
}
std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& w : g_pCompositor->m_vWorkspaces) {
const auto PLASTW = w->getLastFocusedWindow();
result += getFormat(
R"#({
"id": %i,
"name": "%s",
"monitor": "%s",
"windows": %i,
"hasfullscreen": %s,
"lastwindow": "0x%x",
"lastwindowtitle": "%s"
},)#",
w->m_iID,
escapeJSONStrings(w->m_szName).c_str(),
escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(),
g_pCompositor->getWindowsOnWorkspace(w->m_iID),
((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"),
PLASTW,
PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : ""
);
}
// remove trailing comma
result.pop_back();
result += "]";
} else {
for (auto& w : g_pCompositor->m_vWorkspaces) {
const auto PLASTW = w->getLastFocusedWindow();
result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\tlastwindow: 0x%x\n\tlastwindowtitle: %s\n\n",
w->m_iID, w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), (int)w->m_bHasFullscreenWindow, PLASTW, PLASTW ? PLASTW->m_szTitle.c_str() : "");
}
}
return result;
}
std::string activeWindowRequest(HyprCtl::eHyprCtlOutputFormat format) {
const auto PWINDOW = g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW))
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
auto result = getWindowData(PWINDOW, format);
if (format == HyprCtl::FORMAT_JSON)
result.pop_back();
return result;
}
std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) { std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = ""; std::string result = "";
@@ -287,10 +317,12 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
result += getFormat( result += getFormat(
R"#( { R"#( {
"address": "0x%x", "address": "0x%x",
"name": "%s" "name": "%s",
"defaultSpeed": %f
},)#", },)#",
&m, &m,
escapeJSONStrings(m.mouse->name).c_str() escapeJSONStrings(m.name).c_str(),
wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f
); );
} }
@@ -314,7 +346,7 @@ R"#( {
"main": %s "main": %s
},)#", },)#",
&k, &k,
escapeJSONStrings(k.keyboard->name).c_str(), escapeJSONStrings(k.name).c_str(),
escapeJSONStrings(k.currentRules.rules).c_str(), escapeJSONStrings(k.currentRules.rules).c_str(),
escapeJSONStrings(k.currentRules.model).c_str(), escapeJSONStrings(k.currentRules.model).c_str(),
escapeJSONStrings(k.currentRules.layout).c_str(), escapeJSONStrings(k.currentRules.layout).c_str(),
@@ -343,7 +375,7 @@ R"#( {
},)#", },)#",
&d, &d,
d.pTabletParent, d.pTabletParent,
escapeJSONStrings(d.pTabletParent ? d.pTabletParent->wlrDevice ? d.pTabletParent->wlrDevice->name : "" : "").c_str() escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str()
); );
} }
@@ -354,7 +386,7 @@ R"#( {
"name": "%s" "name": "%s"
},)#", },)#",
&d, &d,
escapeJSONStrings(d.wlrDevice ? d.wlrDevice->name : "").c_str() escapeJSONStrings(d.name).c_str()
); );
} }
@@ -370,6 +402,41 @@ R"#( {
); );
} }
// remove trailing comma
result.pop_back();
result += "\n],\n";
result += "\"touch\": [\n";
for (auto& d : g_pInputManager->m_lTouchDevices) {
result += getFormat(
R"#( {
"address": "0x%x",
"name": "%s"
},)#",
&d,
d.name.c_str()
);
}
// remove trailing comma
if (result[result.size() - 1] == ',')
result.pop_back();
result += "\n],\n";
result += "\"switches\": [\n";
for (auto& d : g_pInputManager->m_lSwitches) {
result += getFormat(
R"#( {
"address": "0x%x",
"name": "%s"
},)#",
&d,
d.pWlrDevice ? d.pWlrDevice->name : ""
);
}
// remove trailing comma // remove trailing comma
if (result[result.size() - 1] == ',') if (result[result.size() - 1] == ',')
result.pop_back(); result.pop_back();
@@ -381,29 +448,41 @@ R"#( {
result += "mice:\n"; result += "mice:\n";
for (auto& m : g_pInputManager->m_lMice) { for (auto& m : g_pInputManager->m_lMice) {
result += getFormat("\tMouse at %x:\n\t\t%s\n", &m, m.mouse->name); result += getFormat("\tMouse at %x:\n\t\t%s\n\t\t\tdefault speed: %f\n", &m, m.name.c_str(), (wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f));
} }
result += "\n\nKeyboards:\n"; result += "\n\nKeyboards:\n";
for (auto& k : g_pInputManager->m_lKeyboards) { for (auto& k : g_pInputManager->m_lKeyboards) {
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k); const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no")); result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.name.c_str(), k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no"));
} }
result += "\n\nTablets:\n"; result += "\n\nTablets:\n";
for (auto& d : g_pInputManager->m_lTabletPads) { for (auto& d : g_pInputManager->m_lTabletPads) {
result += getFormat("\tTablet Pad at %x (belongs to %x -> %s)\n", &d, d.pTabletParent, d.pTabletParent ? d.pTabletParent->wlrDevice ? d.pTabletParent->wlrDevice->name : "" : ""); result += getFormat("\tTablet Pad at %x (belongs to %x -> %s)\n", &d, d.pTabletParent, d.pTabletParent ? d.pTabletParent->name.c_str() : "");
} }
for (auto& d : g_pInputManager->m_lTablets) { for (auto& d : g_pInputManager->m_lTablets) {
result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.wlrDevice ? d.wlrDevice->name : ""); result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.name.c_str());
} }
for (auto& d : g_pInputManager->m_lTabletTools) { for (auto& d : g_pInputManager->m_lTabletTools) {
result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0); result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
} }
result += "\n\nTouch:\n";
for (auto& d : g_pInputManager->m_lTouchDevices) {
result += getFormat("\tTouch Device at %x:\n\t\t%s\n", &d, d.name.c_str());
}
result += "\n\nSwitches:\n";
for (auto& d : g_pInputManager->m_lSwitches) {
result += getFormat("\tSwitch Device at %x:\n\t\t%s\n", &d, d.pWlrDevice ? d.pWlrDevice->name : "");
}
} }
return result; return result;
@@ -433,7 +512,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
R"#({ R"#({
"branch": "%s", "branch": "%s",
"commit": "%s", "commit": "%s",
"dirty": %s "dirty": %s,
"commit_message": "%s", "commit_message": "%s",
"flags": [)#", GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str()); "flags": [)#", GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str());
@@ -495,12 +574,16 @@ std::string dispatchKeyword(std::string in) {
if (COMMAND.contains("input") || COMMAND.contains("device:")) { if (COMMAND.contains("input") || COMMAND.contains("device:")) {
g_pInputManager->setKeyboardLayout(); // update kb layout g_pInputManager->setKeyboardLayout(); // update kb layout
g_pInputManager->setMouseConfigs(); // update mouse cfgs g_pInputManager->setPointerConfigs(); // update mouse cfgs
g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
} }
if (COMMAND.contains("general:layout")) if (COMMAND.contains("general:layout"))
g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout
if (COMMAND.contains("decoration:screen_shader"))
g_pHyprOpenGL->m_bReloadScreenShader = true;
Debug::log(LOG, "Hyprctl: keyword %s : %s", COMMAND.c_str(), VALUE.c_str()); Debug::log(LOG, "Hyprctl: keyword %s : %s", COMMAND.c_str(), VALUE.c_str());
if (retval == "") if (retval == "")
@@ -519,6 +602,8 @@ std::string reloadRequest(std::string request) {
g_pConfigManager->m_bNoMonitorReload = true; g_pConfigManager->m_bNoMonitorReload = true;
} }
g_pConfigManager->tick();
return "ok"; return "ok";
} }
@@ -532,6 +617,23 @@ std::string splashRequest() {
return g_pCompositor->m_szCurrentSplash; return g_pCompositor->m_szCurrentSplash;
} }
std::string cursorPosRequest(HyprCtl::eHyprCtlOutputFormat format) {
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal().floor();
if (format == HyprCtl::FORMAT_NORMAL) {
return getFormat("%i, %i", (int)CURSORPOS.x, (int)CURSORPOS.y);
} else {
return getFormat(R"#(
{
"x": %i,
"y": %i
}
)#", (int)CURSORPOS.x, (int)CURSORPOS.y);
}
return "error";
}
std::string getReply(std::string); std::string getReply(std::string);
std::string dispatchBatch(std::string request) { std::string dispatchBatch(std::string request) {
@@ -616,6 +718,51 @@ std::string dispatchSetCursor(std::string request) {
return "ok"; return "ok";
} }
std::string switchXKBLayoutRequest(std::string request) {
CVarList vars(request, 0, ' ');
const auto KB = vars[1];
const auto CMD = vars[2];
// get kb
const auto PKEYBOARD = std::find_if(g_pInputManager->m_lKeyboards.begin(), g_pInputManager->m_lKeyboards.end(), [&] (const SKeyboard& other) { return other.name == g_pInputManager->deviceNameToInternalString(KB); });
if (PKEYBOARD == g_pInputManager->m_lKeyboards.end())
return "device not found";
const auto PWLRKEYBOARD = wlr_keyboard_from_input_device(PKEYBOARD->keyboard);
const auto LAYOUTS = xkb_keymap_num_layouts(PWLRKEYBOARD->keymap);
xkb_layout_index_t activeLayout = 0;
while (activeLayout < LAYOUTS) {
if (xkb_state_layout_index_is_active(PWLRKEYBOARD->xkb_state, activeLayout, XKB_STATE_LAYOUT_EFFECTIVE))
break;
activeLayout++;
}
if (CMD == "next") {
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, activeLayout > LAYOUTS ? 0 : activeLayout + 1);
} else if (CMD == "prev") {
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, activeLayout == 0 ? LAYOUTS - 1 : activeLayout - 1);
} else {
int requestedLayout = 0;
try {
requestedLayout = std::stoi(CMD);
} catch (std::exception& e) {
return "invalid arg 2";
}
if (requestedLayout < 0 || (uint64_t)requestedLayout > LAYOUTS - 1) {
return "layout idx out of range of " + std::to_string(LAYOUTS);
}
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, requestedLayout);
}
return "ok";
}
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) { std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
std::string curitem = ""; std::string curitem = "";
@@ -642,21 +789,102 @@ std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat
return "no such option"; return "no such option";
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL)
return getFormat("option %s\n\tint: %i\n\tfloat: %f\n\tstr: \"%s\"", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str()); return getFormat("option %s\n\tint: %lld\n\tfloat: %f\n\tstr: \"%s\"\n\tdata: %x", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(), PCFGOPT->data.get());
else { else {
return getFormat( return getFormat(
R"#( R"#(
{ {
"option": "%s", "option": "%s",
"int": %i, "int": %lld,
"float": %f, "float": %f,
"str": "%s" "str": "%s",
"data": "0x%x"
} }
)#", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str() )#", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(), PCFGOPT->data.get()
); );
} }
} }
void createOutputIter(wlr_backend* backend, void* data) {
const auto DATA = (std::pair<std::string, bool>*)data;
if (DATA->second)
return;
if (DATA->first.empty() || DATA->first == "auto") {
if (wlr_backend_is_wl(backend)) {
wlr_wl_output_create(backend);
DATA->second = true;
} else if (wlr_backend_is_x11(backend)) {
wlr_x11_output_create(backend);
DATA->second = true;
} else if (wlr_backend_is_headless(backend)) {
wlr_headless_add_output(backend, 1920, 1080);
DATA->second = true;
}
} else {
if (wlr_backend_is_wl(backend) && DATA->first == "wayland") {
wlr_wl_output_create(backend);
DATA->second = true;
} else if (wlr_backend_is_x11(backend) && DATA->first == "x11") {
wlr_x11_output_create(backend);
DATA->second = true;
} else if (wlr_backend_is_headless(backend) && DATA->first == "headless") {
wlr_headless_add_output(backend, 1920, 1080);
DATA->second = true;
}
}
}
std::string dispatchOutput(std::string request) {
std::string curitem = "";
auto nextItem = [&]() {
auto idx = request.find_first_of(' ');
if (idx != std::string::npos) {
curitem = request.substr(0, idx);
request = request.substr(idx + 1);
} else {
curitem = request;
request = "";
}
curitem = removeBeginEndSpacesTabs(curitem);
};
nextItem();
nextItem();
const auto MODE = curitem;
nextItem();
const auto NAME = curitem;
if (MODE == "create" || MODE == "add") {
std::pair<std::string, bool> result = { NAME, false };
wlr_multi_for_each_backend(g_pCompositor->m_sWLRBackend, createOutputIter, &result);
if (!result.second)
return "no backend replied to the request";
} else if (MODE == "destroy" || MODE == "remove") {
const auto PMONITOR = g_pCompositor->getMonitorFromName(NAME);
if (!PMONITOR)
return "output not found";
if (!PMONITOR->createdByUser)
return "cannot remove a real display. Use the monitor keyword.";
wlr_output_destroy(PMONITOR->output);
}
return "ok";
}
std::string getReply(std::string request) { std::string getReply(std::string request) {
auto format = HyprCtl::FORMAT_NORMAL; auto format = HyprCtl::FORMAT_NORMAL;
@@ -698,6 +926,12 @@ std::string getReply(std::string request) {
return devicesRequest(format); return devicesRequest(format);
else if (request == "splash") else if (request == "splash")
return splashRequest(); return splashRequest();
else if (request == "cursorpos")
return cursorPosRequest(format);
else if (request.find("switchxkblayout") == 0)
return switchXKBLayoutRequest(request);
else if (request.find("output") == 0)
return dispatchOutput(request);
else if (request.find("dispatch") == 0) else if (request.find("dispatch") == 0)
return dispatchRequest(request); return dispatchRequest(request);
else if (request.find("keyword") == 0) else if (request.find("keyword") == 0)
@@ -712,9 +946,21 @@ std::string getReply(std::string request) {
return "unknown request"; return "unknown request";
} }
void HyprCtl::tickHyprCtl() { int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
if (!requestMade) if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP)
return; return 0;
sockaddr_in clientAddress;
socklen_t clientSize = sizeof(clientAddress);
const auto ACCEPTEDCONNECTION = accept(HyprCtl::iSocketFD, (sockaddr*)&clientAddress, &clientSize);
char readBuffer[1024];
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';
std::string request(readBuffer);
std::string reply = ""; std::string reply = "";
@@ -725,44 +971,22 @@ void HyprCtl::tickHyprCtl() {
reply = "Err: " + std::string(e.what()); reply = "Err: " + std::string(e.what());
} }
request = reply; write(ACCEPTEDCONNECTION, reply.c_str(), reply.length());
requestMade = false; close(ACCEPTEDCONNECTION);
requestReady = true;
if (g_pConfigManager->m_bWantsMonitorReload) { if (g_pConfigManager->m_bWantsMonitorReload) {
g_pConfigManager->ensureDPMS(); g_pConfigManager->ensureDPMS();
} }
}
std::string getRequestFromThread(std::string rq) { return 0;
while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
HyprCtl::request = rq;
HyprCtl::requestMade = true;
while (!HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
HyprCtl::requestReady = false;
HyprCtl::requestMade = false;
std::string toReturn = HyprCtl::request;
HyprCtl::request = "";
return toReturn;
} }
void HyprCtl::startHyprCtlSocket() { void HyprCtl::startHyprCtlSocket() {
std::thread([&]() {
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SOCKET < 0) { iSocketFD = socket(AF_UNIX, SOCK_STREAM, 0);
if (iSocketFD < 0) {
Debug::log(ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work."); Debug::log(ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work.");
return; return;
} }
@@ -773,38 +997,12 @@ void HyprCtl::startHyprCtlSocket() {
strcpy(SERVERADDRESS.sun_path, socketPath.c_str()); strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS)); bind(iSocketFD, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
// 10 max queued. // 10 max queued.
listen(SOCKET, 10); listen(iSocketFD, 10);
sockaddr_in clientAddress;
socklen_t clientSize = sizeof(clientAddress);
char readBuffer[1024] = {0};
Debug::log(LOG, "Hypr socket started at %s", socketPath.c_str()); Debug::log(LOG, "Hypr socket started at %s", socketPath.c_str());
while(1) { wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, iSocketFD, WL_EVENT_READABLE, hyprCtlFDTick, nullptr);
const auto ACCEPTEDCONNECTION = accept(SOCKET, (sockaddr*)&clientAddress, &clientSize);
if (ACCEPTEDCONNECTION < 0) {
Debug::log(ERR, "Couldn't listen on the Hyprland Socket. (3) IPC will not work.");
break;
}
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';
std::string request(readBuffer);
std::string reply = getRequestFromThread(request);
write(ACCEPTEDCONNECTION, reply.c_str(), reply.length());
close(ACCEPTEDCONNECTION);
}
close(SOCKET);
}).detach();
} }

View File

@@ -6,7 +6,6 @@
namespace HyprCtl { namespace HyprCtl {
void startHyprCtlSocket(); void startHyprCtlSocket();
void tickHyprCtl();
// very simple thread-safe request method // very simple thread-safe request method
inline bool requestMade = false; inline bool requestMade = false;
@@ -15,6 +14,10 @@ namespace HyprCtl {
inline std::ifstream requestStream; inline std::ifstream requestStream;
inline wl_event_source* hyprCtlTickSource = nullptr;
inline int iSocketFD = -1;
enum eHyprCtlOutputFormat { enum eHyprCtlOutputFormat {
FORMAT_NORMAL = 0, FORMAT_NORMAL = 0,
FORMAT_JSON FORMAT_JSON

View File

@@ -6,10 +6,7 @@
#include <iostream> #include <iostream>
void Debug::init(std::string IS) { void Debug::init(std::string IS) {
if (ISDEBUG) logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
logFile = "/tmp/hypr/" + IS + "/hyprlandd.log";
else
logFile = "/tmp/hypr/" + IS + "/hyprland.log";
} }
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) { void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {

View File

@@ -6,6 +6,8 @@
#include "wlrunstable/wlr_ext_workspace_v1.hpp" #include "wlrunstable/wlr_ext_workspace_v1.hpp"
#include <utility>
#ifndef NDEBUG #ifndef NDEBUG
#ifdef HYPRLAND_DEBUG #ifdef HYPRLAND_DEBUG
#define ISDEBUG true #define ISDEBUG true
@@ -16,10 +18,10 @@
#define ISDEBUG false #define ISDEBUG false
#endif #endif
#define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name }; #define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name }
#define DYNLISTENFUNC(name) void listener_##name(void*, void*); #define DYNLISTENFUNC(name) void listener_##name(void*, void*)
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name; #define DYNLISTENER(name) CHyprWLListener hyprListener_##name
#define DYNMULTILISTENER(name) wl_listener listen_##name; #define DYNMULTILISTENER(name) wl_listener listen_##name
#define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2)) #define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2))
@@ -29,6 +31,8 @@
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \ const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
for (int i = 0; i < rectsNum; ++i) for (int i = 0; i < rectsNum; ++i)
#define PIXMAN_REGION_FOREACH(region) PIXMAN_DAMAGE_FOREACH(region)
#define interface class #define interface class
@@ -74,4 +78,6 @@
#define GIT_DIRTY "?" #define GIT_DIRTY "?"
#endif #endif
#define SPECIAL_WORKSPACE_ID -99 #define SPECIAL_WORKSPACE_START -99
#define PI 3.14159265358979

View File

@@ -72,7 +72,7 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
break; break;
case WLR_INPUT_DEVICE_TOUCH: case WLR_INPUT_DEVICE_TOUCH:
Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name); Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name);
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, DEVICE); g_pInputManager->newTouchDevice(DEVICE);
break; break;
case WLR_INPUT_DEVICE_TABLET_TOOL: case WLR_INPUT_DEVICE_TABLET_TOOL:
Debug::log(LOG, "Attached a tablet tool with name %s", DEVICE->name); Debug::log(LOG, "Attached a tablet tool with name %s", DEVICE->name);
@@ -82,12 +82,16 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
Debug::log(LOG, "Attached a tablet pad with name %s", DEVICE->name); Debug::log(LOG, "Attached a tablet pad with name %s", DEVICE->name);
g_pInputManager->newTabletPad(DEVICE); g_pInputManager->newTabletPad(DEVICE);
break; break;
case WLR_INPUT_DEVICE_SWITCH:
Debug::log(LOG, "Attached a switch device with name %s", DEVICE->name);
g_pInputManager->newSwitch(DEVICE);
break;
default: default:
Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name); Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name);
break; break;
} }
g_pInputManager->updateCapabilities(DEVICE); g_pInputManager->updateCapabilities();
} }
void Events::listener_newConstraint(wl_listener* listener, void* data) { void Events::listener_newConstraint(wl_listener* listener, void* data) {
@@ -207,3 +211,15 @@ void Events::listener_touchEnd(wl_listener* listener, void* data) {
void Events::listener_touchUpdate(wl_listener* listener, void* data) { void Events::listener_touchUpdate(wl_listener* listener, void* data) {
g_pInputManager->onTouchMove((wlr_touch_motion_event*)data); g_pInputManager->onTouchMove((wlr_touch_motion_event*)data);
} }
void Events::listener_touchFrame(wl_listener* listener, void* data) {
wlr_seat_touch_notify_frame(g_pCompositor->m_sSeat.seat);
}
void Events::listener_holdBegin(wl_listener* listener, void* data) {
g_pInputManager->onPointerHoldBegin((wlr_pointer_hold_begin_event*)data);
}
void Events::listener_holdEnd(wl_listener* listener, void* data) {
g_pInputManager->onPointerHoldEnd((wlr_pointer_hold_end_event*)data);
}

View File

@@ -12,6 +12,9 @@ namespace Events {
LISTENER(change); LISTENER(change);
LISTENER(newOutput); LISTENER(newOutput);
// DRM events
LISTENER(leaseRequest);
// Layer events // Layer events
LISTENER(newLayerSurface); LISTENER(newLayerSurface);
DYNLISTENFUNC(destroyLayerSurface); DYNLISTENFUNC(destroyLayerSurface);
@@ -39,6 +42,7 @@ namespace Events {
// Surface XDG (window) // Surface XDG (window)
LISTENER(newXDGSurface); LISTENER(newXDGSurface);
LISTENER(activateXDG);
// Window events // Window events
DYNLISTENFUNC(commitWindow); DYNLISTENFUNC(commitWindow);
@@ -84,7 +88,6 @@ namespace Events {
LISTENER(requestMouse); LISTENER(requestMouse);
LISTENER(requestSetSel); LISTENER(requestSetSel);
LISTENER(requestSetPrimarySel); LISTENER(requestSetPrimarySel);
DYNLISTENFUNC(activate);
// outputMgr // outputMgr
LISTENER(outputMgrApply); LISTENER(outputMgrApply);
@@ -93,6 +96,7 @@ namespace Events {
// Monitor part 2 the sequel // Monitor part 2 the sequel
DYNLISTENFUNC(monitorFrame); DYNLISTENFUNC(monitorFrame);
DYNLISTENFUNC(monitorDestroy); DYNLISTENFUNC(monitorDestroy);
DYNLISTENFUNC(monitorStateRequest);
// XWayland // XWayland
LISTENER(readyXWayland); LISTENER(readyXWayland);
@@ -149,4 +153,8 @@ namespace Events {
LISTENER(touchBegin); LISTENER(touchBegin);
LISTENER(touchEnd); LISTENER(touchEnd);
LISTENER(touchUpdate); LISTENER(touchUpdate);
LISTENER(touchFrame);
LISTENER(holdBegin);
LISTENER(holdEnd);
}; };

View File

@@ -31,15 +31,17 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
WLRLAYERSURFACE->output = PMONITOR->output; WLRLAYERSURFACE->output = PMONITOR->output;
} }
const auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output); auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
if (!WLRLAYERSURFACE->output || !PMONITOR || PMONITOR->pMirrorOf) {
PMONITOR = g_pCompositor->m_vMonitors.front().get();
WLRLAYERSURFACE->output = PMONITOR->output; // TODO: current mon
}
SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].emplace_back(std::make_unique<SLayerSurface>()).get(); SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].emplace_back(std::make_unique<SLayerSurface>()).get();
layerSurface->szNamespace = WLRLAYERSURFACE->_namespace; layerSurface->szNamespace = WLRLAYERSURFACE->_namespace;
if (!WLRLAYERSURFACE->output) {
WLRLAYERSURFACE->output = g_pCompositor->m_vMonitors.front()->output; // TODO: current mon
}
layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface"); layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_destroyLayerSurface.initCallback(&WLRLAYERSURFACE->events.destroy, &Events::listener_destroyLayerSurface, layerSurface, "layerSurface"); layerSurface->hyprListener_destroyLayerSurface.initCallback(&WLRLAYERSURFACE->events.destroy, &Events::listener_destroyLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_mapLayerSurface.initCallback(&WLRLAYERSURFACE->events.map, &Events::listener_mapLayerSurface, layerSurface, "layerSurface"); layerSurface->hyprListener_mapLayerSurface.initCallback(&WLRLAYERSURFACE->events.map, &Events::listener_mapLayerSurface, layerSurface, "layerSurface");
@@ -133,8 +135,9 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
if (layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output); wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
if (layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
g_pCompositor->focusSurface(layersurface->layerSurface->surface); g_pCompositor->focusSurface(layersurface->layerSurface->surface);
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y); const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
@@ -151,6 +154,8 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
layersurface->alpha = 255.f; layersurface->alpha = 255.f;
layersurface->readyToDelete = false; layersurface->readyToDelete = false;
layersurface->fadingOut = false; layersurface->fadingOut = false;
g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")});
} }
void Events::listener_unmapLayerSurface(void* owner, void* data) { void Events::listener_unmapLayerSurface(void* owner, void* data) {
@@ -158,7 +163,9 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
Debug::log(LOG, "LayerSurface %x unmapped", layersurface->layerSurface); Debug::log(LOG, "LayerSurface %x unmapped", layersurface->layerSurface);
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID)) { g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")});
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID) || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring."); Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(layersurface); g_pCompositor->addToFadingOutSafe(layersurface);
@@ -194,9 +201,30 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
// refocus if needed // refocus if needed
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) { if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) {
Vector2D surfaceCoords;
SLayerSurface* pFoundLayerSurface = nullptr;
wlr_surface* foundSurface = nullptr;
g_pCompositor->m_pLastFocus = nullptr; g_pCompositor->m_pLastFocus = nullptr;
// find LS-es to focus
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface);
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
if (!foundSurface) {
// if there isn't any, focus the last window
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
g_pCompositor->focusWindow(nullptr);
g_pCompositor->focusWindow(PLASTWINDOW);
} else {
// otherwise, full refocus
g_pInputManager->refocus(); g_pInputManager->refocus();
} }
}
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height}; wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
g_pHyprRenderer->damageBox(&geomFixed); g_pHyprRenderer->damageBox(&geomFixed);

View File

@@ -25,6 +25,15 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
g_pHyprRenderer->outputMgrApplyTest(CONFIG, true); g_pHyprRenderer->outputMgrApplyTest(CONFIG, true);
} }
void Events::listener_leaseRequest(wl_listener* listener, void* data) {
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
if (!lease) {
Debug::log(ERR, "Failed to grant lease request!");
wlr_drm_lease_request_v1_reject(REQUEST);
}
}
void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) { void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) {
const auto EVENT = (wlr_seat_request_set_primary_selection_event*)data; const auto EVENT = (wlr_seat_request_set_primary_selection_event*)data;
wlr_seat_set_primary_selection(g_pCompositor->m_sSeat.seat, EVENT->source, EVENT->serial); wlr_seat_set_primary_selection(g_pCompositor->m_sSeat.seat, EVENT->source, EVENT->serial);
@@ -36,6 +45,7 @@ void Events::listener_requestSetSel(wl_listener* listener, void* data) {
} }
void Events::listener_readyXWayland(wl_listener* listener, void* data) { void Events::listener_readyXWayland(wl_listener* listener, void* data) {
#ifndef NO_XWAYLAND
const auto XCBCONNECTION = xcb_connect(g_pXWaylandManager->m_sWLRXWayland->display_name, NULL); const auto XCBCONNECTION = xcb_connect(g_pXWaylandManager->m_sWLRXWayland->display_name, NULL);
const auto ERR = xcb_connection_has_error(XCBCONNECTION); const auto ERR = xcb_connection_has_error(XCBCONNECTION);
if (ERR) { if (ERR) {
@@ -63,6 +73,7 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
} }
xcb_disconnect(XCBCONNECTION); xcb_disconnect(XCBCONNECTION);
#endif
} }
void Events::listener_requestDrag(wl_listener* listener, void* data) { void Events::listener_requestDrag(wl_listener* listener, void* data) {
@@ -115,13 +126,18 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
void Events::listener_destroyDrag(void* owner, void* data) { void Events::listener_destroyDrag(void* owner, void* data) {
Debug::log(LOG, "Drag destroyed."); Debug::log(LOG, "Drag destroyed.");
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
if (g_pInputManager->m_sDrag.drag && g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.dragIcon->surface)
g_pHyprRenderer->damageBox(g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4);
g_pInputManager->m_sDrag.drag = nullptr; g_pInputManager->m_sDrag.drag = nullptr;
g_pInputManager->m_sDrag.dragIcon = nullptr; g_pInputManager->m_sDrag.dragIcon = nullptr;
g_pInputManager->m_sDrag.hyprListener_destroy.removeCallback(); g_pInputManager->m_sDrag.hyprListener_destroy.removeCallback();
g_pInputManager->refocus(); g_pInputManager->refocus();
if (g_pInputManager->m_pFollowOnDnDBegin) if (g_pInputManager->m_pFollowOnDnDBegin && *PFOLLOWMOUSE != 1)
g_pCompositor->focusWindow(g_pInputManager->m_pFollowOnDnDBegin); g_pCompositor->focusWindow(g_pInputManager->m_pFollowOnDnDBegin);
g_pInputManager->m_pFollowOnDnDBegin = nullptr; g_pInputManager->m_pFollowOnDnDBegin = nullptr;
@@ -175,6 +191,12 @@ void Events::listener_sessionActive(wl_listener* listener, void* data) {
Debug::log(LOG, "Session got activated!"); Debug::log(LOG, "Session got activated!");
g_pCompositor->m_bSessionActive = true; g_pCompositor->m_bSessionActive = true;
for (auto& m : g_pCompositor->m_vMonitors) {
g_pCompositor->scheduleFrameForMonitor(m.get());
}
g_pConfigManager->m_bWantsMonitorReload = true;
} }
void Events::listener_powerMgrSetMode(wl_listener* listener, void* data) { void Events::listener_powerMgrSetMode(wl_listener* listener, void* data) {

View File

@@ -37,8 +37,6 @@ void Events::listener_change(wl_listener* listener, void* data) {
CONFIGHEAD->state.mode = m->output->current_mode; CONFIGHEAD->state.mode = m->output->current_mode;
CONFIGHEAD->state.x = m->vecPosition.x; CONFIGHEAD->state.x = m->vecPosition.x;
CONFIGHEAD->state.y = m->vecPosition.y; CONFIGHEAD->state.y = m->vecPosition.y;
wlr_output_set_custom_mode(m->output, m->vecPixelSize.x, m->vecPixelSize.y, (int)(round(m->refreshRate * 1000)));
} }
wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG); wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
@@ -90,6 +88,9 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
g_pCompositor->m_bReadyToProcess = true; g_pCompositor->m_bReadyToProcess = true;
g_pCompositor->m_bUnsafeState = false; g_pCompositor->m_bUnsafeState = false;
} }
g_pConfigManager->m_bWantsMonitorReload = true;
g_pCompositor->scheduleFrameForMonitor(PNEWMONITOR);
} }
void Events::listener_monitorFrame(void* owner, void* data) { void Events::listener_monitorFrame(void* owner, void* data) {
@@ -108,9 +109,10 @@ void Events::listener_monitorFrame(void* owner, void* data) {
static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now(); static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now();
static auto *const PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue; static auto *const PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue;
static auto *const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("general:damage_tracking_internal")->intValue; static auto *const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("debug:damage_tracking")->intValue;
static auto *const PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->intValue; static auto *const PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->intValue;
static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue; static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue;
static auto *const PNODIRECTSCANOUT = &g_pConfigManager->getConfigValuePtr("misc:no_direct_scanout")->intValue;
static int damageBlinkCleanup = 0; // because double-buffered static int damageBlinkCleanup = 0; // because double-buffered
@@ -156,6 +158,16 @@ void Events::listener_monitorFrame(void* owner, void* data) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
} }
// Direct scanout first
if (!*PNODIRECTSCANOUT) {
if (g_pHyprRenderer->attemptDirectScanout(PMONITOR)) {
return;
} else if (g_pHyprRenderer->m_pLastScanout) {
Debug::log(LOG, "Left a direct scanout.");
g_pHyprRenderer->m_pLastScanout = nullptr;
}
}
timespec now; timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
@@ -190,18 +202,18 @@ void Events::listener_monitorFrame(void* owner, void* data) {
} }
// if we have no tracking or full tracking, invalidate the entire monitor // if we have no tracking or full tracking, invalidate the entire monitor
if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0 || damageBlinkCleanup > 0) { if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0 || damageBlinkCleanup > 0 || PMONITOR->isMirror() /* why??? */) {
pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x * 10, (int)PMONITOR->vecTransformedSize.y * 10); // wot?
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
} else { } else {
static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
// if we use blur we need to expand the damage for proper blurring // if we use blur we need to expand the damage for proper blurring
if (*PBLURENABLED == 1) { if (*PBLURENABLED == 1) {
// TODO: can this be optimized? // TODO: can this be optimized?
static auto* const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue; static auto *const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue; static auto *const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
const auto BLURRADIUS = *PBLURSIZE * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think. const auto BLURRADIUS = *PBLURSIZE * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think.
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
@@ -224,25 +236,29 @@ void Events::listener_monitorFrame(void* owner, void* data) {
// potentially can save on resources. // potentially can save on resources.
g_pHyprOpenGL->begin(PMONITOR, &damage); g_pHyprOpenGL->begin(PMONITOR, &damage);
if (PMONITOR->isMirror()) {
g_pHyprOpenGL->renderMirrored();
} else {
g_pHyprOpenGL->clear(CColor(17, 17, 17, 255)); g_pHyprOpenGL->clear(CColor(17, 17, 17, 255));
g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper" g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
g_pHyprRenderer->renderAllClientsForMonitor(PMONITOR->ID, &now); g_pHyprRenderer->renderAllClientsForMonitor(PMONITOR->ID, &now);
// if correct monitor draw hyprerror // if correct monitor draw hyprerror
if (PMONITOR->ID == 0) if (PMONITOR == g_pCompositor->m_vMonitors.front().get())
g_pHyprError->draw(); g_pHyprError->draw();
// for drawing the debug overlay // for drawing the debug overlay
if (PMONITOR->ID == 0 && *PDEBUGOVERLAY == 1) { if (PMONITOR == g_pCompositor->m_vMonitors.front().get() && *PDEBUGOVERLAY == 1) {
startRenderOverlay = std::chrono::high_resolution_clock::now(); startRenderOverlay = std::chrono::high_resolution_clock::now();
g_pDebugOverlay->draw(); g_pDebugOverlay->draw();
endRenderOverlay = std::chrono::high_resolution_clock::now(); endRenderOverlay = std::chrono::high_resolution_clock::now();
} }
if (*PDAMAGEBLINK && damageBlinkCleanup == 0) { if (*PDAMAGEBLINK && damageBlinkCleanup == 0) {
wlr_box monrect = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; wlr_box monrect = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y};
g_pHyprOpenGL->renderRect(&monrect, CColor(255,0,255,100), 0); g_pHyprOpenGL->renderRect(&monrect, CColor(255, 0, 255, 100), 0);
damageBlinkCleanup = 1; damageBlinkCleanup = 1;
} else if (*PDAMAGEBLINK) { } else if (*PDAMAGEBLINK) {
damageBlinkCleanup++; damageBlinkCleanup++;
@@ -250,14 +266,16 @@ void Events::listener_monitorFrame(void* owner, void* data) {
damageBlinkCleanup = 0; damageBlinkCleanup = 0;
} }
wlr_renderer_begin(g_pCompositor->m_sWLRRenderer, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); if (wlr_renderer_begin(g_pCompositor->m_sWLRRenderer, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y)) {
wlr_output_render_software_cursors(PMONITOR->output, NULL); wlr_output_render_software_cursors(PMONITOR->output, NULL);
wlr_renderer_end(g_pCompositor->m_sWLRRenderer); wlr_renderer_end(g_pCompositor->m_sWLRRenderer);
}
}
g_pHyprOpenGL->end(); g_pHyprOpenGL->end();
g_pProtocolManager->m_pToplevelExportProtocolManager->onMonitorRender(PMONITOR); // dispatch any toplevel sharing
// calc frame damage // calc frame damage
pixman_region32_t frameDamage; pixman_region32_t frameDamage;
pixman_region32_init(&frameDamage); pixman_region32_init(&frameDamage);
@@ -272,10 +290,15 @@ void Events::listener_monitorFrame(void* owner, void* data) {
pixman_region32_union(&frameDamage, &frameDamage, &damage); pixman_region32_union(&frameDamage, &frameDamage, &damage);
wlr_output_set_damage(PMONITOR->output, &frameDamage); wlr_output_set_damage(PMONITOR->output, &frameDamage);
if (!PMONITOR->mirrors.empty())
g_pHyprRenderer->damageMirrorsWith(PMONITOR, &frameDamage);
pixman_region32_fini(&frameDamage); pixman_region32_fini(&frameDamage);
pixman_region32_fini(&damage); pixman_region32_fini(&damage);
wlr_output_commit(PMONITOR->output); if (!wlr_output_commit(PMONITOR->output))
return;
if (*PDAMAGEBLINK || *PNOVFR) if (*PDAMAGEBLINK || *PNOVFR)
g_pCompositor->scheduleFrameForMonitor(PMONITOR); g_pCompositor->scheduleFrameForMonitor(PMONITOR);
@@ -283,7 +306,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
if (*PDEBUGOVERLAY == 1) { if (*PDEBUGOVERLAY == 1) {
const float µs = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f; const float µs = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f;
g_pDebugOverlay->renderData(PMONITOR, µs); g_pDebugOverlay->renderData(PMONITOR, µs);
if (PMONITOR->ID == 0) { if (PMONITOR == g_pCompositor->m_vMonitors.front().get()) {
const float µsNoOverlay = µs - std::chrono::duration_cast<std::chrono::nanoseconds>(endRenderOverlay - startRenderOverlay).count() / 1000.f; const float µsNoOverlay = µs - std::chrono::duration_cast<std::chrono::nanoseconds>(endRenderOverlay - startRenderOverlay).count() / 1000.f;
g_pDebugOverlay->renderDataNoOverlay(PMONITOR, µsNoOverlay); g_pDebugOverlay->renderDataNoOverlay(PMONITOR, µsNoOverlay);
} else { } else {
@@ -297,8 +320,8 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
CMonitor* pMonitor = nullptr; CMonitor* pMonitor = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vRealMonitors) {
if (m->szName == OUTPUT->name) { if (m->output == OUTPUT) {
pMonitor = m.get(); pMonitor = m.get();
break; break;
} }
@@ -307,11 +330,14 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
if (!pMonitor) if (!pMonitor)
return; return;
Debug::log(LOG, "Destroy called for monitor %s", pMonitor->output->name);
pMonitor->onDisconnect(); pMonitor->onDisconnect();
// cleanup if not unsafe // cleanup if not unsafe
if (!g_pCompositor->m_bUnsafeState) { if (!g_pCompositor->m_bUnsafeState) {
Debug::log(LOG, "Removing monitor %s from realMonitors", pMonitor->output->name);
g_pCompositor->m_vRealMonitors.erase(std::remove_if(g_pCompositor->m_vRealMonitors.begin(), g_pCompositor->m_vRealMonitors.end(), [&](std::shared_ptr<CMonitor>& el) { return el.get() == pMonitor; })); g_pCompositor->m_vRealMonitors.erase(std::remove_if(g_pCompositor->m_vRealMonitors.begin(), g_pCompositor->m_vRealMonitors.end(), [&](std::shared_ptr<CMonitor>& el) { return el.get() == pMonitor; }));
if (pMostHzMonitor == pMonitor) { if (pMostHzMonitor == pMonitor) {
@@ -329,3 +355,10 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
} }
} }
} }
void Events::listener_monitorStateRequest(void* owner, void* data) {
const auto PMONITOR = (CMonitor*)owner;
const auto E = (wlr_output_event_request_state*)data;
wlr_output_commit_state(PMONITOR->output, E->state);
}

View File

@@ -18,18 +18,22 @@
void addPopupGlobalCoords(void* pPopup, int* x, int* y) { void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup; SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
auto curPopup = PPOPUP;
int px = 0; int px = 0;
int py = 0; int py = 0;
auto curPopup = PPOPUP;
while (true) { while (true) {
px += curPopup->popup->current.geometry.x; px += curPopup->popup->current.geometry.x;
py += curPopup->popup->current.geometry.y; py += curPopup->popup->current.geometry.y;
// fix oversized fucking popups if (curPopup == PPOPUP && PPOPUP->parentWindow) {
// kill me px -= curPopup->popup->base->current.geometry.x;
if (curPopup->pSurfaceTree && curPopup->pSurfaceTree->pSurface && !curPopup->parentPopup) { py -= curPopup->popup->base->current.geometry.y;
const auto EXTENTSSURFACE = pixman_region32_extents(&curPopup->pSurfaceTree->pSurface->input_region); }
if (curPopup->popup && !curPopup->parentPopup && !curPopup->parentWindow) {
const auto EXTENTSSURFACE = pixman_region32_extents(&curPopup->popup->base->surface->input_region);
px -= EXTENTSSURFACE->x1; px -= EXTENTSSURFACE->x1;
py -= EXTENTSSURFACE->y1; py -= EXTENTSSURFACE->y1;
} }

View File

@@ -48,12 +48,15 @@ void Events::listener_mapWindow(void* owner, void* data) {
static auto *const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue; static auto *const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
static auto *const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue; static auto *const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
static auto *const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
static auto *const PSWALLOW = &g_pConfigManager->getConfigValuePtr("misc:enable_swallow")->intValue;
static auto *const PSWALLOWREGEX = &g_pConfigManager->getConfigValuePtr("misc:swallow_regex")->strValue;
const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); auto PMONITOR = g_pCompositor->m_pLastMonitor;
const auto PWORKSPACE = PMONITOR->specialWorkspaceOpen ? g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
PWINDOW->m_bMappedX11 = true; PWINDOW->m_bMappedX11 = true;
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceOpen ? SPECIAL_WORKSPACE_ID : PMONITOR->activeWorkspace; PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
PWINDOW->m_bIsMapped = true; PWINDOW->m_bIsMapped = true;
PWINDOW->m_bReadyToDelete = false; PWINDOW->m_bReadyToDelete = false;
PWINDOW->m_bFadingOut = false; PWINDOW->m_bFadingOut = false;
@@ -62,8 +65,6 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (PWINDOW->m_iX11Type == 2) if (PWINDOW->m_iX11Type == 2)
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW); g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
// Set all windows tiled regardless of anything // Set all windows tiled regardless of anything
g_pXWaylandManager->setWindowStyleTiled(PWINDOW, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM); g_pXWaylandManager->setWindowStyleTiled(PWINDOW, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
@@ -73,6 +74,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
// checks if the window wants borders and sets the appriopriate flag // checks if the window wants borders and sets the appriopriate flag
g_pXWaylandManager->checkBorders(PWINDOW); g_pXWaylandManager->checkBorders(PWINDOW);
// registers the animated vars and stuff
PWINDOW->onMap();
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW); const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW);
if (!PWINDOWSURFACE) { if (!PWINDOWSURFACE) {
@@ -97,17 +101,21 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height); PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
} }
CWindow* pFullscreenWindow = nullptr;
if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) { if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PFULLWINDOW, FULLSCREEN_FULL, false); pFullscreenWindow = PFULLWINDOW;
g_pXWaylandManager->setWindowFullscreen(PFULLWINDOW, PFULLWINDOW->m_bIsFullscreen); g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
} }
// window rules // window rules
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW); const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
std::string requestedWorkspace = ""; std::string requestedWorkspace = "";
bool workspaceSilent = false; bool workspaceSilent = false;
bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen || (!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && PWINDOW->m_uSurface.xdg->toplevel->requested.fullscreen); bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen || (!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && PWINDOW->m_uSurface.xdg->toplevel->requested.fullscreen) || (PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xwayland->fullscreen);
bool shouldFocus = true;
bool workspaceSpecial = false;
for (auto& r : WINDOWRULES) { for (auto& r : WINDOWRULES) {
if (r.szRule.find("monitor") == 0) { if (r.szRule.find("monitor") == 0) {
@@ -125,7 +133,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace; PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
if (PWINDOW->m_iMonitorID != PMONITOR->ID) {
g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID)); g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID));
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
}
Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID); Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);
} catch (std::exception& e) { } catch (std::exception& e) {
@@ -141,6 +152,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
requestedWorkspace = WORKSPACERQ; requestedWorkspace = WORKSPACERQ;
} }
if (requestedWorkspace == PWORKSPACE->m_szName || requestedWorkspace == "name:" + PWORKSPACE->m_szName)
requestedWorkspace = "";
Debug::log(LOG, "Rule workspace matched by window %x, %s applied.", PWINDOW, r.szValue.c_str()); Debug::log(LOG, "Rule workspace matched by window %x, %s applied.", PWINDOW, r.szValue.c_str());
} else if (r.szRule.find("float") == 0) { } else if (r.szRule.find("float") == 0) {
PWINDOW->m_bIsFloating = true; PWINDOW->m_bIsFloating = true;
@@ -150,37 +164,39 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bIsPseudotiled = true; PWINDOW->m_bIsPseudotiled = true;
} else if (r.szRule.find("nofocus") == 0) { } else if (r.szRule.find("nofocus") == 0) {
PWINDOW->m_bNoFocus = true; PWINDOW->m_bNoFocus = true;
} else if (r.szRule == "noblur") { } else if (r.szRule.find("nofullscreenrequest") == 0) {
PWINDOW->m_sAdditionalConfigData.forceNoBlur = true; PWINDOW->m_bNoFullscreenRequest = true;
} else if (r.szRule == "fullscreen") { } else if (r.szRule == "fullscreen") {
requestsFullscreen = true; requestsFullscreen = true;
} else if (r.szRule == "opaque") { } else if (r.szRule == "windowdance") {
PWINDOW->m_sAdditionalConfigData.forceOpaque = true; PWINDOW->m_sAdditionalConfigData.windowDanceCompat = true;
} else if (r.szRule.find("rounding") == 0) { } else if (r.szRule == "nomaxsize") {
try { PWINDOW->m_sAdditionalConfigData.noMaxSize = true;
PWINDOW->m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1)); } else if (r.szRule == "forceinput") {
} catch (std::exception& e) { PWINDOW->m_sAdditionalConfigData.forceAllowsInput = true;
Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); } else if (r.szRule == "pin") {
} PWINDOW->m_bPinned = true;
} else if (r.szRule.find("opacity") == 0) { } else if (r.szRule.find("idleinhibit") == 0) {
try { auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
std::string alphaPart = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
if (alphaPart.contains(' ')) { if (IDLERULE == "none") {
// we have a comma, 2 values PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_NONE;
PWINDOW->m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' '))); } else if (IDLERULE == "always") {
PWINDOW->m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1)); PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_ALWAYS;
} else if (IDLERULE == "focus") {
PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_FOCUS;
} else if (IDLERULE == "fullscreen") {
PWINDOW->m_eIdleInhibitMode = IDLEINHIBIT_FULLSCREEN;
} else { } else {
PWINDOW->m_sSpecialRenderData.alpha = std::stof(alphaPart); Debug::log(ERR, "Rule idleinhibit: unknown mode %s", IDLERULE.c_str());
}
} catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
} else if (r.szRule.find("animation") == 0) {
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
PWINDOW->m_sAdditionalConfigData.animationStyle = STYLE;
} }
} }
PWINDOW->applyDynamicRule(r);
}
// disallow tiled pinned
if (PWINDOW->m_bPinned && !PWINDOW->m_bIsFloating)
PWINDOW->m_bPinned = false;
if (requestedWorkspace != "") { if (requestedWorkspace != "") {
// process requested workspace // process requested workspace
@@ -188,13 +204,17 @@ void Events::listener_mapWindow(void* owner, void* data) {
// check for silent // check for silent
if (requestedWorkspace.contains("silent")) { if (requestedWorkspace.contains("silent")) {
workspaceSilent = true; workspaceSilent = true;
} shouldFocus = false;
requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' ')); requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
if (requestedWorkspace == "special") {
workspaceSilent = true;
} }
if (!shouldFocus && requestedWorkspace == std::to_string(PMONITOR->activeWorkspace))
shouldFocus = true;
}
if (requestedWorkspace.find("special" == 0)) {
workspaceSpecial = true;
} }
if (!workspaceSilent) { if (!workspaceSilent) {
@@ -202,6 +222,46 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID; PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
PMONITOR = g_pCompositor->m_pLastMonitor;
}
}
if (workspaceSilent) {
// get the workspace
auto PWORKSPACE = g_pCompositor->getWorkspaceByString(requestedWorkspace);
if (!PWORKSPACE) {
std::string workspaceName = "";
int workspaceID = 0;
if (requestedWorkspace.find("name:") == 0) {
workspaceName = requestedWorkspace.substr(5);
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
} else if (workspaceSpecial) {
workspaceName = "";
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
} else {
try {
workspaceID = std::stoi(requestedWorkspace);
} catch (...) {
workspaceID = -1;
Debug::log(ERR, "Invalid workspace requested in workspace silent rule!");
}
if (workspaceID < 1) {
workspaceID = -1; // means invalid
}
}
if (workspaceID != -1)
PWORKSPACE = g_pCompositor->createNewWorkspace(workspaceID, PWINDOW->m_iMonitorID, workspaceName);
}
if (PWORKSPACE) {
PWINDOW->m_iWorkspaceID = PWORKSPACE->m_iID;
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
} }
} }
@@ -217,32 +277,106 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" ")); const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1); const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
const auto SIZEX = !SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x; const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
const auto SIZEY = !SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
const auto SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : (!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
const auto SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : (!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW); Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY); PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY);
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
PWINDOW->m_bHidden = false; PWINDOW->setHidden(false);
} catch (...) { } catch (...) {
Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
} }
} else if (r.szRule.find("move") == 0) { } else if (r.szRule.find("minsize") == 0) {
try { try {
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1); const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
const auto POSXSTR = VALUE.substr(0, VALUE.find(" ")); const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
const auto POSYSTR = VALUE.substr(VALUE.find(" ") + 1); const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
const auto POSX = !POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x; const auto SIZE = Vector2D(std::max((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::max((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
const auto POSY = !POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
PWINDOW->m_vRealSize = SIZE;
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
PWINDOW->setHidden(false);
} catch (...) {
Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
} else if (r.szRule.find("maxsize") == 0) {
try {
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
const auto SIZE = Vector2D(std::min((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::min((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
PWINDOW->m_vRealSize = SIZE;
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
PWINDOW->setHidden(false);
} catch (...) {
Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
} else if (r.szRule.find("move") == 0) {
try {
auto value = r.szRule.substr(r.szRule.find(" ") + 1);
const bool CURSOR = value.find("cursor") == 0;
if (CURSOR)
value = value.substr(value.find_first_of(' ') + 1);
const auto POSXSTR = value.substr(0, value.find(" "));
const auto POSYSTR = value.substr(value.find(" ") + 1);
int posX = 0;
int posY = 0;
if (POSXSTR.find("100%-") == 0) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const auto POSXRAW = POSXSTR.substr(5);
posX = PMONITOR->vecSize.x - (!POSXRAW.contains('%') ? std::stoi(POSXRAW) : std::stoi(POSXRAW.substr(0, POSXRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
if (CURSOR)
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
} else if (!CURSOR) {
posX = !POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x;
} else {
// cursor
if (POSXSTR == "cursor") {
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x;
} else {
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x + (!POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().x);
}
}
if (POSYSTR.find("100%-") == 0) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const auto POSYRAW = POSYSTR.substr(5);
posY = PMONITOR->vecSize.y - (!POSYRAW.contains('%') ? std::stoi(POSYRAW) : std::stoi(POSYRAW.substr(0, POSYRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
if (CURSOR)
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
} else if (!CURSOR) {
posY = !POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y;
} else {
// cursor
if (POSYSTR == "cursor") {
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y;
} else {
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y + (!POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().y);
}
}
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW); Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);
PWINDOW->m_vRealPosition = Vector2D(POSX, POSY) + PMONITOR->vecPosition; PWINDOW->m_vRealPosition = Vector2D(posX, posY) + PMONITOR->vecPosition;
PWINDOW->m_bHidden = false; PWINDOW->setHidden(false);
} catch (...) { } catch (...) {
Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
} }
@@ -254,19 +388,36 @@ void Events::listener_mapWindow(void* owner, void* data) {
// set the pseudo size to the GOAL of our current size // set the pseudo size to the GOAL of our current size
// because the windows are animated on RealSize // because the windows are animated on RealSize
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv(); PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv();
}
else { g_pCompositor->moveWindowToTop(PWINDOW);
} else {
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW); g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
// Set the pseudo size here too so that it doesnt end up being 0x0 // Set the pseudo size here too so that it doesnt end up being 0x0
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10); PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10);
} }
if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus && PWINDOW->m_iX11Type != 2) { const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow;
if (PWINDOW->m_sAdditionalConfigData.forceAllowsInput) {
PWINDOW->m_bNoFocus = false;
PWINDOW->m_bNoInitialFocus = false;
PWINDOW->m_bX11ShouldntFocus = false;
}
// check LS focus grab
const auto PLSFROMFOCUS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
if (PLSFROMFOCUS && PLSFROMFOCUS->layerSurface->current.keyboard_interactive)
PWINDOW->m_bNoInitialFocus = true;
if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus && PWINDOW->m_iX11Type != 2 && !workspaceSilent) {
g_pCompositor->focusWindow(PWINDOW); g_pCompositor->focusWindow(PWINDOW);
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PACTIVEALPHA); PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PACTIVEALPHA);
} else PWINDOW->m_fDimPercent.setValueAndWarp(*PDIMSTRENGTH);
} else {
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PINACTIVEALPHA); PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PINACTIVEALPHA);
PWINDOW->m_fDimPercent.setValueAndWarp(0);
}
Debug::log(LOG, "Window got assigned a surfaceTreeNode %x", PWINDOW->m_pSurfaceTree); Debug::log(LOG, "Window got assigned a surfaceTreeNode %x", PWINDOW->m_pSurfaceTree);
@@ -284,6 +435,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late");
PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late");
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late");
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "Xwayland Window Late");
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "Xwayland Window Late");
if (PWINDOW->m_iX11Type == 2) if (PWINDOW->m_iX11Type == 2)
PWINDOW->hyprListener_setGeometryX11U.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_geometry, &Events::listener_unmanagedSetGeometry, PWINDOW, "XWayland Window Late"); PWINDOW->hyprListener_setGeometryX11U.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_geometry, &Events::listener_unmanagedSetGeometry, PWINDOW, "XWayland Window Late");
@@ -297,24 +450,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto TIMER = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, setAnimToMove, PWINDOW); const auto TIMER = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, setAnimToMove, PWINDOW);
wl_event_source_timer_update(TIMER, PWINDOW->m_vRealPosition.getDurationLeftMs() + 5); wl_event_source_timer_update(TIMER, PWINDOW->m_vRealPosition.getDurationLeftMs() + 5);
if (workspaceSilent) { if (requestsFullscreen && !PWINDOW->m_bNoFullscreenRequest) {
// move the window
if (g_pCompositor->m_pLastWindow == PWINDOW) {
if (requestedWorkspace != "special")
g_pKeybindManager->m_mDispatchers["movetoworkspacesilent"](requestedWorkspace);
else
g_pKeybindManager->m_mDispatchers["movetoworkspace"]("special");
} else {
Debug::log(ERR, "Tried to set workspace silent rule to a nofocus window!");
}
}
if (requestsFullscreen) {
// fix fullscreen on requested (basically do a switcheroo) // fix fullscreen on requested (basically do a switcheroo)
if (PWORKSPACE->m_bHasFullscreenWindow) { if (PWORKSPACE->m_bHasFullscreenWindow) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PFULLWINDOW, FULLSCREEN_FULL, false); g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, FULLSCREEN_FULL);
g_pXWaylandManager->setWindowFullscreen(PFULLWINDOW, PFULLWINDOW->m_bIsFullscreen);
} }
PWINDOW->m_vRealPosition.warp(); PWINDOW->m_vRealPosition.warp();
@@ -323,6 +463,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
g_pCompositor->setWindowFullscreen(PWINDOW, true, FULLSCREEN_FULL); g_pCompositor->setWindowFullscreen(PWINDOW, true, FULLSCREEN_FULL);
} }
if (pFullscreenWindow && workspaceSilent) {
g_pCompositor->setWindowFullscreen(pFullscreenWindow, true, PWORKSPACE->m_efFullscreenMode);
}
// recheck idle inhibitors // recheck idle inhibitors
g_pInputManager->recheckIdleInhibitorStatus(); g_pInputManager->recheckIdleInhibitorStatus();
@@ -330,10 +474,81 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->updateToplevel(); PWINDOW->updateToplevel();
if (!shouldFocus) {
if (g_pCompositor->windowValidMapped(PFOCUSEDWINDOWPREV)) {
g_pCompositor->focusWindow(PFOCUSEDWINDOWPREV);
PFOCUSEDWINDOWPREV->updateWindowDecos(); // need to for some reason i cba to find out why
} else if (!PFOCUSEDWINDOWPREV)
g_pCompositor->focusWindow(nullptr);
}
// verify swallowing
if (*PSWALLOW) {
// don't swallow ourselves
std::regex rgx(*PSWALLOWREGEX);
if (!std::regex_match(g_pXWaylandManager->getAppIDClass(PWINDOW), rgx)) {
// check parent
int ppid = getPPIDof(PWINDOW->getPID());
int curppid = 0;
for (int i = 0; i < 5; ++i) {
curppid = getPPIDof(ppid);
if (curppid < 10) {
break;
}
ppid = curppid;
}
if (ppid) {
// get window by pid
std::vector<CWindow*> found;
CWindow* finalFound = nullptr;
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden())
continue;
if (w->getPID() == ppid) {
found.push_back(w.get());
}
}
if (found.size() > 1) {
for (auto& w : found) {
// try get the focus, otherwise we'll ignore to avoid swallowing incorrect windows
if (w == PFOCUSEDWINDOWPREV) {
finalFound = w;
break;
}
}
} else if (found.size() == 1) {
finalFound = found[0];
}
if (finalFound) {
// check if it's the window we want
if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) {
// swallow
PWINDOW->m_pSwallowed = finalFound;
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound);
finalFound->setHidden(true);
}
}
}
}
}
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y); Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
auto workspaceID = requestedWorkspace != "" ? requestedWorkspace : PWORKSPACE->m_szName; auto workspaceID = requestedWorkspace != "" ? requestedWorkspace : PWORKSPACE->m_szName;
g_pEventManager->postEvent(SHyprIPCEvent{"openwindow", getFormat("%x,%s,%s,%s", PWINDOW, workspaceID.c_str(), g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), PWINDOW->m_szTitle.c_str())}); g_pEventManager->postEvent(SHyprIPCEvent{"openwindow", getFormat("%x,%s,%s,%s", PWINDOW, workspaceID.c_str(), g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), PWINDOW->m_szTitle.c_str())});
// recalc the values for this window
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
} }
void Events::listener_unmapWindow(void* owner, void* data) { void Events::listener_unmapWindow(void* owner, void* data) {
@@ -343,6 +558,8 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", getFormat("%x", PWINDOW)}); g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", getFormat("%x", PWINDOW)});
g_pProtocolManager->m_pToplevelExportProtocolManager->onWindowUnmap(PWINDOW);
if (!PWINDOW->m_bIsX11) { if (!PWINDOW->m_bIsX11) {
Debug::log(LOG, "Unregistered late callbacks XDG"); Debug::log(LOG, "Unregistered late callbacks XDG");
PWINDOW->hyprListener_commitWindow.removeCallback(); PWINDOW->hyprListener_commitWindow.removeCallback();
@@ -360,17 +577,28 @@ void Events::listener_unmapWindow(void* owner, void* data) {
PWINDOW->hyprListener_configureX11.removeCallback(); PWINDOW->hyprListener_configureX11.removeCallback();
PWINDOW->hyprListener_setTitleWindow.removeCallback(); PWINDOW->hyprListener_setTitleWindow.removeCallback();
PWINDOW->hyprListener_setGeometryX11U.removeCallback(); PWINDOW->hyprListener_setGeometryX11U.removeCallback();
PWINDOW->hyprListener_requestMaximize.removeCallback();
PWINDOW->hyprListener_requestMinimize.removeCallback();
} }
if (PWINDOW->m_bIsFullscreen) { if (PWINDOW->m_bIsFullscreen) {
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, false); g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
g_pXWaylandManager->setWindowFullscreen(PWINDOW, PWINDOW->m_bIsFullscreen);
} }
// Allow the renderer to catch the last frame. // Allow the renderer to catch the last frame.
g_pHyprOpenGL->makeWindowSnapshot(PWINDOW); g_pHyprOpenGL->makeWindowSnapshot(PWINDOW);
// swallowing
if (PWINDOW->m_pSwallowed && g_pCompositor->windowExists(PWINDOW->m_pSwallowed)) {
PWINDOW->m_pSwallowed->setHidden(false);
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed);
PWINDOW->m_pSwallowed = nullptr;
}
bool wasLastWindow = false;
if (PWINDOW == g_pCompositor->m_pLastWindow) { if (PWINDOW == g_pCompositor->m_pLastWindow) {
wasLastWindow = true;
g_pCompositor->m_pLastWindow = nullptr; g_pCompositor->m_pLastWindow = nullptr;
g_pCompositor->m_pLastFocus = nullptr; g_pCompositor->m_pLastFocus = nullptr;
} }
@@ -388,14 +616,9 @@ void Events::listener_unmapWindow(void* owner, void* data) {
// do this after onWindowRemoved because otherwise it'll think the window is invalid // do this after onWindowRemoved because otherwise it'll think the window is invalid
PWINDOW->m_bIsMapped = false; PWINDOW->m_bIsMapped = false;
// refocus on a new window // refocus on a new window if needed
auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f); if (wasLastWindow) {
const auto PWINDOWCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
if (PWORKSPACE->m_bHasFullscreenWindow && (!PWINDOWCANDIDATE->m_bCreatedOverFullscreen || !PWINDOW->m_bIsFloating))
PWINDOWCANDIDATE = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
if (!PWINDOWCANDIDATE || PWINDOW == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->m_bHidden || PWINDOWCANDIDATE->m_bX11ShouldntFocus || PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
PWINDOWCANDIDATE = nullptr;
Debug::log(LOG, "On closed window, new focused candidate is %x", PWINDOWCANDIDATE); Debug::log(LOG, "On closed window, new focused candidate is %x", PWINDOWCANDIDATE);
@@ -404,6 +627,11 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pInputManager->refocus(); g_pInputManager->refocus();
else else
g_pCompositor->focusWindow(PWINDOWCANDIDATE); g_pCompositor->focusWindow(PWINDOWCANDIDATE);
} else {
g_pInputManager->refocus();
}
} else {
Debug::log(LOG, "Unmapped was not focused, ignoring a refocus.");
} }
Debug::log(LOG, "Destroying the SubSurface tree of unmapped window %x", PWINDOW); Debug::log(LOG, "Destroying the SubSurface tree of unmapped window %x", PWINDOW);
@@ -435,12 +663,18 @@ void Events::listener_unmapWindow(void* owner, void* data) {
// recheck idle inhibitors // recheck idle inhibitors
g_pInputManager->recheckIdleInhibitorStatus(); g_pInputManager->recheckIdleInhibitorStatus();
// force report all sizes (QT sometimes has an issue with this)
g_pCompositor->forceReportSizesToWindowsOnWorkspace(PWINDOW->m_iWorkspaceID);
// update lastwindow after focus
PWINDOW->onUnmap();
} }
void Events::listener_commitWindow(void* owner, void* data) { void Events::listener_commitWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner; CWindow* PWINDOW = (CWindow*)owner;
if (!PWINDOW->m_bMappedX11 || PWINDOW->m_bHidden || (PWINDOW->m_bIsX11 && !PWINDOW->m_bMappedX11)) if (!PWINDOW->m_bMappedX11 || PWINDOW->isHidden() || (PWINDOW->m_bIsX11 && !PWINDOW->m_bMappedX11))
return; return;
g_pHyprRenderer->damageSurface(g_pXWaylandManager->getWindowSurface(PWINDOW), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y); g_pHyprRenderer->damageSurface(g_pXWaylandManager->getWindowSurface(PWINDOW), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y);
@@ -474,6 +708,11 @@ void Events::listener_destroyWindow(void* owner, void* data) {
} }
PWINDOW->m_bReadyToDelete = true; PWINDOW->m_bReadyToDelete = true;
if (!PWINDOW->m_bFadingOut) {
g_pCompositor->removeWindowFromVectorSafe(PWINDOW); // most likely X11 unmanaged or sumn
Debug::log(LOG, "Unmapped window %x removed instantly", PWINDOW);
}
} }
void Events::listener_setTitleWindow(void* owner, void* data) { void Events::listener_setTitleWindow(void* owner, void* data) {
@@ -487,6 +726,8 @@ void Events::listener_setTitleWindow(void* owner, void* data) {
if (PWINDOW == g_pCompositor->m_pLastWindow) // if it's the active, let's post an event to update others if (PWINDOW == g_pCompositor->m_pLastWindow) // if it's the active, let's post an event to update others
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", g_pXWaylandManager->getAppIDClass(PWINDOW) + "," + PWINDOW->m_szTitle}); g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", g_pXWaylandManager->getAppIDClass(PWINDOW) + "," + PWINDOW->m_szTitle});
PWINDOW->updateDynamicRules();
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
PWINDOW->updateToplevel(); PWINDOW->updateToplevel();
Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str()); Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str());
@@ -500,7 +741,7 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
return; return;
} }
if (PWINDOW->m_bHidden) if (PWINDOW->isHidden() || PWINDOW->m_bNoFullscreenRequest)
return; return;
if (!PWINDOW->m_bIsX11) { if (!PWINDOW->m_bIsX11) {
@@ -511,26 +752,50 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
} else { } else {
g_pCompositor->setWindowFullscreen(PWINDOW, !PWINDOW->m_bIsFullscreen, FULLSCREEN_FULL); if (!PWINDOW->m_uSurface.xwayland->mapped)
return;
g_pCompositor->setWindowFullscreen(PWINDOW, PWINDOW->m_uSurface.xwayland->fullscreen, FULLSCREEN_FULL);
} }
PWINDOW->updateToplevel(); PWINDOW->updateToplevel();
Debug::log(LOG, "Window %x fullscreen to %i", PWINDOW, PWINDOW->m_bIsFullscreen); Debug::log(LOG, "Window %x fullscreen to %i", PWINDOW, PWINDOW->m_bIsFullscreen);
g_pXWaylandManager->setWindowFullscreen(PWINDOW, PWINDOW->m_bIsFullscreen);
} }
void Events::listener_activate(void* owner, void* data) { void Events::listener_activateXDG(wl_listener* listener, void* data) {
// TODO const auto E = (wlr_xdg_activation_v1_request_activate_event*)data;
static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
Debug::log(LOG, "Activate request for surface at %x", E->surface);
if (!*PFOCUSONACTIVATE || !wlr_surface_is_xdg_surface(E->surface))
return;
const auto PWINDOW = g_pCompositor->getWindowFromSurface(E->surface);
if (!PWINDOW || PWINDOW == g_pCompositor->m_pLastWindow)
return;
g_pCompositor->focusWindow(PWINDOW);
Vector2D middle = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
g_pCompositor->warpCursorTo(middle);
} }
void Events::listener_activateX11(void* owner, void* data) { void Events::listener_activateX11(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner; const auto PWINDOW = (CWindow*)owner;
if (PWINDOW->m_iX11Type == 1 /* Managed */) { static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
wlr_xwayland_surface_activate(PWINDOW->m_uSurface.xwayland, 1);
} Debug::log(LOG, "X11 Activate request for window %x", PWINDOW);
if (!*PFOCUSONACTIVATE || PWINDOW->m_iX11Type != 1 || PWINDOW == g_pCompositor->m_pLastWindow)
return;
g_pCompositor->focusWindow(PWINDOW);
Vector2D middle = PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f;
g_pCompositor->warpCursorTo(middle);
} }
void Events::listener_configureX11(void* owner, void* data) { void Events::listener_configureX11(void* owner, void* data) {
@@ -543,21 +808,21 @@ void Events::listener_configureX11(void* owner, void* data) {
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
if (!PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen) { if (!PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen) {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.vec()); g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv(), true);
g_pInputManager->refocus(); g_pInputManager->refocus();
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
return; return;
} }
if (!PWINDOW->m_uSurface.xwayland->mapped) { if (!PWINDOW->m_uSurface.xwayland->mapped || !PWINDOW->m_bMappedX11) {
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height); wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
return; return;
} }
if (E->width > 1 && E->height > 1) if (E->width > 1 && E->height > 1)
PWINDOW->m_bHidden = false; PWINDOW->setHidden(false);
else else
PWINDOW->m_bHidden = true; PWINDOW->setHidden(true);
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y)); PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height)); PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
@@ -572,6 +837,7 @@ void Events::listener_configureX11(void* owner, void* data) {
PWINDOW->m_bCreatedOverFullscreen = true; PWINDOW->m_bCreatedOverFullscreen = true;
if (!PWINDOW->m_sAdditionalConfigData.windowDanceCompat)
g_pInputManager->refocus(); g_pInputManager->refocus();
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
@@ -582,16 +848,22 @@ void Events::listener_configureX11(void* owner, void* data) {
void Events::listener_unmanagedSetGeometry(void* owner, void* data) { void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner; CWindow* PWINDOW = (CWindow*)owner;
if (!PWINDOW->m_bMappedX11 || PWINDOW->m_bHidden) if (!PWINDOW->m_bMappedX11)
return; return;
const auto POS = PWINDOW->m_vRealPosition.goalv(); const auto POS = PWINDOW->m_vRealPosition.goalv();
const auto SIZ = PWINDOW->m_vRealSize.goalv(); const auto SIZ = PWINDOW->m_vRealSize.goalv();
if (PWINDOW->m_uSurface.xwayland->width > 1 && PWINDOW->m_uSurface.xwayland->height > 1) if (PWINDOW->m_uSurface.xwayland->width > 1 && PWINDOW->m_uSurface.xwayland->height > 1)
PWINDOW->m_bHidden = false; PWINDOW->setHidden(false);
else else
PWINDOW->m_bHidden = true; PWINDOW->setHidden(true);
if (PWINDOW->m_bIsFullscreen || !PWINDOW->m_bIsFloating) {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv(), true);
g_pHyprRenderer->damageWindow(PWINDOW);
return;
}
if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) { if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) {
Debug::log(LOG, "Unmanaged window %x requests geometry update to %i %i %i %i", PWINDOW, (int)PWINDOW->m_uSurface.xwayland->x, (int)PWINDOW->m_uSurface.xwayland->y, (int)PWINDOW->m_uSurface.xwayland->width, (int)PWINDOW->m_uSurface.xwayland->height); Debug::log(LOG, "Unmanaged window %x requests geometry update to %i %i %i %i", PWINDOW, (int)PWINDOW->m_uSurface.xwayland->x, (int)PWINDOW->m_uSurface.xwayland->y, (int)PWINDOW->m_uSurface.xwayland->width, (int)PWINDOW->m_uSurface.xwayland->height);
@@ -655,12 +927,37 @@ void Events::listener_NewXDGDeco(wl_listener* listener, void* data) {
void Events::listener_requestMaximize(void* owner, void* data) { void Events::listener_requestMaximize(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner; const auto PWINDOW = (CWindow*)owner;
// ignore if (PWINDOW->m_bNoFullscreenRequest)
return;
Debug::log(LOG, "Maximize request for %x", PWINDOW);
if (!PWINDOW->m_bIsX11) {
const auto EV = (wlr_foreign_toplevel_handle_v1_maximized_event*)data;
g_pCompositor->setWindowFullscreen(PWINDOW, EV ? EV->maximized : !PWINDOW->m_bIsFullscreen, FULLSCREEN_MAXIMIZED); // this will be rejected if there already is a fullscreen window
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg); wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
} else {
if (!PWINDOW->m_bMappedX11 || PWINDOW->m_iX11Type != 1)
return;
g_pCompositor->setWindowFullscreen(PWINDOW, !PWINDOW->m_bIsFullscreen, FULLSCREEN_MAXIMIZED);
}
} }
void Events::listener_requestMinimize(void* owner, void* data) { void Events::listener_requestMinimize(void* owner, void* data) {
// ignore const auto PWINDOW = (CWindow*)owner;
Debug::log(LOG, "Minimize request for %x", PWINDOW);
if (PWINDOW->m_bIsX11) {
if (!PWINDOW->m_bMappedX11 || PWINDOW->m_iX11Type != 1)
return;
const auto E = (wlr_xwayland_minimize_event*)data;
wlr_xwayland_surface_set_minimized(PWINDOW->m_uSurface.xwayland, E->minimize && g_pCompositor->m_pLastWindow != PWINDOW); // fucking DXVK
}
} }
void Events::listener_requestMove(void* owner, void* data) { void Events::listener_requestMove(void* owner, void* data) {

View File

@@ -12,8 +12,6 @@ void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* p
m_pConfig = pAnimConfig; m_pConfig = pAnimConfig;
m_pWindow = pWindow; m_pWindow = pWindow;
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
m_bDummy = false; m_bDummy = false;
} }
@@ -56,8 +54,20 @@ CAnimatedVariable::~CAnimatedVariable() {
void CAnimatedVariable::unregister() { void CAnimatedVariable::unregister() {
g_pAnimationManager->m_lAnimatedVariables.remove(this); g_pAnimationManager->m_lAnimatedVariables.remove(this);
m_bIsRegistered = false;
}
void CAnimatedVariable::registerVar() {
if (!m_bIsRegistered)
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
m_bIsRegistered = true;
} }
int CAnimatedVariable::getDurationLeftMs() { int CAnimatedVariable::getDurationLeftMs() {
return std::clamp((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0, INT_MAX); return std::max((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0);
}
float CAnimatedVariable::getPercent() {
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count();
return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f);
} }

View File

@@ -21,6 +21,7 @@ class CAnimationManager;
class CWorkspace; class CWorkspace;
struct SLayerSurface; struct SLayerSurface;
struct SAnimationPropertyConfig; struct SAnimationPropertyConfig;
class CHyprRenderer;
class CAnimatedVariable { class CAnimatedVariable {
public: public:
@@ -32,6 +33,7 @@ public:
~CAnimatedVariable(); ~CAnimatedVariable();
void unregister(); void unregister();
void registerVar();
// gets the current vector value (real time) // gets the current vector value (real time)
const Vector2D& vec() const { const Vector2D& vec() const {
@@ -67,18 +69,24 @@ public:
m_vGoal = v; m_vGoal = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_vBegun = m_vValue; m_vBegun = m_vValue;
onAnimationBegin();
} }
void operator=(const float& v) { void operator=(const float& v) {
m_fGoal = v; m_fGoal = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_fBegun = m_fValue; m_fBegun = m_fValue;
onAnimationBegin();
} }
void operator=(const CColor& v) { void operator=(const CColor& v) {
m_cGoal = v; m_cGoal = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_cBegun = m_cValue; m_cBegun = m_cValue;
onAnimationBegin();
} }
// Sets the actual stored value, without affecting the goal, but resets the timer // Sets the actual stored value, without affecting the goal, but resets the timer
@@ -86,6 +94,8 @@ public:
m_vValue = v; m_vValue = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_vBegun = m_vValue; m_vBegun = m_vValue;
onAnimationBegin();
} }
// Sets the actual stored value, without affecting the goal, but resets the timer // Sets the actual stored value, without affecting the goal, but resets the timer
@@ -93,6 +103,8 @@ public:
m_fValue = v; m_fValue = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_vBegun = m_vValue; m_vBegun = m_vValue;
onAnimationBegin();
} }
// Sets the actual stored value, without affecting the goal, but resets the timer // Sets the actual stored value, without affecting the goal, but resets the timer
@@ -100,6 +112,8 @@ public:
m_cValue = v; m_cValue = v;
animationBegin = std::chrono::system_clock::now(); animationBegin = std::chrono::system_clock::now();
m_vBegun = m_vValue; m_vBegun = m_vValue;
onAnimationBegin();
} }
// Sets the actual value and goal // Sets the actual value and goal
@@ -138,7 +152,7 @@ public:
return false; // just so that the warning is suppressed return false; // just so that the warning is suppressed
} }
void warp() { void warp(bool endCallback = true) {
switch (m_eVarType) { switch (m_eVarType) {
case AVARTYPE_FLOAT: { case AVARTYPE_FLOAT: {
m_fValue = m_fGoal; m_fValue = m_fGoal;
@@ -155,6 +169,9 @@ public:
default: default:
UNREACHABLE(); UNREACHABLE();
} }
if (endCallback)
onAnimationEnd();
} }
void setConfig(SAnimationPropertyConfig* pConfig) { void setConfig(SAnimationPropertyConfig* pConfig) {
@@ -167,6 +184,35 @@ public:
int getDurationLeftMs(); int getDurationLeftMs();
/* returns the spent (completion) % */
float getPercent();
/* sets a function to be ran when the animation finishes.
if an animation is not running, runs instantly.
if "remove" is set to true, will remove the callback when ran. */
void setCallbackOnEnd(std::function<void(void* thisptr)> func, bool remove = true) {
m_fEndCallback = func;
m_bRemoveEndAfterRan = remove;
if (!isBeingAnimated())
onAnimationEnd();
}
/* sets a function to be ran when an animation is started.
if "remove" is set to true, will remove the callback when ran. */
void setCallbackOnBegin(std::function<void(void* thisptr)> func, bool remove = true) {
m_fBeginCallback = func;
m_bRemoveBeginAfterRan = remove;
}
/* resets all callbacks. Does not call any. */
void resetAllCallbacks() {
m_fBeginCallback = nullptr;
m_fEndCallback = nullptr;
m_bRemoveBeginAfterRan = false;
m_bRemoveEndAfterRan = false;
}
private: private:
Vector2D m_vValue = Vector2D(0,0); Vector2D m_vValue = Vector2D(0,0);
@@ -189,13 +235,37 @@ private:
SAnimationPropertyConfig* m_pConfig = nullptr; SAnimationPropertyConfig* m_pConfig = nullptr;
bool m_bDummy = true; bool m_bDummy = true;
bool m_bIsRegistered = false;
std::chrono::system_clock::time_point animationBegin; std::chrono::system_clock::time_point animationBegin;
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID; ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID; AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
bool m_bRemoveEndAfterRan = true;
bool m_bRemoveBeginAfterRan = true;
std::function<void(void* thisptr)> m_fEndCallback;
std::function<void(void* thisptr)> m_fBeginCallback;
// methods
void onAnimationEnd() {
if (m_fEndCallback) {
m_fEndCallback(this);
if (m_bRemoveEndAfterRan)
m_fEndCallback = nullptr; // reset
}
}
void onAnimationBegin() {
if (m_fBeginCallback) {
m_fBeginCallback(this);
if (m_bRemoveBeginAfterRan)
m_fBeginCallback = nullptr; // reset
}
}
friend class CAnimationManager; friend class CAnimationManager;
friend class CWorkspace; friend class CWorkspace;
friend struct SLayerSurface; friend struct SLayerSurface;
friend class CHyprRenderer;
}; };

View File

@@ -1,9 +1,7 @@
#include "Color.hpp" #include "Color.hpp"
#include "../defines.hpp" #include "../defines.hpp"
CColor::CColor() { CColor::CColor() { }
}
CColor::CColor(float r, float g, float b, float a) { CColor::CColor(float r, float g, float b, float a) {
this->r = r; this->r = r;

View File

@@ -5,6 +5,31 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#include <iomanip> #include <iomanip>
#if defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/sysctl.h>
# if defined(__DragonFly__)
# include <sys/kinfo.h> // struct kinfo_proc
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/user.h> // struct kinfo_proc
# endif
# if defined(__NetBSD__)
# undef KERN_PROC
# define KERN_PROC KERN_PROC2
# define KINFO_PROC struct kinfo_proc2
# else
# define KINFO_PROC struct kinfo_proc
# endif
# if defined(__DragonFly__)
# define KP_PPID(kp) kp.kp_ppid
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# define KP_PPID(kp) kp.ki_ppid
# else
# define KP_PPID(kp) kp.p_ppid
# endif
#endif
static const float transforms[][9] = {{ static const float transforms[][9] = {{
1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
@@ -120,14 +145,21 @@ void scaleBox(wlr_box* box, float scale) {
} }
std::string removeBeginEndSpacesTabs(std::string str) { std::string removeBeginEndSpacesTabs(std::string str) {
while (str[0] == ' ' || str[0] == '\t') { if (str.empty())
str = str.substr(1); return str;
int countBefore = 0;
while (str[countBefore] == ' ' || str[countBefore] == '\t') {
countBefore++;
} }
while (str.length() != 0 && (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t')) { int countAfter = 0;
str = str.substr(0, str.length() - 1); while (str.length() != 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) {
countAfter++;
} }
str = str.substr(countBefore, str.length() - countBefore - countAfter);
return str; return str;
} }
@@ -170,7 +202,28 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
} }
bool isNumber(const std::string& str, bool allowfloat) { bool isNumber(const std::string& str, bool allowfloat) {
return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); });
std::string copy = str;
if (*copy.begin() == '-')
copy = copy.substr(1);
if (copy.empty())
return false;
bool point = !allowfloat;
for (auto& c : copy) {
if (c == '.') {
if (point)
return false;
point = true;
break;
}
if (!std::isdigit(c))
return false;
}
return true;
} }
bool isDirection(const std::string& arg) { bool isDirection(const std::string& arg) {
@@ -181,7 +234,18 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
int result = INT_MAX; int result = INT_MAX;
if (in.find("special") == 0) { if (in.find("special") == 0) {
outName = "special"; outName = "special";
return SPECIAL_WORKSPACE_ID;
if (in.length() > 8) {
const auto NAME = in.substr(8);
const auto WS = g_pCompositor->getWorkspaceByName("special:" + NAME);
outName = "special:" + NAME;
return WS ? WS->m_iID : g_pCompositor->getNewSpecialID();
}
return SPECIAL_WORKSPACE_START;
} else if (in.find("name:") == 0) { } else if (in.find("name:") == 0) {
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1); const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME); const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
@@ -191,8 +255,15 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
result = WORKSPACE->m_iID; result = WORKSPACE->m_iID;
} }
outName = WORKSPACENAME; outName = WORKSPACENAME;
} else if (in.find("empty") == 0) {
int id = 0;
while (++id < INT_MAX) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
if (!PWORKSPACE || (g_pCompositor->getWindowsOnWorkspace(id) == 0))
return id;
}
} else { } else {
if (in[0] == 'm' || in[0] == 'e') { if ((in[0] == 'm' || in[0] == 'e') && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
bool onAllMonitors = in[0] == 'e'; bool onAllMonitors = in[0] == 'e';
if (!g_pCompositor->m_pLastMonitor) { if (!g_pCompositor->m_pLastMonitor) {
@@ -221,6 +292,9 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
int highestID = -99999; int highestID = -99999;
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (g_pCompositor->isWorkspaceSpecial(w->m_iID))
continue;
if (w->m_iID < lowestID) if (w->m_iID < lowestID)
lowestID = w->m_iID; lowestID = w->m_iID;
@@ -234,7 +308,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
searchID = lowestID; searchID = lowestID;
} }
if (const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(searchID); PWORKSPACE && PWORKSPACE->m_iID != SPECIAL_WORKSPACE_ID) { if (const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(searchID); PWORKSPACE && !PWORKSPACE->m_bIsSpecialWorkspace) {
if (onAllMonitors || PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) { if (onAllMonitors || PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) {
currentID = PWORKSPACE->m_iID; currentID = PWORKSPACE->m_iID;
@@ -250,14 +324,22 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
outName = g_pCompositor->getWorkspaceByID(currentID)->m_szName; outName = g_pCompositor->getWorkspaceByID(currentID)->m_szName;
} else { } else {
if (in[0] == '+' || in[0] == '-') {
if (g_pCompositor->m_pLastMonitor) if (g_pCompositor->m_pLastMonitor)
result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX); result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1);
else if (isNumber(in))
result = std::clamp(std::stoi(in), 1, INT_MAX);
else { else {
Debug::log(ERR, "Relative workspace on no mon!"); Debug::log(ERR, "Relative workspace on no mon!");
result = INT_MAX; result = INT_MAX;
} }
} else if (isNumber(in))
result = std::max(std::stoi(in), 1);
else {
// maybe name
const auto PWORKSPACE = g_pCompositor->getWorkspaceByName(in);
if (PWORKSPACE)
result = PWORKSPACE->m_iID;
}
outName = std::to_string(result); outName = std::to_string(result);
} }
} }
@@ -266,8 +348,8 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
} }
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2) { float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2) {
const float DX = std::max((double)0, std::max(p1.x - vec.x, vec.x - p2.x)); const float DX = std::max({0.0, p1.x - vec.x, vec.x - p2.x});
const float DY = std::max((double)0, std::max(p1.y - vec.y, vec.y - p2.y)); const float DY = std::max({0.0, p1.y - vec.y, vec.y - p2.y});
return DX * DX + DY * DY; return DX * DX + DY * DY;
} }
@@ -296,6 +378,15 @@ void logSystemInfo() {
Debug::log(LOG, "Release: %s", unameInfo.release); Debug::log(LOG, "Release: %s", unameInfo.release);
Debug::log(LOG, "Version: %s", unameInfo.version); Debug::log(LOG, "Version: %s", unameInfo.version);
Debug::log(NONE, "\n");
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
Debug::log(LOG, "GPU information:\n%s\n", GPUINFO.c_str());
if (GPUINFO.contains("NVIDIA")) {
Debug::log(WARN, "Warning: you're using an NVIDIA GPU. Make sure you follow the instructions on the wiki if anything is amiss.\n");
}
// log etc // log etc
Debug::log(LOG, "os-release:"); Debug::log(LOG, "os-release:");
@@ -312,8 +403,8 @@ void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) {
// Rotation + reflection // Rotation + reflection
mat[0] = x * t[0]; mat[0] = x * t[0];
mat[1] = x * t[1]; mat[1] = x * t[1];
mat[3] = y * -t[3]; mat[3] = y * t[3];
mat[4] = y * -t[4]; mat[4] = y * t[4];
// Translation // Translation
mat[2] = -copysign(1.0f, mat[0] + mat[1]); mat[2] = -copysign(1.0f, mat[0] + mat[1]);
@@ -322,3 +413,94 @@ void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) {
// Identity // Identity
mat[8] = 1.0f; mat[8] = 1.0f;
} }
int64_t getPPIDof(int64_t pid) {
#if defined(KERN_PROC_PID)
int mib[] = {
CTL_KERN,
KERN_PROC,
KERN_PROC_PID,
(int)pid,
# if defined(__NetBSD__) || defined(__OpenBSD__)
sizeof(KINFO_PROC),
1,
# endif
};
u_int miblen = sizeof(mib) / sizeof(mib[0]);
KINFO_PROC kp;
size_t sz = sizeof(KINFO_PROC);
if (sysctl(mib, miblen, &kp, &sz, NULL, 0) != -1)
return KP_PPID(kp);
return 0;
#else
std::string dir = "/proc/" + std::to_string(pid) + "/status";
FILE* infile;
infile = fopen(dir.c_str(), "r");
if (!infile)
return 0;
char* line = nullptr;
size_t len = 0;
ssize_t len2 = 0;
std::string pidstr;
while ((len2 = getline(&line, &len, infile)) != -1) {
if (strstr(line, "PPid:")) {
pidstr = std::string(line, len2);
const auto tabpos = pidstr.find_last_of('\t');
if (tabpos != std::string::npos)
pidstr = pidstr.substr(tabpos);
break;
}
}
fclose(infile);
if (line)
free(line);
try {
return std::stoll(pidstr);
} catch (std::exception& e) {
return 0;
}
#endif
}
int64_t configStringToInt(const std::string& VALUE) {
if (VALUE.find("0x") == 0) {
// Values with 0x are hex
const auto VALUEWITHOUTHEX = VALUE.substr(2);
return stol(VALUEWITHOUTHEX, nullptr, 16);
} else if (VALUE.find("rgba(") == 0 && VALUE.find(")") == VALUE.length() - 1) {
const auto VALUEWITHOUTFUNC = VALUE.substr(5, VALUE.length() - 6);
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 8) {
Debug::log(WARN, "invalid length %i for rgba", VALUEWITHOUTFUNC.length());
throw std::invalid_argument("rgba() expects length of 8 characters (4 bytes)");
}
const auto RGBA = std::stol(VALUEWITHOUTFUNC, nullptr, 16);
// now we need to RGBA -> ARGB. The config holds ARGB only.
return (RGBA >> 8) + 0x1000000 * (RGBA & 0xFF);
} else if (VALUE.find("rgb(") == 0 && VALUE.find(")") == VALUE.length() - 1) {
const auto VALUEWITHOUTFUNC = VALUE.substr(4, VALUE.length() - 5);
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 6) {
Debug::log(WARN, "invalid length %i for rgb", VALUEWITHOUTFUNC.length());
throw std::invalid_argument("rgb() expects length of 6 characters (3 bytes)");
}
const auto RGB = std::stol(VALUEWITHOUTFUNC, nullptr, 16);
return RGB + 0xFF000000; // 0xFF for opaque
} else if (VALUE.find("true") == 0 || VALUE.find("on") == 0 || VALUE.find("yes") == 0) {
return 1;
} else if (VALUE.find("false") == 0 || VALUE.find("off") == 0 || VALUE.find("no") == 0) {
return 0;
}
return stol(VALUE);
}

View File

@@ -14,6 +14,8 @@ int getWorkspaceIDFromString(const std::string&, std::string&);
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2); float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
void logSystemInfo(); void logSystemInfo();
std::string execAndGet(const char*); std::string execAndGet(const char*);
int64_t getPPIDof(int64_t pid);
int64_t configStringToInt(const std::string&);
float getPlusMinusKeywordResult(std::string in, float relative); float getPlusMinusKeywordResult(std::string in, float relative);

View File

@@ -3,21 +3,30 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
void CMonitor::onConnect(bool noRule) { void CMonitor::onConnect(bool noRule) {
if (m_bEnabled) hyprListener_monitorDestroy.removeCallback();
hyprListener_monitorFrame.removeCallback();
hyprListener_monitorStateRequest.removeCallback();
hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this);
hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this);
hyprListener_monitorStateRequest.initCallback(&output->events.request_state, &Events::listener_monitorStateRequest, this);
if (m_bEnabled) {
wlr_output_enable(output, 1);
wlr_output_commit(output);
return; return;
}
szName = output->name; szName = output->name;
// get monitor rule that matches if (!wlr_backend_is_drm(output->backend))
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name); createdByUser = true; // should be true. WL, X11 and Headless backends should be addable / removable
hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this); // get monitor rule that matches
hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this); SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name, output->description ? output->description : "");
// if it's disabled, disable and ignore // if it's disabled, disable and ignore
if (monitorRule.disabled) { if (monitorRule.disabled) {
wlr_output_enable_adaptive_sync(output, 1);
wlr_output_set_scale(output, 1); wlr_output_set_scale(output, 1);
wlr_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL); wlr_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
@@ -56,7 +65,17 @@ void CMonitor::onConnect(bool noRule) {
return; return;
} }
if (output->non_desktop) {
Debug::log(LOG, "Not configuring non-desktop output");
if (g_pCompositor->m_sWRLDRMLeaseMgr) {
wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output);
}
return;
}
if (!m_bRenderingInitPassed) { if (!m_bRenderingInitPassed) {
output->allocator = nullptr;
output->renderer = nullptr;
wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer); wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
m_bRenderingInitPassed = true; m_bRenderingInitPassed = true;
} }
@@ -78,11 +97,7 @@ void CMonitor::onConnect(bool noRule) {
m_bEnabled = true; m_bEnabled = true;
wlr_output_set_scale(output, monitorRule.scale);
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, monitorRule.scale); wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, monitorRule.scale);
wlr_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL); // TODO: support other transforms
wlr_output_enable_adaptive_sync(output, 1);
// create it in the arr // create it in the arr
vecPosition = monitorRule.offset; vecPosition = monitorRule.offset;
@@ -91,10 +106,6 @@ void CMonitor::onConnect(bool noRule) {
wlr_output_enable(output, 1); wlr_output_enable(output, 1);
// TODO: this doesn't seem to set the X and Y correctly,
// wlr_output_layout_output_coords returns invalid values, I think...
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, output, monitorRule.offset.x, monitorRule.offset.y);
// set mode, also applies // set mode, also applies
if (!noRule) if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true); g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
@@ -110,67 +121,36 @@ void CMonitor::onConnect(bool noRule) {
wlr_ext_workspace_group_handle_v1_output_enter(pWLRWorkspaceGroupHandle, output); wlr_ext_workspace_group_handle_v1_output_enter(pWLRWorkspaceGroupHandle, output);
// Workspace setupDefaultWS(monitorRule);
std::string newDefaultWorkspaceName = "";
auto WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_vWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
if (WORKSPACEID == INT_MAX || WORKSPACEID == (long unsigned int)SPECIAL_WORKSPACE_ID) {
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
}
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
Debug::log(LOG, "New monitor: WORKSPACEID %d, exists: %d", WORKSPACEID, (int)(PNEWWORKSPACE != nullptr));
if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor
g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this);
activeWorkspace = PNEWWORKSPACE->m_iID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
PNEWWORKSPACE->startAnim(true, true, true);
} else {
if (newDefaultWorkspaceName == "")
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(ID, newDefaultWorkspaceName)).get();
// We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str());
PNEWWORKSPACE->m_iID = WORKSPACEID;
}
activeWorkspace = PNEWWORKSPACE->m_iID;
scale = monitorRule.scale; scale = monitorRule.scale;
m_pThisWrap = nullptr; m_pThisWrap = nullptr;
forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering.
g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
PNEWWORKSPACE->setActive(true);
// //
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
g_pCompositor->m_pLastMonitor = this; g_pCompositor->setActiveMonitor(this);
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale); wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
g_pHyprRenderer->arrangeLayersForMonitor(ID); g_pHyprRenderer->arrangeLayersForMonitor(ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName}); // ensure VRR (will enable if necessary)
g_pConfigManager->ensureVRR(this);
} }
void CMonitor::onDisconnect() { void CMonitor::onDisconnect() {
if (!m_bEnabled) if (!m_bEnabled || g_pCompositor->m_bIsShuttingDown)
return; return;
Debug::log(LOG, "onDisconnect called for %s", output->name);
// Cleanup everything. Move windows back, snap cursor, shit. // Cleanup everything. Move windows back, snap cursor, shit.
CMonitor* BACKUPMON = nullptr; CMonitor* BACKUPMON = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
@@ -180,6 +160,23 @@ void CMonitor::onDisconnect() {
} }
} }
if (g_pCompositor->m_pLastMonitor == this)
g_pCompositor->setActiveMonitor(BACKUPMON);
// remove mirror
if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; }));
pMirrorOf = nullptr;
}
if (!mirrors.empty()) {
for (auto& m : mirrors) {
m->setMirror("");
}
g_pConfigManager->m_bWantsMonitorReload = true;
}
m_bEnabled = false; m_bEnabled = false;
m_bRenderingInitPassed = false; m_bRenderingInitPassed = false;
@@ -188,7 +185,7 @@ void CMonitor::onDisconnect() {
if (!BACKUPMON) { if (!BACKUPMON) {
Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend."); Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend.");
hyprListener_monitorMode.removeCallback(); hyprListener_monitorStateRequest.removeCallback();
hyprListener_monitorDestroy.removeCallback(); hyprListener_monitorDestroy.removeCallback();
g_pCompositor->m_bUnsafeState = true; g_pCompositor->m_bUnsafeState = true;
@@ -196,10 +193,8 @@ void CMonitor::onDisconnect() {
return; return;
} }
const auto BACKUPWORKSPACE = BACKUPMON->activeWorkspace > 0 ? std::to_string(BACKUPMON->activeWorkspace) : "name:" + g_pCompositor->getWorkspaceByID(BACKUPMON->activeWorkspace)->m_szName;
// snap cursor // snap cursor
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f, BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f); wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f, BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f);
// move workspaces // move workspaces
std::deque<CWorkspace*> wspToMove; std::deque<CWorkspace*> wspToMove;
@@ -224,13 +219,13 @@ void CMonitor::onDisconnect() {
wlr_output_commit(output); wlr_output_commit(output);
g_pCompositor->m_vWorkspaces.erase(std::remove_if(g_pCompositor->m_vWorkspaces.begin(), g_pCompositor->m_vWorkspaces.end(), [&](std::unique_ptr<CWorkspace>& el) { return el->m_iMonitorID == ID; })); std::erase_if(g_pCompositor->m_vWorkspaces, [&](std::unique_ptr<CWorkspace>& el) { return el->m_iMonitorID == ID; });
Debug::log(LOG, "Removed monitor %s!", szName.c_str()); Debug::log(LOG, "Removed monitor %s!", szName.c_str());
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName}); g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName});
g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::shared_ptr<CMonitor>& el) { return el.get() == this; })); std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr<CMonitor>& el) { return el.get() == this; });
} }
void CMonitor::addDamage(pixman_region32_t* rg) { void CMonitor::addDamage(pixman_region32_t* rg) {
@@ -240,3 +235,136 @@ void CMonitor::addDamage(pixman_region32_t* rg) {
void CMonitor::addDamage(wlr_box* box) { void CMonitor::addDamage(wlr_box* box) {
wlr_output_damage_add_box(damage, box); wlr_output_damage_add_box(damage, box);
} }
bool CMonitor::isMirror() {
return pMirrorOf != nullptr;
}
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
// Workspace
std::string newDefaultWorkspaceName = "";
int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_vWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
}
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
Debug::log(LOG, "New monitor: WORKSPACEID %d, exists: %d", WORKSPACEID, (int)(PNEWWORKSPACE != nullptr));
if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor
g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this);
activeWorkspace = PNEWWORKSPACE->m_iID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
PNEWWORKSPACE->startAnim(true, true, true);
} else {
if (newDefaultWorkspaceName == "")
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(ID, newDefaultWorkspaceName)).get();
// We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str());
PNEWWORKSPACE->m_iID = WORKSPACEID;
}
activeWorkspace = PNEWWORKSPACE->m_iID;
g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle);
PNEWWORKSPACE->setActive(true);
}
void CMonitor::setMirror(const std::string& mirrorOf) {
const auto PMIRRORMON = g_pCompositor->getMonitorFromString(mirrorOf);
if (PMIRRORMON == pMirrorOf)
return;
if (PMIRRORMON && PMIRRORMON->isMirror()) {
Debug::log(ERR, "Cannot mirror a mirror!");
return;
}
if (PMIRRORMON == this) {
Debug::log(ERR, "Cannot mirror self!");
return;
}
if (!PMIRRORMON) {
// disable mirroring
if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; }));
}
pMirrorOf = nullptr;
// set rule
const auto RULE = g_pConfigManager->getMonitorRuleFor(this->szName, this->output->description ? this->output->description : "");
vecPosition = RULE.offset;
// push to mvmonitors
if (!m_pThisWrap) {
// find the wrap
for (auto& m : g_pCompositor->m_vRealMonitors) {
if (m->ID == ID) {
m_pThisWrap = &m;
break;
}
}
}
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()) {
g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
}
setupDefaultWS(RULE);
g_pHyprRenderer->applyMonitorRule(this, (SMonitorRule*)&RULE, true); // will apply the offset and stuff
} else {
CMonitor* BACKUPMON = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) {
if (m.get() != this) {
BACKUPMON = m.get();
break;
}
}
// move all the WS
std::deque<CWorkspace*> wspToMove;
for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == ID) {
wspToMove.push_back(w.get());
}
}
for (auto& w : wspToMove) {
g_pCompositor->moveWorkspaceToMonitor(w, BACKUPMON);
w->startAnim(true, true, true);
}
activeWorkspace = -1;
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
vecPosition = Vector2D(-1337420, -1337420);
pMirrorOf = PMIRRORMON;
pMirrorOf->mirrors.push_back(this);
// remove from mvmonitors
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) != g_pCompositor->m_vMonitors.end()) {
g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](const auto& other) { return other.get() == this; }));
}
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
}
}

View File

@@ -7,9 +7,11 @@
#include <array> #include <array>
#include <memory> #include <memory>
struct SMonitorRule;
class CMonitor { class CMonitor {
public: public:
Vector2D vecPosition = Vector2D(0,0); Vector2D vecPosition = Vector2D(-1,-1); // means unset
Vector2D vecSize = Vector2D(0,0); Vector2D vecSize = Vector2D(0,0);
Vector2D vecPixelSize = Vector2D(0,0); Vector2D vecPixelSize = Vector2D(0,0);
Vector2D vecTransformedSize = Vector2D(0,0); Vector2D vecTransformedSize = Vector2D(0,0);
@@ -35,8 +37,17 @@ public:
bool scheduledRecalc = false; bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
// for the special workspace bool dpmsStatus = true;
bool specialWorkspaceOpen = false; bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
bool createdByUser = false;
// mirroring
CMonitor* pMirrorOf = nullptr;
std::vector<CMonitor*> mirrors;
// for the special workspace. 0 means not open.
int specialWorkspaceID = 0;
// Double-linked list because we need to have constant mem addresses for signals // Double-linked list because we need to have constant mem addresses for signals
// We have to store pointers and use raw new/delete because they might be moved between them // We have to store pointers and use raw new/delete because they might be moved between them
@@ -45,7 +56,7 @@ public:
DYNLISTENER(monitorFrame); DYNLISTENER(monitorFrame);
DYNLISTENER(monitorDestroy); DYNLISTENER(monitorDestroy);
DYNLISTENER(monitorMode); DYNLISTENER(monitorStateRequest);
// hack: a group = workspaces on a monitor. // hack: a group = workspaces on a monitor.
// I don't really care lol :P // I don't really care lol :P
@@ -57,6 +68,8 @@ public:
void onDisconnect(); void onDisconnect();
void addDamage(pixman_region32_t* rg); void addDamage(pixman_region32_t* rg);
void addDamage(wlr_box* box); void addDamage(wlr_box* box);
void setMirror(const std::string&);
bool isMirror();
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr; std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
bool m_bEnabled = false; bool m_bEnabled = false;
@@ -67,4 +80,7 @@ public:
bool operator==(const CMonitor& rhs) { bool operator==(const CMonitor& rhs) {
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName; return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
} }
private:
void setupDefaultWS(const SMonitorRule&);
}; };

View File

@@ -3,8 +3,8 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) { void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) {
*lx += node->pSurface->sx; *lx += node->pSurface->current.dx;
*ly += node->pSurface->sy; *ly += node->pSurface->current.dy;
if (node->offsetfn) { if (node->offsetfn) {
// This is the root node // This is the root node
@@ -101,6 +101,14 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) {
g_pHyprRenderer->damageBox(&extents); g_pHyprRenderer->damageBox(&extents);
} }
// remove references to this node
for (auto& tn : surfaceTreeNodes) {
for (auto& cs : tn.childSubsurfaces) {
if (cs.pChild == pNode)
cs.pChild = nullptr;
}
}
surfaceTreeNodes.remove(*pNode); surfaceTreeNodes.remove(*pNode);
Debug::log(LOG, "SurfaceTree Node removed"); Debug::log(LOG, "SurfaceTree Node removed");
@@ -139,6 +147,9 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
PNEWSUBSURFACE->pWindowOwner = pNode->pWindowOwner; PNEWSUBSURFACE->pWindowOwner = pNode->pWindowOwner;
if (PSUBSURFACE->mapped)
listener_mapSubsurface(PNEWSUBSURFACE, nullptr);
wlr_subsurface* existingWlrSubsurface; wlr_subsurface* existingWlrSubsurface;
wl_list_for_each(existingWlrSubsurface, &PSUBSURFACE->surface->current.subsurfaces_below, current.link) { wl_list_for_each(existingWlrSubsurface, &PSUBSURFACE->surface->current.subsurfaces_below, current.link) {
listener_newSubsurfaceNode(pNode, existingWlrSubsurface); listener_newSubsurfaceNode(pNode, existingWlrSubsurface);
@@ -151,6 +162,9 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
void Events::listener_mapSubsurface(void* owner, void* data) { void Events::listener_mapSubsurface(void* owner, void* data) {
SSubsurface* subsurface = (SSubsurface*)owner; SSubsurface* subsurface = (SSubsurface*)owner;
if (subsurface->pChild)
return;
Debug::log(LOG, "Subsurface %x mapped", subsurface->pSubsurface); Debug::log(LOG, "Subsurface %x mapped", subsurface->pSubsurface);
subsurface->pChild = createSubsurfaceNode(subsurface->pParent, subsurface, subsurface->pSubsurface->surface, subsurface->pWindowOwner); subsurface->pChild = createSubsurfaceNode(subsurface->pParent, subsurface, subsurface->pSubsurface->surface, subsurface->pWindowOwner);
@@ -164,21 +178,23 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
if (subsurface->pChild) { if (subsurface->pChild) {
const auto PNODE = subsurface->pChild; const auto PNODE = subsurface->pChild;
const auto IT = std::find_if(SubsurfaceTree::surfaceTreeNodes.begin(), SubsurfaceTree::surfaceTreeNodes.end(), [&](const SSurfaceTreeNode& other) { return &other == PNODE; });
if (IT != SubsurfaceTree::surfaceTreeNodes.end()) {
int lx = 0, ly = 0; int lx = 0, ly = 0;
addSurfaceGlobalOffset(PNODE, &lx, &ly); addSurfaceGlobalOffset(PNODE, &lx, &ly);
wlr_box extents = {0}; wlr_box extents = {lx, ly, 0, 0};
if (PNODE->pSurface) { if (PNODE->pSurface) {
wlr_surface_get_extends(PNODE->pSurface, &extents); extents.width = PNODE->pSurface->current.width;
extents.height = PNODE->pSurface->current.height;
extents.x += lx;
extents.y += ly;
g_pHyprRenderer->damageBox(&extents); g_pHyprRenderer->damageBox(&extents);
} }
SubsurfaceTree::destroySurfaceTree(subsurface->pChild); // SubsurfaceTree::destroySurfaceTree(subsurface->pChild);
subsurface->pChild = nullptr; // subsurface->pChild = nullptr;
}
} }
} }
@@ -187,7 +203,7 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
// no damaging if it's not visible // no damaging if it's not visible
if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) { if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) {
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
if (*PLOGDAMAGE) if (*PLOGDAMAGE)
Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner); Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner);
return; return;
@@ -214,8 +230,9 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
void Events::listener_destroySubsurface(void* owner, void* data) { void Events::listener_destroySubsurface(void* owner, void* data) {
SSubsurface* subsurface = (SSubsurface*)owner; SSubsurface* subsurface = (SSubsurface*)owner;
if (subsurface->pChild) if (subsurface->pChild) {
listener_destroySubsurfaceNode(subsurface->pChild, nullptr); SubsurfaceTree::destroySurfaceTree(subsurface->pChild);
}
Debug::log(LOG, "Subsurface %x destroyed", subsurface); Debug::log(LOG, "Subsurface %x destroyed", subsurface);

View File

@@ -35,6 +35,10 @@ class Vector2D {
return a.x != x || a.y != y; return a.x != x || a.y != y;
} }
Vector2D operator*(const Vector2D& a) const {
return Vector2D(this->x * a.x, this->y * a.y);
}
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D()); Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D());
Vector2D floor(); Vector2D floor();

View File

@@ -4,4 +4,5 @@
SLayerSurface::SLayerSurface() { SLayerSurface::SLayerSurface() {
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE); alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
alpha.m_pLayer = this; alpha.m_pLayer = this;
alpha.registerVar();
} }

View File

@@ -70,9 +70,13 @@ struct SRenderData {
// for blurring // for blurring
bool blur = false; bool blur = false;
bool blockBlurOptimization = false;
// only for windows, not popups // only for windows, not popups
bool squishOversized = true; bool squishOversized = true;
// for calculating UV
CWindow* pWindow = nullptr;
}; };
struct SExtensionFindingData { struct SExtensionFindingData {
@@ -128,6 +132,8 @@ struct SMouse {
bool virt = false; bool virt = false;
bool connected = false; // means connected to the cursor
DYNLISTENER(commitConstraint); DYNLISTENER(commitConstraint);
DYNLISTENER(destroyMouse); DYNLISTENER(destroyMouse);
@@ -319,3 +325,28 @@ struct SIMEPopup {
return pSurface == other.pSurface; return pSurface == other.pSurface;
} }
}; };
struct STouchDevice {
wlr_input_device* pWlrDevice = nullptr;
std::string name = "";
std::string boundOutput = "";
DYNLISTENER(destroy);
bool operator==(const STouchDevice& other) {
return pWlrDevice == other.pWlrDevice;
}
};
struct SSwitchDevice {
wlr_input_device* pWlrDevice = nullptr;
DYNLISTENER(destroy);
DYNLISTENER(toggle);
bool operator==(const SSwitchDevice& other) {
return pWlrDevice == other.pWlrDevice;
}
};

View File

@@ -26,11 +26,14 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
} }
m_vRenderOffset.m_pWorkspace = this; m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE); m_vRenderOffset.create(AVARTYPE_VECTOR, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
m_fAlpha.m_pWorkspace = this; m_fAlpha.m_pWorkspace = this;
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE); m_fAlpha.create(AVARTYPE_FLOAT, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(255.f); m_fAlpha.setValueAndWarp(255.f);
m_vRenderOffset.registerVar();
m_fAlpha.registerVar();
g_pEventManager->postEvent({"createworkspace", m_szName}, true); g_pEventManager->postEvent({"createworkspace", m_szName}, true);
} }
@@ -91,6 +94,15 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
m_vRenderOffset.warp(); m_vRenderOffset.warp();
m_fAlpha.warp(); m_fAlpha.warp();
} }
// check LS-es
if (in && !m_bIsSpecialWorkspace) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
if (!ls->fadingOut)
ls->alpha = m_bHasFullscreenWindow && m_efFullscreenMode == FULLSCREEN_FULL ? 0.f : 255.f;
}
}
} }
void CWorkspace::setActive(bool on) { void CWorkspace::setActive(bool on) {
@@ -120,3 +132,10 @@ void CWorkspace::moveToMonitor(const int& id) {
wlr_ext_workspace_handle_v1_set_name(m_pWlrHandle, m_szName.c_str()); wlr_ext_workspace_handle_v1_set_name(m_pWlrHandle, m_szName.c_str());
} }
CWindow* CWorkspace::getLastFocusedWindow() {
if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->m_iWorkspaceID != m_iID)
return nullptr;
return m_pLastFocusedWindow;
}

View File

@@ -8,6 +8,8 @@ enum eFullscreenMode : uint8_t {
FULLSCREEN_MAXIMIZED FULLSCREEN_MAXIMIZED
}; };
class CWindow;
class CWorkspace { class CWorkspace {
public: public:
CWorkspace(int monitorID, std::string name, bool special = false); CWorkspace(int monitorID, std::string name, bool special = false);
@@ -36,6 +38,9 @@ public:
// "scratchpad" // "scratchpad"
bool m_bIsSpecialWorkspace = false; bool m_bIsSpecialWorkspace = false;
// last window
CWindow* m_pLastFocusedWindow = nullptr;
// user-set // user-set
bool m_bDefaultFloating = false; bool m_bDefaultFloating = false;
bool m_bDefaultPseudo = false; bool m_bDefaultPseudo = false;
@@ -44,4 +49,6 @@ public:
void setActive(bool on); void setActive(bool on);
void moveToMonitor(const int&); void moveToMonitor(const int&);
CWindow* getLastFocusedWindow();
}; };

View File

@@ -0,0 +1,161 @@
#pragma once
#include <wayland-server.h>
typedef unsigned int xcb_atom_t;
struct xcb_icccm_wm_hints_t;
typedef struct {
/** User specified flags */
uint32_t flags;
/** User-specified position */
int32_t x, y;
/** User-specified size */
int32_t width, height;
/** Program-specified minimum size */
int32_t min_width, min_height;
/** Program-specified maximum size */
int32_t max_width, max_height;
/** Program-specified resize increments */
int32_t width_inc, height_inc;
/** Program-specified minimum aspect ratios */
int32_t min_aspect_num, min_aspect_den;
/** Program-specified maximum aspect ratios */
int32_t max_aspect_num, max_aspect_den;
/** Program-specified base size */
int32_t base_width, base_height;
/** Program-specified window gravity */
uint32_t win_gravity;
} xcb_size_hints_t;
typedef unsigned int xcb_window_t;
typedef enum xcb_stack_mode_t {
XCB_STACK_MODE_ABOVE = 0,
XCB_STACK_MODE_BELOW = 1,
XCB_STACK_MODE_TOP_IF = 2,
XCB_STACK_MODE_BOTTOM_IF = 3,
XCB_STACK_MODE_OPPOSITE = 4
} xcb_stack_mode_t;
struct wlr_xwayland {
struct wlr_xwayland_server *server;
struct wlr_xwm *xwm;
struct wlr_xwayland_cursor *cursor;
const char *display_name;
struct wl_display *wl_display;
struct wlr_compositor *compositor;
struct wlr_seat *seat;
void *data;
};
struct wlr_xwayland_surface {
xcb_window_t window_id;
struct wlr_xwm *xwm;
uint32_t surface_id;
struct wl_list link;
struct wl_list stack_link;
struct wl_list unpaired_link;
struct wlr_surface *surface;
int16_t x, y;
uint16_t width, height;
uint16_t saved_width, saved_height;
bool override_redirect;
bool mapped;
char *title;
char *_class;
char *instance;
char *role;
char *startup_id;
pid_t pid;
bool has_utf8_title;
struct wl_list children; // wlr_xwayland_surface::parent_link
struct wlr_xwayland_surface *parent;
struct wl_list parent_link; // wlr_xwayland_surface::children
xcb_atom_t *window_type;
size_t window_type_len;
xcb_atom_t *protocols;
size_t protocols_len;
uint32_t decorations;
xcb_icccm_wm_hints_t *hints;
xcb_size_hints_t *size_hints;
bool pinging;
struct wl_event_source *ping_timer;
// _NET_WM_STATE
bool modal;
bool fullscreen;
bool maximized_vert, maximized_horz;
bool minimized;
bool has_alpha;
struct {
struct wl_signal destroy;
struct wl_signal request_configure;
struct wl_signal request_move;
struct wl_signal request_resize;
struct wl_signal request_minimize;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
struct wl_signal request_activate;
struct wl_signal map;
struct wl_signal unmap;
struct wl_signal set_title;
struct wl_signal set_class;
struct wl_signal set_role;
struct wl_signal set_parent;
struct wl_signal set_pid;
struct wl_signal set_startup_id;
struct wl_signal set_window_type;
struct wl_signal set_hints;
struct wl_signal set_decorations;
struct wl_signal set_override_redirect;
struct wl_signal set_geometry;
struct wl_signal ping_timeout;
} events;
};
struct wlr_xwayland_surface_configure_event {
struct wlr_xwayland_surface *surface;
int16_t x, y;
uint16_t width, height;
uint16_t mask; // xcb_config_window_t
};
struct wlr_xwayland_minimize_event {
struct wlr_xwayland_surface *surface;
bool minimize;
};
inline void wlr_xwayland_destroy(wlr_xwayland*) { }
inline void wlr_xwayland_surface_configure(wlr_xwayland_surface*, int, int, int, int) { }
inline bool wlr_surface_is_xwayland_surface(void*) { return false; }
inline void wlr_xwayland_surface_activate(wlr_xwayland_surface*, bool) { }
inline void wlr_xwayland_surface_restack(wlr_xwayland_surface*, int, xcb_stack_mode_t) { }
inline wlr_xwayland_surface* wlr_xwayland_surface_from_wlr_surface(void*) { return nullptr; }
inline void wlr_xwayland_surface_close(wlr_xwayland_surface*) { }
inline void wlr_xwayland_surface_set_fullscreen(wlr_xwayland_surface*, bool) { }
inline void wlr_xwayland_surface_set_minimized(wlr_xwayland_surface *, bool) { }
inline bool wlr_backend_is_x11(void*) { return false; }
inline void wlr_x11_output_create(void*) { }

View File

@@ -67,10 +67,10 @@ void CHyprError::createQueued() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#ifndef GLES2 #ifndef GLES2
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
#endif #endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);

View File

@@ -22,7 +22,6 @@
#include <filesystem> #include <filesystem>
#include <climits> #include <climits>
#if true #if true
// wlroots uses dumb-ass shit that makes it not compile on C++, let's fix that. // wlroots uses dumb-ass shit that makes it not compile on C++, let's fix that.
// https://github.com/swaywm/wlroots/issues/682 // https://github.com/swaywm/wlroots/issues/682
@@ -37,12 +36,15 @@
extern "C" { extern "C" {
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/libinput.h> #include <wlr/backend/libinput.h>
#include <wlr/backend/drm.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_control_v1.h> #include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h> #include <wlr/types/wlr_gamma_control_v1.h>
@@ -77,13 +79,11 @@ extern "C" {
#include <wlr/types/wlr_foreign_toplevel_management_v1.h> #include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/xwayland.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
#include <wlr/types/wlr_tablet_pad.h> #include <wlr/types/wlr_tablet_pad.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <X11/Xproto.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/render/gles2.h> #include <wlr/render/gles2.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
@@ -98,6 +98,19 @@ extern "C" {
#include <wlr/types/wlr_input_method_v2.h> #include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_text_input_v3.h> #include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_touch.h> #include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_switch.h>
#include <wlr/config.h>
#include <wlr/backend/headless.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#include <drm_fourcc.h>
#ifndef NO_XWAYLAND
#include <wlr/backend/x11.h>
#include <wlr/xwayland.h>
#include <X11/Xproto.h>
#endif
} }
#undef delete #undef delete
@@ -118,6 +131,7 @@ extern "C" {
#ifdef NO_XWAYLAND #ifdef NO_XWAYLAND
#define XWAYLAND false #define XWAYLAND false
#include "helpers/XWaylandStubs.hpp"
#else #else
#define XWAYLAND true #define XWAYLAND true
#endif #endif
@@ -125,6 +139,3 @@ extern "C" {
#include "helpers/Vector2D.hpp" #include "helpers/Vector2D.hpp"
#include "ext-workspace-unstable-v1-protocol.h" #include "ext-workspace-unstable-v1-protocol.h"
#include <algorithm>
#include <utility>

View File

@@ -6,9 +6,11 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force) {
const auto REVERSESPLITRATIO = 2.f - splitRatio; const auto REVERSESPLITRATIO = 2.f - splitRatio;
if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) { static auto *const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); static auto *const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
splitTop = size.y * WIDTHMULTIPLIER > size.x;
if (*PPRESERVESPLIT == 0) {
splitTop = size.y * *PFLMULT > size.x;
} }
const auto SPLITSIDE = !splitTop; const auto SPLITSIDE = !splitTop;
@@ -67,7 +69,7 @@ SDwindleNodeData* SDwindleNodeData::getGroupVisible() {
SDwindleNodeData* current = this->pNextGroupMember; SDwindleNodeData* current = this->pNextGroupMember;
while (current != this) { while (current != this) {
if (!current->pWindow->m_bHidden) { if (!current->pWindow->isHidden()) {
return current; return current;
} }
@@ -81,11 +83,24 @@ void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) {
SDwindleNodeData* current = this->pNextGroupMember; SDwindleNodeData* current = this->pNextGroupMember;
while (current != this) { while (current != this) {
current->pWindow->m_bHidden = current != pMember; current->pWindow->setHidden(current != pMember);
current = current->pNextGroupMember; current = current->pNextGroupMember;
} }
this->pWindow->m_bHidden = pMember != this; this->pWindow->setHidden(pMember != this);
}
int SDwindleNodeData::getGroupMemberCount() {
SDwindleNodeData* current = this->pNextGroupMember;
int no = 1;
while (current != this) {
current = current->pNextGroupMember;
no++;
}
return no;
} }
int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) { int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) {
@@ -129,9 +144,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
CMonitor* PMONITOR = nullptr; CMonitor* PMONITOR = nullptr;
if (pNode->workspaceID == SPECIAL_WORKSPACE_ID) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceOpen) { if (m->specialWorkspaceID == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m.get();
break; break;
} }
@@ -151,14 +166,15 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y); const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const auto GAPSIN = g_pConfigManager->getInt("general:gaps_in"); const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
const auto GAPSOUT = g_pConfigManager->getInt("general:gaps_out"); const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow; const auto PWINDOW = pNode->pWindow;
if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) { if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) {
Debug::log(ERR, "Node %x holding invalid window %x!!", pNode, PWINDOW); Debug::log(ERR, "Node %x holding invalid window %x!!", pNode, PWINDOW);
onWindowRemovedTiling(PWINDOW);
return; return;
} }
@@ -167,29 +183,33 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue; static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE); auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) { const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
PWINDOW->m_vRealPosition = calcPos - Vector2D(BORDERSIZE, BORDERSIZE);
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE) || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.border = false; PWINDOW->m_sSpecialRenderData.border = false;
PWINDOW->m_sSpecialRenderData.decorate = false;
return; return;
} }
PWINDOW->m_sSpecialRenderData.rounding = true; PWINDOW->m_sSpecialRenderData.rounding = true;
PWINDOW->m_sSpecialRenderData.border = true; PWINDOW->m_sSpecialRenderData.border = true;
PWINDOW->m_sSpecialRenderData.decorate = true;
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN, const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
DISPLAYTOP ? GAPSOUT : GAPSIN); DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN, const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
DISPLAYBOTTOM ? GAPSOUT : GAPSIN); DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
calcPos = calcPos + OFFSETTOPLEFT; calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT; calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
@@ -218,7 +238,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
} }
} }
if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
// if special, we adjust the coords a bit // if special, we adjust the coords a bit
static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue; static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue;
@@ -234,6 +254,8 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
} }
if (force) { if (force) {
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->m_vRealPosition.warp(); PWINDOW->m_vRealPosition.warp();
PWINDOW->m_vRealSize.warp(); PWINDOW->m_vRealSize.warp();
@@ -271,7 +293,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
SDwindleNodeData* OPENINGON; SDwindleNodeData* OPENINGON;
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor(); const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && !*PUSEACTIVE) { if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
// happens on reserved area // happens on reserved area
@@ -279,7 +301,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
} else if (*PUSEACTIVE) { } else if (*PUSEACTIVE) {
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) { if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) {
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow); OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
} else { } else {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
@@ -307,6 +329,23 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
return; return;
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, FULLSCREEN_FULL);
}
// last fail-safe to avoid duplicate fullscreens
if ((!OPENINGON || OPENINGON->pWindow == pWindow) && getNodesOnWorkspace(PNODE->workspaceID) > 1) {
for (auto& node : m_lDwindleNodesData) {
if (node.workspaceID == PNODE->workspaceID && node.pWindow != pWindow) {
OPENINGON = &node;
break;
}
}
}
// if it's the first, it's easy. Make it fullscreen. // if it's the first, it's easy. Make it fullscreen.
if (!OPENINGON || OPENINGON->pWindow == pWindow) { if (!OPENINGON || OPENINGON->pWindow == pWindow) {
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
@@ -336,6 +375,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
applyNodeDataToWindow(PNODE); applyNodeDataToWindow(PNODE);
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
return; return;
} }
@@ -351,19 +392,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
NEWPARENT->pParent = OPENINGON->pParent; NEWPARENT->pParent = OPENINGON->pParent;
NEWPARENT->isNode = true; // it is a node NEWPARENT->isNode = true; // it is a node
const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
// if cursor over first child, make it first, etc // if cursor over first child, make it first, etc
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * WIDTHMULTIPLIER; const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
NEWPARENT->splitTop = !SIDEBYSIDE; NEWPARENT->splitTop = !SIDEBYSIDE;
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split"); const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
if (FORCESPLIT == 0) { if (*PFORCESPLIT == 0) {
if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
// we are hovering over the first node, make PNODE first. // we are hovering over the first node, make PNODE first.
NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE; NEWPARENT->children[0] = PNODE;
@@ -373,7 +414,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
NEWPARENT->children[1] = PNODE; NEWPARENT->children[1] = PNODE;
} }
} else { } else {
if (FORCESPLIT == 1) { if (*PFORCESPLIT == 1) {
NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE; NEWPARENT->children[0] = PNODE;
} else { } else {
@@ -394,7 +435,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
// Update the children // Update the children
if (NEWPARENT->size.x * WIDTHMULTIPLIER > NEWPARENT->size.y) { if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
// split left/right // split left/right
OPENINGON->position = NEWPARENT->position; OPENINGON->position = NEWPARENT->position;
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
@@ -426,6 +467,13 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
return; return;
} }
pWindow->m_sSpecialRenderData.rounding = true;
pWindow->m_sSpecialRenderData.border = true;
pWindow->m_sSpecialRenderData.decorate = true;
if (pWindow->m_bIsFullscreen)
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
// check if it was grouped // check if it was grouped
if (PNODE->isGroupMember()) { if (PNODE->isGroupMember()) {
// get shit // get shit
@@ -449,21 +497,25 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
PNEXT->position = PNODE->position; PNEXT->position = PNODE->position;
PNEXT->size = PNODE->size; PNEXT->size = PNODE->size;
applyNodeDataToWindow(PNEXT);
} else { } else {
const auto PHEAD = PNODE->getGroupHead(); const auto PHEAD = PNODE->getGroupHead();
PNEXT->position = PHEAD->position; PNEXT->position = PHEAD->position;
PNEXT->size = PHEAD->size; PNEXT->size = PHEAD->size;
applyNodeDataToWindow(PNEXT);
} }
PNEXT->setGroupFocusedNode(PNEXT); PNEXT->setGroupFocusedNode(PNEXT);
PNEXT->pWindow->m_bHidden = false; PNEXT->pWindow->setHidden(false);
m_lDwindleNodesData.remove(*PNODE); m_lDwindleNodesData.remove(*PNODE);
applyNodeDataToWindow(PNEXT);
if (!PNEXT->isGroupMember()) {
// means we dissolved the group
recalculateMonitor(PNEXT->pWindow->m_iMonitorID);
}
return; return;
} }
@@ -481,6 +533,17 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
PSIBLING->size = PPARENT->size; PSIBLING->size = PPARENT->size;
PSIBLING->pParent = PPARENT->pParent; PSIBLING->pParent = PPARENT->pParent;
if (PSIBLING->isGroupMember()) {
// apply to all group members
SDwindleNodeData* current = PSIBLING->pNextGroupMember;
while (current != PSIBLING) {
current->position = PPARENT->position;
current->size = PPARENT->size;
current = current->pNextGroupMember;
}
}
if (PPARENT->pParent != nullptr) { if (PPARENT->pParent != nullptr) {
if (PPARENT->pParent->children[0] == PPARENT) { if (PPARENT->pParent->children[0] == PPARENT) {
PPARENT->pParent->children[0] = PSIBLING; PPARENT->pParent->children[0] = PSIBLING;
@@ -514,8 +577,8 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceID) {
const auto TOPNODE = getMasterNodeOnWorkspace(SPECIAL_WORKSPACE_ID); const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->specialWorkspaceID);
if (TOPNODE && PMONITOR) { if (TOPNODE && PMONITOR) {
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
@@ -572,7 +635,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const auto PNODE = getNodeFromWindow(PWINDOW); const auto PNODE = getNodeFromWindow(PWINDOW);
if (!PNODE) { if (!PNODE) {
PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999)); PWINDOW->m_vRealSize = Vector2D(std::max((PWINDOW->m_vRealSize.goalv() + pixResize).x, 20.0), std::max((PWINDOW->m_vRealSize.goalv() + pixResize).y, 20.0));
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
return; return;
} }
@@ -609,11 +672,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
if (!PPARENT2) { if (!PPARENT2) {
if (PARENTSIDEBYSIDE) { if (PARENTSIDEBYSIDE) {
allowedMovement.x *= 2.f / PPARENT->size.x; allowedMovement.x *= 2.f / PPARENT->size.x;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f); PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, 0.1, 1.9);
PPARENT->recalcSizePosRecursive(*PANIMATE == 0); PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} else { } else {
allowedMovement.y *= 2.f / PPARENT->size.y; allowedMovement.y *= 2.f / PPARENT->size.y;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f); PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, 0.1, 1.9);
PPARENT->recalcSizePosRecursive(*PANIMATE == 0); PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} }
@@ -628,11 +691,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
if (!PPARENT2) { if (!PPARENT2) {
if (PARENTSIDEBYSIDE) { if (PARENTSIDEBYSIDE) {
allowedMovement.x *= 2.f / PPARENT->size.x; allowedMovement.x *= 2.f / PPARENT->size.x;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f); PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, 0.1, 1.9);
PPARENT->recalcSizePosRecursive(*PANIMATE == 0); PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} else { } else {
allowedMovement.y *= 2.f / PPARENT->size.y; allowedMovement.y *= 2.f / PPARENT->size.y;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f); PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, 0.1, 1.9);
PPARENT->recalcSizePosRecursive(*PANIMATE == 0); PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} }
@@ -646,8 +709,8 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
allowedMovement.x *= 2.f / SIDECONTAINER->size.x; allowedMovement.x *= 2.f / SIDECONTAINER->size.x;
allowedMovement.y *= 2.f / TOPCONTAINER->size.y; allowedMovement.y *= 2.f / TOPCONTAINER->size.y;
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f); SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, 0.1, 1.9);
TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f); TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0); SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0); TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
} }
@@ -656,10 +719,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
if (!g_pCompositor->windowValidMapped(pWindow)) if (!g_pCompositor->windowValidMapped(pWindow))
return; return;
if (!g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
return;
if (on == pWindow->m_bIsFullscreen)
return; // ignore return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
@@ -759,12 +819,13 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow) if (PWORKSPACE->m_bHasFullscreenWindow && !PNODE->isGroupMember()) {
fullscreenRequestForWindow(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), FULLSCREEN_FULL, false); Debug::log(ERR, "Cannot enable group on fullscreen window");
return;
}
if (PNODE->isGroupMember()) { if (PNODE->isGroupMember()) {
// dissolve group // dissolve group
const auto PHEAD = PNODE->getGroupHead(); const auto PHEAD = PNODE->getGroupHead();
SDwindleNodeData* current = PNODE->pNextGroupMember; SDwindleNodeData* current = PNODE->pNextGroupMember;
@@ -782,11 +843,18 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
toAddWindows.push_back(PWINDOW); toAddWindows.push_back(PWINDOW);
PWINDOW->m_bHidden = false; PWINDOW->setHidden(false);
} }
if (PHEAD->pPreviousGroupMember)
PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
if (PHEAD->pNextGroupMember)
PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
PHEAD->pPreviousGroupMember = nullptr; PHEAD->pPreviousGroupMember = nullptr;
PHEAD->pNextGroupMember = nullptr; PHEAD->pNextGroupMember = nullptr;
onWindowRemoved(PHEAD->pWindow); onWindowRemoved(PHEAD->pWindow);
for (auto& pw : toAddWindows) { for (auto& pw : toAddWindows) {
@@ -799,6 +867,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
for (auto& pw : toAddWindows) { for (auto& pw : toAddWindows) {
onWindowCreated(pw); onWindowCreated(pw);
pw->removeDecorationByType(DECORATION_GROUPBAR);
} }
recalculateMonitor(PWORKSPACE->m_iMonitorID); recalculateMonitor(PWORKSPACE->m_iMonitorID);
@@ -858,10 +927,16 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER; newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER; newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
// add the deco
newGroupMembers[i]->pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(newGroupMembers[i]->pWindow));
} }
// focus // focus
PNODE->setGroupFocusedNode(PNODE); PNODE->setGroupFocusedNode(PNODE);
// required for no_gaps_when_only to work
applyNodeDataToWindow(PNODE);
} }
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();
@@ -879,14 +954,15 @@ std::deque<CWindow*> CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) {
// get the node // get the node
const auto PNODE = getNodeFromWindow(pWindow); const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE) if (!PNODE || !PNODE->isGroupMember())
return result; // reject with empty return result; // reject with empty
SDwindleNodeData* current = PNODE->pNextGroupMember; const auto HEAD = PNODE->getGroupHead();
SDwindleNodeData* current = HEAD->pNextGroupMember;
result.push_back(pWindow); result.push_back(HEAD->pWindow);
while (current != PNODE) { while (current != HEAD) {
result.push_back(current->pWindow); result.push_back(current->pWindow);
current = current->pNextGroupMember; current = current->pNextGroupMember;
} }
@@ -894,7 +970,7 @@ std::deque<CWindow*> CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) {
return result; return result;
} }
void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward) { void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWindow* forceTo) {
if (!g_pCompositor->windowValidMapped(pWindow)) if (!g_pCompositor->windowValidMapped(pWindow))
return; // reject return; // reject
@@ -912,10 +988,18 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward) {
else else
pNewNode = PNODE->pPreviousGroupMember; pNewNode = PNODE->pPreviousGroupMember;
if (forceTo) {
const auto NODETO = getNodeFromWindow(forceTo);
if (NODETO)
pNewNode = NODETO;
}
PNODE->setGroupFocusedNode(pNewNode); PNODE->setGroupFocusedNode(pNewNode);
pNewNode->position = PNODE->position; pNewNode->position = PNODE->position;
pNewNode->size = PNODE->size; pNewNode->size = PNODE->size;
pNewNode->workspaceID = PNODE->workspaceID;
applyNodeDataToWindow(pNewNode); applyNodeDataToWindow(pNewNode);
@@ -927,14 +1011,19 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward) {
pNewNode->pWindow->m_bIsFloating = PNODE->pWindow->m_bIsFloating; pNewNode->pWindow->m_bIsFloating = PNODE->pWindow->m_bIsFloating;
if (PNODE->pWindow->m_bIsFullscreen) { if (PNODE->pWindow->m_bIsFullscreen) {
PNODE->pWindow->m_bHidden = false; PNODE->pWindow->setHidden(false);
g_pCompositor->setWindowFullscreen(PNODE->pWindow, false, PWORKSPACE->m_efFullscreenMode); g_pCompositor->setWindowFullscreen(PNODE->pWindow, false, PWORKSPACE->m_efFullscreenMode);
PNODE->pWindow->m_bHidden = true; PNODE->pWindow->setHidden(true);
g_pCompositor->setWindowFullscreen(pNewNode->pWindow, true, PWORKSPACE->m_efFullscreenMode); g_pCompositor->setWindowFullscreen(pNewNode->pWindow, true, PWORKSPACE->m_efFullscreenMode);
pNewNode->pWindow->m_vRealSize.warp(); pNewNode->pWindow->m_vRealSize.warp();
pNewNode->pWindow->m_vRealPosition.warp(); pNewNode->pWindow->m_vRealPosition.warp();
} }
pNewNode->pWindow->updateWindowDecos();
PNODE->pWindow->updateWindowDecos();
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID));
} }
SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow) { SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow) {
@@ -942,6 +1031,9 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
SWindowRenderLayoutHints hints; SWindowRenderLayoutHints hints;
static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
const auto PNODE = getNodeFromWindow(pWindow); const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE) if (!PNODE)
return hints; // left for the future, maybe floating funkiness return hints; // left for the future, maybe floating funkiness
@@ -950,9 +1042,9 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
hints.isBorderColor = true; hints.isBorderColor = true;
if (pWindow == g_pCompositor->m_pLastWindow) if (pWindow == g_pCompositor->m_pLastWindow)
hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")); hints.borderColor = CColor(*PGROUPCOLACTIVE);
else else
hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border")); hints.borderColor = CColor(*PGROUPCOLINACTIVE);
} }
return hints; return hints;
@@ -961,18 +1053,33 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) { void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
// windows should be valid, insallah // windows should be valid, insallah
const auto PNODE = getNodeFromWindow(pWindow); auto PNODE = getNodeFromWindow(pWindow);
const auto PNODE2 = getNodeFromWindow(pWindow2); auto PNODE2 = getNodeFromWindow(pWindow2);
if (!PNODE2 || !PNODE) if (!PNODE2 || !PNODE) {
return;
if (PNODE->workspaceID != PNODE2->workspaceID) {
Debug::log(ERR, "Dwindle: Rejecting a swap between workspaces");
return; return;
} }
// we will not delete the nodes, just fix the tree SDwindleNodeData* ACTIVE1 = nullptr;
SDwindleNodeData* ACTIVE2 = nullptr;
if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
if (PNODE->workspaceID != PNODE2->workspaceID) {
Debug::log(ERR, "Groups are confined to a monitor");
return;
}
if (PNODE->isGroupMember()) {
ACTIVE1 = PNODE;
PNODE = PNODE->getGroupHead();
}
if (PNODE2->isGroupMember()) {
ACTIVE2 = PNODE2;
PNODE2 = PNODE2->getGroupHead();
}
if (PNODE2->pParent == PNODE->pParent) { if (PNODE2->pParent == PNODE->pParent) {
const auto PPARENT = PNODE->pParent; const auto PPARENT = PNODE->pParent;
@@ -1009,10 +1116,41 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
PNODE2->pParent = PNODE->pParent; PNODE2->pParent = PNODE->pParent;
PNODE->pParent = PPARENTNODE2; PNODE->pParent = PPARENTNODE2;
// these are window nodes, so no children. std::swap(PNODE2->workspaceID, PNODE->workspaceID);
} else {
// swap the windows and recalc
PNODE2->pWindow = pWindow;
PNODE->pWindow = pWindow2;
}
if (PNODE->workspaceID != PNODE2->workspaceID) {
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
}
// recalc the workspace // recalc the workspace
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive(); getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
if (PNODE2->workspaceID != PNODE->workspaceID) {
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
}
if (ACTIVE1) {
ACTIVE1->position = PNODE->position;
ACTIVE1->size = PNODE->size;
ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
}
if (ACTIVE2) {
ACTIVE2->position = PNODE2->position;
ACTIVE2->size = PNODE2->size;
ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
}
g_pHyprRenderer->damageWindow(pWindow);
g_pHyprRenderer->damageWindow(pWindow2);
} }
void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) { void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
@@ -1020,7 +1158,7 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
const auto PNODE = getNodeFromWindow(pWindow); const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE || !PNODE->pParent) if (!PNODE || !PNODE->pParent || (PNODE->isGroupMember() && PNODE->getGroupMemberCount() == g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID)))
return; return;
PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f); PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f);
@@ -1038,7 +1176,7 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
else if (message == "togglesplit") else if (message == "togglesplit")
toggleSplit(header.pWindow); toggleSplit(header.pWindow);
else if (message == "groupinfo") { else if (message == "groupinfo") {
auto res = getGroupMembers(g_pCompositor->m_pLastWindow); auto res = getGroupMembers(header.pWindow ? header.pWindow : g_pCompositor->m_pLastWindow);
return res; return res;
} }
@@ -1062,7 +1200,7 @@ std::string CHyprDwindleLayout::getLayoutName() {
void CHyprDwindleLayout::onEnable() { void CHyprDwindleLayout::onEnable() {
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->m_bHidden) if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->isHidden())
continue; continue;
onWindowCreatedTiling(w.get()); onWindowCreatedTiling(w.get());

View File

@@ -41,6 +41,7 @@ struct SDwindleNodeData {
bool isGroupMember(); bool isGroupMember();
SDwindleNodeData* getGroupHead(); SDwindleNodeData* getGroupHead();
SDwindleNodeData* getGroupVisible(); SDwindleNodeData* getGroupVisible();
int getGroupMemberCount();
void setGroupFocusedNode(SDwindleNodeData*); void setGroupFocusedNode(SDwindleNodeData*);
CHyprDwindleLayout* layout = nullptr; CHyprDwindleLayout* layout = nullptr;
}; };
@@ -74,7 +75,7 @@ private:
SDwindleNodeData* getMasterNodeOnWorkspace(const int&); SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
void toggleWindowGroup(CWindow*); void toggleWindowGroup(CWindow*);
void switchGroupWindow(CWindow*, bool forward); void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
void toggleSplit(CWindow*); void toggleSplit(CWindow*);
std::deque<CWindow*> getGroupMembers(CWindow*); std::deque<CWindow*> getGroupMembers(CWindow*);

View File

@@ -21,11 +21,17 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow) {
} }
void IHyprLayout::onWindowRemoved(CWindow* pWindow) { void IHyprLayout::onWindowRemoved(CWindow* pWindow) {
if (pWindow->m_bIsFullscreen)
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
if (pWindow->m_bIsFloating) { if (pWindow->m_bIsFloating) {
onWindowRemovedFloating(pWindow); onWindowRemovedFloating(pWindow);
} else { } else {
onWindowRemovedTiling(pWindow); onWindowRemovedTiling(pWindow);
} }
if (pWindow == m_pLastTiledWindow)
m_pLastTiledWindow = nullptr;
} }
void IHyprLayout::onWindowRemovedFloating(CWindow* pWindow) { void IHyprLayout::onWindowRemovedFloating(CWindow* pWindow) {
@@ -47,7 +53,7 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height); pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms? if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms?
pWindow->m_bHidden = true; pWindow->setHidden(true);
return; return;
} }
@@ -64,8 +70,24 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
// check if it's on the correct monitor! // check if it's on the correct monitor!
Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f; Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f;
// check if it's visible on any monitor (only for XDG)
bool visible = pWindow->m_bIsX11;
if (!pWindow->m_bIsX11) {
for (auto& m : g_pCompositor->m_vMonitors) {
if (VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|| VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|| VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|| VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)) {
visible = true;
break;
}
}
}
// TODO: detect a popup in a more consistent way. // TODO: detect a popup in a more consistent way.
if ((desiredGeometry.x == 0 && desiredGeometry.y == 0)) { if ((desiredGeometry.x == 0 && desiredGeometry.y == 0) || !visible) {
// if it's not, fall back to the center placement // if it's not, fall back to the center placement
pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f); pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f);
} else { } else {
@@ -115,13 +137,15 @@ void IHyprLayout::onBeginDragWindow() {
return; return;
} }
g_pInputManager->setCursorImageUntilUnset("hand1");
DRAGGINGWINDOW->m_vRealPosition.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove")); DRAGGINGWINDOW->m_vRealPosition.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
DRAGGINGWINDOW->m_vRealSize.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove")); DRAGGINGWINDOW->m_vRealSize.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
DRAGGINGWINDOW->m_bDraggingTiled = false; DRAGGINGWINDOW->m_bDraggingTiled = false;
if (!DRAGGINGWINDOW->m_bIsFloating) { if (!DRAGGINGWINDOW->m_bIsFloating) {
if (g_pInputManager->dragButton == BTN_LEFT) { if (g_pInputManager->dragMode == MBIND_MOVE) {
changeWindowFloatingMode(DRAGGINGWINDOW); changeWindowFloatingMode(DRAGGINGWINDOW);
DRAGGINGWINDOW->m_bIsFloating = true; DRAGGINGWINDOW->m_bIsFloating = true;
DRAGGINGWINDOW->m_bDraggingTiled = true; DRAGGINGWINDOW->m_bDraggingTiled = true;
@@ -135,6 +159,21 @@ void IHyprLayout::onBeginDragWindow() {
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv(); m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
m_vLastDragXY = m_vBeginDragXY; m_vLastDragXY = m_vBeginDragXY;
// get the grab corner
if (m_vBeginDragXY.x < m_vBeginDragPositionXY.x + m_vBeginDragSizeXY.x / 2.0) {
// left
if (m_vBeginDragXY.y < m_vBeginDragPositionXY.y + m_vBeginDragSizeXY.y / 2.0)
m_iGrabbedCorner = 0;
else
m_iGrabbedCorner = 4;
} else {
// right
if (m_vBeginDragXY.y < m_vBeginDragPositionXY.y + m_vBeginDragSizeXY.y / 2.0)
m_iGrabbedCorner = 1;
else
m_iGrabbedCorner = 3;
}
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
// shadow to ignore any bound to MAIN_MOD // shadow to ignore any bound to MAIN_MOD
@@ -147,12 +186,17 @@ void IHyprLayout::onEndDragWindow() {
if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW)) if (!g_pCompositor->windowValidMapped(DRAGGINGWINDOW))
return; return;
g_pInputManager->unsetCursorImage();
if (DRAGGINGWINDOW->m_bDraggingTiled) { if (DRAGGINGWINDOW->m_bDraggingTiled) {
DRAGGINGWINDOW->m_bIsFloating = false; DRAGGINGWINDOW->m_bIsFloating = false;
g_pInputManager->refocus();
changeWindowFloatingMode(DRAGGINGWINDOW); changeWindowFloatingMode(DRAGGINGWINDOW);
} }
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
g_pCompositor->focusWindow(DRAGGINGWINDOW);
} }
void IHyprLayout::onMouseMove(const Vector2D& mousePos) { void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
@@ -176,20 +220,46 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
if (g_pInputManager->dragButton == BTN_LEFT) { if (g_pInputManager->dragMode == MBIND_MOVE) {
if (*PANIMATE) {
DRAGGINGWINDOW->m_vRealPosition = m_vBeginDragPositionXY + DELTA;
} else {
DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(m_vBeginDragPositionXY + DELTA); DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(m_vBeginDragPositionXY + DELTA);
}
g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv()); g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv());
} else { } else if (g_pInputManager->dragMode == MBIND_RESIZE) {
if (DRAGGINGWINDOW->m_bIsFloating) { if (DRAGGINGWINDOW->m_bIsFloating) {
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(DRAGGINGWINDOW); const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(DRAGGINGWINDOW);
// calc the new size and pos
Vector2D newSize = m_vBeginDragSizeXY;
Vector2D newPos = m_vBeginDragPositionXY;
if (m_iGrabbedCorner == 3) {
newSize = newSize + DELTA;
} else if (m_iGrabbedCorner == 0) {
newSize = newSize - DELTA;
newPos = newPos + DELTA;
} else if (m_iGrabbedCorner == 1) {
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
newPos = newPos + Vector2D(0, DELTA.y);
} else if (m_iGrabbedCorner == 4) {
newSize = newSize + Vector2D(-DELTA.x, DELTA.y);
newPos = newPos + Vector2D(DELTA.x, 0);
}
newSize = newSize.clamp(Vector2D(20,20), MAXSIZE);
if (*PANIMATE) { if (*PANIMATE) {
DRAGGINGWINDOW->m_vRealSize = Vector2D(std::clamp(m_vBeginDragSizeXY.x + DELTA.x, (double)20, (double)MAXSIZE.x), std::clamp(m_vBeginDragSizeXY.y + DELTA.y, (double)20, (double)MAXSIZE.y)); DRAGGINGWINDOW->m_vRealSize = newSize;
DRAGGINGWINDOW->m_vRealPosition = newPos;
} else { } else {
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA); DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(newSize);
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().x, (double)20, (double)MAXSIZE.x), std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().y, (double)20, (double)MAXSIZE.y))); DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(newPos);
} }
g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv()); g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv());
@@ -226,6 +296,8 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
return; return;
} }
pWindow->m_bPinned = false;
const auto TILED = isWindowTiled(pWindow); const auto TILED = isWindowTiled(pWindow);
if (!TILED) { if (!TILED) {
@@ -234,14 +306,17 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
pWindow->moveToWorkspace(PNEWMON->activeWorkspace); pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
// save real pos cuz the func applies the default 5,5 mid // save real pos cuz the func applies the default 5,5 mid
const auto PSAVEDPOS = pWindow->m_vRealPosition.vec(); const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
const auto PSAVEDSIZE = pWindow->m_vRealSize.vec(); const auto PSAVEDSIZE = pWindow->m_vRealSize.goalv();
// if the window is pseudo, update its size // if the window is pseudo, update its size
pWindow->m_vPseudoSize = pWindow->m_vRealSize.vec(); pWindow->m_vPseudoSize = pWindow->m_vRealSize.goalv();
pWindow->m_vLastFloatingSize = PSAVEDSIZE; pWindow->m_vLastFloatingSize = PSAVEDSIZE;
// move to narnia because we don't wanna find our own node. onWindowCreatedTiling should apply the coords back.
pWindow->m_vPosition = Vector2D(-999999, -999999);
onWindowCreatedTiling(pWindow); onWindowCreatedTiling(pWindow);
pWindow->m_vRealPosition.setValue(PSAVEDPOS); pWindow->m_vRealPosition.setValue(PSAVEDPOS);
@@ -249,20 +324,26 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
// fix pseudo leaving artifacts // fix pseudo leaving artifacts
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
} else {
pWindow->m_vSize = pWindow->m_vRealSize.vec();
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
if (pWindow == g_pCompositor->m_pLastWindow)
m_pLastTiledWindow = pWindow;
} else {
onWindowRemovedTiling(pWindow); onWindowRemovedTiling(pWindow);
g_pCompositor->moveWindowToTop(pWindow); g_pCompositor->moveWindowToTop(pWindow);
pWindow->m_vRealPosition = pWindow->m_vRealPosition.vec() + (pWindow->m_vRealSize.vec() - pWindow->m_vLastFloatingSize) / 2.f; pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f;
pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
pWindow->m_vSize = pWindow->m_vRealSize.goalv();
pWindow->m_vPosition = pWindow->m_vRealPosition.goalv();
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
pWindow->m_sSpecialRenderData.rounding = true; pWindow->m_sSpecialRenderData.rounding = true;
if (pWindow == m_pLastTiledWindow)
m_pLastTiledWindow = nullptr;
} }
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
@@ -285,3 +366,59 @@ void IHyprLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) {
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
} }
void IHyprLayout::onWindowFocusChange(CWindow* pNewFocus) {
m_pLastTiledWindow = pNewFocus && !pNewFocus->m_bIsFloating ? pNewFocus : m_pLastTiledWindow;
}
CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
// although we don't expect nullptrs here, let's verify jic
if (!pWindow)
return nullptr;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
// first of all, if this is a fullscreen workspace,
if (PWORKSPACE->m_bHasFullscreenWindow)
return g_pCompositor->getFullscreenWindowOnWorkspace(pWindow->m_iWorkspaceID);
if (pWindow->m_bIsFloating) {
// find whether there is a floating window below this one
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus) {
if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x, w->m_vPosition.y + w->m_vSize.y)) {
return w.get();
}
}
}
// let's try the last tiled window.
if (m_pLastTiledWindow && m_pLastTiledWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID)
return m_pLastTiledWindow;
// if we don't, let's try to find any window that is in the middle
if (const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f); PWINDOWCANDIDATE)
return PWINDOWCANDIDATE;
// if not, floating window
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus)
return w.get();
}
// if there is no candidate, too bad
return nullptr;
}
// if it was a tiled window, we first try to find the window that will replace it.
const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f);
if (!PWINDOWCANDIDATE || pWindow == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->isHidden() || PWINDOWCANDIDATE->m_bX11ShouldntFocus || PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
return nullptr;
return PWINDOWCANDIDATE;
}
IHyprLayout::~IHyprLayout() {
}

View File

@@ -16,6 +16,7 @@ enum eFullscreenMode : uint8_t;
interface IHyprLayout { interface IHyprLayout {
public: public:
virtual ~IHyprLayout() = 0;
virtual void onEnable() = 0; virtual void onEnable() = 0;
virtual void onDisable() = 0; virtual void onDisable() = 0;
@@ -123,9 +124,22 @@ public:
*/ */
virtual std::string getLayoutName() = 0; virtual std::string getLayoutName() = 0;
/*
Called for getting the next candidate for a focus
*/
virtual CWindow* getNextWindowCandidate(CWindow*);
/*
Internal: called when window focus changes
*/
virtual void onWindowFocusChange(CWindow*);
private: private:
Vector2D m_vBeginDragXY; Vector2D m_vBeginDragXY;
Vector2D m_vLastDragXY; Vector2D m_vLastDragXY;
Vector2D m_vBeginDragPositionXY; Vector2D m_vBeginDragPositionXY;
Vector2D m_vBeginDragSizeXY; Vector2D m_vBeginDragSizeXY;
int m_iGrabbedCorner = 0;
CWindow* m_pLastTiledWindow = nullptr;
}; };

View File

@@ -20,6 +20,16 @@ int CHyprMasterLayout::getNodesOnWorkspace(const int& ws) {
return no; return no;
} }
int CHyprMasterLayout::getMastersOnWorkspace(const int& ws) {
int no = 0;
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == ws && n.isMaster)
no++;
}
return no;
}
std::string CHyprMasterLayout::getLayoutName() { std::string CHyprMasterLayout::getLayoutName() {
return "Master"; return "Master";
} }
@@ -84,6 +94,13 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
} }
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, FULLSCREEN_FULL);
}
// recalc // recalc
recalculateMonitor(pWindow->m_iMonitorID); recalculateMonitor(pWindow->m_iMonitorID);
} }
@@ -94,10 +111,19 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
if (!PNODE) if (!PNODE)
return; return;
if (PNODE->isMaster) { pWindow->m_sSpecialRenderData.rounding = true;
pWindow->m_sSpecialRenderData.border = true;
pWindow->m_sSpecialRenderData.decorate = true;
if (pWindow->m_bIsFullscreen)
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
const auto MASTERSLEFT = getMastersOnWorkspace(PNODE->workspaceID);
if (PNODE->isMaster && MASTERSLEFT < 2) {
// find new one // find new one
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (!nd.isMaster) { if (!nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
nd.isMaster = true; nd.isMaster = true;
break; break;
} }
@@ -106,6 +132,15 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
m_lMasterNodesData.remove(*PNODE); m_lMasterNodesData.remove(*PNODE);
if (getMastersOnWorkspace(PNODE->workspaceID) == getNodesOnWorkspace(PNODE->workspaceID) && MASTERSLEFT > 1) {
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->workspaceID == PNODE->workspaceID) {
it->isMaster = false;
break;
}
}
}
recalculateMonitor(pWindow->m_iMonitorID); recalculateMonitor(pWindow->m_iMonitorID);
} }
@@ -118,8 +153,8 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceID) {
calculateWorkspace(SPECIAL_WORKSPACE_ID); calculateWorkspace(PMONITOR->specialWorkspaceID);
} }
if (PWORKSPACE->m_bHasFullscreenWindow) { if (PWORKSPACE->m_bHasFullscreenWindow) {
@@ -159,32 +194,52 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
if (!PMASTERNODE) if (!PMASTERNODE)
return; return;
const auto MASTERS = getMastersOnWorkspace(PWORKSPACE->m_iID);
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) { if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition; PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y); PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
applyNodeDataToWindow(PMASTERNODE); applyNodeDataToWindow(PMASTERNODE);
return; return;
} else { } else {
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition; float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
PMASTERNODE->size = Vector2D((PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y); int nodesLeft = MASTERS;
float nextY = 0;
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
float HEIGHT = nodesLeft > 1 ? heightLeft / nodesLeft * n.percSize : heightLeft;
if (HEIGHT > heightLeft * 0.9f && nodesLeft > 1)
HEIGHT = heightLeft * 0.9f;
n.size = Vector2D((PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster, HEIGHT);
nodesLeft--;
heightLeft -= HEIGHT;
nextY += HEIGHT;
applyNodeDataToWindow(&n);
}
}
} }
const auto SLAVESIZE = 1.f / (getNodesOnWorkspace(PWORKSPACE->m_iID) - 1) * (PMASTERNODE->size.y); float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
int slavesDone = 0; int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
float nextY = 0;
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID) if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
continue; continue;
if (nd == *PMASTERNODE) { nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(PMASTERNODE->percMaster * PMONITOR->vecSize.x, nextY);
applyNodeDataToWindow(PMASTERNODE); float HEIGHT = slavesLeft > 1 ? heightLeft / slavesLeft * nd.percSize : heightLeft;
continue; if (HEIGHT > heightLeft * 0.9f && slavesLeft > 1)
} HEIGHT = heightLeft * 0.9f;
nd.size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x, HEIGHT);
nd.position = Vector2D(PMASTERNODE->size.x + PMASTERNODE->position.x, slavesDone * SLAVESIZE + PMASTERNODE->position.y); slavesLeft--;
nd.size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x, SLAVESIZE); heightLeft -= HEIGHT;
nextY += HEIGHT;
slavesDone++;
applyNodeDataToWindow(&nd); applyNodeDataToWindow(&nd);
} }
@@ -193,9 +248,9 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
CMonitor* PMONITOR = nullptr; CMonitor* PMONITOR = nullptr;
if (pNode->workspaceID == SPECIAL_WORKSPACE_ID) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceOpen) { if (m->specialWorkspaceID == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m.get();
break; break;
} }
@@ -215,9 +270,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y); const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const auto GAPSIN = g_pConfigManager->getInt("general:gaps_in"); const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
const auto GAPSOUT = g_pConfigManager->getInt("general:gaps_out"); const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow; const auto PWINDOW = pNode->pWindow;
@@ -231,34 +286,36 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
PWINDOW->m_vSize = pNode->size; PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position; PWINDOW->m_vPosition = pNode->position;
auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE); auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) { if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(BORDERSIZE, BORDERSIZE); PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.border = false; PWINDOW->m_sSpecialRenderData.border = false;
PWINDOW->m_sSpecialRenderData.decorate = false;
return; return;
} }
PWINDOW->m_sSpecialRenderData.rounding = true; PWINDOW->m_sSpecialRenderData.rounding = true;
PWINDOW->m_sSpecialRenderData.border = true; PWINDOW->m_sSpecialRenderData.border = true;
PWINDOW->m_sSpecialRenderData.decorate = true;
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN, const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
DISPLAYTOP ? GAPSOUT : GAPSIN); DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN, const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
DISPLAYBOTTOM ? GAPSOUT : GAPSIN); DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
calcPos = calcPos + OFFSETTOPLEFT; calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT; calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue; static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f; PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
@@ -273,6 +330,8 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
} }
if (m_bForceWarps) { if (m_bForceWarps) {
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->m_vRealPosition.warp(); PWINDOW->m_vRealPosition.warp();
PWINDOW->m_vRealSize.warp(); PWINDOW->m_vRealSize.warp();
@@ -295,13 +354,12 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
const auto PNODE = getNodeFromWindow(PWINDOW); const auto PNODE = getNodeFromWindow(PWINDOW);
if (!PNODE) { if (!PNODE) {
PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999)); PWINDOW->m_vRealSize = Vector2D(std::max((PWINDOW->m_vRealSize.goalv() + pixResize).x, 20.0), std::max((PWINDOW->m_vRealSize.goalv() + pixResize).y, 20.0));
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
return; return;
} }
// get master // get monitor
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) < 2) if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) < 2)
@@ -309,11 +367,24 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
m_bForceWarps = true; m_bForceWarps = true;
float delta = pixResize.x / PMONITOR->vecSize.x; double delta = pixResize.x / PMONITOR->vecSize.x;
PMASTER->percMaster += delta; for (auto& n : m_lMasterNodesData) {
if (n.isMaster && n.workspaceID == PMONITOR->activeWorkspace)
n.percMaster = std::clamp(n.percMaster + delta, 0.05, 0.95);
}
std::clamp(PMASTER->percMaster, 0.05f, 0.95f); // check the up/down resize
if (pixResize.y != 0) {
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
// check master size
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getNodesOnWorkspace(PNODE->workspaceID);
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
}
}
recalculateMonitor(PMONITOR->ID); recalculateMonitor(PMONITOR->ID);
@@ -324,10 +395,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
if (!g_pCompositor->windowValidMapped(pWindow)) if (!g_pCompositor->windowValidMapped(pWindow))
return; return;
if (!g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
return;
if (on == pWindow->m_bIsFullscreen)
return; // ignore return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
@@ -423,16 +491,20 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
return; return;
if (PNODE->workspaceID != PNODE2->workspaceID) { if (PNODE->workspaceID != PNODE2->workspaceID) {
Debug::log(ERR, "Master: Rejecting a swap between workspaces"); std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
return; std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
} }
// massive hack: just swap window pointers, lol // massive hack: just swap window pointers, lol
const auto PWINDOW1 = PNODE->pWindow; PNODE->pWindow = pWindow2;
PNODE->pWindow = PNODE2->pWindow; PNODE2->pWindow = pWindow;
PNODE2->pWindow = PWINDOW1;
recalculateMonitor(PWINDOW1->m_iMonitorID); recalculateMonitor(pWindow->m_iMonitorID);
if (PNODE2->workspaceID != PNODE->workspaceID)
recalculateMonitor(pWindow2->m_iMonitorID);
g_pHyprRenderer->damageWindow(pWindow);
g_pHyprRenderer->damageWindow(pWindow2);
} }
void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) { void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
@@ -450,108 +522,237 @@ void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
recalculateMonitor(pWindow->m_iMonitorID); recalculateMonitor(pWindow->m_iMonitorID);
} }
CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
if (!isWindowTiled(pWindow))
return nullptr;
const auto PNODE = getNodeFromWindow(pWindow);
if (next) {
if (PNODE->isMaster) {
// focus the first non master
for (auto n : m_lMasterNodesData) {
if (n.pWindow != pWindow && n.workspaceID == pWindow->m_iWorkspaceID) {
return n.pWindow;
}
}
} else {
// focus next
bool reached = false;
bool found = false;
for (auto n : m_lMasterNodesData) {
if (n.pWindow == pWindow) {
reached = true;
continue;
}
if (n.workspaceID == pWindow->m_iWorkspaceID && reached) {
return n.pWindow;
}
}
if (!found) {
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
if (PMASTER)
return PMASTER->pWindow;
}
}
} else {
if (PNODE->isMaster) {
// focus the first non master
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->pWindow != pWindow && it->workspaceID == pWindow->m_iWorkspaceID) {
return it->pWindow;
}
}
} else {
// focus next
bool reached = false;
bool found = false;
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->pWindow == pWindow) {
reached = true;
continue;
}
if (it->workspaceID == pWindow->m_iWorkspaceID && reached) {
return it->pWindow;
}
}
if (!found) {
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
if (PMASTER)
return PMASTER->pWindow;
}
}
}
return nullptr;
}
std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::string message) { std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::string message) {
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) { auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
if (!g_pCompositor->windowValidMapped(PWINDOWTOCHANGETO))
return;
g_pCompositor->focusWindow(PWINDOWTOCHANGETO); g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f; g_pCompositor->warpCursorTo(PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f);
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
}; };
if (message == "swapwithmaster") { if (message == "swapwithmaster") {
const auto PWINDOW = header.pWindow; const auto PWINDOW = header.pWindow;
if (!PWINDOW)
return 0;
if (!isWindowTiled(PWINDOW)) if (!isWindowTiled(PWINDOW))
return 0; return 0;
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID); const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
if (!PMASTER || PMASTER->pWindow == PWINDOW) if (!PMASTER)
return 0; return 0;
if (PMASTER->pWindow != PWINDOW) {
switchWindows(PWINDOW, PMASTER->pWindow); switchWindows(PWINDOW, PMASTER->pWindow);
switchToWindow(PWINDOW); switchToWindow(PWINDOW);
} else {
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
switchWindows(n.pWindow, PMASTER->pWindow);
switchToWindow(n.pWindow);
break;
}
}
}
return 0;
} else if (message == "focusmaster") {
const auto PWINDOW = header.pWindow;
if (!PWINDOW)
return 0;
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
if (!PMASTER)
return 0;
if (PMASTER->pWindow != PWINDOW)
switchToWindow(PMASTER->pWindow);
else {
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == PMASTER->workspaceID && !n.isMaster) {
switchToWindow(n.pWindow);
break;
}
}
}
return 0; return 0;
} else if (message == "cyclenext") { } else if (message == "cyclenext") {
const auto PWINDOW = header.pWindow; const auto PWINDOW = header.pWindow;
if (!isWindowTiled(PWINDOW)) if (!PWINDOW)
return 0; return 0;
const auto PNODE = getNodeFromWindow(PWINDOW); switchToWindow(getNextWindow(PWINDOW, true));
if (PNODE->isMaster) {
// focus the first non master
for (auto n : m_lMasterNodesData) {
if (n.pWindow != PWINDOW && n.workspaceID == PWINDOW->m_iWorkspaceID) {
switchToWindow(n.pWindow);
break;
}
}
} else {
// focus next
bool reached = false;
bool found = false;
for (auto n : m_lMasterNodesData) {
if (n.pWindow == PWINDOW) {
reached = true;
continue;
}
if (n.workspaceID == PWINDOW->m_iWorkspaceID && reached) {
switchToWindow(n.pWindow);
found = true;
break;
}
}
if (!found) {
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
if (PMASTER)
switchToWindow(PMASTER->pWindow);
}
}
} else if (message == "cycleprev") { } else if (message == "cycleprev") {
const auto PWINDOW = header.pWindow; const auto PWINDOW = header.pWindow;
if (!isWindowTiled(PWINDOW)) if (!PWINDOW)
return 0; return 0;
const auto PNODE = getNodeFromWindow(PWINDOW); switchToWindow(getNextWindow(PWINDOW, false));
} else if (message == "swapnext") {
if (!g_pCompositor->windowValidMapped(header.pWindow))
return 0;
if (PNODE->isMaster) { if (header.pWindow->m_bIsFloating) {
// focus the first non master g_pKeybindManager->m_mDispatchers["swapnext"]("");
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { return 0;
if (it->pWindow != PWINDOW && it->workspaceID == PWINDOW->m_iWorkspaceID) { }
switchToWindow(it->pWindow);
const auto PWINDOWTOSWAPWITH = getNextWindow(header.pWindow, true);
if (PWINDOWTOSWAPWITH) {
switchWindows(header.pWindow, PWINDOWTOSWAPWITH);
g_pCompositor->focusWindow(header.pWindow);
}
} else if (message == "swapprev") {
if (!g_pCompositor->windowValidMapped(header.pWindow))
return 0;
if (header.pWindow->m_bIsFloating) {
g_pKeybindManager->m_mDispatchers["swapnext"]("prev");
return 0;
}
const auto PWINDOWTOSWAPWITH = getNextWindow(header.pWindow, false);
if (PWINDOWTOSWAPWITH) {
switchWindows(header.pWindow, PWINDOWTOSWAPWITH);
g_pCompositor->focusWindow(header.pWindow);
}
} else if (message == "addmaster") {
if (!g_pCompositor->windowValidMapped(header.pWindow))
return 0;
if (header.pWindow->m_bIsFloating)
return 0;
const auto PNODE = getNodeFromWindow(header.pWindow);
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID);
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID);
if (MASTERS + 2 > WINDOWS)
return 0;
if (!PNODE || PNODE->isMaster) {
// first non-master node
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == header.pWindow->m_iWorkspaceID && !n.isMaster) {
n.isMaster = true;
break; break;
} }
} }
} else { } else {
// focus next PNODE->isMaster = true;
bool reached = false;
bool found = false;
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->pWindow == PWINDOW) {
reached = true;
continue;
} }
if (it->workspaceID == PWINDOW->m_iWorkspaceID && reached) { recalculateMonitor(header.pWindow->m_iMonitorID);
switchToWindow(it->pWindow);
found = true; } else if (message == "removemaster") {
if (!g_pCompositor->windowValidMapped(header.pWindow))
return 0;
if (header.pWindow->m_bIsFloating)
return 0;
const auto PNODE = getNodeFromWindow(header.pWindow);
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID);
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID);
if (WINDOWS < 2 || MASTERS < 2)
return 0;
if (!PNODE || !PNODE->isMaster) {
// first non-master node
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->workspaceID == header.pWindow->m_iWorkspaceID && it->isMaster) {
it->isMaster = false;
break; break;
} }
} }
if (!found) { } else {
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID); PNODE->isMaster = false;
}
if (PMASTER) recalculateMonitor(header.pWindow->m_iMonitorID);
switchToWindow(PMASTER->pWindow);
}
}
} }
return 0; return 0;
@@ -559,7 +760,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
void CHyprMasterLayout::onEnable() { void CHyprMasterLayout::onEnable() {
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->m_bHidden) if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->isHidden())
continue; continue;
onWindowCreatedTiling(w.get()); onWindowCreatedTiling(w.get());

View File

@@ -15,6 +15,8 @@ struct SMasterNodeData {
Vector2D position; Vector2D position;
Vector2D size; Vector2D size;
float percSize = 1.f; // size multiplier for resizing children
int workspaceID = -1; int workspaceID = -1;
bool operator==(const SMasterNodeData& rhs) { bool operator==(const SMasterNodeData& rhs) {
@@ -51,6 +53,8 @@ private:
SMasterNodeData* getNodeFromWindow(CWindow*); SMasterNodeData* getNodeFromWindow(CWindow*);
SMasterNodeData* getMasterNodeOnWorkspace(const int&); SMasterNodeData* getMasterNodeOnWorkspace(const int&);
void calculateWorkspace(const int&); void calculateWorkspace(const int&);
CWindow* getNextWindow(CWindow*, bool);
int getMastersOnWorkspace(const int&);
friend struct SMasterNodeData; friend struct SMasterNodeData;
}; };

View File

@@ -5,17 +5,22 @@
#include "init/initHelpers.hpp" #include "init/initHelpers.hpp"
#include <iostream> #include <iostream>
// I am a bad bad boy and have used some global vars here,
// just for this file
bool ignoreSudo = false;
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (!getenv("XDG_RUNTIME_DIR")) if (!getenv("XDG_RUNTIME_DIR"))
throw std::runtime_error("XDG_RUNTIME_DIR is not set!"); throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
// export HYPRLAND_CMD
std::string cmd = "";
for (auto i = 0; i < argc; ++i)
cmd += std::string(i == 0 ? "" : " ") + argv[i];
setenv("HYPRLAND_CMD", cmd.c_str(), 1);
setenv("XDG_BACKEND", "wayland", 1);
setenv("_JAVA_AWT_WM_NONREPARENTING", "1", 0);
// parse some args // parse some args
std::string configPath; std::string configPath;
bool ignoreSudo = false;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--i-am-really-stupid")) if (!strcmp(argv[i], "--i-am-really-stupid"))
ignoreSudo = true; ignoreSudo = true;
@@ -61,7 +66,13 @@ int main(int argc, char** argv) {
// If we are here it means we got yote. // If we are here it means we got yote.
Debug::log(LOG, "Hyprland reached the end."); Debug::log(LOG, "Hyprland reached the end.");
g_pCompositor->cleanup(); wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
// kill all clients
for (auto& c : g_pCompositor->m_dProcessPIDsOnShutdown)
kill(c, SIGKILL);
wl_display_destroy(g_pCompositor->m_sWLDisplay);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@@ -21,18 +21,20 @@ void CAnimationManager::addBezierWithName(std::string name, const Vector2D& p1,
void CAnimationManager::tick() { void CAnimationManager::tick() {
bool animationsDisabled = false; bool animGlobalDisabled = false;
static auto *const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue; static auto *const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue;
if (!*PANIMENABLED) if (!*PANIMENABLED)
animationsDisabled = true; animGlobalDisabled = true;
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
const auto DEFAULTBEZIER = m_mBezierCurves.find("default"); const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
std::vector<CAnimatedVariable*> animationEndedVars;
for (auto& av : m_lAnimatedVariables) { for (auto& av : m_lAnimatedVariables) {
// first of all, check if we need to update it at all // first of all, check if we need to update it at all
@@ -40,27 +42,25 @@ void CAnimationManager::tick() {
continue; continue;
if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) { if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) {
av->warp(); av->warp(false);
continue; continue;
} }
// get speed
const auto SPEED = av->m_pConfig->pValues->internalSpeed;
// get the spent % (0 - 1) // get the spent % (0 - 1)
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count(); const float SPENT = av->getPercent();
const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f);
// window stuff // window stuff
const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWINDOW = (CWindow*)av->m_pWindow;
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
const auto PLAYER = (SLayerSurface*)av->m_pLayer; const auto PLAYER = (SLayerSurface*)av->m_pLayer;
CMonitor* PMONITOR = nullptr; CMonitor* PMONITOR = nullptr;
bool animationsDisabled = animGlobalDisabled;
wlr_box WLRBOXPREV = {0,0,0,0}; wlr_box WLRBOXPREV = {0,0,0,0};
if (PWINDOW) { if (PWINDOW) {
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox(); WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
animationsDisabled = animationsDisabled || PWINDOW->m_sAdditionalConfigData.forceNoAnims;
} else if (PWORKSPACE) { } else if (PWORKSPACE) {
PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID); PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y}; WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y};
@@ -76,12 +76,12 @@ void CAnimationManager::tick() {
case AVARTYPE_FLOAT: { case AVARTYPE_FLOAT: {
// for disabled anims just warp // for disabled anims just warp
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) { if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp(); av->warp(false);
break; break;
} }
if (SPENT >= 1.f) { if (SPENT >= 1.f) {
av->warp(); av->warp(false);
break; break;
} }
@@ -97,12 +97,12 @@ void CAnimationManager::tick() {
case AVARTYPE_VECTOR: { case AVARTYPE_VECTOR: {
// for disabled anims just warp // for disabled anims just warp
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) { if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp(); av->warp(false);
break; break;
} }
if (SPENT >= 1.f) { if (SPENT >= 1.f) {
av->warp(); av->warp(false);
break; break;
} }
@@ -118,12 +118,12 @@ void CAnimationManager::tick() {
case AVARTYPE_COLOR: { case AVARTYPE_COLOR: {
// for disabled anims just warp // for disabled anims just warp
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) { if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp(); av->warp(false);
break; break;
} }
if (SPENT >= 1.f) { if (SPENT >= 1.f) {
av->warp(); av->warp(false);
break; break;
} }
@@ -151,7 +151,7 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
} else if (PWORKSPACE) { } else if (PWORKSPACE) {
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bHidden) if (!w->m_bIsMapped || w->isHidden())
continue; continue;
if (w->m_iWorkspaceID != PWORKSPACE->m_iID) if (w->m_iWorkspaceID != PWORKSPACE->m_iID)
@@ -164,8 +164,7 @@ void CAnimationManager::tick() {
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR);
} }
break; break;
} } case AVARDAMAGE_BORDER: {
case AVARDAMAGE_BORDER: {
RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!"); RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!");
// damage only the border. // damage only the border.
@@ -190,7 +189,7 @@ void CAnimationManager::tick() {
} case AVARDAMAGE_SHADOW: { } case AVARDAMAGE_SHADOW: {
RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!"); RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!");
static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW); const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW);
@@ -223,13 +222,21 @@ void CAnimationManager::tick() {
} }
} }
// set size and pos if valid, but only if damage policy entire (dont if border for example) // set size and pos if valid, but only if damage policy entire (dont if border for example)
if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE && PWINDOW->m_iX11Type != 2) if (g_pCompositor->windowValidMapped(PWINDOW) && av->m_eDamagePolicy == AVARDAMAGE_ENTIRE && PWINDOW->m_iX11Type != 2)
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
// manually schedule a frame // manually schedule a frame
g_pCompositor->scheduleFrameForMonitor(PMONITOR); g_pCompositor->scheduleFrameForMonitor(PMONITOR);
// check if we did not finish animating. If so, trigger onAnimationEnd.
if (!av->isBeingAnimated())
animationEndedVars.push_back(av);
}
// do it here, because if this alters the animation vars deque we would be in trouble above.
for (auto& ave : animationEndedVars) {
ave->onAnimationEnd();
} }
} }
@@ -285,7 +292,7 @@ void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPe
} }
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) { void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) {
pWindow->m_vRealSize.warp(); // size we preserve in slide pWindow->m_vRealSize.warp(false); // size we preserve in slide
const auto GOALPOS = pWindow->m_vRealPosition.goalv(); const auto GOALPOS = pWindow->m_vRealPosition.goalv();
const auto GOALSIZE = pWindow->m_vRealSize.goalv(); const auto GOALSIZE = pWindow->m_vRealSize.goalv();
@@ -359,6 +366,10 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
if (!pWindow->m_vRealPosition.isBeingAnimated() && !pWindow->m_vRealSize.isBeingAnimated()) if (!pWindow->m_vRealPosition.isBeingAnimated() && !pWindow->m_vRealSize.isBeingAnimated())
return; return;
// if the animation is disabled and we are leaving, ignore the anim to prevent the snapshot being fucked
if (!pWindow->m_vRealPosition.m_pConfig->pValues->internalEnabled)
return;
if (pWindow->m_sAdditionalConfigData.animationStyle != "") { if (pWindow->m_sAdditionalConfigData.animationStyle != "") {
// the window has config'd special anim // the window has config'd special anim
if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) { if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) {
@@ -428,7 +439,7 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
} }
return "unknown style"; return "unknown style";
} else if (config == "workspaces") { } else if (config == "workspaces" || config == "specialWorkspace") {
if (style == "slide" || style == "slidevert" || style == "fade") if (style == "slide" || style == "slidevert" || style == "fade")
return ""; return "";

View File

@@ -18,8 +18,25 @@
CEventManager::CEventManager() { CEventManager::CEventManager() {
} }
int fdHandleWrite(int fd, uint32_t mask, void* data) {
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
// remove, hanged up
const auto ACCEPTEDFDS = (std::deque<std::pair<int, wl_event_source*>>*)data;
for (auto it = ACCEPTEDFDS->begin(); it != ACCEPTEDFDS->end(); ) {
if (it->first == fd) {
wl_event_source_remove(it->second); // remove this fd listener
it = ACCEPTEDFDS->erase(it);
} else {
it++;
}
}
}
return 0;
}
void CEventManager::startThread() { void CEventManager::startThread() {
std::thread([&]() { m_tThread = std::thread([&]() {
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0); const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SOCKET < 0) { if (SOCKET < 0) {
@@ -36,78 +53,52 @@ void CEventManager::startThread() {
// 10 max queued. // 10 max queued.
listen(SOCKET, 10); listen(SOCKET, 10);
char readBuf[1024] = {0};
sockaddr_in clientAddress; sockaddr_in clientAddress;
socklen_t clientSize = sizeof(clientAddress); socklen_t clientSize = sizeof(clientAddress);
Debug::log(LOG, "Hypr socket 2 started at %s", socketPath.c_str()); Debug::log(LOG, "Hypr socket 2 started at %s", socketPath.c_str());
// set the socket nonblock
int flags = fcntl(SOCKET, F_GETFL, 0);
fcntl(SOCKET, F_SETFL, flags | O_NONBLOCK);
while (1) { while (1) {
const auto ACCEPTEDCONNECTION = accept(SOCKET, (sockaddr*)&clientAddress, &clientSize); const auto ACCEPTEDCONNECTION = accept(SOCKET, (sockaddr*)&clientAddress, &clientSize);
if (ACCEPTEDCONNECTION > 0) { if (ACCEPTEDCONNECTION > 0) {
// new connection! // new connection!
m_dAcceptedSocketFDs.push_back(ACCEPTEDCONNECTION);
int flagsNew = fcntl(ACCEPTEDCONNECTION, F_GETFL, 0); int flagsNew = fcntl(ACCEPTEDCONNECTION, F_GETFL, 0);
fcntl(ACCEPTEDCONNECTION, F_SETFL, flagsNew | O_NONBLOCK); fcntl(ACCEPTEDCONNECTION, F_SETFL, flagsNew | O_NONBLOCK);
Debug::log(LOG, "Socket 2 accepted a new client at FD %d", ACCEPTEDCONNECTION); Debug::log(LOG, "Socket 2 accepted a new client at FD %d", ACCEPTEDCONNECTION);
// add to event loop so we can close it when we need to
m_dAcceptedSocketFDs.push_back({ACCEPTEDCONNECTION, wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, ACCEPTEDCONNECTION, WL_EVENT_READABLE, fdHandleWrite, &m_dAcceptedSocketFDs)});
}
} }
// pong if all FDs valid close(SOCKET);
for (auto it = m_dAcceptedSocketFDs.begin(); it != m_dAcceptedSocketFDs.end();) { });
auto sizeRead = recv(*it, &readBuf, 1024, 0);
if (sizeRead != 0) { m_tThread.detach();
it++; }
continue;
}
// invalid! void CEventManager::flushEvents() {
Debug::log(LOG, "Removed invalid socket (2) FD: %d", *it);
it = m_dAcceptedSocketFDs.erase(it);
}
// valid FDs, check the queue
// don't do anything if main thread is writing to the eventqueue
eventQueueMutex.lock(); eventQueueMutex.lock();
if (m_dQueuedEvents.empty()){ // if queue empty, sleep and ignore
eventQueueMutex.unlock();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
// write all queued events
for (auto& ev : m_dQueuedEvents) { for (auto& ev : m_dQueuedEvents) {
std::string eventString = (ev.event + ">>" + ev.data).substr(0, 1022) + "\n"; std::string eventString = (ev.event + ">>" + ev.data).substr(0, 1022) + "\n";
for (auto& fd : m_dAcceptedSocketFDs) { for (auto& fd : m_dAcceptedSocketFDs) {
write(fd, eventString.c_str(), eventString.length()); write(fd.first, eventString.c_str(), eventString.length());
} }
} }
m_dQueuedEvents.clear(); m_dQueuedEvents.clear();
eventQueueMutex.unlock(); eventQueueMutex.unlock();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
close(SOCKET);
}).detach();
} }
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) { void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
if (m_bIgnoreEvents && !force) { if ((m_bIgnoreEvents && !force) || g_pCompositor->m_bIsShuttingDown) {
Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s",event.event.c_str(), event.data.c_str()); Debug::log(WARN, "Suppressed (ignoreevents true / shutting down) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
return; return;
} }
@@ -115,5 +106,7 @@ void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
eventQueueMutex.lock(); eventQueueMutex.lock();
m_dQueuedEvents.push_back(ev); m_dQueuedEvents.push_back(ev);
eventQueueMutex.unlock(); eventQueueMutex.unlock();
flushEvents();
}, event).detach(); }, event).detach();
} }

View File

@@ -21,12 +21,16 @@ public:
bool m_bIgnoreEvents = false; bool m_bIgnoreEvents = false;
std::thread m_tThread;
private: private:
void flushEvents();
std::mutex eventQueueMutex; std::mutex eventQueueMutex;
std::deque<SHyprIPCEvent> m_dQueuedEvents; std::deque<SHyprIPCEvent> m_dQueuedEvents;
std::deque<int> m_dAcceptedSocketFDs; std::deque<std::pair<int, wl_event_source*>> m_dAcceptedSocketFDs;
}; };
inline std::unique_ptr<CEventManager> g_pEventManager; inline std::unique_ptr<CEventManager> g_pEventManager;

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,7 @@
#include <functional> #include <functional>
class CInputManager; class CInputManager;
class CConfigManager;
struct SKeybind { struct SKeybind {
std::string key = ""; std::string key = "";
@@ -18,6 +19,7 @@ struct SKeybind {
std::string submap = ""; std::string submap = "";
bool release = false; bool release = false;
bool repeat = false; bool repeat = false;
bool mouse = false;
// DO NOT INITIALIZE // DO NOT INITIALIZE
bool shadowed = false; bool shadowed = false;
@@ -37,6 +39,7 @@ public:
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*); bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
bool onAxisEvent(wlr_pointer_axis_event*); bool onAxisEvent(wlr_pointer_axis_event*);
bool onMouseEvent(wlr_pointer_button_event*); bool onMouseEvent(wlr_pointer_button_event*);
void onSwitchEvent(const std::string&);
void addKeybind(SKeybind); void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&); void removeKeybind(uint32_t, const std::string&);
@@ -61,6 +64,11 @@ private:
uint32_t m_uTimeLastMs = 0; uint32_t m_uTimeLastMs = 0;
uint32_t m_uLastCode = 0; uint32_t m_uLastCode = 0;
uint32_t m_uLastMouseCode = 0;
bool m_bIsMouseBindActive = false;
int m_iPassPressed = -1; // used for pass
CTimer m_tScrollTimer; CTimer m_tScrollTimer;
@@ -72,9 +80,11 @@ private:
xkb_state* m_pXKBTranslationState = nullptr; xkb_state* m_pXKBTranslationState = nullptr;
void updateXKBTranslationState(); void updateXKBTranslationState();
bool ensureMouseBindState();
// -------------- Dispatchers -------------- // // -------------- Dispatchers -------------- //
static void killActive(std::string); static void killActive(std::string);
static void kill(std::string);
static void spawn(std::string); static void spawn(std::string);
static void toggleActiveFloating(std::string); static void toggleActiveFloating(std::string);
static void toggleActivePseudo(std::string); static void toggleActivePseudo(std::string);
@@ -83,6 +93,7 @@ private:
static void moveActiveToWorkspace(std::string); static void moveActiveToWorkspace(std::string);
static void moveActiveToWorkspaceSilent(std::string); static void moveActiveToWorkspaceSilent(std::string);
static void moveFocusTo(std::string); static void moveFocusTo(std::string);
static void centerWindow(std::string);
static void moveActiveTo(std::string); static void moveActiveTo(std::string);
static void toggleGroup(std::string); static void toggleGroup(std::string);
static void changeGroupActive(std::string); static void changeGroupActive(std::string);
@@ -107,9 +118,15 @@ private:
static void layoutmsg(std::string); static void layoutmsg(std::string);
static void toggleOpaque(std::string); static void toggleOpaque(std::string);
static void dpms(std::string); static void dpms(std::string);
static void swapnext(std::string);
static void swapActiveWorkspaces(std::string);
static void pinActive(std::string);
static void mouse(std::string);
static void bringActiveToTop(std::string);
friend class CCompositor; friend class CCompositor;
friend class CInputManager; friend class CInputManager;
friend class CConfigManager;
}; };
inline std::unique_ptr<CKeybindManager> g_pKeybindManager; inline std::unique_ptr<CKeybindManager> g_pKeybindManager;

View File

@@ -0,0 +1,5 @@
#include "ProtocolManager.hpp"
CProtocolManager::CProtocolManager() {
m_pToplevelExportProtocolManager = std::make_unique<CToplevelExportProtocolManager>();
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "../defines.hpp"
#include "../protocols/ToplevelExport.hpp"
class CProtocolManager {
public:
CProtocolManager();
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
};
inline std::unique_ptr<CProtocolManager> g_pProtocolManager;

View File

@@ -7,6 +7,9 @@ int slowUpdate = 0;
int handleTimer(void* data) { int handleTimer(void* data) {
const auto PTM = (CThreadManager*)data; const auto PTM = (CThreadManager*)data;
static auto *const PDISABLECFGRELOAD = &g_pConfigManager->getConfigValuePtr("misc:disable_autoreload")->intValue;
if (*PDISABLECFGRELOAD != 1)
g_pConfigManager->tick(); g_pConfigManager->tick();
wl_event_source_timer_update(PTM->m_esConfigTimer, 1000); wl_event_source_timer_update(PTM->m_esConfigTimer, 1000);
@@ -19,8 +22,6 @@ CThreadManager::CThreadManager() {
HyprCtl::startHyprCtlSocket(); HyprCtl::startHyprCtlSocket();
g_pCompositor->startHyprCtlTick();
m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this); m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this);
wl_event_source_timer_update(m_esConfigTimer, 1000); wl_event_source_timer_update(m_esConfigTimer, 1000);

View File

@@ -3,7 +3,7 @@
#include "../events/Events.hpp" #include "../events/Events.hpp"
CHyprXWaylandManager::CHyprXWaylandManager() { CHyprXWaylandManager::CHyprXWaylandManager() {
if (XWAYLAND) { #ifndef NO_XWAYLAND
m_sWLRXWayland = wlr_xwayland_create(g_pCompositor->m_sWLDisplay, g_pCompositor->m_sWLRCompositor, 1); m_sWLRXWayland = wlr_xwayland_create(g_pCompositor->m_sWLDisplay, g_pCompositor->m_sWLRCompositor, 1);
if (!m_sWLRXWayland) { if (!m_sWLRXWayland) {
@@ -17,7 +17,9 @@ CHyprXWaylandManager::CHyprXWaylandManager() {
setenv("DISPLAY", m_sWLRXWayland->display_name, 1); setenv("DISPLAY", m_sWLRXWayland->display_name, 1);
Debug::log(LOG, "CHyprXWaylandManager started on display %s", m_sWLRXWayland->display_name); Debug::log(LOG, "CHyprXWaylandManager started on display %s", m_sWLRXWayland->display_name);
} #else
unsetenv("DISPLAY"); // unset DISPLAY so that X11 apps do not try to start on a different/invalid DISPLAY
#endif
} }
CHyprXWaylandManager::~CHyprXWaylandManager() { CHyprXWaylandManager::~CHyprXWaylandManager() {
@@ -32,9 +34,12 @@ wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) {
} }
void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) { void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) {
if (!pSurface)
return;
if (wlr_surface_is_xdg_surface(pSurface)) { if (wlr_surface_is_xdg_surface(pSurface)) {
const auto PSURF = wlr_xdg_surface_from_wlr_surface(pSurface); const auto PSURF = wlr_xdg_surface_from_wlr_surface(pSurface);
if (PSURF->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) { if (PSURF && PSURF->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_set_activated(PSURF->toplevel, activate); wlr_xdg_toplevel_set_activated(PSURF->toplevel, activate);
} }
} else if (wlr_surface_is_xwayland_surface(pSurface)) { } else if (wlr_surface_is_xwayland_surface(pSurface)) {
@@ -48,25 +53,41 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate)
void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) { void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
if (pWindow->m_bIsX11) { if (pWindow->m_bIsX11) {
if (pWindow->m_uSurface.xwayland->minimized)
if (activate) {
wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false); wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false);
wlr_xwayland_surface_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
}
wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate); wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate);
wlr_xwayland_surface_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
} }
else else
wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate); wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);
if (activate) {
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow); g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
g_pCompositor->m_pLastWindow = pWindow; g_pCompositor->m_pLastWindow = pWindow;
}
if (!pWindow->m_bPinned)
g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID)->m_pLastFocusedWindow = pWindow;
} }
void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox) { void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox) {
if (pWindow->m_bIsX11) { if (pWindow->m_bIsX11) {
const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints;
if (SIZEHINTS && pWindow->m_iX11Type != 2) {
pbox->x = SIZEHINTS->x;
pbox->y = SIZEHINTS->y;
pbox->width = SIZEHINTS->width;
pbox->height = SIZEHINTS->height;
} else {
pbox->x = pWindow->m_uSurface.xwayland->x; pbox->x = pWindow->m_uSurface.xwayland->x;
pbox->y = pWindow->m_uSurface.xwayland->y; pbox->y = pWindow->m_uSurface.xwayland->y;
pbox->width = pWindow->m_uSurface.xwayland->width; pbox->width = pWindow->m_uSurface.xwayland->width;
pbox->height = pWindow->m_uSurface.xwayland->height; pbox->height = pWindow->m_uSurface.xwayland->height;
}
} else { } else {
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, pbox); wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, pbox);
} }
@@ -242,7 +263,7 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
if (!g_pCompositor->windowValidMapped(pWindow)) if (!g_pCompositor->windowValidMapped(pWindow))
return Vector2D(99999, 99999); return Vector2D(99999, 99999);
if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel)) if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel) || pWindow->m_sAdditionalConfigData.noMaxSize)
return Vector2D(99999, 99999); return Vector2D(99999, 99999);
auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height) auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height)

View File

@@ -49,6 +49,27 @@ void CInputManager::recheckIdleInhibitorStatus() {
} }
} }
// check manual user-set inhibitors
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_eIdleInhibitMode == IDLEINHIBIT_NONE)
continue;
if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
return;
}
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w.get())) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
return;
}
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID)) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false);
return;
}
}
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true); wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true);
return; return;
} }

View File

@@ -2,16 +2,18 @@
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
float sensitivity = g_pConfigManager->getFloat("general:sensitivity"); static auto *const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
static auto *const PNOACCEL = &g_pConfigManager->getConfigValuePtr("input:force_no_accel")->intValue;
static auto* const PSENSTORAW = &g_pConfigManager->getConfigValuePtr("general:apply_sens_to_raw")->intValue;
const auto DELTA = g_pConfigManager->getInt("input:force_no_accel") == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y); const auto DELTA = *PNOACCEL == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y);
if (g_pConfigManager->getInt("general:apply_sens_to_raw") == 1) if (*PSENSTORAW == 1)
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * sensitivity, DELTA.y * sensitivity, e->unaccel_dx * sensitivity, e->unaccel_dy * sensitivity); wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * *PSENS, DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
else else
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y, e->unaccel_dx, e->unaccel_dy); wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y, e->unaccel_dx, e->unaccel_dy);
wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * sensitivity, DELTA.y * sensitivity); wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * *PSENS, DELTA.y * *PSENS);
mouseMoveUnified(e->time_msec); mouseMoveUnified(e->time_msec);
@@ -27,14 +29,22 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
} }
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
static auto *const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue; static auto *const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue; static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
static auto *const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue; static auto *const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
static auto *const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue; static auto *const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
if (!g_pCompositor->m_bReadyToProcess) m_pFoundSurfaceToFocus = nullptr;
m_pFoundLSToFocus = nullptr;
m_pFoundWindowToFocus = nullptr;
wlr_surface* foundSurface = nullptr;
Vector2D surfaceCoords;
Vector2D surfacePos = Vector2D(-1337, -1337);
CWindow* pFoundWindow = nullptr;
SLayerSurface* pFoundLayerSurface = nullptr;
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown)
return; return;
if (!g_pCompositor->m_sSeat.mouse) { if (!g_pCompositor->m_sSeat.mouse) {
@@ -42,9 +52,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return; return;
} }
if (g_pCompositor->m_sSeat.mouse->virt)
return; // don't refocus on virt
if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS) { if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS) {
// enable dpms // enable dpms
g_pKeybindManager->dpms("on"); g_pKeybindManager->dpms("on");
@@ -60,14 +67,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
bool didConstraintOnCursor = false;
// constraints // constraints
// All constraints TODO: multiple mice? // All constraints TODO: multiple mice?
if (g_pCompositor->m_sSeat.mouse->currentConstraint) { if (g_pCompositor->m_sSeat.mouse->currentConstraint && !g_pCompositor->m_sSeat.exclusiveClient) {
// XWayland windows sometimes issue constraints weirdly. // XWayland windows sometimes issue constraints weirdly.
// TODO: We probably should search their parent. wlr_xwayland_surface->parent // TODO: We probably should search their parent. wlr_xwayland_surface->parent
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
const auto PCONSTRAINT = g_pCompositor->m_sSeat.mouse->currentConstraint;
if (!CONSTRAINTWINDOW) { if (!CONSTRAINTWINDOW) {
unconstrainMouse(); unconstrainMouse();
@@ -77,33 +83,38 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x - 1.0, CONSTRAINTPOS.y + CONSTRAINTSIZE.y - 1.0)) { if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
// we just snap the cursor to where it should be.
Vector2D hint = { PCONSTRAINT->current.cursor_hint.x, PCONSTRAINT->current.cursor_hint.y };
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + hint.x, CONSTRAINTPOS.y + hint.y);
return; // don't process anything else, the cursor is locked. The surface should not receive any further events.
// these are usually FPS games. They will use the relative motion.
} else {
// we restrict the cursor to the confined region
if (!pixman_region32_contains_point(&PCONSTRAINT->region, mouseCoords.x - CONSTRAINTPOS.x, mouseCoords.y - CONSTRAINTPOS.y, nullptr)) {
if (g_pCompositor->m_sSeat.mouse->constraintActive) { if (g_pCompositor->m_sSeat.mouse->constraintActive) {
Vector2D newConstrainedCoords = mouseCoords; wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, NULL, mouseCoords.x, mouseCoords.y);
mouseCoords = getMouseCoordsInternal();
if (mouseCoords.x < CONSTRAINTPOS.x)
newConstrainedCoords.x = CONSTRAINTPOS.x;
else if (mouseCoords.x >= CONSTRAINTPOS.x + CONSTRAINTSIZE.x)
newConstrainedCoords.x = CONSTRAINTPOS.x + CONSTRAINTSIZE.x - 1.0;
if (mouseCoords.y < CONSTRAINTPOS.y)
newConstrainedCoords.y = CONSTRAINTPOS.y;
else if (mouseCoords.y >= CONSTRAINTPOS.y + CONSTRAINTSIZE.y)
newConstrainedCoords.y = CONSTRAINTPOS.y + CONSTRAINTSIZE.y - 1.0;
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, newConstrainedCoords.x, newConstrainedCoords.y);
mouseCoords = newConstrainedCoords;
didConstraintOnCursor = true;
} }
} else { } else {
if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) { if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) {
g_pCompositor->m_sSeat.mouse->constraintActive = true; g_pCompositor->m_sSeat.mouse->constraintActive = true;
didConstraintOnCursor = true;
} }
} }
} }
if (CONSTRAINTWINDOW->m_bIsX11) {
foundSurface = g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW);
surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
} else {
g_pCompositor->vectorWindowToSurface(mouseCoords, CONSTRAINTWINDOW, surfaceCoords);
}
pFoundWindow = CONSTRAINTWINDOW;
}
} }
// update stuff // update stuff
@@ -111,45 +122,41 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
// focus
wlr_surface* foundSurface = nullptr;
if (didConstraintOnCursor)
return; // don't process when cursor constrained
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) { if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) {
g_pCompositor->m_pLastMonitor = PMONITOR; g_pCompositor->setActiveMonitor(PMONITOR);
// set active workspace and deactivate all other in wlr // set active workspace and deactivate all other in wlr
const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle);
ACTIVEWORKSPACE->setActive(true); ACTIVEWORKSPACE->setActive(true);
// event
g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName});
} }
Vector2D surfaceCoords;
Vector2D surfacePos = Vector2D(-1337, -1337);
CWindow* pFoundWindow = nullptr;
SLayerSurface* pFoundLayerSurface = nullptr;
// overlay is above fullscreen // overlay is above fullscreen
if (!foundSurface) if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface); foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface);
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
// then, we check if the workspace doesnt have a fullscreen window // then, we check if the workspace doesnt have a fullscreen window
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
surfacePos = pFoundWindow->m_vRealPosition.vec(); if (!pFoundWindow) {
// what the fuck, somehow happens occasionally??
PWORKSPACE->m_bHasFullscreenWindow = false;
return;
}
// only check floating because tiled cant be over fullscreen // only check floating because tiled cant be over fullscreen
for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) { for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) {
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y}; wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && (*w)->m_bCreatedOverFullscreen) || ((*w)->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden) { if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) || (g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) {
pFoundWindow = (*w).get(); pFoundWindow = (*w).get();
break;
}
}
if (!pFoundWindow->m_bIsX11) { if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
@@ -158,23 +165,16 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
surfacePos = pFoundWindow->m_vRealPosition.vec(); surfacePos = pFoundWindow->m_vRealPosition.vec();
} }
break;
} }
}
}
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
// then windows // then windows
if (!foundSurface) { if (!foundSurface) {
if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) { if (PWORKSPACE->m_bHasFullscreenWindow && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceID) {
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
if (pFoundWindow && pFoundWindow->m_iWorkspaceID != SPECIAL_WORKSPACE_ID) { if (pFoundWindow && !g_pCompositor->isWorkspaceSpecial(pFoundWindow->m_iWorkspaceID)) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
} }
} else { } else {
@@ -209,12 +209,19 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!foundSurface) if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface); foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface);
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_pLastMonitor);
if (!foundSurface) { if (!foundSurface) {
if (!m_bEmptyFocusCursorSet) {
// TODO: maybe wrap?
if (m_ecbClickBehavior == CLICKMODE_KILL) if (m_ecbClickBehavior == CLICKMODE_KILL)
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor); wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
else else
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
m_bEmptyFocusCursorSet = true;
}
wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat);
if (refocus) { // if we are forcing a refocus, and we don't find a surface, clear the kb focus too! if (refocus) { // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
@@ -224,6 +231,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
return; return;
} }
m_bEmptyFocusCursorSet = false;
if (time) if (time)
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
@@ -247,37 +256,53 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
} }
} }
// set the values for use
if (refocus) {
m_pFoundLSToFocus = pFoundLayerSurface;
m_pFoundWindowToFocus = pFoundWindow;
m_pFoundSurfaceToFocus = foundSurface;
}
if (pFoundWindow) { if (pFoundWindow) {
if (*PFOLLOWMOUSE != 1 && !refocus) { if (*PFOLLOWMOUSE != 1 && !refocus) {
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR) { if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow && ((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
// enter if change floating style // enter if change floating style
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface); g_pCompositor->focusWindow(pFoundWindow, foundSurface);
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
} else if (*PFOLLOWMOUSE == 2) { } else if (*PFOLLOWMOUSE == 2 || *PFOLLOWMOUSE == 3) {
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
} }
if (pFoundWindow == g_pCompositor->m_pLastWindow && foundSurface != g_pCompositor->m_pLastFocus) { if (pFoundWindow == g_pCompositor->m_pLastWindow) {
// we changed the subsurface if (foundSurface != g_pCompositor->m_pLastFocus || m_bLastFocusOnLS) {
// ^^^ changed the subsurface ^^^ came back from a LS
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
} }
}
if (*PFOLLOWONDND && m_sDrag.dragIcon) { if (*PFOLLOWONDND && m_sDrag.dragIcon) {
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
} }
if (*PFOLLOWMOUSE != 0 || pFoundWindow == g_pCompositor->m_pLastWindow)
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
m_bLastFocusOnLS = false;
return; // don't enter any new surfaces return; // don't enter any new surfaces
} else { } else {
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus) if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface); g_pCompositor->focusWindow(pFoundWindow, foundSurface);
} }
m_bLastFocusOnLS = false;
} else { } else {
if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) { if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) {
g_pCompositor->focusSurface(foundSurface); g_pCompositor->focusSurface(foundSurface);
g_pCompositor->m_pLastWindow = nullptr; // reset last window as we have a full focus on a LS
} }
if (pFoundLayerSurface)
m_bLastFocusOnLS = true;
} }
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
@@ -311,6 +336,10 @@ void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_even
g_pHyprRenderer->m_bWindowRequestedCursorHide = false; g_pHyprRenderer->m_bWindowRequestedCursorHide = false;
} }
if (m_bCursorImageOverriden) {
return;
}
if (m_ecbClickBehavior == CLICKMODE_KILL) { if (m_ecbClickBehavior == CLICKMODE_KILL) {
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor); wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
return; return;
@@ -349,45 +378,29 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
} }
void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) { void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
if (!PKEYBOARD) { // ???
Debug::log(ERR, "No active keyboard in processMouseDownNormal??");
return;
}
// notify the keybind manager // notify the keybind manager
static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue; static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
const auto PASS = g_pKeybindManager->onMouseEvent(e); const auto PASS = g_pKeybindManager->onMouseEvent(e);
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
if (!PASS && !*PPASSMOUSE) if (!PASS && !*PPASSMOUSE)
return; return;
switch (e->state) { switch (e->state) {
case WLR_BUTTON_PRESSED: case WLR_BUTTON_PRESSED:
if (*PFOLLOWMOUSE == 3) // don't refocus on full loose
break;
if (!g_pCompositor->m_sSeat.mouse->currentConstraint) if (!g_pCompositor->m_sSeat.mouse->currentConstraint)
refocus(); refocus();
// if clicked on a floating window make it top // if clicked on a floating window make it top
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_bIsFloating) if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow); g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal")) {
currentlyDraggedWindow = g_pCompositor->windowFromCursor();
dragButton = e->button;
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
return;
}
break; break;
case WLR_BUTTON_RELEASED: case WLR_BUTTON_RELEASED:
if (currentlyDraggedWindow) {
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
currentlyDraggedWindow = nullptr;
dragButton = -1;
}
break; break;
} }
@@ -402,7 +415,7 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
case WLR_BUTTON_PRESSED: { case WLR_BUTTON_PRESSED: {
const auto PWINDOW = g_pCompositor->m_pLastWindow; const auto PWINDOW = g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW)){ if (!PWINDOW) {
Debug::log(ERR, "Cannot kill invalid window!"); Debug::log(ERR, "Cannot kill invalid window!");
break; break;
} }
@@ -422,12 +435,17 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
} }
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) { void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
static auto *const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
bool passEvent = g_pKeybindManager->onAxisEvent(e); bool passEvent = g_pKeybindManager->onAxisEvent(e);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
if (passEvent) { if (passEvent) {
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source); wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta,
std::round(factor * e->delta_discrete), e->source);
} }
} }
@@ -441,7 +459,7 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->keyboard = keyboard; PNEWKEYBOARD->keyboard = keyboard;
try { try {
PNEWKEYBOARD->name = std::string(keyboard->name); PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Keyboard had no name???"); // logic error Debug::log(ERR, "Keyboard had no name???"); // logic error
} }
@@ -477,7 +495,7 @@ void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->isVirtual = true; PNEWKEYBOARD->isVirtual = true;
try { try {
PNEWKEYBOARD->name = std::string(keyboard->name); PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Keyboard had no name???"); // logic error Debug::log(ERR, "Keyboard had no name???"); // logic error
} }
@@ -514,7 +532,6 @@ void CInputManager::setKeyboardLayout() {
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
auto devname = pKeyboard->name; auto devname = pKeyboard->name;
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
@@ -638,7 +655,7 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
PMOUSE->mouse = mouse; PMOUSE->mouse = mouse;
PMOUSE->virt = virt; PMOUSE->virt = virt;
try { try {
PMOUSE->name = std::string(mouse->name); PMOUSE->name = getNameForNewDevice(mouse->name);
} catch(std::exception& e) { } catch(std::exception& e) {
Debug::log(ERR, "Mouse had no name???"); // logic error Debug::log(ERR, "Mouse had no name???"); // logic error
} }
@@ -649,12 +666,14 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
} }
setMouseConfigs(); wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
PMOUSE->connected = true;
setPointerConfigs();
PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse"); PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
g_pCompositor->m_sSeat.mouse = PMOUSE; g_pCompositor->m_sSeat.mouse = PMOUSE;
m_tmrLastCursorMovement.reset(); m_tmrLastCursorMovement.reset();
@@ -662,15 +681,25 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse); Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse);
} }
void CInputManager::setMouseConfigs() { void CInputManager::setPointerConfigs() {
for (auto& m : m_lMice) { for (auto& m : m_lMice) {
const auto PMOUSE = &m; const auto PPOINTER = &m;
auto devname = PMOUSE->name; auto devname = PPOINTER->name;
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
if (HASCONFIG) {
const auto ENABLED = g_pConfigManager->getDeviceInt(devname, "enabled");
if (ENABLED && !m.connected) {
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, m.mouse);
m.connected = true;
} else if (!ENABLED && m.connected) {
wlr_cursor_detach_input_device(g_pCompositor->m_sWLRCursor, m.mouse);
m.connected = false;
}
}
if (wlr_input_device_is_libinput(m.mouse)) { if (wlr_input_device_is_libinput(m.mouse)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse); const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);
@@ -679,6 +708,11 @@ void CInputManager::setMouseConfigs() {
else else
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "left_handed") : g_pConfigManager->getInt("input:left_handed")) == 0)
libinput_device_config_left_handed_set(LIBINPUTDEV, 0);
else
libinput_device_config_left_handed_set(LIBINPUTDEV, 1);
if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1) if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1)
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED); libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
@@ -686,6 +720,21 @@ void CInputManager::setMouseConfigs() {
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
} }
const auto SCROLLMETHOD = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "scroll_method") : g_pConfigManager->getString("input:scroll_method");
if (SCROLLMETHOD == "") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, libinput_device_config_scroll_get_default_method(LIBINPUTDEV));
} else if (SCROLLMETHOD == "no_scroll") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
} else if (SCROLLMETHOD == "2fg") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_2FG);
} else if (SCROLLMETHOD == "edge") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_EDGE);
} else if (SCROLLMETHOD == "on_button_down") {
libinput_device_config_scroll_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN);
} else {
Debug::log(WARN, "Scroll method unknown");
}
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0) if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0)
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
else else
@@ -710,10 +759,24 @@ void CInputManager::setMouseConfigs() {
} }
const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f); const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE);
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS); libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
const auto ACCELPROFILE = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "accel_profile") : g_pConfigManager->getString("input:accel_profile");
if (ACCELPROFILE == "") {
libinput_device_config_accel_set_profile(LIBINPUTDEV, libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
} else if (ACCELPROFILE == "adaptive") {
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE);
} else if (ACCELPROFILE == "flat") {
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
} else {
Debug::log(WARN, "Unknown acceleration profile, falling back to default");
}
const auto SCROLLBUTTON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "scroll_button") : g_pConfigManager->getInt("input:scroll_button");
libinput_device_config_scroll_set_button(LIBINPUTDEV, SCROLLBUTTON == 0 ? libinput_device_config_scroll_get_default_button(LIBINPUTDEV) : SCROLLBUTTON);
Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS); Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS);
} }
} }
@@ -752,6 +815,31 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
unconstrainMouse(); unconstrainMouse();
} }
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
if (keyboard->xkb_state == NULL) {
return;
}
uint32_t leds = 0;
for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
if (xkb_state_led_index_is_active(keyboard->xkb_state,
keyboard->led_indexes[i])) {
leds |= (1 << i);
}
}
for (auto& kb : m_lKeyboards) {
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
continue;
wlr_keyboard_led_update(wlr_keyboard_from_input_device(kb.keyboard), leds);
}
}
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) { void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
@@ -768,20 +856,29 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state); wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state);
} }
updateKeyboardsLeds(pKeyboard->keyboard);
} }
} }
void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard); const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard);
const auto ALLMODS = accumulateModsFromAllKBs();
auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
MODS.depressed = ALLMODS;
if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) { if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) {
wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_input_method_keyboard_grab_v2_send_modifiers(PIMEGRAB->pWlrKbGrab, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers); wlr_input_method_keyboard_grab_v2_send_modifiers(PIMEGRAB->pWlrKbGrab, &MODS);
} else { } else {
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers); wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS);
} }
updateKeyboardsLeds(pKeyboard->keyboard);
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard); const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) { if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
@@ -791,6 +888,10 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
} }
} }
bool CInputManager::shouldIgnoreVirtualKeyboard(SKeyboard* pKeyboard) {
return !pKeyboard || (m_sIMERelay.m_pKeyboardGrab && wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource));
}
void CInputManager::refocus() { void CInputManager::refocus() {
mouseMoveUnified(0, true); mouseMoveUnified(0, true);
} }
@@ -891,11 +992,7 @@ void CInputManager::unconstrainMouse() {
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (CONSTRAINTWINDOW) { if (CONSTRAINTWINDOW) {
if (CONSTRAINTWINDOW->m_bIsX11) { g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW), false);
wlr_xwayland_surface_activate(CONSTRAINTWINDOW->m_uSurface.xwayland, false);
} else {
wlr_xdg_toplevel_set_activated(CONSTRAINTWINDOW->m_uSurface.xdg->toplevel, false);
}
} }
wlr_pointer_constraint_v1_send_deactivated(g_pCompositor->m_sSeat.mouse->currentConstraint); wlr_pointer_constraint_v1_send_deactivated(g_pCompositor->m_sSeat.mouse->currentConstraint);
@@ -911,24 +1008,20 @@ void Events::listener_commitConstraint(void* owner, void* data) {
//g_pInputManager->recheckConstraint((SMouse*)owner); //g_pInputManager->recheckConstraint((SMouse*)owner);
} }
void CInputManager::updateCapabilities(wlr_input_device* pDev) { void CInputManager::updateCapabilities() {
// TODO: this is dumb uint32_t caps = 0;
switch (pDev->type) { if (!m_lKeyboards.empty())
case WLR_INPUT_DEVICE_KEYBOARD: caps |= WL_SEAT_CAPABILITY_KEYBOARD;
m_uiCapabilities |= WL_SEAT_CAPABILITY_KEYBOARD; if (!m_lMice.empty())
break; caps |= WL_SEAT_CAPABILITY_POINTER;
case WLR_INPUT_DEVICE_POINTER: if (!m_lTouchDevices.empty())
m_uiCapabilities |= WL_SEAT_CAPABILITY_POINTER; caps |= WL_SEAT_CAPABILITY_TOUCH;
break; if (!m_lTabletTools.empty())
case WLR_INPUT_DEVICE_TOUCH: caps |= WL_SEAT_CAPABILITY_POINTER;
m_uiCapabilities |= WL_SEAT_CAPABILITY_TOUCH;
break;
default:
break;
}
wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, m_uiCapabilities); wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, caps);
m_uiCapabilities = caps;
} }
uint32_t CInputManager::accumulateModsFromAllKBs() { uint32_t CInputManager::accumulateModsFromAllKBs() {
@@ -936,6 +1029,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
uint32_t finalMask = 0; uint32_t finalMask = 0;
for (auto& kb : m_lKeyboards) { for (auto& kb : m_lKeyboards) {
if (kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb))
continue;
finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard)); finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard));
} }
@@ -970,3 +1066,157 @@ void CInputManager::disableAllKeyboards(bool virt) {
k.active = false; k.active = false;
} }
} }
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
PNEWDEV->pWlrDevice = pDevice;
try {
PNEWDEV->name = getNameForNewDevice(pDevice->name);
} catch(std::exception& e) {
Debug::log(ERR, "Touch Device had no name???"); // logic error
}
setTouchDeviceConfigs();
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
Debug::log(LOG, "New touch device added at %x", PNEWDEV);
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
destroyTouchDevice((STouchDevice*)data);
}, PNEWDEV, "TouchDevice");
}
void CInputManager::setTouchDeviceConfigs() {
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
static const float MATRICES[8][6] = {
{ // normal
1, 0, 0,
0, 1, 0
},
{ // rotation 90°
0, -1, 1,
1, 0, 0
},
{ // rotation 180°
-1, 0, 1,
0, -1, 1
},
{ // rotation 270°
0, 1, 0,
-1, 0, 1
},
{ // flipped
-1, 0, 1,
0, 1, 0
},
{ // flipped + rotation 90°
0, 1, 0,
1, 0, 0
},
{ // flipped + rotation 180°
1, 0, 0,
0, -1, 1
},
{ // flipped + rotation 270°
0, -1, 1,
-1, 0, 1
}
};
for (auto& m : m_lTouchDevices) {
const auto PTOUCHDEV = &m;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PTOUCHDEV->name);
if (wlr_input_device_is_libinput(m.pWlrDevice)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice);
const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "touch_output") : g_pConfigManager->getString("input:touchdevice:output");
if (!OUTPUT.empty() && OUTPUT != STRVAL_EMPTY)
PTOUCHDEV->boundOutput = OUTPUT;
else
PTOUCHDEV->boundOutput = "";
}
}
}
void CInputManager::destroyTouchDevice(STouchDevice* pDevice) {
Debug::log(LOG, "Touch device at %x removed", pDevice);
m_lTouchDevices.remove(*pDevice);
}
void CInputManager::newSwitch(wlr_input_device* pDevice) {
const auto PNEWDEV = &m_lSwitches.emplace_back();
PNEWDEV->pWlrDevice = pDevice;
Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name);
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
destroySwitch((SSwitchDevice*)owner);
}, PNEWDEV, "SwitchDevice");
const auto PSWITCH = wlr_switch_from_input_device(pDevice);
PNEWDEV->hyprListener_toggle.initCallback(&PSWITCH->events.toggle, [&](void* owner, void* data) {
const auto PDEVICE = (SSwitchDevice*)owner;
const auto NAME = std::string(PDEVICE->pWlrDevice->name);
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
g_pKeybindManager->onSwitchEvent(NAME);
}, PNEWDEV, "SwitchDevice");
}
void CInputManager::destroySwitch(SSwitchDevice* pDevice) {
m_lSwitches.remove(*pDevice);
}
void CInputManager::setCursorImageUntilUnset(std::string name) {
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, name.c_str(), g_pCompositor->m_sWLRCursor);
m_bCursorImageOverriden = true;
}
void CInputManager::unsetCursorImage() {
if (!m_bCursorImageOverriden)
return;
m_bCursorImageOverriden = false;
if (!g_pHyprRenderer->m_bWindowRequestedCursorHide)
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
}
std::string CInputManager::deviceNameToInternalString(std::string in) {
std::replace(in.begin(), in.end(), ' ', '-');
std::transform(in.begin(), in.end(), in.begin(), ::tolower);
return in;
}
std::string CInputManager::getNameForNewDevice(std::string internalName) {
auto proposedNewName = deviceNameToInternalString(internalName);
int dupeno = 0;
while (std::find_if(m_lKeyboards.begin(), m_lKeyboards.end(), [&] (const SKeyboard& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lKeyboards.end())
dupeno++;
while (std::find_if(m_lMice.begin(), m_lMice.end(), [&] (const SMouse& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lMice.end())
dupeno++;
while (std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&] (const STouchDevice& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTouchDevices.end())
dupeno++;
while (std::find_if(m_lTabletPads.begin(), m_lTabletPads.end(), [&] (const STabletPad& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletPads.end())
dupeno++;
while (std::find_if(m_lTablets.begin(), m_lTablets.end(), [&] (const STablet& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTablets.end())
dupeno++;
while (std::find_if(m_lTabletTools.begin(), m_lTabletTools.end(), [&] (const STabletTool& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletTools.end())
dupeno++;
return proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno)));
}

View File

@@ -12,11 +12,21 @@ enum eClickBehaviorMode {
CLICKMODE_KILL CLICKMODE_KILL
}; };
enum eMouseBindMode {
MBIND_INVALID = -1,
MBIND_MOVE = 0,
MBIND_RESIZE
};
struct STouchData { struct STouchData {
CWindow* touchFocusWindow = nullptr; CWindow* touchFocusWindow = nullptr;
SLayerSurface* touchFocusLS = nullptr;
wlr_surface* touchFocusSurface = nullptr;
Vector2D touchSurfaceOrigin; Vector2D touchSurfaceOrigin;
}; };
class CKeybindManager;
class CInputManager { class CInputManager {
public: public:
@@ -30,8 +40,12 @@ public:
void newKeyboard(wlr_input_device*); void newKeyboard(wlr_input_device*);
void newVirtualKeyboard(wlr_input_device*); void newVirtualKeyboard(wlr_input_device*);
void newMouse(wlr_input_device*, bool virt = false); void newMouse(wlr_input_device*, bool virt = false);
void newTouchDevice(wlr_input_device*);
void newSwitch(wlr_input_device*);
void destroyTouchDevice(STouchDevice*);
void destroyKeyboard(SKeyboard*); void destroyKeyboard(SKeyboard*);
void destroyMouse(wlr_input_device*); void destroyMouse(wlr_input_device*);
void destroySwitch(SSwitchDevice*);
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*); void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
void recheckConstraint(SMouse*); void recheckConstraint(SMouse*);
@@ -42,10 +56,11 @@ public:
void refocus(); void refocus();
void setKeyboardLayout(); void setKeyboardLayout();
void setMouseConfigs(); void setPointerConfigs();
void setTouchDeviceConfigs();
void updateDragIcon(); void updateDragIcon();
void updateCapabilities(wlr_input_device*); void updateCapabilities();
void setClickMode(eClickBehaviorMode); void setClickMode(eClickBehaviorMode);
eClickBehaviorMode getClickMode(); eClickBehaviorMode getClickMode();
@@ -55,11 +70,14 @@ public:
void onTouchUp(wlr_touch_up_event*); void onTouchUp(wlr_touch_up_event*);
void onTouchMove(wlr_touch_motion_event*); void onTouchMove(wlr_touch_motion_event*);
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
STouchData m_sTouchData; STouchData m_sTouchData;
// for dragging floating windows // for dragging floating windows
CWindow* currentlyDraggedWindow = nullptr; CWindow* currentlyDraggedWindow = nullptr;
int dragButton = -1; eMouseBindMode dragMode = MBIND_INVALID;
SDrag m_sDrag; SDrag m_sDrag;
@@ -75,6 +93,12 @@ public:
// idle inhibitors // idle inhibitors
std::list<SIdleInhibitor> m_lIdleInhibitors; std::list<SIdleInhibitor> m_lIdleInhibitors;
// Touch devices
std::list<STouchDevice> m_lTouchDevices;
// Switches
std::list<SSwitchDevice> m_lSwitches;
void newTabletTool(wlr_input_device*); void newTabletTool(wlr_input_device*);
void newTabletPad(wlr_input_device*); void newTabletPad(wlr_input_device*);
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false); void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
@@ -93,17 +117,35 @@ public:
CInputMethodRelay m_sIMERelay; CInputMethodRelay m_sIMERelay;
void updateKeyboardsLeds(wlr_input_device* pKeyboard);
// for shared mods // for shared mods
uint32_t accumulateModsFromAllKBs(); uint32_t accumulateModsFromAllKBs();
CWindow* m_pFollowOnDnDBegin = nullptr; CWindow* m_pFollowOnDnDBegin = nullptr;
// for virtual keyboards: whether we should respect them as normal ones
bool shouldIgnoreVirtualKeyboard(SKeyboard*);
// for special cursors that we choose
void setCursorImageUntilUnset(std::string);
void unsetCursorImage();
std::string deviceNameToInternalString(std::string);
std::string getNameForNewDevice(std::string);
private: private:
bool m_bCursorImageOverriden = false;
// for click behavior override // for click behavior override
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT; eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
bool m_bEmptyFocusCursorSet = false;
Vector2D m_vLastCursorPosFloored = Vector2D(); Vector2D m_vLastCursorPosFloored = Vector2D();
// for some bugs in follow mouse 0
bool m_bLastFocusOnLS = false;
void processMouseDownNormal(wlr_pointer_button_event* e); void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e); void processMouseDownKill(wlr_pointer_button_event* e);
@@ -116,6 +158,16 @@ private:
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*); STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
void applyConfigToKeyboard(SKeyboard*); void applyConfigToKeyboard(SKeyboard*);
// this will be set after a refocus()
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
SLayerSurface* m_pFoundLSToFocus = nullptr;
CWindow* m_pFoundWindowToFocus = nullptr;
// swipe
void beginWorkspaceSwipe();
friend class CKeybindManager;
}; };
inline std::unique_ptr<CInputManager> g_pInputManager; inline std::unique_ptr<CInputManager> g_pInputManager;

View File

@@ -2,9 +2,7 @@
#include "InputManager.hpp" #include "InputManager.hpp"
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
CInputMethodRelay::CInputMethodRelay() { CInputMethodRelay::CInputMethodRelay() { }
}
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) { void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
if (m_pWLRIME) { if (m_pWLRIME) {
@@ -303,7 +301,7 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
const auto PINPUT = (STextInput*)owner; const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) { if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Enabling TextInput on no IME!"); // Debug::log(WARN, "Enabling TextInput on no IME!");
return; return;
} }
@@ -319,12 +317,12 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
const auto PINPUT = (STextInput*)owner; const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) { if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Committing TextInput on no IME!"); // Debug::log(WARN, "Committing TextInput on no IME!");
return; return;
} }
if (!PINPUT->pWlrInput->current_enabled) { if (!PINPUT->pWlrInput->current_enabled) {
Debug::log(ERR, "Disabled TextInput commit?"); Debug::log(WARN, "Disabled TextInput commit?");
return; return;
} }
@@ -337,7 +335,7 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
const auto PINPUT = (STextInput*)owner; const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) { if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Disabling TextInput on no IME!"); // Debug::log(WARN, "Disabling TextInput on no IME!");
return; return;
} }
@@ -354,7 +352,7 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
const auto PINPUT = (STextInput*)owner; const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) { if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Disabling TextInput on no IME!"); // Debug::log(WARN, "Disabling TextInput on no IME!");
return; return;
} }

View File

@@ -3,6 +3,8 @@
#include "../../defines.hpp" #include "../../defines.hpp"
#include "../../helpers/WLClasses.hpp" #include "../../helpers/WLClasses.hpp"
class CInputManager;
class CInputMethodRelay { class CInputMethodRelay {
public: public:
CInputMethodRelay(); CInputMethodRelay();
@@ -45,4 +47,5 @@ private:
void createNewTextInput(wlr_text_input_v3*); void createNewTextInput(wlr_text_input_v3*);
friend class CHyprRenderer; friend class CHyprRenderer;
friend class CInputManager;
}; };

View File

@@ -2,23 +2,27 @@
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) { void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue; static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue; static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
if (e->fingers != *PSWIPEFINGERS|| *PSWIPE == 0) if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
return; return;
int onMonitor = 0; int onMonitor = 0;
for (auto& w : g_pCompositor->m_vWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) { if (w->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID && !g_pCompositor->isWorkspaceSpecial(w->m_iID)) {
onMonitor++; onMonitor++;
} }
} }
if (onMonitor < 2) if (onMonitor < 2 && !*PSWIPENEW)
return; // disallow swiping when there's 1 workspace on a monitor return; // disallow swiping when there's 1 workspace on a monitor
beginWorkspaceSwipe();
}
void CInputManager::beginWorkspaceSwipe() {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str()); Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
@@ -28,44 +32,66 @@ void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor; m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
m_sActiveSwipe.avgSpeed = 0; m_sActiveSwipe.avgSpeed = 0;
m_sActiveSwipe.speedPoints = 0; m_sActiveSwipe.speedPoints = 0;
if (PWORKSPACE->m_bHasFullscreenWindow) {
for (auto& ls : g_pCompositor->m_pLastMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
ls->alpha = 255.f;
}
}
} }
void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) { void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
if (!m_sActiveSwipe.pWorkspaceBegin) if (!m_sActiveSwipe.pWorkspaceBegin)
return; // no valid swipe return; // no valid swipe
static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue; static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue;
static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue; static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue; static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue;
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
// commit // commit
std::string wsname = ""; std::string wsname = "";
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname); auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname); auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); if ((workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID || (workspaceIDRight == workspaceIDLeft && workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)) && *PSWIPENEW) {
workspaceIDRight = m_sActiveSwipe.pWorkspaceBegin->m_iID > 0 ? m_sActiveSwipe.pWorkspaceBegin->m_iID + 1 : 1;
}
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec(); const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
CWorkspace* pSwitchedTo = nullptr;
if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) { if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) {
// revert // revert
if (abs(m_sActiveSwipe.delta) < 2) { if (abs(m_sActiveSwipe.delta) < 2) {
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0)); PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
if (PWORKSPACER)
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0)); PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0)); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
} else { } else {
if (m_sActiveSwipe.delta < 0) { if (m_sActiveSwipe.delta < 0) {
// to left // to left
if (VERTANIMS)
PWORKSPACEL->m_vRenderOffset = Vector2D({0, -m_sActiveSwipe.pMonitor->vecSize.y});
else
PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0}); PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0});
} else { } else if (PWORKSPACER) {
// to right // to right
if (VERTANIMS)
PWORKSPACER->m_vRenderOffset = Vector2D({0, m_sActiveSwipe.pMonitor->vecSize.y});
else
PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0}); PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0});
} }
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
} }
pSwitchedTo = m_sActiveSwipe.pWorkspaceBegin;
} else if (m_sActiveSwipe.delta < 0) { } else if (m_sActiveSwipe.delta < 0) {
// switch to left // switch to left
const auto RENDEROFFSET = PWORKSPACEL->m_vRenderOffset.vec(); const auto RENDEROFFSET = PWORKSPACEL->m_vRenderOffset.vec();
@@ -76,39 +102,61 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f); PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
if (VERTANIMS)
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0, m_sActiveSwipe.pMonitor->vecSize.y);
else
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(m_sActiveSwipe.pMonitor->vecSize.x, 0); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the left"); Debug::log(LOG, "Ended swipe to the left");
pSwitchedTo = PWORKSPACEL;
} else { } else {
// switch to right // switch to right
const auto RENDEROFFSET = PWORKSPACER->m_vRenderOffset.vec(); const auto RENDEROFFSET = PWORKSPACER ? PWORKSPACER->m_vRenderOffset.vec() : Vector2D();
if (PWORKSPACER)
g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDRight)); g_pKeybindManager->m_mDispatchers["workspace"]("[internal]" + std::to_string(workspaceIDRight));
else
g_pKeybindManager->m_mDispatchers["workspace"](std::to_string(workspaceIDRight)); // so that the ID is created properly
if (!PWORKSPACER)
PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed on PSWIPENEW
PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET); PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET);
PWORKSPACER->m_fAlpha.setValueAndWarp(255.f); PWORKSPACER->m_fAlpha.setValueAndWarp(255.f);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
if (VERTANIMS)
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0, -m_sActiveSwipe.pMonitor->vecSize.y);
else
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-m_sActiveSwipe.pMonitor->vecSize.x, 0); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
g_pInputManager->unconstrainMouse(); g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the right"); Debug::log(LOG, "Ended swipe to the right");
pSwitchedTo = PWORKSPACER;
} }
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
PWORKSPACEL->m_bForceRendering = false; PWORKSPACEL->m_bForceRendering = false;
if (PWORKSPACER)
PWORKSPACER->m_bForceRendering = false; PWORKSPACER->m_bForceRendering = false;
m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false; m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;
m_sActiveSwipe.pWorkspaceBegin = nullptr; m_sActiveSwipe.pWorkspaceBegin = nullptr;
g_pInputManager->refocus(); g_pInputManager->refocus();
// apply alpha
for (auto& ls : g_pCompositor->m_pLastMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
ls->alpha = pSwitchedTo->m_bHasFullscreenWindow && pSwitchedTo->m_efFullscreenMode == FULLSCREEN_FULL ? 0.f : 255.f;
}
} }
void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
@@ -117,8 +165,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue; static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
static auto *const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue; static auto *const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
static auto *const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
m_sActiveSwipe.delta += *PSWIPEINVR ? -e->dx : e->dx; const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*PSWIPEINVR ? -e->dx : e->dx);
m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1); m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1);
m_sActiveSwipe.speedPoints++; m_sActiveSwipe.speedPoints++;
@@ -127,15 +179,25 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname); auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname); auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) if ((workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
return; return;
}
m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = true; m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = true;
m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST); m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
if ((m_sActiveSwipe.pWorkspaceBegin->m_iID == workspaceIDLeft && *PSWIPENEW && (m_sActiveSwipe.delta < 0)) ||
(m_sActiveSwipe.delta > 0 && g_pCompositor->getWindowsOnWorkspace(m_sActiveSwipe.pWorkspaceBegin->m_iID) == 0 && workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID) ||
(m_sActiveSwipe.delta < 0 && m_sActiveSwipe.pWorkspaceBegin->m_iID <= workspaceIDLeft)) {
m_sActiveSwipe.delta = 0;
return;
}
if (m_sActiveSwipe.delta < 0) { if (m_sActiveSwipe.delta < 0) {
if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID){ if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID && !*PSWIPENEW){
m_sActiveSwipe.delta = 0; m_sActiveSwipe.delta = 0;
return; return;
} }
@@ -152,12 +214,28 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
PWORKSPACER->m_fAlpha.setValueAndWarp(0.f); PWORKSPACER->m_fAlpha.setValueAndWarp(0.f);
} }
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); if (VERTANIMS) {
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0)); PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y - m_sActiveSwipe.pMonitor->vecSize.y));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
} else {
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
}
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft); g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft);
} else { } else {
if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID){ if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID) {
if (*PSWIPENEW) {
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
if (VERTANIMS)
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
else
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
return;
}
m_sActiveSwipe.delta = 0; m_sActiveSwipe.delta = 0;
return; return;
} }
@@ -174,8 +252,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
PWORKSPACEL->m_fAlpha.setValueAndWarp(0.f); PWORKSPACEL->m_fAlpha.setValueAndWarp(0.f);
} }
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); if (VERTANIMS) {
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0)); PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y + m_sActiveSwipe.pMonitor->vecSize.y));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
} else {
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
}
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight); g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight);
} }
@@ -183,4 +266,11 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID); g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
if (*PSWIPEFOREVER) {
if (abs(m_sActiveSwipe.delta) >= *PSWIPEDIST) {
onSwipeEnd(nullptr);
beginWorkspaceSwipe();
}
}
} }

View File

@@ -5,7 +5,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
const auto PNEWTABLET = &m_lTablets.emplace_back(); const auto PNEWTABLET = &m_lTablets.emplace_back();
try { try {
PNEWTABLET->name = std::string(pDevice->name); PNEWTABLET->name = deviceNameToInternalString(pDevice->name);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Tablet had no name???"); // logic error Debug::log(ERR, "Tablet had no name???"); // logic error
} }
@@ -158,7 +158,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
const auto PNEWPAD = &m_lTabletPads.emplace_back(); const auto PNEWPAD = &m_lTabletPads.emplace_back();
try { try {
PNEWPAD->name = std::string(pDevice->name); PNEWPAD->name = deviceNameToInternalString(pDevice->name);
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(ERR, "Pad had no name???"); // logic error Debug::log(ERR, "Pad had no name???"); // logic error
} }
@@ -219,7 +219,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) { void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTool); const auto PTOOL = g_pInputManager->ensureTabletToolPresent(pTool);
if (const auto PWINDOW = g_pCompositor->m_pLastWindow; g_pCompositor->windowValidMapped(PWINDOW)) { if (const auto PWINDOW = g_pCompositor->m_pLastWindow; PWINDOW) {
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal(); const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
const auto LOCAL = CURSORPOS - PWINDOW->m_vRealPosition.goalv(); const auto LOCAL = CURSORPOS - PWINDOW->m_vRealPosition.goalv();

View File

@@ -2,44 +2,76 @@
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
void CInputManager::onTouchDown(wlr_touch_down_event* e) { void CInputManager::onTouchDown(wlr_touch_down_event* e) {
auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, g_pCompositor->m_pLastMonitor->vecPosition.x + e->x * g_pCompositor->m_pLastMonitor->vecSize.x, g_pCompositor->m_pLastMonitor->vecPosition.y + e->y * g_pCompositor->m_pLastMonitor->vecSize.y); const auto PDEVIT = std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&](const STouchDevice& other) { return other.pWlrDevice == &e->touch->base; });
if (PDEVIT != m_lTouchDevices.end() && !PDEVIT->boundOutput.empty())
PMONITOR = g_pCompositor->getMonitorFromName(PDEVIT->boundOutput);
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_pLastMonitor;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
refocus(); refocus();
m_sTouchData.touchFocusWindow = nullptr; m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) {
Vector2D local; Vector2D local;
if (g_pCompositor->m_pLastWindow->m_bIsX11) {
local = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv(); if (m_sTouchData.touchFocusWindow) {
if (m_sTouchData.touchFocusWindow->m_bIsX11) {
local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition.goalv();
} else { } else {
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), g_pCompositor->m_pLastWindow, local); g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_sTouchData.touchFocusWindow, local);
} }
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
} else if (m_sTouchData.touchFocusLS) {
local = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_sTouchData.touchFocusLS->geometry.x, m_sTouchData.touchFocusLS->geometry.y) - g_pCompositor->m_pLastMonitor->vecPosition;
wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, e->time_msec, e->touch_id, local.x, local.y); m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
} else {
m_sTouchData.touchFocusWindow = g_pCompositor->m_pLastWindow; return; // oops, nothing found.
} }
wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, m_sTouchData.touchFocusSurface, e->time_msec, e->touch_id, local.x, local.y);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
} }
void CInputManager::onTouchUp(wlr_touch_up_event* e){ void CInputManager::onTouchUp(wlr_touch_up_event* e){
if (m_sTouchData.touchFocusSurface) {
if (m_sTouchData.touchFocusWindow) {
wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id); wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id);
} }
} }
void CInputManager::onTouchMove(wlr_touch_motion_event* e){ void CInputManager::onTouchMove(wlr_touch_motion_event* e){
if (g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) { if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y); wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin; const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y);
} else if (m_sTouchData.touchFocusLS) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLS->monitorID);
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y); wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y);
} }
} }
void CInputManager::onPointerHoldBegin(wlr_pointer_hold_begin_event* e) {
wlr_pointer_gestures_v1_send_hold_begin(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->fingers);
}
void CInputManager::onPointerHoldEnd(wlr_pointer_hold_end_event* e) {
wlr_pointer_gestures_v1_send_hold_end(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->cancelled);
}

View File

@@ -1,4 +1,4 @@
globber = run_command('find', '-name', '*.cpp', check: true) globber = run_command('find', '.', '-name', '*.cpp', check: true)
src = globber.stdout().strip().split('\n') src = globber.stdout().strip().split('\n')
executable('Hyprland', src, executable('Hyprland', src,
@@ -18,7 +18,7 @@ executable('Hyprland', src,
xcb_dep, xcb_dep,
dependency('pixman-1'), dependency('pixman-1'),
dependency('GL'), dependency('gl', 'opengl'),
dependency('threads') dependency('threads')
], ],
install : true install : true

View File

@@ -0,0 +1,392 @@
#include "ToplevelExport.hpp"
#include "../Compositor.hpp"
#include <drm_fourcc.h>
#include <algorithm>
#include "ToplevelExportWlrFuncs.hpp"
#define TOPLEVEL_EXPORT_VERSION 1
static void bindManagerInt(wl_client* client, void* data, uint32_t version, uint32_t id) {
g_pProtocolManager->m_pToplevelExportProtocolManager->bindManager(client, data, version, id);
}
static void handleDisplayDestroy(struct wl_listener* listener, void* data) {
g_pProtocolManager->m_pToplevelExportProtocolManager->displayDestroy();
}
void CToplevelExportProtocolManager::displayDestroy() {
wl_global_destroy(m_pGlobal);
}
CToplevelExportProtocolManager::CToplevelExportProtocolManager() {
#ifndef GLES32
Debug::log(WARN, "Toplevel sharing is not supported on LEGACY_RENDERER!");
return;
#endif
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, &hyprland_toplevel_export_manager_v1_interface,
TOPLEVEL_EXPORT_VERSION, this, bindManagerInt);
if (!m_pGlobal) {
Debug::log(ERR, "ToplevelExportManager could not start! Sharing windows will not work!");
return;
}
m_liDisplayDestroy.notify = handleDisplayDestroy;
wl_display_add_destroy_listener(g_pCompositor->m_sWLDisplay, &m_liDisplayDestroy);
Debug::log(LOG, "ToplevelExportManager started successfully!");
}
void handleCaptureToplevel(wl_client* client, wl_resource* resource, uint32_t frame, int32_t overlay_cursor, uint32_t handle) {
g_pProtocolManager->m_pToplevelExportProtocolManager->captureToplevel(client, resource, frame, overlay_cursor, handle);
}
void handleDestroy(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
void handleCopyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer, int32_t ignore_damage) {
g_pProtocolManager->m_pToplevelExportProtocolManager->copyFrame(client, resource, buffer, ignore_damage);
}
void handleDestroyFrame(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
static const struct hyprland_toplevel_export_manager_v1_interface toplevelExportManagerImpl = {
.capture_toplevel = handleCaptureToplevel,
.destroy = handleDestroy
};
static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {
.copy = handleCopyFrame,
.destroy = handleDestroyFrame
};
SToplevelClient* clientFromResource(wl_resource* resource) {
ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_manager_v1_interface, &toplevelExportManagerImpl));
return (SToplevelClient*)wl_resource_get_user_data(resource);
}
SToplevelFrame* frameFromResource(wl_resource* resource) {
ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_frame_v1_interface, &toplevelFrameImpl));
return (SToplevelFrame*)wl_resource_get_user_data(resource);
}
void CToplevelExportProtocolManager::removeClient(SToplevelClient* client, bool force) {
if (!force) {
if (!client || client->ref <= 0)
return;
if (--client->ref != 0)
return;
}
m_lClients.remove(*client); // TODO: this doesn't get cleaned up after sharing app exits???
}
void handleManagerResourceDestroy(wl_resource* resource) {
const auto PCLIENT = clientFromResource(resource);
g_pProtocolManager->m_pToplevelExportProtocolManager->removeClient(PCLIENT, true);
}
void CToplevelExportProtocolManager::bindManager(wl_client* client, void* data, uint32_t version, uint32_t id) {
const auto PCLIENT = &m_lClients.emplace_back();
PCLIENT->resource = wl_resource_create(client, &hyprland_toplevel_export_manager_v1_interface,
version, id);
if (!PCLIENT->resource) {
Debug::log(ERR, "ToplevelExportManager could not bind! (out of memory?)");
m_lClients.remove(*PCLIENT);
wl_client_post_no_memory(client);
return;
}
PCLIENT->ref = 1;
wl_resource_set_implementation(PCLIENT->resource, &toplevelExportManagerImpl, PCLIENT, handleManagerResourceDestroy);
Debug::log(LOG, "ToplevelExportManager bound successfully!");
}
void handleFrameResourceDestroy(wl_resource* resource) {
const auto PFRAME = frameFromResource(resource);
g_pProtocolManager->m_pToplevelExportProtocolManager->removeFrame(PFRAME);
}
void CToplevelExportProtocolManager::removeFrame(SToplevelFrame* frame, bool force) {
if (!frame)
return;
std::erase_if(m_vFramesAwaitingWrite, [&] (const auto& other) { return other == frame; });
wl_resource_set_user_data(frame->resource, nullptr);
wlr_buffer_unlock(frame->buffer);
removeClient(frame->client, force);
m_lFrames.remove(*frame);
}
void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resource* resource, uint32_t frame, int32_t overlay_cursor, uint32_t handle) {
const auto PCLIENT = clientFromResource(resource);
const auto PWINDOW = g_pCompositor->getWindowFromHandle(handle);
// create a frame
const auto PFRAME = &m_lFrames.emplace_back();
PFRAME->overlayCursor = !!overlay_cursor;
PFRAME->resource = wl_resource_create(client, &hyprland_toplevel_export_frame_v1_interface, wl_resource_get_version(resource), frame);
PFRAME->pWindow = PWINDOW;
if (!PWINDOW) {
Debug::log(ERR, "Client requested sharing of window handle %x which does not exist!", handle);
hyprland_toplevel_export_frame_v1_send_failed(PFRAME->resource);
removeFrame(PFRAME);
return;
}
if (!PWINDOW->m_bIsMapped || PWINDOW->isHidden()) {
Debug::log(ERR, "Client requested sharing of window handle %x which is not shareable!", handle);
hyprland_toplevel_export_frame_v1_send_failed(PFRAME->resource);
removeFrame(PFRAME);
return;
}
if (!PFRAME->resource) {
Debug::log(ERR, "Couldn't alloc frame for sharing! (no memory)");
m_lFrames.remove(*PFRAME);
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(PFRAME->resource, &toplevelFrameImpl, PFRAME, handleFrameResourceDestroy);
PFRAME->client = PCLIENT;
PCLIENT->ref++;
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
PFRAME->shmFormat = wlr_output_preferred_read_format(PMONITOR->output);
if (PFRAME->shmFormat == DRM_FORMAT_INVALID) {
Debug::log(ERR, "No format supported by renderer in capture toplevel");
hyprland_toplevel_export_frame_v1_send_failed(resource);
removeFrame(PFRAME);
return;
}
const auto PSHMINFO = drm_get_pixel_format_info(PFRAME->shmFormat);
if (!PSHMINFO) {
Debug::log(ERR, "No pixel format supported by renderer in capture toplevel");
hyprland_toplevel_export_frame_v1_send_failed(resource);
removeFrame(PFRAME);
return;
}
if (PMONITOR->output->allocator && (PMONITOR->output->allocator->buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
PFRAME->dmabufFormat = PMONITOR->output->render_format;
} else {
PFRAME->dmabufFormat = DRM_FORMAT_INVALID;
}
PFRAME->box = {0, 0, (int)PWINDOW->m_vRealSize.vec().x, (int)PWINDOW->m_vRealSize.vec().y};
int ow, oh;
wlr_output_effective_resolution(PMONITOR->output, &ow, &oh);
wlr_box_transform(&PFRAME->box, &PFRAME->box, PMONITOR->transform, ow, oh);
PFRAME->shmStride = (PSHMINFO->bpp / 8) * PFRAME->box.width;
hyprland_toplevel_export_frame_v1_send_buffer(PFRAME->resource, convert_drm_format_to_wl_shm(PFRAME->shmFormat), PFRAME->box.width, PFRAME->box.height, PFRAME->shmStride);
}
void CToplevelExportProtocolManager::copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer, int32_t ignore_damage) {
const auto PFRAME = frameFromResource(resource);
if (!PFRAME) {
Debug::log(ERR, "No frame in copyFrame??");
return;
}
if (!PFRAME->pWindow->m_bIsMapped || PFRAME->pWindow->isHidden()) {
Debug::log(ERR, "Client requested sharing of window handle %x which is not shareable (2)!", PFRAME->pWindow);
hyprland_toplevel_export_frame_v1_send_failed(PFRAME->resource);
removeFrame(PFRAME);
return;
}
const auto PBUFFER = wlr_buffer_from_resource(buffer);
if (!PBUFFER) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer");
removeFrame(PFRAME);
return;
}
if (PBUFFER->width != PFRAME->box.width || PBUFFER->height != PFRAME->box.height) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions");
removeFrame(PFRAME);
return;
}
if (PFRAME->buffer) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_ALREADY_USED, "frame already used");
removeFrame(PFRAME);
return;
}
wlr_dmabuf_attributes dmabufAttrs;
void* wlrBufferAccessData;
uint32_t wlrBufferAccessFormat;
size_t wlrBufferAccessStride;
if (wlr_buffer_get_dmabuf(PBUFFER, &dmabufAttrs)) {
PFRAME->bufferCap = WLR_BUFFER_CAP_DMABUF;
if (dmabufAttrs.format != PFRAME->dmabufFormat) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
removeFrame(PFRAME);
return;
}
} else if (wlr_buffer_begin_data_ptr_access(PBUFFER, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &wlrBufferAccessData, &wlrBufferAccessFormat, &wlrBufferAccessStride)) {
wlr_buffer_end_data_ptr_access(PBUFFER);
if (wlrBufferAccessFormat != PFRAME->shmFormat) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
removeFrame(PFRAME);
return;
} else if ((int)wlrBufferAccessStride != PFRAME->shmStride) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
removeFrame(PFRAME);
return;
}
} else {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer type");
removeFrame(PFRAME);
return;
}
PFRAME->buffer = PBUFFER;
m_vFramesAwaitingWrite.emplace_back(PFRAME);
}
void CToplevelExportProtocolManager::onMonitorRender(CMonitor* pMonitor) {
if (m_vFramesAwaitingWrite.empty())
return; // nothing to share
std::vector<SToplevelFrame*> framesToRemove;
// share frame if correct output
for (auto& f : m_vFramesAwaitingWrite) {
if (!f->pWindow) {
framesToRemove.push_back(f);
continue;
}
wlr_box geometry = { f->pWindow->m_vRealPosition.vec().x, f->pWindow->m_vRealPosition.vec().y,
f->pWindow->m_vRealSize.vec().x, f->pWindow->m_vRealSize.vec().y };
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
continue;
shareFrame(f);
framesToRemove.push_back(f);
}
for (auto& f : framesToRemove) {
removeFrame(f);
}
}
void CToplevelExportProtocolManager::shareFrame(SToplevelFrame* frame) {
if (!frame->buffer) {
return;
}
// TODO: damage
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
uint32_t flags = 0;
if (frame->bufferCap == WLR_BUFFER_CAP_DMABUF) {
if (!copyFrameDmabuf(frame)) {
hyprland_toplevel_export_frame_v1_send_failed(frame->resource);
return;
}
} else {
if (!copyFrameShm(frame, &now)) {
hyprland_toplevel_export_frame_v1_send_failed(frame->resource);
return;
}
}
hyprland_toplevel_export_frame_v1_send_flags(frame->resource, flags);
// todo: send damage
uint32_t tvSecHi = (sizeof(now.tv_sec) > 4) ? now.tv_sec >> 32 : 0;
uint32_t tvSecLo = now.tv_sec & 0xFFFFFFFF;
hyprland_toplevel_export_frame_v1_send_ready(frame->resource, tvSecHi, tvSecLo, now.tv_nsec);
}
bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespec* now) {
void* data;
uint32_t format;
size_t stride;
if (!wlr_buffer_begin_data_ptr_access(frame->buffer, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &data, &format, &stride))
return false;
// render the client
const auto PMONITOR = g_pCompositor->getMonitorFromID(frame->pWindow->m_iMonitorID);
pixman_region32_t fakeDamage;
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
g_pHyprOpenGL->begin(PMONITOR, &fakeDamage, true);
g_pHyprOpenGL->clear(CColor(0, 0, 0, 255));
// render client at 0,0
g_pHyprRenderer->m_bBlockSurfaceFeedback = g_pHyprRenderer->shouldRenderWindow(frame->pWindow); // block the feedback to avoid spamming the surface if it's visible
g_pHyprRenderer->renderWindow(frame->pWindow, PMONITOR, now, false, RENDER_PASS_ALL, true, true);
g_pHyprRenderer->m_bBlockSurfaceFeedback = false;
// copy pixels
const auto PFORMAT = get_gles2_format_from_drm(format);
if (!PFORMAT) {
Debug::log(ERR, "Cannot read pixels, unsupported format %x", PFORMAT);
g_pHyprOpenGL->end();
pixman_region32_fini(&fakeDamage);
wlr_buffer_end_data_ptr_access(frame->buffer);
return false;
}
glBindFramebuffer(GL_FRAMEBUFFER, g_pHyprOpenGL->m_RenderData.pCurrentMonData->primaryFB.m_iFb);
glFinish(); // flush
glReadPixels(0, 0, frame->box.width, frame->box.height, PFORMAT->gl_format, PFORMAT->gl_type, data);
g_pHyprOpenGL->end();
pixman_region32_fini(&fakeDamage);
wlr_buffer_end_data_ptr_access(frame->buffer);
return true;
}
bool CToplevelExportProtocolManager::copyFrameDmabuf(SToplevelFrame* frame) {
// todo
Debug::log(ERR, "DMABUF copying not impl'd!");
return false;
}
void CToplevelExportProtocolManager::onWindowUnmap(CWindow* pWindow) {
for (auto& f : m_lFrames) {
if (f.pWindow == pWindow)
f.pWindow = nullptr;
}
}

View File

@@ -0,0 +1,69 @@
#pragma once
#include "../defines.hpp"
#include "hyprland-toplevel-export-v1-protocol.h"
#include <list>
#include <vector>
class CMonitor;
class CWindow;
struct SToplevelClient {
int ref = 0;
wl_resource* resource = nullptr;
bool operator==(const SToplevelClient& other) {
return resource == other.resource;
}
};
struct SToplevelFrame {
wl_resource* resource = nullptr;
SToplevelClient* client = nullptr;
uint32_t shmFormat = 0;
uint32_t dmabufFormat = 0;
wlr_box box = { 0 };
int shmStride = 0;
bool overlayCursor = false;
wlr_buffer_cap bufferCap = WLR_BUFFER_CAP_SHM;
wlr_buffer* buffer = nullptr;
CWindow* pWindow = nullptr;
bool operator==(const SToplevelFrame& other) {
return resource == other.resource && client == other.client;
}
};
class CToplevelExportProtocolManager {
public:
CToplevelExportProtocolManager();
void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
void captureToplevel(wl_client* client, wl_resource* resource, uint32_t frame, int32_t overlay_cursor, uint32_t handle);
void removeClient(SToplevelClient* client, bool force = false);
void removeFrame(SToplevelFrame* frame, bool force = false);
void copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer, int32_t ignore_damage);
void onMonitorRender(CMonitor* pMonitor);
void displayDestroy();
void onWindowUnmap(CWindow* pWindow);
private:
wl_global* m_pGlobal = nullptr;
std::list<SToplevelFrame> m_lFrames;
std::list<SToplevelClient> m_lClients;
wl_listener m_liDisplayDestroy;
std::vector<SToplevelFrame*> m_vFramesAwaitingWrite;
void shareFrame(SToplevelFrame* frame);
bool copyFrameDmabuf(SToplevelFrame* frame);
bool copyFrameShm(SToplevelFrame* frame, timespec* now);
};

View File

@@ -0,0 +1,312 @@
#include <GLES2/gl2ext.h>
struct wlr_pixel_format_info {
uint32_t drm_format;
/* Equivalent of the format if it has an alpha channel,
* DRM_FORMAT_INVALID (0) if NA
*/
uint32_t opaque_substitute;
/* Bits per pixels */
uint32_t bpp;
/* True if the format has an alpha channel */
bool has_alpha;
};
static const struct wlr_pixel_format_info pixel_format_info[] = {
{
.drm_format = DRM_FORMAT_XRGB8888,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ARGB8888,
.opaque_substitute = DRM_FORMAT_XRGB8888,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR8888,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR8888,
.opaque_substitute = DRM_FORMAT_XBGR8888,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_RGBX8888,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBA8888,
.opaque_substitute = DRM_FORMAT_RGBX8888,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_BGRX8888,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_BGRA8888,
.opaque_substitute = DRM_FORMAT_BGRX8888,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_BGR888,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 24,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBX4444,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 16,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBA4444,
.opaque_substitute = DRM_FORMAT_RGBX4444,
.bpp = 16,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_RGBX5551,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 16,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBA5551,
.opaque_substitute = DRM_FORMAT_RGBX5551,
.bpp = 16,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_RGB565,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 16,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_BGR565,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 16,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_XRGB2101010,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ARGB2101010,
.opaque_substitute = DRM_FORMAT_XRGB2101010,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR2101010,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 32,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR2101010,
.opaque_substitute = DRM_FORMAT_XBGR2101010,
.bpp = 32,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR16161616F,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 64,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR16161616F,
.opaque_substitute = DRM_FORMAT_XBGR16161616F,
.bpp = 64,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR16161616,
.opaque_substitute = DRM_FORMAT_INVALID,
.bpp = 64,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR16161616,
.opaque_substitute = DRM_FORMAT_XBGR16161616,
.bpp = 64,
.has_alpha = true,
},
};
static const size_t pixel_format_info_size =
sizeof(pixel_format_info) / sizeof(pixel_format_info[0]);
const struct wlr_pixel_format_info* drm_get_pixel_format_info(uint32_t fmt) {
for (size_t i = 0; i < pixel_format_info_size; ++i) {
if (pixel_format_info[i].drm_format == fmt) {
return &pixel_format_info[i];
}
}
return NULL;
}
uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt) {
switch (fmt) {
case WL_SHM_FORMAT_XRGB8888:
return DRM_FORMAT_XRGB8888;
case WL_SHM_FORMAT_ARGB8888:
return DRM_FORMAT_ARGB8888;
default:
return (uint32_t)fmt;
}
}
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt) {
switch (fmt) {
case DRM_FORMAT_XRGB8888:
return WL_SHM_FORMAT_XRGB8888;
case DRM_FORMAT_ARGB8888:
return WL_SHM_FORMAT_ARGB8888;
default:
return (enum wl_shm_format)fmt;
}
}
struct wlr_gles2_pixel_format {
uint32_t drm_format;
// optional field, if empty then internalformat = format
GLint gl_internalformat;
GLint gl_format, gl_type;
bool has_alpha;
};
static const struct wlr_gles2_pixel_format formats[] = {
{
.drm_format = DRM_FORMAT_ARGB8888,
.gl_format = GL_BGRA_EXT,
.gl_type = GL_UNSIGNED_BYTE,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XRGB8888,
.gl_format = GL_BGRA_EXT,
.gl_type = GL_UNSIGNED_BYTE,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_XBGR8888,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_BYTE,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR8888,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_BYTE,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_BGR888,
.gl_format = GL_RGB,
.gl_type = GL_UNSIGNED_BYTE,
.has_alpha = false,
},
#if WLR_LITTLE_ENDIAN
{
.drm_format = DRM_FORMAT_RGBX4444,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT_4_4_4_4,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBA4444,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT_4_4_4_4,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_RGBX5551,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT_5_5_5_1,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_RGBA5551,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT_5_5_5_1,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_RGB565,
.gl_format = GL_RGB,
.gl_type = GL_UNSIGNED_SHORT_5_6_5,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_XBGR2101010,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR2101010,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_INT_2_10_10_10_REV_EXT,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR16161616F,
.gl_format = GL_RGBA,
.gl_type = GL_HALF_FLOAT_OES,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR16161616F,
.gl_format = GL_RGBA,
.gl_type = GL_HALF_FLOAT_OES,
.has_alpha = true,
},
{
.drm_format = DRM_FORMAT_XBGR16161616,
.gl_internalformat = GL_RGBA16_EXT,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT,
.has_alpha = false,
},
{
.drm_format = DRM_FORMAT_ABGR16161616,
.gl_internalformat = GL_RGBA16_EXT,
.gl_format = GL_RGBA,
.gl_type = GL_UNSIGNED_SHORT,
.has_alpha = true,
},
#endif
};
const struct wlr_gles2_pixel_format* get_gles2_format_from_drm(uint32_t fmt) {
for (size_t i = 0; i < sizeof(formats) / sizeof(*formats); ++i) {
if (formats[i].drm_format == fmt) {
return &formats[i];
}
}
return NULL;
}

View File

@@ -3,6 +3,7 @@
bool CFramebuffer::alloc(int w, int h) { bool CFramebuffer::alloc(int w, int h) {
bool firstAlloc = false; bool firstAlloc = false;
RASSERT((w > 1 && h > 1), "cannot alloc a FB with negative / zero size! (attempted %ix%i)", w, h);
if (m_iFb == (uint32_t)-1) { if (m_iFb == (uint32_t)-1) {
firstAlloc = true; firstAlloc = true;
@@ -26,7 +27,6 @@ bool CFramebuffer::alloc(int w, int h) {
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);
// TODO: Allow this with gles2 // TODO: Allow this with gles2
#ifndef GLES2 #ifndef GLES2
if (m_pStencilTex) { if (m_pStencilTex) {
@@ -73,8 +73,13 @@ void CFramebuffer::release() {
m_cTex.m_iTexID = 0; m_cTex.m_iTexID = 0;
m_iFb = -1; m_iFb = -1;
m_Size = Vector2D();
} }
CFramebuffer::~CFramebuffer() { CFramebuffer::~CFramebuffer() {
release(); release();
} }
bool CFramebuffer::isAllocated() {
return m_iFb != (GLuint)-1;
}

View File

@@ -12,6 +12,7 @@ public:
void bind(); void bind();
void release(); void release();
void reset(); void reset();
bool isAllocated();
Vector2D m_Position; Vector2D m_Position;
Vector2D m_Size; Vector2D m_Size;

File diff suppressed because it is too large Load Diff

View File

@@ -8,16 +8,12 @@
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include "Shaders.hpp"
#include "Shader.hpp" #include "Shader.hpp"
#include "Texture.hpp" #include "Texture.hpp"
#include "Framebuffer.hpp" #include "Framebuffer.hpp"
inline const float matrixFlip180[] = { class CHyprRenderer;
1.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
};
inline const float fullVerts[] = { inline const float fullVerts[] = {
1, 0, // top right 1, 0, // top right
0, 0, // top left 0, 0, // top left
@@ -33,8 +29,10 @@ inline const float fanVertsFull[] = {
struct SMonitorRenderData { struct SMonitorRenderData {
CFramebuffer primaryFB; CFramebuffer primaryFB;
CFramebuffer mirrorFB; CFramebuffer mirrorFB; // these are used for some effects,
CFramebuffer mirrorSwapFB; CFramebuffer mirrorSwapFB; // etc
CFramebuffer monitorMirrorFB; // used for mirroring outputs
CTexture stencilTex; CTexture stencilTex;
@@ -66,8 +64,12 @@ struct SCurrentRenderData {
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1); Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1); Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
wlr_box clipBox = {};
}; };
class CGradientValueData;
class CHyprOpenGLImpl { class CHyprOpenGLImpl {
public: public:
@@ -80,20 +82,21 @@ public:
void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0);
void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false); void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false);
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false); void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false);
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0); void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0); void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
void renderBorder(wlr_box*, const CColor&, int round); void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
void makeWindowSnapshot(CWindow*); void makeWindowSnapshot(CWindow*);
void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
void makeLayerSnapshot(SLayerSurface*); void makeLayerSnapshot(SLayerSurface*);
void renderSnapshot(CWindow**); void renderSnapshot(CWindow**);
void renderSnapshot(SLayerSurface**); void renderSnapshot(SLayerSurface**);
void clear(const CColor&); void clear(const CColor&);
void clearWithTex(); void clearWithTex();
void scissor(const wlr_box*); void scissor(const wlr_box*, bool transform = true);
void scissor(const pixman_box32*); void scissor(const pixman_box32*, bool transform = true);
void scissor(const int x, const int y, const int w, const int h); void scissor(const int x, const int y, const int w, const int h, bool transform = true);
void destroyMonitorResources(CMonitor*); void destroyMonitorResources(CMonitor*);
@@ -102,11 +105,21 @@ public:
void preWindowPass(); void preWindowPass();
void preRender(CMonitor*); void preRender(CMonitor*);
void saveBufferForMirror();
void renderMirrored();
void onWindowResizeStart(CWindow*);
void onWindowResizeEnd(CWindow*);
void applyScreenShader(const std::string& path);
SCurrentRenderData m_RenderData; SCurrentRenderData m_RenderData;
GLint m_iCurrentOutputFb = 0; GLint m_iCurrentOutputFb = 0;
GLint m_iWLROutputFb = 0; GLint m_iWLROutputFb = 0;
bool m_bReloadScreenShader = true; // at launch it can be set
CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window
pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region
@@ -125,20 +138,24 @@ private:
bool m_bFakeFrame = false; bool m_bFakeFrame = false;
bool m_bEndFrame = false; bool m_bEndFrame = false;
bool m_bApplyFinalShader = false;
GLuint createProgram(const std::string&, const std::string&); CShader m_sFinalScreenShader;
GLuint compileShader(const GLuint&, std::string);
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
void createBGTextureForMonitor(CMonitor*); void createBGTextureForMonitor(CMonitor*);
void initShaders(); void initShaders();
// returns the out FB, can be either Mirror or MirrorSwap // returns the out FB, can be either Mirror or MirrorSwap
CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage); CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage);
void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false, bool allowCustomUV = false); void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false, bool allowCustomUV = false, bool allowDim = false);
void renderSplash(cairo_t *const, cairo_surface_t *const, double);
void renderSplash(cairo_t *const, cairo_surface_t *const);
void preBlurForCurrentMonitor(); void preBlurForCurrentMonitor();
friend class CHyprRenderer;
}; };
inline std::unique_ptr<CHyprOpenGLImpl> g_pHyprOpenGL; inline std::unique_ptr<CHyprOpenGLImpl> g_pHyprOpenGL;

View File

@@ -1,5 +1,6 @@
#include "Renderer.hpp" #include "Renderer.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "linux-dmabuf-unstable-v1-protocol.h"
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
const auto TEXTURE = wlr_surface_get_texture(surface); const auto TEXTURE = wlr_surface_get_texture(surface);
@@ -15,13 +16,8 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
if (RDATA->surface && surface == RDATA->surface) if (RDATA->surface && surface == RDATA->surface)
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h}; windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h};
else // here we clamp to 2, these might be some tiny specks else // here we clamp to 2, these might be some tiny specks
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::clamp(surface->current.width, 2, 1337420), std::clamp(surface->current.height, 2, 1337420)}; windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)};
// squish all oversized but dont in some cases, jesus christ this is a mess
// TODO: this shouldn't be done this way. Custom UV here as well.
// this is fucking horrible
// Issue: will cause oversized apps with reserved area to overflow from the window box. (see chromium on ozone wayland)
const auto PRESQUISHSIZE = Vector2D(windowBox.width, windowBox.height);
if (RDATA->squishOversized) { if (RDATA->squishOversized) {
if (x + windowBox.width > RDATA->w) if (x + windowBox.width > RDATA->w)
windowBox.width = RDATA->w - x; windowBox.width = RDATA->w - x;
@@ -29,6 +25,9 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
windowBox.height = RDATA->h - y; windowBox.height = RDATA->h - y;
} }
if (RDATA->pWindow)
g_pHyprRenderer->calculateUVForWindowSurface(RDATA->pWindow, surface, RDATA->squishOversized);
scaleBox(&windowBox, RDATA->output->scale); scaleBox(&windowBox, RDATA->output->scale);
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
@@ -43,32 +42,23 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
} else { } else {
if (RDATA->blur) if (RDATA->blur)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding); g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, RDATA->blockBlurOptimization);
else else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
} }
} }
else { else {
if (RDATA->surface && wlr_surface_is_xdg_surface(RDATA->surface)) { g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
wlr_box geo;
wlr_xdg_surface_get_geometry(wlr_xdg_surface_from_wlr_surface(RDATA->surface), &geo);
// TODO: continuation of the above madness.
if (geo.x != 0 || geo.y != 0) {
windowBox.width = PRESQUISHSIZE.x;
windowBox.height = PRESQUISHSIZE.y;
}
windowBox.x -= geo.x;
windowBox.y -= geo.y;
}
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, false);
} }
if (!g_pHyprRenderer->m_bBlockSurfaceFeedback) {
wlr_surface_send_frame_done(surface, RDATA->when); wlr_surface_send_frame_done(surface, RDATA->when);
wlr_presentation_surface_sampled_on_output(g_pCompositor->m_sWLRPresentation, surface, RDATA->output); wlr_presentation_surface_sampled_on_output(g_pCompositor->m_sWLRPresentation, surface, RDATA->output);
}
// reset the UV, we might've set it above
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
} }
bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) { bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
@@ -77,11 +67,14 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry)) if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
return false; return false;
if (pWindow->m_bPinned)
return true;
// now check if it has the same workspace // now check if it has the same workspace
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID) { if (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID) {
if (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()) { if (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering) {
return true; return true;
} else { } else {
if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen))) if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen)))
@@ -93,12 +86,10 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
return true; return true;
// if not, check if it maybe is active on a different monitor. // if not, check if it maybe is active on a different monitor.
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) && pWindow->m_bIsFloating /* tiled windows can't be multi-ws */)
(PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_bForceRendering) || // vvvv might be in animation progress vvvvv
(PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
return !pWindow->m_bIsFullscreen; // Do not draw fullscreen windows on other monitors return !pWindow->m_bIsFullscreen; // Do not draw fullscreen windows on other monitors
if (pMonitor->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (pMonitor->specialWorkspaceID && g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
return true; return true;
return false; return false;
@@ -111,6 +102,9 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (pWindow->m_bPinned || PWORKSPACE->m_bForceRendering)
return true;
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID))
return true; return true;
@@ -118,7 +112,7 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())) if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()))
return true; return true;
if (m->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (m->specialWorkspaceID && g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
return true; return true;
} }
@@ -128,11 +122,39 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr; CWindow* pWorkspaceWindow = nullptr;
// loop over the tiled windows that are fading out
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID != pMonitor->activeWorkspace)
continue;
if (w->m_fAlpha.fl() == 0.f)
continue;
if (w->m_bIsFullscreen || w->m_bIsFloating)
continue;
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
}
// and floating ones too
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID != pMonitor->activeWorkspace)
continue;
if (w->m_fAlpha.fl() == 0.f)
continue;
if (w->m_bIsFullscreen || !w->m_bIsFloating)
continue;
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
}
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen){ if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen){
if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()))) if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering)))
continue; continue;
if (w->m_iMonitorID != pMonitor->ID) if (w->m_iMonitorID != pMonitor->ID)
@@ -147,20 +169,26 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
pWorkspaceWindow = w.get(); pWorkspaceWindow = w.get();
} }
// then render windows over fullscreen if (!pWorkspaceWindow) {
// ?? happens sometimes...
pWorkspace->m_bHasFullscreenWindow = false;
return; // this will produce one blank frame. Oh well.
}
// then render windows over fullscreen.
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID != pWorkspaceWindow->m_iWorkspaceID || !w->m_bCreatedOverFullscreen || !w->m_bIsMapped) if (w->m_iWorkspaceID != pWorkspaceWindow->m_iWorkspaceID || (!w->m_bCreatedOverFullscreen && !w->m_bPinned) || !w->m_bIsMapped)
continue; continue;
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
} }
// and then special windows // and then special windows
for (auto& w : g_pCompositor->m_vWindows) { if (pMonitor->specialWorkspaceID) for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut) if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
continue; continue;
if (w->m_iWorkspaceID != SPECIAL_WORKSPACE_ID) if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor))
@@ -171,12 +199,11 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
} }
// and the overlay layers // and the overlay layers
if (pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL) {
// on non-full we draw the bar and shit
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
if (ls->alpha.fl() != 0.f)
renderLayer(ls.get(), pMonitor, time); renderLayer(ls.get(), pMonitor, time);
} }
}
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) { for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
renderLayer(ls.get(), pMonitor, time); renderLayer(ls.get(), pMonitor, time);
@@ -189,8 +216,8 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
g_pHyprError->draw(); g_pHyprError->draw();
} }
void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode) { void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode, bool ignorePosition, bool ignoreAllGeometry) {
if (pWindow->m_bHidden) if (pWindow->isHidden())
return; return;
if (pWindow->m_bFadingOut) { if (pWindow->m_bFadingOut) {
@@ -200,19 +227,33 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
} }
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
const auto REALPOS = pWindow->m_vRealPosition.vec() + PWORKSPACE->m_vRenderOffset.vec(); const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec());
static const auto PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue; static auto *const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue;
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y}; SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
if (ignorePosition) {
renderdata.x = pMonitor->vecPosition.x;
renderdata.y = pMonitor->vecPosition.y;
}
if (ignoreAllGeometry)
decorate = false;
renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow); renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow);
renderdata.w = std::clamp(pWindow->m_vRealSize.vec().x, (double)5, (double)1337420); // clamp the size to min 5, renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5,
renderdata.h = std::clamp(pWindow->m_vRealSize.vec().y, (double)5, (double)1337420); // otherwise we'll have issues later with invalid boxes renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes
renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding); renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding);
renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f); renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : (PWORKSPACE->m_fAlpha.fl() / 255.f));
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl(); renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl();
renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL);
renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding; renderdata.rounding = ignoreAllGeometry ? 0 : pWindow->m_sAdditionalConfigData.rounding;
renderdata.blur = true; // if it shouldn't, it will be ignored later renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later
renderdata.pWindow = pWindow;
if (ignoreAllGeometry) {
renderdata.alpha = 1.f;
renderdata.fadeAlpha = 255.f;
}
// apply window special data // apply window special data
if (pWindow->m_sSpecialRenderData.alphaInactive == -1) if (pWindow->m_sSpecialRenderData.alphaInactive == -1)
@@ -226,43 +267,39 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
g_pHyprOpenGL->m_pCurrentWindow = pWindow; g_pHyprOpenGL->m_pCurrentWindow = pWindow;
// render window decorations first, if not fullscreen full // clip box for animated offsets
Vector2D offset;
if (!ignorePosition && pWindow->m_bIsFloating) {
if (PWORKSPACE->m_vRenderOffset.vec().x != 0) {
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().x / PWSMON->vecSize.x;
const auto WINBB = pWindow->getFullWindowBoundingBox();
if (WINBB.x < PWSMON->vecPosition.x) {
offset.x = (PWSMON->vecPosition.x - WINBB.x) * PROGRESS;
} else if (WINBB.x + WINBB.width > PWSMON->vecPosition.x + PWSMON->vecSize.x) {
offset.x = (WINBB.x + WINBB.width - PWSMON->vecPosition.x - PWSMON->vecSize.x) * PROGRESS;
}
} else if (PWORKSPACE->m_vRenderOffset.vec().y) {
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().y / PWSMON->vecSize.y;
const auto WINBB = pWindow->getFullWindowBoundingBox();
if (WINBB.y < PWSMON->vecPosition.y) {
offset.y = (PWSMON->vecPosition.y - WINBB.y) * PROGRESS;
} else if (WINBB.y + WINBB.height > PWSMON->vecPosition.y + PWSMON->vecSize.y) {
offset.y = (WINBB.y + WINBB.width - PWSMON->vecPosition.y - PWSMON->vecSize.y) * PROGRESS;
}
}
renderdata.x += offset.x;
renderdata.y += offset.y;
}
// render window decorations first, if not fullscreen full
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) { if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) {
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) for (auto& wd : pWindow->m_dWindowDecorations) if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) for (auto& wd : pWindow->m_dWindowDecorations)
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f); wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f, offset);
if (!pWindow->m_bIsX11) {
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
// first, check for poorly sized windows.
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D((double)geom.x / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)geom.y / (double)pWindow->m_uSurface.xdg->surface->current.height);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D((double)(geom.width + geom.x) / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)(geom.y + geom.height) / (double)pWindow->m_uSurface.xdg->surface->current.height);
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
// No special UV mods needed
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
}
// then, if the surface is too big, modify the pos UV
if (geom.width > renderdata.w + 1 || geom.height > renderdata.h + 1) {
const auto OFF = Vector2D(renderdata.w / (double)geom.width, renderdata.h / (double)geom.height);
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1))
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * ((double)renderdata.w / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)),
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * ((double)renderdata.h / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y))
);
}
} else {
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
}
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata); wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
@@ -272,22 +309,31 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding; float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding;
rounding *= pMonitor->scale; rounding *= pMonitor->scale;
auto col = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor.col(); auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor;
col.a *= renderdata.fadeAlpha * renderdata.alpha / 255.f; const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.isBeingAnimated();
float a1 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f);
wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
scaleBox(&windowBox, pMonitor->scale); scaleBox(&windowBox, pMonitor->scale);
g_pHyprOpenGL->renderBorder(&windowBox, col, rounding); g_pHyprOpenGL->renderBorder(&windowBox, grad, rounding, a1);
}
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); if (ANIMATED) {
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); float a2 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl());
g_pHyprOpenGL->renderBorder(&windowBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, rounding, a2);
}
}
} }
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_POPUP) { if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_POPUP) {
if (!pWindow->m_bIsX11) { if (!pWindow->m_bIsX11) {
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
renderdata.x -= geom.x;
renderdata.y -= geom.y;
renderdata.dontRound = true; // don't round popups renderdata.dontRound = true; // don't round popups
renderdata.pMonitor = pMonitor; renderdata.pMonitor = pMonitor;
renderdata.squishOversized = false; // don't squish popups renderdata.squishOversized = false; // don't squish popups
@@ -296,6 +342,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
} }
g_pHyprOpenGL->m_pCurrentWindow = nullptr; g_pHyprOpenGL->m_pCurrentWindow = nullptr;
g_pHyprOpenGL->m_RenderData.clipBox = { 0, 0, 0, 0 };
} }
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
@@ -311,6 +358,7 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
renderdata.decorate = false; renderdata.decorate = false;
renderdata.w = pLayer->layerSurface->surface->current.width; renderdata.w = pLayer->layerSurface->surface->current.width;
renderdata.h = pLayer->layerSurface->surface->current.height; renderdata.h = pLayer->layerSurface->surface->current.height;
renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata); wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
renderdata.squishOversized = false; // don't squish popups renderdata.squishOversized = false; // don't squish popups
@@ -356,33 +404,44 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
return; return;
} }
CWindow* lastWindow = nullptr;
// Non-floating main // Non-floating main
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut) if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w->m_bIsFloating) if (w->m_bIsFloating)
continue; // floating are in the second pass continue; // floating are in the second pass
if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
continue; continue;
// render active window after all others of this pass
if (w.get() == g_pCompositor->m_pLastWindow) {
lastWindow = w.get();
continue;
}
// render the bad boy // render the bad boy
renderWindow(w.get(), PMONITOR, time, true, RENDER_PASS_MAIN); renderWindow(w.get(), PMONITOR, time, true, RENDER_PASS_MAIN);
} }
if (lastWindow)
renderWindow(lastWindow, PMONITOR, time, true, RENDER_PASS_MAIN);
// Non-floating popup // Non-floating popup
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut) if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w->m_bIsFloating) if (w->m_bIsFloating)
continue; // floating are in the second pass continue; // floating are in the second pass
if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
@@ -394,13 +453,13 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
// floating on top // floating on top
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut) if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (!w->m_bIsFloating) if (!w->m_bIsFloating)
continue; continue;
if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
@@ -412,10 +471,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
// and then special // and then special
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut) if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w->m_iWorkspaceID != SPECIAL_WORKSPACE_ID) if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
@@ -442,6 +501,220 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
renderDragIcon(PMONITOR, time); renderDragIcon(PMONITOR, time);
} }
void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* pSurface, bool main) {
if (!pWindow->m_bIsX11) {
Vector2D uvTL;
Vector2D uvBR = Vector2D(1, 1);
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
const auto SUBSURFACE = g_pXWaylandManager->getWindowSurface(pWindow) != pSurface && main;
// wp_viewporter_v1 implementation
if (pSurface->current.viewport.has_src) {
wlr_fbox bufferSource;
wlr_surface_get_buffer_source_box(pSurface, &bufferSource);
Vector2D surfaceSize = Vector2D(pSurface->buffer->texture->width, pSurface->buffer->texture->height);
uvTL = Vector2D(bufferSource.x / surfaceSize.x, bufferSource.y / surfaceSize.y);
uvBR = Vector2D((bufferSource.x + bufferSource.width) / surfaceSize.x, (bufferSource.y + bufferSource.height) / surfaceSize.y);
if (uvBR.x < 0.01f || uvBR.y < 0.01f) {
uvTL = Vector2D();
uvBR = Vector2D(1,1);
}
// TODO: (example: chromium) this still has a tiny "bump" at the end.
if (main) {
uvTL = uvTL + (Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)) * (((uvBR.x - uvTL.x) * surfaceSize.x) / surfaceSize.x));
uvBR = uvBR * Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
}
} else if (main) {
// oversized windows' UV adjusting
uvTL = Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height));
uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
}
// set UV
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
// No special UV mods needed
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
}
if (!main)
return; // ignore the rest
// then, if the surface is too big, modify the pos UV
if ((geom.width > pWindow->m_vRealSize.vec().x + 1 || geom.height > pWindow->m_vRealSize.vec().y + 1) && !SUBSURFACE) {
const auto OFF = Vector2D(pWindow->m_vRealSize.vec().x / (double)geom.width, pWindow->m_vRealSize.vec().y / (double)geom.height);
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1))
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * (pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)),
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * (pWindow->m_vRealSize.vec().y / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y)));
}
} else {
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
}
}
void countSubsurfacesIter(wlr_surface* pSurface, int x, int y, void* data) {
*(int*)data += 1;
}
bool CHyprRenderer::attemptDirectScanout(CMonitor* pMonitor) {
if (!pMonitor->mirrors.empty())
return false; // do not DS if this monitor is being mirrored. Will break the functionality.
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pMonitor->activeWorkspace);
if (!PWORKSPACE || !PWORKSPACE->m_bHasFullscreenWindow || g_pInputManager->m_sDrag.drag || g_pCompositor->m_sSeat.exclusiveClient || pMonitor->specialWorkspaceID)
return false;
const auto PCANDIDATE = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
if (!PCANDIDATE)
return false; // ????
if (PCANDIDATE->m_fAlpha.fl() != 255.f || PCANDIDATE->m_fActiveInactiveAlpha.fl() != 1.f || PWORKSPACE->m_fAlpha.fl() != 255.f)
return false;
if (PCANDIDATE->m_vRealSize.vec() != pMonitor->vecSize || PCANDIDATE->m_vRealPosition.vec() != pMonitor->vecPosition || PCANDIDATE->m_vRealPosition.isBeingAnimated() || PCANDIDATE->m_vRealSize.isBeingAnimated())
return false;
if (!pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY].empty())
return false;
for (auto& topls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
if (topls->alpha.fl() != 0.f)
return false;
}
// check if it did not open any subsurfaces or shit
int surfaceCount = 0;
if (PCANDIDATE->m_bIsX11) {
surfaceCount = 1;
// check opaque
if (PCANDIDATE->m_uSurface.xwayland->has_alpha)
return false;
} else {
wlr_xdg_surface_for_each_surface(PCANDIDATE->m_uSurface.xdg, countSubsurfacesIter, &surfaceCount);
wlr_xdg_surface_for_each_popup_surface(PCANDIDATE->m_uSurface.xdg, countSubsurfacesIter, &surfaceCount);
if (!PCANDIDATE->m_uSurface.xdg->surface->opaque)
return false;
}
if (surfaceCount != 1)
return false;
const auto PSURFACE = g_pXWaylandManager->getWindowSurface(PCANDIDATE);
if (!PSURFACE || PSURFACE->current.scale != pMonitor->output->scale || PSURFACE->current.transform != pMonitor->output->transform)
return false;
// finally, we should be GTG.
wlr_output_attach_buffer(pMonitor->output, &PSURFACE->buffer->base);
if (!wlr_output_test(pMonitor->output)) {
return false;
}
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_surface_send_frame_done(PSURFACE, &now);
wlr_presentation_surface_sampled_on_output(g_pCompositor->m_sWLRPresentation, PSURFACE, pMonitor->output);
if (wlr_output_commit(pMonitor->output)) {
if (!m_pLastScanout) {
m_pLastScanout = PCANDIDATE;
Debug::log(LOG, "Entered a direct scanout to %x: \"%s\"", PCANDIDATE, PCANDIDATE->m_szTitle.c_str());
}
} else {
m_pLastScanout = nullptr;
return false;
}
return true;
}
void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
if (!g_pCompositor->m_sWLRLinuxDMABuf)
return;
if (!pWindow->m_bIsFullscreen) {
wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), nullptr);
Debug::log(LOG, "Scanout mode OFF set for %x", pWindow);
return;
}
const auto RENDERERDRMFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer);
const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend);
if (RENDERERDRMFD < 0 || BACKENDDRMFD < 0)
return;
auto deviceIDFromFD = [](int fd, unsigned long* deviceID) -> bool {
struct stat stat;
if (fstat(fd, &stat) != 0) {
return false;
}
*deviceID = stat.st_rdev;
return true;
};
unsigned long rendererDevice, scanoutDevice;
if (!deviceIDFromFD(RENDERERDRMFD, &rendererDevice) || !deviceIDFromFD(BACKENDDRMFD, &scanoutDevice))
return;
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto POUTPUTFORMATS = wlr_output_get_primary_formats(PMONITOR->output, WLR_BUFFER_CAP_DMABUF);
if (!POUTPUTFORMATS)
return;
const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
wlr_drm_format_set scanoutFormats = { 0 };
if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS))
return;
const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = {
{
.target_device = scanoutDevice,
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
.formats = &scanoutFormats
}, {
.target_device = rendererDevice,
.formats = PRENDERERFORMATS
}
};
const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {
.main_device = rendererDevice,
.tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]),
.tranches = TRANCHES
};
if (!wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &FEEDBACK)) {
Debug::log(ERR, "Error in scanout mode setting: wlr_linux_dmabuf_v1_set_surface_feedback returned false.");
}
wlr_drm_format_set_finish(&scanoutFormats);
Debug::log(LOG, "Scanout mode ON set for %x", pWindow);
}
void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) { void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) {
wlr_output_configuration_head_v1* head; wlr_output_configuration_head_v1* head;
bool noError = true; bool noError = true;
@@ -469,9 +742,17 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
commandForCfg += std::to_string(head->state.x) + "x" + std::to_string(head->state.y) + "," + std::to_string(head->state.scale); commandForCfg += std::to_string(head->state.x) + "x" + std::to_string(head->state.y) + "," + std::to_string(head->state.scale);
if (!test) if (!test) {
g_pConfigManager->parseKeyword("monitor", commandForCfg, true); g_pConfigManager->parseKeyword("monitor", commandForCfg, true);
std::string transformStr = std::string(OUTPUT->name) + ",transform," + std::to_string((int)OUTPUT->transform);
const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name);
if (!PMONITOR || OUTPUT->transform != PMONITOR->transform)
g_pConfigManager->parseKeyword("monitor", transformStr);
}
noError = wlr_output_test(OUTPUT); noError = wlr_output_test(OUTPUT);
if (!noError) if (!noError)
@@ -669,14 +950,22 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition; PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition;
PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft; PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft;
const auto ENTRY = g_pConfigManager->m_mAdditionalReservedAreas[PMONITOR->szName]; auto ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(PMONITOR->szName);
PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ENTRY.left, ENTRY.top); if (ADDITIONALRESERVED == g_pConfigManager->m_mAdditionalReservedAreas.end()) {
PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ENTRY.right, ENTRY.bottom); ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(""); // glob wildcard
}
if (ADDITIONALRESERVED != g_pConfigManager->m_mAdditionalReservedAreas.end()) {
PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ADDITIONALRESERVED->second.left, ADDITIONALRESERVED->second.top);
PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ADDITIONALRESERVED->second.right, ADDITIONALRESERVED->second.bottom);
}
// damage the monitor if can // damage the monitor if can
if (PMONITOR->damage) if (PMONITOR->damage)
damageMonitor(PMONITOR); damageMonitor(PMONITOR);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor);
Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y); Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y);
} }
@@ -737,17 +1026,17 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
m->addDamage(&fixedDamageBox); m->addDamage(&fixedDamageBox);
} }
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
if (*PLOGDAMAGE) if (*PLOGDAMAGE)
Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height); Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height);
} }
void CHyprRenderer::damageMonitor(CMonitor* pMonitor) { void CHyprRenderer::damageMonitor(CMonitor* pMonitor) {
if (g_pCompositor->m_bUnsafeState) if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror())
return; return;
wlr_box damageBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y}; wlr_box damageBox = { 0, 0, INT16_MAX, INT16_MAX };
pMonitor->addDamage(&damageBox); pMonitor->addDamage(&damageBox);
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
@@ -761,6 +1050,9 @@ void CHyprRenderer::damageBox(wlr_box* pBox) {
return; return;
for (auto& m : g_pCompositor->m_vMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m->isMirror())
continue; // don't damage mirrors traditionally
wlr_box damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height}; wlr_box damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height};
scaleBox(&damageBox, m->scale); scaleBox(&damageBox, m->scale);
m->addDamage(&damageBox); m->addDamage(&damageBox);
@@ -784,6 +1076,19 @@ void CHyprRenderer::damageRegion(pixman_region32_t* rg) {
} }
} }
void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, pixman_region32_t* pRegion) {
for (auto& mirror : pMonitor->mirrors) {
Vector2D scale = {mirror->vecSize.x / pMonitor->vecSize.x, mirror->vecSize.y / pMonitor->vecSize.y};
pixman_region32_t rg;
pixman_region32_init(&rg);
pixman_region32_copy(&rg, pRegion);
wlr_region_scale_xy(&rg, &rg, scale.x, scale.y);
pMonitor->addDamage(&rg);
pixman_region32_fini(&rg);
}
}
void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) {
if (!(g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.iconMapped && g_pInputManager->m_sDrag.dragIcon->surface)) if (!(g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.iconMapped && g_pInputManager->m_sDrag.dragIcon->surface))
return; return;
@@ -835,7 +1140,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
&& DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1)
&& pMonitor->scale == pMonitorRule->scale && pMonitor->scale == pMonitorRule->scale
&& ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1)) && ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1))
&& pMonitor->transform == pMonitorRule->transform) { && pMonitor->transform == pMonitorRule->transform
&& pMonitorRule->enable10bit == pMonitor->enabled10bit) {
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str()); Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
return true; return true;
@@ -844,10 +1150,11 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
wlr_output_set_scale(pMonitor->output, pMonitorRule->scale); wlr_output_set_scale(pMonitor->output, pMonitorRule->scale);
pMonitor->scale = pMonitorRule->scale; pMonitor->scale = pMonitorRule->scale;
pMonitor->vecPosition = pMonitorRule->offset; wlr_output_set_transform(pMonitor->output, pMonitorRule->transform);
pMonitor->transform = pMonitorRule->transform;
// loop over modes and choose an appropriate one. // loop over modes and choose an appropriate one.
if (pMonitorRule->resolution != Vector2D()) { if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1,-1) && pMonitorRule->resolution != Vector2D(-1,-2)) {
if (!wl_list_empty(&pMonitor->output->modes)) { if (!wl_list_empty(&pMonitor->output->modes)) {
wlr_output_mode* mode; wlr_output_mode* mode;
bool found = false; bool found = false;
@@ -880,6 +1187,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
if (!found) { if (!found) {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000); wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
pMonitor->vecSize = pMonitorRule->resolution; pMonitor->vecSize = pMonitorRule->resolution;
pMonitor->refreshRate = pMonitorRule->refreshRate;
if (!wlr_output_test(pMonitor->output)) { if (!wlr_output_test(pMonitor->output)) {
Debug::log(ERR, "Custom resolution FAILED, falling back to preferred"); Debug::log(ERR, "Custom resolution FAILED, falling back to preferred");
@@ -908,8 +1216,95 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} else { } else {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000); wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
pMonitor->vecSize = pMonitorRule->resolution; pMonitor->vecSize = pMonitorRule->resolution;
pMonitor->refreshRate = pMonitorRule->refreshRate;
Debug::log(LOG, "Setting custom mode for %s", pMonitor->output->name); if (!wlr_output_test(pMonitor->output)) {
Debug::log(ERR, "Custom resolution FAILED, falling back to preferred");
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
if (!PREFERREDMODE) {
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
return true;
}
// Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
} else {
Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
}
}
} else if (pMonitorRule->resolution != Vector2D()) {
if (!wl_list_empty(&pMonitor->output->modes)) {
wlr_output_mode* mode;
float currentWidth = 0;
float currentHeight = 0;
float currentRefresh = 0;
bool success = false;
//(-1,-1) indicates a preference to refreshrate over resolution, (-1,-2) preference to resolution
if(pMonitorRule->resolution == Vector2D(-1,-1)) {
wl_list_for_each(mode, &pMonitor->output->modes, link) {
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || mode->refresh > ( currentRefresh + 3000.f ) ) {
wlr_output_set_mode(pMonitor->output, mode);
if (wlr_output_test(pMonitor->output)) {
currentWidth = mode->width;
currentHeight = mode->height;
currentRefresh = mode->refresh;
success = true;
}
}
}
} else {
wl_list_for_each(mode, &pMonitor->output->modes, link) {
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || ( mode->width > currentWidth && mode->height > currentHeight ) ) {
wlr_output_set_mode(pMonitor->output, mode);
if (wlr_output_test(pMonitor->output)) {
currentWidth = mode->width;
currentHeight = mode->height;
currentRefresh = mode->refresh;
success = true;
}
}
}
}
if (!success) {
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh / 1000.f);
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
if (!PREFERREDMODE) {
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f",
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
return true;
}
// Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
} else {
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.",
pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
mode->width, mode->height, mode->refresh / 1000.f);
pMonitor->refreshRate = currentRefresh / 1000.f;
pMonitor->vecSize = Vector2D(currentWidth, currentHeight);
}
} }
} else { } else {
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output); const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
@@ -952,18 +1347,37 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
} }
pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR()
wlr_output_set_transform(pMonitor->output, pMonitorRule->transform);
pMonitor->transform = pMonitorRule->transform;
pMonitor->vecPixelSize = pMonitor->vecSize; pMonitor->vecPixelSize = pMonitor->vecSize;
// update renderer if (pMonitorRule->enable10bit) {
g_pHyprOpenGL->destroyMonitorResources(pMonitor); // try 10b RGB
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB2101010);
pMonitor->enabled10bit = true;
if (!wlr_output_test(pMonitor->output)) {
Debug::log(ERR, "Output %s -> 10 bit enabled, but failed format DRM_FORMAT_XRGB2101010. Trying BGR.", pMonitor->output->name);
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XBGR2101010);
if (!wlr_output_test(pMonitor->output)) {
Debug::log(ERR, "Output %s -> 10 bit enabled, but failed format DRM_FORMAT_XBGR2101010. Falling back to 8 bit.", pMonitor->output->name);
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888);
} else {
Debug::log(LOG, "10bit format DRM_FORMAT_XBGR2101010 succeeded for output %s", pMonitor->output->name);
}
} else {
Debug::log(LOG, "10bit format DRM_FORMAT_XRGB2101010 succeeded for output %s", pMonitor->output->name);
}
} else {
wlr_output_set_render_format(pMonitor->output, DRM_FORMAT_XRGB8888);
pMonitor->enabled10bit = false;
}
if (!wlr_output_commit(pMonitor->output)) { if (!wlr_output_commit(pMonitor->output)) {
Debug::log(ERR, "Couldn't commit output named %s", pMonitor->output->name); Debug::log(ERR, "Couldn't commit output named %s", pMonitor->output->name);
return true;
} }
int x, y; int x, y;
@@ -971,7 +1385,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor(); pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
pMonitor->vecTransformedSize = Vector2D(x,y); pMonitor->vecTransformedSize = Vector2D(x,y);
if (pMonitorRule->offset == Vector2D(-1, -1)) { if (pMonitor->createdByUser) {
wlr_box transformedBox = { 0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y };
wlr_box_transform(&transformedBox, &transformedBox, wlr_output_transform_invert(pMonitor->output->transform), (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y);
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
}
if (pMonitorRule->offset == Vector2D(-1, -1) && pMonitor->vecPosition == Vector2D(-1, -1)) {
// let's find manually a sensible position for it, to the right. // let's find manually a sensible position for it, to the right.
Vector2D finalPos; Vector2D finalPos;
@@ -985,14 +1406,15 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
} }
pMonitor->vecPosition = finalPos; pMonitor->vecPosition = finalPos;
} else if (pMonitorRule->offset != Vector2D(-1, -1)) {
pMonitor->vecPosition = pMonitorRule->offset;
} }
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y); // update renderer (here because it will call rollback, so we cannot do this before committing)
g_pHyprOpenGL->destroyMonitorResources(pMonitor);
wlr_output_enable(pMonitor->output, true);
// updato wlroots // updato wlroots
Events::listener_change(nullptr, nullptr); wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y);
// updato us // updato us
arrangeLayersForMonitor(pMonitor->ID); arrangeLayersForMonitor(pMonitor->ID);
@@ -1000,6 +1422,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
// frame skip // frame skip
pMonitor->framesToSkip = 1; pMonitor->framesToSkip = 1;
// reload to fix mirrors
g_pConfigManager->m_bWantsMonitorReload = true;
return true; return true;
} }

View File

@@ -23,6 +23,8 @@ enum eRenderPassMode {
RENDER_PASS_POPUP RENDER_PASS_POPUP
}; };
class CToplevelExportProtocolManager;
class CHyprRenderer { class CHyprRenderer {
public: public:
@@ -35,20 +37,27 @@ public:
void damageBox(const int& x, const int& y, const int& w, const int& h); void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageRegion(pixman_region32_t*); void damageRegion(pixman_region32_t*);
void damageMonitor(CMonitor*); void damageMonitor(CMonitor*);
void damageMirrorsWith(CMonitor*, pixman_region32_t*);
bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false); bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false);
bool shouldRenderWindow(CWindow*, CMonitor*); bool shouldRenderWindow(CWindow*, CMonitor*);
bool shouldRenderWindow(CWindow*); bool shouldRenderWindow(CWindow*);
void ensureCursorRenderingMode(); void ensureCursorRenderingMode();
bool shouldRenderCursor(); bool shouldRenderCursor();
void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false);
bool m_bWindowRequestedCursorHide = false; bool m_bWindowRequestedCursorHide = false;
bool m_bBlockSurfaceFeedback = false;
CWindow* m_pLastScanout = nullptr;
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&); DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
bool attemptDirectScanout(CMonitor*);
void setWindowScanoutMode(CWindow*);
private: private:
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*); void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*); void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode); void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(SLayerSurface*, CMonitor*, timespec*); void renderLayer(SLayerSurface*, CMonitor*, timespec*);
void renderDragIcon(CMonitor*, timespec*); void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*); void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
@@ -57,6 +66,7 @@ private:
friend class CHyprOpenGLImpl; friend class CHyprOpenGLImpl;
friend class CToplevelExportProtocolManager;
}; };
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer; inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;

View File

@@ -14,7 +14,11 @@ GLint CShader::getUniformLocation(const std::string& unif) {
CShader::~CShader() { CShader::~CShader() {
// destroy shader // destroy shader
if (program != 0) { destroy();
glDeleteProgram(program); }
}
void CShader::destroy() {
glDeleteProgram(program);
program = 0;
} }

View File

@@ -19,6 +19,7 @@ public:
GLint topLeft; GLint topLeft;
GLint bottomRight; GLint bottomRight;
GLint fullSize; GLint fullSize;
GLint fullSizeUntransformed;
GLint radius; GLint radius;
GLint primitiveMultisample; GLint primitiveMultisample;
@@ -29,8 +30,17 @@ public:
GLint range; GLint range;
GLint shadowPower; GLint shadowPower;
GLint applyTint;
GLint tint;
GLint gradient;
GLint gradientLength;
GLint angle;
GLint getUniformLocation(const std::string&); GLint getUniformLocation(const std::string&);
void destroy();
private: private:
std::unordered_map<std::string, GLint> m_muUniforms; std::unordered_map<std::string, GLint> m_muUniforms;
}; };

View File

@@ -38,7 +38,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
const auto WORKSPACEOFFSET = PWORKSPACE ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D(); const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) { if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
@@ -48,7 +48,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
} }
} }
void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) { void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
if (!g_pCompositor->windowValidMapped(m_pWindow)) if (!g_pCompositor->windowValidMapped(m_pWindow))
return; return;
@@ -56,45 +56,66 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
if (m_pWindow->m_cRealShadowColor.col() == CColor(0, 0, 0, 0)) if (m_pWindow->m_cRealShadowColor.col() == CColor(0, 0, 0, 0))
return; // don't draw invisible shadows return; // don't draw invisible shadows
if (!m_pWindow->m_sSpecialRenderData.decorate)
return;
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
return;
static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue;
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
static auto *const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->strValue; static auto *const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue;
static auto *const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue;
if (*PSHADOWS != 1) if (*PSHADOWS != 1)
return; // disabled return; // disabled
// get the real offset
Vector2D offset;
try {
if (const auto SPACEPOS = PSHADOWOFFSET->find(' '); SPACEPOS != std::string::npos) {
const auto X = PSHADOWOFFSET->substr(0, SPACEPOS);
const auto Y = PSHADOWOFFSET->substr(SPACEPOS + 1);
if (isNumber(X, true) && isNumber(Y, true)) {
offset = Vector2D(std::stof(X), std::stof(Y));
}
}
} catch (std::exception& e) {
return; // cannot parse
}
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding); const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding);
// update the extents
m_seExtents = {{*PSHADOWSIZE + 2 - offset.x, *PSHADOWSIZE + 2 - offset.y}, {*PSHADOWSIZE + 2 + offset.x, *PSHADOWSIZE + 2 + offset.y}};
// draw the shadow // draw the shadow
wlr_box fullBox = {m_vLastWindowPos.x - m_seExtents.topLeft.x + 2, m_vLastWindowPos.y - m_seExtents.topLeft.y + 2, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x - 4, m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y - 4}; wlr_box fullBox = { m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE,
m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE };
fullBox.x -= pMonitor->vecPosition.x; fullBox.x -= pMonitor->vecPosition.x;
fullBox.y -= pMonitor->vecPosition.y; fullBox.y -= pMonitor->vecPosition.y;
const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
// scale the box in relation to the center of the box
const Vector2D NEWSIZE = Vector2D { fullBox.width, fullBox.height } * SHADOWSCALE;
fullBox.width = NEWSIZE.x;
fullBox.height = NEWSIZE.y;
if (PSHADOWOFFSET->x < 0) {
fullBox.x += PSHADOWOFFSET->x;
} else if (PSHADOWOFFSET->x > 0) {
fullBox.x = m_vLastWindowPos.x + m_vLastWindowSize.x - fullBox.width + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x;
} else {
fullBox.x += ((m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0;
}
if (PSHADOWOFFSET->y < 0) {
fullBox.y += PSHADOWOFFSET->y;
} else if (PSHADOWOFFSET->y > 0) {
fullBox.y = m_vLastWindowPos.y + m_vLastWindowSize.y - fullBox.height + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y;
} else {
fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0;
}
m_seExtents = { { m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2,
m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
{ fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2} };
fullBox.x += offset.x;
fullBox.y += offset.y;
if (fullBox.width < 1 || fullBox.height < 1) if (fullBox.width < 1 || fullBox.height < 1)
return; // don't draw invisible shadows return; // don't draw invisible shadows
g_pHyprOpenGL->scissor((wlr_box *)nullptr); g_pHyprOpenGL->scissor((wlr_box*)nullptr);
if (*PSHADOWIGNOREWINDOW) { if (*PSHADOWIGNOREWINDOW) {
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);

View File

@@ -9,7 +9,7 @@ public:
virtual SWindowDecorationExtents getWindowDecorationExtents(); virtual SWindowDecorationExtents getWindowDecorationExtents();
virtual void draw(CMonitor*, float a); virtual void draw(CMonitor*, float a, const Vector2D& offset);
virtual eDecorationType getDecorationType(); virtual eDecorationType getDecorationType();

View File

@@ -3,7 +3,6 @@
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) { CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) {
m_pWindow = pWindow; m_pWindow = pWindow;
updateWindow(pWindow);
} }
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() { CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {
@@ -23,13 +22,13 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
const auto WORKSPACEOFFSET = PWORKSPACE ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D(); const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) { if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
// we draw 3px above the window's border with 3px // we draw 3px above the window's border with 3px
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
m_seExtents.topLeft = Vector2D(0, BORDERSIZE + 3 + 3); m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3);
m_seExtents.bottomRight = Vector2D(); m_seExtents.bottomRight = Vector2D();
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
@@ -46,7 +45,7 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
// get the group info // get the group info
SLayoutMessageHeader header; SLayoutMessageHeader header;
header.pWindow = g_pCompositor->m_pLastWindow; header.pWindow = m_pWindow;
m_dwGroupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo")); m_dwGroupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
@@ -64,11 +63,14 @@ void CHyprGroupBarDecoration::damageEntire() {
g_pHyprRenderer->damageBox(&dm); g_pHyprRenderer->damageBox(&dm);
} }
void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) { void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
// get how many bars we will draw // get how many bars we will draw
int barsToDraw = m_dwGroupMembers.size(); int barsToDraw = m_dwGroupMembers.size();
if (barsToDraw < 1 || m_pWindow->m_bHidden || !g_pCompositor->windowValidMapped(m_pWindow)) if (barsToDraw < 1 || m_pWindow->isHidden() || !g_pCompositor->windowValidMapped(m_pWindow))
return;
if (!m_pWindow->m_sSpecialRenderData.decorate)
return; return;
const int PAD = 2; //2px const int PAD = 2; //2px
@@ -78,12 +80,17 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
int xoff = 0; int xoff = 0;
for (int i = 0; i < barsToDraw; ++i) { for (int i = 0; i < barsToDraw; ++i) {
wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y, BARW, 3}; wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x + offset.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y + offset.y, BARW, 3};
if (rect.width <= 0 || rect.height <= 0) if (rect.width <= 0 || rect.height <= 0)
break; break;
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")) : CColor(g_pConfigManager->getInt("dwindle:col.group_border")); scaleBox(&rect, pMonitor->scale);
static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE);
color.a *= a; color.a *= a;
g_pHyprOpenGL->renderRect(&rect, color); g_pHyprOpenGL->renderRect(&rect, color);

Some files were not shown because too many files have changed in this diff Show More