Compare commits

...

632 Commits

Author SHA1 Message Date
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
vaxerski
fba7ed97fb don't refocus if candidate is last window 2022-08-23 23:15:04 +02:00
vaxerski
fd70a9184b fix logic in fullscreen close candidates 2022-08-23 23:09:28 +02:00
vaxerski
0a9ac47030 remove unintuitive candidate behavior 2022-08-23 18:25:33 +02:00
vaxerski
e2450247c0 minor fixes to candidate finding 2022-08-23 18:18:18 +02:00
vaxerski
973540bbc5 minor fix on unfocus on fullscreen workspace 2022-08-23 18:01:22 +02:00
vaxerski
f9b2aa5468 don't round popups 2022-08-23 16:54:32 +02:00
vaxerski
451659ec34 fix oversized popup misalignment 2022-08-23 16:52:36 +02:00
vaxerski
a9e34cba93 move monitor damage to separate funcs 2022-08-23 16:07:47 +02:00
vaxerski
48c9e9d83d damage on force warp resize 2022-08-23 15:08:15 +02:00
vaxerski
23c5760538 IME Popup damage fixes 2022-08-23 11:16:35 +02:00
vaxerski
9bfa3ebc50 fix up keyword to accept spaced args 2022-08-22 23:25:11 +02:00
Mihai Fufezan
8feb6f7da1 Nix: add shortRev to version 2022-08-23 00:17:00 +03:00
vaxerski
fb0e81c18e fix up hyprctl dispatch 2022-08-22 19:16:35 +02:00
vaxerski
359df96d53 fix wlr logging 2022-08-22 18:58:29 +02:00
vaxerski
63493b5736 use a custom logging func for wlr 2022-08-22 18:50:38 +02:00
vaxerski
6565c31dbf fix IME grab on multiple open native inputs 2022-08-22 18:40:38 +02:00
vaxerski
575bfa40e5 added misc:float_switch_override_focus 2022-08-22 18:22:26 +02:00
vaxerski
429b2bffed fix minor refocus issue 2022-08-22 18:16:32 +02:00
vaxerski
c83948ea9a added HYPRLAND_LOG_WLR envvar 2022-08-22 15:50:08 +02:00
vaxerski
8a6e29974b [gha] build man pages 2022-08-22 13:16:57 +00:00
Vaxry
4c6d9b7d5a Merge pull request #555 from viperML/update-man
docs: build man pages to repo
2022-08-22 15:16:32 +02:00
Vaxry
9f5e099cd1 Merge pull request #562 from sp1ritCS/s/ospatches
openSUSE patches
2022-08-22 14:47:17 +02:00
vaxerski
8b39a1cf9b always use /usr/share/ for wayland-sessions 2022-08-22 14:46:53 +02:00
Florian sp1rit​
e9551731f0 improve compatability with older meson versions
- changed <compiler>.get_version() to <compiler>.version()

Signed-off-by: Florian "sp1rit"​ <sp1ritCS@protonmail.com>
2022-08-22 14:35:49 +02:00
Florian sp1rit​
39a9980fb1 dropped deprecated gethostbyname check
Done to avoid the rpmlint warning:
hyprland.x86_64: W: binary-or-shlib-calls-gethostbyname /usr/bin/hyprctl
The binary calls gethostbyname. Please port the code to use getaddrinfo.

Signed-off-by: Florian "sp1rit"​ <sp1ritCS@protonmail.com>
2022-08-22 14:35:41 +02:00
vaxerski
d0ec2b72ae report sizes to all windows on fullscreen 2022-08-22 14:22:21 +02:00
vaxerski
e97fa4e26b destroy monitor resources on exit 2022-08-22 14:17:25 +02:00
vaxerski
52318692f0 clean up temp logic in snapshots 2022-08-22 13:38:40 +02:00
vaxerski
86be6c3884 fix LS snapshot rendering logic 2022-08-22 13:36:00 +02:00
vaxerski
21bea0fcb4 typo 2022-08-22 11:37:00 +02:00
vaxerski
83f7fee3f5 fullscreen request only when mapped 2022-08-22 11:35:46 +02:00
vaxerski
f273ebed9c fix another edge case for fullscreen default windows 2022-08-21 23:24:57 +02:00
vaxerski
3cb30e7fb0 fix crash 2022-08-21 23:16:54 +02:00
vaxerski
3e9a8a7bc8 set new optimizations for blur in example configs 2022-08-21 22:59:19 +02:00
vaxerski
7ca50d7566 handle fullscreen pre-map
stupid-ass qt
2022-08-21 22:30:48 +02:00
vaxerski
ebe07c6656 fix incorrect popup handling on oversized 2022-08-21 21:23:05 +02:00
vaxerski
ce62a98470 fix warn 2022-08-21 18:35:45 +02:00
vaxerski
8faac0c9ac minor activewindow and focus fixes 2022-08-21 18:34:38 +02:00
Fernando Ayats
fea6d7deb0 docs: install manpages with meson 2022-08-21 18:00:04 +02:00
Fernando Ayats
463bc7ab13 doc: install mapages 2022-08-21 17:28:56 +02:00
Vaxry
c4ba11729f Merge pull request #557 from xDarksome/main
Add window{open/close/move} IPC events (#549)
2022-08-21 17:10:24 +02:00
vaxerski
5569e1f69c remove unused func 2022-08-21 17:09:35 +02:00
vaxerski
da725d7aa5 warn about outdated keybind cfg 2022-08-21 17:01:32 +02:00
Darksome
f7f3446882 CCompositor::moveWindowToWorkspace -> CWindow::moveToWorkspace 2022-08-21 18:01:26 +03:00
vaxerski
0f63077a07 use a custom translation state in keybinds 2022-08-21 16:43:22 +02:00
xDarksome
0f25f3aee3 Merge branch 'hyprwm:main' into main 2022-08-21 16:03:51 +03:00
Vaxry
5e1f2539cb Merge pull request #352 from CharlesEkkel/previous-workspace
Add switching to previous workspace
2022-08-21 14:16:52 +02:00
Charles Taylor
9dbdd66da4 fix retrieval of monitor 2022-08-21 22:11:40 +10:00
Charles Taylor
6ec932d11f fix bug which allowed a switch to workspace ID -1.
This only happened for the workspace_back_and_forth setting, since it
was missing a check.
2022-08-21 22:05:35 +10:00
Charles Taylor
3c8c605541 fix style conflicts and config + monitor retrieval 2022-08-21 21:58:46 +10:00
Charles Taylor
9ee42836d5 add general:allow_workspace_cycles option 2022-08-21 20:47:56 +10:00
Charles Taylor
d6ff7e40cf add general:workspace_back_and_forth option 2022-08-21 20:40:06 +10:00
Charles Taylor
04f0efadc3 add switching to previous workspace 2022-08-21 20:21:21 +10:00
viperML
12cdca7422 [gha] build man pages 2022-08-21 08:40:27 +00:00
Fernando Ayats
7ce2c91673 doc: build man pages to repo 2022-08-21 10:39:47 +02:00
Fernando Ayats
aaba11b7a2 gha: build man pages 2022-08-21 10:33:45 +02:00
vaxerski
9513031da3 fix a minor border issue 2022-08-20 22:45:30 +02:00
vaxerski
08e874bcf9 fix special workspace windows being xray with new optim 2022-08-20 20:16:04 +02:00
vaxerski
61aa4ff70e [gha] bump flake inputs 2022-08-20 18:07:29 +00:00
vaxerski
cc3f0ff9e7 update wlroots dep 2022-08-20 20:06:24 +02:00
vaxerski
7af193d921 reload on input and device hyprctl 2022-08-20 18:57:30 +02:00
vaxerski
132c96f867 multiple fixes for device configs 2022-08-20 18:47:48 +02:00
vaxerski
45a0e69286 Find a candidate better on window close 2022-08-20 18:12:59 +02:00
vaxerski
0ebef9a8ae no focus to OR Xwayland 2022-08-20 18:00:50 +02:00
vaxerski
185f93ae64 fix dwindle active for splits 2022-08-20 17:59:15 +02:00
Darksome
776750ee34 Merge branch 'main' of github.com:xDarksome/Hyprland 2022-08-20 13:26:31 +03:00
Darksome
37e1450a4d Impl CCompositor::moveWindowToWorkspace 2022-08-20 13:25:56 +03:00
vaxerski
1b1a0259a8 fix crash 2022-08-19 23:22:59 +02:00
Vaxry
223ca6e286 Merge pull request #548 from FlafyDev/main
add input:kb_file option to use a .xkb file.
2022-08-19 22:39:50 +02:00
FlafyDev
f0ad77251b move absolutePath to MiscFunctions 2022-08-19 23:18:09 +03:00
vaxerski
c2a3896cc9 added dwindle:use_active_for_splits 2022-08-19 22:03:41 +02:00
Vaxry
e749331f30 update wiki links in readme 2022-08-19 21:50:57 +02:00
FlafyDev
69d17bf424 add input:kb_file 2022-08-19 21:01:51 +03:00
vaxerski
946222f4a7 fix typo in swipe alpha control 2022-08-19 17:42:10 +02:00
vaxerski
504d07a87d fix swipe on workspace style fade 2022-08-19 17:36:01 +02:00
vaxerski
81b27be6bb reset lastwindow on full LS focus 2022-08-19 17:29:16 +02:00
vaxerski
f9e30e985c fix refocus on no window 2022-08-19 17:25:07 +02:00
vaxerski
6cae44e2c0 fix custom rounding in shadow deco 2022-08-19 14:52:18 +02:00
vaxerski
43aea417b0 Fix occasional hangups on exit 2022-08-18 22:36:58 +02:00
xDarksome
4af95d4253 Merge branch 'hyprwm:main' into main 2022-08-18 22:24:00 +03:00
Darksome
844c33c980 Add mapwindow, unmapwindow and movewindow IPC events 2022-08-18 22:23:28 +03:00
Vaxry
ece3ac97f9 Merge pull request #543 from Roger-Roger-debug/main
More fullscreen animation fixes
2022-08-18 19:51:37 +02:00
vaxerski
9b62328b22 minor changes to the activelayout event 2022-08-18 17:50:32 +02:00
vaxerski
c1a64a2b9d added main param to keyboards 2022-08-18 17:34:01 +02:00
vaxerski
b078a12eed Added an activelayout event 2022-08-18 17:17:33 +02:00
Roger Roger
eca6e53bd7 Animate workspaces with fullscreen windows 2022-08-18 12:42:21 +02:00
Roger Roger
f2d3aecf00 Don't draw fullscreen windows on other monitors 2022-08-18 12:41:10 +02:00
vaxerski
f3c597bfb7 fix crash 2022-08-18 07:28:07 +02:00
vaxerski
c5a4c83f78 better integrate touch with subsurfaces 2022-08-17 23:23:36 +02:00
vaxerski
f4d11d2d43 fix lastFocus on activateWindow 2022-08-17 22:59:40 +02:00
Vaxry
4c1dba643e Merge pull request #535 from Roger-Roger-debug/main
Fix workspace animation showing on other monitors
2022-08-17 12:35:03 +02:00
Roger Roger
5a20573e91 Fix workspace animation showing on other monitors 2022-08-17 12:12:16 +02:00
vaxerski
cd9c85a150 never animate moving floating windows 2022-08-16 22:40:16 +02:00
vaxerski
bbc6b5d5e0 added misc:animate_manual_resizes 2022-08-16 21:56:54 +02:00
vaxerski
a59641096c ignore dwindle reload on full window null 2022-08-16 21:32:12 +02:00
vaxerski
c6de4ee4b7 more checks in fullscreen event 2022-08-16 21:30:53 +02:00
vaxerski
317b6c430c damage monitor on workspace swipe end 2022-08-16 16:34:36 +02:00
vaxerski
095487ea5d disallow configure from fullscreen 2022-08-16 16:31:44 +02:00
vaxerski
daeb0d3418 force sending size on setWindowFullscreen 2022-08-16 16:30:10 +02:00
vaxerski
7cde50a018 scale hyprerror with the monitor res 2022-08-16 16:25:53 +02:00
vaxerski
bec7501365 fix borders on no_gaps_when_only 2022-08-16 16:19:52 +02:00
vaxerski
ea45c6bfe0 fix memory issue with hyprctl devices 2022-08-16 16:15:43 +02:00
vaxerski
6e2467cc24 fix active keymap in hyprctl devices 2022-08-16 16:10:20 +02:00
vaxerski
454d0d3f9f fix autogen config warning 2022-08-16 15:59:18 +02:00
vaxerski
d2011a4ba9 added support for window selection in moving to workspace 2022-08-15 16:12:53 +02:00
vaxerski
b0b3a5af10 added resizewindowpixel and movewindowpixel 2022-08-15 15:59:07 +02:00
vaxerski
d47bfe6af1 remove unused fixXWaylandWindowsOnWorkspace 2022-08-15 00:34:39 +02:00
Mihai Fufezan
c982312c07 Nix HM module: reload config-only 2022-08-15 00:47:56 +03:00
vaxerski
f0fe0c25d6 added config-only to hyprctl reload 2022-08-14 23:26:18 +02:00
vaxerski
d906617fb6 clean up fullscreen logic in fullscreenWindow event 2022-08-14 23:03:50 +02:00
Mihai Fufezan
ed1b72f37d Nix HM module: add XDG_SESSION_TYPE, fix reload 2022-08-14 23:45:55 +03:00
vaxerski
28867758c4 better fix the last fix 2022-08-14 16:39:56 +02:00
vaxerski
920727cbba fix crash with fullscreen requests 2022-08-14 16:34:40 +02:00
vaxerski
bfe0f844d2 fix wallpaper pixelation in some cases 2022-08-13 22:33:51 +02:00
vaxerski
214c2c7b1c fix groups not updating size on head change 2022-08-13 10:08:35 +02:00
vaxerski
9136783e9c default hardcoded rule to preferred auto 2022-08-12 22:26:35 +02:00
Vaxry
662b6003c6 Merge pull request #515 from SignalWalker/main
fix: support clang in meson build
2022-08-12 22:15:32 +02:00
Fernando Ayats
c136078239 nix: use cleanSource (#518) 2022-08-12 23:12:24 +03:00
Ash Walker
38056c0102 fix: support clang in meson build 2022-08-12 11:21:19 -04:00
vaxerski
db35a1c6d0 ensure egl is current in begin 2022-08-12 17:10:07 +02:00
vaxerski
66b0622bc5 fixed popup unmap damage 2022-08-12 17:04:26 +02:00
vaxerski
0e57651e2f fix segfault with cyclenext null 2022-08-11 22:56:16 +02:00
vaxerski
e5ab9643be enable layers_hog_keyboard_focus by default 2022-08-11 21:52:38 +02:00
vaxerski
b3c5809986 fix flags syntax in json 2022-08-11 21:29:31 +02:00
vaxerski
ae175fdda5 handle json for hyprctl version 2022-08-11 21:28:37 +02:00
vaxerski
9102471610 added hyprctl getoption 2022-08-11 21:16:38 +02:00
vaxerski
f85c765634 change activemon to focusedmon for consistency 2022-08-11 20:55:39 +02:00
vaxerski
37442db20e destroy program in shader destructor 2022-08-11 20:33:35 +02:00
vaxerski
b178891ab3 compile shaders for every context separately 2022-08-11 20:29:21 +02:00
vaxerski
073f08301a fix formatting in focused monitor hyprctl 2022-08-11 20:22:41 +02:00
vaxerski
8fb4669b85 fix cyclenext on fullscreen 2022-08-11 20:21:55 +02:00
vaxerski
008cc63dc0 fix error for popin 2022-08-11 20:17:23 +02:00
vaxerski
aba63a7f96 disallow nested groups creation 2022-08-11 19:56:29 +02:00
vaxerski
c9ed5bf77e fix cyclenext with fullscreen windows 2022-08-11 19:45:37 +02:00
vaxerski
f4f0495050 disable focus to menu x11 types 2022-08-11 19:36:15 +02:00
vaxerski
c319a2aba9 Completely rewrote Dwindle group code 2022-08-11 19:29:39 +02:00
vaxerski
cd75606f42 change active to focused in hyprctl monitors 2022-08-10 23:49:20 +02:00
vaxerski
c7350117f1 reinit render on disconnected displays 2022-08-10 23:19:15 +02:00
vaxerski
69db6207c0 don't damage in unsafe state 2022-08-10 23:14:53 +02:00
vaxerski
58ff04fdf3 added experimental monitor saving 2022-08-10 21:54:09 +02:00
vaxerski
9b39a0c2e0 Added hyprctl setcursor 2022-08-10 21:22:11 +02:00
vaxerski
f64f94ca56 scale rounding in shadows 2022-08-10 18:29:37 +02:00
vaxerski
76877d4b15 minor changes to monitor logging 2022-08-10 18:27:57 +02:00
vaxerski
96f3b62429 multiply by scale in rounding 2022-08-10 18:22:01 +02:00
vaxerski
0162da7a7c adjust curve size for scaled 2022-08-10 18:10:38 +02:00
vaxerski
9eb750c00b added misc:layers_hog_keyboard_focus 2022-08-10 17:46:01 +02:00
vaxerski
03f2e4d42a fix compile 2022-08-10 13:45:20 +02:00
vaxerski
15fc0892c7 further fixes to monitor disabling on launch 2022-08-10 13:44:04 +02:00
vaxerski
a564be73c5 set correct full params in disabled at launch 2022-08-10 13:31:58 +02:00
vaxerski
7e8666754f allow focus to override redirect 2022-08-10 12:49:45 +02:00
vaxerski
c043bcdee6 fixes to toplevel updates 2022-08-10 08:51:59 +02:00
vaxerski
8e5985d70e clean up unconstraining logic 2022-08-09 20:36:21 +02:00
vaxerski
9255a4d2ff ignore further keybinds on submap change 2022-08-09 19:54:06 +02:00
vaxerski
113ac67a16 focus monitor on monitor rule 2022-08-09 18:51:26 +02:00
vaxerski
862722412f handle fullscreen in dwindle groups better 2022-08-09 18:37:50 +02:00
vaxerski
a6d4a4d5f3 warn about incorrect bezier args 2022-08-09 18:15:37 +02:00
vaxerski
e2f61e267e add parse errors for invalid kb layouts 2022-08-09 18:13:13 +02:00
Mihai Fufezan
ecce027c02 flake: add aarch64-linux as supported platform 2022-08-09 13:17:47 +03:00
Mihai Fufezan
f28b71232a unhide window on requested size change 2022-08-09 11:57:09 +03:00
Yavor Kolev
af9d34ab77 Fix my idiotic mistake (#502)
When resolving conflicts i accepted the old changes 👨🏻🔫
2022-08-09 02:22:55 +03:00
Mihai Fufezan
2d33d4aebc nix & meson: update version to 0.10.0 2022-08-09 01:35:05 +03:00
Vaxry
aa39653ea1 Merge pull request #500 from yavko/fix-active-window-json-bools
Fix the fix
2022-08-08 22:58:34 +02:00
Yavor Kolev
6d788f0fc9 Merge branch 'main' into fix-active-window-json-bools 2022-08-08 13:51:08 -07:00
vaxerski
ab6a62f0fd Revert "Merge pull request #499 from yavko/fix-active-window-json-bools"
This reverts commit 5aed6f1bc7, reversing
changes made to 6f137938da.
2022-08-08 22:49:02 +02:00
Yavor Kolev
d460519c30 Fix the fix 2022-08-08 13:48:33 -07:00
vaxerski
b60b52c5cf fix movefocusto with null last 2022-08-08 22:46:11 +02:00
Vaxry
5aed6f1bc7 Merge pull request #499 from yavko/fix-active-window-json-bools
makes active windoe consistient with client json
2022-08-08 22:42:09 +02:00
Yavor Kolev
5cec6257e9 The fix 2022-08-08 13:39:02 -07:00
vaxerski
6f137938da send enter and leave events for surfaces 2022-08-08 21:20:41 +02:00
vaxerski
9fca4b5bc2 fix lastwindow in focusWindow null 2022-08-08 20:42:14 +02:00
vaxerski
87a2ecb90e notify of all mods in pass 2022-08-08 20:31:48 +02:00
vaxerski
bf9d358d3b fix refocus shenanigans with window data 2022-08-08 20:21:11 +02:00
vaxerski
9532ff4287 fix unconstrain coords 2022-08-07 21:27:30 +02:00
vaxerski
d64227e7c7 added basic touch controls 2022-08-07 21:17:03 +02:00
vaxerski
3a8dcf284a add more errors 2022-08-07 19:28:46 +02:00
vaxerski
1744be7bdd log more in output cfg 2022-08-07 19:28:31 +02:00
Vaxry
9fcfaaadb6 Merge pull request #484 from rubyist/unlock-then-sleep
unlock the event queue before sleeping
2022-08-06 23:32:05 +02:00
Scott Barron
355ee15039 unlock the event queue before sleeping 2022-08-06 17:21:54 -04:00
vaxerski
9564a4cd12 added misc:always_follow_on_dnd 2022-08-06 22:26:32 +02:00
vaxerski
64e80991ca added popin anim minimum % 2022-08-06 22:11:08 +02:00
Vaxry
3829b1626e Merge pull request #483 from rubyist/json-when-no-activewindow
Have hyprctl -j activewindows return empty json object if there are no activewindows
2022-08-06 21:56:16 +02:00
Scott Barron
5ce7c71cef use empty json object when no activewindow 2022-08-06 15:36:28 -04:00
vaxerski
793b23dbe6 fix crash in toplevel set appid 2022-08-06 21:15:50 +02:00
vaxerski
070db65a24 [gha] bump flake inputs 2022-08-06 19:11:51 +00:00
vaxerski
6aa448534f guard toplevel funcs 2022-08-06 21:10:37 +02:00
vaxerski
6357a92e46 update wlroots dep 2022-08-06 21:07:32 +02:00
vaxerski
68fd97fae9 change workspace in focusWindow if necessary 2022-08-06 21:05:19 +02:00
vaxerski
1b109d9242 [gha] bump flake inputs 2022-08-06 18:58:50 +00:00
vaxerski
69b8568ccf better foreign toplevel protocol obedience 2022-08-06 20:57:38 +02:00
Vaxry
ccd68049f7 Merge pull request #479 from rubyist/fix-json
output valid json when there are no clients
2022-08-06 01:06:21 +02:00
Scott Barron
206b7f4372 output valid json when there are no clients 2022-08-05 18:53:19 -04:00
Vaxry
aa7177a9e4 Merge pull request #478 from yavko/change-to-json-bools
Change more to json bools
2022-08-06 00:33:33 +02:00
yavko
59088decd0 Change to json bools 2022-08-05 15:23:38 -07:00
Vaxry
c77b571fa7 Merge pull request #474 from yavko/patch-1
Change monitor active to json bool
2022-08-05 23:54:33 +02:00
Vaxry
49f5ae2ef3 Updated the readme header 2022-08-05 22:54:27 +02:00
vaxerski
74cbfdcda4 guard zero border 2022-08-05 22:21:14 +02:00
vaxerski
f66365d9da fix crash in dwindle on create tiled 2022-08-05 20:00:17 +02:00
vaxerski
b30bb22bb8 fix crash in getMaxSizeForWindow 2022-08-05 19:41:50 +02:00
vaxerski
d72f1cc644 fix various shadow damage issues 2022-08-05 19:23:53 +02:00
vaxerski
78e4f274bc remove some spammy logs from IME 2022-08-05 19:03:03 +02:00
vaxerski
14026d4484 move IME panel below the cursor to not obstruct 2022-08-05 18:54:59 +02:00
Vaxry
f44af0366f mention IME in the readme 2022-08-05 18:52:55 +02:00
vaxerski
cd37a1533e reject tiling windows that do not meet the max size requirement 2022-08-05 18:10:59 +02:00
vaxerski
575434f1a4 fix rounding on switching only tiled 2022-08-05 18:08:23 +02:00
vaxerski
97e82fa4fb clamp resizing tiled to their max sizes 2022-08-05 17:58:08 +02:00
vaxerski
4ea37fe64d remember floating size between tiles 2022-08-05 17:52:14 +02:00
vaxerski
ad42392856 fix rare IME crash 2022-08-05 17:19:49 +02:00
vaxerski
e0ada97a24 support zwp_input_method_v2 popups 2022-08-05 17:07:01 +02:00
vaxerski
9a8a6317ff multiple IME fixes 2022-08-05 16:21:08 +02:00
vaxerski
cb5521ec6e fix possible crashes with IME 2022-08-05 13:19:16 +02:00
vaxerski
1c4d0e8c18 added IME protocol support 2022-08-05 13:03:37 +02:00
Yavor Kolev
9f11765707 Change monitor active to json bool 2022-08-04 16:25:56 -07:00
vaxerski
3947fe9e9f simplify border rendering when rounding is 0 2022-08-04 17:21:01 +02:00
vaxerski
c7c0149c08 [gha] bump flake inputs 2022-08-04 14:02:25 +00:00
vaxerski
d58233d08b update wlroots dep 2022-08-04 16:01:11 +02:00
vaxerski
07f68bf72a scale shadows properly 2022-08-04 11:18:33 +02:00
vaxerski
5e97fe8fcd use auto in default configs 2022-08-04 11:11:21 +02:00
vaxerski
81308a9cc3 add position auto for mon config 2022-08-04 11:10:26 +02:00
vaxerski
5dcbce550f only ensure DPMS in hyprctl monitors 2022-08-03 21:19:12 +02:00
vaxerski
5a96142cf8 guard monitor settings 2022-08-03 21:06:51 +02:00
vaxerski
9540106959 check for x11type and not nofocus in wcf 2022-08-03 21:03:08 +02:00
vaxerski
69558acb2e noInitialFocus in onWindowCreatedFloating as a check 2022-08-03 20:15:39 +02:00
vaxerski
37068cf4f0 fix crash with reenabling a monitor 2022-08-03 17:42:19 +02:00
vaxerski
587330d864 fix recursion bomb 2022-08-03 17:32:12 +02:00
vaxerski
9991db159c fix dynamic reenabling of a monitor 2022-08-03 17:29:05 +02:00
vaxerski
f488ec166d fix crash 2022-08-03 17:19:32 +02:00
vaxerski
871c81ac1a erase instead of overwriting monitor rules 2022-08-03 17:15:45 +02:00
vaxerski
36e563c79c reload monitors instantly on tickHyprCtl 2022-08-03 17:12:38 +02:00
vaxerski
69365c7609 fix monitor rule possible segv 2022-08-03 16:20:33 +02:00
vaxerski
c3edb20e04 make monitor IDs permanent 2022-08-03 16:19:00 +02:00
vaxerski
b9be405d32 clear ls lists on monitor disconnect 2022-08-03 16:12:05 +02:00
vaxerski
8dd88d901d guard onDisconnect 2022-08-03 16:05:25 +02:00
vaxerski
996e5a9e69 disallow swapping in fullscreen 2022-08-03 15:35:28 +02:00
vaxerski
fff7534721 fullscreen new window on fullscreen movefocus 2022-08-03 15:33:55 +02:00
vaxerski
cd483a7a37 ignore borders in nogapswhenonly 2022-08-03 15:25:30 +02:00
vaxerski
e13f2480ff fixed missing recursion of force in dwindle 2022-08-03 12:30:28 +02:00
vaxerski
f36cd350cc do not animate mouse resizes in layouts 2022-08-03 12:27:20 +02:00
vaxerski
c779a7c03b move refocus on only unmap 2022-08-03 12:03:18 +02:00
vaxerski
179e5188a4 remove incorrect border thickness calc 2022-08-03 12:03:15 +02:00
Vaxry
d3c96c248c Merge pull request #463 from luxus/patch-1
update flake to 0.9.1
2022-08-02 23:20:58 +02:00
Kai
3fabf1c483 update flake to 0.9.1
and again :D
2022-08-02 22:40:37 +02:00
vaxerski
02fbb3a417 fix preferred mode 2022-08-02 22:20:45 +02:00
vaxerski
9c8d32d1c2 default new blur optimiz to 0 2022-08-02 15:26:44 +02:00
vaxerski
a71f4114b0 added opaque windowrule 2022-08-02 00:08:31 +02:00
vaxerski
a6cd552980 bring back xdg current desktop 2022-08-01 23:31:25 +02:00
vaxerski
100d29d34d use nproc in makefile 2022-08-01 22:48:43 +02:00
vaxerski
00747fc6df fix preWindowPass with floating as first 2022-08-01 20:32:46 +02:00
vaxerski
523023aec7 mark blur dirty on monitor damage 2022-08-01 20:28:20 +02:00
vaxerski
024752bbe3 fix new blur optimizations with non-full damage 2022-08-01 20:18:26 +02:00
vaxerski
e794de1f4d guard texid in new optimized blur 2022-08-01 19:50:37 +02:00
vaxerski
1edd66618f added general:no_cursor_warps 2022-08-01 18:50:16 +02:00
vaxerski
338865e433 added follow_mouse 3 2022-08-01 18:42:11 +02:00
vaxerski
cb36456f40 optimize new blur rendering 2022-08-01 15:32:20 +02:00
vaxerski
b90159c089 revert blur changes 2022-08-01 15:29:49 +02:00
vaxerski
0ba17d4da3 fix oopsie with optim 2022-08-01 15:28:14 +02:00
vaxerski
d6e227ae0d don't stencil with new optimizations in blur 2022-08-01 15:24:42 +02:00
vaxerski
6427bb41d8 reload blur on cfg reload 2022-08-01 13:12:50 +02:00
vaxerski
60c16f77a6 added master:no_gaps_when_only 2022-08-01 12:57:37 +02:00
vaxerski
f892387b70 added dwindle:no_gaps_when_only 2022-08-01 12:51:52 +02:00
vaxerski
6378990bc3 fixes to the new blur system 2022-08-01 12:23:09 +02:00
vaxerski
070d7699a7 added decoration:blur_new_optimizations 2022-08-01 12:16:33 +02:00
vaxerski
8a4e04d789 check window validity in getfirstwindowonworkspace 2022-08-01 00:45:06 +02:00
vaxerski
46e18e08d1 contain for the hyprland default bg 2022-07-31 23:44:04 +02:00
Kai
9ac00fe52b update flake.nix to version 0.9.0beta (#451) 2022-07-31 22:44:51 +03:00
vaxerski
d44adb1bea [gha] bump flake inputs 2022-07-31 18:31:50 +00:00
vaxerski
40c652f23e update wlroots dep 2022-07-31 20:30:43 +02:00
vaxerski
575c3e071a fix ls fadeout on scaled 2022-07-31 17:20:33 +02:00
vaxerski
dba4596c7e focus to first window on not found in refocus 2022-07-31 17:07:39 +02:00
vaxerski
e95aa8ef26 minor fixes to render loop 2022-07-31 16:54:36 +02:00
vaxerski
a1d1ec4c46 added misc:mouse_move_enables_dpms 2022-07-31 15:46:42 +02:00
Mihai Fufezan
d9687c93ee Nix: add cachix (#448) 2022-07-31 15:19:28 +03:00
vaxerski
9be239dac6 remove wlr_viewporter, we do not support it 2022-07-31 14:10:21 +02:00
vaxerski
76f7c2510e account for geom in initial XDG window popups 2022-07-31 14:05:47 +02:00
vaxerski
2230f0ccaa move to XDG 4 2022-07-31 13:21:33 +02:00
vaxerski
04f8029fcc fix minor XDG issue 2022-07-31 13:14:56 +02:00
vaxerski
20cba2d707 damage monitor on dpms on 2022-07-31 12:39:49 +02:00
vaxerski
e2bc07d276 fix lack of return in tickHyprctl 2022-07-31 12:35:10 +02:00
vaxerski
edac94bed1 tick hyprctl separately 2022-07-31 00:27:32 +02:00
Mihai Fufezan
4610b3d864 protocols: add wlr-output-power-management-unstable-v1.xml to meson.build 2022-07-31 01:09:26 +03:00
vaxerski
0573d5987f dont account for scale in border thick 2022-07-31 00:07:35 +02:00
vaxerski
e5cef8fc96 account for scale in downrounding 2022-07-31 00:04:34 +02:00
vaxerski
382f851b30 account for border in rounding 2022-07-31 00:00:24 +02:00
vaxerski
2e3d42a9a9 added a dpms dispatcher 2022-07-30 23:51:13 +02:00
vaxerski
217ff1f401 do not call dmabuf_create twice 2022-07-30 23:45:27 +02:00
vaxerski
c2db3ad8ce fix minor memory issue 2022-07-30 23:04:31 +02:00
vaxerski
2e0dd4bea2 use pref in default configs 2022-07-30 22:55:20 +02:00
vaxerski
d6a649c1b3 added preferred to monitor cfg 2022-07-30 22:54:29 +02:00
vaxerski
f96b611651 support wlr-output-power-management 2022-07-30 22:41:24 +02:00
vaxerski
4211b37e22 added misc:damage_entire_on_snapshot 2022-07-30 22:26:46 +02:00
vaxerski
45747fb8e6 fix snapshots on scaled 2022-07-30 22:22:51 +02:00
vaxerski
adeab98831 some window fadeout fixes 2022-07-30 22:07:40 +02:00
vaxerski
036be18bf5 fix shader fix 2022-07-30 19:00:38 +02:00
Mihai Fufezan
59879e0bd1 Nix module: make package nullable part 3 2022-07-30 18:19:27 +03:00
Mihai Fufezan
132b5ba5b6 Nix module: make package nullable part 2 2022-07-30 18:14:46 +03:00
Mihai Fufezan
3c544e1c31 Nix module: make package nullable 2022-07-30 18:11:46 +03:00
vaxerski
191c02a4f4 update decos on configureX11 2022-07-30 15:22:34 +02:00
vaxerski
7c7690eb08 windowrules for floating remove hidden flag 2022-07-30 12:42:27 +02:00
Mihai Fufezan
66680a1149 Nix: fix failing module 2022-07-29 18:39:10 +03:00
Vaxry
fd74208453 Merge pull request #446 from IanManske/movecurrentworkspace-nullmonitor-fix
Fix crash from moving current workspace to nonexistent (null) monitor.
2022-07-29 17:19:25 +02:00
vaxerski
e56699826f Optimize shaders 2022-07-29 17:07:33 +02:00
Ian Manske
ef2417fbcb Fix crash from moving current workspace to nonexistent (null) monitor. 2022-07-29 10:59:31 -04:00
reptee
fd999100f0 Remove extra packages in nix module (#343)
Co-authored-by: Mihai Fufezan <fufexan@pm.me>
Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2022-07-29 14:35:38 +03:00
Mihai Fufezan
0eebf3ab16 meson: add -DGIT arguments (#321) 2022-07-29 13:21:19 +03:00
vaxerski
ac8e5fef10 even more damage scaled fixes 2022-07-29 11:52:56 +02:00
vaxerski
429a9bc6c3 hide only XWayland on incorrect size 2022-07-29 11:45:32 +02:00
vaxerski
233bad5011 Spam the protocols less with resizes of XDG 2022-07-28 23:55:00 +02:00
vaxerski
0f19bd99f8 more scaled surface damage fixes 2022-07-28 23:21:35 +02:00
vaxerski
f0cd784f79 fixes to surface damaging on scaled 3 2022-07-28 22:41:59 +02:00
vaxerski
7a2f296c93 surface damage fixes 2 2022-07-28 22:23:27 +02:00
vaxerski
0b0cd85085 surface damage fixes 2 2022-07-28 22:23:00 +02:00
vaxerski
3f62a386bf surface damage fixes 2022-07-28 22:15:56 +02:00
vaxerski
4076a3b6d7 fixed device configs 2022-07-28 21:38:30 +02:00
vaxerski
13d9c85e4e fix alpha with xwl opacity 2022-07-28 18:17:47 +02:00
vaxerski
9afa3953e9 fix crash oopsie 2022-07-28 17:56:11 +02:00
Vaxry
398662c75a Merge pull request #440 from Roger-Roger-debug/main
Fix hyprctl flags help
2022-07-28 17:47:56 +02:00
Roger Roger
5bc9534642 Fix hyprctl flags help 2022-07-28 16:42:18 +02:00
vaxerski
0e2038fedf minor fullscreen anim fixes 2022-07-28 16:33:45 +02:00
vaxerski
6d35d642ea fix fullscreen workspace slide anims 2022-07-28 15:56:55 +02:00
vaxerski
b0ab8afc58 fix some XWayland weird popups 2022-07-28 15:40:06 +02:00
vaxerski
578787b36d add gestures to example configs 2022-07-28 13:44:17 +02:00
vaxerski
f6c7a79988 update default configs for new anim config 2022-07-28 13:39:05 +02:00
vaxerski
9d5b76b757 fix typo in new anim handlers 2022-07-28 13:34:52 +02:00
vaxerski
920fdd6bff Animation config rework 2022-07-28 13:28:43 +02:00
vaxerski
9dd17a4be6 Added toggleopaque dispatcher 2022-07-28 12:07:41 +02:00
vaxerski
3904351678 Added layoutmsg and some master layout msgs 2022-07-28 12:00:10 +02:00
vaxerski
b6f2a4bc36 damage popups correctly 2022-07-28 11:37:27 +02:00
vaxerski
e102f9ec8c remove make man 2022-07-27 23:12:18 +02:00
vaxerski
ee15ad1215 render ls popups correctly 2022-07-27 18:02:20 +02:00
Gabriel Fontes
1d3e1472f2 nix: add home-manager module (#395) 2022-07-27 17:32:42 +03:00
Mihai Fufezan
b2627c05c4 flake & meson: 0.7.0 -> 0.8.1
nix: add legacyRenderer option
2022-07-27 14:57:59 +03:00
vaxerski
427bc35b6b fix empty workspace name on unspecified default 2022-07-27 13:56:01 +02:00
vaxerski
c9c4b14ef2 optimize xwayland has_alpha blur 2022-07-27 13:30:55 +02:00
vaxerski
cb1a36faf0 missed 2 structs 2022-07-27 12:36:56 +02:00
vaxerski
31a079b347 added DPMS 2022-07-27 12:32:00 +02:00
Vaxry
50b991674b Merge pull request #379 from volitank/main
docs: add man pages
2022-07-27 00:08:12 +02:00
vaxerski
28046e9da0 added binds:scroll_event_delay 2022-07-26 23:34:03 +02:00
vaxerski
cc146f0344 use transformed size in popup unconstrain 2022-07-26 22:58:25 +02:00
vaxerski
d3c1d3435c fix typo in XDG popup callbacks 2022-07-26 22:45:59 +02:00
vaxerski
57f5de68ae remove commit event cuz i forgot 2022-07-26 22:01:55 +02:00
vaxerski
eb30d9bdc8 fix typo in LS destroy event 2022-07-26 21:59:07 +02:00
vaxerski
98ef43496b listener fixes 2022-07-26 21:41:29 +02:00
vaxerski
1455442b9a fix swipe not cancelling constraints 2022-07-26 18:38:30 +02:00
vaxerski
71c1ff8ee3 log xwayland in hyprctl 2022-07-26 18:25:08 +02:00
vaxerski
b18a2738e3 schedule recalcs in LS 2022-07-26 18:22:34 +02:00
vaxerski
99ebbb36b2 README stuff 2022-07-26 17:34:53 +02:00
vaxerski
6f2368f809 Add a pass dispatcher 2022-07-26 17:30:30 +02:00
vaxerski
7dc014e967 r and e exclusivity in bind 2022-07-26 17:04:26 +02:00
vaxerski
66eac124e2 add binding to mouse buttons 2022-07-26 14:50:21 +02:00
vaxerski
d04f36c57d set moz env 2022-07-26 10:05:29 +02:00
vaxerski
7babcf7e6a arrange after switch 2022-07-25 23:53:43 +02:00
vaxerski
b0d91cbf3a simplify formats 2022-07-25 22:40:34 +02:00
vaxerski
db899e00e7 adjust ls fading out logic 2022-07-25 22:00:46 +02:00
vaxerski
6e16dfa5e5 use defines for unreachable 2022-07-25 21:34:57 +02:00
vaxerski
c998e946aa Wrap adding to fading out
needed to avoid memory safety issues, because sometimes there would be duplicates.
2022-07-25 21:08:54 +02:00
vaxerski
cde39e0b6e ls fixes 2022-07-25 20:47:56 +02:00
vaxerski
b1d3a1deea force unmap on direct destroy 2022-07-25 18:38:40 +02:00
vaxerski
e2594c79cc fix fading out layers without unmap 2022-07-25 18:35:53 +02:00
vaxerski
a0be6e19d8 fix shadowing with doesntHave 2022-07-25 16:12:06 +02:00
vaxerski
14176f01ca fix swiping with one workspace on monitor 2022-07-25 15:42:27 +02:00
Vaxry
574d950145 updated previews in readme 2022-07-25 15:05:23 +02:00
vaxerski
bb539f0a8d added keybind repeat flag 2022-07-25 14:42:49 +02:00
vaxerski
067e2d39f6 shadow with respect of keysym on press 2022-07-25 14:24:02 +02:00
vaxerski
e388a86c9d move floating windows manually on moveworkspacetomonitor 2022-07-25 14:22:32 +02:00
vaxerski
3e6abaf680 fix some swipe issues 2022-07-25 14:06:49 +02:00
vaxerski
6dc8c4b310 Shadowing Keybinds fixes 2022-07-24 14:35:58 +02:00
vaxerski
1ddd7ee713 remove forced envvars 2022-07-24 13:29:46 +02:00
vaxerski
92d1d21a3d added default touchpad settings to example configs 2022-07-24 12:23:31 +02:00
vaxerski
8dcc3032a8 fix keybinds shadowing multibinds 2022-07-24 12:16:26 +02:00
vaxerski
1626707b7f make layerSurfaces into RAII 2022-07-23 15:48:08 +02:00
Blake Lee
970bcc467c remove version 2022-07-22 15:32:56 -04:00
Mihai Fufezan
72700bf9dc layersurfaces: set default geometry 2022-07-22 20:28:43 +03:00
vaxerski
616ec22735 wrapped wl_listener fixes 2022-07-22 13:34:19 +02:00
vaxerski
d9b0edb786 remove newPopup handler for LS 2022-07-22 13:12:26 +02:00
vaxerski
3f169a937a fix wlr workspace names before init 2022-07-22 12:37:44 +02:00
vaxerski
fa1273f258 minor changes to swipes 2022-07-22 00:13:56 +02:00
vaxerski
8f66ddcad0 minor changes to swipes 2022-07-22 00:10:26 +02:00
vaxerski
4db1062af6 minor changes to swipes 2022-07-22 00:08:25 +02:00
vaxerski
0013ef9ef0 reload input after exec once 2022-07-21 20:30:48 +02:00
vaxerski
19cd04c85f shadow keybinds on drag events 2022-07-21 19:44:34 +02:00
Vaxry
a011c28227 Merge pull request #265 from xDarksome/main
Scroll workspaces with Super+MouseWheel
2022-07-21 19:40:15 +02:00
Darksome
d5ccca4fdb Consider scroll as a 'pressed' key 2022-07-21 20:31:38 +03:00
vaxerski
f512bf6b5a remove server from hyprctl as it's unused 2022-07-21 19:27:55 +02:00
Darksome
ce508f1cdc Fix merge 2022-07-21 19:48:34 +03:00
Darksome
eb8a1939e6 Merge upstream 2022-07-21 19:18:03 +03:00
Vaxry
7f660fed0d Merge pull request #404 from System-x64/new-hyprland.png
Updated assets/hyprland.png
2022-07-21 14:46:56 +02:00
vaxerski
75ce01b1a7 Make the thread manager into a wl event loop timer 2022-07-21 12:33:22 +02:00
Dikshant Namdeo
b9f8d900b3 updated-hyprland.png 2022-07-21 12:31:24 +05:30
vaxerski
189cbe9f09 added shadowing keybinds 2022-07-20 23:17:26 +02:00
vaxerski
fa2bd3b1a8 added keybinds on key up 2022-07-20 22:45:06 +02:00
vaxerski
fc33cae70c change bind flag parsing 2022-07-20 22:33:43 +02:00
vaxerski
641aaff998 minor code adjustments 2022-07-20 18:39:08 +02:00
vaxerski
9463e3eb0a fix transformed snapshots a bit 2022-07-20 16:28:05 +02:00
vaxerski
e6b151b6c3 fix memory read after free in damageSurface 2022-07-20 12:06:14 +02:00
vaxerski
d52446135b add sensitivity per device & reload mice on config 2022-07-19 19:26:53 +02:00
vaxerski
1ba600ca23 added workspace swipe fingers 2022-07-19 18:35:24 +02:00
vaxerski
0026414f9b fix workspace swipes mistake 2022-07-19 18:30:53 +02:00
vaxerski
ce8d655fad fix oopsie in log 2022-07-19 16:39:15 +02:00
vaxerski
d4690a5c5e minor change to unmanaged X11 geom requests 2022-07-19 16:38:27 +02:00
vaxerski
755245e752 adjust workspace on geom change x11 2022-07-19 16:21:35 +02:00
vaxerski
ec2afb563e fix oopsie include 2022-07-19 14:28:37 +02:00
vaxerski
59e34e311e fix oopsie include 2022-07-19 14:27:52 +02:00
vaxerski
c6c3d66373 fix hyprctl with relative negative 2022-07-19 14:24:03 +02:00
vaxerski
21217bcb2b notify enter on subsurfaces with follow mouse not 1 2022-07-19 14:05:12 +02:00
vaxerski
f905ae33c8 guard pSurface in unmapsubsurface 2022-07-19 13:54:42 +02:00
vaxerski
0281caa8e0 fix ASan error 2022-07-19 13:36:54 +02:00
Blake Lee
a312f8e0ac replace rst2man with pandoc 2022-07-18 18:56:46 -04:00
Vaxry
f35d513bf5 Merge pull request #391 from dgerblick/focuswindow-options
focuswindow options + other hyprctl bugs I found when testing
2022-07-18 23:19:12 +02:00
vaxerski
10a83853ac added ls noprocess 2022-07-18 21:16:01 +02:00
vaxerski
53b8263eb1 remove fixXwaylandwindowsonworkspace, not needed anymore 2022-07-18 21:15:46 +02:00
vaxerski
8bcfda2230 update moveactivetoworkspace logic 2022-07-18 20:53:29 +02:00
Daniel Gerblick
f2c0e6ef02 fixed issue causing hyprctl to output ill-formed json when strings include characters needing escaping 2022-07-18 14:47:28 -04:00
vaxerski
b669948737 fix logo center 2022-07-18 15:41:02 +02:00
vaxerski
a4b1d51c63 add new wallpapers 2022-07-18 15:31:59 +02:00
vaxerski
e7b8cda360 update logo 2022-07-18 15:23:26 +02:00
vaxerski
c466bd1219 fix webkit 2022-07-18 14:21:21 +02:00
vaxerski
ad19a15cef readme center 2022-07-18 14:20:43 +02:00
vaxerski
954a387cf9 fix center 2022-07-18 14:19:21 +02:00
vaxerski
a51f44d566 readme fix 2022-07-18 14:16:49 +02:00
vaxerski
423c9f9d56 new logo 2022-07-18 14:15:33 +02:00
vaxerski
900e6947e9 reject windows with tiny sizes, overwrite size 2022-07-18 13:14:31 +02:00
vaxerski
90d07d7b52 fix shadows on unmanaged and noborder 2022-07-18 12:39:57 +02:00
vaxerski
60cc33a53c added time logging 2022-07-18 11:46:42 +02:00
Daniel Gerblick
dc1f34c5fa added PID and address-based options for focuswindow, as well as updated hyprctl clients to be consistent with logs and hyprctl activewindow 2022-07-17 19:00:12 -04:00
vaxerski
afeb040684 fix selection events 2022-07-17 18:56:01 +02:00
vaxerski
f5bd30569f fix borders on scaled 2022-07-16 23:29:42 +02:00
vaxerski
6f1b9d6af9 add master:new_on_top 2022-07-16 23:24:42 +02:00
vaxerski
1848086abd reload layout on hyprctl layout 2022-07-16 22:44:29 +02:00
vaxerski
cb2989cec5 fix fade corner artifacts 2022-07-16 21:10:16 +02:00
vaxerski
16afa2c422 fix border rendering on certain windows
oversized subsurfaces had a tendency to be above borders, now they wont be
2022-07-16 20:57:59 +02:00
vaxerski
edcecae7a0 dont cycle on fullscreen 2022-07-16 19:55:40 +02:00
vaxerski
aac546b771 added center windowrule 2022-07-16 16:27:17 +02:00
vaxerski
ef24329495 pass through pinch events 2022-07-16 16:12:31 +02:00
vaxerski
5c836e6460 added master layout 2022-07-16 15:57:31 +02:00
Darksome
68cfc1a496 Merge branch 'main' of github.com:xDarksome/Hyprland 2022-07-16 15:35:47 +03:00
Darksome
08319dd1f5 Fix handleKeybinds debug log 2022-07-16 15:34:13 +03:00
xDarksome
4f9be67298 Merge branch 'hyprwm:main' into main 2022-07-16 15:30:32 +03:00
Darksome
ce9efb7ae3 Impl changeworkspace(e+{n}) 2022-07-16 15:28:17 +03:00
vaxerski
48e5bd96bc Added shadow colors animations and inactive col 2022-07-16 12:44:45 +02:00
Darksome
2ae088d631 Use correct wlroots commit 2022-07-16 12:47:37 +03:00
Darksome
fdbc54d97b Restore events/Devices.cpp formatting 2022-07-16 12:44:12 +03:00
Darksome
e56ff0fcb0 Merge remote-tracking branch 'upstream/main' into mouse-wheel-cfg 2022-07-16 12:40:02 +03:00
Darksome
43b7da0bb1 Rollback flake.lock 2022-07-16 12:30:07 +03:00
Blake Lee
88506d4284 Apply suggestions from code review 2022-07-15 22:34:35 -04:00
volitank
9fc74a708e Apply suggestions from code review
Co-authored-by: Mihai Fufezan <fufexan@pm.me>
2022-07-15 22:25:03 -04:00
Blake Lee
310a839700 docs: add man pages 2022-07-15 20:04:17 -04:00
vaxerski
b2650928ea obey xdg reqs better 2022-07-16 00:11:21 +02:00
Vaxry
069e3b2114 Merge pull request #376 from dgerblick/hyprctl-json-segfault-fix
Fixed SEGFAULT when running hyprctl with only the -j option
2022-07-15 23:21:46 +02:00
Daniel Gerblick
db693ec7e5 Fixed SEGFAULT when running hyprctl with only the -j option 2022-07-15 15:39:39 -04:00
xDarksome
16fecac2d1 [gha] bump flake inputs 2022-07-15 18:55:08 +00:00
Darksome
1eceae811f Try mouse wheel configuration 2022-07-15 21:54:05 +03:00
vaxerski
fbcc6936f4 fix dashes in hyprctl 2022-07-15 20:07:52 +02:00
vaxerski
90ebeaa881 fixed fullscreen opacity on fullscreen 1 2022-07-15 19:33:09 +02:00
vaxerski
1441856811 fix blur on oversized, default to enabled 2022-07-15 19:21:13 +02:00
vaxerski
19c646ab47 Minor changes to the renderer's overflow behavior
Won't squish base layers anymore
2022-07-15 19:07:06 +02:00
Darksome
5388b54442 Merge upstream 2022-07-15 19:42:03 +03:00
vaxerski
6306d4dae3 add remove, to blurls 2022-07-15 13:29:56 +02:00
Vaxry
5af26a451a Merge pull request #373 from fufexan/configpath
Add config flag
2022-07-15 12:03:50 +02:00
vaxerski
ba48e7ceea fixed up hyprctl flags 2022-07-15 11:58:09 +02:00
vaxerski
c0377457df don't poison wlr in make install 2022-07-15 11:39:11 +02:00
Mihai Fufezan
202fb4d8d4 add clangd cache in gitignore 2022-07-15 00:10:00 +03:00
Mihai Fufezan
d8fee02063 add simple help message 2022-07-15 00:09:31 +03:00
Mihai Fufezan
01fc3d6068 add config flag
you can now specify a config with -c <path>
2022-07-14 23:55:24 +03:00
vaxerski
634970a284 update deco values on fullscreen 2022-07-14 22:49:49 +02:00
vaxerski
642af5395e dont focus anything on constrained 2022-07-14 21:33:36 +02:00
Vaxry
316589406f Merge pull request #372 from bazuin-32/main
Fix error when running `hyprctl dispatch exec` with an arg that contains a `/`
2022-07-14 19:33:21 +02:00
bazuin-32
0085319c18 Fix error when running hyprctl dispatch exec with an arg that contains
a `/`
2022-07-14 11:23:18 -06:00
vaxerski
0488f17976 fix opacity inactive methodology 2022-07-14 18:46:42 +02:00
vaxerski
8b52858bb5 fix opacity active 2022-07-14 18:45:16 +02:00
Vaxry
b0dd370421 Merge pull request #342 from viperML/main
ci: add release workflow
2022-07-14 12:54:49 +02:00
vaxerski
65e75c0b44 fix backwards hyprctl compat 2022-07-14 11:43:15 +02:00
Vaxry
7c999fb9f5 Merge pull request #242 from calebowens/caleb-feature-add-width-multiplier
Added a multiplier for the width to height ratio
2022-07-14 11:38:49 +02:00
Kainoa Kanter
21da348826 hyprwm in readme links 2022-07-13 11:23:43 -07:00
vaxerski
c2215e4efb fix focus on fullscreen and over 2022-07-13 18:33:36 +02:00
vaxerski
49dbb586e3 fixed session-less envs 2022-07-13 18:31:09 +02:00
Vaxry
6708f3b133 Fixed TTY switching (#364) 2022-07-13 18:18:23 +02:00
vaxerski
ef7ee2fd0f added active keymap prop 2022-07-13 16:02:14 +02:00
vaxerski
e93b45615c better doc in help 2022-07-13 15:50:46 +02:00
vaxerski
0a16513946 fix warning 2022-07-13 15:48:47 +02:00
vaxerski
99e9503732 flag pos 2022-07-13 15:47:35 +02:00
Vaxry
be69098cb8 Merge pull request #360 from bazuin-32/main
Add hyprctl output in json when `-j` flag is used
2022-07-13 15:44:59 +02:00
Fernando Ayats
d7d5b1a4eb ci: fix repo source 2022-07-13 10:39:57 +02:00
Fernando Ayats
868fc6e0f3 Revert "FIXME: temp disable workflows"
This reverts commit 532ffe1681.
2022-07-13 10:36:47 +02:00
Fernando Ayats
9580ef4bc2 ci: upload source 2022-07-13 10:35:23 +02:00
Fernando Ayats
532ffe1681 FIXME: temp disable workflows 2022-07-13 10:26:11 +02:00
Fernando Ayats
0cfc97972f ci: upload source 2022-07-13 10:25:21 +02:00
bazuin-32
ab859ec9fc Fix issues with batch requests 2022-07-12 16:34:28 -06:00
bazuin-32
ac9ff795cd Fix calls to substr with invalid pos 2022-07-12 15:38:50 -06:00
vaxerski
4bea3467e0 update hyprctl help 2022-07-12 23:21:00 +02:00
vaxerski
bca93f4d3c code styling 2022-07-12 23:17:55 +02:00
vaxerski
bf762f566f Fix VRAM memory leak when releasing snapshots 2022-07-12 23:11:34 +02:00
bazuin-32
2402f2e364 Use enum for specifying hyprctl output format and change the way flags
are passed for json output
2022-07-12 14:59:36 -06:00
bazuin-32
036f431206 Add hyprctl output in json when -j flag is used 2022-07-12 11:57:33 -06:00
Mihai Fufezan
f9985a36b3 nix & meson: 0.6.2 -> 0.7.0 2022-07-12 20:12:59 +03:00
vaxerski
ad03360665 fix device sections shadowing parse errors 2022-07-12 16:07:51 +02:00
vaxerski
3914672dd5 mention more config options in cfgs 2022-07-12 15:41:42 +02:00
vaxerski
78c6371743 default vfr to off 2022-07-12 15:41:28 +02:00
Vaxry
f789a14527 updated issue guidelines 2022-07-12 15:35:23 +02:00
Darksome
cb8a6f881b Disallow scrolling into empty workspaces 2022-07-02 19:55:35 +03:00
xDarksome
185c4d6ea1 Merge branch 'hyprwm:main' into main 2022-07-02 19:43:52 +03:00
xDarksome
fc4b10d13c Remove empty line 2022-06-26 19:28:30 +03:00
xDarksome
504f76112a Merge branch 'hyprwm:main' into main 2022-06-26 19:20:20 +03:00
xDarksome
be460ea954 Merge branch 'hyprwm:main' into main 2022-06-24 18:58:11 +03:00
Darksome
776ca3baf2 Change workspace wheel scrolling direction 2022-06-24 18:57:14 +03:00
Darksome
8f62f6d4b0 Add workspace switching with mouse wheel 2022-06-20 22:47:28 +03:00
Caleb Owens
7d80327e7d fixed vertical swapping issue 2022-06-20 17:11:59 +01:00
Caleb Owens
3d46c73981 Added a multiplier for the width to height ratio 2022-06-20 14:37:27 +01:00
109 changed files with 8618 additions and 1943 deletions

28
.github/workflows/man-update.yaml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Build man pages
on:
workflow_dispatch:
push:
paths:
- docs/**
branches:
- 'main'
jobs:
main:
name: Build man pages
runs-on: ubuntu-latest
steps:
- name: Install deps
run: sudo apt install pandoc
- name: Clone repository
uses: actions/checkout@v3
# Not needed
# with:
# submodules: recursive
- name: Build man pages
run: make man
- uses: stefanzweifel/git-auto-commit-action@v4
name: Commit
with:
commit_message: "[gha] build man pages"

View File

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

38
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Release artifacts
on:
release:
types: [published]
workflow_dispatch:
jobs:
source-tarball:
runs-on: ubuntu-latest
steps:
- name: Checkout Hyprland
id: checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Create tarball with submodules
id: tar
run: tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz *
- id: whatrelease
name: Get latest release
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: hyprwm
repo: Hyprland
excludes: prerelease, draft
- name: Upload to release
id: upload
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: source.tar.gz
asset_name: source-${{ steps.whatrelease.outputs.release }}.tar.gz
tag: ${{ steps.whatrelease.outputs.release }}
overwrite: true

5
.gitignore vendored
View File

@@ -10,9 +10,10 @@ CTestTestfile.cmake
_deps
build/
result
result*
/.vscode/
.envrc
.cache
*.o
*-protocol.c
@@ -23,4 +24,4 @@ hyprctl/hyprctl
gmon.out
*.out
*.tar.gz
*.tar.gz

View File

@@ -9,6 +9,8 @@ PKGS = wlroots wayland-server xcb xkbcommon libinput
CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p)))
LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p)))
DATE=$(shell date "+%d %b %Y")
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
@@ -79,21 +81,31 @@ idle-protocol.c:
idle-protocol.o: idle-protocol.h
wlr-output-power-management-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-output-power-management-unstable-v1.xml $@
wlr-output-power-management-unstable-v1-protocol.c:
$(WAYLAND_SCANNER) private-code \
protocols/wlr-output-power-management-unstable-v1.xml $@
wlr-output-power-management-unstable-v1-protocol.o: wlr-output-power-management-unstable-v1-protocol.h
legacyrenderer:
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 10
cmake --build ./build --config Release --target all -j $(nproc)
legacyrendererdebug:
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 10
cmake --build ./build --config Release --target all -j $(nproc)
release:
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 10
cmake --build ./build --config Release --target all -j $(nproc)
debug:
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 10
cmake --build ./build --config Debug --target all -j $(nproc)
clear:
rm -rf build
@@ -107,13 +119,15 @@ all:
cd ./hyprctl && make all && cd ..
install:
[ ! -d /usr/include/wlr ] || mv /usr/include/wlr /usr/include/wlrBackup
[ ! -f /usr/lib/libwlroots.so ] || mv /usr/lib/libwlroots.so /usr/lib/libwlroots.so.backup
[ ! -f /usr/lib/pkgconfig/wlroots.pc ] || mv /usr/lib/pkgconfig/wlroots.pc /usr/lib/pkgconfig/wlroots.pc.backup
make clear
make fixwlr
cd ./subprojects/wlroots && meson build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.11032 /usr/lib/ && cd ../..
make protocols
make release
cd hyprctl && make all && cd ..
make all
mkdir -p ${PREFIX}/share/wayland-sessions
cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions/
mkdir -p /usr/share/wayland-sessions
cp ./example/hyprland.desktop /usr/share/wayland-sessions/
mkdir -p ${PREFIX}/bin
cp ./build/Hyprland ${PREFIX}/bin
cp ./hyprctl/hyprctl ${PREFIX}/bin
@@ -122,12 +136,26 @@ install:
cp ./assets/wall_4K.png ${PREFIX}/share/hyprland
cp ./assets/wall_8K.png ${PREFIX}/share/hyprland
rm -rf /usr/include/wlr
rm -f /usr/lib/libwlroots.so
rm -f /usr/lib/pkgconfig/wlroots.pc
[ ! -d /usr/include/wlrBackup ] || mv /usr/include/wlrBackup /usr/include/wlr
[ ! -f /usr/lib/libwlroots.so.backup ] || mv -f /usr/lib/libwlroots.so.backup /usr/lib/libwlroots.so
[ ! -f /usr/lib/pkgconfig/wlroots.pc.backup ] || mv -f /usr/lib/pkgconfig/wlroots.pc.backup /usr/lib/pkgconfig/wlroots.pc
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.11032 /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:
rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop
@@ -135,8 +163,10 @@ uninstall:
rm -f ${PREFIX}/bin/hyprctl
rm -f /usr/lib/libwlroots.so.11032
rm -rf ${PREFIX}/share/hyprland
rm -f ${PREFIX}/share/man/man1/Hyprland.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
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
fixwlr:
sed -i -E 's/(soversion = 11)([^032]|$$)/soversion = 11032/g' subprojects/wlroots/meson.build
@@ -152,3 +182,20 @@ config:
cd subprojects/wlroots && ninja -C build/
cd subprojects/wlroots && ninja -C build/ install
man:
pandoc ./docs/Hyprland.1.rst \
--standalone \
--variable=header:"Hyprland User Manual" \
--variable=date:"${DATE}" \
--variable=section:1 \
--from rst \
--to man > ./docs/Hyprland.1
pandoc ./docs/hyprctl.1.rst \
--standalone \
--variable=header:"hyprctl User Manual" \
--variable=date:"${DATE}" \
--variable=section:1 \
--from rst \
--to man > ./docs/hyprctl.1

View File

@@ -1,6 +1,6 @@
<div align = center>
<img src="https://raw.githubusercontent.com/vaxerski/Hyprland/main/assets/header.svg" width="1000" height="500" alt="banner">
<img src="https://raw.githubusercontent.com/vaxerski/Hyprland/main/assets/header.svg" width="750" height="300" alt="banner">
<br>
@@ -17,9 +17,7 @@
Hyprland is a dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks.
For Hyprland without the `land` part, see [Hypr], the Xorg window manager.
Please note, especially for folks moving from Hypr, that Hyprland and Hypr share a very different feature set and are not 1:1 experiences.
It supports multiple layouts, fancy effects, has a very flexible IPC model allowing for a lot of customization, and more.
<br>
<br>
@@ -57,6 +55,7 @@ Try it out and report bugs / suggestions!
- Drop shadows
- Fully dynamic workspaces
- Closely follows `wlroots-git`
- Global keybinds passed to your apps of choice
- Bundled wlroots
- Window/layer fade in/out
- Tiling/pseudotiling/floating/fullscreen windows
@@ -69,6 +68,8 @@ Try it out and report bugs / suggestions!
- Full damage tracking
- Docks support
- Drawing tablet support
- Native IME + Input panels support
- and much more...
<br>
<br>
@@ -122,18 +123,18 @@ Try it out and report bugs / suggestions!
<!----------------------------------------------------------------------------->
[Configure]: https://github.com/vaxerski/Hyprland/wiki/Configuring-Hyprland
[Configure]: https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
[Discord]: https://discord.gg/hQ9XvMUjjr
[Stars]: https://starchart.cc/vaxerski/Hyprland
[Hypr]: https://github.com/vaxerski/Hypr
[Stars]: https://starchart.cc/hyprwm/Hyprland
[Hypr]: https://github.com/hyprwm/Hypr
[Pull Requests]: https://github.com/vaxerski/Hyprland/pulls
[Issues]: https://github.com/vaxerski/Hyprland/issues
[Todo]: https://github.com/vaxerski/Hyprland/projects?type=beta
[Pull Requests]: https://github.com/hyprwm/Hyprland/pulls
[Issues]: https://github.com/hyprwm/Hyprland/issues
[Todo]: https://github.com/hyprwm/Hyprland/projects?type=beta
[Contribute]: https://github.com/vaxerski/Hyprland/wiki/Contributing-&-Debugging
[Install]: https://github.com/vaxerski/Hyprland/wiki/Installation
[Quick Start]: https://github.com/vaxerski/Hyprland/wiki/Quick-start
[Contribute]: https://wiki.hyprland.org/Contributing-and-Debugging/
[Install]: https://wiki.hyprland.org/Getting-Started/Installation/
[Quick Start]: https://wiki.hyprland.org/Getting-Started/Quick-start/
[License]: LICENSE
@@ -149,19 +150,19 @@ Try it out and report bugs / suggestions!
<!----------------------------------{ Images }--------------------------------->
[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg
[Preview A]: https://i.imgur.com/NbrTnZH.png
[Preview B]: https://i.imgur.com/ZA4Fa8R.png
[Preview C]: https://i.imgur.com/BpXxM8H.png
[Preview A]: https://i.imgur.com/pC6YF1Y.png
[Preview B]: https://i.imgur.com/NbrTnZH.png
[Preview C]: https://i.imgur.com/sCafdKQ.png
<!----------------------------------{ Badges }--------------------------------->
[Badge Workflow]: https://github.com/vaxerski/Hyprland/actions/workflows/ci.yaml/badge.svg
[Badge Workflow]: https://github.com/hyprwm/Hyprland/actions/workflows/ci.yaml/badge.svg
[Badge Discord]: https://img.shields.io/badge/Join%20the-Discord%20server-6666ff
[Badge Issues]: https://img.shields.io/github/issues/vaxerski/Hyprland
[Badge Pull Requests]: https://img.shields.io/github/issues-pr/vaxerski/Hyprland
[Badge Language]: https://img.shields.io/github/languages/top/vaxerski/Hyprland
[Badge License]: https://img.shields.io/github/license/vaxerski/Hyprland
[Badge Lines]: https://img.shields.io/tokei/lines/github/vaxerski/Hyprland
[Badge Issues]: https://img.shields.io/github/issues/hyprwm/Hyprland
[Badge Pull Requests]: https://img.shields.io/github/issues-pr/hyprwm/Hyprland
[Badge Language]: https://img.shields.io/github/languages/top/hyprwm/Hyprland
[Badge License]: https://img.shields.io/github/license/hyprwm/Hyprland
[Badge Lines]: https://img.shields.io/tokei/lines/github/hyprwm/Hyprland
[Badge Hi Mom]: https://img.shields.io/badge/Hi-mom!-ff69b4

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 798 KiB

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 KiB

After

Width:  |  Height:  |  Size: 146 KiB

46
docs/Hyprland.1 Normal file
View File

@@ -0,0 +1,46 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "Hyprland" "1" "24 Aug 2022" "" "Hyprland User Manual"
.hy
.SH NAME
.PP
Hyprland \- Dynamic tiling Wayland compositor
.SH SYNOPSIS
.PP
\f[B]Hyprland\f[R] [\f[I]arg [...]\f[R]].
.SH DESCRIPTION
.PP
\f[B]Hyprland\f[R] is a dynamic tiling Wayland compositor based on
wlroots that doesn\[aq]t sacrifice on its looks.
.PP
You can launch Hyprland by either going into a TTY and executing
\f[B]Hyprland\f[R], or with a login manager.
.SH NOTICE
.PP
Hyprland is still in pretty early development compared to some other
Wayland compositors.
.PP
Although Hyprland is pretty stable, it may have some bugs.
.SH CONFIGURATION
.PP
For configuration information please see
<\f[I]https://github.com/hyprwm/Hyprland/wiki\f[R]>.
.SH OPTIONS
.TP
.B \f[B]\-h\f[R], \f[B]\-\-help\f[R]
Show command usage.
.TP
.B \f[B]\-c\f[R], \f[B]\-\-config\f[R]
Specify config file to use.
.SH BUGS
.TP
.B Submit bug reports and request features online at:
<\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]>
.SH SEE ALSO
.PP
Sources at: <\f[I]https://github.com/hyprwm/Hyprland\f[R]>
.SH COPYRIGHT
.PP
Copyright (c) 2022, vaxerski
.SH AUTHORS
Vaxerski <\f[I]https://github.com/vaxerski\f[R]>.

58
docs/Hyprland.1.rst Normal file
View File

@@ -0,0 +1,58 @@
:title: Hyprland
:author: Vaxerski <*https://github.com/vaxerski*>
NAME
====
Hyprland - Dynamic tiling Wayland compositor
SYNOPSIS
========
**Hyprland** [*arg [...]*].
DESCRIPTION
===========
**Hyprland** is a dynamic tiling Wayland compositor based on
wlroots that doesn't sacrifice on its looks.
You can launch Hyprland by either going into a TTY and
executing **Hyprland**, or with a login manager.
NOTICE
======
Hyprland is still in pretty early development compared to some other Wayland compositors.
Although Hyprland is pretty stable, it may have some bugs.
CONFIGURATION
=============
For configuration information please see <*https://github.com/hyprwm/Hyprland/wiki*>.
OPTIONS
=======
**-h**, **--help**
Show command usage.
**-c**, **--config**
Specify config file to use.
BUGS
====
Submit bug reports and request features online at:
<*https://github.com/hyprwm/Hyprland/issues*>
SEE ALSO
========
Sources at: <*https://github.com/hyprwm/Hyprland*>
COPYRIGHT
=========
Copyright (c) 2022, vaxerski

View File

@@ -26,6 +26,7 @@ If your bug is one that doesn't crash Hyprland, but feels like invalid behavior,
If your bug crashes Hyprland, append additionally:
- The Hyprland log
- Coredump / Coredump analysis (with a stacktrace)
- Your config
**Important**: Please do NOT use any package for reporting bugs! Clone and compile from source.

145
docs/hyprctl.1 Normal file
View File

@@ -0,0 +1,145 @@
.\" Automatically generated by Pandoc 2.5
.\"
.TH "hyprctl" "1" "24 Aug 2022" "" "hyprctl User Manual"
.hy
.SH NAME
.PP
hyprctl \- Utility for controlling parts of Hyprland from a CLI or a
script
.SH SYNOPSIS
.PP
\f[B]hyprctl\f[R] [\f[I](opt)flags\f[R]] [\f[B]command\f[R]]
[\f[I](opt)args\f[R]]
.SH DESCRIPTION
.PP
\f[B]hyprctl\f[R] is a utility for controlling some parts of the
compositor from a CLI or a script.
.SH CONTROL COMMANDS
.PP
\f[B]dispatch\f[R]
.RS
.PP
Call a dispatcher with an argument.
.PP
An argument must be present.
For dispatchers without parameters it can be anything.
.PP
Returns: \f[I]ok\f[R] on success, and an error message on failure.
.TP
.B Examples:
\f[B]hyprctl\f[R] \f[I]dispatch exec kitty\f[R]
.RS
.PP
\f[B]hyprctl\f[R] \f[I]dispatch pseudo x\f[R]
.RE
.RE
.PP
\f[B]keyword\f[R]
.RS
.PP
Set a config keyword dynamically.
.PP
Returns: \f[I]ok\f[R] on success, and an error message on failure.
.TP
.B Examples:
\f[B]hyprctl\f[R] \f[I]keyword bind SUPER,0,pseudo\f[R]
.RS
.PP
\f[B]hyprctl\f[R] \f[I]keyword general:border_size 10\f[R]
.RE
.RE
.PP
\f[B]reload\f[R]
.RS
.PP
Force a reload of the config file.
.RE
.PP
\f[B]kill\f[R]
.RS
.PP
Enter kill mode, where you can kill an app by clicking on it.
You can exit by pressing ESCAPE.
.RE
.SH INFO COMMANDS
.PP
\f[B]version\f[R]
.RS
.PP
Prints the Hyprland version, flags, commit and branch of build.
.RE
.PP
\f[B]monitors\f[R]
.RS
.PP
Lists all the outputs with their properties.
.RE
.PP
\f[B]workspaces\f[R]
.RS
.PP
Lists all workspaces with their properties.
.RE
.PP
\f[B]clients\f[R]
.RS
.PP
Lists all windows with their properties.
.RE
.PP
\f[B]devices\f[R]
.RS
.PP
Lists all connected input devices.
.RE
.PP
\f[B]activewindow\f[R]
.RS
.PP
Returns the active window name.
.RE
.PP
\f[B]layers\f[R]
.RS
.PP
Lists all the layers.
.RE
.PP
\f[B]splash\f[R]
.RS
.PP
Returns the current random splash.
.RE
.SH OPTIONS
.PP
\f[B]\-\-batch\f[R]
.RS
.PP
Specify a batch of commands to execute.
.TP
.B Example:
\f[B]hyprctl\f[R] \f[I]\-\-batch \[dq]keyword general:border_size 2 ;
keyword general:gaps_out 20\[dq]\f[R]
.RS
.PP
\f[I];\f[R] separates the commands.
.RE
.RE
.PP
\f[B]\-j\f[R]
.RS
.PP
Outputs information in JSON.
.RE
.SH BUGS
.TP
.B Submit bug reports and request features online at:
<\f[I]https://github.com/hyprwm/Hyprland/issues\f[R]>
.SH SEE ALSO
.PP
Sources at: <\f[I]https://github.com/hyprwm/Hyprland\f[R]>
.SH COPYRIGHT
.PP
Copyright (c) 2022, vaxerski
.SH AUTHORS
Vaxerski <\f[I]https://github.com/vaxerski\f[R]>.

121
docs/hyprctl.1.rst Normal file
View File

@@ -0,0 +1,121 @@
:title: hyprctl(1)
:author: Vaxerski <*https://github.com/vaxerski*>
NAME
====
hyprctl - Utility for controlling parts of Hyprland from a CLI or a script
SYNOPSIS
========
**hyprctl** [*(opt)flags*] [**command**] [*(opt)args*]
DESCRIPTION
===========
**hyprctl** is a utility for controlling some parts of the compositor from a CLI or a script.
CONTROL COMMANDS
================
**dispatch**
Call a dispatcher with an argument.
An argument must be present.
For dispatchers without parameters it can be anything.
Returns: *ok* on success, and an error message on failure.
Examples:
**hyprctl** *dispatch exec kitty*
**hyprctl** *dispatch pseudo x*
**keyword**
Set a config keyword dynamically.
Returns: *ok* on success, and an error message on failure.
Examples:
**hyprctl** *keyword bind SUPER,0,pseudo*
**hyprctl** *keyword general:border_size 10*
**reload**
Force a reload of the config file.
**kill**
Enter kill mode, where you can kill an app by clicking on it.
You can exit by pressing ESCAPE.
INFO COMMANDS
=============
**version**
Prints the Hyprland version, flags, commit and branch of build.
**monitors**
Lists all the outputs with their properties.
**workspaces**
Lists all workspaces with their properties.
**clients**
Lists all windows with their properties.
**devices**
Lists all connected input devices.
**activewindow**
Returns the active window name.
**layers**
Lists all the layers.
**splash**
Returns the current random splash.
OPTIONS
=======
**--batch**
Specify a batch of commands to execute.
Example:
**hyprctl** *--batch "keyword general:border_size 2 ; keyword general:gaps_out 20"*
*;* separates the commands.
**-j**
Outputs information in JSON.
BUGS
====
Submit bug reports and request features online at:
<*https://github.com/hyprwm/Hyprland/issues*>
SEE ALSO
========
Sources at: <*https://github.com/hyprwm/Hyprland*>
COPYRIGHT
=========
Copyright (c) 2022, vaxerski

2
docs/meson.build Normal file
View File

@@ -0,0 +1,2 @@
install_man ('Hyprland.1')
install_man ('hyprctl.1')

View File

@@ -3,10 +3,16 @@
#
# Refer to the wiki for more information.
monitor=,1280x720@60,0x0,1
#
# Please note not all available settings / options are set here.
# For a full list, see the wiki (basic and advanced configuring)
#
monitor=,preferred,auto,1
workspace=DP-1,1
input {
kb_file=
kb_layout=
kb_variant=
kb_model=
@@ -14,10 +20,15 @@ input {
kb_rules=
follow_mouse=1
touchpad {
natural_scroll=no
}
sensitivity=0 # -1.0 - 1.0, 0 means no modification.
}
general {
sensitivity=1.0 # for mouse cursor
main_mod=SUPER
gaps_in=5
@@ -35,17 +46,15 @@ decoration {
rounding=10
blur=1
blur_size=3 # minimum 1
blur_passes=1 # minimum 1, more passes = more resource intensive.
# Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts.
# if you want heavy blur, you need to up the blur_passes.
# the more passes, the more you can up the blur_size without noticing artifacts.
blur_passes=1 # minimum 1
blur_new_optimizations=1
}
animations {
enabled=1
animation=windows,1,7,default
animation=borders,1,10,default
animation=fadein,1,10,default
animation=border,1,10,default
animation=fade,1,10,default
animation=workspaces,1,6,default
}
@@ -53,6 +62,10 @@ dwindle {
pseudotile=0 # enable pseudotiling on dwindle
}
gestures {
workspace_swipe=no
}
# example window rules
# for windows named/classed as abc and xyz
#windowrule=move 69 420,abc
@@ -97,3 +110,6 @@ bind=ALT,7,movetoworkspace,7
bind=ALT,8,movetoworkspace,8
bind=ALT,9,movetoworkspace,9
bind=ALT,0,movetoworkspace,10
bind=SUPER,mouse_down,workspace,e+1
bind=SUPER,mouse_up,workspace,e-1

12
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1657447684,
"narHash": "sha256-FCP9AuU1q6PE3vOeM5SFf58f/UKPBAsoSGDUGamNBbo=",
"lastModified": 1661931183,
"narHash": "sha256-0+2KzcexiJCB3Il5t7cZAM2RXNRfm5/gMCwhcZJxLuQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5f43d8b088d3771274bcfb69d3c7435b1121ac88",
"rev": "97747d3209efde533f7b1b28f1be11619f556a06",
"type": "github"
},
"original": {
@@ -26,11 +26,11 @@
"flake": false,
"locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1656865312,
"narHash": "sha256-xtQ0zwJZwN8sciruveM10CzKz6TWxBY8SyXa8E4jly4=",
"lastModified": 1661882030,
"narHash": "sha256-Kw0MG4rXdTnbndVLLCNwkXDmNszwdQZmm7pwI1R3Kds=",
"owner": "wlroots",
"repo": "wlroots",
"rev": "5dc1d4671dd2ca3c1f0f09587c463fdbb542f0a4",
"rev": "fd0b0276c9ecc159549acff48b932b83ec3b4f12",
"type": "gitlab"
},
"original": {

View File

@@ -17,6 +17,7 @@
inherit (nixpkgs) lib;
genSystems = lib.genAttrs [
# Add more systems if they are supported
"aarch64-linux"
"x86_64-linux"
];
pkgsFor = nixpkgs.legacyPackages;
@@ -27,16 +28,18 @@
]);
in {
overlays.default = _: prev: rec {
wlroots-hyprland = prev.wlroots.overrideAttrs (__: {
version = mkDate (inputs.wlroots.lastModifiedDate or "19700101");
wlroots-hyprland = prev.callPackage ./nix/wlroots.nix {
version = mkDate (inputs.wlroots.lastModifiedDate or "19700101") + "_" + (inputs.wlroots.shortRev or "dirty");
src = inputs.wlroots;
});
};
hyprland = prev.callPackage ./nix/default.nix {
stdenv = prev.gcc12Stdenv;
version = "0.6.2beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101"));
version = "0.12.1beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
wlroots = wlroots-hyprland;
};
hyprland-debug = hyprland.override {debug = true;};
hyprland-no-hidpi = hyprland.override {hidpiXWayland = false;};
waybar-hyprland = prev.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
});
@@ -61,7 +64,11 @@
formatter = genSystems (system: pkgsFor.${system}.alejandra);
nixosModules.default = import ./nix/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

@@ -1,4 +1,4 @@
all:
g++ -std=c++20 ./main.cpp -o ./hyprctl
g++ -std=c++23 ./main.cpp -o ./hyprctl
clean:
rm ./hyprctl
rm ./hyprctl

View File

@@ -9,14 +9,18 @@
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <ranges>
#include <algorithm>
#include <iostream>
#include <string>
#include <fstream>
#include <string>
#include <deque>
const std::string USAGE = R"#(usage: hyprctl [command] [(opt)args]
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
commands:
monitors
workspaces
clients
@@ -29,7 +33,14 @@ const std::string USAGE = R"#(usage: hyprctl [command] [(opt)args]
kill
splash
hyprpaper
reload)#";
reload
setcursor
getoption
flags:
-j -> output in JSON
--batch -> execute a batch of commands, separated by ';'
)#";
void request(std::string arg) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -39,12 +50,6 @@ void request(std::string arg) {
return;
}
const auto SERVER = gethostbyname("localhost");
if (!SERVER) {
std::cout << "Couldn't get host (2)";
return;
}
// get the instance signature
auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
@@ -97,13 +102,6 @@ void requestHyprpaper(std::string arg) {
return;
}
const auto SERVER = gethostbyname("localhost");
if (!SERVER) {
std::cout << "Couldn't get host (2)";
return;
}
// get the instance signature
auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
@@ -154,7 +152,10 @@ void dispatchRequest(int argc, char** argv) {
return;
}
std::string rq = "dispatch " + std::string(argv[2]) + " " + std::string(argv[3]);
std::string rq = "/dispatch";
for(int i = 2; i < argc; i++)
rq += " " + std::string(argv[i]);
request(rq);
}
@@ -165,7 +166,10 @@ void keywordRequest(int argc, char** argv) {
return;
}
std::string rq = "keyword " + std::string(argv[2]) + " " + std::string(argv[3]);
std::string rq = "/keyword";
for(int i = 2; i < argc; i++)
rq += " " + std::string(argv[i]);
request(rq);
}
@@ -181,12 +185,36 @@ void hyprpaperRequest(int argc, char** argv) {
requestHyprpaper(rq);
}
void batchRequest(int argc, char** argv) {
std::string rq = "[[BATCH]]" + std::string(argv[2]);
void setcursorRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "setcursor requires 2 params";
return;
}
std::string rq = "setcursor " + std::string(argv[2]) + " " + std::string(argv[3]);
request(rq);
}
void batchRequest(std::string arg) {
std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
request(rq);
}
std::deque<std::string> splitArgs(int argc, char** argv) {
std::deque<std::string> result;
for (auto i = 1 /* skip the executable */; i < argc; ++i)
result.push_back(std::string(argv[i]));
return result;
}
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 == '.'); });
}
int main(int argc, char** argv) {
int bflag = 0, sflag = 0, index, c;
@@ -195,21 +223,54 @@ int main(int argc, char** argv) {
return 1;
}
if (!strcmp(argv[1], "monitors")) request("monitors");
else if (!strcmp(argv[1], "clients")) request("clients");
else if (!strcmp(argv[1], "workspaces")) request("workspaces");
else if (!strcmp(argv[1], "activewindow")) request("activewindow");
else if (!strcmp(argv[1], "layers")) request("layers");
else if (!strcmp(argv[1], "version")) request("version");
else if (!strcmp(argv[1], "kill")) request("kill");
else if (!strcmp(argv[1], "splash")) request("splash");
else if (!strcmp(argv[1], "devices")) request("devices");
else if (!strcmp(argv[1], "reload")) request("reload");
else if (!strcmp(argv[1], "dispatch")) dispatchRequest(argc, argv);
else if (!strcmp(argv[1], "keyword")) keywordRequest(argc, argv);
else if (!strcmp(argv[1], "hyprpaper")) hyprpaperRequest(argc, argv);
else if (!strcmp(argv[1], "--batch")) batchRequest(argc, argv);
else if (!strcmp(argv[1], "--help")) printf("%s", USAGE.c_str());
std::string fullRequest = "";
std::string fullArgs = "";
const auto ARGS = splitArgs(argc, argv);
for (auto i = 0; i < ARGS.size(); ++i) {
if (ARGS[i][0] == '-' && !isNumber(ARGS[i], true) /* For stuff like -2 */) {
// parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j";
} else if (ARGS[i] == "--batch") {
fullRequest = "--batch ";
} else {
printf("%s\n", USAGE.c_str());
return 1;
}
continue;
}
fullRequest += ARGS[i] + " ";
}
if (fullRequest.empty()) {
printf("%s\n", USAGE.c_str());
return 1;
}
fullRequest.pop_back(); // remove trailing space
fullRequest = fullArgs + "/" + fullRequest;
if (fullRequest.contains("/--batch")) batchRequest(fullRequest);
else if (fullRequest.contains("/monitors")) request(fullRequest);
else if (fullRequest.contains("/clients")) request(fullRequest);
else if (fullRequest.contains("/workspaces")) request(fullRequest);
else if (fullRequest.contains("/activewindow")) request(fullRequest);
else if (fullRequest.contains("/layers")) request(fullRequest);
else if (fullRequest.contains("/version")) request(fullRequest);
else if (fullRequest.contains("/kill")) request(fullRequest);
else if (fullRequest.contains("/splash")) request(fullRequest);
else if (fullRequest.contains("/devices")) request(fullRequest);
else if (fullRequest.contains("/reload")) request(fullRequest);
else if (fullRequest.contains("/getoption")) request(fullRequest);
else if (fullRequest.contains("/setcursor")) setcursorRequest(argc, argv);
else if (fullRequest.contains("/dispatch")) dispatchRequest(argc, argv);
else if (fullRequest.contains("/keyword")) keywordRequest(argc, argv);
else if (fullRequest.contains("/hyprpaper")) hyprpaperRequest(argc, argv);
else if (fullRequest.contains("/--help")) printf("%s", USAGE.c_str());
else {
printf("%s\n", USAGE.c_str());
return 1;

View File

@@ -1,8 +1,27 @@
project('Hyprland', 'cpp', 'c',
version : '0.6.2beta',
default_options : ['warning_level=2', 'default_library=static', 'optimization=3'])
version : '0.12.1beta',
default_options : [
'warning_level=2',
'default_library=static',
'optimization=3',
# 'cpp_std=c++23' # not yet supported by meson, as of version 0.63.0
])
add_global_arguments('-std=c++23', language: 'cpp')
# clang v14.0.6 uses C++2b instead of C++23, so we've gotta account for that
# replace the following with a project default option once meson gets support for C++23
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.has_argument('-std=c++23')
add_global_arguments('-std=c++23', language: 'cpp')
elif cpp_compiler.has_argument('-std=c++2b')
add_global_arguments('-std=c++2b', language: 'cpp')
else
error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)')
endif
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_MESSAGE = run_command('bash', '-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()
add_project_arguments(
[
@@ -10,6 +29,11 @@ add_project_arguments(
'-Wno-unused-value',
'-Wno-missing-field-initializers',
'-Wno-narrowing',
f'-DGIT_BRANCH="@GIT_BRANCH@"',
f'-DGIT_COMMIT_HASH="@GIT_COMMIT_HASH@"',
f'-DGIT_COMMIT_MESSAGE="@GIT_COMMIT_MESSAGE@"',
f'-DGIT_DIRTY="@GIT_DIRTY@"',
],
language: 'cpp')
@@ -35,3 +59,4 @@ subdir('src')
subdir('hyprctl')
subdir('assets')
subdir('example')
subdir('docs')

View File

@@ -2,9 +2,11 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
pkg-config,
meson,
ninja,
git,
libdrm,
libinput,
libxcb,
@@ -18,61 +20,87 @@
wlroots,
xcbutilwm,
xwayland,
enableXWayland ? true,
version ? "git",
debug ? false,
}:
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug";
inherit version;
src = ../.;
nativeBuildInputs = [
meson
ninja
pkg-config
];
buildInputs =
[
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland
wayland-protocols
wayland-scanner
(wlroots.override {inherit enableXWayland;})
xcbutilwm
]
++ lib.optional enableXWayland xwayland;
mesonBuildType =
if debug
then "debug"
else "release";
mesonFlags = lib.optional (!enableXWayland) "-DNO_XWAYLAND=true";
patches = [
# make meson use the provided wlroots instead of the git submodule
./meson-build.patch
];
# Fix hardcoded paths to /usr installation
postPatch = ''
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
enableXWayland ? true,
hidpiXWayland ? true,
legacyRenderer ? false,
nvidiaPatches ? false,
version ? "git",
}: let
assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) ''
Hyprland: cannot have hidpiXWayland when enableXWayland is false.
'';
in
assert assertXWayland;
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug";
inherit version;
passthru.providedSessions = ["hyprland"];
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (
lib.hasSuffix ".nix" baseName
);
src = lib.cleanSource ../.;
};
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
mainProgram = "Hyprland";
};
}
nativeBuildInputs = [
meson
ninja
pkg-config
];
outputs = [
"out"
"man"
];
buildInputs =
[
git
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland
wayland-protocols
wayland-scanner
(wlroots.override {inherit enableXWayland hidpiXWayland nvidiaPatches;})
xcbutilwm
]
++ lib.optional enableXWayland xwayland;
mesonBuildType =
if debug
then "debug"
else "release";
mesonFlags = builtins.concatLists [
(lib.optional (!enableXWayland) "-Dxwayland=disabled")
(lib.optional legacyRenderer "-DLEGACY_RENDERER:STRING=true")
];
patches = [
# make meson use the provided wlroots instead of the git submodule
./meson-build.patch
];
# Fix hardcoded paths to /usr installation
postPatch = ''
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
'';
passthru.providedSessions = ["hyprland"];
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
mainProgram = "Hyprland";
};
}

129
nix/hm-module.nix Normal file
View File

@@ -0,0 +1,129 @@
self: {
config,
lib,
pkgs,
...
}: let
cfg = config.wayland.windowManager.hyprland;
defaultHyprlandPackage = self.packages.${pkgs.system}.default.override {
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
};
in {
options.wayland.windowManager.hyprland = {
enable = lib.mkEnableOption "hyprland wayland compositor";
package = lib.mkOption {
type = with lib.types; nullOr package;
default = defaultHyprlandPackage;
description = ''
Hyprland package to use. Will override the 'xwayland' option.
Defaults to the one provided by the flake. Set it to
<literal>pkgs.hyprland</literal> to use the one provided by nixpkgs or
if you have an overlay.
Set to null to not add any Hyprland package to your path. This should
be done if you want to use the NixOS module to install Hyprland.
'';
};
systemdIntegration = lib.mkOption {
type = lib.types.bool;
default = pkgs.stdenv.isLinux;
description = ''
Whether to enable <filename>hyprland-session.target</filename> on
hyprland startup. This links to <filename>graphical-session.target</filename>.
Some important environment variables will be imported to systemd
and dbus user environment before reaching the target, including
<itemizedlist>
<listitem><para><literal>DISPLAY</literal></para></listitem>
<listitem><para><literal>WAYLAND_DISPLAY</literal></para></listitem>
<listitem><para><literal>HYPRLAND_INSTANCE_SIGNATURE</literal></para></listitem>
<listitem><para><literal>XDG_CURRENT_DESKTOP</literal></para></listitem>
</itemizedlist>
'';
};
xwayland = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable XWayland.
'';
};
hidpi = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable HiDPI XWayland.
'';
};
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
'';
};
imports = [
(
lib.mkRenamedOptionModule
["wayland" "windowManager" "hyprland" "xwayland"]
["wayland" "windowManager" "hyprland" "xwayland" "enable"]
)
];
};
config = lib.mkIf cfg.enable {
home.packages =
lib.optional (cfg.package != null) cfg.package
++ lib.optional cfg.xwayland.enable pkgs.xwayland;
home.sessionVariables = {
CLUTTER_BACKEND = "wayland";
GDK_BACKEND = "wayland";
_JAVA_AWT_WM_NONREPARENTING = "1";
MOZ_ENABLE_WAYLAND = "1";
NIXOS_OZONE_WL = "1";
QT_QPA_PLATFORM = "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
XCURSOR_SIZE = toString config.home.pointerCursor.size or "24";
XDG_SESSION_TYPE = "wayland";
};
xdg.configFile."hypr/hyprland.conf" = {
text =
(lib.optionalString cfg.systemdIntegration ''
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;
onChange = let
hyprlandPackage =
if cfg.package == null
then defaultHyprlandPackage
else cfg.package;
in "HYPRLAND_INSTANCE_SIGNATURE=$(ls -w 1 /tmp/hypr | tail -1) ${hyprlandPackage}/bin/hyprctl reload config-only";
};
systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
Unit = {
Description = "hyprland compositor session";
Documentation = ["man:systemd.special(7)"];
BindsTo = ["graphical-session.target"];
Wants = ["graphical-session-pre.target"];
After = ["graphical-session-pre.target"];
};
};
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = ["graphical-session-pre.target"];
};
};
};
}

View File

@@ -8,6 +8,10 @@ self: {
with lib; let
cfg = config.programs.hyprland;
in {
imports = [
(mkRemovedOptionModule ["programs" "hyprland" "extraPackages"] "extraPackages has been removed. Use environment.systemPackages instead.")
];
options.programs.hyprland = {
enable = mkEnableOption ''
Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
@@ -18,7 +22,7 @@ in {
'';
package = mkOption {
type = types.package;
type = types.nullOr types.package;
default = self.packages.${pkgs.system}.default;
defaultText = literalExpression "<Hyprland flake>.packages.<system>.default";
example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }";
@@ -26,37 +30,34 @@ in {
Hyprland package to use.
'';
};
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [
kitty
wofi
swaybg
];
defaultText = literalExpression ''
with pkgs; [ kitty wofi swaybg ];
'';
example = literalExpression ''
with pkgs; [
alacritty wofi
]
'';
description = ''
Extra packages to be installed system wide.
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [cfg.package] ++ cfg.extraPackages;
security.polkit.enable = true;
hardware.opengl.enable = mkDefault true;
environment = {
systemPackages = lib.optional (cfg.package != null) cfg.package;
sessionVariables = {
CLUTTER_BACKEND = lib.mkDefault "wayland";
GDK_BACKEND = lib.mkDefault "wayland";
_JAVA_AWT_WM_NONREPARENTING = lib.mkDefault "1";
MOZ_ENABLE_WAYLAND = lib.mkDefault "1";
NIXOS_OZONE_WL = lib.mkDefault "1";
QT_QPA_PLATFORM = lib.mkDefault "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = lib.mkDefault "1";
XCURSOR_SIZE = lib.mkDefault "24";
XDG_SESSION_TYPE = lib.mkDefault "wayland";
};
};
fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true;
services.xserver.displayManager.sessionPackages = [cfg.package];
programs.xwayland.enable = mkDefault true;
xdg.portal.enable = mkDefault true;
xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-wlr];
hardware.opengl.enable = mkDefault true;
programs = {
dconf.enable = mkDefault true;
xwayland.enable = mkDefault true;
};
security.polkit.enable = true;
services.xserver.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
xdg.portal = {
enable = mkDefault true;
extraPortals = [pkgs.xdg-desktop-portal-wlr];
};
};
}

64
nix/wlroots.nix Normal file
View File

@@ -0,0 +1,64 @@
{
version,
src,
#
wlroots,
xwayland,
fetchpatch,
lib,
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 ""
);
}))
.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

@@ -14,6 +14,7 @@ wayland_scanner = find_program(
protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],
['ext-workspace-unstable-v1.xml'],
['pointer-constraints-unstable-v1.xml'],
['tablet-unstable-v2.xml'],

View File

@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_output_power_management_unstable_v1">
<copyright>
Copyright © 2019 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Control power management modes of outputs">
This protocol allows clients to control power management modes
of outputs that are currently part of the compositor space. The
intent is to allow special clients like desktop shells to power
down outputs when the system is idle.
To modify outputs not currently part of the compositor space see
wlr-output-management.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_output_power_manager_v1" version="1">
<description summary="manager to create per-output power management">
This interface is a manager that allows creating per-output power
management mode controls.
</description>
<request name="get_output_power">
<description summary="get a power management for an output">
Create a output power management mode control that can be used to
adjust the power management mode for a given output.
</description>
<arg name="id" type="new_id" interface="zwlr_output_power_v1"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>
<interface name="zwlr_output_power_v1" version="1">
<description summary="adjust power management mode for an output">
This object offers requests to set the power management mode of
an output.
</description>
<enum name="mode">
<entry name="off" value="0"
summary="Output is turned off."/>
<entry name="on" value="1"
summary="Output is turned on, no power saving"/>
</enum>
<enum name="error">
<entry name="invalid_mode" value="1" summary="inexistent power save mode"/>
</enum>
<request name="set_mode">
<description summary="Set an outputs power save mode">
Set an output's power save mode to the given mode. The mode change
is effective immediately. If the output does not support the given
mode a failed event is sent.
</description>
<arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/>
</request>
<event name="mode">
<description summary="Report a power management mode change">
Report the power management mode change of an output.
The mode event is sent after an output changed its power
management mode. The reason can be a client using set_mode or the
compositor deciding to change an output's mode.
This event is also sent immediately when the object is created
so the client is informed about the current power management mode.
</description>
<arg name="mode" type="uint" enum="mode"
summary="the output's new power management mode"/>
</event>
<event name="failed">
<description summary="object no longer valid">
This event indicates that the output power management mode control
is no longer valid. This can happen for a number of reasons,
including:
- The output doesn't support power management
- Another client already has exclusive power management mode control
for this output
- The output disappeared
Upon receiving this event, the client should destroy this object.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy this power management">
Destroys the output power management mode control object.
</description>
</request>
</interface>
</protocol>

View File

@@ -1,8 +1,23 @@
#include "Compositor.hpp"
#include "helpers/Splashes.hpp"
#include <random>
#include "debug/HyprCtl.hpp"
int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal %d", signo);
if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL) {
g_pCompositor->cleanup();
}
return 0; // everything went fine
}
CCompositor::CCompositor() {
wlr_log_init(WLR_INFO, NULL);
m_iHyprlandPID = getpid();
m_szInstanceSignature = GIT_COMMIT_HASH + std::string("_") + std::to_string(time(NULL));
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);
@@ -14,6 +29,8 @@ CCompositor::CCompositor() {
Debug::log(LOG, "Instance Signature: %s", m_szInstanceSignature.c_str());
Debug::log(LOG, "Hyprland PID: %i", m_iHyprlandPID);
Debug::log(LOG, "===== SYSTEM INFO: =====");
logSystemInfo();
@@ -30,6 +47,12 @@ CCompositor::CCompositor() {
m_sWLDisplay = wl_display_create();
m_sWLEventLoop = wl_display_get_event_loop(m_sWLDisplay);
// register crit signal handler
wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr);
//wl_event_loop_add_signal(m_sWLEventLoop, SIGINT, handleCritSignal, nullptr);
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay);
if (!m_sWLRBackend) {
@@ -70,7 +93,6 @@ CCompositor::CCompositor() {
m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay);
m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay);
m_sWLRDmabuf = wlr_linux_dmabuf_v1_create(m_sWLDisplay, m_sWLRRenderer);
wlr_export_dmabuf_manager_v1_create(m_sWLDisplay);
wlr_screencopy_manager_v1_create(m_sWLDisplay);
wlr_data_control_manager_v1_create(m_sWLDisplay);
@@ -80,10 +102,12 @@ CCompositor::CCompositor() {
m_sWLROutputLayout = wlr_output_layout_create();
m_sWLROutputPowerMgr = wlr_output_power_manager_v1_create(m_sWLDisplay);
m_sWLRScene = wlr_scene_create();
wlr_scene_attach_output_layout(m_sWLRScene, m_sWLROutputLayout);
m_sWLRXDGShell = wlr_xdg_shell_create(m_sWLDisplay, 3);
m_sWLRXDGShell = wlr_xdg_shell_create(m_sWLDisplay, 4);
m_sWLRCursor = wlr_cursor_create();
wlr_cursor_attach_output_layout(m_sWLRCursor, m_sWLROutputLayout);
@@ -121,6 +145,12 @@ CCompositor::CCompositor() {
m_sWLRToplevelMgr = wlr_foreign_toplevel_manager_v1_create(m_sWLDisplay);
m_sWRLDRMLeaseMgr = wlr_drm_lease_v1_manager_create(m_sWLDisplay, m_sWLRBackend);
if (!m_sWRLDRMLeaseMgr) {
Debug::log(INFO, "Failed to create wlr_drm_lease_v1_manager");
Debug::log(INFO, "VR will not be available");
}
m_sWLRTabletManager = wlr_tablet_v2_create(m_sWLDisplay);
m_sWLRForeignRegistry = wlr_xdg_foreign_registry_create(m_sWLDisplay);
@@ -131,15 +161,16 @@ CCompositor::CCompositor() {
wlr_xdg_foreign_v2_create(m_sWLDisplay, m_sWLRForeignRegistry);
m_sWLRPointerGestures = wlr_pointer_gestures_v1_create(m_sWLDisplay);
m_sWLRSession = wlr_backend_get_session(m_sWLRBackend);
m_sWLRTextInputMgr = wlr_text_input_manager_v3_create(m_sWLDisplay);
m_sWLRIMEMgr = wlr_input_method_manager_v2_create(m_sWLDisplay);
}
CCompositor::~CCompositor() {
cleanupExit();
}
void handleCritSignal(int signo) {
g_pCompositor->cleanupExit();
exit(signo);
cleanup();
}
void CCompositor::setRandomSplash() {
@@ -161,11 +192,19 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLRCursor->events.swipe_begin, &Events::listen_swipeBegin, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.swipe_update, &Events::listen_swipeUpdate, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.swipe_end, &Events::listen_swipeEnd, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.pinch_begin, &Events::listen_pinchBegin, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.pinch_update, &Events::listen_pinchUpdate, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.pinch_end, &Events::listen_pinchEnd, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.touch_down, &Events::listen_touchBegin, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.touch_up, &Events::listen_touchEnd, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRCursor->events.touch_motion, &Events::listen_touchUpdate, m_sWLRCursor, "WLRCursor");
addWLSignal(&m_sWLRBackend->events.new_input, &Events::listen_newInput, m_sWLRBackend, "Backend");
addWLSignal(&m_sSeat.seat->events.request_set_cursor, &Events::listen_requestMouse, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.request_set_selection, &Events::listen_requestSetSel, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.request_start_drag, &Events::listen_requestDrag, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.start_drag, &Events::listen_startDrag, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.request_set_selection, &Events::listen_requestSetSel, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.request_set_primary_selection, &Events::listen_requestSetPrimarySel, &m_sSeat, "Seat");
addWLSignal(&m_sWLRLayerShell->events.new_surface, &Events::listen_newLayerSurface, m_sWLRLayerShell, "LayerShell");
addWLSignal(&m_sWLROutputLayout->events.change, &Events::listen_change, m_sWLROutputLayout, "OutputLayout");
addWLSignal(&m_sWLROutputMgr->events.apply, &Events::listen_outputMgrApply, m_sWLROutputMgr, "OutputMgr");
@@ -175,32 +214,60 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints");
addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr");
addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr");
addWLSignal(&m_sWLRVKeyboardMgr->events.new_virtual_keyboard, &Events::listen_newVirtualKeyboard, m_sWLRVKeyboardMgr, "VKeyboardMgr");
addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer");
addWLSignal(&m_sWLRIdleInhibitMgr->events.new_inhibitor, &Events::listen_newIdleInhibitor, m_sWLRIdleInhibitMgr, "WLRIdleInhibitMgr");
addWLSignal(&m_sWLROutputPowerMgr->events.set_mode, &Events::listen_powerMgrSetMode, m_sWLROutputPowerMgr, "PowerMgr");
addWLSignal(&m_sWLRIMEMgr->events.input_method, &Events::listen_newIME, m_sWLRIMEMgr, "IMEMgr");
addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr");
signal(SIGINT, handleCritSignal);
signal(SIGTERM, handleCritSignal);
if(m_sWRLDRMLeaseMgr)
addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM");
if (m_sWLRSession)
addWLSignal(&m_sWLRSession->events.active, &Events::listen_sessionActive, m_sWLRSession, "Session");
}
void CCompositor::cleanupExit() {
if (!m_sWLDisplay)
void CCompositor::cleanup() {
if (!m_sWLDisplay || m_bIsShuttingDown)
return;
m_pLastFocus = nullptr;
m_pLastWindow = nullptr;
// accumulate all PIDs for killing, also request closing.
for (auto& w : m_vWindows) {
if (w->m_bIsMapped || !w->m_bIsX11)
m_dProcessPIDsOnShutdown.push_back(w->getPID());
closeWindow(w.get());
}
// end threads
g_pEventManager->m_tThread = std::thread();
HyprCtl::tThread = std::thread();
m_vWorkspaces.clear();
m_vWindows.clear();
for (auto& m : m_vMonitors) {
g_pHyprOpenGL->destroyMonitorResources(m.get());
wlr_output_enable(m->output, false);
wlr_output_commit(m->output);
}
if (g_pXWaylandManager->m_sWLRXWayland) {
wlr_xwayland_destroy(g_pXWaylandManager->m_sWLRXWayland);
g_pXWaylandManager->m_sWLRXWayland = nullptr;
}
wl_display_destroy_clients(m_sWLDisplay);
wl_display_destroy(m_sWLDisplay);
wl_display_terminate(m_sWLDisplay);
m_sWLDisplay = nullptr;
m_bIsShuttingDown = true;
g_pKeybindManager->spawn("sleep 5 && kill -9 " + std::to_string(m_iHyprlandPID)); // this is to prevent that random "freezing"
// the PID should not be reused.
}
void CCompositor::startCompositor() {
@@ -216,6 +283,9 @@ void CCompositor::startCompositor() {
Debug::log(LOG, "Creating the AnimationManager!");
g_pAnimationManager = std::make_unique<CAnimationManager>();
Debug::log(LOG, "Creating the LayoutManager!");
g_pLayoutManager = std::make_unique<CLayoutManager>();
Debug::log(LOG, "Creating the ConfigManager!");
g_pConfigManager = std::make_unique<CConfigManager>();
@@ -234,9 +304,6 @@ void CCompositor::startCompositor() {
Debug::log(LOG, "Creating the XWaylandManager!");
g_pXWaylandManager = std::make_unique<CHyprXWaylandManager>();
Debug::log(LOG, "Creating the LayoutManager!");
g_pLayoutManager = std::make_unique<CLayoutManager>();
Debug::log(LOG, "Creating the EventManager!");
g_pEventManager = std::make_unique<CEventManager>();
g_pEventManager->startThread();
@@ -246,17 +313,13 @@ void CCompositor::startCompositor() {
//
//
// firefox wont detect wl
setenv("MOZ_ENABLE_WAYLAND", "1", 1);
setenv("XDG_CURRENT_DESKTOP", "Hyprland", 1);
initAllSignals();
// Set some env vars so that Firefox is automatically in Wayland mode
// and QT apps too
// electron needs -- flags so we can't really set them here
setenv("QT_QPA_PLATFORM", "wayland", true);
setenv("MOZ_ENABLE_WAYLAND", "1", true);
// Set XDG_CURRENT_DESKTOP to our compositor's name
setenv("XDG_CURRENT_DESKTOP", "hyprland", true);
m_szWLDisplaySocket = wl_display_add_socket_auto(m_sWLDisplay);
if (!m_szWLDisplaySocket) {
@@ -285,7 +348,7 @@ void CCompositor::startCompositor() {
wl_display_run(m_sWLDisplay);
}
SMonitor* CCompositor::getMonitorFromID(const int& id) {
CMonitor* CCompositor::getMonitorFromID(const int& id) {
for (auto& m : m_vMonitors) {
if (m->ID == (uint64_t)id) {
return m.get();
@@ -295,7 +358,7 @@ SMonitor* CCompositor::getMonitorFromID(const int& id) {
return nullptr;
}
SMonitor* CCompositor::getMonitorFromName(const std::string& name) {
CMonitor* CCompositor::getMonitorFromName(const std::string& name) {
for (auto& m : m_vMonitors) {
if (m->szName == name) {
return m.get();
@@ -305,18 +368,18 @@ SMonitor* CCompositor::getMonitorFromName(const std::string& name) {
return nullptr;
}
SMonitor* CCompositor::getMonitorFromCursor() {
CMonitor* CCompositor::getMonitorFromCursor() {
const auto COORDS = Vector2D(m_sWLRCursor->x, m_sWLRCursor->y);
return getMonitorFromVector(COORDS);
}
SMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
const auto OUTPUT = wlr_output_layout_output_at(m_sWLROutputLayout, point.x, point.y);
if (!OUTPUT) {
float bestDistance = 0.f;
SMonitor* pBestMon = nullptr;
CMonitor* pBestMon = nullptr;
for (auto& m : m_vMonitors) {
float dist = vecToRectDistanceSquared(point, m->vecPosition, m->vecPosition + m->vecSize);
@@ -443,13 +506,13 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
if (PMONITOR->specialWorkspaceOpen) {
for (auto w = m_vWindows.rbegin(); w != 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};
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !(*w)->m_bHidden && (*w)->m_iX11Type != 2)
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !(*w)->m_bHidden && !(*w)->m_bX11ShouldntFocus)
return (*w).get();
}
for (auto& w : m_vWindows) {
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (!w->m_bIsFloating && w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->m_bHidden && w->m_iX11Type != 2)
if (!w->m_bIsFloating && w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->m_bHidden && !w->m_bX11ShouldntFocus)
return w.get();
}
}
@@ -457,7 +520,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
for (auto w = m_vWindows.rbegin(); w != 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};
if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden && (*w)->m_iX11Type != 2) {
if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden && !(*w)->m_bX11ShouldntFocus) {
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y))
return w->get();
@@ -475,7 +538,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
// for windows, we need to check their extensions too, first.
for (auto& w : m_vWindows) {
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bHidden && w->m_iX11Type != 2) {
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bHidden && !w->m_bX11ShouldntFocus) {
wlr_surface* resultSurf = nullptr;
Vector2D origin = w->m_vRealPosition.vec();
SExtensionFindingData data = {origin, pos, &resultSurf};
@@ -487,7 +550,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
}
for (auto& w : m_vWindows) {
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (!w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bHidden && w->m_iX11Type != 2)
if (!w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bHidden && !w->m_bX11ShouldntFocus)
return w.get();
}
@@ -569,7 +632,7 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
return PSURFACE->surface;
}
SMonitor* CCompositor::getMonitorFromOutput(wlr_output* out) {
CMonitor* CCompositor::getMonitorFromOutput(wlr_output* out) {
for (auto& m : m_vMonitors) {
if (m->output == out) {
return m.get();
@@ -587,7 +650,21 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
}
if (!pWindow || !windowValidMapped(pWindow)) {
const auto PLASTWINDOW = m_pLastWindow;
m_pLastWindow = nullptr;
if (windowValidMapped(PLASTWINDOW)) {
updateWindowAnimatedDecorationValues(PLASTWINDOW);
if (PLASTWINDOW->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_activated(PLASTWINDOW->m_phForeignToplevel, false);
}
wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat);
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","});
m_pLastFocus = nullptr;
return;
}
@@ -599,6 +676,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
if (m_pLastWindow == pWindow && m_sSeat.seat->keyboard_state.focused_surface == pSurface)
return;
if (!isWorkspaceVisible(pWindow->m_iWorkspaceID))
g_pKeybindManager->changeworkspace("[internal]" + std::to_string(pWindow->m_iWorkspaceID));
const auto PLASTWINDOW = m_pLastWindow;
m_pLastWindow = pWindow;
@@ -630,7 +710,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
updateWindowAnimatedDecorationValues(pWindow);
// Send an event
g_pEventManager->postEvent(SHyprIPCEvent("activewindow", g_pXWaylandManager->getAppIDClass(pWindow) + "," + pWindow->m_szTitle));
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", g_pXWaylandManager->getAppIDClass(pWindow) + "," + pWindow->m_szTitle});
if (pWindow->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_activated(pWindow->m_phForeignToplevel, true);
@@ -647,7 +727,8 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
if (!pSurface) {
wlr_seat_keyboard_clear_focus(m_sSeat.seat);
g_pEventManager->postEvent(SHyprIPCEvent("activewindow", ",")); // unfocused
g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","}); // unfocused
g_pInputManager->m_sIMERelay.onKeyboardFocus(nullptr);
return;
}
@@ -659,12 +740,14 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
wlr_seat_keyboard_notify_enter(m_sSeat.seat, pSurface, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers);
g_pInputManager->m_sIMERelay.onKeyboardFocus(pSurface);
wlr_seat_keyboard_focus_change_event event = {
.seat = m_sSeat.seat,
.old_surface = m_pLastFocus,
.new_surface = pSurface,
};
wlr_signal_emit_safe(&m_sSeat.seat->keyboard_state.events.focus_change, &event);
wl_signal_emit_mutable(&m_sSeat.seat->keyboard_state.events.focus_change, &event);
if (pWindowOwner)
Debug::log(LOG, "Set keyboard focus to surface %x, with window name: %s", pSurface, pWindowOwner->m_szTitle.c_str());
@@ -700,7 +783,7 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
return nullptr;
}
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::list<SLayerSurface*>* layerSurfaces, Vector2D* sCoords, SLayerSurface** ppLayerSurfaceFound) {
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords, SLayerSurface** ppLayerSurfaceFound) {
for (auto it = layerSurfaces->rbegin(); it != layerSurfaces->rend(); it++) {
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped))
continue;
@@ -708,7 +791,7 @@ wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::list<SL
const auto SURFACEAT = wlr_layer_surface_v1_surface_at((*it)->layerSurface, pos.x - (*it)->geometry.x, pos.y - (*it)->geometry.y, &sCoords->x, &sCoords->y);
if (SURFACEAT) {
*ppLayerSurfaceFound = *it;
*ppLayerSurfaceFound = it->get();
return SURFACEAT;
}
}
@@ -795,35 +878,13 @@ int CCompositor::getWindowsOnWorkspace(const int& id) {
CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == id)
if (w->m_iWorkspaceID == id && w->m_bIsMapped && !w->m_bHidden)
return w.get();
}
return nullptr;
}
void CCompositor::fixXWaylandWindowsOnWorkspace(const int& id) {
const auto ISVISIBLE = isWorkspaceVisible(id);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
if (!PWORKSPACE)
return;
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == id) {
// moveXWaylandWindow only moves XWayland windows
// so there is no need to check here
// if the window is XWayland or not.
if (ISVISIBLE && (!PWORKSPACE->m_bHasFullscreenWindow || w->m_bIsFullscreen))
g_pXWaylandManager->moveXWaylandWindow(w.get(), w->m_vRealPosition.vec());
else
g_pXWaylandManager->moveXWaylandWindow(w.get(), Vector2D(42069,42069));
}
}
}
bool CCompositor::doesSeatAcceptInput(wlr_surface* surface) {
return !m_sSeat.exclusiveClient || (surface && m_sSeat.exclusiveClient == wl_resource_get_client(surface->resource));
}
@@ -844,17 +905,43 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
if (!windowValidMapped(pWindow))
return;
for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
if (it->get() == pWindow) {
std::rotate(it, it + 1, m_vWindows.end());
break;
auto moveToTop = [&](CWindow* pw) -> void {
for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
if (it->get() == pw) {
std::rotate(it, it + 1, m_vWindows.end());
break;
}
}
};
moveToTop(pWindow);
if (!pWindow->m_bIsX11)
return;
// move all children
std::deque<CWindow*> toMove;
for (auto& w : m_vWindows) {
if (w->m_bIsMapped && w->m_bMappedX11 && !w->m_bHidden && w->m_bIsX11 && w->X11TransientFor() == pWindow) {
toMove.emplace_back(w.get());
}
}
for (auto& pw : toMove) {
moveToTop(pw);
moveWindowToTop(pw);
}
}
void CCompositor::cleanupFadingOut() {
void CCompositor::cleanupFadingOut(const int& monid) {
for (auto& w : m_vWindowsFadingOut) {
if (w->m_iMonitorID != (long unsigned int)monid)
continue;
bool valid = windowExists(w);
if (!valid || !w->m_bFadingOut || w->m_fAlpha.fl() == 0.f) {
@@ -867,31 +954,88 @@ void CCompositor::cleanupFadingOut() {
m_vWindowsFadingOut.erase(std::remove(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), w));
Debug::log(LOG, "Cleanup: destroyed a window");
glFlush(); // to free mem NOW.
return;
}
}
for (auto& ls : m_vSurfacesFadingOut) {
// sometimes somehow fucking happens wtf
bool exists = false;
for (auto& m : m_vMonitors) {
for (auto& lsl : m->m_aLayerSurfaceLists) {
for (auto& lsp : lsl) {
if (lsp.get() == ls) {
exists = true;
break;
}
}
if (exists)
break;
}
if (exists)
break;
}
if (!exists) {
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
Debug::log(LOG, "Fading out a non-existent LS??");
return;
}
if (ls->monitorID != monid)
continue;
// mark blur for recalc
if (ls->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || ls->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(getMonitorFromID(monid));
if (ls->fadingOut && ls->readyToDelete && !ls->alpha.isBeingAnimated()) {
g_pHyprOpenGL->m_mLayerFramebuffers[ls].release();
g_pHyprOpenGL->m_mLayerFramebuffers.erase(ls);
for (auto& m : m_vMonitors) {
for (auto& lsl : m->m_aLayerSurfaceLists) {
lsl.remove(ls);
if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end()) {
lsl.erase(std::remove_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }));
}
}
}
g_pHyprOpenGL->m_mLayerFramebuffers[ls].release();
g_pHyprOpenGL->m_mLayerFramebuffers.erase(ls);
delete ls;
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
Debug::log(LOG, "Cleanup: destroyed a layersurface");
glFlush(); // to free mem NOW.
return;
}
}
}
void CCompositor::addToFadingOutSafe(SLayerSurface* pLS) {
const auto FOUND = std::find_if(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), [&](SLayerSurface* other) { return other == pLS; });
if (FOUND != m_vSurfacesFadingOut.end())
return; // if it's already added, don't add it.
m_vSurfacesFadingOut.emplace_back(pLS);
}
void CCompositor::addToFadingOutSafe(CWindow* pWindow) {
const auto FOUND = std::find_if(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), [&](CWindow* other) { return other == pWindow; });
if (FOUND != m_vWindowsFadingOut.end())
return; // if it's already added, don't add it.
m_vWindowsFadingOut.emplace_back(pWindow);
}
CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto WINDOWIDEALBB = pWindow->getWindowIdealBoundingBoxIgnoreReserved();
@@ -1073,12 +1217,12 @@ CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) {
return nullptr;
}
SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
const auto POSA = m_pLastMonitor->vecPosition;
const auto SIZEA = m_pLastMonitor->vecSize;
auto longestIntersect = -1;
SMonitor* longestIntersectMonitor = nullptr;
CMonitor* longestIntersectMonitor = nullptr;
for (auto& m : m_vMonitors) {
if (m.get() == m_pLastMonitor)
@@ -1150,7 +1294,9 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
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 PFULLSCREENALPHA = &g_pConfigManager->getConfigValuePtr("decoration:fullscreen_opacity")->floatValue;
static auto *const PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
static auto *const PSHADOWCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow_inactive")->intValue;
static auto *const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
// border
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);
@@ -1168,28 +1314,39 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
else {
if (pWindow == m_pLastWindow)
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha != -1 ? pWindow->m_sSpecialRenderData.alpha : *PACTIVEALPHA;
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
else
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive : *PINACTIVEALPHA;
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA : *PINACTIVEALPHA;
}
} else {
if (pWindow == m_pLastWindow)
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha != -1 ? pWindow->m_sSpecialRenderData.alpha : *PACTIVEALPHA;
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
else
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive : *PINACTIVEALPHA;
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA : *PINACTIVEALPHA;
}
}
void CCompositor::moveWindowToWorkspace(CWindow* pWindow, const std::string& work) {
m_pLastWindow = pWindow;
g_pKeybindManager->moveActiveToWorkspace(work);
// dim
if (pWindow == m_pLastWindow) {
pWindow->m_fDimPercent = 0;
} else {
pWindow->m_fDimPercent = *PDIMSTRENGTH;
}
g_pInputManager->refocus();
// shadow
if (pWindow->m_iX11Type != 2 && !pWindow->m_bX11DoesntWantBorders) {
if (pWindow == m_pLastWindow) {
pWindow->m_cRealShadowColor = CColor(*PSHADOWCOL);
} else {
pWindow->m_cRealShadowColor = CColor(*PSHADOWCOLINACTIVE != INT_MAX ? *PSHADOWCOLINACTIVE : *PSHADOWCOL);
}
} else {
pWindow->m_cRealShadowColor.setValueAndWarp(CColor(0, 0, 0, 0)); // no shadow
}
}
int CCompositor::getNextAvailableMonitorID() {
int64_t topID = -1;
for (auto& m : m_vMonitors) {
for (auto& m : m_vRealMonitors) {
if ((int64_t)m->ID > topID)
topID = m->ID;
}
@@ -1197,7 +1354,101 @@ int CCompositor::getNextAvailableMonitorID() {
return topID + 1;
}
void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMonitor) {
void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) {
const auto PWORKSPACEA = g_pCompositor->getWorkspaceByID(pMonitorA->activeWorkspace);
const auto PWORKSPACEB = g_pCompositor->getWorkspaceByID(pMonitorB->activeWorkspace);
PWORKSPACEA->m_iMonitorID = pMonitorB->ID;
PWORKSPACEA->moveToMonitor(pMonitorB->ID);
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEA->m_iID) {
w->m_iMonitorID = pMonitorB->ID;
// additionally, move floating and fs windows manually
if (w->m_bIsFloating)
w->m_vRealPosition = w->m_vRealPosition.vec() - pMonitorA->vecPosition + pMonitorB->vecPosition;
if (w->m_bIsFullscreen) {
w->m_vRealPosition = pMonitorB->vecPosition;
w->m_vRealSize = pMonitorB->vecSize;
}
w->updateToplevel();
}
}
PWORKSPACEB->m_iMonitorID = pMonitorA->ID;
PWORKSPACEB->moveToMonitor(pMonitorA->ID);
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == PWORKSPACEB->m_iID) {
w->m_iMonitorID = pMonitorA->ID;
// additionally, move floating and fs windows manually
if (w->m_bIsFloating)
w->m_vRealPosition = w->m_vRealPosition.vec() - pMonitorB->vecPosition + pMonitorA->vecPosition;
if (w->m_bIsFullscreen) {
w->m_vRealPosition = pMonitorA->vecPosition;
w->m_vRealSize = pMonitorA->vecSize;
}
w->updateToplevel();
}
}
pMonitorA->activeWorkspace = PWORKSPACEB->m_iID;
pMonitorB->activeWorkspace = PWORKSPACEA->m_iID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorA->ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pMonitorB->ID);
g_pInputManager->refocus();
// event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEA->m_szName + "," + pMonitorB->szName});
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEB->m_szName + "," + pMonitorA->szName});
}
CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
if (isNumber(name)) {
// change by ID
int monID = -1;
try {
monID = std::stoi(name);
} catch (std::exception& e) {
// shouldn't happen but jic
Debug::log(ERR, "Error in getMonitorFromString: invalid num");
return nullptr;
}
if (monID > -1 && monID < (int)g_pCompositor->m_vMonitors.size()) {
return g_pCompositor->getMonitorFromID(monID);
} else {
Debug::log(ERR, "Error in getMonitorFromString: invalid arg 1");
return nullptr;
}
} else {
if (isDirection(name)) {
const auto PMONITOR = g_pCompositor->getMonitorInDirection(name[0]);
return PMONITOR;
} else {
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->szName == name) {
return m.get();
}
}
}
Debug::log(ERR, "Error in getMonitorFromString: no such monitor");
}
return nullptr;
}
void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMonitor) {
// We trust the workspace and monitor to be correct.
@@ -1239,8 +1490,22 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMoni
pWorkspace->moveToMonitor(pMonitor->ID);
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID)
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
w->m_iMonitorID = pMonitor->ID;
// additionally, move floating and fs windows manually
if (w->m_bIsMapped && !w->m_bHidden) {
if (w->m_bIsFloating)
w->m_vRealPosition = w->m_vRealPosition.vec() - POLDMON->vecPosition + pMonitor->vecPosition;
if (w->m_bIsFullscreen) {
w->m_vRealPosition = pMonitor->vecPosition;
w->m_vRealSize = pMonitor->vecSize;
}
}
w->updateToplevel();
}
}
if (SWITCHINGISACTIVE) { // if it was active, preserve its' status. If it wasn't, don't.
@@ -1261,6 +1526,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMoni
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
g_pInputManager->refocus();
// event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", pWorkspace->m_szName + "," + pMonitor->szName});
}
bool CCompositor::workspaceIDOutOfBounds(const int& id) {
@@ -1282,14 +1550,21 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode
if (!windowValidMapped(pWindow))
return;
focusWindow(pWindow);
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(pWindow, mode, on);
g_pXWaylandManager->setWindowFullscreen(pWindow, pWindow->m_bIsFullscreen && mode == FULLSCREEN_FULL);
// make all windows on the same workspace under the fullscreen window
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID)
w->m_bCreatedOverFullscreen = false;
}
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv(), true);
forceReportSizesToWindowsOnWorkspace(pWindow->m_iWorkspaceID);
}
void CCompositor::moveUnmanagedX11ToWindows(CWindow* pWindow) {
@@ -1325,3 +1600,191 @@ void CCompositor::updateWorkspaceWindowDecos(const int& id) {
w->updateWindowDecos();
}
}
void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) {
if ((m_sWLRSession && !m_sWLRSession->active) || !m_bSessionActive)
return;
wlr_output_schedule_frame(pMonitor->output);
}
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
eFocusWindowMode mode = MODE_CLASS_REGEX;
std::regex regexCheck(regexp);
std::string matchCheck;
if (regexp.find("title:") == 0) {
mode = MODE_TITLE_REGEX;
regexCheck = std::regex(regexp.substr(6));
} else if (regexp.find("address:") == 0) {
mode = MODE_ADDRESS;
matchCheck = regexp.substr(8);
} else if (regexp.find("pid:") == 0) {
mode = MODE_PID;
matchCheck = regexp.substr(4);
}
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bHidden)
continue;
switch (mode) {
case MODE_CLASS_REGEX: {
const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
if (!std::regex_search(g_pXWaylandManager->getAppIDClass(w.get()), regexCheck))
continue;
break;
}
case MODE_TITLE_REGEX: {
const auto windowTitle = g_pXWaylandManager->getTitle(w.get());
if (!std::regex_search(windowTitle, regexCheck))
continue;
break;
}
case MODE_ADDRESS: {
std::string addr = getFormat("0x%x", w.get());
if (matchCheck != addr)
continue;
break;
}
case MODE_PID: {
std::string pid = getFormat("%d", w->getPID());
if (matchCheck != pid)
continue;
break;
}
default:
break;
}
return w.get();
}
return nullptr;
}
wl_event_source* hyprCtlTickSource = nullptr;
int hyprCtlTick(void* data) {
HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit
wl_event_source_timer_update(hyprCtlTickSource, 16); // tick it 60/s, should be enough.
return 0;
}
void CCompositor::startHyprCtlTick() {
if (hyprCtlTickSource)
return;
hyprCtlTickSource = wl_event_loop_add_timer(m_sWLEventLoop, hyprCtlTick, nullptr);
wl_event_source_timer_update(hyprCtlTickSource, 16);
}
void CCompositor::warpCursorTo(const Vector2D& pos) {
// warpCursorTo should only be used for warps that
// should be disabled with no_cursor_warps
static auto *const PNOWARPS = &g_pConfigManager->getConfigValuePtr("general:no_cursor_warps")->intValue;
if (*PNOWARPS)
return;
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pos.x, pos.y);
const auto PMONITORNEW = getMonitorFromVector(pos);
if (PMONITORNEW != m_pLastMonitor)
m_pLastMonitor = PMONITORNEW;
}
SLayerSurface* CCompositor::getLayerSurfaceFromWlr(wlr_layer_surface_v1* pLS) {
for (auto& m : m_vMonitors) {
for (auto& lsl : m->m_aLayerSurfaceLists) {
for (auto& ls : lsl) {
if (ls->layerSurface == pLS)
return ls.get();
}
}
}
return nullptr;
}
void CCompositor::closeWindow(CWindow* pWindow) {
if (pWindow && windowValidMapped(pWindow)) {
g_pXWaylandManager->sendCloseWindow(pWindow);
}
}
SLayerSurface* CCompositor::getLayerSurfaceFromSurface(wlr_surface* pSurface) {
for (auto& m : m_vMonitors) {
for (auto& lsl : m->m_aLayerSurfaceLists) {
for (auto& ls : lsl) {
if (ls->layerSurface && ls->layerSurface->surface == pSurface)
return ls.get();
}
}
}
return nullptr;
}
// returns a delta
Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, const Vector2D& relativeTo) {
if (!args.contains(' '))
return relativeTo;
std::string x = args.substr(0, args.find_first_of(' '));
std::string y = args.substr(args.find_first_of(' ') + 1);
if (x == "exact") {
std::string newX = y.substr(0, y.find_first_of(' '));
std::string newY = y.substr(y.find_first_of(' ') + 1);
if (!isNumber(newX) || !isNumber(newY)) {
Debug::log(ERR, "parseWindowVectorArgsRelative: exact args not numbers");
return relativeTo;
}
const int X = std::stoi(newX);
const int Y = std::stoi(newY);
if (X < 0 || Y < 0) {
Debug::log(ERR, "parseWindowVectorArgsRelative: exact args cannot be < 0");
return relativeTo;
}
return Vector2D(X, Y);
}
if (!isNumber(x) || !isNumber(y)) {
Debug::log(ERR, "parseWindowVectorArgsRelative: args not numbers");
return relativeTo;
}
const int X = std::stoi(x);
const int Y = std::stoi(y);
return Vector2D(X + relativeTo.x, Y + relativeTo.y);
}
void CCompositor::forceReportSizesToWindowsOnWorkspace(const int& wid) {
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID == wid && w->m_bIsMapped && !w->m_bHidden) {
g_pXWaylandManager->setWindowSize(w.get(), w->m_vRealSize.vec(), true);
}
}
}
bool CCompositor::cursorOnReservedArea() {
const auto PMONITOR = getMonitorFromCursor();
const auto XY1 = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
const auto XY2 = PMONITOR->vecPosition + PMONITOR->vecSize - PMONITOR->vecReservedBottomRight;
const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal();
return !VECINRECT(CURSORPOS, XY1.x, XY1.y, XY2.x, XY2.y);
}

View File

@@ -30,12 +30,16 @@ public:
// ------------------ WLR BASICS ------------------ //
wl_display* m_sWLDisplay;
wl_event_loop* m_sWLEventLoop;
wlr_backend* m_sWLRBackend;
wlr_session* m_sWLRSession;
wlr_renderer* m_sWLRRenderer;
wlr_allocator* m_sWLRAllocator;
wlr_compositor* m_sWLRCompositor;
wlr_subcompositor* m_sWLRSubCompositor;
wlr_data_device_manager* m_sWLRDataDevMgr;
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout;
wlr_idle* m_sWLRIdle;
@@ -52,7 +56,6 @@ public:
wlr_egl* m_sWLREGL;
int m_iDRMFD;
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
wlr_linux_dmabuf_v1* m_sWLRDmabuf;
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
@@ -63,6 +66,9 @@ public:
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
wlr_input_method_manager_v2* m_sWLRIMEMgr;
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
// ------------------------------------------------- //
@@ -70,7 +76,8 @@ public:
std::string m_szInstanceSignature = "";
std::string m_szCurrentSplash = "error";
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
std::vector<std::unique_ptr<CWindow>> m_vWindows;
std::deque<std::unique_ptr<CWindow>> m_dUnmanagedX11Windows;
std::vector<std::unique_ptr<SXDGPopup>> m_vXDGPopups;
@@ -80,22 +87,27 @@ public:
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
void startCompositor();
void cleanupExit();
void cleanup();
wlr_surface* m_pLastFocus = nullptr;
CWindow* m_pLastWindow = nullptr;
SMonitor* m_pLastMonitor = nullptr;
CMonitor* m_pLastMonitor = nullptr;
SSeat m_sSeat;
bool m_bReadyToProcess = false;
bool m_bSessionActive = true;
bool m_bDPMSStateON = true;
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
// ------------------------------------------------- //
SMonitor* getMonitorFromID(const int&);
SMonitor* getMonitorFromName(const std::string&);
SMonitor* getMonitorFromCursor();
SMonitor* getMonitorFromVector(const Vector2D&);
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(CWindow*);
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
@@ -104,11 +116,11 @@ public:
CWindow* vectorToWindow(const Vector2D&);
CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
CWindow* vectorToWindowTiled(const Vector2D&);
wlr_surface* vectorToLayerSurface(const Vector2D&, std::list<SLayerSurface*>*, Vector2D*, SLayerSurface**);
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
CWindow* windowFromCursor();
CWindow* windowFloatingFromCursor();
SMonitor* getMonitorFromOutput(wlr_output*);
CMonitor* getMonitorFromOutput(wlr_output*);
CWindow* getWindowForPopup(wlr_xdg_popup*);
CWindow* getWindowFromSurface(wlr_surface*);
bool isWorkspaceVisible(const int&);
@@ -119,12 +131,11 @@ public:
void updateWorkspaceWindowDecos(const int&);
int getWindowsOnWorkspace(const int&);
CWindow* getFirstWindowOnWorkspace(const int&);
void fixXWaylandWindowsOnWorkspace(const int&);
CWindow* getFullscreenWindowOnWorkspace(const int&);
bool doesSeatAcceptInput(wlr_surface*);
bool isWindowActive(CWindow*);
void moveWindowToTop(CWindow*);
void cleanupFadingOut();
void cleanupFadingOut(const int& monid);
CWindow* getWindowInDirection(CWindow*, char);
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
CWindow* getNextWindowOnWorkspace(CWindow*);
@@ -132,20 +143,39 @@ public:
int getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&);
CWindow* getConstraintWindow(SMouse*);
SMonitor* getMonitorInDirection(const char&);
CMonitor* getMonitorInDirection(const char&);
void updateAllWindowsAnimatedDecorationValues();
void updateWindowAnimatedDecorationValues(CWindow*);
void moveWindowToWorkspace(CWindow*, const std::string&);
int getNextAvailableMonitorID();
void moveWorkspaceToMonitor(CWorkspace*, SMonitor*);
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void moveUnmanagedX11ToWindows(CWindow*);
CWindow* getX11Parent(CWindow*);
void scheduleFrameForMonitor(CMonitor*);
void addToFadingOutSafe(SLayerSurface*);
void addToFadingOutSafe(CWindow*);
CWindow* getWindowByRegex(const std::string&);
void warpCursorTo(const Vector2D&);
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
void closeWindow(CWindow*);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&);
bool cursorOnReservedArea();
std::string explicitConfigPath;
void startHyprCtlTick();
private:
void initAllSignals();
void setRandomSplash();
void setRandomSplash();
uint64_t m_iHyprlandPID = 0;
};

View File

@@ -3,11 +3,13 @@
#include "render/decorations/CHyprDropShadowDecoration.hpp"
CWindow::CWindow() {
m_vRealPosition.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:windows_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:windows")->intValue, &g_pConfigManager->getConfigValuePtr("animations:windows_curve")->strValue, (void*) this, AVARDAMAGE_ENTIRE);
m_vRealSize.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:windows_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:windows")->intValue, &g_pConfigManager->getConfigValuePtr("animations:windows_curve")->strValue, (void*)this, AVARDAMAGE_ENTIRE);
m_cRealBorderColor.create(AVARTYPE_COLOR, &g_pConfigManager->getConfigValuePtr("animations:borders_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:borders")->intValue, &g_pConfigManager->getConfigValuePtr("animations:borders_curve")->strValue, (void*)this, AVARDAMAGE_BORDER);
m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, (void*)this, AVARDAMAGE_ENTIRE);
m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, (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_cRealBorderColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
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_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)
}
@@ -20,9 +22,9 @@ CWindow::~CWindow() {
}
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) {
@@ -103,3 +105,144 @@ pid_t CWindow::getPID() {
return PID;
}
IHyprWindowDecoration* CWindow::getDecorationByType(eDecorationType type) {
for (auto& wd : m_dWindowDecorations) {
if (wd->getDecorationType() == type)
return wd.get();
}
return nullptr;
}
void CWindow::createToplevelHandle() {
if (m_bIsX11 && (m_bX11DoesntWantBorders || m_iX11Type == 2))
return; // don't create a toplevel
m_phForeignToplevel = wlr_foreign_toplevel_handle_v1_create(g_pCompositor->m_sWLRToplevelMgr);
wlr_foreign_toplevel_handle_v1_set_app_id(m_phForeignToplevel, g_pXWaylandManager->getAppIDClass(this).c_str());
wlr_foreign_toplevel_handle_v1_output_enter(m_phForeignToplevel, g_pCompositor->getMonitorFromID(m_iMonitorID)->output);
wlr_foreign_toplevel_handle_v1_set_title(m_phForeignToplevel, m_szTitle.c_str());
wlr_foreign_toplevel_handle_v1_set_maximized(m_phForeignToplevel, false);
wlr_foreign_toplevel_handle_v1_set_minimized(m_phForeignToplevel, false);
wlr_foreign_toplevel_handle_v1_set_fullscreen(m_phForeignToplevel, false);
// handle events
hyprListener_toplevelActivate.initCallback(&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) {
g_pCompositor->focusWindow(this);
}, this, "Toplevel");
hyprListener_toplevelFullscreen.initCallback(&m_phForeignToplevel->events.request_fullscreen, [&](void* owner, void* data) {
const auto EV = (wlr_foreign_toplevel_handle_v1_fullscreen_event*)data;
g_pCompositor->setWindowFullscreen(this, EV->fullscreen, FULLSCREEN_FULL);
}, this, "Toplevel");
hyprListener_toplevelClose.initCallback(&m_phForeignToplevel->events.request_close, [&](void* owner, void* data) {
g_pCompositor->closeWindow(this);
}, this, "Toplevel");
m_iLastToplevelMonitorID = m_iMonitorID;
}
void CWindow::destroyToplevelHandle() {
if (!m_phForeignToplevel)
return;
hyprListener_toplevelActivate.removeCallback();
hyprListener_toplevelClose.removeCallback();
hyprListener_toplevelFullscreen.removeCallback();
wlr_foreign_toplevel_handle_v1_destroy(m_phForeignToplevel);
m_phForeignToplevel = nullptr;
}
void CWindow::updateToplevel() {
updateSurfaceOutputs();
if (!m_phForeignToplevel)
return;
wlr_foreign_toplevel_handle_v1_set_title(m_phForeignToplevel, m_szTitle.c_str());
wlr_foreign_toplevel_handle_v1_set_fullscreen(m_phForeignToplevel, m_bIsFullscreen);
if (m_iLastToplevelMonitorID != m_iMonitorID) {
if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iLastToplevelMonitorID); PMONITOR && PMONITOR->m_bEnabled)
wlr_foreign_toplevel_handle_v1_output_leave(m_phForeignToplevel, PMONITOR->output);
wlr_foreign_toplevel_handle_v1_output_enter(m_phForeignToplevel, g_pCompositor->getMonitorFromID(m_iMonitorID)->output);
m_iLastToplevelMonitorID = m_iMonitorID;
}
}
void sendEnterIter(wlr_surface* pSurface, int x, int y, void* data) {
const auto OUTPUT = (wlr_output*)data;
wlr_surface_send_enter(pSurface, OUTPUT);
}
void sendLeaveIter(wlr_surface* pSurface, int x, int y, void* data) {
const auto OUTPUT = (wlr_output*)data;
wlr_surface_send_leave(pSurface, OUTPUT);
}
void CWindow::updateSurfaceOutputs() {
if (m_iLastSurfaceMonitorID == m_iMonitorID || !m_bIsMapped || m_bHidden || !m_bMappedX11)
return;
const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_iLastSurfaceMonitorID);
m_iLastSurfaceMonitorID = m_iMonitorID;
const auto PNEWMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
if (PLASTMONITOR && PLASTMONITOR->m_bEnabled)
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(this), sendLeaveIter, PLASTMONITOR->output);
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(this), sendEnterIter, PNEWMONITOR->output);
}
void CWindow::moveToWorkspace(int workspaceID) {
if (m_iWorkspaceID != workspaceID) {
m_iWorkspaceID = workspaceID;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
if (PWORKSPACE) {
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();
}

View File

@@ -10,12 +10,18 @@
struct SWindowSpecialRenderData {
float alpha = 1.f;
float alphaInactive = -1.f; // -1 means unset
// set by the layout
bool rounding = true;
bool border = true;
};
struct SWindowAdditionalConfigData {
std::string animationStyle = "";
int rounding = -1; // -1 means no
bool forceNoBlur = false;
bool forceOpaque = false;
bool forceAllowsInput = false;
};
class CWindow {
@@ -31,6 +37,15 @@ public:
DYNLISTENER(setGeometryX11U);
DYNLISTENER(fullscreenWindow);
DYNLISTENER(newPopupXDG);
DYNLISTENER(requestMove);
DYNLISTENER(requestMinimize);
DYNLISTENER(requestMaximize);
DYNLISTENER(requestResize);
DYNLISTENER(activateX11);
DYNLISTENER(configureX11);
DYNLISTENER(toplevelClose);
DYNLISTENER(toplevelActivate);
DYNLISTENER(toplevelFullscreen);
// DYNLISTENER(newSubsurfaceWindow);
union {
@@ -46,6 +61,13 @@ public:
CAnimatedVariable m_vRealPosition;
CAnimatedVariable m_vRealSize;
// for not spamming the protocols
Vector2D m_vReportedPosition;
Vector2D m_vReportedSize;
// for restoring floating statuses
Vector2D m_vLastFloatingSize;
// this is used for pseudotiling
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(0,0);
@@ -72,14 +94,16 @@ public:
uint64_t m_iX11Type = 0;
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
DYNLISTENER(activateX11);
DYNLISTENER(configureX11);
bool m_bX11ShouldntFocus = false;
//
// For nofocus
bool m_bNoFocus = false;
bool m_bNoInitialFocus = false;
// initial fullscreen
bool m_bWantsInitialFullscreen = false;
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
// Animated border
@@ -95,6 +119,9 @@ public:
// For hidden windows and stuff
bool m_bHidden = 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
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
@@ -109,6 +136,16 @@ public:
// for alpha
CAnimatedVariable m_fActiveInactiveAlpha;
// animated shadow color
CAnimatedVariable m_cRealShadowColor;
// animated tint
CAnimatedVariable m_fDimPercent;
// for toplevel monitor events
uint64_t m_iLastToplevelMonitorID = -1;
uint64_t m_iLastSurfaceMonitorID = -1;
// For the list lookup
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;
@@ -119,5 +156,12 @@ public:
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
void updateWindowDecos();
pid_t getPID();
IHyprWindowDecoration* getDecorationByType(eDecorationType);
void removeDecorationByType(eDecorationType);
void createToplevelHandle();
void destroyToplevelHandle();
void updateToplevel();
void updateSurfaceOutputs();
void moveToWorkspace(int);
CWindow* X11TransientFor();
};

View File

@@ -12,11 +12,20 @@
CConfigManager::CConfigManager() {
setDefaultVars();
static const char* const ENVHOME = getenv("HOME");
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
setDefaultAnimationVars();
std::string CONFIGPATH;
if (g_pCompositor->explicitConfigPath == "") {
static const char* const ENVHOME = getenv("HOME");
CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
} else {
CONFIGPATH = g_pCompositor->explicitConfigPath;
}
configPaths.emplace_back(CONFIGPATH);
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
Debug::disableTime = &configValues["debug:disable_time"].intValue;
}
void CConfigManager::setDefaultVars() {
@@ -36,33 +45,46 @@ void CConfigManager::setDefaultVars() {
configValues["general:col.active_border"].intValue = 0xffffffff;
configValues["general:col.inactive_border"].intValue = 0xff444444;
configValues["general:cursor_inactive_timeout"].intValue = 0;
configValues["general:no_cursor_warps"].intValue = 0;
configValues["general:layout"].strValue = "dwindle";
configValues["misc:disable_hyprland_logo"].intValue = 0;
configValues["misc:disable_splash_rendering"].intValue = 0;
configValues["misc:no_vfr"].intValue = 0;
configValues["misc:no_vfr"].intValue = 1;
configValues["misc:damage_entire_on_snapshot"].intValue = 0;
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
configValues["misc:always_follow_on_dnd"].intValue = 1;
configValues["misc:layers_hog_keyboard_focus"].intValue = 1;
configValues["misc:animate_manual_resizes"].intValue = 0;
configValues["debug:int"].intValue = 0;
configValues["debug:log_damage"].intValue = 0;
configValues["debug:overlay"].intValue = 0;
configValues["debug:damage_blink"].intValue = 0;
configValues["debug:disable_logs"].intValue = 0;
configValues["debug:disable_time"].intValue = 1;
configValues["decoration:rounding"].intValue = 1;
configValues["decoration:rounding"].intValue = 0;
configValues["decoration:blur"].intValue = 1;
configValues["decoration:blur_size"].intValue = 8;
configValues["decoration:blur_passes"].intValue = 1;
configValues["decoration:blur_ignore_opacity"].intValue = 0;
configValues["decoration:blur_new_optimizations"].intValue = 0;
configValues["decoration:active_opacity"].floatValue = 1;
configValues["decoration:inactive_opacity"].floatValue = 1;
configValues["decoration:fullscreen_opacity"].floatValue = 1;
configValues["decoration:multisample_edges"].intValue = 1;
configValues["decoration:no_blur_on_oversized"].intValue = 1;
configValues["decoration:no_blur_on_oversized"].intValue = 0;
configValues["decoration:drop_shadow"].intValue = 1;
configValues["decoration:shadow_range"].intValue = 4;
configValues["decoration:shadow_render_power"].intValue = 3;
configValues["decoration:shadow_ignore_window"].intValue = 1;
configValues["decoration:shadow_offset"].strValue = "0 0";
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
configValues["decoration:col.shadow_inactive"].intValue = INT_MAX;
configValues["decoration:dim_inactive"].intValue = 0;
configValues["decoration:dim_strength"].floatValue = 0.5f;
configValues["dwindle:pseudotile"].intValue = 0;
configValues["dwindle:col.group_border"].intValue = 0x66777700;
@@ -70,6 +92,14 @@ void CConfigManager::setDefaultVars() {
configValues["dwindle:force_split"].intValue = 0;
configValues["dwindle:preserve_split"].intValue = 0;
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
configValues["dwindle:split_width_multiplier"].floatValue = 1.0f;
configValues["dwindle:no_gaps_when_only"].intValue = 0;
configValues["dwindle:use_active_for_splits"].intValue = 1;
configValues["master:special_scale_factor"].floatValue = 0.8f;
configValues["master:new_is_master"].intValue = 1;
configValues["master:new_on_top"].intValue = 0;
configValues["master:no_gaps_when_only"].intValue = 0;
configValues["animations:enabled"].intValue = 1;
configValues["animations:speed"].floatValue = 7.f;
@@ -91,6 +121,8 @@ void CConfigManager::setDefaultVars() {
configValues["animations:workspaces_speed"].floatValue = 0.f;
configValues["animations:workspaces"].intValue = 1;
configValues["input:sensitivity"].floatValue = 0.f;
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
configValues["input:kb_layout"].strValue = "us";
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
configValues["input:kb_options"].strValue = STRVAL_EMPTY;
@@ -101,6 +133,7 @@ void CConfigManager::setDefaultVars() {
configValues["input:natural_scroll"].intValue = 0;
configValues["input:numlock_by_default"].intValue = 0;
configValues["input:force_no_accel"].intValue = 0;
configValues["input:float_switch_override_focus"].intValue = 1;
configValues["input:touchpad:natural_scroll"].intValue = 0;
configValues["input:touchpad:disable_while_typing"].intValue = 1;
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
@@ -108,7 +141,13 @@ void CConfigManager::setDefaultVars() {
configValues["input:touchpad:tap-to-click"].intValue = 1;
configValues["input:touchpad:drag_lock"].intValue = 0;
configValues["binds:pass_mouse_when_bound"].intValue = 1;
configValues["binds:scroll_event_delay"].intValue = 300;
configValues["binds:workspace_back_and_forth"].intValue = 0;
configValues["binds:allow_workspace_cycles"].intValue = 0;
configValues["gestures:workspace_swipe"].intValue = 0;
configValues["gestures:workspace_swipe_fingers"].intValue = 3;
configValues["gestures:workspace_swipe_distance"].intValue = 300;
configValues["gestures:workspace_swipe_invert"].intValue = 1;
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
@@ -122,6 +161,8 @@ void CConfigManager::setDefaultVars() {
void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
auto& cfgValues = deviceConfigs[dev];
cfgValues["sensitivity"].floatValue = 0.f;
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
cfgValues["kb_layout"].strValue = "us";
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
cfgValues["kb_options"].strValue = STRVAL_EMPTY;
@@ -138,6 +179,61 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
cfgValues["drag_lock"].intValue = 0;
}
void CConfigManager::setDefaultAnimationVars() {
if (isFirstLaunch) {
INITANIMCFG("global");
INITANIMCFG("windows");
INITANIMCFG("fade");
INITANIMCFG("border");
INITANIMCFG("workspaces");
// windows
INITANIMCFG("windowsIn");
INITANIMCFG("windowsOut");
INITANIMCFG("windowsMove");
// fade
INITANIMCFG("fadeIn");
INITANIMCFG("fadeOut");
INITANIMCFG("fadeSwitch");
INITANIMCFG("fadeShadow");
INITANIMCFG("fadeDim");
// border
// workspaces
INITANIMCFG("specialWorkspace");
}
// init the values
animationConfig["global"] = {
false,
"default",
"",
8.f,
1,
&animationConfig["general"],
nullptr
};
CREATEANIMCFG("windows", "global");
CREATEANIMCFG("fade", "global");
CREATEANIMCFG("border", "global");
CREATEANIMCFG("workspaces", "global");
CREATEANIMCFG("windowsIn", "windows");
CREATEANIMCFG("windowsOut", "windows");
CREATEANIMCFG("windowsMove", "windows");
CREATEANIMCFG("fadeIn", "fade");
CREATEANIMCFG("fadeOut", "fade");
CREATEANIMCFG("fadeSwitch", "fade");
CREATEANIMCFG("fadeShadow", "fade");
CREATEANIMCFG("fadeDim", "fade");
CREATEANIMCFG("specialWorkspace", "workspaces");
}
void CConfigManager::init() {
loadConfigLoadVars();
@@ -159,17 +255,15 @@ void CConfigManager::init() {
void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::string& VALUE) {
if (configValues.find(COMMAND) == configValues.end()) {
if (COMMAND[0] == '$') {
// register a dynamic var
Debug::log(LOG, "Registered dynamic var \"%s\" -> %s", COMMAND.c_str(), VALUE.c_str());
configDynamicVars[COMMAND.substr(1)] = VALUE;
} else {
parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field.";
}
if (COMMAND.find("device:") != 0 /* devices parsed later */) {
if (COMMAND[0] == '$') {
// register a dynamic var
Debug::log(LOG, "Registered dynamic var \"%s\" -> %s", COMMAND.c_str(), VALUE.c_str());
configDynamicVars[COMMAND.substr(1)] = VALUE;
} else {
parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field.";
}
if (COMMAND.find("device:") == 0 /* devices parsed later */) {
parseError = "";
} else {
return;
}
}
@@ -355,34 +449,47 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
return;
}
// overwrite if exists
for (auto& r : m_dMonitorRules) {
if (r.name == newrule.name) {
r = newrule;
return;
}
}
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
m_dMonitorRules.push_back(newrule);
return;
}
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
if (curitem.find("pref") == 0) {
newrule.resolution = Vector2D();
} else {
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
if (curitem.contains("@"))
newrule.refreshRate = stof(curitem.substr(curitem.find_first_of('@') + 1));
if (curitem.contains("@"))
newrule.refreshRate = stof(curitem.substr(curitem.find_first_of('@') + 1));
}
nextItem();
newrule.offset.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.offset.y = stoi(curitem.substr(curitem.find_first_of('x') + 1));
if (curitem.find("auto") == 0) {
newrule.offset = Vector2D(-1, -1);
} else {
newrule.offset.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.offset.y = stoi(curitem.substr(curitem.find_first_of('x') + 1));
if (newrule.offset.x < 0 || newrule.offset.y < 0) {
parseError = "invalid offset. Offset cannot be negative.";
newrule.offset = Vector2D();
}
}
nextItem();
newrule.scale = stof(curitem);
if (newrule.scale < 0.25f) {
parseError = "not a valid scale.";
newrule.scale = 1;
}
nextItem();
if (curitem != "") {
@@ -392,13 +499,8 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
return;
}
// overwrite if exists
for (auto& r : m_dMonitorRules) {
if (r.name == newrule.name) {
r = newrule;
return;
}
}
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
m_dMonitorRules.push_back(newrule);
}
@@ -425,17 +527,39 @@ void CConfigManager::handleBezier(const std::string& command, const std::string&
std::string bezierName = curitem;
nextItem();
if (curitem == "")
parseError = "too few arguments";
float p1x = std::stof(curitem);
nextItem();
if (curitem == "")
parseError = "too few arguments";
float p1y = std::stof(curitem);
nextItem();
if (curitem == "")
parseError = "too few arguments";
float p2x = std::stof(curitem);
nextItem();
if (curitem == "")
parseError = "too few arguments";
float p2y = std::stof(curitem);
nextItem();
if (curitem != "")
parseError = "too many arguments";
g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y));
}
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig *const ANIM) {
for (auto& [name, anim] : animationConfig) {
if (anim.pParentAnimation == ANIM && !anim.overriden) {
// if a child isnt overriden, set the values of the parent
anim.pValues = ANIM->pValues;
setAnimForChildren(&anim);
}
}
};
void CConfigManager::handleAnimation(const std::string& command, const std::string& args) {
std::string curitem = "";
@@ -459,38 +583,94 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
// anim name
const auto ANIMNAME = curitem;
const auto ANIMMASTERSETTING = configValues.find("animations:" + ANIMNAME);
const auto PANIM = animationConfig.find(ANIMNAME);
if (ANIMMASTERSETTING == configValues.end()) {
Debug::log(ERR, "Anim %s doesnt exist", ANIMNAME.c_str());
parseError = "Animation " + ANIMNAME + " does not exist";
if (PANIM == animationConfig.end()) {
parseError = "no such animation";
return;
}
PANIM->second.overriden = true;
PANIM->second.pValues = &PANIM->second;
nextItem();
// on/off
configSetValueSafe("animations:" + ANIMNAME, curitem);
PANIM->second.internalEnabled = curitem == "1";
if (curitem != "0" && curitem != "1") {
parseError = "invalid animation on/off state";
}
nextItem();
// Speed
configSetValueSafe("animations:" + ANIMNAME + "_speed", curitem);
// speed
if (isNumber(curitem, true)) {
PANIM->second.internalSpeed = std::stof(curitem);
if (PANIM->second.internalSpeed <= 0) {
parseError = "invalid speed";
PANIM->second.internalSpeed = 1.f;
}
} else {
PANIM->second.internalSpeed = 10.f;
parseError = "invalid speed";
}
nextItem();
// curve
configSetValueSafe("animations:" + ANIMNAME + "_curve", curitem);
PANIM->second.internalBezier = curitem;
if (!g_pAnimationManager->bezierExists(curitem)) {
parseError = "no such bezier";
PANIM->second.internalBezier = "default";
}
nextItem();
// style
configSetValueSafe("animations:" + ANIMNAME + "_style", curitem);
PANIM->second.internalStyle = curitem;
if (curitem != "") {
const auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, curitem);
if (ERR != "")
parseError = ERR;
}
// now, check for children, recursively
setAnimForChildren(&PANIM->second);
}
void CConfigManager::handleBind(const std::string& command, const std::string& value, bool locked) {
void CConfigManager::handleBind(const std::string& command, const std::string& value) {
// example:
// bind=SUPER,G,exec,dmenu_run <args>
// bind[fl]=SUPER,G,exec,dmenu_run <args>
// flags
bool locked = false;
bool release = false;
bool repeat = false;
const auto ARGS = command.substr(4);
for (auto& arg : ARGS) {
if (arg == 'l') {
locked = true;
} else if (arg == 'r') {
release = true;
} else if (arg == 'e') {
repeat = true;
} else {
parseError = "bind: invalid flag";
return;
}
}
if (release && repeat) {
parseError = "flags r and e are mutually exclusive";
return;
}
auto valueCopy = value;
@@ -520,11 +700,16 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
return;
}
if (KEY == "exclam" || KEY == "asciicircum" || KEY == "at") { // just some
parseError = "Your config contains (probably) wrong keys. The SHIFT keysym behavior has changed after v0.10.3beta. Please consult the wiki (Advanced configuring -> binds)";
return;
}
if (KEY != "") {
if (isNumber(KEY) && std::stoi(KEY) > 9)
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap});
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat});
else
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap});
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat});
}
}
@@ -540,6 +725,25 @@ void CConfigManager::handleUnbind(const std::string& command, const std::string&
g_pKeybindManager->removeKeybind(MOD, KEY);
}
bool windowRuleValid(const std::string& RULE) {
return !(RULE != "float"
&& RULE != "tile"
&& RULE.find("opacity") != 0
&& RULE.find("move") != 0
&& RULE.find("size") != 0
&& RULE.find("pseudo") != 0
&& RULE.find("monitor") != 0
&& RULE != "nofocus"
&& RULE != "noblur"
&& RULE != "center"
&& RULE != "opaque"
&& RULE != "forceinput"
&& RULE != "fullscreen"
&& RULE.find("animation") != 0
&& RULE.find("rounding") != 0
&& RULE.find("workspace") != 0);
}
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
const auto RULE = value.substr(0, value.find_first_of(","));
const auto VALUE = value.substr(value.find_first_of(",") + 1);
@@ -550,29 +754,86 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
}
// verify we support a rule
if (RULE != "float"
&& RULE != "tile"
&& RULE.find("opacity") != 0
&& RULE.find("move") != 0
&& RULE.find("size") != 0
&& RULE.find("pseudo") != 0
&& RULE.find("monitor") != 0
&& RULE != "nofocus"
&& RULE != "noblur"
&& RULE != "fullscreen"
&& RULE.find("animation") != 0
&& RULE.find("rounding") != 0
&& RULE.find("workspace") != 0) {
Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
parseError = "Invalid rule found: " + RULE;
return;
}
if (!windowRuleValid(RULE)) {
Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
parseError = "Invalid rule found: " + RULE;
return;
}
m_dWindowRules.push_back({RULE, VALUE});
}
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
const auto RULE = value.substr(0, value.find_first_of(","));
const auto VALUE = value.substr(value.find_first_of(",") + 1);
if (!windowRuleValid(RULE)) {
Debug::log(ERR, "Invalid rulev2 found: %s", RULE.c_str());
parseError = "Invalid rulev2 found: " + RULE;
return;
}
// now we estract shit from the value
SWindowRule rule;
rule.v2 = true;
rule.szRule = RULE;
rule.szValue = VALUE;
const auto TITLEPOS = VALUE.find("title:");
const auto CLASSPOS = VALUE.find("class:");
const auto X11POS = VALUE.find("xwayland:");
const auto FLOATPOS = VALUE.find("floating:");
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos) {
Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str());
parseError = "Invalid rulev2 syntax: " + VALUE;
return;
}
auto extract = [&](size_t pos) -> std::string {
std::string result;
result = VALUE.substr(pos);
size_t min = 999999;
if (TITLEPOS > pos && TITLEPOS < min) min = TITLEPOS;
if (CLASSPOS > pos && CLASSPOS < min) min = CLASSPOS;
if (X11POS > pos && X11POS < min) min = X11POS;
if (FLOATPOS > pos && FLOATPOS < min) min = FLOATPOS;
result = result.substr(0, min - pos);
if (result.back() == ',')
result.pop_back();
return result;
};
if (CLASSPOS != std::string::npos) {
rule.szClass = extract(CLASSPOS + 6);
}
if (TITLEPOS != std::string::npos) {
rule.szTitle = extract(TITLEPOS + 6);
}
if (X11POS != std::string::npos) {
rule.bX11 = extract(X11POS + 9) == "1" ? 1 : 0;
}
if (FLOATPOS != std::string::npos) {
rule.bFloating = extract(FLOATPOS + 9) == "1" ? 1 : 0;
}
m_dWindowRules.push_back(rule);
}
void CConfigManager::handleBlurLS(const std::string& command, const std::string& value) {
if (value.find("remove,") == 0) {
const auto TOREMOVE = value.substr(7);
m_dBlurLSNamespaces.erase(std::remove(m_dBlurLSNamespaces.begin(), m_dBlurLSNamespaces.end(), TOREMOVE));
return;
}
m_dBlurLSNamespaces.emplace_back(value);
}
@@ -597,30 +858,13 @@ void CConfigManager::handleSubmap(const std::string& command, const std::string&
}
void CConfigManager::handleSource(const std::string& command, const std::string& rawpath) {
static const char* const ENVHOME = getenv("HOME");
auto value = rawpath;
if (value.length() < 2) {
if (rawpath.length() < 2) {
Debug::log(ERR, "source= path garbage");
parseError = "source path " + value + " bogus!";
parseError = "source path " + rawpath + " bogus!";
return;
}
if (value[0] == '.') {
auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/'));
if (value[1] == '.') {
auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
value.replace(0, 2, parentDir);
} else {
value.replace(0, 1, currentDir);
}
}
if (value[0] == '~') {
value.replace(0, 1, std::string(ENVHOME));
}
auto value = absolutePath(rawpath, configCurrentPath);
if (!std::filesystem::exists(value)) {
Debug::log(ERR, "source= file doesnt exist");
@@ -685,11 +929,11 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
}
}
else if (COMMAND == "monitor") handleMonitor(COMMAND, VALUE);
else if (COMMAND == "bind") handleBind(COMMAND, VALUE);
else if (COMMAND == "bindl") handleBind(COMMAND, VALUE, true);
else if (COMMAND.find("bind") == 0) handleBind(COMMAND, VALUE);
else if (COMMAND == "unbind") handleUnbind(COMMAND, VALUE);
else if (COMMAND == "workspace") handleDefaultWorkspace(COMMAND, VALUE);
else if (COMMAND == "windowrule") handleWindowRule(COMMAND, VALUE);
else if (COMMAND == "windowrulev2") handleWindowRuleV2(COMMAND, VALUE);
else if (COMMAND == "bezier") handleBezier(COMMAND, VALUE);
else if (COMMAND == "animation") handleAnimation(COMMAND, VALUE);
else if (COMMAND == "source") handleSource(COMMAND, VALUE);
@@ -750,6 +994,7 @@ void CConfigManager::parseLine(std::string& line) {
if (line.contains(" {")) {
auto cat = line.substr(0, line.find(" {"));
transform(cat.begin(), cat.end(), cat.begin(), ::tolower);
std::replace(cat.begin(), cat.end(), ' ', '-');
if (currentCategory.length() != 0) {
currentCategory.push_back(':');
currentCategory.append(cat);
@@ -762,7 +1007,14 @@ void CConfigManager::parseLine(std::string& line) {
}
if (line.contains("}") && currentCategory != "") {
currentCategory = "";
const auto LASTSEP = currentCategory.find_last_of(':');
if (LASTSEP == std::string::npos || currentCategory.contains("device"))
currentCategory = "";
else
currentCategory = currentCategory.substr(0, LASTSEP);
return;
}
@@ -798,32 +1050,42 @@ void CConfigManager::loadConfigLoadVars() {
configDynamicVars.clear();
deviceConfigs.clear();
m_dBlurLSNamespaces.clear();
setDefaultAnimationVars(); // reset anims
// paths
configPaths.clear();
std::string CONFIGPATH;
static const char* const ENVHOME = getenv("HOME");
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
const std::string CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
if (g_pCompositor->explicitConfigPath == "") {
CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
} else {
CONFIGPATH = g_pCompositor->explicitConfigPath;
}
configPaths.push_back(CONFIGPATH);
std::ifstream ifs;
ifs.open(CONFIGPATH);
if (!ifs.good()) {
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
try {
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
} catch(...) { /* Probably doesn't exist */}
if(g_pCompositor->explicitConfigPath == "") {
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
try {
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
} catch(...) { /* Probably doesn't exist */}
try {
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
std::filesystem::create_directories(CONFIGPARENTPATH);
}
catch (...) {
parseError = "Broken config file! (Could not create directory)";
return;
try {
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
std::filesystem::create_directories(CONFIGPARENTPATH);
}
catch (...) {
parseError = "Broken config file! (Could not create directory)";
return;
}
}
std::ofstream ofs;
@@ -870,8 +1132,10 @@ void CConfigManager::loadConfigLoadVars() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
// Update the keyboard layout to the cfg'd one if this is not the first launch
if (!isFirstLaunch)
if (!isFirstLaunch) {
g_pInputManager->setKeyboardLayout();
g_pInputManager->setMouseConfigs();
}
// Calculate the internal vars
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask(configValues["general:main_mod"].strValue);
@@ -887,23 +1151,37 @@ void CConfigManager::loadConfigLoadVars() {
if (parseError != "")
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
else if (configValues["autogenerated"].intValue == 1)
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Enter -> kitty\nSUPER+T -> Alacritty\nSUPER+M -> exit Hyprland", CColor(255, 255, 70, 255));
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Q -> kitty\nSUPER+M -> exit Hyprland", CColor(255, 255, 70, 255));
else
g_pHyprError->destroy();
// Set the modes for all monitors as we configured them
// not on first launch because monitors might not exist yet
// and they'll be taken care of in the newMonitor event
if (!isFirstLaunch) {
// ignore if nomonitorreload is set
if (!isFirstLaunch && !m_bNoMonitorReload) {
m_bWantsMonitorReload = true;
// check
ensureDPMS();
}
// Update window border colors
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
// Force the compositor to fully re-render all monitors
for (auto& m : g_pCompositor->m_vMonitors)
// update layout
g_pLayoutManager->switchToLayout(configValues["general:layout"].strValue);
for (auto& m : g_pCompositor->m_vMonitors) {
// mark blur dirty
g_pHyprOpenGL->markBlurDirtyForMonitor(m.get());
// Force the compositor to fully re-render all monitors
m->forceFullFrames = 2;
}
// Reset no monitor reload
m_bNoMonitorReload = false;
}
void CConfigManager::tick() {
@@ -952,9 +1230,13 @@ SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) {
SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) {
std::lock_guard<std::mutex> lg(configmtx);
const auto it = deviceConfigs.find(dev);
auto devcopy = dev;
std::replace(devcopy.begin(), devcopy.end(), ' ', '-');
const auto it = deviceConfigs.find(devcopy);
if (it == deviceConfigs.end()) {
Debug::log(ERR, "getConfigValueSafeDevice: No device config for %s found???", devcopy.c_str());
return SConfigValue();
}
@@ -963,7 +1245,11 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co
// fallback if not set explicitly
if (!copy.set) {
for (auto& cv : configValues) {
if (cv.first.find(val) == cv.first.length() - val.length()) {
auto foundIt = cv.first.find(val);
if (foundIt == std::string::npos)
continue;
if (cv.first == "input:" + val || cv.first == "input:touchpad:" + cv.first) {
copy = cv.second;
}
}
@@ -1045,7 +1331,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(std::string name) {
Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
return SMonitorRule{.name = "", .resolution = Vector2D(1280, 720), .offset = Vector2D(0, 0), .scale = 1};
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-1, -1), .scale = 1}; // 0, 0 is preferred and -1, -1 is auto
}
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
@@ -1061,22 +1347,53 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
for (auto& rule : m_dWindowRules) {
// check if we have a matching rule
try {
if (rule.szValue.find("title:") == 0) {
// we have a title rule.
std::regex RULECHECK(rule.szValue.substr(6));
if (!rule.v2) {
try {
if (rule.szValue.find("title:") == 0) {
// we have a title rule.
std::regex RULECHECK(rule.szValue.substr(6));
if (!std::regex_search(title, RULECHECK))
continue;
} else {
std::regex classCheck(rule.szValue);
if (!std::regex_search(title, RULECHECK))
continue;
} else {
std::regex classCheck(rule.szValue);
if (!std::regex_search(appidclass, classCheck))
continue;
if (!std::regex_search(appidclass, classCheck))
continue;
}
} catch (...) {
Debug::log(ERR, "Regex error at %s", rule.szValue.c_str());
continue;
}
} else {
try {
if (rule.szClass != "") {
std::regex RULECHECK(rule.szClass);
if (!std::regex_search(appidclass, RULECHECK))
continue;
}
if (rule.szTitle != "") {
std::regex RULECHECK(rule.szTitle);
if (!std::regex_search(title, RULECHECK))
continue;
}
if (rule.bX11 != -1) {
if (pWindow->m_bIsX11 != rule.bX11)
continue;
}
if (rule.bFloating != -1) {
if (pWindow->m_bIsFloating != rule.bFloating)
continue;
}
} catch (...) {
Debug::log(ERR, "Regex error at %s", rule.szValue.c_str());
continue;
}
} catch (...) {
Debug::log(ERR, "Regex error at %s", rule.szValue.c_str());
continue;
}
// applies. Read the rule and behave accordingly
@@ -1099,18 +1416,29 @@ void CConfigManager::dispatchExecOnce() {
}
firstExecRequests.clear(); // free some kb of memory :P
// set input, fixes some certain issues
g_pInputManager->setKeyboardLayout();
g_pInputManager->setMouseConfigs();
// set ws names again
for (auto& ws : g_pCompositor->m_vWorkspaces) {
wlr_ext_workspace_handle_v1_set_name(ws->m_pWlrHandle, ws->m_szName.c_str());
}
}
void CConfigManager::performMonitorReload() {
bool overAgain = false;
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto& m : g_pCompositor->m_vRealMonitors) {
auto rule = getMonitorRuleFor(m->szName);
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) {
overAgain = true;
break;
}
g_pHyprRenderer->arrangeLayersForMonitor(m->ID);
}
if (overAgain)
@@ -1123,8 +1451,20 @@ SConfigValue* CConfigManager::getConfigValuePtr(std::string val) {
return &configValues[val];
}
SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) {
const auto IT = configValues.find(val);
if (IT == configValues.end())
return nullptr;
return &(IT->second);
}
bool CConfigManager::deviceConfigExists(const std::string& dev) {
const auto it = deviceConfigs.find(dev);
auto copy = dev;
std::replace(copy.begin(), copy.end(), ' ', '-');
const auto it = deviceConfigs.find(copy);
return it != deviceConfigs.end();
}
@@ -1138,3 +1478,23 @@ bool CConfigManager::shouldBlurLS(const std::string& ns) {
return false;
}
void CConfigManager::ensureDPMS() {
for (auto& rm : g_pCompositor->m_vRealMonitors) {
auto rule = getMonitorRuleFor(rm->szName);
if (rule.disabled == rm->m_bEnabled) {
rm->m_pThisWrap = &rm;
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);
}
}
}
SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::string& name) {
return &animationConfig[name];
}
void CConfigManager::addParseError(const std::string& err) {
if (parseError == "")
parseError = err;
}

View File

@@ -16,6 +16,9 @@
#define STRVAL_EMPTY "[[EMPTY]]"
#define INITANIMCFG(name) animationConfig[name] = {}
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
struct SConfigValue {
int64_t intValue = -1;
float floatValue = -1;
@@ -45,6 +48,24 @@ struct SMonitorAdditionalReservedArea {
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;
};
struct SAnimationPropertyConfig {
bool overriden = true;
std::string internalBezier = "";
std::string internalStyle = "";
float internalSpeed = 0.f;
int internalEnabled = -1;
SAnimationPropertyConfig* pValues = nullptr;
SAnimationPropertyConfig* pParentAnimation = nullptr;
};
class CConfigManager {
@@ -68,6 +89,7 @@ public:
bool shouldBlurLS(const std::string&);
SConfigValue* getConfigValuePtr(std::string);
SConfigValue* getConfigValuePtrSafe(std::string);
SMonitorRule getMonitorRuleFor(std::string);
@@ -81,9 +103,17 @@ public:
void performMonitorReload();
bool m_bWantsMonitorReload = false;
bool m_bForceReload = false;
bool m_bNoMonitorReload = false;
void ensureDPMS();
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
void addParseError(const std::string&);
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
std::string configCurrentPath;
private:
std::deque<std::string> configPaths; // stores all the config paths
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
@@ -91,7 +121,7 @@ private:
std::unordered_map<std::string, SConfigValue> configValues;
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
std::string configCurrentPath;
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
std::string currentCategory = ""; // For storing the category of the current item
@@ -110,8 +140,11 @@ private:
// internal methods
void setDefaultVars();
void setDefaultAnimationVars();
void setDeviceDefaultVars(const std::string&);
void setAnimForChildren(SAnimationPropertyConfig *const);
void applyUserDefinedVars(std::string&, const size_t);
void loadConfigLoadVars();
SConfigValue getConfigValueSafe(const std::string&);
@@ -121,9 +154,10 @@ private:
void handleDeviceConfig(const std::string&, const std::string&);
void handleRawExec(const std::string&, const std::string&);
void handleMonitor(const std::string&, const std::string&);
void handleBind(const std::string&, const std::string&, bool locked = false);
void handleBind(const std::string&, const std::string&);
void handleUnbind(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 handleBezier(const std::string&, const std::string&);
void handleAnimation(const std::string&, const std::string&);
@@ -132,4 +166,4 @@ private:
void handleBlurLS(const std::string&, const std::string&);
};
inline std::unique_ptr<CConfigManager> g_pConfigManager;
inline std::unique_ptr<CConfigManager> g_pConfigManager;

View File

@@ -9,11 +9,18 @@ PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT,
OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
########################################################################################
#
# Please note not all available settings / options are set here.
# For a full list, see the wiki (basic and advanced configuring)
#
autogenerated=1 # remove this line to get rid of the warning on top.
monitor=,1920x1080@60,0x0,1
monitor=,preferred,auto,1
input {
kb_file=
kb_layout=
kb_variant=
kb_model=
@@ -21,10 +28,15 @@ input {
kb_rules=
follow_mouse=1
touchpad {
natural_scroll=no
}
sensitivity=0 # -1.0 - 1.0, 0 means no modification.
}
general {
sensitivity=1.0 # for mouse cursor
main_mod=SUPER
gaps_in=5
@@ -42,17 +54,15 @@ decoration {
rounding=10
blur=1
blur_size=3 # minimum 1
blur_passes=1 # minimum 1, more passes = more resource intensive.
# Your blur "amount" is blur_size * blur_passes, but high blur_size (over around 5-ish) will produce artifacts.
# if you want heavy blur, you need to up the blur_passes.
# the more passes, the more you can up the blur_size without noticing artifacts.
blur_passes=1 # minimum 1
blur_new_optimizations=1
}
animations {
enabled=1
animation=windows,1,7,default
animation=borders,1,10,default
animation=fadein,1,10,default
animation=border,1,10,default
animation=fade,1,10,default
animation=workspaces,1,6,default
}
@@ -60,6 +70,10 @@ dwindle {
pseudotile=0 # enable pseudotiling on dwindle
}
gestures {
workspace_swipe=no
}
# example window rules
# for windows named/classed as abc and xyz
#windowrule=move 69 420,abc
@@ -105,4 +119,7 @@ bind=ALT,7,movetoworkspace,7
bind=ALT,8,movetoworkspace,8
bind=ALT,9,movetoworkspace,9
bind=ALT,0,movetoworkspace,10
)#";
bind=SUPER,mouse_down,workspace,e+1
bind=SUPER,mouse_up,workspace,e-1
)#";

View File

@@ -13,117 +13,459 @@
#include <string>
std::string monitorsRequest() {
std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
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\tactive: %s\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"));
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& m : g_pCompositor->m_vMonitors) {
result += getFormat(
R"#({
"id": %i,
"name": "%s",
"width": %i,
"height": %i,
"refreshRate": %f,
"x": %i,
"y": %i,
"activeWorkspace": {
"id": %i,
"name": "%s"
},
"reserved": [%i, %i, %i, %i],
"scale": %.2f,
"transform": %i,
"focused": %s
},)#",
m->ID,
escapeJSONStrings(m->szName).c_str(),
(int)m->vecPixelSize.x, (int)m->vecPixelSize.y,
m->refreshRate,
(int)m->vecPosition.x, (int)m->vecPosition.y,
m->activeWorkspace, escapeJSONStrings(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 ? "true" : "false")
);
}
// remove trailing comma
result.pop_back();
result += "]";
} else {
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",
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"));
}
}
return result;
}
std::string clientsRequest() {
std::string clientsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
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\n",
&w, 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());
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsMapped) {
result += getFormat(
R"#({
"address": "0x%x",
"at": [%i, %i],
"size": [%i, %i],
"workspace": {
"id": %i,
"name": "%s"
},
"floating": %s,
"monitor": %i,
"class": "%s",
"title": "%s",
"pid": %i,
"xwayland": %s
},)#",
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
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() {
std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
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);
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() {
std::string activeWindowRequest(HyprCtl::eHyprCtlOutputFormat format) {
const auto PWINDOW = g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW))
return "Invalid";
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
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\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());
if (format == HyprCtl::FORMAT_JSON) {
return getFormat(
R"#({
"address": "0x%x",
"at": [%i, %i],
"size": [%i, %i],
"workspace": {
"id": %i,
"name": "%s"
},
"floating": %s,
"monitor": %i,
"class": "%s",
"title": "%s",
"pid": %i,
"xwayland": %s
})#",
PWINDOW,
(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, escapeJSONStrings(PWINDOW->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_szName).c_str(),
((int)PWINDOW->m_bIsFloating == 1 ? "true" : "false"),
PWINDOW->m_iMonitorID,
escapeJSONStrings(g_pXWaylandManager->getAppIDClass(PWINDOW)).c_str(),
escapeJSONStrings(g_pXWaylandManager->getTitle(PWINDOW)).c_str(),
PWINDOW->getPID(),
((int)PWINDOW->m_bIsX11 == 1 ? "true" : "false")
);
} 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",
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);
}
}
std::string layersRequest() {
std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
for (auto& mon : g_pCompositor->m_vMonitors) {
result += getFormat("Monitor %s:\n", mon->szName.c_str());
int layerLevel = 0;
for (auto& level : mon->m_aLayerSurfaceLists) {
result += getFormat("\tLayer level %i:\n", layerLevel);
if (format == HyprCtl::FORMAT_JSON) {
result += "{\n";
for (auto& layer : level) {
result += getFormat("\t\tLayer %x: xywh: %i %i %i %i, namespace: %s\n", layer, layer->geometry.x, layer->geometry.y, layer->geometry.width, layer->geometry.height, layer->szNamespace.c_str());
for (auto& mon : g_pCompositor->m_vMonitors) {
result += getFormat(
R"#("%s": {
"levels": {
)#",
escapeJSONStrings(mon->szName).c_str()
);
int layerLevel = 0;
for (auto& level : mon->m_aLayerSurfaceLists) {
result += getFormat(
R"#(
"%i": [
)#",
layerLevel
);
for (auto& layer : level) {
result += getFormat(
R"#( {
"address": "0x%x",
"x": %i,
"y": %i,
"w": %i,
"h": %i,
"namespace": "%s"
},)#",
layer.get(),
layer->geometry.x,
layer->geometry.y,
layer->geometry.width,
layer->geometry.height,
escapeJSONStrings(layer->szNamespace).c_str()
);
}
// remove trailing comma
result.pop_back();
if (level.size() > 0)
result += "\n ";
result += "],";
layerLevel++;
}
layerLevel++;
// remove trailing comma
result.pop_back();
result += "\n }\n},";
}
// remove trailing comma
result.pop_back();
result += "\n}\n";
} else {
for (auto& mon : g_pCompositor->m_vMonitors) {
result += getFormat("Monitor %s:\n", mon->szName.c_str());
int layerLevel = 0;
for (auto& level : mon->m_aLayerSurfaceLists) {
result += getFormat("\tLayer level %i:\n", layerLevel);
for (auto& layer : level) {
result += getFormat("\t\tLayer %x: xywh: %i %i %i %i, namespace: %s\n", layer.get(), layer->geometry.x, layer->geometry.y, layer->geometry.width, layer->geometry.height, layer->szNamespace.c_str());
}
layerLevel++;
}
result += "\n\n";
}
result += "\n\n";
}
return result;
}
std::string devicesRequest() {
std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
result += "mice:\n";
if (format == HyprCtl::FORMAT_JSON) {
result += "{\n";
result += "\"mice\": [\n";
for (auto& m : g_pInputManager->m_lMice) {
result += getFormat("\tMouse at %x:\n\t\t%s\n", &m, m.mouse->name);
}
for (auto& m : g_pInputManager->m_lMice) {
result += getFormat(
R"#( {
"address": "0x%x",
"name": "%s"
},)#",
&m,
escapeJSONStrings(m.mouse->name).c_str()
);
}
result += "\n\nKeyboards:\n";
// remove trailing comma
result.pop_back();
result += "\n],\n";
for (auto& k : g_pInputManager->m_lKeyboards) {
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%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());
}
result += "\"keyboards\": [\n";
for (auto& k : g_pInputManager->m_lKeyboards) {
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
result += getFormat(
R"#( {
"address": "0x%x",
"name": "%s",
"rules": "%s",
"model": "%s",
"layout": "%s",
"variant": "%s",
"options": "%s",
"active_keymap": "%s",
"main": %s
},)#",
&k,
escapeJSONStrings(k.keyboard->name).c_str(),
escapeJSONStrings(k.currentRules.rules).c_str(),
escapeJSONStrings(k.currentRules.model).c_str(),
escapeJSONStrings(k.currentRules.layout).c_str(),
escapeJSONStrings(k.currentRules.variant).c_str(),
escapeJSONStrings(k.currentRules.options).c_str(),
escapeJSONStrings(KM).c_str(),
(k.active ? "true" : "false")
);
}
result += "\n\nTablets:\n";
// remove trailing comma
result.pop_back();
result += "\n],\n";
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 += "\"tablets\": [\n";
for (auto& d : g_pInputManager->m_lTablets) {
result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.wlrDevice ? d.wlrDevice->name : "");
}
for (auto& d : g_pInputManager->m_lTabletPads) {
result += getFormat(
R"#( {
"address": "0x%x",
"type": "tabletPad",
"belongsTo": {
"address": "0x%x",
"name": "%s"
}
},)#",
&d,
d.pTabletParent,
escapeJSONStrings(d.pTabletParent ? d.pTabletParent->wlrDevice ? d.pTabletParent->wlrDevice->name : "" : "").c_str()
);
}
for (auto& d : g_pInputManager->m_lTabletTools) {
result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
for (auto& d : g_pInputManager->m_lTablets) {
result += getFormat(
R"#( {
"address": "0x%x",
"name": "%s"
},)#",
&d,
escapeJSONStrings(d.wlrDevice ? d.wlrDevice->name : "").c_str()
);
}
for (auto& d : g_pInputManager->m_lTabletTools) {
result += getFormat(
R"#( {
"address": "0x%x",
"type": "tabletTool",
"belongsTo": "0x%x"
},)#",
&d,
d.wlrTabletTool ? d.wlrTabletTool->data : 0
);
}
// remove trailing comma
if (result[result.size() - 1] == ',')
result.pop_back();
result += "\n]\n";
result += "}\n";
} else {
result += "mice:\n";
for (auto& m : g_pInputManager->m_lMice) {
result += getFormat("\tMouse at %x:\n\t\t%s\n", &m, m.mouse->name);
}
result += "\n\nKeyboards:\n";
for (auto& k : g_pInputManager->m_lKeyboards) {
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 += "\n\nTablets:\n";
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 : "" : "");
}
for (auto& d : g_pInputManager->m_lTablets) {
result += getFormat("\tTablet at %x:\n\t\t%s\n", &d, d.wlrDevice ? d.wlrDevice->name : "");
}
for (auto& d : g_pInputManager->m_lTabletTools) {
result += getFormat("\tTablet Tool at %x (belongs to %x)\n", &d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
}
}
return result;
}
std::string versionRequest() {
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" + GIT_COMMIT_MESSAGE + ").\nflags: (if any)\n";
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" + removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str() + ").\nflags: (if any)\n";
#ifdef LEGACY_RENDERER
result += "legacyrenderer\n";
result += "legacyrenderer\n";
#endif
#ifndef NDEBUG
result += "debug\n";
result += "debug\n";
#endif
#ifdef HYPRLAND_DEBUG
result += "debug\n";
result += "debug\n";
#endif
#ifdef NO_XWAYLAND
result += "no xwayland\n";
result += "no xwayland\n";
#endif
return result;
return result;
} else {
std::string result = getFormat(
R"#({
"branch": "%s",
"commit": "%s",
"dirty": %s
"commit_message": "%s",
"flags": [)#", GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str());
#ifdef LEGACY_RENDERER
result += "\"legacyrenderer\",";
#endif
#ifndef NDEBUG
result += "\"debug\",";
#endif
#ifdef HYPRLAND_DEBUG
result += "\"debug\",";
#endif
#ifdef NO_XWAYLAND
result += "\"no xwayland\",";
#endif
if (result[result.length() - 1] == ',')
result.pop_back();
result += "]\n}";
return result;
}
return ""; // make the compiler happy
}
std::string dispatchRequest(std::string in) {
@@ -158,8 +500,13 @@ std::string dispatchKeyword(std::string in) {
if (COMMAND == "monitor")
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
if (COMMAND.contains("input"))
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
g_pInputManager->setKeyboardLayout(); // update kb layout
g_pInputManager->setMouseConfigs(); // update mouse cfgs
}
if (COMMAND.contains("general:layout"))
g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout
Debug::log(LOG, "Hyprctl: keyword %s : %s", COMMAND.c_str(), VALUE.c_str());
@@ -169,9 +516,16 @@ std::string dispatchKeyword(std::string in) {
return retval;
}
std::string reloadRequest() {
std::string reloadRequest(std::string request) {
const auto REQMODE = request.substr(request.find_last_of(' ') + 1);
g_pConfigManager->m_bForceReload = true;
if (REQMODE == "config-only") {
g_pConfigManager->m_bNoMonitorReload = true;
}
return "ok";
}
@@ -219,31 +573,146 @@ std::string dispatchBatch(std::string request) {
return reply;
}
std::string dispatchSetCursor(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 THEME = curitem;
nextItem();
const auto SIZE = curitem;
if (!isNumber(SIZE)) {
return "size not int";
}
const auto SIZEINT = std::stoi(SIZE);
if (SIZEINT < 1) {
return "size must be positive";
}
wlr_xcursor_manager_destroy(g_pCompositor->m_sWLRXCursorMgr);
g_pCompositor->m_sWLRXCursorMgr = wlr_xcursor_manager_create(THEME.c_str(), SIZEINT);
setenv("XCURSOR_SIZE", SIZE.c_str(), true);
setenv("XCURSOR_THEME", THEME.c_str(), true);
for (auto& m : g_pCompositor->m_vMonitors) {
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, m->scale);
}
return "ok";
}
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
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 PCFGOPT = g_pConfigManager->getConfigValuePtrSafe(curitem);
if (!PCFGOPT)
return "no such option";
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());
else {
return getFormat(
R"#(
{
"option": "%s",
"int": %i,
"float": %f,
"str": "%s"
}
)#", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str()
);
}
}
std::string getReply(std::string request) {
auto format = HyprCtl::FORMAT_NORMAL;
// process flags for non-batch requests
if (!request.contains("[[BATCH]]") && request.contains("/")) {
long unsigned int sepIndex = 0;
for (const auto& c : request) {
if (c == '/') { // stop at separator
break;
}
sepIndex++;
if (c == 'j')
format = HyprCtl::FORMAT_JSON;
}
if (sepIndex < request.size())
request = request.substr(sepIndex + 1); // remove flags and separator so we can compare the rest of the string
}
if (request == "monitors")
return monitorsRequest();
return monitorsRequest(format);
else if (request == "workspaces")
return workspacesRequest();
return workspacesRequest(format);
else if (request == "clients")
return clientsRequest();
return clientsRequest(format);
else if (request == "kill")
return killRequest();
else if (request == "activewindow")
return activeWindowRequest();
return activeWindowRequest(format);
else if (request == "layers")
return layersRequest();
return layersRequest(format);
else if (request == "version")
return versionRequest();
else if (request == "reload")
return reloadRequest();
return versionRequest(format);
else if (request.find("reload") == 0)
return reloadRequest(request);
else if (request == "devices")
return devicesRequest();
return devicesRequest(format);
else if (request == "splash")
return splashRequest();
else if (request.find("dispatch") == 0)
return dispatchRequest(request);
else if (request.find("keyword") == 0)
return dispatchKeyword(request);
else if (request.find("setcursor") == 0)
return dispatchSetCursor(request);
else if (request.find("getoption") == 0)
return dispatchGetOption(request, format);
else if (request.find("[[BATCH]]") == 0)
return dispatchBatch(request);
@@ -267,19 +736,14 @@ void HyprCtl::tickHyprCtl() {
requestMade = false;
requestReady = true;
if (g_pConfigManager->m_bWantsMonitorReload) {
g_pConfigManager->ensureDPMS();
}
}
std::string getRequestFromThread(std::string rq) {
// we need to do something to wake hyprland up if VFR is enabled
static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue;
// TODO: is this safe...?
// this might be a race condition
// tested with 2 instances of `watch -n 0.1 hyprctl splash` and seems to not crash so I'll take that as a yes
if (!*PNOVFR)
wlr_output_schedule_frame(g_pCompositor->m_vMonitors.front()->output);
while (HyprCtl::request != "" || HyprCtl::requestMade || HyprCtl::requestReady) {
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
@@ -302,7 +766,7 @@ std::string getRequestFromThread(std::string rq) {
}
void HyprCtl::startHyprCtlSocket() {
std::thread([&]() {
tThread = std::thread([&]() {
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SOCKET < 0) {
@@ -349,5 +813,7 @@ void HyprCtl::startHyprCtlSocket() {
}
close(SOCKET);
}).detach();
}
});
tThread.detach();
}

View File

@@ -14,4 +14,11 @@ namespace HyprCtl {
inline std::string request = "";
inline std::ifstream requestStream;
inline std::thread tThread;
enum eHyprCtlOutputFormat {
FORMAT_NORMAL = 0,
FORMAT_JSON
};
};

View File

@@ -1,7 +1,7 @@
#include "HyprDebugOverlay.hpp"
#include "../Compositor.hpp"
void CHyprMonitorDebugOverlay::renderData(SMonitor* pMonitor, float µs) {
void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_dLastRenderTimes.push_back(µs / 1000.f);
if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate)
@@ -11,7 +11,7 @@ void CHyprMonitorDebugOverlay::renderData(SMonitor* pMonitor, float µs) {
m_pMonitor = pMonitor;
}
void CHyprMonitorDebugOverlay::renderDataNoOverlay(SMonitor* pMonitor, float µs) {
void CHyprMonitorDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float µs) {
m_dLastRenderTimesNoOverlay.push_back(µs / 1000.f);
if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate)
@@ -21,7 +21,7 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(SMonitor* pMonitor, float µs
m_pMonitor = pMonitor;
}
void CHyprMonitorDebugOverlay::frameData(SMonitor* pMonitor) {
void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate)
@@ -126,15 +126,15 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
return yOffset - offset;
}
void CHyprDebugOverlay::renderData(SMonitor* pMonitor, float µs) {
void CHyprDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_mMonitorOverlays[pMonitor].renderData(pMonitor, µs);
}
void CHyprDebugOverlay::renderDataNoOverlay(SMonitor* pMonitor, float µs) {
void CHyprDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float µs) {
m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, µs);
}
void CHyprDebugOverlay::frameData(SMonitor* pMonitor) {
void CHyprDebugOverlay::frameData(CMonitor* pMonitor) {
m_mMonitorOverlays[pMonitor].frameData(pMonitor);
}

View File

@@ -11,16 +11,16 @@ class CHyprMonitorDebugOverlay {
public:
int draw(int offset);
void renderData(SMonitor* pMonitor, float µs);
void renderDataNoOverlay(SMonitor* pMonitor, float µs);
void frameData(SMonitor* pMonitor);
void renderData(CMonitor* pMonitor, float µs);
void renderDataNoOverlay(CMonitor* pMonitor, float µs);
void frameData(CMonitor* pMonitor);
private:
std::deque<float> m_dLastFrametimes;
std::deque<float> m_dLastRenderTimes;
std::deque<float> m_dLastRenderTimesNoOverlay;
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
SMonitor* m_pMonitor = nullptr;
CMonitor* m_pMonitor = nullptr;
wlr_box m_wbLastDrawnBox;
};
@@ -28,13 +28,13 @@ class CHyprDebugOverlay {
public:
void draw();
void renderData(SMonitor*, float µs);
void renderDataNoOverlay(SMonitor*, float µs);
void frameData(SMonitor*);
void renderData(CMonitor*, float µs);
void renderDataNoOverlay(CMonitor*, float µs);
void frameData(CMonitor*);
private:
std::unordered_map<SMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;

View File

@@ -6,10 +6,23 @@
#include <iostream>
void Debug::init(std::string IS) {
if (ISDEBUG)
logFile = "/tmp/hypr/" + IS + "/hyprlandd.log";
else
logFile = "/tmp/hypr/" + IS + "/hyprland.log";
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
}
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
char* outputStr = nullptr;
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
vasprintf(&outputStr, fmt, args);
std::string output = std::string(outputStr);
free(outputStr);
ofs << "[wlr] " << output << "\n";
ofs.close();
}
void Debug::log(LogLevel level, const char* fmt, ...) {
@@ -41,37 +54,37 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
break;
}
char buf[LOGMESSAGESIZE] = "";
char* outputStr;
int logLen;
// print date and time to the ofs
if (disableTime && !*disableTime) {
auto timet = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
const auto MILLIS = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() % 1000;
ofs << std::put_time(std::localtime(&timet), "[%H:%M:%S:");
if (MILLIS > 99)
ofs << MILLIS;
else if (MILLIS > 9)
ofs << "0" << MILLIS;
else
ofs << "00" << MILLIS;
ofs << "] ";
}
char* outputStr = nullptr;
va_list args;
va_start(args, fmt);
logLen = vsnprintf(buf, sizeof buf, fmt, args);
vasprintf(&outputStr, fmt, args);
va_end(args);
if ((long unsigned int)logLen < sizeof buf) {
outputStr = strdup(buf);
} else {
outputStr = (char*)malloc(logLen + 1);
std::string output = std::string(outputStr);
free(outputStr);
if (!outputStr) {
printf("CRITICAL: Cannot alloc size %d for log! (Out of memory?)", logLen + 1);
return;
}
va_start(args, fmt);
vsnprintf(outputStr, logLen + 1U, fmt, args);
va_end(args);
}
ofs << outputStr << "\n";
ofs << output << "\n";
ofs.close();
// log it to the stdout too.
std::cout << outputStr << "\n";
// free the log
free(outputStr);
std::cout << output << "\n";
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include <string>
#include <wlr/util/log.h>
#define LOGMESSAGESIZE 1024
@@ -15,7 +16,9 @@ enum LogLevel {
namespace Debug {
void init(std::string IS);
void log(LogLevel level, const char* fmt, ...);
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
inline std::string logFile;
inline int64_t* disableLogs = nullptr;
inline int64_t* disableTime = nullptr;
};

View File

@@ -54,6 +54,12 @@
#define ASSERT(expr) RASSERT(expr, "?")
#if ISDEBUG
#define UNREACHABLE() { Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); *((int*)nullptr) = 1; }
#else
#define UNREACHABLE() std::unreachable();
#endif
// git stuff
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH "?"

View File

@@ -49,9 +49,7 @@ void Events::listener_mouseButton(wl_listener* listener, void* data) {
}
void Events::listener_mouseAxis(wl_listener* listener, void* data) {
const auto E = (wlr_pointer_axis_event*)data;
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, E->time_msec, E->orientation, E->delta, E->delta_discrete, E->source);
g_pInputManager->onMouseWheel((wlr_pointer_axis_event*)data);
}
void Events::listener_requestMouse(wl_listener* listener, void* data) {
@@ -74,7 +72,6 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
break;
case WLR_INPUT_DEVICE_TOUCH:
Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name);
Debug::log(WARN, "!!!! Hyprland does not directly support touchscreens, bugs may occur !!!!");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, DEVICE);
break;
case WLR_INPUT_DEVICE_TABLET_TOOL:
@@ -177,3 +174,36 @@ void Events::listener_swipeEnd(wl_listener* listener, void* data) {
g_pInputManager->onSwipeEnd(EVENT);
}
void Events::listener_pinchBegin(wl_listener* listener, void* data) {
const auto EV = (wlr_pointer_pinch_begin_event*)data;
wlr_pointer_gestures_v1_send_pinch_begin(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->fingers);
}
void Events::listener_pinchUpdate(wl_listener* listener, void* data) {
const auto EV = (wlr_pointer_pinch_update_event*)data;
wlr_pointer_gestures_v1_send_pinch_update(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->dx, EV->dy, EV->scale, EV->rotation);
}
void Events::listener_pinchEnd(wl_listener* listener, void* data) {
const auto EV = (wlr_pointer_pinch_end_event*)data;
wlr_pointer_gestures_v1_send_pinch_end(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->cancelled);
}
void Events::listener_newVirtualKeyboard(wl_listener* listener, void* data) {
const auto WLRKB = (wlr_virtual_keyboard_v1*)data;
g_pInputManager->newVirtualKeyboard(&WLRKB->keyboard.base);
}
void Events::listener_touchBegin(wl_listener* listener, void* data) {
g_pInputManager->onTouchDown((wlr_touch_down_event*)data);
}
void Events::listener_touchEnd(wl_listener* listener, void* data) {
g_pInputManager->onTouchUp((wlr_touch_up_event*)data);
}
void Events::listener_touchUpdate(wl_listener* listener, void* data) {
g_pInputManager->onTouchMove((wlr_touch_motion_event*)data);
}

View File

@@ -12,6 +12,9 @@ namespace Events {
LISTENER(change);
LISTENER(newOutput);
// DRM events
LISTENER(leaseRequest);
// Layer events
LISTENER(newLayerSurface);
DYNLISTENFUNC(destroyLayerSurface);
@@ -50,6 +53,10 @@ namespace Events {
DYNLISTENFUNC(activateX11);
DYNLISTENFUNC(configureX11);
DYNLISTENFUNC(unmanagedSetGeometry);
DYNLISTENFUNC(requestMove);
DYNLISTENFUNC(requestResize);
DYNLISTENFUNC(requestMinimize);
DYNLISTENFUNC(requestMaximize);
// Window subsurfaces
// LISTENER(newSubsurfaceWindow);
@@ -116,7 +123,33 @@ namespace Events {
LISTENER(newIdleInhibitor);
// session
LISTENER(sessionActive);
// Touchpad shit
LISTENER(swipeBegin);
LISTENER(swipeEnd);
LISTENER(swipeUpdate);
LISTENER(pinchBegin);
LISTENER(pinchUpdate);
LISTENER(pinchEnd);
// Power
LISTENER(powerMgrSetMode);
// IME
LISTENER(newIME);
LISTENER(newTextInput);
LISTENER(newVirtualKeyboard);
// IME Popups
DYNLISTENFUNC(mapInputPopup);
DYNLISTENFUNC(unmapInputPopup);
DYNLISTENFUNC(commitInputPopup);
DYNLISTENFUNC(destroyInputPopup);
// Touch
LISTENER(touchBegin);
LISTENER(touchEnd);
LISTENER(touchUpdate);
};

View File

@@ -31,8 +31,8 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
WLRLAYERSURFACE->output = PMONITOR->output;
}
const auto PMONITOR = (SMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].emplace_back(new SLayerSurface());
const auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].emplace_back(std::make_unique<SLayerSurface>()).get();
layerSurface->szNamespace = WLRLAYERSURFACE->_namespace;
@@ -41,7 +41,7 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
}
layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_destroyLayerSurface.initCallback(&WLRLAYERSURFACE->surface->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_unmapLayerSurface.initCallback(&WLRLAYERSURFACE->events.unmap, &Events::listener_unmapLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_newPopup.initCallback(&WLRLAYERSURFACE->events.new_popup, &Events::listener_newPopup, layerSurface, "layerSurface");
@@ -66,12 +66,20 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID))
Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)");
if (!layersurface->fadingOut && PMONITOR) {
Debug::log(LOG, "Removing LayerSurface that wasn't mapped.");
layersurface->alpha.setValueAndWarp(0.f);
layersurface->fadingOut = true;
if (!layersurface->fadingOut) {
if (layersurface->mapped) {
Debug::log(LOG, "Forcing an unmap of a LS that did a straight destroy!");
listener_unmapLayerSurface(layersurface, nullptr);
} else {
Debug::log(LOG, "Removing LayerSurface that wasn't mapped.");
layersurface->alpha.setValueAndWarp(0.f);
layersurface->fadingOut = true;
g_pCompositor->addToFadingOutSafe(layersurface);
}
}
layersurface->noProcess = true;
layersurface->hyprListener_commitLayerSurface.removeCallback();
layersurface->hyprListener_destroyLayerSurface.removeCallback();
layersurface->hyprListener_mapLayerSurface.removeCallback();
@@ -81,7 +89,7 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
// rearrange to fix the reserved areas
if (PMONITOR) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
PMONITOR->scheduledRecalc = true;
// and damage
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
@@ -98,8 +106,10 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
Debug::log(LOG, "LayerSurface %x mapped", layersurface->layerSurface);
layersurface->layerSurface->mapped = true;
layersurface->mapped = true;
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
// anim
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn"));
// fix if it changed its mon
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
@@ -109,22 +119,28 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
POLDMON->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].push_back(layersurface);
for (auto it = POLDMON->m_aLayerSurfaceLists[layersurface->layer].begin(); it != POLDMON->m_aLayerSurfaceLists[layersurface->layer].end(); it++) {
if (it->get() == layersurface) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].emplace_back(std::move(*it));
POLDMON->m_aLayerSurfaceLists[layersurface->layer].erase(it);
break;
}
}
layersurface->monitorID = PMONITOR->ID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
PMONITOR->scheduledRecalc = true;
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->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
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);
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
// mouse enter always, keeb only when needed
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y);
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y);
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y);
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y);
}
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
@@ -142,18 +158,31 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
Debug::log(LOG, "LayerSurface %x unmapped", layersurface->layerSurface);
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID)) {
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID) || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(layersurface);
layersurface->mapped = false;
layersurface->fadingOut = true;
layersurface->alpha.setValueAndWarp(0.f);
return;
}
// anim
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeOut"));
// make a snapshot and start fade
g_pHyprOpenGL->makeLayerSnapshot(layersurface);
layersurface->alpha = 0.f;
layersurface->mapped = false;
layersurface->fadingOut = true;
g_pCompositor->m_vSurfacesFadingOut.push_back(layersurface);
g_pCompositor->addToFadingOutSafe(layersurface);
if (layersurface->layerSurface->mapped)
layersurface->layerSurface->mapped = false;
@@ -190,29 +219,49 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
if (!PMONITOR)
return;
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
wlr_box geomFixed = {layersurface->geometry.x, layersurface->geometry.y, layersurface->geometry.width, layersurface->geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
// fix if it changed its mon
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
POLDMON->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].push_back(layersurface);
for (auto it = POLDMON->m_aLayerSurfaceLists[layersurface->layer].begin(); it != POLDMON->m_aLayerSurfaceLists[layersurface->layer].end(); it++) {
if (it->get() == layersurface) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].emplace_back(std::move(*it));
POLDMON->m_aLayerSurfaceLists[layersurface->layer].erase(it);
break;
}
}
layersurface->monitorID = PMONITOR->ID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
PMONITOR->scheduledRecalc = true;
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
}
if (layersurface->layerSurface->current.committed != 0) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
if (layersurface->layer != layersurface->layerSurface->current.layer) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].push_back(layersurface);
for (auto it = PMONITOR->m_aLayerSurfaceLists[layersurface->layer].begin(); it != PMONITOR->m_aLayerSurfaceLists[layersurface->layer].end(); it++) {
if (it->get() == layersurface) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].emplace_back(std::move(*it));
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].erase(it);
break;
}
}
layersurface->layer = layersurface->layerSurface->current.layer;
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
PMONITOR->scheduledRecalc = true;
}
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);

View File

@@ -25,6 +25,15 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
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) {
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);
@@ -103,16 +112,31 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
g_pInputManager->m_sDrag.hyprListener_destroyIcon.initCallback(&wlrDrag->icon->events.destroy, &Events::listener_destroyDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
g_pInputManager->m_sDrag.hyprListener_commitIcon.initCallback(&wlrDrag->icon->surface->events.commit, &Events::listener_commitDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
}
static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
if (*PFOLLOWONDND)
g_pInputManager->m_pFollowOnDnDBegin = g_pCompositor->m_pLastWindow;
else
g_pInputManager->m_pFollowOnDnDBegin = nullptr;
}
void Events::listener_destroyDrag(void* owner, void* data) {
Debug::log(LOG, "Drag destroyed.");
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.dragIcon = nullptr;
g_pInputManager->m_sDrag.hyprListener_destroy.removeCallback();
g_pInputManager->refocus();
if (g_pInputManager->m_pFollowOnDnDBegin)
g_pCompositor->focusWindow(g_pInputManager->m_pFollowOnDnDBegin);
g_pInputManager->m_pFollowOnDnDBegin = nullptr;
}
void Events::listener_mapDragIcon(void* owner, void* data) {
@@ -157,4 +181,33 @@ void Events::listener_InhibitDeactivate(wl_listener* listener, void* data) {
void Events::listener_RendererDestroy(wl_listener* listener, void* data) {
Debug::log(LOG, "!!Renderer destroyed!!");
}
void Events::listener_sessionActive(wl_listener* listener, void* data) {
Debug::log(LOG, "Session got activated!");
g_pCompositor->m_bSessionActive = true;
}
void Events::listener_powerMgrSetMode(wl_listener* listener, void* data) {
Debug::log(LOG, "PowerMgr set mode!");
const auto EVENT = (wlr_output_power_v1_set_mode_event*)data;
wlr_output_enable(EVENT->output, EVENT->mode == 1);
if (!wlr_output_commit(EVENT->output))
Debug::log(ERR, "Couldn't set power mode");
}
void Events::listener_newIME(wl_listener* listener, void* data) {
Debug::log(LOG, "New IME added!");
g_pInputManager->m_sIMERelay.onNewIME((wlr_input_method_v2*)data);
}
void Events::listener_newTextInput(wl_listener* listener, void* data) {
Debug::log(LOG, "New TextInput added!");
g_pInputManager->m_sIMERelay.onNewTextInput((wlr_text_input_v3*)data);
}

View File

@@ -15,7 +15,7 @@
// //
// --------------------------------------------------------- //
SMonitor* pMostHzMonitor = nullptr;
CMonitor* pMostHzMonitor = nullptr;
void Events::listener_change(wl_listener* listener, void* data) {
// layout got changed, let's update monitors.
@@ -53,118 +53,55 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
return;
}
if (g_pCompositor->getMonitorFromName(std::string(OUTPUT->name))) {
Debug::log(WARN, "Monitor with name %s already exists, not adding as new!", OUTPUT->name);
return;
if (g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Recovering from an unsafe state. May you be lucky.");
}
// get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
// add it to real
std::shared_ptr<CMonitor>* PNEWMONITORWRAP = nullptr;
// if it's disabled, disable and ignore
if (monitorRule.disabled) {
wlr_output_enable(OUTPUT, 0);
wlr_output_commit(OUTPUT);
if (const auto PMONITOR = g_pCompositor->getMonitorFromName(std::string(OUTPUT->name)); PMONITOR) {
listener_monitorDestroy(nullptr, PMONITOR->output);
for (auto& rm : g_pCompositor->m_vRealMonitors) {
if (rm->szName == OUTPUT->name) {
PNEWMONITORWRAP = &rm;
Debug::log(LOG, "Recovering a removed monitor.");
break;
}
return;
}
SMonitor newMonitor;
newMonitor.output = OUTPUT;
newMonitor.ID = g_pCompositor->getNextAvailableMonitorID();
newMonitor.szName = OUTPUT->name;
if (!PNEWMONITORWRAP) {
Debug::log(LOG, "Adding completely new monitor.");
PNEWMONITORWRAP = &g_pCompositor->m_vRealMonitors.emplace_back(std::make_shared<CMonitor>());
wlr_output_init_render(OUTPUT, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
wlr_output_set_scale(OUTPUT, 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
newMonitor.vecPosition = monitorRule.offset;
newMonitor.vecSize = monitorRule.resolution;
newMonitor.refreshRate = monitorRule.refreshRate;
const auto PNEWMONITOR = g_pCompositor->m_vMonitors.emplace_back(std::make_unique<SMonitor>(newMonitor)).get();
PNEWMONITOR->hyprListener_monitorFrame.initCallback(&OUTPUT->events.frame, &Events::listener_monitorFrame, PNEWMONITOR);
PNEWMONITOR->hyprListener_monitorDestroy.initCallback(&OUTPUT->events.destroy, &Events::listener_monitorDestroy, PNEWMONITOR);
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
g_pHyprRenderer->applyMonitorRule(PNEWMONITOR, &monitorRule, true);
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", OUTPUT->name, (int)monitorRule.offset.x, (int)monitorRule.offset.y, (int)monitorRule.resolution.x, (int)monitorRule.resolution.y, OUTPUT);
PNEWMONITOR->damage = wlr_output_damage_create(PNEWMONITOR->output);
// add a WLR workspace group
PNEWMONITOR->pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
wlr_ext_workspace_group_handle_v1_output_enter(PNEWMONITOR->pWLRWorkspaceGroupHandle, PNEWMONITOR->output);
// Workspace
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);
(*PNEWMONITORWRAP)->ID = g_pCompositor->getNextAvailableMonitorID();
}
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
const auto PNEWMONITOR = PNEWMONITORWRAP->get();
Debug::log(LOG, "New monitor: WORKSPACEID %d, exists: %d", WORKSPACEID, (int)(PNEWWORKSPACE != nullptr));
PNEWMONITOR->output = OUTPUT;
PNEWMONITOR->m_pThisWrap = PNEWMONITORWRAP;
if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor
g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, PNEWMONITOR);
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID);
PNEWWORKSPACE->startAnim(true,true,true);
} else {
PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(newMonitor.ID, newDefaultWorkspaceName)).get();
PNEWMONITOR->onConnect(false);
// 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;
}
PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID;
PNEWMONITOR->scale = monitorRule.scale;
PNEWMONITOR->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);
//
if (!pMostHzMonitor || monitorRule.refreshRate > pMostHzMonitor->refreshRate)
if ((!pMostHzMonitor || PNEWMONITOR->refreshRate > pMostHzMonitor->refreshRate) && PNEWMONITOR->m_bEnabled)
pMostHzMonitor = PNEWMONITOR;
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
g_pCompositor->m_pLastMonitor = PNEWMONITOR;
g_pEventManager->postEvent(SHyprIPCEvent("monitoradded", PNEWMONITOR->szName));
// ready to process cuz we have a monitor
g_pCompositor->m_bReadyToProcess = true;
if (PNEWMONITOR->m_bEnabled) {
g_pCompositor->m_bReadyToProcess = true;
g_pCompositor->m_bUnsafeState = false;
}
}
void Events::listener_monitorFrame(void* owner, void* data) {
SMonitor* const PMONITOR = (SMonitor*)owner;
CMonitor* const PMONITOR = (CMonitor*)owner;
if ((g_pCompositor->m_sWLRSession && !g_pCompositor->m_sWLRSession->active) || !g_pCompositor->m_bSessionActive || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Attempted to render frame on inactive session!");
return; // cannot draw on session inactive (different tty)
}
if (!PMONITOR->m_bEnabled)
return;
static std::chrono::high_resolution_clock::time_point startRender = std::chrono::high_resolution_clock::now();
static std::chrono::high_resolution_clock::time_point startRenderOverlay = std::chrono::high_resolution_clock::now();
@@ -177,18 +114,33 @@ void Events::listener_monitorFrame(void* owner, void* data) {
static int damageBlinkCleanup = 0; // because double-buffered
if (!*PDAMAGEBLINK)
damageBlinkCleanup = 0;
if (*PDEBUGOVERLAY == 1) {
startRender = std::chrono::high_resolution_clock::now();
g_pDebugOverlay->frameData(PMONITOR);
}
if (PMONITOR->framesToSkip > 0) {
PMONITOR->framesToSkip -= 1;
if (!PMONITOR->noFrameSchedule)
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
else {
Debug::log(LOG, "NoFrameSchedule hit for %s.", PMONITOR->szName.c_str());
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
if (PMONITOR->framesToSkip > 10)
PMONITOR->framesToSkip = 0;
return;
}
// checks //
if (PMONITOR->ID == pMostHzMonitor->ID || !*PNOVFR) { // unfortunately with VFR we don't have the guarantee mostHz is going to be updated all the time, so we have to ignore that
g_pCompositor->sanityCheckWorkspaces();
g_pAnimationManager->tick();
g_pCompositor->cleanupFadingOut();
HyprCtl::tickHyprCtl(); // so that we dont get that race condition multithread bullshit
g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd
@@ -199,16 +151,9 @@ void Events::listener_monitorFrame(void* owner, void* data) {
}
// //
if (PMONITOR->framesToSkip > 0) {
PMONITOR->framesToSkip -= 1;
if (!PMONITOR->noFrameSchedule)
wlr_output_schedule_frame(PMONITOR->output);
else {
Debug::log(LOG, "NoFrameSchedule hit for %s.", PMONITOR->szName.c_str());
}
if (PMONITOR->scheduledRecalc) {
PMONITOR->scheduledRecalc = false;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
return;
}
timespec now;
@@ -224,34 +169,39 @@ void Events::listener_monitorFrame(void* owner, void* data) {
return;
}
g_pHyprOpenGL->preRender(PMONITOR);
if (!wlr_output_damage_attach_render(PMONITOR->damage, &hasChanged, &damage)){
Debug::log(ERR, "Couldn't attach render to display %s ???", PMONITOR->szName.c_str());
return;
}
// we need to cleanup fading out when rendering the appropriate context
g_pCompositor->cleanupFadingOut(PMONITOR->ID);
if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE && PMONITOR->forceFullFrames == 0 && damageBlinkCleanup == 0) {
pixman_region32_fini(&damage);
wlr_output_rollback(PMONITOR->output);
if (*PDAMAGEBLINK || *PNOVFR)
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
return;
}
// 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) {
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);
} 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 (*PBLURENABLED == 1) {
// TODO: can this be optimized?
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 PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->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.
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
@@ -263,8 +213,12 @@ void Events::listener_monitorFrame(void* owner, void* data) {
}
}
if (PMONITOR->forceFullFrames > 0)
if (PMONITOR->forceFullFrames > 0) {
PMONITOR->forceFullFrames -= 1;
if (PMONITOR->forceFullFrames > 10)
PMONITOR->forceFullFrames = 0;
}
// TODO: this is getting called with extents being 0,0,0,0 should it be?
// potentially can save on resources.
@@ -287,7 +241,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
}
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);
damageBlinkCleanup = 1;
} else if (*PDAMAGEBLINK) {
@@ -324,7 +278,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
wlr_output_commit(PMONITOR->output);
if (*PDAMAGEBLINK || *PNOVFR)
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
if (*PDEBUGOVERLAY == 1) {
const float µs = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - startRender).count() / 1000.f;
@@ -341,7 +295,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
void Events::listener_monitorDestroy(void* owner, void* data) {
const auto OUTPUT = (wlr_output*)data;
SMonitor* pMonitor = nullptr;
CMonitor* pMonitor = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->szName == OUTPUT->name) {
@@ -353,55 +307,25 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
if (!pMonitor)
return;
// Cleanup everything. Move windows back, snap cursor, shit.
const auto BACKUPMON = g_pCompositor->m_vMonitors.front().get();
pMonitor->onDisconnect();
if (!BACKUPMON) {
Debug::log(CRIT, "No monitors! Unplugged last! Exiting.");
g_pCompositor->cleanupExit();
exit(1);
return;
}
// cleanup if not unsafe
const auto BACKUPWORKSPACE = BACKUPMON->activeWorkspace > 0 ? std::to_string(BACKUPMON->activeWorkspace) : "name:" + g_pCompositor->getWorkspaceByID(BACKUPMON->activeWorkspace)->m_szName;
if (!g_pCompositor->m_bUnsafeState) {
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; }));
// 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);
if (pMostHzMonitor == pMonitor) {
int mostHz = 0;
CMonitor* pMonitorMostHz = nullptr;
// move workspaces
std::deque<CWorkspace*> wspToMove;
for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == pMonitor->ID) {
wspToMove.push_back(w.get());
}
}
for (auto& w : wspToMove) {
g_pCompositor->moveWorkspaceToMonitor(w, BACKUPMON);
w->startAnim(true, true, true);
}
pMonitor->activeWorkspace = -1;
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 == pMonitor->ID; }));
Debug::log(LOG, "Removed monitor %s!", pMonitor->szName.c_str());
g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName));
g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::unique_ptr<SMonitor>& el) { return el.get() == pMonitor; }));
if (pMostHzMonitor == pMonitor) {
int mostHz = 0;
SMonitor* pMonitorMostHz = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->refreshRate > mostHz) {
pMonitorMostHz = m.get();
mostHz = m->refreshRate;
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->refreshRate > mostHz) {
pMonitorMostHz = m.get();
mostHz = m->refreshRate;
}
}
}
pMostHzMonitor = pMonitorMostHz;
pMostHzMonitor = pMonitorMostHz;
}
}
}

View File

@@ -18,17 +18,21 @@
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
auto curPopup = PPOPUP;
int px = 0;
int py = 0;
auto curPopup = PPOPUP;
while (true) {
px += curPopup->popup->current.geometry.x;
py += curPopup->popup->current.geometry.y;
// fix oversized fucking popups
// kill me
if (curPopup->pSurfaceTree && curPopup->pSurfaceTree->pSurface && !curPopup->parentPopup) {
if (curPopup == PPOPUP && PPOPUP->parentWindow) {
px -= curPopup->popup->base->current.geometry.x;
py -= curPopup->popup->base->current.geometry.y;
}
if (curPopup->pSurfaceTree && curPopup->pSurfaceTree->pSurface && !curPopup->parentPopup && !curPopup->parentWindow) {
const auto EXTENTSSURFACE = pixman_region32_extents(&curPopup->pSurfaceTree->pSurface->input_region);
px -= EXTENTSSURFACE->x1;
py -= EXTENTSSURFACE->y1;
@@ -51,10 +55,11 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
pHyprPopup->popup = popup;
pHyprPopup->hyprListener_destroyPopupXDG.initCallback(&popup->base->surface->events.destroy, &Events::listener_destroyPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_destroyPopupXDG.initCallback(&popup->base->events.destroy, &Events::listener_destroyPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_mapPopupXDG.initCallback(&popup->base->events.map, &Events::listener_mapPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_unmapPopupXDG.initCallback(&popup->base->events.unmap, &Events::listener_unmapPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_newPopupFromPopupXDG.initCallback(&popup->base->events.new_popup, &Events::listener_newPopupFromPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_commitPopupXDG.initCallback(&popup->base->surface->events.commit, &Events::listener_commitPopupXDG, pHyprPopup, "HyprPopup");
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
@@ -144,6 +149,14 @@ void Events::listener_mapPopupXDG(void* owner, void* data) {
PPOPUP->pSurfaceTree = SubsurfaceTree::createTreeRoot(PPOPUP->popup->base->surface, addPopupGlobalCoords, PPOPUP, PPOPUP->parentWindow);
int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
wlr_box extents;
wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
g_pHyprRenderer->damageBox(lx - extents.x, ly - extents.y, extents.width + 2, extents.height + 2);
Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode %x", PPOPUP->pSurfaceTree);
}
@@ -155,9 +168,26 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
SubsurfaceTree::destroySurfaceTree(PPOPUP->pSurfaceTree);
int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
wlr_box extents;
wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
g_pHyprRenderer->damageBox(lx - extents.x, ly - extents.y, extents.width + 2, extents.height + 2);
PPOPUP->pSurfaceTree = nullptr;
}
void Events::listener_commitPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly);
}
void Events::listener_destroyPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;

View File

@@ -29,13 +29,28 @@ void addViewCoords(void* pWindow, int* x, int* y) {
}
}
int setAnimToMove(void* data) {
const auto PWINDOW = (CWindow*)data;
auto *const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
if (!g_pCompositor->windowValidMapped(PWINDOW))
return 0;
PWINDOW->m_vRealPosition.setConfig(PANIMCFG);
PWINDOW->m_vRealSize.setConfig(PANIMCFG);
return 0;
}
void Events::listener_mapWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
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 PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
const auto PWORKSPACE = PMONITOR->specialWorkspaceOpen ? g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
PWINDOW->m_iMonitorID = PMONITOR->ID;
PWINDOW->m_bMappedX11 = true;
@@ -44,18 +59,17 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bReadyToDelete = false;
PWINDOW->m_bFadingOut = false;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
PWINDOW->m_fAlpha = 255.f;
if (PWINDOW->m_iX11Type == 2)
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
// Set all windows tiled regardless of anything
g_pXWaylandManager->setWindowStyleTiled(PWINDOW, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
// Foreign Toplevel
PWINDOW->m_phForeignToplevel = wlr_foreign_toplevel_handle_v1_create(g_pCompositor->m_sWLRToplevelMgr);
// TODO: handle foreign events (requests)
wlr_foreign_toplevel_handle_v1_set_app_id(PWINDOW->m_phForeignToplevel, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str());
PWINDOW->createToplevelHandle();
// checks if the window wants borders and sets the appriopriate flag
g_pXWaylandManager->checkBorders(PWINDOW);
@@ -72,6 +86,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bRequestsFloat = true;
}
PWINDOW->m_bX11ShouldntFocus = PWINDOW->m_bX11ShouldntFocus || (PWINDOW->m_bIsX11 && PWINDOW->m_iX11Type == 2);
if (PWORKSPACE->m_bDefaultFloating)
PWINDOW->m_bIsFloating = true;
@@ -82,17 +98,20 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
}
CWindow* pFullscreenWindow = nullptr;
if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PFULLWINDOW, FULLSCREEN_FULL, false);
g_pXWaylandManager->setWindowFullscreen(PFULLWINDOW, PFULLWINDOW->m_bIsFullscreen);
pFullscreenWindow = PFULLWINDOW;
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
}
// window rules
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
std::string requestedWorkspace = "";
bool workspaceSilent = false;
bool requestsFullscreen = 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 shouldFocus = true;
for (auto& r : WINDOWRULES) {
if (r.szRule.find("monitor") == 0) {
@@ -103,13 +122,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_iMonitorID = PMONITOR->ID;
} else {
const long int MONITOR = std::stoi(MONITORSTR);
if (MONITOR >= (long int)g_pCompositor->m_vMonitors.size() || MONITOR < (long int)0)
if (!g_pCompositor->getMonitorFromID(MONITOR))
PWINDOW->m_iMonitorID = 0;
else
PWINDOW->m_iMonitorID = MONITOR;
}
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID));
Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);
} catch (std::exception& e) {
@@ -138,6 +158,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_sAdditionalConfigData.forceNoBlur = true;
} else if (r.szRule == "fullscreen") {
requestsFullscreen = true;
} else if (r.szRule == "opaque") {
PWINDOW->m_sAdditionalConfigData.forceOpaque = true;
} else if (r.szRule == "forceinput") {
PWINDOW->m_sAdditionalConfigData.forceAllowsInput = true;
} else if (r.szRule.find("rounding") == 0) {
try {
PWINDOW->m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
@@ -170,10 +194,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
// check for silent
if (requestedWorkspace.contains("silent")) {
workspaceSilent = true;
shouldFocus = false;
}
requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
if (!shouldFocus && requestedWorkspace == std::to_string(PMONITOR->activeWorkspace))
shouldFocus = true;
if (requestedWorkspace == "special") {
workspaceSilent = true;
}
@@ -206,6 +234,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY);
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
PWINDOW->m_bHidden = false;
} catch (...) {
Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
@@ -221,9 +251,13 @@ void Events::listener_mapWindow(void* owner, void* data) {
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);
PWINDOW->m_vRealPosition = Vector2D(POSX, POSY) + PMONITOR->vecPosition;
PWINDOW->m_bHidden = false;
} catch (...) {
Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
}
} else if (r.szRule == "center") {
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
}
}
@@ -238,19 +272,34 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10);
}
const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow;
if (PWINDOW->m_sAdditionalConfigData.forceAllowsInput) {
PWINDOW->m_bNoFocus = false;
PWINDOW->m_bNoInitialFocus = false;
PWINDOW->m_bX11ShouldntFocus = false;
}
if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus && PWINDOW->m_iX11Type != 2) {
g_pCompositor->focusWindow(PWINDOW);
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PACTIVEALPHA);
} else
PWINDOW->m_fDimPercent.setValueAndWarp(*PDIMSTRENGTH);
} else {
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PINACTIVEALPHA);
PWINDOW->m_fDimPercent.setValueAndWarp(0);
}
Debug::log(LOG, "Window got assigned a surfaceTreeNode %x", PWINDOW->m_pSurfaceTree);
if (!PWINDOW->m_bIsX11) {
PWINDOW->hyprListener_commitWindow.initCallback(&PWINDOW->m_uSurface.xdg->surface->events.commit, &Events::listener_commitWindow, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_newPopupXDG.initCallback(&PWINDOW->m_uSurface.xdg->events.new_popup, &Events::listener_newPopupXDG, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_requestMaximize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_requestMove.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_move, &Events::listener_requestMove, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_requestResize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_resize, &Events::listener_requestResize, PWINDOW, "XDG Window Late");
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XDG Window Late");
} else {
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XWayland Window Late");
PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late");
@@ -263,9 +312,16 @@ void Events::listener_mapWindow(void* owner, void* data) {
// do the animation thing
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false);
PWINDOW->m_fAlpha.setValueAndWarp(0.f);
PWINDOW->m_fAlpha = 255.f;
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);
if (workspaceSilent) {
// move the window
const auto OLDWORKSPACE = PWINDOW->m_iWorkspaceID;
if (g_pCompositor->m_pLastWindow == PWINDOW) {
if (requestedWorkspace != "special")
g_pKeybindManager->m_mDispatchers["movetoworkspacesilent"](requestedWorkspace);
@@ -274,6 +330,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
} else {
Debug::log(ERR, "Tried to set workspace silent rule to a nofocus window!");
}
g_pCompositor->forceReportSizesToWindowsOnWorkspace(OLDWORKSPACE);
}
if (requestsFullscreen) {
@@ -290,27 +348,50 @@ void Events::listener_mapWindow(void* owner, void* data) {
g_pCompositor->setWindowFullscreen(PWINDOW, true, FULLSCREEN_FULL);
}
if (pFullscreenWindow && workspaceSilent) {
g_pCompositor->setWindowFullscreen(pFullscreenWindow, true, PWORKSPACE->m_efFullscreenMode);
}
// recheck idle inhibitors
g_pInputManager->recheckIdleInhibitorStatus();
PWINDOW->m_pSurfaceTree = SubsurfaceTree::createTreeRoot(g_pXWaylandManager->getWindowSurface(PWINDOW), addViewCoords, PWINDOW, PWINDOW);
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);
}
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;
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())});
}
void Events::listener_unmapWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
Debug::log(LOG, "Window %x unmapped (class %s)", PWINDOW, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str());
g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", getFormat("%x", PWINDOW)});
if (!PWINDOW->m_bIsX11) {
Debug::log(LOG, "Unregistered late callbacks XDG: %x %x %x %x", &PWINDOW->hyprListener_commitWindow.m_sListener.link, &PWINDOW->hyprListener_setTitleWindow.m_sListener.link, &PWINDOW->hyprListener_fullscreenWindow.m_sListener.link, &PWINDOW->hyprListener_newPopupXDG.m_sListener.link);
Debug::log(LOG, "Unregistered late callbacks XDG");
PWINDOW->hyprListener_commitWindow.removeCallback();
PWINDOW->hyprListener_setTitleWindow.removeCallback();
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
PWINDOW->hyprListener_newPopupXDG.removeCallback();
PWINDOW->hyprListener_requestMaximize.removeCallback();
PWINDOW->hyprListener_requestMinimize.removeCallback();
PWINDOW->hyprListener_requestMove.removeCallback();
PWINDOW->hyprListener_requestResize.removeCallback();
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
} else {
Debug::log(LOG, "Unregistered late callbacks XWL: %x %x %x %x", &PWINDOW->hyprListener_fullscreenWindow.m_sListener.link, &PWINDOW->hyprListener_activateX11.m_sListener.link, &PWINDOW->hyprListener_configureX11.m_sListener.link, &PWINDOW->hyprListener_setTitleWindow.m_sListener.link);
Debug::log(LOG, "Unregistered late callbacks XWL");
PWINDOW->hyprListener_fullscreenWindow.removeCallback();
PWINDOW->hyprListener_activateX11.removeCallback();
PWINDOW->hyprListener_configureX11.removeCallback();
@@ -321,18 +402,20 @@ void Events::listener_unmapWindow(void* owner, void* data) {
if (PWINDOW->m_bIsFullscreen) {
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, false);
g_pXWaylandManager->setWindowFullscreen(PWINDOW, PWINDOW->m_bIsFullscreen);
g_pCompositor->forceReportSizesToWindowsOnWorkspace(PWINDOW->m_iWorkspaceID);
}
// Allow the renderer to catch the last frame.
g_pHyprOpenGL->makeWindowSnapshot(PWINDOW);
bool wasLastWindow = false;
if (PWINDOW == g_pCompositor->m_pLastWindow) {
wasLastWindow = true;
g_pCompositor->m_pLastWindow = nullptr;
g_pCompositor->m_pLastFocus = nullptr;
}
PWINDOW->m_fAlpha = 0.f;
PWINDOW->m_bMappedX11 = false;
// remove the fullscreen window status from workspace if we closed it
@@ -346,8 +429,27 @@ void Events::listener_unmapWindow(void* owner, void* data) {
// do this after onWindowRemoved because otherwise it'll think the window is invalid
PWINDOW->m_bIsMapped = false;
// refocus on a new window
g_pInputManager->refocus();
// refocus on a new window if needed
if (wasLastWindow) {
auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f);
if (PWORKSPACE->m_bHasFullscreenWindow && ((!PWINDOWCANDIDATE || !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);
if (PWINDOWCANDIDATE != g_pCompositor->m_pLastWindow) {
if (!PWINDOWCANDIDATE)
g_pInputManager->refocus();
else
g_pCompositor->focusWindow(PWINDOWCANDIDATE);
}
} else {
Debug::log(LOG, "Unmapped was not focused, ignoring a refocus.");
}
Debug::log(LOG, "Destroying the SubSurface tree of unmapped window %x", PWINDOW);
SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree);
@@ -356,7 +458,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
PWINDOW->m_bFadingOut = true;
g_pCompositor->m_vWindowsFadingOut.emplace_back(PWINDOW);
g_pCompositor->addToFadingOutSafe(PWINDOW);
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
@@ -368,11 +470,13 @@ void Events::listener_unmapWindow(void* owner, void* data) {
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
// anims
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
PWINDOW->m_fAlpha = 0.f;
// Destroy Foreign Toplevel
wlr_foreign_toplevel_handle_v1_destroy(PWINDOW->m_phForeignToplevel);
PWINDOW->m_phForeignToplevel = nullptr;
PWINDOW->destroyToplevelHandle();
// recheck idle inhibitors
g_pInputManager->recheckIdleInhibitorStatus();
@@ -426,10 +530,9 @@ void Events::listener_setTitleWindow(void* owner, void* data) {
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
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});
if (PWINDOW->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_title(PWINDOW->m_phForeignToplevel, PWINDOW->m_szTitle.c_str());
PWINDOW->updateToplevel();
Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str());
}
@@ -437,15 +540,27 @@ void Events::listener_setTitleWindow(void* owner, void* data) {
void Events::listener_fullscreenWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
if (!PWINDOW->m_bIsMapped) {
PWINDOW->m_bWantsInitialFullscreen = true;
return;
}
if (PWINDOW->m_bHidden)
return;
if (!PWINDOW->m_bIsX11) {
const auto REQUESTED = &PWINDOW->m_uSurface.xdg->toplevel->requested;
if (REQUESTED->fullscreen != PWINDOW->m_bIsFullscreen)
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, REQUESTED->fullscreen);
g_pCompositor->setWindowFullscreen(PWINDOW, REQUESTED->fullscreen, FULLSCREEN_FULL);
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
} else {
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW, FULLSCREEN_FULL, !PWINDOW->m_bIsFullscreen);
g_pCompositor->setWindowFullscreen(PWINDOW, !PWINDOW->m_bIsFullscreen, FULLSCREEN_FULL);
}
PWINDOW->updateToplevel();
Debug::log(LOG, "Window %x fullscreen to %i", PWINDOW, PWINDOW->m_bIsFullscreen);
g_pXWaylandManager->setWindowFullscreen(PWINDOW, PWINDOW->m_bIsFullscreen);
@@ -472,7 +587,7 @@ void Events::listener_configureX11(void* owner, void* data) {
const auto E = (wlr_xwayland_surface_configure_event*)data;
g_pHyprRenderer->damageWindow(PWINDOW);
if (!PWINDOW->m_bIsFloating) {
if (!PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen) {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.vec());
g_pInputManager->refocus();
g_pHyprRenderer->damageWindow(PWINDOW);
@@ -484,6 +599,11 @@ void Events::listener_configureX11(void* owner, void* data) {
return;
}
if (E->width > 1 && E->height > 1)
PWINDOW->m_bHidden = false;
else
PWINDOW->m_bHidden = true;
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
@@ -491,6 +611,8 @@ void Events::listener_configureX11(void* owner, void* data) {
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace;
g_pCompositor->moveWindowToTop(PWINDOW);
PWINDOW->m_bCreatedOverFullscreen = true;
@@ -498,6 +620,8 @@ void Events::listener_configureX11(void* owner, void* data) {
g_pInputManager->refocus();
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->updateWindowDecos();
}
void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
@@ -509,14 +633,22 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
const auto POS = PWINDOW->m_vRealPosition.goalv();
const auto SIZ = PWINDOW->m_vRealSize.goalv();
if (abs(floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 || abs(floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) {
if (PWINDOW->m_uSurface.xwayland->width > 1 && PWINDOW->m_uSurface.xwayland->height > 1)
PWINDOW->m_bHidden = false;
else
PWINDOW->m_bHidden = true;
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);
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y));
if (abs(floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2)
if (abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2)
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(PWINDOW->m_uSurface.xwayland->width, PWINDOW->m_uSurface.xwayland->height));
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.vec());
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace;
g_pCompositor->moveWindowToTop(PWINDOW);
PWINDOW->updateWindowDecos();
g_pHyprRenderer->damageWindow(PWINDOW);
@@ -547,10 +679,10 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
// A window got opened
const auto XDGSURFACE = (wlr_xdg_surface*)data;
Debug::log(LOG, "New XDG Surface created. (class: %s)", XDGSURFACE->toplevel->app_id);
if (XDGSURFACE->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
return; // TODO: handle?
return;
Debug::log(LOG, "New XDG Surface created. (class: %s)", XDGSURFACE->toplevel->app_id);
const auto PNEWWINDOW = g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
@@ -564,3 +696,28 @@ void Events::listener_NewXDGDeco(wl_listener* listener, void* data) {
const auto WLRDECO = (wlr_xdg_toplevel_decoration_v1*)data;
wlr_xdg_toplevel_decoration_v1_set_mode(WLRDECO, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
void Events::listener_requestMaximize(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
// ignore
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
}
void Events::listener_requestMinimize(void* owner, void* data) {
// ignore
}
void Events::listener_requestMove(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
// ignore
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
}
void Events::listener_requestResize(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
// ignore
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
}

View File

@@ -1,25 +1,24 @@
#include "AnimatedVariable.hpp"
#include "../managers/AnimationManager.hpp"
#include "../config/ConfigManager.hpp"
CAnimatedVariable::CAnimatedVariable() {
; // dummy var
}
void CAnimatedVariable::create(ANIMATEDVARTYPE type, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY policy) {
void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
m_eVarType = type;
m_eDamagePolicy = policy;
m_pSpeed = speed;
m_pEnabled = enabled;
m_pConfig = pAnimConfig;
m_pWindow = pWindow;
m_pBezier = pBezier;
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
m_bDummy = false;
}
void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY policy) {
create(type, speed, enabled, pBezier, pWindow, policy);
void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
create(type, pAnimConfig, pWindow, policy);
try {
switch (type) {
@@ -57,4 +56,8 @@ CAnimatedVariable::~CAnimatedVariable() {
void CAnimatedVariable::unregister() {
g_pAnimationManager->m_lAnimatedVariables.remove(this);
}
}
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);
}

View File

@@ -13,19 +13,21 @@ enum ANIMATEDVARTYPE {
enum AVARDAMAGEPOLICY {
AVARDAMAGE_INVALID = -1,
AVARDAMAGE_ENTIRE = 0,
AVARDAMAGE_BORDER
AVARDAMAGE_BORDER,
AVARDAMAGE_SHADOW
};
class CAnimationManager;
class CWorkspace;
struct SLayerSurface;
struct SAnimationPropertyConfig;
class CAnimatedVariable {
public:
CAnimatedVariable(); // dummy var
void create(ANIMATEDVARTYPE, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY);
void create(ANIMATEDVARTYPE, std::any val, float* speed, int64_t* enabled, std::string* pBezier, void* pWindow, AVARDAMAGEPOLICY);
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
void create(ANIMATEDVARTYPE, std::any val, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
~CAnimatedVariable();
@@ -128,10 +130,12 @@ public:
case AVARTYPE_COLOR:
return m_cValue != m_cGoal;
default:
std::unreachable();
UNREACHABLE();
}
std::unreachable();
UNREACHABLE();
return false; // just so that the warning is suppressed
}
void warp() {
@@ -149,10 +153,20 @@ public:
break;
}
default:
std::unreachable();
UNREACHABLE();
}
}
void setConfig(SAnimationPropertyConfig* pConfig) {
m_pConfig = pConfig;
}
SAnimationPropertyConfig* getConfig() {
return m_pConfig;
}
int getDurationLeftMs();
private:
Vector2D m_vValue = Vector2D(0,0);
@@ -167,15 +181,12 @@ private:
float m_fBegun = 0;
CColor m_cBegun;
float* m_pSpeed = nullptr;
int64_t* m_pEnabled = nullptr;
// owners
void* m_pWindow = nullptr;
void* m_pWorkspace = nullptr;
void* m_pLayer = nullptr;
std::string* m_pBezier = nullptr;
SAnimationPropertyConfig* m_pConfig = nullptr;
bool m_bDummy = true;

View File

@@ -3,6 +3,7 @@
#include <algorithm>
#include "../Compositor.hpp"
#include <sys/utsname.h>
#include <iomanip>
static const float transforms[][9] = {{
1.0f, 0.0f, 0.0f,
@@ -39,6 +40,28 @@ static const float transforms[][9] = {{
},
};
std::string absolutePath(const std::string& rawpath, const std::string& currentPath) {
auto value = rawpath;
if (value[0] == '.') {
auto currentDir = currentPath.substr(0, currentPath.find_last_of('/'));
if (value[1] == '.') {
auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
value.replace(0, 2, parentDir);
} else {
value.replace(0, 1, currentDir);
}
}
if (value[0] == '~') {
static const char* const ENVHOME = getenv("HOME");
value.replace(0, 1, std::string(ENVHOME));
}
return value;
}
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) {
ASSERT(pSignal);
ASSERT(pListener);
@@ -52,67 +75,43 @@ void handleNoop(struct wl_listener *listener, void *data) {
// Do nothing
}
void wlr_signal_emit_safe(struct wl_signal *signal, void *data) {
struct wl_listener cursor;
struct wl_listener end;
/* Add two special markers: one cursor and one end marker. This way, we know
* that we've already called listeners on the left of the cursor and that we
* don't want to call listeners on the right of the end marker. The 'it'
* function can remove any element it wants from the list without troubles.
* wl_list_for_each_safe tries to be safe but it fails: it works fine
* if the current item is removed, but not if the next one is. */
wl_list_insert(&signal->listener_list, &cursor.link);
cursor.notify = handleNoop;
wl_list_insert(signal->listener_list.prev, &end.link);
end.notify = handleNoop;
while (cursor.link.next != &end.link) {
struct wl_list *pos = cursor.link.next;
struct wl_listener *l = wl_container_of(pos, l, link);
wl_list_remove(&cursor.link);
wl_list_insert(pos, &cursor.link);
l->notify(l, data);
}
wl_list_remove(&cursor.link);
wl_list_remove(&end.link);
}
std::string getFormat(const char *fmt, ...) {
char buf[LOGMESSAGESIZE] = "";
char* outputStr;
int logLen;
char* outputStr = nullptr;
va_list args;
va_start(args, fmt);
logLen = vsnprintf(buf, sizeof buf, fmt, args);
vasprintf(&outputStr, fmt, args);
va_end(args);
if ((long unsigned int)logLen < sizeof buf) {
outputStr = strdup(buf);
} else {
outputStr = (char*)malloc(logLen + 1);
if (!outputStr) {
printf("CRITICAL: Cannot alloc size %d for log! (Out of memory?)", logLen + 1);
return "";
}
va_start(args, fmt);
vsnprintf(outputStr, logLen + 1U, fmt, args);
va_end(args);
}
std::string output = std::string(outputStr);
free(outputStr);
return output;
}
std::string escapeJSONStrings(const std::string& str) {
std::ostringstream oss;
for (auto &c : str) {
switch (c) {
case '"': oss << "\\\""; break;
case '\\': oss << "\\\\"; break;
case '\b': oss << "\\b"; break;
case '\f': oss << "\\f"; break;
case '\n': oss << "\\n"; break;
case '\r': oss << "\\r"; break;
case '\t': oss << "\\t"; break;
default:
if ('\x00' <= c && c <= '\x1f') {
oss << "\\u"
<< std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
} else {
oss << c;
}
}
}
return oss.str();
}
void scaleBox(wlr_box* box, float scale) {
box->width = std::round(box->width * scale);
box->height = std::round(box->height * scale);
@@ -193,7 +192,9 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
}
outName = WORKSPACENAME;
} else {
if (in[0] == 'm') {
if (in[0] == 'm' || in[0] == 'e') {
bool onAllMonitors = in[0] == 'e';
if (!g_pCompositor->m_pLastMonitor) {
Debug::log(ERR, "Relative monitor workspace on monitor null!");
result = INT_MAX;
@@ -234,7 +235,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
}
if (const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(searchID); PWORKSPACE && PWORKSPACE->m_iID != SPECIAL_WORKSPACE_ID) {
if (PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) {
if (onAllMonitors || PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) {
currentID = PWORKSPACE->m_iID;
if (remains < 0)

View File

@@ -2,9 +2,10 @@
#include "../includes.hpp"
std::string absolutePath(const std::string&, const std::string&);
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
std::string escapeJSONStrings(const std::string& str);
void scaleBox(wlr_box*, float);
std::string removeBeginEndSpacesTabs(std::string);
bool isNumber(const std::string&, bool allowfloat = false);
@@ -16,4 +17,4 @@ std::string execAndGet(const char*);
float getPlusMinusKeywordResult(std::string in, float relative);
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);

248
src/helpers/Monitor.cpp Normal file
View File

@@ -0,0 +1,248 @@
#include "Monitor.hpp"
#include "../Compositor.hpp"
void CMonitor::onConnect(bool noRule) {
if (m_bEnabled)
return;
szName = output->name;
// get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name);
hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this);
hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this);
// if it's disabled, disable and ignore
if (monitorRule.disabled) {
wlr_output_enable_adaptive_sync(output, 1);
wlr_output_set_scale(output, 1);
wlr_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
auto PREFSTATE = wlr_output_preferred_mode(output);
if (!PREFSTATE) {
wlr_output_mode* mode;
wl_list_for_each(mode, &output->modes, link) {
wlr_output_set_mode(output, PREFSTATE);
if (!wlr_output_test(output))
continue;
PREFSTATE = mode;
break;
}
}
if (PREFSTATE)
wlr_output_set_mode(output, PREFSTATE);
else
Debug::log(WARN, "No mode found for disabled output %s", output->name);
wlr_output_enable(output, 0);
if (!wlr_output_commit(output)) {
Debug::log(ERR, "Couldn't commit disabled state on output %s", output->name);
}
Events::listener_change(nullptr, nullptr);
m_bEnabled = false;
hyprListener_monitorFrame.removeCallback();
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) {
wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
m_bRenderingInitPassed = true;
}
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);
}
m_bEnabled = true;
wlr_output_set_scale(output, 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
// create it in the arr
vecPosition = monitorRule.offset;
vecSize = monitorRule.resolution;
refreshRate = monitorRule.refreshRate;
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
if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true);
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x, (int)vecPixelSize.y, output);
damage = wlr_output_damage_create(output);
// add a WLR workspace group
if (!pWLRWorkspaceGroupHandle) {
pWLRWorkspaceGroupHandle = wlr_ext_workspace_group_handle_v1_create(g_pCompositor->m_sWLREXTWorkspaceMgr);
}
wlr_ext_workspace_group_handle_v1_output_enter(pWLRWorkspaceGroupHandle, output);
// Workspace
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;
m_pThisWrap = nullptr;
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);
//
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
g_pCompositor->m_pLastMonitor = this;
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
g_pHyprRenderer->arrangeLayersForMonitor(ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
}
void CMonitor::onDisconnect() {
if (!m_bEnabled)
return;
// Cleanup everything. Move windows back, snap cursor, shit.
CMonitor* BACKUPMON = nullptr;
for (auto& m : g_pCompositor->m_vMonitors) {
if (m.get() != this) {
BACKUPMON = m.get();
break;
}
}
m_bEnabled = false;
m_bRenderingInitPassed = false;
hyprListener_monitorFrame.removeCallback();
if (!BACKUPMON) {
Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend.");
hyprListener_monitorMode.removeCallback();
hyprListener_monitorDestroy.removeCallback();
g_pCompositor->m_bUnsafeState = true;
return;
}
const auto BACKUPWORKSPACE = BACKUPMON->activeWorkspace > 0 ? std::to_string(BACKUPMON->activeWorkspace) : "name:" + g_pCompositor->getWorkspaceByID(BACKUPMON->activeWorkspace)->m_szName;
// 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);
// move workspaces
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_damage_destroy(damage);
wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output);
wlr_output_enable(output, false);
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; }));
Debug::log(LOG, "Removed monitor %s!", szName.c_str());
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; }));
}
void CMonitor::addDamage(pixman_region32_t* rg) {
wlr_output_damage_add(damage, rg);
}
void CMonitor::addDamage(wlr_box* box) {
wlr_output_damage_add_box(damage, box);
}

View File

@@ -3,10 +3,12 @@
#include "../defines.hpp"
#include <deque>
#include "WLClasses.hpp"
#include <list>
#include <vector>
#include <array>
#include <memory>
struct SMonitor {
class CMonitor {
public:
Vector2D vecPosition = Vector2D(0,0);
Vector2D vecSize = Vector2D(0,0);
Vector2D vecPixelSize = Vector2D(0,0);
@@ -30,6 +32,7 @@ struct SMonitor {
int framesToSkip = 0;
int forceFullFrames = 0;
bool noFrameSchedule = false;
bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
// for the special workspace
@@ -38,7 +41,7 @@ struct SMonitor {
// 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
// and I am lazy
std::array<std::list<SLayerSurface*>, 4> m_aLayerSurfaceLists;
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLists;
DYNLISTENER(monitorFrame);
DYNLISTENER(monitorDestroy);
@@ -49,9 +52,19 @@ struct SMonitor {
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
// methods
void onConnect(bool noRule);
void onDisconnect();
void addDamage(pixman_region32_t* rg);
void addDamage(wlr_box* box);
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
bool m_bEnabled = false;
bool m_bRenderingInitPassed = false;
// For the list lookup
bool operator==(const SMonitor& rhs) {
bool operator==(const CMonitor& rhs) {
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
}
};

View File

@@ -21,9 +21,7 @@ void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) {
}
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
SubsurfaceTree::surfaceTreeNodes.push_back(SSurfaceTreeNode());
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.back();
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.emplace_back();
PNODE->pSurface = pSurface;
PNODE->pWindowOwner = pWindow;
@@ -128,8 +126,7 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
const auto PSUBSURFACE = (wlr_subsurface*)data;
pNode->childSubsurfaces.push_back(SSubsurface());
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.back();
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.emplace_back();
Debug::log(LOG, "Added a new subsurface %x", PSUBSURFACE);
@@ -142,6 +139,9 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
PNEWSUBSURFACE->pWindowOwner = pNode->pWindowOwner;
if (PSUBSURFACE->mapped)
listener_mapSubsurface(PNEWSUBSURFACE, nullptr);
wlr_subsurface* existingWlrSubsurface;
wl_list_for_each(existingWlrSubsurface, &PSUBSURFACE->surface->current.subsurfaces_below, current.link) {
listener_newSubsurfaceNode(pNode, existingWlrSubsurface);
@@ -171,12 +171,14 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
addSurfaceGlobalOffset(PNODE, &lx, &ly);
wlr_box extents = {0};
wlr_surface_get_extends(PNODE->pSurface, &extents);
if (PNODE->pSurface) {
wlr_surface_get_extends(PNODE->pSurface, &extents);
extents.x += lx;
extents.y += ly;
extents.x += lx;
extents.y += ly;
g_pHyprRenderer->damageBox(&extents);
g_pHyprRenderer->damageBox(&extents);
}
SubsurfaceTree::destroySurfaceTree(subsurface->pChild);
subsurface->pChild = nullptr;
@@ -188,7 +190,7 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
// no damaging if it's not visible
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)
Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner);
return;

View File

@@ -35,6 +35,10 @@ class Vector2D {
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 floor();

View File

@@ -2,6 +2,6 @@
#include "../config/ConfigManager.hpp"
SLayerSurface::SLayerSurface() {
alpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:fadein_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:fadein")->intValue, &g_pConfigManager->getConfigValuePtr("animations:fadein_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
alpha.m_pLayer = this;
}

View File

@@ -19,10 +19,12 @@ struct SLayerSurface {
DYNLISTENER(commitLayerSurface);
DYNLISTENER(newPopup);
wlr_box geometry;
wlr_box geometry = {0,0,0,0};
Vector2D position;
zwlr_layer_shell_v1_layer layer;
bool mapped = false;
int monitorID = -1;
std::string szNamespace = "";
@@ -30,6 +32,7 @@ struct SLayerSurface {
CAnimatedVariable alpha;
bool fadingOut = false;
bool readyToDelete = false;
bool noProcess = false;
bool forceBlur = false;
@@ -68,8 +71,11 @@ struct SRenderData {
// for blurring
bool blur = false;
// for windows that animate poorly
bool squishOversized = false;
// only for windows, not popups
bool squishOversized = true;
// for calculating UV
CWindow* pWindow = nullptr;
};
struct SExtensionFindingData {
@@ -91,11 +97,16 @@ struct SKeyboard {
DYNLISTENER(keyboardMod);
DYNLISTENER(keyboardKey);
DYNLISTENER(keyboardKeymap);
DYNLISTENER(keyboardDestroy);
bool isVirtual = false;
bool active = false;
xkb_layout_index_t activeLayout = 0;
std::string name = "";
std::string xkbFilePath = "";
SStringRuleNames currentRules;
int repeatRate = 0;
@@ -140,18 +151,19 @@ struct SConstraint {
}
};
struct SMonitor;
class CMonitor;
struct SXDGPopup {
CWindow* parentWindow = nullptr;
SXDGPopup* parentPopup = nullptr;
wlr_xdg_popup* popup = nullptr;
SMonitor* monitor = nullptr;
CMonitor* monitor = nullptr;
DYNLISTENER(newPopupFromPopupXDG);
DYNLISTENER(destroyPopupXDG);
DYNLISTENER(mapPopupXDG);
DYNLISTENER(unmapPopupXDG);
DYNLISTENER(commitPopupXDG);
double lx;
double ly;
@@ -267,5 +279,46 @@ struct SSwipeGesture {
float avgSpeed = 0;
int speedPoints = 0;
SMonitor* pMonitor = nullptr;
};
CMonitor* pMonitor = nullptr;
};
struct STextInput {
wlr_text_input_v3* pWlrInput = nullptr;
wlr_surface* pPendingSurface = nullptr;
DYNLISTENER(textInputEnable);
DYNLISTENER(textInputDisable);
DYNLISTENER(textInputCommit);
DYNLISTENER(textInputDestroy);
DYNLISTENER(pendingSurfaceDestroy);
};
struct SIMEKbGrab {
wlr_input_method_keyboard_grab_v2* pWlrKbGrab = nullptr;
wlr_keyboard* pKeyboard = nullptr;
DYNLISTENER(grabDestroy);
};
struct SIMEPopup {
wlr_input_popup_surface_v2* pSurface = nullptr;
int x, y;
int realX, realY;
bool visible;
Vector2D lastSize;
DYNLISTENER(mapPopup);
DYNLISTENER(unmapPopup);
DYNLISTENER(destroyPopup);
DYNLISTENER(commitPopup);
DYNLISTENER(focusedSurfaceUnmap);
bool operator==(const SIMEPopup& other) {
return pSurface == other.pSurface;
}
};

View File

@@ -4,9 +4,9 @@
#include "../debug/Log.hpp"
void handleWrapped(wl_listener* listener, void* data) {
CHyprWLListener* pListener = wl_container_of(listener, pListener, m_sListener);
CHyprWLListener::SWrapper* pWrap = wl_container_of(listener, pWrap, m_sListener);
pListener->emit(data);
pWrap->m_pSelf->emit(data);
}
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) {
@@ -14,7 +14,9 @@ CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, v
}
CHyprWLListener::CHyprWLListener() {
; //
m_swWrapper.m_pSelf = this;
m_swWrapper.m_sListener.notify = &handleWrapped;
wl_list_init(&m_swWrapper.m_sListener.link);
}
CHyprWLListener::~CHyprWLListener() {
@@ -22,31 +24,28 @@ CHyprWLListener::~CHyprWLListener() {
}
void CHyprWLListener::removeCallback() {
if (m_bIsConnected) {
Debug::log(LOG, "Callback %x -> %x, %s removed.", m_pCallback, m_pOwner, m_szAuthor.c_str());
wl_list_remove(&m_sListener.link);
if (isConnected()) {
Debug::log(LOG, "Callback %x -> %x, %s removed.", &m_pCallback, &m_pOwner, m_szAuthor.c_str());
wl_list_remove(&m_swWrapper.m_sListener.link);
wl_list_init(&m_swWrapper.m_sListener.link);
}
m_bIsConnected = false;
}
bool CHyprWLListener::isConnected() {
return m_bIsConnected;
return !wl_list_empty(&m_swWrapper.m_sListener.link);
}
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner, std::string author) {
if (m_bIsConnected)
removeCallback();
if (isConnected()) {
Debug::log(ERR, "Tried to connect a listener twice?!");
return;
}
m_pOwner = pOwner;
m_pCallback = callback;
m_szAuthor = author;
m_sListener.notify = &handleWrapped;
m_bIsConnected = true;
addWLSignal(pSignal, &m_sListener, pOwner, m_szAuthor);
addWLSignal(pSignal, &m_swWrapper.m_sListener, pOwner, m_szAuthor);
}
void CHyprWLListener::emit(void* data) {

View File

@@ -9,18 +9,26 @@ public:
CHyprWLListener();
~CHyprWLListener();
CHyprWLListener(const CHyprWLListener&) = delete;
CHyprWLListener(CHyprWLListener&&) = delete;
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
void removeCallback();
bool isConnected();
wl_listener m_sListener;
struct SWrapper {
wl_listener m_sListener;
CHyprWLListener* m_pSelf;
};
void emit(void*);
private:
bool m_bIsConnected = false;
SWrapper m_swWrapper;
void* m_pOwner = nullptr;

View File

@@ -26,9 +26,9 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
}
m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, 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.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, 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);
g_pEventManager->postEvent({"createworkspace", m_szName}, true);
@@ -49,7 +49,7 @@ CWorkspace::~CWorkspace() {
}
void CWorkspace::startAnim(bool in, bool left, bool instant) {
const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style");
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
if (ANIMSTYLE == "fade") {
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
@@ -119,4 +119,11 @@ void CWorkspace::moveToMonitor(const int& id) {
wlr_ext_workspace_handle_v1_set_urgent(m_pWlrHandle, false);
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
};
class CWindow;
class CWorkspace {
public:
CWorkspace(int monitorID, std::string name, bool special = false);
@@ -18,6 +20,9 @@ public:
int m_iID = -1;
std::string m_szName = "";
uint64_t m_iMonitorID = -1;
// Previous workspace ID is stored during a workspace change, allowing travel
// to the previous workspace.
int m_iPrevWorkspaceID = -1;
bool m_bHasFullscreenWindow = false;
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
@@ -33,6 +38,9 @@ public:
// "scratchpad"
bool m_bIsSpecialWorkspace = false;
// last window
CWindow* m_pLastFocusedWindow = nullptr;
// user-set
bool m_bDefaultFloating = false;
bool m_bDefaultPseudo = false;
@@ -41,4 +49,6 @@ public:
void setActive(bool on);
void moveToMonitor(const int&);
CWindow* getLastFocusedWindow();
};

View File

@@ -14,6 +14,8 @@ void CHyprError::createQueued() {
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
const auto FONTSIZE = std::clamp((int)(10.f * (PMONITOR->vecPixelSize.x / 1920.f)), 8, 40);
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
const auto CAIRO = cairo_create(CAIROSURFACE);
@@ -27,7 +29,7 @@ void CHyprError::createQueued() {
const auto LINECOUNT = 1 + std::count(m_szQueued.begin(), m_szQueued.end(), '\n');
cairo_set_source_rgba(CAIRO, m_cQueued.r / 255.f, m_cQueued.g / 255.f, m_cQueued.b / 255.f, m_cQueued.a / 255.f);
cairo_rectangle(CAIRO, 0, 0, PMONITOR->vecPixelSize.x, 10 * LINECOUNT);
cairo_rectangle(CAIRO, 0, 0, PMONITOR->vecPixelSize.x, (FONTSIZE + 2 * (FONTSIZE / 10.f)) * LINECOUNT);
// outline
cairo_rectangle(CAIRO, 0, 0, 1, PMONITOR->vecPixelSize.y); // left
@@ -40,10 +42,10 @@ void CHyprError::createQueued() {
const CColor textColor = m_cQueued.r * m_cQueued.g * m_cQueued.b < 0.5f ? CColor(255, 255, 255, 255) : CColor(0, 0, 0, 255);
cairo_select_font_face(CAIRO, "Noto Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(CAIRO, 8);
cairo_set_font_size(CAIRO, FONTSIZE);
cairo_set_source_rgba(CAIRO, textColor.r / 255.f, textColor.g / 255.f, textColor.b / 255.f, textColor.a / 255.f);
float yoffset = 8;
float yoffset = FONTSIZE;
while(m_szQueued != "") {
std::string current = m_szQueued.substr(0, m_szQueued.find('\n'));
if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos)
@@ -52,7 +54,7 @@ void CHyprError::createQueued() {
m_szQueued = "";
cairo_move_to(CAIRO, 0, yoffset);
cairo_show_text(CAIRO, current.c_str());
yoffset += 9;
yoffset += FONTSIZE + (FONTSIZE / 10.f);
}

View File

@@ -32,16 +32,20 @@
#define class _class
#define namespace _namespace
#define static
#define delete delete_
extern "C" {
#include <wlr/backend.h>
#include <wlr/backend/libinput.h>
#include <wlr/backend/drm.h>
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_control_v1.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_linux_dmabuf_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
@@ -93,8 +97,13 @@ extern "C" {
#include <wlr/types/wlr_xdg_foreign_v1.h>
#include <wlr/types/wlr_xdg_foreign_v2.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_output_power_management_v1.h>
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_text_input_v3.h>
#include <wlr/types/wlr_touch.h>
}
#undef delete
#undef class
#undef namespace
#undef static

View File

@@ -1,51 +1,38 @@
#include "DwindleLayout.hpp"
#include "../Compositor.hpp"
void SDwindleNodeData::recalcSizePosRecursive() {
// check the group, if we are in one and not active, ignore.
if (pGroupParent && pGroupParent->groupMembers[pGroupParent->groupMemberActive] != this) {
if (pWindow)
pWindow->m_bHidden = true;
return;
} else {
if (pWindow)
pWindow->m_bHidden = false;
}
if (pGroupParent) {
// means we are in a group and focused. let's just act like the full window in this
size = pGroupParent->size;
position = pGroupParent->position;
}
void SDwindleNodeData::recalcSizePosRecursive(bool force) {
if (children[0]) {
const auto REVERSESPLITRATIO = 2.f - splitRatio;
if (g_pConfigManager->getInt("dwindle:preserve_split") == 0)
splitTop = size.y > size.x;
static auto *const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
static auto *const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
if (*PPRESERVESPLIT == 0) {
splitTop = size.y * *PFLMULT > size.x;
}
const auto SPLITSIDE = !splitTop;
if (SPLITSIDE) {
// split sidey
// split left/right
children[0]->position = position;
children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
} else {
// split toppy bottomy
// split top/bottom
children[0]->position = position;
children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
}
children[0]->recalcSizePosRecursive();
children[1]->recalcSizePosRecursive();
children[0]->recalcSizePosRecursive(force);
children[1]->recalcSizePosRecursive(force);
} else {
layout->applyNodeDataToWindow(this);
layout->applyNodeDataToWindow(this, force);
}
}
@@ -58,10 +45,68 @@ void SDwindleNodeData::getAllChildrenRecursive(std::deque<SDwindleNodeData*>* pD
}
}
bool SDwindleNodeData::isGroupMember() {
return pNextGroupMember && pNextGroupMember != this;
}
SDwindleNodeData* SDwindleNodeData::getGroupHead() {
SDwindleNodeData* current = this->pNextGroupMember;
while (current != this) {
if (current->groupHead) {
return current;
}
current = current->pNextGroupMember;
}
this->groupHead = true;
return this;
}
SDwindleNodeData* SDwindleNodeData::getGroupVisible() {
SDwindleNodeData* current = this->pNextGroupMember;
while (current != this) {
if (!current->pWindow->m_bHidden) {
return current;
}
current = current->pNextGroupMember;
}
return this;
}
void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) {
SDwindleNodeData* current = this->pNextGroupMember;
while (current != this) {
current->pWindow->m_bHidden = current != pMember;
current = current->pNextGroupMember;
}
this->pWindow->m_bHidden = 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 no = 0;
for (auto& n : m_lDwindleNodesData) {
if (n.workspaceID == id)
if (n.workspaceID == id && n.valid)
++no;
}
return no;
@@ -92,12 +137,12 @@ SDwindleNodeData* CHyprDwindleLayout::getMasterNodeOnWorkspace(const int& id) {
return nullptr;
}
void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool force) {
// Don't set nodes, only windows.
if (pNode->isNode)
return;
SMonitor* PMONITOR = nullptr;
CMonitor* PMONITOR = nullptr;
if (pNode->workspaceID == SPECIAL_WORKSPACE_ID) {
for (auto& m : g_pCompositor->m_vMonitors) {
@@ -121,28 +166,48 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
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 auto BORDERSIZE = g_pConfigManager->getInt("general:border_size");
const auto GAPSIN = g_pConfigManager->getInt("general:gaps_in");
const auto GAPSOUT = g_pConfigManager->getInt("general:gaps_out");
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) {
Debug::log(ERR, "Node %x holding invalid window %x!!", pNode, PWINDOW);
onWindowRemovedTiling(PWINDOW);
return;
}
PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position;
auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE);
static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN,
DISPLAYTOP ? GAPSOUT : GAPSIN);
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN,
DISPLAYBOTTOM ? GAPSOUT : GAPSIN);
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE))) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.border = false;
return;
}
PWINDOW->m_sSpecialRenderData.rounding = true;
PWINDOW->m_sSpecialRenderData.border = true;
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
@@ -186,6 +251,23 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
}
if (force) {
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->m_vRealPosition.warp();
PWINDOW->m_vRealSize.warp();
g_pHyprRenderer->damageWindow(PWINDOW);
}
if (pNode->isGroupMember() && pNode->groupHead) {
// update visible node
const auto PVISNODE = pNode->getGroupVisible();
PVISNODE->pWindow->m_vRealSize = PWINDOW->m_vRealSize.goalv();
PVISNODE->pWindow->m_vRealPosition = PWINDOW->m_vRealPosition.goalv();
}
PWINDOW->updateWindowDecos();
}
@@ -198,6 +280,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
static auto *const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue;
// Populate the node with our window's data
PNODE->workspaceID = pWindow->m_iWorkspaceID;
PNODE->pWindow = pWindow;
@@ -207,15 +291,24 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
SDwindleNodeData* OPENINGON;
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen))) {
if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
// happens on reserved area
if (!OPENINGON && g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID) > 0)
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
} 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) {
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
} else {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
}
if (!OPENINGON && g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID) > 0)
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
} else
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID);
Debug::log(LOG, "OPENINGON: %x, Workspace: %i, Monitor: %i", OPENINGON, PNODE->workspaceID, PMONITOR->ID);
@@ -224,6 +317,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
OPENINGON = getFirstNodeOnWorkspace(PNODE->workspaceID);
}
// first, check if OPENINGON isn't too big.
const auto PREDSIZEMAX = OPENINGON ? Vector2D(OPENINGON->size.x, OPENINGON->size.y) : PMONITOR->vecSize;
if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PREDSIZEMAX.x || MAXSIZE.y < PREDSIZEMAX.y) {
// we can't continue. make it floating.
pWindow->m_bIsFloating = true;
m_lDwindleNodesData.remove(*PNODE);
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
return;
}
// if it's the first, it's easy. Make it fullscreen.
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
@@ -233,6 +336,30 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
return;
}
// if it's a group, add the window
if (OPENINGON->isGroupMember()) {
const auto PHEAD = OPENINGON->getGroupHead();
const auto PTAIL = PHEAD->pPreviousGroupMember;
PHEAD->pPreviousGroupMember = PNODE;
PTAIL->pNextGroupMember = PNODE;
PNODE->pNextGroupMember = PHEAD;
PNODE->pPreviousGroupMember = PTAIL;
PHEAD->setGroupFocusedNode(PNODE);
PNODE->position = PHEAD->position;
PNODE->size = PHEAD->size;
applyNodeDataToWindow(PNODE);
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
return;
}
// If it's not, get the node under our cursor
@@ -246,16 +373,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
NEWPARENT->pParent = OPENINGON->pParent;
NEWPARENT->isNode = true; // it is a node
const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
// if cursor over first child, make it first, etc
const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f;
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
NEWPARENT->splitTop = !SIDEBYSIDE;
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 ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
if (*PFORCESPLIT == 0) {
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 / *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.
NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE;
@@ -265,7 +395,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
NEWPARENT->children[1] = PNODE;
}
} else {
if (FORCESPLIT == 1) {
if (*PFORCESPLIT == 1) {
NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE;
} else {
@@ -284,14 +414,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
}
// Update the children
if (NEWPARENT->size.x > NEWPARENT->size.y) {
// split sidey
if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
// split left/right
OPENINGON->position = NEWPARENT->position;
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
} else {
// split toppy bottomy
// split top/bottom
OPENINGON->position = NEWPARENT->position;
OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
@@ -301,35 +433,70 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
OPENINGON->pParent = NEWPARENT;
PNODE->pParent = NEWPARENT;
if (OPENINGON->pGroupParent) {
// means we opened on a group
NEWPARENT->recalcSizePosRecursive();
// add the group deco
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
PNODE->pGroupParent = OPENINGON->pGroupParent;
PNODE->pGroupParent->groupMembers.push_back(PNODE);
PNODE->pGroupParent->groupMemberActive = PNODE->pGroupParent->groupMembers.size() - 1;
PNODE->pGroupParent->recalcSizePosRecursive();
} else {
NEWPARENT->recalcSizePosRecursive();
applyNodeDataToWindow(PNODE);
applyNodeDataToWindow(OPENINGON);
}
applyNodeDataToWindow(PNODE);
applyNodeDataToWindow(OPENINGON);
}
void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
if (!PNODE) {
Debug::log(ERR, "onWindowRemovedTiling node null?");
return;
}
// check if it was grouped
if (PNODE->isGroupMember()) {
// get shit
const auto PPREV = PNODE->pPreviousGroupMember;
const auto PNEXT = PNODE->pNextGroupMember;
PPREV->pNextGroupMember = PNEXT;
PNEXT->pPreviousGroupMember = PPREV;
if (PNODE->groupHead) {
PNEXT->groupHead = true;
PNEXT->pParent = PNODE->pParent;
if (PNODE->pParent) {
if (PNODE->pParent->children[0] == PNODE) {
PNODE->pParent->children[0] = PNEXT;
} else {
PNODE->pParent->children[1] = PNEXT;
}
}
PNEXT->position = PNODE->position;
PNEXT->size = PNODE->size;
} else {
const auto PHEAD = PNODE->getGroupHead();
PNEXT->position = PHEAD->position;
PNEXT->size = PHEAD->size;
}
PNEXT->setGroupFocusedNode(PNEXT);
PNEXT->pWindow->m_bHidden = false;
m_lDwindleNodesData.remove(*PNODE);
applyNodeDataToWindow(PNEXT);
if (!PNEXT->isGroupMember()) {
// means we dissolved the group
recalculateMonitor(PNEXT->pWindow->m_iMonitorID);
}
return;
}
const auto PPARENT = PNODE->pParent;
if (!PPARENT) {
Debug::log(LOG, "Removing last node (dwindle)");
m_lDwindleNodesData.remove(*PNODE);
return;
}
@@ -348,28 +515,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
}
}
// check if it was grouped
if (PNODE->pGroupParent) {
PNODE->pGroupParent->groupMembers.erase(PNODE->pGroupParent->groupMembers.begin() + PNODE->pGroupParent->groupMemberActive);
if ((long unsigned int)PNODE->pGroupParent->groupMemberActive >= PNODE->pGroupParent->groupMembers.size())
PNODE->pGroupParent->groupMemberActive = 0;
if (PNODE->pGroupParent->groupMembers.size() <= 1) {
PNODE->pGroupParent->isGroup = false;
PSIBLING->pGroupParent = nullptr;
PNODE->pGroupParent->groupMembers.clear();
PSIBLING->recalcSizePosRecursive();
} else {
PNODE->pGroupParent->recalcSizePosRecursive();
}
// if the parent is to be removed, remove the group
if (PPARENT == PNODE->pGroupParent) {
toggleWindowGroup(PPARENT->groupMembers[PPARENT->groupMemberActive]->pWindow);
}
}
PPARENT->valid = false;
PNODE->valid = false;
if (PSIBLING->pParent)
PSIBLING->pParent->recalcSizePosRecursive();
@@ -382,6 +529,10 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
if (!PMONITOR)
return; // ???
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
if (!PWORKSPACE)
@@ -407,17 +558,21 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
// massive hack from the fullscreen func
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
SDwindleNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position;
PFULLWINDOW->m_vSize = fakeNode.size;
if (!PFULLWINDOW) { // ????
PWORKSPACE->m_bHasFullscreenWindow = false;
} else {
SDwindleNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position;
PFULLWINDOW->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
applyNodeDataToWindow(&fakeNode);
return;
return;
}
}
const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace);
@@ -448,6 +603,8 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
return;
}
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
// get some data about our window
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
@@ -479,11 +636,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
if (PARENTSIDEBYSIDE) {
allowedMovement.x *= 2.f / PPARENT->size.x;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f);
PPARENT->recalcSizePosRecursive();
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} else {
allowedMovement.y *= 2.f / PPARENT->size.y;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f);
PPARENT->recalcSizePosRecursive();
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
}
return;
@@ -498,11 +655,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
if (PARENTSIDEBYSIDE) {
allowedMovement.x *= 2.f / PPARENT->size.x;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f);
PPARENT->recalcSizePosRecursive();
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
} else {
allowedMovement.y *= 2.f / PPARENT->size.y;
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f);
PPARENT->recalcSizePosRecursive();
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
}
return;
@@ -517,14 +674,17 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f);
TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f);
SIDECONTAINER->recalcSizePosRecursive();
TOPCONTAINER->recalcSizePosRecursive();
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
}
void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
if (!g_pCompositor->windowValidMapped(pWindow))
return;
if (!g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID))
return;
if (on == pWindow->m_bIsFullscreen)
return; // ignore
@@ -541,7 +701,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
pWindow->m_bIsFullscreen = on;
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)on)));
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
if (!pWindow->m_bIsFullscreen) {
// if it got its fullscreen disabled, set back its node if it had one
@@ -585,14 +745,12 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
}
}
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
g_pCompositor->moveWindowToTop(pWindow);
// we need to fix XWayland windows by sending them to NARNIA
// because otherwise they'd still be recieving mouse events
g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);
recalculateMonitor(PMONITOR->ID);
}
@@ -605,6 +763,16 @@ void CHyprDwindleLayout::recalculateWindow(CWindow* pWindow) {
PNODE->recalcSizePosRecursive();
}
void addToDequeRecursive(std::deque<SDwindleNodeData*>* pDeque, std::deque<SDwindleNodeData*>* pParents, SDwindleNodeData* node) {
if (node->isNode) {
pParents->push_back(node);
addToDequeRecursive(pDeque, pParents, node->children[0]);
addToDequeRecursive(pDeque, pParents, node->children[1]);
} else {
pDeque->emplace_back(node);
}
}
void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
if (!g_pCompositor->windowValidMapped(pWindow))
return;
@@ -615,61 +783,122 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
if (!PNODE)
return; // reject
const auto PGROUPPARENT = PNODE->pGroupParent;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
if (PGROUPPARENT) {
// if there is a parent, release it
const auto INACTIVEBORDERCOL = CColor(g_pConfigManager->getInt("general:col.inactive_border"));
for (auto& node : PGROUPPARENT->groupMembers) {
node->pGroupParent = nullptr;
node->pWindow->m_cRealBorderColor.setValueAndWarp(INACTIVEBORDERCOL); // no anim here because they pop in
if (PWORKSPACE->m_bHasFullscreenWindow)
fullscreenRequestForWindow(g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID), FULLSCREEN_FULL, false);
for (auto& wd : node->pWindow->m_dWindowDecorations) {
wd->updateWindow(node->pWindow);
}
}
if (PNODE->isGroupMember()) {
// dissolve group
const auto PHEAD = PNODE->getGroupHead();
SDwindleNodeData* current = PNODE->pNextGroupMember;
PNODE->pWindow->m_bIsFloating = PHEAD->pWindow->m_bIsFloating;
std::deque<CWindow*> toAddWindows;
PGROUPPARENT->groupMembers.clear();
const auto PWINDOWNODE = PNODE->pWindow;
toAddWindows.push_back(PWINDOWNODE);
PGROUPPARENT->isGroup = false;
while (current != PNODE) {
const auto PWINDOW = current->pWindow;
current = current->pNextGroupMember;
PGROUPPARENT->recalcSizePosRecursive();
toAddWindows.push_back(PWINDOW);
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow))
g_pCompositor->m_pLastWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.active_border"));
} else {
// if there is no parent, let's make one
const auto PPARENT = PNODE->pParent;
if (!PPARENT)
return; // reject making group on single window
PPARENT->isGroup = true;
// recursively get all members
std::deque<SDwindleNodeData*> allChildren;
PPARENT->getAllChildrenRecursive(&allChildren);
PPARENT->groupMembers = allChildren;
const auto GROUPINACTIVEBORDERCOL = CColor(g_pConfigManager->getInt("dwinle:col.group_border"));
for (auto& c : PPARENT->groupMembers) {
c->pGroupParent = PPARENT;
c->pWindow->m_cRealBorderColor = GROUPINACTIVEBORDERCOL;
c->pWindow->m_dWindowDecorations.push_back(std::make_unique<CHyprGroupBarDecoration>(c->pWindow));
if (c->pWindow == g_pCompositor->m_pLastWindow)
c->pWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active"));
PWINDOW->m_bHidden = false;
}
PPARENT->groupMemberActive = 0;
PHEAD->pPreviousGroupMember = nullptr;
PHEAD->pNextGroupMember = nullptr;
onWindowRemoved(PHEAD->pWindow);
PPARENT->recalcSizePosRecursive();
for (auto& pw : toAddWindows) {
const auto PNODE = getNodeFromWindow(pw);
if (PNODE)
m_lDwindleNodesData.remove(*PNODE);
pw->m_vPosition = Vector2D(-1000000, -1000000);
}
for (auto& pw : toAddWindows) {
onWindowCreated(pw);
pw->removeDecorationByType(DECORATION_GROUPBAR);
}
recalculateMonitor(PWORKSPACE->m_iMonitorID);
} else {
// create group
if (!PNODE->pParent)
return;
PNODE->groupHead = true;
std::deque<SDwindleNodeData*> newGroupMembers;
std::deque<SDwindleNodeData*> nodesToRemove;
newGroupMembers.emplace_back(PNODE);
addToDequeRecursive(&newGroupMembers, &nodesToRemove, PNODE->pParent->children[0] == PNODE ? PNODE->pParent->children[1] : PNODE->pParent->children[0]);
for (auto& n : newGroupMembers) {
if (n->isGroupMember())
return; // reject nested groups
}
for (auto& nd : nodesToRemove) {
m_lDwindleNodesData.remove(*nd);
}
PNODE->position = PNODE->pParent->position;
PNODE->size = PNODE->pParent->size;
applyNodeDataToWindow(PNODE);
if (PNODE->pParent->pParent) {
if (PNODE->pParent->pParent->children[0] == PNODE->pParent) {
PNODE->pParent->pParent->children[0] = PNODE;
} else {
PNODE->pParent->pParent->children[1] = PNODE;
}
}
const auto PPARENT2 = PNODE->pParent->pParent;
m_lDwindleNodesData.remove(*PNODE->pParent);
PNODE->pParent = PPARENT2;
// now remove everyone but head from tree
// and set order
for (int i = 0; i < (int)newGroupMembers.size(); ++i) {
if (i != 0) {
newGroupMembers[i]->groupHead = false;
newGroupMembers[i]->pParent = PNODE->pParent;
}
const auto PREVMEMBER = i == 0 ? newGroupMembers[newGroupMembers.size() - 1] : newGroupMembers[i - 1];
const auto NEXTMEMBER = i == (int)newGroupMembers.size() - 1 ? newGroupMembers[0] : newGroupMembers[i + 1];
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
// add the deco
newGroupMembers[i]->pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(newGroupMembers[i]->pWindow));
}
// focus
PNODE->setGroupFocusedNode(PNODE);
// required for no_gaps_when_only to work
applyNodeDataToWindow(PNODE);
}
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
g_pInputManager->refocus();
}
@@ -683,16 +912,17 @@ std::deque<CWindow*> CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) {
// get the node
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
if (!PNODE || !PNODE->isGroupMember())
return result; // reject with empty
const auto PGROUPPARENT = PNODE->pGroupParent;
const auto HEAD = PNODE->getGroupHead();
SDwindleNodeData* current = HEAD->pNextGroupMember;
if (!PGROUPPARENT)
return result; // reject with empty
result.push_back(HEAD->pWindow);
for (auto& node : PGROUPPARENT->groupMembers) {
result.push_back(node->pWindow);
while (current != HEAD) {
result.push_back(current->pWindow);
current = current->pNextGroupMember;
}
return result;
@@ -704,33 +934,44 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward) {
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
if (!PNODE || !PNODE->isGroupMember())
return; // reject
if (!PNODE->pGroupParent)
return; // reject
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
SDwindleNodeData* pNewNode;
if (forward)
PNODE->pGroupParent->groupMemberActive++;
pNewNode = PNODE->pNextGroupMember;
else
PNODE->pGroupParent->groupMemberActive--;
pNewNode = PNODE->pPreviousGroupMember;
if (PNODE->pGroupParent->groupMemberActive < 0)
PNODE->pGroupParent->groupMemberActive = PNODE->pGroupParent->groupMembers.size() - 1;
PNODE->setGroupFocusedNode(pNewNode);
if ((long unsigned int)PNODE->pGroupParent->groupMemberActive >= PNODE->pGroupParent->groupMembers.size())
PNODE->pGroupParent->groupMemberActive = 0;
pNewNode->position = PNODE->position;
pNewNode->size = PNODE->size;
PNODE->pGroupParent->recalcSizePosRecursive();
applyNodeDataToWindow(pNewNode);
for (auto& gm : PNODE->pGroupParent->groupMembers) {
for (auto& deco : gm->pWindow->m_dWindowDecorations) {
deco->updateWindow(gm->pWindow);
}
pNewNode->pWindow->m_vRealSize.warp();
pNewNode->pWindow->m_vRealPosition.warp();
g_pCompositor->focusWindow(pNewNode->pWindow);
pNewNode->pWindow->m_bIsFloating = PNODE->pWindow->m_bIsFloating;
if (PNODE->pWindow->m_bIsFullscreen) {
PNODE->pWindow->m_bHidden = false;
g_pCompositor->setWindowFullscreen(PNODE->pWindow, false, PWORKSPACE->m_efFullscreenMode);
PNODE->pWindow->m_bHidden = true;
g_pCompositor->setWindowFullscreen(pNewNode->pWindow, true, PWORKSPACE->m_efFullscreenMode);
pNewNode->pWindow->m_vRealSize.warp();
pNewNode->pWindow->m_vRealPosition.warp();
}
// focus
g_pCompositor->focusWindow(PNODE->pGroupParent->groupMembers[PNODE->pGroupParent->groupMemberActive]->pWindow);
pNewNode->pWindow->updateWindowDecos();
PNODE->pWindow->updateWindowDecos();
}
SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow) {
@@ -738,17 +979,20 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
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);
if (!PNODE)
return hints; // left for the future, maybe floating funkiness
if (PNODE->pGroupParent) {
if (PNODE->isGroupMember()) {
hints.isBorderColor = true;
if (pWindow == g_pCompositor->m_pLastWindow)
hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active"));
hints.borderColor = CColor(*PGROUPCOLACTIVE);
else
hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border"));
hints.borderColor = CColor(*PGROUPCOLINACTIVE);
}
return hints;
@@ -854,4 +1098,17 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
std::string CHyprDwindleLayout::getLayoutName() {
return "dwindle";
}
}
void CHyprDwindleLayout::onEnable() {
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->m_bHidden)
continue;
onWindowCreatedTiling(w.get());
}
}
void CHyprDwindleLayout::onDisable() {
m_lDwindleNodesData.clear();
}

View File

@@ -18,10 +18,9 @@ struct SDwindleNodeData {
bool splitTop = false; // for preserve_split
bool isGroup = false;
int groupMemberActive = 0;
std::deque<SDwindleNodeData*> groupMembers;
SDwindleNodeData* pGroupParent = nullptr;
bool groupHead = false;
SDwindleNodeData* pNextGroupMember = nullptr;
SDwindleNodeData* pPreviousGroupMember = nullptr;
Vector2D position;
Vector2D size;
@@ -30,13 +29,20 @@ struct SDwindleNodeData {
float splitRatio = 1.f;
bool valid = true;
// For list lookup
bool operator==(const SDwindleNodeData& rhs) {
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
}
void recalcSizePosRecursive();
void recalcSizePosRecursive(bool force = false);
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
bool isGroupMember();
SDwindleNodeData* getGroupHead();
SDwindleNodeData* getGroupVisible();
int getGroupMemberCount();
void setGroupFocusedNode(SDwindleNodeData*);
CHyprDwindleLayout* layout = nullptr;
};
@@ -55,12 +61,15 @@ public:
virtual void alterSplitRatioBy(CWindow*, float);
virtual std::string getLayoutName();
virtual void onEnable();
virtual void onDisable();
private:
std::list<SDwindleNodeData> m_lDwindleNodesData;
int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SDwindleNodeData*);
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
SDwindleNodeData* getNodeFromWindow(CWindow*);
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);

View File

@@ -6,6 +6,16 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow) {
if (pWindow->m_bIsFloating) {
onWindowCreatedFloating(pWindow);
} else {
wlr_box desiredGeometry = {0};
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
pWindow->m_vLastFloatingSize = PMONITOR->vecSize / 2.f;
} else {
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
}
onWindowCreatedTiling(pWindow);
}
}
@@ -32,11 +42,21 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
return;
}
if (desiredGeometry.width <= 0 || desiredGeometry.height <= 0) {
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow);
pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.vec().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.vec().y) / 2.f);
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;
return;
}
// reject any windows with size <= 5x5
if (pWindow->m_vRealSize.goalv().x <= 5 || pWindow->m_vRealSize.goalv().y <= 5) {
pWindow->m_vRealSize = PMONITOR->vecSize / 2.f;
}
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
} else {
// we respect the size.
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
@@ -67,7 +87,6 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
if (pWindow->m_iX11Type != 2) {
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);
g_pCompositor->moveWindowToTop(pWindow);
}
@@ -96,6 +115,9 @@ void IHyprLayout::onBeginDragWindow() {
return;
}
DRAGGINGWINDOW->m_vRealPosition.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
DRAGGINGWINDOW->m_vRealSize.setConfig(g_pConfigManager->getAnimationPropertyConfig("windowsMove"));
DRAGGINGWINDOW->m_bDraggingTiled = false;
if (!DRAGGINGWINDOW->m_bIsFloating) {
@@ -103,15 +125,20 @@ void IHyprLayout::onBeginDragWindow() {
changeWindowFloatingMode(DRAGGINGWINDOW);
DRAGGINGWINDOW->m_bIsFloating = true;
DRAGGINGWINDOW->m_bDraggingTiled = true;
DRAGGINGWINDOW->m_vRealPosition = g_pInputManager->getMouseCoordsInternal() - DRAGGINGWINDOW->m_vRealSize.goalv() / 2.f;
}
}
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.vec();
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.vec();
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.goalv();
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
m_vLastDragXY = m_vBeginDragXY;
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
// shadow to ignore any bound to MAIN_MOD
g_pKeybindManager->shadowKeybinds();
}
void IHyprLayout::onEndDragWindow() {
@@ -140,6 +167,8 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
if (abs(TICKDELTA.x) < 1.f && abs(TICKDELTA.y) < 1.f)
return;
@@ -150,16 +179,19 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
if (g_pInputManager->dragButton == BTN_LEFT) {
DRAGGINGWINDOW->m_vRealPosition.setValueAndWarp(m_vBeginDragPositionXY + DELTA);
DRAGGINGWINDOW->updateWindowDecos();
g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv());
} else {
if (DRAGGINGWINDOW->m_bIsFloating) {
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA);
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().x, (double)20, (double)999999), std::clamp(DRAGGINGWINDOW->m_vRealSize.vec().y, (double)20, (double)999999)));
DRAGGINGWINDOW->updateWindowDecos();
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(DRAGGINGWINDOW);
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));
} else {
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(m_vBeginDragSizeXY + DELTA);
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)));
}
g_pXWaylandManager->setWindowSize(DRAGGINGWINDOW, DRAGGINGWINDOW->m_vRealSize.goalv());
} else {
resizeActiveWindow(TICKDELTA, DRAGGINGWINDOW);
@@ -174,9 +206,13 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
if (PMONITOR) {
DRAGGINGWINDOW->m_iMonitorID = PMONITOR->ID;
DRAGGINGWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace;
DRAGGINGWINDOW->moveToWorkspace(PMONITOR->activeWorkspace);
DRAGGINGWINDOW->updateToplevel();
}
DRAGGINGWINDOW->updateWindowDecos();
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
}
@@ -195,7 +231,7 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
if (!TILED) {
const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
pWindow->m_iMonitorID = PNEWMON->ID;
pWindow->m_iWorkspaceID = PNEWMON->activeWorkspace;
pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
// save real pos cuz the func applies the default 5,5 mid
const auto PSAVEDPOS = pWindow->m_vRealPosition.vec();
@@ -204,6 +240,8 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
// if the window is pseudo, update its size
pWindow->m_vPseudoSize = pWindow->m_vRealSize.vec();
pWindow->m_vLastFloatingSize = PSAVEDSIZE;
onWindowCreatedTiling(pWindow);
pWindow->m_vRealPosition.setValue(PSAVEDPOS);
@@ -219,17 +257,17 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
g_pCompositor->moveWindowToTop(pWindow);
const auto POS = pWindow->m_vRealPosition.goalv();
const auto SIZ = pWindow->m_vRealSize.goalv();
pWindow->m_vRealPosition.setValueAndWarp(POS + Vector2D(5, 5));
pWindow->m_vRealSize.setValueAndWarp(SIZ - Vector2D(10, 10));
pWindow->m_vRealPosition = POS;
pWindow->m_vRealSize = SIZ;
pWindow->m_vRealPosition = pWindow->m_vRealPosition.vec() + (pWindow->m_vRealSize.vec() - pWindow->m_vLastFloatingSize) / 2.f;
pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
pWindow->m_sSpecialRenderData.rounding = true;
}
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
pWindow->updateToplevel();
}
void IHyprLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) {

View File

@@ -16,6 +16,8 @@ enum eFullscreenMode : uint8_t;
interface IHyprLayout {
public:
virtual void onEnable() = 0;
virtual void onDisable() = 0;
/*
Called when a window is created (mapped)

605
src/layout/MasterLayout.cpp Normal file
View File

@@ -0,0 +1,605 @@
#include "MasterLayout.hpp"
#include "../Compositor.hpp"
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) {
for (auto& nd : m_lMasterNodesData) {
if (nd.pWindow == pWindow)
return &nd;
}
return nullptr;
}
int CHyprMasterLayout::getNodesOnWorkspace(const int& ws) {
int no = 0;
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == ws)
no++;
}
return no;
}
std::string CHyprMasterLayout::getLayoutName() {
return "Master";
}
SMasterNodeData* CHyprMasterLayout::getMasterNodeOnWorkspace(const int& ws) {
for (auto& n : m_lMasterNodesData) {
if (n.isMaster && n.workspaceID == ws)
return &n;
}
return nullptr;
}
void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
if (pWindow->m_bIsFloating)
return;
static auto *const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue;
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
PNODE->workspaceID = pWindow->m_iWorkspaceID;
PNODE->pWindow = pWindow;
static auto *const PNEWISMASTER = &g_pConfigManager->getConfigValuePtr("master:new_is_master")->intValue;
const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
float lastSplitPercent = 0.5f;
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1) {
for (auto& nd : m_lMasterNodesData) {
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
nd.isMaster = false;
lastSplitPercent = nd.percMaster;
break;
}
}
PNODE->isMaster = true;
PNODE->percMaster = lastSplitPercent;
// first, check if it isn't too big.
if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * lastSplitPercent || MAXSIZE.y < PMONITOR->vecSize.y) {
// we can't continue. make it floating.
pWindow->m_bIsFloating = true;
m_lMasterNodesData.remove(*PNODE);
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
return;
}
} else {
PNODE->isMaster = false;
// first, check if it isn't too big.
if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
// we can't continue. make it floating.
pWindow->m_bIsFloating = true;
m_lMasterNodesData.remove(*PNODE);
g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow);
return;
}
}
// recalc
recalculateMonitor(pWindow->m_iMonitorID);
}
void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
return;
if (PNODE->isMaster) {
// find new one
for (auto& nd : m_lMasterNodesData) {
if (!nd.isMaster) {
nd.isMaster = true;
break;
}
}
}
m_lMasterNodesData.remove(*PNODE);
recalculateMonitor(pWindow->m_iMonitorID);
}
void CHyprMasterLayout::recalculateMonitor(const int& monid) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
if (!PWORKSPACE)
return;
g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceOpen) {
calculateWorkspace(SPECIAL_WORKSPACE_ID);
}
if (PWORKSPACE->m_bHasFullscreenWindow) {
if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL)
return;
// massive hack from the fullscreen func
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
SMasterNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position;
PFULLWINDOW->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
return;
}
// calc the WS
calculateWorkspace(PWORKSPACE->m_iID);
}
void CHyprMasterLayout::calculateWorkspace(const int& ws) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
if (!PWORKSPACE)
return;
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
const auto PMASTERNODE = getMasterNodeOnWorkspace(PWORKSPACE->m_iID);
if (!PMASTERNODE)
return;
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
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);
applyNodeDataToWindow(PMASTERNODE);
return;
} else {
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
PMASTERNODE->size = Vector2D((PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
}
const auto SLAVESIZE = 1.f / (getNodesOnWorkspace(PWORKSPACE->m_iID) - 1) * (PMASTERNODE->size.y);
int slavesDone = 0;
for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID)
continue;
if (nd == *PMASTERNODE) {
applyNodeDataToWindow(PMASTERNODE);
continue;
}
nd.position = Vector2D(PMASTERNODE->size.x + PMASTERNODE->position.x, slavesDone * SLAVESIZE + PMASTERNODE->position.y);
nd.size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x, SLAVESIZE);
slavesDone++;
applyNodeDataToWindow(&nd);
}
}
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
CMonitor* PMONITOR = nullptr;
if (pNode->workspaceID == SPECIAL_WORKSPACE_ID) {
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->specialWorkspaceOpen) {
PMONITOR = m.get();
break;
}
}
} else {
PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID);
}
if (!PMONITOR) {
Debug::log(ERR, "Orphaned Node %x (workspace ID: %i)!!", pNode, pNode->workspaceID);
return;
}
// for gaps outer
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
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 auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
Debug::log(ERR, "Node %x holding invalid window %x!!", pNode, PWINDOW);
return;
}
static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("master:no_gaps_when_only")->intValue;
PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position;
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.border = false;
return;
}
PWINDOW->m_sSpecialRenderData.rounding = true;
PWINDOW->m_sSpecialRenderData.border = true;
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) {
static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
} else {
PWINDOW->m_vRealSize = calcSize;
PWINDOW->m_vRealPosition = calcPos;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
}
if (m_bForceWarps) {
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->m_vRealPosition.warp();
PWINDOW->m_vRealSize.warp();
g_pHyprRenderer->damageWindow(PWINDOW);
}
PWINDOW->updateWindowDecos();
}
bool CHyprMasterLayout::isWindowTiled(CWindow* pWindow) {
return getNodeFromWindow(pWindow) != nullptr;
}
void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* pWindow) {
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow;
if (!g_pCompositor->windowValidMapped(PWINDOW))
return;
const auto PNODE = getNodeFromWindow(PWINDOW);
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->updateWindowDecos();
return;
}
// get master
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) < 2)
return;
m_bForceWarps = true;
float delta = pixResize.x / PMONITOR->vecSize.x;
PMASTER->percMaster += delta;
std::clamp(PMASTER->percMaster, 0.05f, 0.95f);
recalculateMonitor(PMONITOR->ID);
m_bForceWarps = false;
}
void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
if (!g_pCompositor->windowValidMapped(pWindow))
return;
if (!g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID))
return;
if (on == pWindow->m_bIsFullscreen)
return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
// if the window wants to be fullscreen but there already is one,
// ignore the request.
return;
}
// otherwise, accept it.
pWindow->m_bIsFullscreen = on;
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
if (!pWindow->m_bIsFullscreen) {
// if it got its fullscreen disabled, set back its node if it had one
const auto PNODE = getNodeFromWindow(pWindow);
if (PNODE)
applyNodeDataToWindow(PNODE);
else {
// get back its' dimensions from position and size
pWindow->m_vRealPosition = pWindow->m_vPosition;
pWindow->m_vRealSize = pWindow->m_vSize;
}
} else {
// if it now got fullscreen, make it fullscreen
PWORKSPACE->m_efFullscreenMode = fullscreenMode;
// save position and size if floating
if (pWindow->m_bIsFloating) {
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
pWindow->m_vSize = pWindow->m_vRealSize.vec();
}
// apply new pos and size being monitors' box
if (fullscreenMode == FULLSCREEN_FULL) {
pWindow->m_vRealPosition = PMONITOR->vecPosition;
pWindow->m_vRealSize = PMONITOR->vecSize;
} else {
// This is a massive hack.
// We make a fake "only" node and apply
// To keep consistent with the settings without C+P code
SMasterNodeData fakeNode;
fakeNode.pWindow = pWindow;
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
pWindow->m_vPosition = fakeNode.position;
pWindow->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
}
}
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
g_pCompositor->moveWindowToTop(pWindow);
recalculateMonitor(PMONITOR->ID);
}
void CHyprMasterLayout::recalculateWindow(CWindow* pWindow) {
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
return;
recalculateMonitor(pWindow->m_iMonitorID);
}
SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow) {
// window should be valid, insallah
SWindowRenderLayoutHints hints;
return hints; // master doesnt have any hints
}
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
// windows should be valid, insallah
const auto PNODE = getNodeFromWindow(pWindow);
const auto PNODE2 = getNodeFromWindow(pWindow2);
if (!PNODE2 || !PNODE)
return;
if (PNODE->workspaceID != PNODE2->workspaceID) {
Debug::log(ERR, "Master: Rejecting a swap between workspaces");
return;
}
// massive hack: just swap window pointers, lol
const auto PWINDOW1 = PNODE->pWindow;
PNODE->pWindow = PNODE2->pWindow;
PNODE2->pWindow = PWINDOW1;
recalculateMonitor(PWINDOW1->m_iMonitorID);
}
void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
// window should be valid, insallah
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
return;
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
PMASTER->percMaster = std::clamp(PMASTER->percMaster + ratio, 0.05f, 0.95f);
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) {
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
if (!g_pCompositor->windowValidMapped(PWINDOWTOCHANGETO))
return;
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
Vector2D middle = 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") {
const auto PWINDOW = header.pWindow;
if (!isWindowTiled(PWINDOW))
return 0;
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
if (!PMASTER || PMASTER->pWindow == PWINDOW)
return 0;
switchWindows(PWINDOW, PMASTER->pWindow);
switchToWindow(PWINDOW);
return 0;
} else if (message == "cyclenext") {
const auto PWINDOW = header.pWindow;
switchToWindow(getNextWindow(PWINDOW, true));
} else if (message == "cycleprev") {
const auto PWINDOW = header.pWindow;
switchToWindow(getNextWindow(PWINDOW, false));
} else if (message == "swapnext") {
if (!g_pCompositor->windowValidMapped(header.pWindow))
return 0;
if (header.pWindow->m_bIsFloating) {
g_pKeybindManager->m_mDispatchers["swapnext"]("");
return 0;
}
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);
}
}
return 0;
}
void CHyprMasterLayout::onEnable() {
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_bIsFloating || !w->m_bMappedX11 || !w->m_bIsMapped || w->m_bHidden)
continue;
onWindowCreatedTiling(w.get());
}
}
void CHyprMasterLayout::onDisable() {
m_lMasterNodesData.clear();
}

View File

@@ -0,0 +1,57 @@
#pragma once
#include "IHyprLayout.hpp"
#include <list>
#include <deque>
enum eFullscreenMode : uint8_t;
struct SMasterNodeData {
bool isMaster = false;
float percMaster = 0.5f;
CWindow* pWindow = nullptr;
Vector2D position;
Vector2D size;
int workspaceID = -1;
bool operator==(const SMasterNodeData& rhs) {
return pWindow == rhs.pWindow;
}
};
class CHyprMasterLayout : public IHyprLayout {
public:
virtual void onWindowCreatedTiling(CWindow*);
virtual void onWindowRemovedTiling(CWindow*);
virtual bool isWindowTiled(CWindow*);
virtual void recalculateMonitor(const int&);
virtual void recalculateWindow(CWindow*);
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
virtual void switchWindows(CWindow*, CWindow*);
virtual void alterSplitRatioBy(CWindow*, float);
virtual std::string getLayoutName();
virtual void onEnable();
virtual void onDisable();
private:
std::list<SMasterNodeData> m_lMasterNodesData;
bool m_bForceWarps = false;
int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SMasterNodeData*);
SMasterNodeData* getNodeFromWindow(CWindow*);
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
void calculateWorkspace(const int&);
CWindow* getNextWindow(CWindow*, bool);
friend struct SMasterNodeData;
};

View File

@@ -15,9 +15,19 @@ int main(int argc, char** argv) {
throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
// parse some args
std::string configPath;
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--i-am-really-stupid"))
ignoreSudo = true;
else if ((!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")) && argc >= i + 2) {
configPath = std::string(argv[++i]);
Debug::log(LOG, "Using config location %s.", configPath.c_str());
} else {
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n" <<
"--help -h | Show this help message\n" <<
"--config -c | Specify config file to use\n";
return 1;
}
}
system("mkdir -p /tmp/hypr");
@@ -34,9 +44,14 @@ int main(int argc, char** argv) {
std::cout << "Welcome to Hyprland!\n";
const auto LOGWLR = getenv("HYPRLAND_LOG_WLR");
if (LOGWLR && std::string(LOGWLR) == "1")
wlr_log_init(WLR_DEBUG, Debug::wlrLog);
// let's init the compositor.
// it initializes basic Wayland stuff in the constructor.
g_pCompositor = std::make_unique<CCompositor>();
g_pCompositor->explicitConfigPath = configPath;
Debug::log(LOG, "Hyprland init finished.");
@@ -46,7 +61,13 @@ int main(int argc, char** argv) {
// If we are here it means we got yote.
Debug::log(LOG, "Hyprland reached the end.");
g_pCompositor->cleanupExit();
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;
}

View File

@@ -28,13 +28,10 @@ void CAnimationManager::tick() {
if (!*PANIMENABLED)
animationsDisabled = true;
static auto *const PANIMSPEED = &g_pConfigManager->getConfigValuePtr("animations:speed")->floatValue;
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
static auto *const BEZIERSTR = &g_pConfigManager->getConfigValuePtr("animations:curve")->strValue;
static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
auto DEFAULTBEZIER = m_mBezierCurves.find(*BEZIERSTR);
if (DEFAULTBEZIER == m_mBezierCurves.end())
DEFAULTBEZIER = m_mBezierCurves.find("default");
const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
for (auto& av : m_lAnimatedVariables) {
@@ -42,8 +39,13 @@ void CAnimationManager::tick() {
if (!av->isBeingAnimated())
continue;
if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) {
av->warp();
continue;
}
// get speed
const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed;
const auto SPEED = av->m_pConfig->pValues->internalSpeed;
// get the spent % (0 - 1)
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count();
@@ -53,7 +55,7 @@ void CAnimationManager::tick() {
const auto PWINDOW = (CWindow*)av->m_pWindow;
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
const auto PLAYER = (SLayerSurface*)av->m_pLayer;
SMonitor* PMONITOR = nullptr;
CMonitor* PMONITOR = nullptr;
wlr_box WLRBOXPREV = {0,0,0,0};
if (PWINDOW) {
@@ -73,7 +75,7 @@ void CAnimationManager::tick() {
switch (av->m_eVarType) {
case AVARTYPE_FLOAT: {
// for disabled anims just warp
if (*av->m_pEnabled == 0 || animationsDisabled) {
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp();
break;
}
@@ -84,7 +86,7 @@ void CAnimationManager::tick() {
}
const auto DELTA = av->m_fGoal - av->m_fBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
if (BEZIER != m_mBezierCurves.end())
av->m_fValue = av->m_fBegun + BEZIER->second.getYForPoint(SPENT) * DELTA;
@@ -94,7 +96,7 @@ void CAnimationManager::tick() {
}
case AVARTYPE_VECTOR: {
// for disabled anims just warp
if (*av->m_pEnabled == 0 || animationsDisabled) {
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp();
break;
}
@@ -105,7 +107,7 @@ void CAnimationManager::tick() {
}
const auto DELTA = av->m_vGoal - av->m_vBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
if (BEZIER != m_mBezierCurves.end())
av->m_vValue = av->m_vBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
@@ -115,7 +117,7 @@ void CAnimationManager::tick() {
}
case AVARTYPE_COLOR: {
// for disabled anims just warp
if (*av->m_pEnabled == 0 || animationsDisabled) {
if (av->m_pConfig->pValues->internalEnabled == 0 || animationsDisabled) {
av->warp();
break;
}
@@ -126,7 +128,7 @@ void CAnimationManager::tick() {
}
const auto DELTA = av->m_cGoal - av->m_cBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
if (BEZIER != m_mBezierCurves.end())
av->m_cValue = av->m_cBegun + DELTA * BEZIER->second.getYForPoint(SPENT);
@@ -145,8 +147,8 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageBox(&WLRBOXPREV);
if (PWINDOW) {
g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->updateWindowDecos();
g_pHyprRenderer->damageWindow(PWINDOW);
} else if (PWORKSPACE) {
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bHidden)
@@ -157,6 +159,9 @@ void CAnimationManager::tick() {
w->updateWindowDecos();
}
} else if (PLAYER) {
if (PLAYER->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || PLAYER->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR);
}
break;
}
@@ -181,6 +186,35 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageBox(WLRBOXNEW.x + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // right
g_pHyprRenderer->damageBox(WLRBOXNEW.x, WLRBOXNEW.y + WLRBOXNEW.height - ROUNDINGSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
break;
} case AVARDAMAGE_SHADOW: {
RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!");
static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW);
if (PDECO) {
const auto EXTENTS = PDECO->getWindowDecorationExtents();
wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y,
PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y};
if (!*PSHADOWIGNOREWINDOW) {
// easy, damage the entire box
g_pHyprRenderer->damageBox(&dmg);
} else {
pixman_region32_t rg;
pixman_region32_init_rect(&rg, dmg.x, dmg.y, dmg.width, dmg.height);
pixman_region32_t wb;
pixman_region32_init_rect(&wb, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y);
pixman_region32_subtract(&rg, &rg, &wb);
g_pHyprRenderer->damageRegion(&rg);
pixman_region32_fini(&rg);
pixman_region32_fini(&wb);
}
}
break;
}
default: {
@@ -195,7 +229,7 @@ void CAnimationManager::tick() {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
// manually schedule a frame
wlr_output_schedule_frame(PMONITOR->output);
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
}
}
@@ -223,21 +257,30 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
}
bool CAnimationManager::bezierExists(const std::string& bezier) {
for (auto&[bc, bz] : m_mBezierCurves) {
if (bc == bezier)
return true;
}
return false;
}
//
// Anims
//
//
void CAnimationManager::animationPopin(CWindow* pWindow, bool close) {
void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPerc) {
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
if (!close) {
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
pWindow->m_vRealSize.setValue(Vector2D(5, 5));
pWindow->m_vRealSize.setValue((GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y}));
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vValue / 2.f);
} else {
pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f;
pWindow->m_vRealSize = Vector2D(5, 5);
pWindow->m_vRealSize = (GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y});
pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vGoal / 2.f;
}
}
@@ -299,7 +342,17 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool
}
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
if (!close) {
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeIn");
} else {
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeOut");
}
auto ANIMSTYLE = pWindow->m_vRealPosition.m_pConfig->pValues->internalStyle;
transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
// if the window is not being animated, that means the layout set a fixed size for it, don't animate.
@@ -317,14 +370,72 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
}
} else {
// anim popin, fallback
animationPopin(pWindow, close);
float minPerc = 0.f;
if (pWindow->m_sAdditionalConfigData.animationStyle.find("%") != std::string::npos) {
try {
auto percstr = pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find_last_of(' '));
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) {
; // oops
}
}
animationPopin(pWindow, close, minPerc / 100.f);
}
} else {
if (ANIMSTYLE == "slide") {
animationSlide(pWindow, "", close);
} else {
// anim popin, fallback
animationPopin(pWindow, close);
float minPerc = 0.f;
if (ANIMSTYLE.find("%") != 0) {
try {
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' '));
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) {
; // oops
}
}
animationPopin(pWindow, close, minPerc / 100.f);
}
}
}
std::string CAnimationManager::styleValidInConfigVar(const std::string& config, const std::string& style) {
if (config.find("window") == 0) {
if (style == "slide") {
return "";
} else if (style.find("popin") == 0) {
// try parsing
float minPerc = 0.f;
if (style.find("%") != std::string::npos) {
try {
auto percstr = style.substr(style.find_last_of(' '));
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) {
return "invalid minperc";
}
return "";
}
minPerc; // fix warning
return "";
}
return "unknown style";
} else if (config == "workspaces" || config == "specialWorkspace") {
if (style == "slide" || style == "slidevert" || style == "fade")
return "";
return "unknown style";
} else {
return "animation has no styles";
}
return "";
}

View File

@@ -18,6 +18,10 @@ public:
void onWindowPostCreateClose(CWindow*, bool close = false);
bool bezierExists(const std::string&);
std::string styleValidInConfigVar(const std::string&, const std::string&);
std::list<CAnimatedVariable*> m_lAnimatedVariables;
private:
@@ -31,7 +35,7 @@ private:
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
// Anim stuff
void animationPopin(CWindow*, bool close = false);
void animationPopin(CWindow*, bool close = false, float minPerc = 0.f);
void animationSlide(CWindow*, std::string force = "", bool close = false);
};

View File

@@ -19,7 +19,7 @@ CEventManager::CEventManager() {
}
void CEventManager::startThread() {
std::thread([&]() {
m_tThread = std::thread([&]() {
const auto SOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SOCKET < 0) {
@@ -80,8 +80,8 @@ void CEventManager::startThread() {
eventQueueMutex.lock();
if (m_dQueuedEvents.empty()){ // if queue empty, sleep and ignore
std::this_thread::sleep_for(std::chrono::milliseconds(1));
eventQueueMutex.unlock();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
@@ -101,13 +101,15 @@ void CEventManager::startThread() {
}
close(SOCKET);
}).detach();
});
m_tThread.detach();
}
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
if (m_bIgnoreEvents && !force) {
Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
if ((m_bIgnoreEvents && !force) || g_pCompositor->m_bIsShuttingDown) {
Debug::log(WARN, "Suppressed (ignoreevents true / shutting down) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
return;
}

View File

@@ -21,6 +21,8 @@ public:
bool m_bIgnoreEvents = false;
std::thread m_tThread;
private:
std::mutex eventQueueMutex;

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,8 @@
#include <unordered_map>
#include <functional>
class CInputManager;
struct SKeybind {
std::string key = "";
int keycode = -1;
@@ -14,30 +16,69 @@ struct SKeybind {
std::string arg = "";
bool locked = false;
std::string submap = "";
bool release = false;
bool repeat = false;
// DO NOT INITIALIZE
bool shadowed = false;
};
enum eFocusWindowMode {
MODE_CLASS_REGEX = 0,
MODE_TITLE_REGEX,
MODE_ADDRESS,
MODE_PID
};
class CKeybindManager {
public:
CKeybindManager();
bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&);
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
bool onAxisEvent(wlr_pointer_axis_event*);
bool onMouseEvent(wlr_pointer_button_event*);
void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&);
uint32_t stringToModMask(std::string);
void clearKeybinds();
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
std::unordered_map<std::string, std::function<void(std::string)>> m_mDispatchers;
wl_event_source* m_pActiveKeybindEventSource = nullptr;
private:
std::list<SKeybind> m_lKeybinds;
std::deque<xkb_keysym_t> m_dPressedKeysyms;
std::deque<int> m_dPressedKeycodes;
inline static std::string m_szCurrentSelectedSubmap = "";
xkb_keysym_t m_kHeldBack = 0;
SKeybind* m_pActiveKeybind = nullptr;
uint32_t m_uTimeLastMs = 0;
uint32_t m_uLastCode = 0;
uint32_t m_uLastMouseCode = 0;
int m_iPassPressed = -1; // used for pass
CTimer m_tScrollTimer;
bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);
bool handleInternalKeybinds(xkb_keysym_t);
bool handleVT(xkb_keysym_t);
xkb_state* m_pXKBTranslationState = nullptr;
void updateXKBTranslationState();
// -------------- Dispatchers -------------- //
static void killActive(std::string);
static void kill(std::string);
static void spawn(std::string);
static void toggleActiveFloating(std::string);
static void toggleActivePseudo(std::string);
@@ -61,11 +102,20 @@ private:
static void forceRendererReload(std::string);
static void resizeActive(std::string);
static void moveActive(std::string);
static void moveWindow(std::string);
static void resizeWindow(std::string);
static void circleNext(std::string);
static void focusWindow(std::string);
static void setSubmap(std::string);
static void pass(std::string);
static void layoutmsg(std::string);
static void toggleOpaque(std::string);
static void dpms(std::string);
static void swapnext(std::string);
static void swapActiveWorkspaces(std::string);
friend class CCompositor;
friend class CInputManager;
};
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;

View File

@@ -4,8 +4,28 @@ IHyprLayout* CLayoutManager::getCurrentLayout() {
switch (m_iCurrentLayoutID) {
case DWINDLE:
return &m_cDwindleLayout;
case MASTER:
return &m_cMasterLayout;
}
// fallback
return &m_cDwindleLayout;
}
void CLayoutManager::switchToLayout(std::string layout) {
if (layout == "dwindle") {
if (m_iCurrentLayoutID != DWINDLE) {
getCurrentLayout()->onDisable();
m_iCurrentLayoutID = DWINDLE;
getCurrentLayout()->onEnable();
}
} else if (layout == "master") {
if (m_iCurrentLayoutID != MASTER) {
getCurrentLayout()->onDisable();
m_iCurrentLayoutID = MASTER;
getCurrentLayout()->onEnable();
}
} else {
Debug::log(ERR, "Unknown layout %s!", layout.c_str());
}
}

View File

@@ -1,20 +1,25 @@
#pragma once
#include "../layout/DwindleLayout.hpp"
#include "../layout/MasterLayout.hpp"
class CLayoutManager {
public:
IHyprLayout* getCurrentLayout();
void switchToLayout(std::string);
private:
enum HYPRLAYOUTS {
DWINDLE = 0,
MASTER
};
HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE;
CHyprDwindleLayout m_cDwindleLayout;
CHyprMasterLayout m_cMasterLayout;
};
inline std::unique_ptr<CLayoutManager> g_pLayoutManager;

View File

@@ -1,34 +1,31 @@
#include "ThreadManager.hpp"
#include "../debug/HyprCtl.hpp"
CThreadManager::CThreadManager() {
m_tMainThread = new std::thread([&]() {
// Call the handle method.
this->handle();
});
m_tMainThread->detach(); // detach and continue.
}
CThreadManager::~CThreadManager() {
//
}
#include "../Compositor.hpp"
int slowUpdate = 0;
void CThreadManager::handle() {
int handleTimer(void* data) {
const auto PTM = (CThreadManager*)data;
g_pConfigManager->tick();
wl_event_source_timer_update(PTM->m_esConfigTimer, 1000);
return 0;
}
CThreadManager::CThreadManager() {
g_pConfigManager->init();
HyprCtl::startHyprCtlSocket();
while (3.1415f) {
slowUpdate++;
if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){
g_pConfigManager->tick();
slowUpdate = 0;
}
g_pCompositor->startHyprCtlTick();
std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps")));
}
m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this);
wl_event_source_timer_update(m_esConfigTimer, 1000);
}
CThreadManager::~CThreadManager() {
//
}

View File

@@ -9,11 +9,9 @@ public:
CThreadManager();
~CThreadManager();
private:
wl_event_source* m_esConfigTimer;
void handle();
std::thread* m_tMainThread;
private:
};
inline std::unique_ptr<CThreadManager> g_pThreadManager;

View File

@@ -32,9 +32,15 @@ wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) {
}
void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) {
if (wlr_surface_is_xdg_surface(pSurface))
wlr_xdg_toplevel_set_activated(wlr_xdg_surface_from_wlr_surface(pSurface)->toplevel, activate);
else if (wlr_surface_is_xwayland_surface(pSurface)) {
if (!pSurface)
return;
if (wlr_surface_is_xdg_surface(pSurface)) {
const auto PSURF = wlr_xdg_surface_from_wlr_surface(pSurface);
if (PSURF && PSURF->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_set_activated(PSURF->toplevel, activate);
}
} else if (wlr_surface_is_xwayland_surface(pSurface)) {
wlr_xwayland_surface_activate(wlr_xwayland_surface_from_wlr_surface(pSurface), activate);
if (activate)
@@ -56,6 +62,8 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
g_pCompositor->m_pLastWindow = pWindow;
g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID)->m_pLastFocusedWindow = pWindow;
}
void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox) {
@@ -120,7 +128,14 @@ void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) {
}
}
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size) {
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size, bool force) {
if (!force && ((pWindow->m_vReportedSize == size && pWindow->m_vRealPosition.vec() == pWindow->m_vReportedPosition) || (pWindow->m_vReportedSize == size && !pWindow->m_bIsX11)))
return;
pWindow->m_vReportedPosition = pWindow->m_vRealPosition.vec();
pWindow->m_vReportedSize = size;
if (pWindow->m_bIsX11)
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, size.x, size.y);
else
@@ -148,8 +163,11 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"])
{
pWindow->m_bNoInitialFocus = true;
return true;
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"])
pWindow->m_bX11ShouldntFocus = true;
pWindow->m_bNoInitialFocus = true;
return true;
}
if (pWindow->m_uSurface.xwayland->role) {
@@ -223,4 +241,22 @@ void CHyprXWaylandManager::setWindowFullscreen(CWindow* pWindow, bool fullscreen
if (pWindow->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_fullscreen(pWindow->m_phForeignToplevel, fullscreen);
}
}
Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
if (!g_pCompositor->windowValidMapped(pWindow))
return Vector2D(99999, 99999);
if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel))
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)
: Vector2D(pWindow->m_uSurface.xdg->toplevel->current.max_width, pWindow->m_uSurface.xdg->toplevel->current.max_height);
if (MAXSIZE.x < 5)
MAXSIZE.x = 99999;
if (MAXSIZE.y < 5)
MAXSIZE.y = 99999;
return MAXSIZE;
}

View File

@@ -17,13 +17,14 @@ public:
std::string getTitle(CWindow*);
std::string getAppIDClass(CWindow*);
void sendCloseWindow(CWindow*);
void setWindowSize(CWindow*, const Vector2D&);
void setWindowSize(CWindow*, const Vector2D&, bool force = false);
void setWindowStyleTiled(CWindow*, uint32_t);
void setWindowFullscreen(CWindow*, bool);
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
bool shouldBeFloated(CWindow*);
void moveXWaylandWindow(CWindow*, const Vector2D&);
void checkBorders(CWindow*);
Vector2D getMaxSizeForWindow(CWindow*);
};
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;

View File

@@ -2,16 +2,18 @@
#include "../../Compositor.hpp"
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)
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);
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 * *PSENS, DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
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_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);
@@ -29,6 +31,10 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
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 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 PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
if (!g_pCompositor->m_bReadyToProcess)
return;
@@ -41,6 +47,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (g_pCompositor->m_sSeat.mouse->virt)
return; // don't refocus on virt
if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS) {
// enable dpms
g_pKeybindManager->dpms("on");
}
Vector2D mouseCoords = getMouseCoordsInternal();
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
@@ -61,7 +72,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (!CONSTRAINTWINDOW) {
g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
unconstrainMouse();
} else {
// Native Wayland apps know how 2 constrain themselves.
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
@@ -117,7 +128,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
ACTIVEWORKSPACE->setActive(true);
// event
g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName));
g_pEventManager->postEvent(SHyprIPCEvent{"focusedmon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName});
}
Vector2D surfaceCoords;
@@ -133,6 +144,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
if (!pFoundWindow) {
// what the fuck, somehow happens occasionally??
PWORKSPACE->m_bHasFullscreenWindow = false;
return;
}
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
surfacePos = pFoundWindow->m_vRealPosition.vec();
@@ -169,11 +187,20 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
}
} else {
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
if (!(pFoundWindow && pFoundWindow->m_bIsFloating && pFoundWindow->m_bCreatedOverFullscreen))
pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
}
} else
} else {
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
// TODO: this causes crashes, sometimes. ???
// if (refocus && !pFoundWindow) {
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
// }
}
if (pFoundWindow) {
if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
@@ -191,23 +218,30 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!foundSurface)
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 (m_ecbClickBehavior == CLICKMODE_KILL)
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
else
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
if (!m_bEmptyFocusCursorSet) {
// TODO: maybe wrap?
if (m_ecbClickBehavior == CLICKMODE_KILL)
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
else
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);
if (refocus) { // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
g_pCompositor->focusSurface(nullptr);
g_pCompositor->m_pLastWindow = nullptr;
g_pCompositor->focusWindow(nullptr);
}
return;
}
m_bEmptyFocusCursorSet = false;
if (time)
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
@@ -221,22 +255,56 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
surfaceLocal = mouseCoords - surfacePos + Vector2D(geom.x, geom.y);
}
bool allowKeyboardRefocus = true;
if (*PHOGFOCUS && !refocus && g_pCompositor->m_pLastFocus) {
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
if (PLS && PLS->layerSurface->current.keyboard_interactive) {
allowKeyboardRefocus = false;
}
}
if (pFoundWindow) {
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)) {
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR) {
// enter if change floating style
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
} else if (*PFOLLOWMOUSE == 2) {
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y);
}
if (pFoundWindow == g_pCompositor->m_pLastWindow) {
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);
}
}
if (*PFOLLOWONDND && m_sDrag.dragIcon) {
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, 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
} else {
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
}
} else if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive)
g_pCompositor->focusSurface(foundSurface);
m_bLastFocusOnLS = false;
} else {
if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) {
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_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
@@ -295,7 +363,7 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
m_ecbClickBehavior = CLICKMODE_KILL;
// remove constraints
g_pCompositor->m_sSeat.mouse->constraintActive = false;
g_pInputManager->unconstrainMouse();
refocus();
// set cursor
@@ -314,6 +382,14 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
return;
}
// notify the keybind manager
static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
static auto *const PMAINMODINTERNAL = &g_pConfigManager->getConfigValuePtr("general:main_mod_internal")->intValue;
const auto PASS = g_pKeybindManager->onMouseEvent(e);
if (!PASS && !*PPASSMOUSE)
return;
switch (e->state) {
case WLR_BUTTON_PRESSED:
if (!g_pCompositor->m_sSeat.mouse->currentConstraint)
@@ -323,7 +399,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_bIsFloating)
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")) {
if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)*PMAINMODINTERNAL) {
currentlyDraggedWindow = g_pCompositor->windowFromCursor();
dragButton = e->button;
@@ -372,6 +448,16 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
m_ecbClickBehavior = CLICKMODE_DEFAULT;
}
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
bool passEvent = g_pKeybindManager->onAxisEvent(e);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
if (passEvent) {
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source);
}
}
Vector2D CInputManager::getMouseCoordsInternal() {
return Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y);
}
@@ -391,10 +477,19 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
if (m_pActiveKeyboard)
m_pActiveKeyboard->active = false;
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
const auto PKEYBOARD = (SKeyboard*)owner;
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
}, PNEWKEYBOARD, "Keyboard");
disableAllKeyboards(false);
m_pActiveKeyboard = PNEWKEYBOARD;
PNEWKEYBOARD->active = true;
applyConfigToKeyboard(PNEWKEYBOARD);
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard));
@@ -402,32 +497,75 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
Debug::log(LOG, "New keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard);
}
void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
PNEWKEYBOARD->keyboard = keyboard;
PNEWKEYBOARD->isVirtual = true;
try {
PNEWKEYBOARD->name = std::string(keyboard->name);
} catch (std::exception& e) {
Debug::log(ERR, "Keyboard had no name???"); // logic error
}
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
const auto PKEYBOARD = (SKeyboard*)owner;
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
}, PNEWKEYBOARD, "Keyboard");
disableAllKeyboards(true);
m_pActiveKeyboard = PNEWKEYBOARD;
PNEWKEYBOARD->active = true;
applyConfigToKeyboard(PNEWKEYBOARD);
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard));
Debug::log(LOG, "New virtual keyboard created, pointers Hypr: %x and WLR: %x", PNEWKEYBOARD, keyboard);
}
void CInputManager::setKeyboardLayout() {
for (auto& k : m_lKeyboards)
applyConfigToKeyboard(&k);
g_pKeybindManager->updateXKBTranslationState();
}
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(pKeyboard->name);
auto devname = pKeyboard->name;
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
Debug::log(LOG, "ApplyConfigToKeyboard for \"%s\", hasconfig: %i", pKeyboard->name.c_str(), (int)HASCONFIG);
ASSERT(pKeyboard);
if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
return;
const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(pKeyboard->name, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default");
const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default");
const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_model") : g_pConfigManager->getString("input:kb_model");
const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(pKeyboard->name, "kb_options") : g_pConfigManager->getString("input:kb_options");
const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file");
const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model");
const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
try {
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) {
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) {
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
return;
}
@@ -441,6 +579,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
pKeyboard->repeatDelay = REPEATDELAY;
pKeyboard->repeatRate = REPEATRATE;
pKeyboard->numlockOn = NUMLOCKON;
pKeyboard->xkbFilePath = FILEPATH.c_str();
xkb_rule_names rules = {
.rules = RULES.c_str(),
@@ -464,9 +603,25 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_keymap * KEYMAP = NULL;
if (!FILEPATH.empty()) {
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
if (!std::filesystem::exists(path)) {
Debug::log(ERR, "input:kb_file= file doesnt exist");
} else {
KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
}
if (!KEYMAP) {
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
if (!KEYMAP) {
g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )");
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
memset(&rules, 0, sizeof(rules));
@@ -498,6 +653,8 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
xkb_keymap_unref(KEYMAP);
xkb_context_unref(CONTEXT);
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," +getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
}
@@ -513,47 +670,14 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
Debug::log(ERR, "Mouse had no name???"); // logic error
}
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PMOUSE->name);
if (wlr_input_device_is_libinput(mouse)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse);
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
else
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "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);
else
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
}
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0)
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
else
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
double w = 0, h = 0;
if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
else
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
}
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
const auto DWT = static_cast<enum libinput_config_dwt_state>((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
}
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();
PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
@@ -565,6 +689,63 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse);
}
void CInputManager::setMouseConfigs() {
for (auto& m : m_lMice) {
const auto PMOUSE = &m;
auto devname = PMOUSE->name;
transform(devname.begin(), devname.end(), devname.begin(), ::tolower);
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
if (wlr_input_device_is_libinput(m.mouse)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
else
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
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)
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
else
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
}
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);
else
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
double w = 0, h = 0;
if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
else
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
}
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
const auto DWT = static_cast<enum libinput_config_dwt_state>((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
}
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);
Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS);
}
}
}
void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
pKeyboard->hyprListener_keyboardDestroy.removeCallback();
pKeyboard->hyprListener_keyboardMod.removeCallback();
@@ -595,38 +776,51 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
g_pCompositor->m_sSeat.mouse = m_lMice.size() > 0 ? &m_lMice.front() : nullptr;
if (g_pCompositor->m_sSeat.mouse)
g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
unconstrainMouse();
}
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
const xkb_keysym_t* keysyms;
int syms = xkb_state_key_get_syms(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE, &keysyms);
const auto MODS = accumulateModsFromAllKBs();
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
bool found = false;
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
for (int i = 0; i < syms; ++i)
found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
if (passEvent) {
found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found;
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
// hee hee
}
const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard);
if (!found) {
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);
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_send_key(PIMEGRAB->pWlrKbGrab, e->time_msec, e->keycode, e->state);
} else {
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);
}
}
}
void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
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);
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) {
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, &MODS);
} else {
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, &MODS);
}
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
pKeyboard->activeLayout = PWLRKB->modifiers.group;
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
}
}
void CInputManager::refocus() {
@@ -634,16 +828,16 @@ void CInputManager::refocus() {
}
void CInputManager::updateDragIcon() {
if (!g_pInputManager->m_sDrag.dragIcon)
if (!m_sDrag.dragIcon)
return;
switch (g_pInputManager->m_sDrag.dragIcon->drag->grab_type) {
switch (m_sDrag.dragIcon->drag->grab_type) {
case WLR_DRAG_GRAB_KEYBOARD:
break;
case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
wlr_box box = {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};
wlr_box box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
g_pHyprRenderer->damageBox(&box);
g_pInputManager->m_sDrag.pos = g_pInputManager->getMouseCoordsInternal();
m_sDrag.pos = getMouseCoordsInternal();
break;
}
default:
@@ -722,6 +916,25 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
Debug::log(LOG, "Constrained mouse to %x", pMouse->currentConstraint);
}
void CInputManager::unconstrainMouse() {
if (!g_pCompositor->m_sSeat.mouse->currentConstraint)
return;
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (CONSTRAINTWINDOW) {
g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW), false);
}
wlr_pointer_constraint_v1_send_deactivated(g_pCompositor->m_sSeat.mouse->currentConstraint);
g_pCompositor->m_sSeat.mouse->constraintActive = false;
// TODO: its better to somehow detect the workspace...
g_pCompositor->m_sSeat.mouse->currentConstraint = nullptr;
g_pCompositor->m_sSeat.mouse->hyprListener_commitConstraint.removeCallback();
}
void Events::listener_commitConstraint(void* owner, void* data) {
//g_pInputManager->recheckConstraint((SMouse*)owner);
}
@@ -751,8 +964,40 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
uint32_t finalMask = 0;
for (auto& kb : m_lKeyboards) {
if (kb.isVirtual)
continue;
finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard));
}
return finalMask;
}
std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
const auto KEYMAP = WLRKB->keymap;
const auto STATE = WLRKB->xkb_state;
const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
if (xkb_state_layout_index_is_active(STATE, i, XKB_STATE_LAYOUT_EFFECTIVE)) {
const auto LAYOUTNAME = xkb_keymap_layout_get_name(KEYMAP, i);
if (LAYOUTNAME)
return std::string(LAYOUTNAME);
return "error";
}
}
return "none";
}
void CInputManager::disableAllKeyboards(bool virt) {
for (auto& k : m_lKeyboards) {
if (k.isVirtual != virt)
continue;
k.active = false;
}
}

View File

@@ -5,33 +5,44 @@
#include "../../helpers/WLClasses.hpp"
#include "../../Window.hpp"
#include "../../helpers/Timer.hpp"
#include "InputMethodRelay.hpp"
enum eClickBehaviorMode {
CLICKMODE_DEFAULT = 0,
CLICKMODE_KILL
};
struct STouchData {
CWindow* touchFocusWindow = nullptr;
Vector2D touchSurfaceOrigin;
};
class CInputManager {
public:
void onMouseMoved(wlr_pointer_motion_event*);
void onMouseWarp(wlr_pointer_motion_absolute_event*);
void onMouseButton(wlr_pointer_button_event*);
void onMouseWheel(wlr_pointer_axis_event*);
void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
void onKeyboardMod(void*, SKeyboard*);
void newKeyboard(wlr_input_device*);
void newVirtualKeyboard(wlr_input_device*);
void newMouse(wlr_input_device*, bool virt = false);
void destroyKeyboard(SKeyboard*);
void destroyMouse(wlr_input_device*);
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
void recheckConstraint(SMouse*);
void unconstrainMouse();
std::string getActiveLayoutForKeyboard(SKeyboard*);
Vector2D getMouseCoordsInternal();
void refocus();
void setKeyboardLayout();
void setMouseConfigs();
void updateDragIcon();
void updateCapabilities(wlr_input_device*);
@@ -40,6 +51,11 @@ public:
eClickBehaviorMode getClickMode();
void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
void onTouchDown(wlr_touch_down_event*);
void onTouchUp(wlr_touch_up_event*);
void onTouchMove(wlr_touch_motion_event*);
STouchData m_sTouchData;
// for dragging floating windows
CWindow* currentlyDraggedWindow = nullptr;
@@ -75,15 +91,28 @@ public:
CTimer m_tmrLastCursorMovement;
CInputMethodRelay m_sIMERelay;
// for shared mods
uint32_t accumulateModsFromAllKBs();
CWindow* m_pFollowOnDnDBegin = nullptr;
private:
// for click behavior override
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
bool m_bEmptyFocusCursorSet = false;
Vector2D m_vLastCursorPosFloored = Vector2D();
// for some bugs in follow mouse 0
bool m_bLastFocusOnLS = false;
void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e);
void disableAllKeyboards(bool virt = false);
uint32_t m_uiCapabilities = 0;
void mouseMoveUnified(uint32_t, bool refocus = false);
@@ -91,9 +120,6 @@ private:
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
void applyConfigToKeyboard(SKeyboard*);
// for shared mods
uint32_t accumulateModsFromAllKBs();
};
inline std::unique_ptr<CInputManager> g_pInputManager;

View File

@@ -0,0 +1,451 @@
#include "InputMethodRelay.hpp"
#include "InputManager.hpp"
#include "../../Compositor.hpp"
CInputMethodRelay::CInputMethodRelay() {
}
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
if (m_pWLRIME) {
Debug::log(ERR, "Cannot register 2 IMEs at once!");
wlr_input_method_v2_send_unavailable(pIME);
return;
}
m_pWLRIME = pIME;
hyprListener_IMECommit.initCallback(&m_pWLRIME->events.commit, [&](void* owner, void* data) {
const auto PTI = getFocusedTextInput();
const auto PIMR = (CInputMethodRelay*)owner;
if (!PTI) {
Debug::log(LOG, "No focused TextInput on IME Commit");
return;
}
if (PIMR->m_pWLRIME->current.preedit.text) {
wlr_text_input_v3_send_preedit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.preedit.text, PIMR->m_pWLRIME->current.preedit.cursor_begin, PIMR->m_pWLRIME->current.preedit.cursor_end);
}
if (PIMR->m_pWLRIME->current.commit_text) {
wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
}
if (PIMR->m_pWLRIME->current.delete_.before_length || PIMR->m_pWLRIME->current.delete_.after_length) {
wlr_text_input_v3_send_delete_surrounding_text(PTI->pWlrInput, PIMR->m_pWLRIME->current.delete_.before_length, PIMR->m_pWLRIME->current.delete_.after_length);
}
wlr_text_input_v3_send_done(PTI->pWlrInput);
}, this, "IMERelay");
hyprListener_IMEDestroy.initCallback(&m_pWLRIME->events.destroy, [&](void* owner, void* data) {
m_pWLRIME = nullptr;
hyprListener_IMEDestroy.removeCallback();
hyprListener_IMECommit.removeCallback();
hyprListener_IMEGrab.removeCallback();
hyprListener_IMENewPopup.removeCallback();
m_pKeyboardGrab.reset(nullptr);
const auto PTI = getFocusedTextInput();
Debug::log(LOG, "IME Destroy");
if (PTI) {
setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
wlr_text_input_v3_send_leave(PTI->pWlrInput);
}
}, this, "IMERelay");
hyprListener_IMEGrab.initCallback(&m_pWLRIME->events.grab_keyboard, [&](void* owner, void* data) {
Debug::log(LOG, "IME TextInput Keyboard Grab new");
m_pKeyboardGrab.reset(nullptr);
m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(&PKBGRAB->events.destroy, [&](void* owner, void* data) {
m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
if (m_pKeyboardGrab->pKeyboard) {
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
}
m_pKeyboardGrab.reset(nullptr);
}, m_pKeyboardGrab.get(), "IME Keyboard Grab");
}, this, "IMERelay");
hyprListener_IMENewPopup.initCallback(&m_pWLRIME->events.new_popup_surface, [&](void* owner, void* data) {
const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
PNEWPOPUP->hyprListener_commitPopup.initCallback(&PNEWPOPUP->pSurface->surface->events.commit, &Events::listener_commitInputPopup, PNEWPOPUP, "IME Popup");
PNEWPOPUP->hyprListener_mapPopup.initCallback(&PNEWPOPUP->pSurface->events.map, &Events::listener_mapInputPopup, PNEWPOPUP, "IME Popup");
PNEWPOPUP->hyprListener_unmapPopup.initCallback(&PNEWPOPUP->pSurface->events.unmap, &Events::listener_unmapInputPopup, PNEWPOPUP, "IME Popup");
PNEWPOPUP->hyprListener_destroyPopup.initCallback(&PNEWPOPUP->pSurface->events.destroy, &Events::listener_destroyInputPopup, PNEWPOPUP, "IME Popup");
Debug::log(LOG, "New input popup");
}, this, "IMERelay");
const auto PTI = getFocusableTextInput();
if (PTI) {
wlr_text_input_v3_send_enter(PTI->pWlrInput, PTI->pPendingSurface);
setPendingSurface(PTI, nullptr);
}
}
void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
if (!pPopup->pSurface->mapped)
return;
// damage last known pos & size
g_pHyprRenderer->damageBox(pPopup->realX, pPopup->realY, pPopup->lastSize.x, pPopup->lastSize.y);
const auto PFOCUSEDTI = getFocusedTextInput();
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
return;
bool cursorRect = PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
Vector2D parentPos;
Vector2D parentSize;
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
if (PLS) {
parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
parentSize = Vector2D(PLS->geometry.width, PLS->geometry.height);
}
} else {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
if (PWINDOW) {
parentPos = PWINDOW->m_vRealPosition.goalv();
parentSize = PWINDOW->m_vRealSize.goalv();
}
}
if (!cursorRect) {
cursorBox = {0, 0, (int)parentSize.x, (int)parentSize.y};
}
// todo: anti-overflow
wlr_box finalBox = cursorBox;
pPopup->x = finalBox.x;
pPopup->y = finalBox.y + finalBox.height;
pPopup->realX = finalBox.x + parentPos.x;
pPopup->realY = finalBox.y + parentPos.y + finalBox.height;
pPopup->lastSize = Vector2D(pPopup->pSurface->surface->current.width, pPopup->pSurface->surface->current.height);
wlr_input_popup_surface_v2_send_text_input_rectangle(pPopup->pSurface, &finalBox);
damagePopup(pPopup);
}
void CInputMethodRelay::setIMEPopupFocus(SIMEPopup* pPopup, wlr_surface* pSurface) {
updateInputPopup(pPopup);
}
void Events::listener_mapInputPopup(void* owner, void* data) {
const auto PPOPUP = (SIMEPopup*)owner;
Debug::log(LOG, "Mapped an IME Popup");
g_pInputManager->m_sIMERelay.updateInputPopup(PPOPUP);
}
void Events::listener_unmapInputPopup(void* owner, void* data) {
const auto PPOPUP = (SIMEPopup*)owner;
Debug::log(LOG, "Unmapped an IME Popup");
g_pHyprRenderer->damageBox(PPOPUP->realX, PPOPUP->realY, PPOPUP->lastSize.x, PPOPUP->lastSize.y);
g_pInputManager->m_sIMERelay.updateInputPopup(PPOPUP);
}
void Events::listener_destroyInputPopup(void* owner, void* data) {
const auto PPOPUP = (SIMEPopup*)owner;
Debug::log(LOG, "Removed an IME Popup");
PPOPUP->hyprListener_commitPopup.removeCallback();
PPOPUP->hyprListener_destroyPopup.removeCallback();
PPOPUP->hyprListener_focusedSurfaceUnmap.removeCallback();
PPOPUP->hyprListener_mapPopup.removeCallback();
PPOPUP->hyprListener_unmapPopup.removeCallback();
g_pInputManager->m_sIMERelay.removePopup(PPOPUP);
}
void Events::listener_commitInputPopup(void* owner, void* data) {
const auto PPOPUP = (SIMEPopup*)owner;
g_pInputManager->m_sIMERelay.updateInputPopup(PPOPUP);
}
void CInputMethodRelay::removePopup(SIMEPopup* pPopup) {
m_lIMEPopups.remove(*pPopup);
}
void CInputMethodRelay::damagePopup(SIMEPopup* pPopup) {
if (!pPopup->pSurface->mapped)
return;
const auto PFOCUSEDTI = getFocusedTextInput();
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
return;
Vector2D parentPos;
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
if (PLS) {
parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
}
} else {
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
if (PWINDOW) {
parentPos = PWINDOW->m_vRealPosition.goalv();
}
}
g_pHyprRenderer->damageSurface(pPopup->pSurface->surface, parentPos.x + pPopup->x, parentPos.y + pPopup->y);
}
SIMEKbGrab* CInputMethodRelay::getIMEKeyboardGrab(SKeyboard* pKeyboard) {
if (!m_pWLRIME)
return nullptr;
if (!m_pKeyboardGrab.get())
return nullptr;
const auto VIRTKB = wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard);
if (VIRTKB && (wl_resource_get_client(VIRTKB->resource) == wl_resource_get_client(m_pKeyboardGrab->pWlrKbGrab->resource)))
return nullptr;
return m_pKeyboardGrab.get();
}
STextInput* CInputMethodRelay::getFocusedTextInput() {
for (auto& ti : m_lTextInputs) {
if (ti.pWlrInput->focused_surface) {
return &ti;
}
}
return nullptr;
}
STextInput* CInputMethodRelay::getFocusableTextInput() {
for (auto& ti : m_lTextInputs) {
if (ti.pPendingSurface) {
return &ti;
}
}
return nullptr;
}
void CInputMethodRelay::onNewTextInput(wlr_text_input_v3* pInput) {
createNewTextInput(pInput);
}
void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
const auto PTEXTINPUT = &m_lTextInputs.emplace_back();
PTEXTINPUT->pWlrInput = pInput;
PTEXTINPUT->hyprListener_textInputEnable.initCallback(&pInput->events.enable, [](void* owner, void* data) {
const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Enabling TextInput on no IME!");
return;
}
Debug::log(LOG, "Enable TextInput");
wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
}, PTEXTINPUT, "textInput");
PTEXTINPUT->hyprListener_textInputCommit.initCallback(&pInput->events.commit, [](void* owner, void* data) {
const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Committing TextInput on no IME!");
return;
}
if (!PINPUT->pWlrInput->current_enabled) {
Debug::log(ERR, "Disabled TextInput commit?");
return;
}
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
}, PTEXTINPUT, "textInput");
PTEXTINPUT->hyprListener_textInputDisable.initCallback(&pInput->events.disable, [](void* owner, void* data) {
const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Disabling TextInput on no IME!");
return;
}
Debug::log(LOG, "Disable TextInput");
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
}, PTEXTINPUT, "textInput");
PTEXTINPUT->hyprListener_textInputDestroy.initCallback(&pInput->events.destroy, [](void* owner, void* data) {
const auto PINPUT = (STextInput*)owner;
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
Debug::log(ERR, "Disabling TextInput on no IME!");
return;
}
if (PINPUT->pWlrInput->current_enabled) {
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
}
g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
PINPUT->hyprListener_textInputCommit.removeCallback();
PINPUT->hyprListener_textInputDestroy.removeCallback();
PINPUT->hyprListener_textInputDisable.removeCallback();
PINPUT->hyprListener_textInputEnable.removeCallback();
g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
}, PTEXTINPUT, "textInput");
}
void CInputMethodRelay::removeTextInput(wlr_text_input_v3* pInput) {
m_lTextInputs.remove_if([&](const auto& other) { return other.pWlrInput == pInput; });
}
void CInputMethodRelay::commitIMEState(wlr_text_input_v3* pInput) {
if (!m_pWLRIME)
return;
if (pInput->active_features & WLR_TEXT_INPUT_V3_FEATURE_SURROUNDING_TEXT)
wlr_input_method_v2_send_surrounding_text(m_pWLRIME, pInput->current.surrounding.text, pInput->current.surrounding.cursor, pInput->current.surrounding.anchor);
wlr_input_method_v2_send_text_change_cause(m_pWLRIME, pInput->current.text_change_cause);
if (pInput->active_features & WLR_TEXT_INPUT_V3_FEATURE_CONTENT_TYPE)
wlr_input_method_v2_send_content_type(m_pWLRIME, pInput->current.content_type.hint, pInput->current.content_type.purpose);
for (auto& p : m_lIMEPopups) {
updateInputPopup(&p);
}
wlr_input_method_v2_send_done(m_pWLRIME);
}
void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
if (!m_pWLRIME)
return;
for (auto& ti : m_lTextInputs) {
if (ti.pPendingSurface) {
if (pSurface != ti.pPendingSurface)
setPendingSurface(&ti, nullptr);
} else if (ti.pWlrInput->focused_surface) {
if (pSurface != ti.pWlrInput->focused_surface) {
wlr_input_method_v2_send_deactivate(m_pWLRIME);
commitIMEState(ti.pWlrInput);
wlr_text_input_v3_send_leave(ti.pWlrInput);
} else {
continue;
}
}
if (pSurface && wl_resource_get_client(ti.pWlrInput->resource) == wl_resource_get_client(pSurface->resource)) {
if (m_pWLRIME) {
wlr_text_input_v3_send_enter(ti.pWlrInput, pSurface);
} else {
setPendingSurface(&ti, pSurface);
}
}
}
}
void CInputMethodRelay::setPendingSurface(STextInput* pInput, wlr_surface* pSurface) {
pInput->pPendingSurface = pSurface;
if (pSurface) {
pInput->hyprListener_pendingSurfaceDestroy.initCallback(&pSurface->events.destroy, [](void* owner, void* data) {
const auto PINPUT = (STextInput*)owner;
PINPUT->pPendingSurface = nullptr;
PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
}, pInput, "TextInput");
} else {
pInput->hyprListener_pendingSurfaceDestroy.removeCallback();
}
}

View File

@@ -0,0 +1,48 @@
#pragma once
#include "../../defines.hpp"
#include "../../helpers/WLClasses.hpp"
class CInputMethodRelay {
public:
CInputMethodRelay();
void onNewIME(wlr_input_method_v2*);
void onNewTextInput(wlr_text_input_v3*);
wlr_input_method_v2* m_pWLRIME = nullptr;
void commitIMEState(wlr_text_input_v3*);
void removeTextInput(wlr_text_input_v3*);
void onKeyboardFocus(wlr_surface*);
STextInput* getFocusedTextInput();
STextInput* getFocusableTextInput();
void setPendingSurface(STextInput*, wlr_surface*);
SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
void updateInputPopup(SIMEPopup*);
void damagePopup(SIMEPopup*);
void removePopup(SIMEPopup*);
private:
std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;
std::list<STextInput> m_lTextInputs;
std::list<SIMEPopup> m_lIMEPopups;
DYNLISTENER(textInputNew);
DYNLISTENER(IMECommit);
DYNLISTENER(IMEDestroy);
DYNLISTENER(IMEGrab);
DYNLISTENER(IMENewPopup);
void createNewTextInput(wlr_text_input_v3*);
friend class CHyprRenderer;
};

View File

@@ -4,10 +4,21 @@
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
if (e->fingers < 3 || *PSWIPE == 0)
if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
return;
int onMonitor = 0;
for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID) {
onMonitor++;
}
}
if (onMonitor < 2)
return; // disallow swiping when there's 1 workspace on a monitor
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
@@ -40,15 +51,21 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) {
// revert
if (m_sActiveSwipe.delta < 0) {
// to left
PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0});
if (abs(m_sActiveSwipe.delta) < 2) {
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
} else {
// to right
PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0});
}
if (m_sActiveSwipe.delta < 0) {
// to left
PWORKSPACEL->m_vRenderOffset = Vector2D({-m_sActiveSwipe.pMonitor->vecSize.x, 0});
} else {
// to right
PWORKSPACER->m_vRenderOffset = Vector2D({m_sActiveSwipe.pMonitor->vecSize.x, 0});
}
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
}
} else if (m_sActiveSwipe.delta < 0) {
// switch to left
const auto RENDEROFFSET = PWORKSPACEL->m_vRenderOffset.vec();
@@ -58,6 +75,12 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
PWORKSPACEL->m_vRenderOffset.setValue(RENDEROFFSET);
PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the left");
} else {
// switch to right
@@ -68,11 +91,16 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET);
PWORKSPACER->m_fAlpha.setValueAndWarp(255.f);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-m_sActiveSwipe.pMonitor->vecSize.x, 0);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
g_pInputManager->unconstrainMouse();
Debug::log(LOG, "Ended swipe to the right");
}
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f);
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
PWORKSPACEL->m_bForceRendering = false;
PWORKSPACER->m_bForceRendering = false;
@@ -102,6 +130,8 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
if (workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)
return;
m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = true;
m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
if (m_sActiveSwipe.delta < 0) {
@@ -113,11 +143,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
PWORKSPACE->m_bForceRendering = true;
PWORKSPACE->m_fAlpha.setValueAndWarp(255.f);
if (workspaceIDLeft != workspaceIDRight) {
const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight);
PWORKSPACER->m_bForceRendering = false;
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));
@@ -133,11 +165,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight);
PWORKSPACE->m_bForceRendering = true;
PWORKSPACE->m_fAlpha.setValueAndWarp(255.f);
if (workspaceIDLeft != workspaceIDRight) {
const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
PWORKSPACEL->m_bForceRendering = false;
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));

View File

@@ -0,0 +1,45 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
void CInputManager::onTouchDown(wlr_touch_down_event* e) {
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);
refocus();
m_sTouchData.touchFocusWindow = nullptr;
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) {
Vector2D local;
if (g_pCompositor->m_pLastWindow->m_bIsX11) {
local = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv();
} else {
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), g_pCompositor->m_pLastWindow, local);
}
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
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.touchFocusWindow = g_pCompositor->m_pLastWindow;
}
}
void CInputManager::onTouchUp(wlr_touch_up_event* e){
if (m_sTouchData.touchFocusWindow) {
wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id);
}
}
void CInputManager::onTouchMove(wlr_touch_motion_event* e){
if (g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
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);
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);
}
}

View File

@@ -2,15 +2,14 @@
#include "OpenGL.hpp"
bool CFramebuffer::alloc(int w, int h) {
bool firstAlloc = false;
if (m_iFb == (uint32_t)-1)
{
bool firstAlloc = false;
if (m_iFb == (uint32_t)-1) {
firstAlloc = true;
glGenFramebuffers(1, &m_iFb);
}
if (m_cTex.m_iTexID == 0)
{
if (m_cTex.m_iTexID == 0) {
firstAlloc = true;
glGenTextures(1, &m_cTex.m_iTexID);
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
@@ -20,13 +19,11 @@ bool CFramebuffer::alloc(int w, int h) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
if (firstAlloc || m_Size != Vector2D(w, h))
{
if (firstAlloc || m_Size != Vector2D(w, h)) {
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);
@@ -37,7 +34,6 @@ bool CFramebuffer::alloc(int w, int h) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0);
}
@@ -78,3 +74,7 @@ void CFramebuffer::release() {
m_cTex.m_iTexID = 0;
m_iFb = -1;
}
CFramebuffer::~CFramebuffer() {
release();
}

View File

@@ -6,6 +6,8 @@
class CFramebuffer {
public:
~CFramebuffer();
bool alloc(int w, int h);
void bind();
void release();

View File

@@ -23,72 +23,6 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
Debug::log(WARN, "!RENDERER: Using the legacy GLES2 renderer!");
#endif
// Init shaders
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
m_shQUAD.program = prog;
m_shQUAD.proj = glGetUniformLocation(prog, "proj");
m_shQUAD.color = glGetUniformLocation(prog, "color");
m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
m_shQUAD.texAttrib = glGetAttribLocation(prog, "texcoord");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
m_shRGBA.program = prog;
m_shRGBA.proj = glGetUniformLocation(prog, "proj");
m_shRGBA.tex = glGetUniformLocation(prog, "tex");
m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
m_shRGBX.program = prog;
m_shRGBX.tex = glGetUniformLocation(prog, "tex");
m_shRGBX.proj = glGetUniformLocation(prog, "proj");
m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
m_shEXT.program = prog;
m_shEXT.tex = glGetUniformLocation(prog, "tex");
m_shEXT.proj = glGetUniformLocation(prog, "proj");
m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
m_shBLUR1.program = prog;
m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos");
m_shBLUR1.texAttrib = glGetAttribLocation(prog, "texcoord");
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
m_shBLUR2.program = prog;
m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos");
m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord");
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
m_shSHADOW.program = prog;
m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
prog = createProgram(QUADVERTSRC, FRAGBORDER1);
m_shBORDER1.program = prog;
m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
Debug::log(LOG, "Shaders initialized successfully.");
// End shaders
pixman_region32_init(&m_rOriginalDamageRegion);
@@ -139,9 +73,13 @@ GLuint CHyprOpenGLImpl::compileShader(const GLuint& type, std::string src) {
return shader;
}
void CHyprOpenGLImpl::begin(SMonitor* pMonitor, pixman_region32_t* pDamage, bool fake) {
void CHyprOpenGLImpl::begin(CMonitor* pMonitor, pixman_region32_t* pDamage, bool fake) {
m_RenderData.pMonitor = pMonitor;
if (eglGetCurrentContext() != wlr_egl_get_context(g_pCompositor->m_sWLREGL)) {
eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL));
}
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
@@ -168,6 +106,9 @@ void CHyprOpenGLImpl::begin(SMonitor* pMonitor, pixman_region32_t* pDamage, bool
createBGTextureForMonitor(pMonitor);
}
if (!m_RenderData.pCurrentMonData->m_bShadersInitialized)
initShaders();
// bind the primary Hypr Framebuffer
m_RenderData.pCurrentMonData->primaryFB.bind();
@@ -198,6 +139,118 @@ void CHyprOpenGLImpl::end() {
m_iWLROutputFb = 0;
}
void CHyprOpenGLImpl::initShaders() {
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
m_RenderData.pCurrentMonData->m_shQUAD.program = prog;
m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color");
m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shQUAD.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shQUAD.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
m_RenderData.pCurrentMonData->m_shRGBA.program = prog;
m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex");
m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shRGBA.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shRGBA.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shRGBX.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shRGBX.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint");
m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint");
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
m_RenderData.pCurrentMonData->m_shEXT.program = prog;
m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex");
m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shEXT.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shEXT.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint");
m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint");
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
m_RenderData.pCurrentMonData->m_shBLUR1.program = prog;
m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shBLUR1.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shBLUR1.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel = glGetUniformLocation(prog, "halfpixel");
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
m_RenderData.pCurrentMonData->m_shBLUR2.program = prog;
m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shBLUR2.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel = glGetUniformLocation(prog, "halfpixel");
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
m_RenderData.pCurrentMonData->m_shSHADOW.program = prog;
m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range");
m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower = glGetUniformLocation(prog, "shadowPower");
m_RenderData.pCurrentMonData->m_shSHADOW.color = glGetUniformLocation(prog, "color");
prog = createProgram(QUADVERTSRC, FRAGBORDER1);
m_RenderData.pCurrentMonData->m_shBORDER1.program = prog;
m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick");
m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft");
m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight");
m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize");
m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius");
m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
m_RenderData.pCurrentMonData->m_shBORDER1.color = glGetUniformLocation(prog, "color");
m_RenderData.pCurrentMonData->m_bShadersInitialized = true;
Debug::log(LOG, "Shaders initialized successfully.");
}
void CHyprOpenGLImpl::clear(const CColor& color) {
RASSERT(m_RenderData.pMonitor, "Tried to render without begin()!");
@@ -215,7 +268,7 @@ void CHyprOpenGLImpl::clear(const CColor& color) {
scissor((wlr_box*)nullptr);
}
void CHyprOpenGLImpl::scissor(const wlr_box* pBox) {
void CHyprOpenGLImpl::scissor(const wlr_box* pBox, bool transform) {
RASSERT(m_RenderData.pMonitor, "Tried to scissor without begin()!");
if (!pBox) {
@@ -225,17 +278,19 @@ void CHyprOpenGLImpl::scissor(const wlr_box* pBox) {
wlr_box newBox = *pBox;
int w, h;
wlr_output_transformed_resolution(m_RenderData.pMonitor->output, &w, &h);
if (transform) {
int w, h;
wlr_output_transformed_resolution(m_RenderData.pMonitor->output, &w, &h);
const auto TR = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
wlr_box_transform(&newBox, &newBox, TR, w, h);
const auto TR = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
wlr_box_transform(&newBox, &newBox, TR, w, h);
}
glScissor(newBox.x, newBox.y, newBox.width, newBox.height);
glEnable(GL_SCISSOR_TEST);
}
void CHyprOpenGLImpl::scissor(const pixman_box32* pBox) {
void CHyprOpenGLImpl::scissor(const pixman_box32* pBox, bool transform) {
RASSERT(m_RenderData.pMonitor, "Tried to scissor without begin()!");
if (!pBox) {
@@ -245,12 +300,12 @@ void CHyprOpenGLImpl::scissor(const pixman_box32* pBox) {
wlr_box newBox = {pBox->x1, pBox->y1, pBox->x2 - pBox->x1, pBox->y2 - pBox->y1};
scissor(&newBox);
scissor(&newBox, transform);
}
void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h) {
void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h, bool transform) {
wlr_box box = {x,y,w,h};
scissor(&box);
scissor(&box, transform);
}
void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
@@ -273,10 +328,10 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(m_shQUAD.program);
glUseProgram(m_RenderData.pCurrentMonData->m_shQUAD.program);
glUniformMatrix3fv(m_shQUAD.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
const auto TOPLEFT = Vector2D(round, round);
const auto BOTTOMRIGHT = Vector2D(box->width - round, box->height - round);
@@ -285,17 +340,17 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
// Rounded corners
glUniform2f(m_shQUAD.getUniformLocation("topLeft"), (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_shQUAD.getUniformLocation("bottomRight"), (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_shQUAD.getUniformLocation("fullSize"), (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_shQUAD.getUniformLocation("radius"), round);
glUniform1i(m_shQUAD.getUniformLocation("primitiveMultisample"), (int)(*PMULTISAMPLEEDGES == 1 && round != 0));
glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_RenderData.pCurrentMonData->m_shQUAD.radius, round);
glUniform1i(m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample, (int)(*PMULTISAMPLEEDGES == 1 && round != 0));
glVertexAttribPointer(m_shQUAD.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_shQUAD.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shQUAD.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glEnableVertexAttribArray(m_shQUAD.posAttrib);
glEnableVertexAttribArray(m_shQUAD.texAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.texAttrib);
if (pixman_region32_not_empty(damage)) {
PIXMAN_DAMAGE_FOREACH(damage) {
@@ -305,8 +360,8 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
}
}
glDisableVertexAttribArray(m_shQUAD.posAttrib);
glDisableVertexAttribArray(m_shQUAD.texAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.texAttrib);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -320,15 +375,17 @@ void CHyprOpenGLImpl::renderTexture(wlr_texture* tex, wlr_box* pBox, float alpha
void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round, bool discardopaque, bool allowCustomUV) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardopaque, false, allowCustomUV);
renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardopaque, false, allowCustomUV, true);
scissor((wlr_box*)nullptr);
}
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA, bool allowCustomUV) {
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA, bool allowCustomUV, bool allowDim) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
static auto *const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
// get transform
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
float matrix[9];
@@ -347,13 +404,13 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
switch (tex.m_iType) {
case TEXTURE_RGBA:
shader = &m_shRGBA;
shader = &m_RenderData.pCurrentMonData->m_shRGBA;
break;
case TEXTURE_RGBX:
shader = &m_shRGBX;
shader = &m_RenderData.pCurrentMonData->m_shRGBX;
break;
case TEXTURE_EXTERNAL:
shader = &m_shEXT;
shader = &m_RenderData.pCurrentMonData->m_shEXT;
break;
default:
RASSERT(false, "tex.m_iTarget unsupported!");
@@ -380,22 +437,30 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
// Rounded corners
glUniform2f(shader->getUniformLocation("topLeft"), (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(shader->getUniformLocation("bottomRight"), (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(shader->getUniformLocation("fullSize"), (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(shader->getUniformLocation("radius"), round);
glUniform1i(shader->getUniformLocation("primitiveMultisample"), (int)(*PMULTISAMPLEEDGES == 1 && round != 0 && !noAA));
glUniform2f(shader->topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(shader->bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(shader->fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(shader->radius, round);
glUniform1i(shader->primitiveMultisample, (int)(*PMULTISAMPLEEDGES == 1 && round != 0 && !noAA));
if (allowDim && m_pCurrentWindow && *PDIMINACTIVE && m_pCurrentWindow != g_pCompositor->m_pLastWindow) {
glUniform1i(shader->applyTint, 1);
const auto DIM = m_pCurrentWindow->m_fDimPercent.fl();
glUniform3f(shader->tint, 1.f - DIM, 1.f - DIM, 1.f - DIM);
} else {
glUniform1i(shader->applyTint, 0);
}
glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
if (allowCustomUV && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) {
const float verts[] = {
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
};
const float verts[] = {
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
};
if (allowCustomUV && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) {
glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, verts);
} else {
glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
@@ -428,9 +493,9 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
glDisable(GL_STENCIL_TEST);
// get transforms for the full monitor
const auto TRANSFORM = wlr_output_transform_invert(WL_OUTPUT_TRANSFORM_NORMAL);
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
float matrix[9];
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y};
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix);
float glMatrix[9];
@@ -446,8 +511,9 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
pixman_region32_t damage;
pixman_region32_init(&damage);
pixman_region32_copy(&damage, originalDamage);
wlr_region_transform(&damage, &damage, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
wlr_region_expand(&damage, &damage, pow(2, *PBLURPASSES) * *PBLURSIZE);
// helper
const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB;
const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB;
@@ -471,11 +537,11 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
// prep two shaders
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix);
glUniform1f(pShader->getUniformLocation("radius"), *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a
if (pShader == &m_shBLUR1)
glUniform2f(m_shBLUR1.getUniformLocation("halfpixel"), 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f));
glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a
if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1)
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f));
else
glUniform2f(m_shBLUR2.getUniformLocation("halfpixel"), 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f));
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f));
glUniform1i(pShader->tex, 0);
glVertexAttribPointer(pShader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
@@ -487,7 +553,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
if (pixman_region32_not_empty(pDamage)) {
PIXMAN_DAMAGE_FOREACH(pDamage) {
const auto RECT = RECTSARR[i];
scissor(&RECT);
scissor(&RECT, false /* this region is already transformed */);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -510,19 +576,19 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
// damage region will be scaled, make a temp
pixman_region32_t tempDamage;
pixman_region32_init(&tempDamage);
wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET
drawPass(&m_shBLUR1, &tempDamage);
wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage);
// and draw
for (int i = 1; i < *PBLURPASSES; ++i) {
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << (i + 1)));
drawPass(&m_shBLUR1, &tempDamage); // down
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // down
}
for (int i = *PBLURPASSES - 1; i >= 0; --i) {
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << i)); // when upsampling we make the region twice as big
drawPass(&m_shBLUR2, &tempDamage); // up
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR2, &tempDamage); // up
}
// finish
@@ -537,11 +603,79 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
return currentRenderToFB;
}
void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) {
m_mMonitorRenderResources[pMonitor].blurFBDirty = true;
}
void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
if (!*PBLURNEWOPTIMIZE || !m_mMonitorRenderResources[pMonitor].blurFBDirty)
return;
bool has = false;
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pMonitor->activeWorkspace && w->m_bIsMapped && !w->m_bHidden && !w->m_bIsFloating) {
has = true;
break;
}
}
if (has)
g_pHyprRenderer->damageMonitor(pMonitor);
}
void CHyprOpenGLImpl::preBlurForCurrentMonitor() {
// make the fake dmg
pixman_region32_t fakeDamage;
pixman_region32_init_rect(&fakeDamage, 0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage);
// render onto blurFB
m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y);
m_RenderData.pCurrentMonData->blurFB.bind();
clear(CColor(0,0,0,0));
m_bEndFrame = true; // fix transformed
renderTextureInternalWithDamage(POUTFB->m_cTex, &wholeMonitor, 255, &fakeDamage, 0, false, true, false);
m_bEndFrame = false;
m_RenderData.pCurrentMonData->primaryFB.bind();
m_RenderData.pCurrentMonData->blurFBDirty = false;
}
void CHyprOpenGLImpl::preWindowPass() {
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
if (!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE)
return;
bool hasWindows = false;
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == m_RenderData.pMonitor->activeWorkspace && !w->m_bHidden && w->m_bIsMapped && !w->m_bIsFloating) {
hasWindows = true;
break;
}
}
if (!hasWindows)
return;
// blur the main FB, it will be rendered onto the mirror
preBlurForCurrentMonitor();
}
void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round) {
RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!");
static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
static auto* const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue;
static auto *const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue;
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) {
renderTexture(tex, pBox, a, round, false, true);
@@ -567,12 +701,14 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
}
if (!pixman_region32_not_empty(&inverseOpaque)) {
renderTexture(tex, pBox, a, round, false); // reject blurring a fully opaque window
renderTexture(tex, pBox, a, round, false, true); // reject blurring a fully opaque window
return;
}
// blur the main FB, it will be rendered onto the mirror
const auto POUTFB = blurMainFramebufferWithDamage(a, pBox, &inverseOpaque);
// vvv TODO: layered blur fbs?
const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && m_pCurrentWindow->m_iWorkspaceID != SPECIAL_WORKSPACE_ID);
const auto POUTFB = USENEWOPTIMIZE ? &m_RenderData.pCurrentMonData->blurFB : blurMainFramebufferWithDamage(a, pBox, &inverseOpaque);
pixman_region32_fini(&inverseOpaque);
@@ -590,7 +726,10 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
renderTexture(tex, pBox, a, round, true); // discard opaque
if (USENEWOPTIMIZE)
renderRect(pBox, CColor(0,0,0,0), round);
else
renderTexture(tex, pBox, a, round, true, true); // discard opaque
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_EQUAL, 1, -1);
@@ -601,7 +740,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
if (pixman_region32_not_empty(&damage)) {
// render our great blurred FB
static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, true);
m_bEndFrame = true; // fix transformed
renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false);
m_bEndFrame = false;
// render the window, but clear stencil
glClearStencil(0);
@@ -609,7 +750,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
// draw window
glDisable(GL_STENCIL_TEST);
renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true);
renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true, true);
}
glStencilMask(-1);
@@ -632,6 +773,23 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) {
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
static auto *const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
if (*PBORDERSIZE < 1)
return;
if (round < 1) {
// zero rounding, just lines
wlr_box borderbox = {box->x - *PBORDERSIZE, box->y - *PBORDERSIZE, *PBORDERSIZE, box->height + 2 * *PBORDERSIZE};
renderRect(&borderbox, col, 0); // left
borderbox = {box->x, box->y - (int)*PBORDERSIZE, box->width + (int)*PBORDERSIZE, (int)*PBORDERSIZE};
renderRect(&borderbox, col, 0); // top
borderbox = {box->x + box->width, box->y, (int)*PBORDERSIZE, box->height + (int)*PBORDERSIZE};
renderRect(&borderbox, col, 0); // right
borderbox = {box->x, box->y + box->height, box->width, (int)*PBORDERSIZE};
renderRect(&borderbox, col, 0); // bottom
return;
}
// adjust box
box->x -= *PBORDERSIZE;
box->y -= *PBORDERSIZE;
@@ -652,27 +810,27 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(m_shBORDER1.program);
glUseProgram(m_RenderData.pCurrentMonData->m_shBORDER1.program);
glUniformMatrix3fv(m_shBORDER1.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_shBORDER1.getUniformLocation("color"), col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_RenderData.pCurrentMonData->m_shBORDER1.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
const auto TOPLEFT = Vector2D(round, round);
const auto BOTTOMRIGHT = Vector2D(box->width - round, box->height - round);
const auto FULLSIZE = Vector2D(box->width, box->height);
glUniform2f(m_shBORDER1.getUniformLocation("topLeft"), (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_shBORDER1.getUniformLocation("bottomRight"), (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_shBORDER1.getUniformLocation("fullSize"), (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_shBORDER1.getUniformLocation("radius"), round);
glUniform1f(m_shBORDER1.getUniformLocation("thick"), *PBORDERSIZE);
glUniform1i(m_shBORDER1.getUniformLocation("primitiveMultisample"), *PMULTISAMPLE);
glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.radius, round);
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.thick, *PBORDERSIZE);
glUniform1i(m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample, *PMULTISAMPLE);
glVertexAttribPointer(m_shBORDER1.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_shBORDER1.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glEnableVertexAttribArray(m_shBORDER1.posAttrib);
glEnableVertexAttribArray(m_shBORDER1.texAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib);
if (pixman_region32_not_empty(m_RenderData.pDamage)) {
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
@@ -682,8 +840,8 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) {
}
}
glDisableVertexAttribArray(m_shBORDER1.posAttrib);
glDisableVertexAttribArray(m_shBORDER1.texAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -698,12 +856,10 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
// this is temporary, doesnt mess with the actual wlr damage
pixman_region32_t fakeDamage;
pixman_region32_init(&fakeDamage);
pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecPixelSize.x, (int)PMONITOR->vecPixelSize.y);
pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y);
begin(PMONITOR, &fakeDamage, true);
pixman_region32_fini(&fakeDamage);
clear(CColor(0,0,0,0)); // JIC
timespec now;
@@ -717,24 +873,22 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
const auto BLURVAL = g_pConfigManager->getInt("decoration:blur");
g_pConfigManager->setInt("decoration:blur", 0);
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL);
g_pConfigManager->setInt("decoration:blur", BLURVAL);
// render onto the window fb
// we rendered onto the primary because it has a stencil, which we need for the borders etc
const auto PFRAMEBUFFER = &m_mWindowFramebuffers[pWindow];
glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y);
PFRAMEBUFFER->m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
PFRAMEBUFFER->alloc(PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
PFRAMEBUFFER->bind();
clear(CColor(0, 0, 0, 0)); // JIC
wlr_box fullMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &fullMonBox, 255.f, 0);
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL);
g_pConfigManager->setInt("decoration:blur", BLURVAL);
// restore original fb
#ifndef GLES2
@@ -742,9 +896,10 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
#else
glBindFramebuffer(GL_FRAMEBUFFER, m_iCurrentOutputFb);
#endif
end();
pixman_region32_fini(&fakeDamage);
wlr_output_rollback(PMONITOR->output);
}
@@ -758,12 +913,10 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
// this is temporary, doesnt mess with the actual wlr damage
pixman_region32_t fakeDamage;
pixman_region32_init(&fakeDamage);
pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecPixelSize.x, (int)PMONITOR->vecPixelSize.y);
pixman_region32_union_rect(&fakeDamage, &fakeDamage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y);
begin(PMONITOR, &fakeDamage, true);
pixman_region32_fini(&fakeDamage);
const auto PFRAMEBUFFER = &m_mLayerFramebuffers[pLayer];
glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y);
@@ -792,6 +945,8 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
end();
pixman_region32_fini(&fakeDamage);
wlr_output_rollback(PMONITOR->output);
}
@@ -816,17 +971,26 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
// the originalClosedPos is relative to the monitor's pos
Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)), (PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale)));
windowBox.width = PMONITOR->vecPixelSize.x * scaleXY.x;
windowBox.height = PMONITOR->vecPixelSize.y * scaleXY.y;
windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x;
windowBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y;
windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x);
windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y);
pixman_region32_t fakeDamage;
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
m_bEndFrame = true;
renderTextureInternalWithDamage(it->second.m_cTex, &windowBox, PWINDOW->m_fAlpha.fl(), &fakeDamage, 0);
m_bEndFrame = false;
pixman_region32_fini(&fakeDamage);
static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
if (*PDAMAGEMON)
PMONITOR->forceFullFrames += 1;
}
void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
@@ -845,26 +1009,35 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID);
wlr_box windowBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
wlr_box monbox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y};
pixman_region32_t fakeDamage;
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
renderTextureInternalWithDamage(it->second.m_cTex, &windowBox, PLAYER->alpha.fl(), &fakeDamage, 0);
m_bEndFrame = true;
renderTextureInternalWithDamage(it->second.m_cTex, &monbox, PLAYER->alpha.fl(), &fakeDamage, 0);
m_bEndFrame = false;
pixman_region32_fini(&fakeDamage);
static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
if (*PDAMAGEMON)
PMONITOR->forceFullFrames += 1;
}
void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, float a) {
RASSERT(m_RenderData.pMonitor, "Tried to render shadow without begin()!");
RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!");
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
static auto *const PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue;
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
const auto col = CColor(*PSHADOWCOL);
const auto col = m_pCurrentWindow->m_cRealShadowColor.col();
float matrix[9];
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
@@ -878,28 +1051,28 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(m_shSHADOW.program);
glUseProgram(m_RenderData.pCurrentMonData->m_shSHADOW.program);
glUniformMatrix3fv(m_shSHADOW.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_shSHADOW.getUniformLocation("color"), col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a);
glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_FALSE, glMatrix);
glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a);
const auto TOPLEFT = Vector2D(range + round, range + round);
const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round));
const auto FULLSIZE = Vector2D(box->width, box->height);
// Rounded corners
glUniform2f(m_shSHADOW.getUniformLocation("topLeft"), (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_shSHADOW.getUniformLocation("bottomRight"), (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_shSHADOW.getUniformLocation("fullSize"), (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_shSHADOW.getUniformLocation("radius"), range + round);
glUniform1f(m_shSHADOW.getUniformLocation("range"), range);
glUniform1f(m_shSHADOW.getUniformLocation("shadowPower"), SHADOWPOWER);
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.radius, range + round);
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.range, range);
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower, SHADOWPOWER);
glVertexAttribPointer(m_shSHADOW.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_shSHADOW.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glVertexAttribPointer(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
glEnableVertexAttribArray(m_shSHADOW.posAttrib);
glEnableVertexAttribArray(m_shSHADOW.texAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
glEnableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib);
if (pixman_region32_not_empty(m_RenderData.pDamage)) {
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
@@ -909,8 +1082,8 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
}
}
glDisableVertexAttribArray(m_shSHADOW.posAttrib);
glDisableVertexAttribArray(m_shSHADOW.texAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -932,7 +1105,7 @@ void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const
cairo_surface_flush(CAIROSURFACE);
}
void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
static auto *const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue;
@@ -955,10 +1128,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
// get the adequate tex
std::string texPath = "/usr/share/hyprland/wall_";
Vector2D textureSize;
if (pMonitor->vecTransformedSize.x > 7000) {
if (pMonitor->vecTransformedSize.x > 3850) {
textureSize = Vector2D(7680, 4320);
texPath += "8K.png";
} else if (pMonitor->vecTransformedSize.x > 3000) {
} else if (pMonitor->vecTransformedSize.x > 1930) {
textureSize = Vector2D(3840, 2160);
texPath += "4K.png";
} else {
@@ -966,6 +1139,8 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
texPath += "2K.png";
}
PTEX->m_vSize = textureSize;
// create a new one with cairo
const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
@@ -977,8 +1152,8 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
// copy the data to an OpenGL texture we have
const auto DATA = cairo_image_surface_get_data(CAIROSURFACE);
glBindTexture(GL_TEXTURE_2D, PTEX->m_iTexID);
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_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
#ifndef GLES2
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
@@ -988,6 +1163,28 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(SMonitor* pMonitor) {
cairo_surface_destroy(CAIROSURFACE);
cairo_destroy(CAIRO);
// calc the target box
const float MONRATIO = m_RenderData.pMonitor->vecTransformedSize.x / m_RenderData.pMonitor->vecTransformedSize.y;
const float WPRATIO = 1.77f;
Vector2D origin;
float scale;
if (MONRATIO > WPRATIO) {
scale = m_RenderData.pMonitor->vecTransformedSize.x / PTEX->m_vSize.x;
origin.y = -(PTEX->m_vSize.y * scale - m_RenderData.pMonitor->vecTransformedSize.y) / 2.f / scale;
} else {
scale = m_RenderData.pMonitor->vecTransformedSize.y / PTEX->m_vSize.y;
origin.x = -(PTEX->m_vSize.x * scale - m_RenderData.pMonitor->vecTransformedSize.x) / 2.f / scale;
}
wlr_box box = {origin.x * scale, origin.y * scale, PTEX->m_vSize.x * scale, PTEX->m_vSize.y * scale};
m_mMonitorRenderResources[pMonitor].backgroundTexBox = box;
Debug::log(LOG, "Background created for monitor %s", pMonitor->szName.c_str());
}
@@ -997,12 +1194,11 @@ void CHyprOpenGLImpl::clearWithTex() {
static auto *const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
if (!*PRENDERTEX) {
wlr_box box = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
renderTexture(m_mMonitorBGTextures[m_RenderData.pMonitor], &box, 255, 0);
renderTexture(m_mMonitorBGTextures[m_RenderData.pMonitor], &m_mMonitorRenderResources[m_RenderData.pMonitor].backgroundTexBox, 255, 0);
}
}
void CHyprOpenGLImpl::destroyMonitorResources(SMonitor* pMonitor) {
void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].mirrorFB.release();
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].primaryFB.release();
g_pHyprOpenGL->m_mMonitorRenderResources[pMonitor].stencilTex.destroyTexture();

View File

@@ -37,10 +37,27 @@ struct SMonitorRenderData {
CFramebuffer mirrorSwapFB;
CTexture stencilTex;
CFramebuffer blurFB;
bool blurFBDirty = true;
wlr_box backgroundTexBox;
// Shaders
bool m_bShadersInitialized = false;
CShader m_shQUAD;
CShader m_shRGBA;
CShader m_shRGBX;
CShader m_shEXT;
CShader m_shBLUR1;
CShader m_shBLUR2;
CShader m_shSHADOW;
CShader m_shBORDER1;
//
};
struct SCurrentRenderData {
SMonitor* pMonitor = nullptr;
CMonitor* pMonitor = nullptr;
float projection[9];
SMonitorRenderData* pCurrentMonData = nullptr;
@@ -56,7 +73,7 @@ public:
CHyprOpenGLImpl();
void begin(SMonitor*, pixman_region32_t*, bool fake = false);
void begin(CMonitor*, pixman_region32_t*, bool fake = false);
void end();
void renderRect(wlr_box*, const CColor&, int round = 0);
@@ -74,11 +91,16 @@ public:
void clear(const CColor&);
void clearWithTex();
void scissor(const wlr_box*);
void scissor(const pixman_box32*);
void scissor(const int x, const int y, const int w, const int h);
void scissor(const wlr_box*, bool transform = true);
void scissor(const pixman_box32*, bool transform = true);
void scissor(const int x, const int y, const int w, const int h, bool transform = true);
void destroyMonitorResources(SMonitor*);
void destroyMonitorResources(CMonitor*);
void markBlurDirtyForMonitor(CMonitor*);
void preWindowPass();
void preRender(CMonitor*);
SCurrentRenderData m_RenderData;
@@ -91,8 +113,8 @@ public:
std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
std::unordered_map<SMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
std::unordered_map<SMonitor*, CTexture> m_mMonitorBGTextures;
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
private:
std::list<GLuint> m_lBuffers;
@@ -104,27 +126,19 @@ private:
bool m_bFakeFrame = false;
bool m_bEndFrame = false;
// Shaders
CShader m_shQUAD;
CShader m_shRGBA;
CShader m_shRGBX;
CShader m_shEXT;
CShader m_shBLUR1;
CShader m_shBLUR2;
CShader m_shSHADOW;
CShader m_shBORDER1;
//
GLuint createProgram(const std::string&, const std::string&);
GLuint compileShader(const GLuint&, std::string);
void createBGTextureForMonitor(SMonitor*);
void createBGTextureForMonitor(CMonitor*);
void initShaders();
// returns the out FB, can be either Mirror or MirrorSwap
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);
void preBlurForCurrentMonitor();
};
inline std::unique_ptr<CHyprOpenGLImpl> g_pHyprOpenGL;

View File

@@ -17,64 +17,74 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
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)};
// squish all oversized
if (RDATA->squishOversized) {
if (x + windowBox.width > RDATA->w)
windowBox.width = RDATA->w - x;
if (y + windowBox.height > RDATA->h)
if (y + windowBox.height > RDATA->h)
windowBox.height = RDATA->h - y;
}
if (RDATA->pWindow)
g_pHyprRenderer->calculateUVForWindowSurface(RDATA->pWindow, surface, RDATA->squishOversized);
scaleBox(&windowBox, RDATA->output->scale);
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding;
rounding *= RDATA->output->scale;
rounding -= 1; // to fix a border issue
if (RDATA->surface && surface == RDATA->surface) {
if (RDATA->blur)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding);
else
if (wlr_surface_is_xwayland_surface(surface) && !wlr_xwayland_surface_from_wlr_surface(surface)->has_alpha && RDATA->fadeAlpha * RDATA->alpha == 255.f) {
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
if (RDATA->decorate) {
auto col = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor.col();
col.a *= RDATA->fadeAlpha * RDATA->alpha / 255.f;
g_pHyprOpenGL->renderBorder(&windowBox, col, rounding);
} else {
if (RDATA->blur)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding);
else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
}
}
else {
if (RDATA->surface && wlr_surface_is_xdg_surface(RDATA->surface)) {
wlr_box geo;
wlr_xdg_surface_get_geometry(wlr_xdg_surface_from_wlr_surface(RDATA->surface), &geo);
windowBox.x -= geo.x;
windowBox.y -= geo.y;
}
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, false);
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
}
wlr_surface_send_frame_done(surface, RDATA->when);
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, SMonitor* pMonitor) {
bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
wlr_box geometry = pWindow->getFullWindowBoundingBox();
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
return false;
// now check if it has the same workspace
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID) {
if (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()) {
return true;
} else {
if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen)))
return false;
}
}
if (pWindow->m_iWorkspaceID == pMonitor->activeWorkspace)
return true;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
// if not, check if it maybe is active on a different monitor. vvv might be animation in progress
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_bForceRendering) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
return true;
// if not, check if it maybe is active on a different monitor.
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) ||
(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
if (pMonitor->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
return true;
@@ -103,14 +113,23 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
return false;
}
void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr;
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen)
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen){
if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
continue;
if (w->m_iMonitorID != pMonitor->ID)
continue;
}
if (w->m_iWorkspaceID == pMonitor->activeWorkspace && !w->m_bIsFullscreen)
continue;
// found it!
renderWindow(w.get(), pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL, RENDER_PASS_ALL);
pWorkspaceWindow = w.get();
@@ -143,12 +162,12 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor
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]) {
renderLayer(ls, pMonitor, time);
renderLayer(ls.get(), pMonitor, time);
}
}
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
renderLayer(ls, pMonitor, time);
renderLayer(ls.get(), pMonitor, time);
}
renderDragIcon(pMonitor, time);
@@ -158,7 +177,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor
g_pHyprError->draw();
}
void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode) {
void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode) {
if (pWindow->m_bHidden)
return;
@@ -176,13 +195,13 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
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.h = std::clamp(pWindow->m_vRealSize.vec().y, (double)5, (double)1337420); // otherwise we'll have issues later with invalid boxes
renderdata.dontRound = pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
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.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.rounding = pWindow->m_sAdditionalConfigData.rounding;
renderdata.blur = true; // if it shouldn't, it will be ignored later
renderdata.squishOversized = pWindow->m_vRealPosition.isBeingAnimated();
renderdata.pWindow = pWindow;
// apply window special data
if (pWindow->m_sSpecialRenderData.alphaInactive == -1)
@@ -190,6 +209,10 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
else
renderdata.alpha *= pWindow == g_pCompositor->m_pLastWindow ? pWindow->m_sSpecialRenderData.alpha : pWindow->m_sSpecialRenderData.alphaInactive;
// apply opaque
if (pWindow->m_sAdditionalConfigData.forceOpaque)
renderdata.alpha = 1.f;
g_pHyprOpenGL->m_pCurrentWindow = pWindow;
// render window decorations first, if not fullscreen full
@@ -198,33 +221,36 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) for (auto& wd : pWindow->m_dWindowDecorations)
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f);
if (!pWindow->m_bIsX11) {
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
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);
}
} 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);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
if (renderdata.decorate && pWindow->m_sSpecialRenderData.border) {
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding;
rounding *= pMonitor->scale;
auto col = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor.col();
col.a *= renderdata.fadeAlpha * renderdata.alpha / 255.f;
wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
scaleBox(&windowBox, pMonitor->scale);
g_pHyprOpenGL->renderBorder(&windowBox, col, rounding);
}
}
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_POPUP) {
if (!pWindow->m_bIsX11) {
renderdata.dontRound = false; // restore dontround
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.pMonitor = pMonitor;
renderdata.squishOversized = false; // don't squish popups
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
}
}
@@ -232,7 +258,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
}
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, SMonitor* pMonitor, timespec* time) {
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
if (pLayer->fadingOut) {
g_pHyprOpenGL->renderSnapshot(&pLayer);
return;
@@ -246,6 +272,22 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, SMonitor* pMonitor, times
renderdata.w = pLayer->layerSurface->surface->current.width;
renderdata.h = pLayer->layerSurface->surface->current.height;
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
renderdata.squishOversized = false; // don't squish popups
renderdata.dontRound = true;
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
}
void CHyprRenderer::renderIMEPopup(SIMEPopup* pPopup, CMonitor* pMonitor, timespec* time) {
SRenderData renderdata = {pMonitor->output, time, pPopup->realX, pPopup->realY};
renderdata.blur = false;
renderdata.surface = pPopup->pSurface->surface;
renderdata.decorate = false;
renderdata.w = pPopup->pSurface->surface->current.width;
renderdata.h = pPopup->pSurface->surface->current.height;
wlr_surface_for_each_surface(pPopup->pSurface->surface, renderSurface, &renderdata);
}
void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
@@ -256,12 +298,15 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
// Render layer surfaces below windows for monitor
for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
renderLayer(ls, PMONITOR, time);
renderLayer(ls.get(), PMONITOR, time);
}
for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
renderLayer(ls, PMONITOR, time);
renderLayer(ls.get(), PMONITOR, time);
}
// pre window pass
g_pHyprOpenGL->preWindowPass();
// if there is a fullscreen window, render it and then do not render anymore.
// fullscreen window will hide other windows and top layers
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
@@ -342,15 +387,87 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
// Render surfaces above windows for monitor
for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
renderLayer(ls, PMONITOR, time);
renderLayer(ls.get(), PMONITOR, time);
}
// Render IME popups
for (auto& imep : g_pInputManager->m_sIMERelay.m_lIMEPopups) {
renderIMEPopup(&imep, PMONITOR, time);
}
for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
renderLayer(ls, PMONITOR, time);
renderLayer(ls.get(), 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 * ((double)pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)),
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * ((double)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 CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) {
wlr_output_configuration_head_v1* head;
bool noError = true;
@@ -470,11 +587,11 @@ void apply_exclusive(struct wlr_box* usable_area, uint32_t anchor, int32_t exclu
}
}
void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::list<SLayerSurface*>& layerSurfaces, bool exclusiveZone, wlr_box* usableArea) {
void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std::unique_ptr<SLayerSurface>>& layerSurfaces, bool exclusiveZone, wlr_box* usableArea) {
wlr_box full_area = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y};
for (auto& ls : layerSurfaces) {
if (ls->fadingOut || ls->readyToDelete || !ls->layerSurface)
if (ls->fadingOut || ls->readyToDelete || !ls->layerSurface || ls->noProcess)
continue;
const auto PLAYER = ls->layerSurface;
@@ -543,7 +660,7 @@ void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::list<SLayer
box.y -= PSTATE->margin.bottom;
}
if (box.width <= 0 || box.height <= 0) {
Debug::log(ERR, "LayerSurface %x has a negative/zero w/h???", ls);
Debug::log(ERR, "LayerSurface %x has a negative/zero w/h???", ls.get());
continue;
}
// Apply
@@ -586,6 +703,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
if (PMONITOR->damage)
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);
}
@@ -593,13 +712,16 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
if (!pSurface)
return; // wut?
if (g_pCompositor->m_bUnsafeState)
return;
pixman_region32_t damageBox;
pixman_region32_init(&damageBox);
wlr_surface_get_effective_damage(pSurface, &damageBox);
// schedule frame events
if (!wl_list_empty(&pSurface->current.frame_callback_list)) {
wlr_output_schedule_frame(g_pCompositor->getMonitorFromVector(Vector2D(x, y))->output);
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->getMonitorFromVector(Vector2D(x, y)));
}
if (!pixman_region32_not_empty(&damageBox)) {
@@ -607,42 +729,54 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
return;
}
pixman_region32_translate(&damageBox, x, y);
pixman_region32_t damageBoxForEach;
pixman_region32_init(&damageBoxForEach);
for (auto& m : g_pCompositor->m_vMonitors) {
double lx = 0, ly = 0;
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, m->output, &lx, &ly);
pixman_region32_translate(&damageBox, lx, ly);
wlr_region_scale(&damageBox, &damageBox, m->scale);
wlr_output_damage_add(m->damage, &damageBox);
pixman_region32_translate(&damageBox, -lx, -ly);
pixman_region32_copy(&damageBoxForEach, &damageBox);
pixman_region32_translate(&damageBoxForEach, x - m->vecPosition.x, y - m->vecPosition.y);
wlr_region_scale(&damageBoxForEach, &damageBoxForEach, m->scale);
pixman_region32_translate(&damageBoxForEach, lx + m->vecPosition.x, ly + m->vecPosition.y);
m->addDamage(&damageBoxForEach);
}
pixman_region32_fini(&damageBox);
pixman_region32_fini(&damageBoxForEach);
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
if (*PLOGDAMAGE)
Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1, damageBox.extents.y2 - damageBox.extents.y1);
pixman_region32_fini(&damageBox);
}
void CHyprRenderer::damageWindow(CWindow* pWindow) {
if (g_pCompositor->m_bUnsafeState)
return;
wlr_box damageBox = pWindow->getFullWindowBoundingBox();
for (auto& m : g_pCompositor->m_vMonitors) {
wlr_box fixedDamageBox = {damageBox.x - m->vecPosition.x, damageBox.y - m->vecPosition.y, damageBox.width, damageBox.height};
scaleBox(&fixedDamageBox, m->scale);
wlr_output_damage_add_box(m->damage, &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)
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(SMonitor* pMonitor) {
void CHyprRenderer::damageMonitor(CMonitor* pMonitor) {
if (g_pCompositor->m_bUnsafeState)
return;
wlr_box damageBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y};
wlr_output_damage_add_box(pMonitor->damage, &damageBox);
pMonitor->addDamage(&damageBox);
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
@@ -651,10 +785,13 @@ void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
}
void CHyprRenderer::damageBox(wlr_box* pBox) {
if (g_pCompositor->m_bUnsafeState)
return;
for (auto& m : g_pCompositor->m_vMonitors) {
wlr_box damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height};
scaleBox(&damageBox, m->scale);
wlr_output_damage_add_box(m->damage, &damageBox);
m->addDamage(&damageBox);
}
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
@@ -668,7 +805,14 @@ void CHyprRenderer::damageBox(const int& x, const int& y, const int& w, const in
damageBox(&box);
}
void CHyprRenderer::renderDragIcon(SMonitor* pMonitor, timespec* time) {
void CHyprRenderer::damageRegion(pixman_region32_t* rg) {
PIXMAN_DAMAGE_FOREACH(rg) {
const auto RECT = RECTSARR[i];
damageBox(RECT.x1, RECT.y1, RECT.x2 - RECT.x1, RECT.y2 - RECT.y1);
}
}
void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) {
if (!(g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.iconMapped && g_pInputManager->m_sDrag.dragIcon->surface))
return;
@@ -694,21 +838,33 @@ DAMAGETRACKINGMODES CHyprRenderer::damageTrackingModeFromStr(const std::string&
return DAMAGE_TRACKING_INVALID;
}
bool CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) {
bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) {
Debug::log(LOG, "Applying monitor rule for %s", pMonitor->szName.c_str());
// if it's disabled, disable and ignore
if (pMonitorRule->disabled) {
wlr_output_enable(pMonitor->output, 0);
wlr_output_commit(pMonitor->output);
Events::listener_monitorDestroy(nullptr, pMonitor->output);
return false;
if (pMonitor->m_bEnabled)
pMonitor->onDisconnect();
return true;
}
if (!pMonitor->m_bEnabled) {
pMonitor->onConnect(true); // enable it.
force = true;
}
// Check if the rule isn't already applied
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale && DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1) && pMonitor->transform == pMonitorRule->transform) {
if (!force
&& DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1)
&& DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1)
&& DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1)
&& 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))
&& pMonitor->transform == pMonitorRule->transform) {
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
return true;
}
@@ -719,73 +875,125 @@ bool CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->vecPosition = pMonitorRule->offset;
// loop over modes and choose an appropriate one.
if (!wl_list_empty(&pMonitor->output->modes)) {
wlr_output_mode* mode;
bool found = false;
if (pMonitorRule->resolution != Vector2D()) {
if (!wl_list_empty(&pMonitor->output->modes)) {
wlr_output_mode* mode;
bool found = false;
wl_list_for_each(mode, &pMonitor->output->modes, link) {
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it
if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) {
wlr_output_set_mode(pMonitor->output, mode);
wl_list_for_each(mode, &pMonitor->output->modes, link) {
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it
if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) {
wlr_output_set_mode(pMonitor->output, mode);
if (!wlr_output_test(pMonitor->output)) {
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh / 1000.f);
continue;
}
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh);
found = true;
pMonitor->refreshRate = mode->refresh / 1000.f;
pMonitor->vecSize = Vector2D(mode->width, mode->height);
break;
}
}
if (!found) {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
pMonitor->vecSize = pMonitorRule->resolution;
if (!wlr_output_test(pMonitor->output)) {
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
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,
mode->width, mode->height, mode->refresh / 1000.f);
continue;
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);
}
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh);
found = true;
pMonitor->refreshRate = mode->refresh / 1000.f;
pMonitor->vecSize = Vector2D(mode->width, mode->height);
break;
}
}
if (!found) {
} else {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
pMonitor->vecSize = pMonitorRule->resolution;
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);
}
Debug::log(LOG, "Setting custom mode for %s", pMonitor->output->name);
}
} else {
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
pMonitor->vecSize = pMonitorRule->resolution;
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
if (!PREFERREDMODE) {
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE",
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
if (!wl_list_empty(&pMonitor->output->modes)) {
wlr_output_mode* mode;
wl_list_for_each(mode, &pMonitor->output->modes, link) {
wlr_output_set_mode(pMonitor->output, mode);
if (!wlr_output_test(pMonitor->output)) {
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh / 1000.f);
continue;
}
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
mode->width, mode->height, mode->refresh);
pMonitor->refreshRate = mode->refresh / 1000.f;
pMonitor->vecSize = Vector2D(mode->width, mode->height);
break;
}
}
} else {
// Preferred is valid
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
Debug::log(LOG, "Setting preferred mode for %s", pMonitor->output->name);
}
}
wlr_output_set_transform(pMonitor->output, pMonitorRule->transform);
pMonitor->transform = pMonitorRule->transform;
pMonitor->vecPixelSize = pMonitor->vecSize;
// Adaptive sync (VRR)
wlr_output_enable_adaptive_sync(pMonitor->output, 1);
if (!wlr_output_test(pMonitor->output)) {
Debug::log(LOG, "Pending output %s does not accept VRR.", pMonitor->output->name);
wlr_output_enable_adaptive_sync(pMonitor->output, 0);
}
// update renderer
g_pHyprOpenGL->destroyMonitorResources(pMonitor);
@@ -799,9 +1007,23 @@ bool CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
pMonitor->vecTransformedSize = Vector2D(x,y);
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitorRule->offset.x, (int)pMonitorRule->offset.y);
if (pMonitorRule->offset == Vector2D(-1, -1)) {
// let's find manually a sensible position for it, to the right.
Vector2D finalPos;
//wlr_output_damage_add_whole(pMonitor->damage);
for (auto& m : g_pCompositor->m_vMonitors) {
if (m->ID == pMonitor->ID)
continue;
if (m->vecPosition.x + std::ceil(m->vecSize.x) > finalPos.x) {
finalPos.x = m->vecPosition.x + std::ceil(m->vecSize.x);
}
}
pMonitor->vecPosition = finalPos;
}
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, pMonitor->output, (int)pMonitor->vecPosition.x, (int)pMonitor->vecPosition.y);
wlr_output_enable(pMonitor->output, true);

View File

@@ -33,23 +33,26 @@ public:
void damageWindow(CWindow*);
void damageBox(wlr_box*);
void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageMonitor(SMonitor*);
bool applyMonitorRule(SMonitor*, SMonitorRule*, bool force = false);
bool shouldRenderWindow(CWindow*, SMonitor*);
void damageRegion(pixman_region32_t*);
void damageMonitor(CMonitor*);
bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false);
bool shouldRenderWindow(CWindow*, CMonitor*);
bool shouldRenderWindow(CWindow*);
void ensureCursorRenderingMode();
bool shouldRenderCursor();
void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false);
bool m_bWindowRequestedCursorHide = false;
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
private:
void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(SMonitor*, CWorkspace*, timespec*);
void renderWindow(CWindow*, SMonitor*, timespec*, bool, eRenderPassMode);
void renderLayer(SLayerSurface*, SMonitor*, timespec*);
void renderDragIcon(SMonitor*, timespec*);
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode);
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
void renderDragIcon(CMonitor*, timespec*);
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
bool m_bHasARenderedCursor = true;

View File

@@ -10,4 +10,11 @@ GLint CShader::getUniformLocation(const std::string& unif) {
}
return itpos->second;
}
CShader::~CShader() {
// destroy shader
if (program) {
glDeleteProgram(program);
}
}

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