Compare commits

...

398 Commits

Author SHA1 Message Date
vaxerski
0a78f6031c props: bump ver to 0.29.0 2023-08-28 23:03:35 +02:00
vaxerski
981386d2ae layout: allow changing float status of fullscreen windows 2023-08-28 22:55:52 +02:00
vaxerski
b8f38dcbd3 layout: allow drag on fullscreen windows 2023-08-28 22:54:23 +02:00
vaxerski
df691859fb renderer: make contrast and brightness adjustments before rendering 2023-08-28 18:29:44 +02:00
pastalian
aed1f66bec makefile: fix build failure with some PREFIX (#3099)
Most systems does not have xdg-desktop-portal directory other than
/usr/share.
2023-08-28 17:21:01 +02:00
Vaxry
4a41d013a2 internal: Fix XDP multi-portal issues (#3077)
* add a hyprland portals conf

* remove portal checks

* typo

* Nix: remove portal patch

---------

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2023-08-26 17:12:21 +02:00
vaxerski
299d201e56 renderer: don't blur special on disabled blur 2023-08-26 11:48:04 +02:00
Mihai Fufezan
d63a42e93f Nix & Meson: bump wlroots 2023-08-26 12:07:11 +03:00
vaxerski
ae69b9a2fa deps: update wlroots 2023-08-25 20:42:11 +02:00
vaxerski
116b9a8056 xdgoutput: mark resources defunct when monitor is unplugged 2023-08-25 18:22:25 +02:00
vaxerski
9dae8ece71 layout: use full box for visibility check of floating xdg
Fixes #3069, if an xdg dialog pops up and is partially off bounds, just move it to the center.
2023-08-25 18:10:12 +02:00
vaxerski
870471dd96 internal: allow opening empty special workspaces
Fixes point 2 of #2596
2023-08-25 18:05:08 +02:00
vaxerski
23e17700a7 renderer: add decoration:blur:special
will blur behind the special ws
2023-08-25 17:44:17 +02:00
memchr
f0da0b0be4 input: improved path handling; null check return value of fopen. (#3061) 2023-08-25 17:21:55 +02:00
vaxerski
3a1f30519b compositor: fix offset in auto arrangeMonitors
Fixes #3043, I am an idiot
2023-08-25 13:11:32 +02:00
vaxerski
6a5a5ed11e input: add transparent binds
adds a new flag for binds to be transparent (non-shadowable)
fixes #3058
2023-08-25 12:35:24 +02:00
vaxerski
ad085666c1 input: sanitize newlines in device names
fixes #3066 by replacing newlines with dashes in device names
2023-08-25 12:17:48 +02:00
Jeremy Huang
90c03e5bd2 master: layout resize makes the wrong size changes (#3064) 2023-08-24 11:57:30 +02:00
end-4
17ea7db23a gestures: Swipe direction lock (#3052) 2023-08-23 22:40:19 +02:00
Tristan Daniël Maat
4d14edd8a5 nix module: Fix attempted workaround for option name change
`system.stateVersion` is about *system state*, i.e., stuff that was
created by old software versions on users' machines, like SQL
databases that have moved to a different directory or such.

It will not help figure out whether an option has been renamed.
2023-08-23 13:32:06 +03:00
Mihai Fufezan
3576ee61f1 Nix: update flake.lock 2023-08-23 13:12:25 +03:00
Mihai Fufezan
6692fb12ab CI: set myself as author and committer 2023-08-23 13:08:02 +03:00
vaxerski
9d094f655e renderer: track fade alpha for blur if ignore opacity is true
with ignore_opacity, blur would stay at 1 opacity during a fadeOut animation on layers, making it look wrong. Fixes #3051
2023-08-23 12:03:27 +02:00
Mihai Fufezan
5e7183daf5 CI/Nix: remove waybar build 2023-08-22 20:59:15 +03:00
vaxerski
ba31518ed8 compositor: fix log types 2023-08-22 16:44:33 +02:00
MightyPlaza
41d9b6f0d7 dwindle: use smart on display borders (#2897) 2023-08-21 20:57:55 +02:00
memchr
9ad4a96d18 renderer: update alpha of layers only if active ws (#2994)
update `alpha` of ZWLR_LAYER_SHELL_V1_LAYER_TOP only when Workspaces is active on the monitor.
2023-08-21 20:55:57 +02:00
memchr
cb59763d32 fix: improved focus behaviour on workspace switching for follow_mouse!=1 (#3041)
* fix: improved focus behaviour on workspace switching for follow_mouse!=1

When the 'input:follow_mouse' is not set to 1 and the target workspace
for switching does not currently have the previously focused window,
Hyprland will prioritize focusing on the top-left-most window.

* fix: #2451 call simulateMouseMovement.

* unify logic

* multimon fix

---------

Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
2023-08-21 20:54:02 +02:00
vaxerski
9977a8bfd4 compositor: log more in arrangeMonitors 2023-08-21 19:52:34 +02:00
Vaxry
37128bfd43 internal: Wayland Protocol impl improvements (#2944) 2023-08-21 19:36:09 +02:00
Mihai Fufezan
17d8e4750b Nix: remove waybar completely
Get it from Nixpkgs instead.
2023-08-21 15:34:38 +03:00
vaxerski
63b2189ce8 xdgshell: damage old popup coords after a reposition
fixes #3038. I updated the shell ver without properly supporting .reposition
2023-08-21 01:15:00 +02:00
vaxerski
025c023e4b xwayland: use logical pos in unmanaged geom requests
using raw xwayland coords is wrong cuz we use separate coord spaces
2023-08-21 00:39:39 +02:00
memchr
09cc96c0d5 feat(debug): add debug:suppress_errors to suppress errors. (#3032) 2023-08-20 18:17:49 +02:00
vaxerski
b79dfcceb4 compositor: fix missed raw throws 2023-08-20 13:58:46 +02:00
vaxerski
7713daa86a compositor: log thrown runtime exceptions 2023-08-20 11:47:06 +02:00
vaxerski
fff118fa76 xdgoutput: don't send all details in .get 2023-08-19 21:14:12 +02:00
vaxerski
ebc5fed9b2 compositor: minor cleanup 2023-08-19 19:24:48 +02:00
vaxerski
942ee943f5 input: unify constraint hint logic
Unifies the constraint hint logic. Previously, ignoring the stupid conditions, unscaled hints were mistaken with scaled coordinates.
2023-08-18 22:40:23 +02:00
vaxerski
14f20a7372 xwayland: fix incorrect VECINRECT usage
Fixes #3002. VECINRECT uses x2 and y2 and not w / h.
2023-08-18 22:20:05 +02:00
vaxerski
3d9545d2e0 shaders: minor premultiplication fixes 2023-08-18 22:07:28 +02:00
end-4
37a211a2ae animations: add slidefade and slidefadevert styles for workspaces (#3008)
* add slidefade and slidefadevert animations

* fix swiping for slidefadevert

* rename minPerc to movePerc for slidefade anim styles

* change default slidefade percentage to 100%

* remove useless comments

* findlastof + 1

* debug logging for slidefade/slidefadevert percentage
2023-08-17 22:30:20 +02:00
MightyPlaza
7155b4c266 renderer: Border improvements (#2986)
* simplify getting border size
	modified:   src/Window.cpp
	modified:   src/Window.hpp
	modified:   src/layout/DwindleLayout.cpp
	modified:   src/layout/MasterLayout.cpp
	modified:   src/render/decorations/CHyprGroupBarDecoration.cpp

* fix border damage and input box
	modified:   src/Window.cpp
	modified:   src/managers/AnimationManager.cpp

* add border size in resize_on_border box
	modified:   src/managers/input/InputManager.cpp

* simplify border (fixes possible typo)
	modified:   src/Window.cpp

* use updateSpecialRenderData()
	modified:   Window.cpp
	modified:   Window.hpp
	modified:   events/Windows.cpp
	modified:   layout/DwindleLayout.cpp
	modified:   layout/IHyprLayout.cpp
	modified:   layout/MasterLayout.cpp
	modified:   render/Renderer.cpp

* update window workspace rule data on reload
	modified:   src/config/ConfigManager.cpp

* use rounding()
	modified:   src/Window.cpp
2023-08-17 10:13:19 +02:00
vaxerski
7e8a212027 internal: allow negative monitor offsets 2023-08-16 18:16:39 +02:00
Mihai Fufezan
19f3e927d9 Nix: deprecate waybar-hyprland
Now merged in Nixpkgs, no reason to keep it here.
2023-08-16 18:46:57 +03:00
Mihai Fufezan
78fa8adadc Nix/module: fix system when config.allowAlias is false 2023-08-16 13:39:20 +03:00
Dashie
19c4855afc layout: Use refreshrate tick on all manual animations (#2988) 2023-08-16 10:56:48 +02:00
memchr
63b266cf65 internal: ioctl use /dev/tty instead of fd 0 for VT_GETSTATE (#2989)
* fix: ioctl use /dev/tty instead of fd 0 for VT_GETSTATE

ioctl VT_GETSTATE on stdin fails if it is not console, such as when
using GDM.  `/dev/tty` should be used instead.

- `/dev/tty` is a synonym for the controlling terminal of a process, if
there is one.

---------

Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
2023-08-16 10:51:08 +02:00
vaxerski
4986d74ef2 xwayland: fix use of xwayland coords in native spaces 2023-08-15 20:10:43 +02:00
vaxerski
91e28bbe9d xwayland: use a completely separate coordinate system
Use a completely separate coordinate system for XWayland. This fixes all issues with force_zero_scaling overlaps.

Fixes #2916
2023-08-15 19:15:37 +02:00
kbtz
2b4537606f master: fix always_center_master (#2961)
* master: fix always_center_master

* master: allow resizing single centered window

---------

Co-authored-by: kbtz <github@kbtz.dev>
2023-08-15 18:13:45 +02:00
vaxerski
347a1eb662 xdgoutput: separate logic for zero scaling positions
if a scaled monitor was directly to the left of another monitor, we'd change the size to have zero scaling without pushing other monitors out of the way, creating overlaps in xwayland.
2023-08-15 17:55:29 +02:00
vaxerski
7c4daee29a compositor: fix skipping iterators in arrangeMonitors 2023-08-14 19:27:33 +02:00
vaxerski
b9a783229b compositor: don't apply offsets in renderer 2023-08-14 18:41:52 +02:00
vaxerski
2110dc1f03 compositor: fix auto positioning offset calcs 2023-08-14 17:31:36 +02:00
Mihai Fufezan
e5fb9b1b02 CI: update auto commit author & committer 2023-08-14 15:34:44 +03:00
vaxerski
13886a264f internal: add a new monitor auto system 2023-08-14 14:22:10 +02:00
Mihai Fufezan
a0cf890292 Nix/module: final fix 2023-08-14 11:53:58 +03:00
Mihai Fufezan
9ba6eab8db ugh 2023-08-14 11:37:08 +03:00
Mihai Fufezan
9180fb08e2 Nix/module: fix package option 2023-08-14 11:12:57 +03:00
Mihai Fufezan
314f88de53 Nix: disable nixpkgs module in ours 2023-08-14 11:03:01 +03:00
Mihai Fufezan
aff4a1e237 Nix: don't warn against xdpw and xdph being present
It seems that, on NixOS at least, having both the Hyprland and the wlr
desktop portals does not result in unexpected behaviour. xdph will be
started and wlr ignored.
2023-08-14 10:39:57 +03:00
Mihai Fufezan
2650224c1f Nix: remove hidpi from modules 2023-08-14 10:39:57 +03:00
Mihai Fufezan
e510c6a7fc Nix: add deprecation messages for removed/renamed flags 2023-08-14 10:39:57 +03:00
Mihai Fufezan
c1bcbdb3dd Nix: remove HiDPI patches
- remove `hidpiXWayland` option
- rename `nvidiaPatches` -> `enableNvidiaPatches` for consistency
2023-08-14 10:39:57 +03:00
vaxerski
0314a727eb layers: set proper alpha to top grabbing surfaces 2023-08-13 21:52:43 +02:00
vaxerski
3fc4ac07e0 hyprctl: fix hyprpaper 2023-08-13 21:42:16 +02:00
Mihai Fufezan
38814e8a95 flake.lock: update 2023-08-13 20:47:44 +03:00
vaxerski
0220e4c1ea input: notify idle about activity on mouse move regardless of focus 2023-08-13 17:46:20 +02:00
MightyPlaza
4b568ae5f6 remove shadow no_gaps_when_only master (#2958)
* remove shadow no_gaps_when_only
	modified:   src/Window.hpp
	modified:   src/config/ConfigManager.cpp
	modified:   src/config/ConfigManager.hpp
	modified:   src/layout/DwindleLayout.cpp
	modified:   src/render/decorations/CHyprDropShadowDecoration.cpp

* add master
	modified:   src/layout/MasterLayout.cpp

* fix wrong
	modified:   src/layout/MasterLayout.cpp
2023-08-13 10:18:48 +02:00
MightyPlaza
739598717b remove shadow no_gaps_when_only (#2956)
modified:   src/Window.hpp
	modified:   src/config/ConfigManager.cpp
	modified:   src/config/ConfigManager.hpp
	modified:   src/layout/DwindleLayout.cpp
	modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
2023-08-12 23:37:55 +02:00
Jacob Birkett
d20837bef8 Nix: corrections for overlays, overrideable systems (#2929)
* nix: overlays: move waybar-hyprland to own overlay

* flake: use legacyPackages for formatter

Run `nix fmt` for all files.

* flake: move default overlay to nix/overlays.nix

* nix: lib: remove lib

* nix: overlays: extras: explicitly include xdph overlays

* nix: use interpolation for versions

* nix: overlays: include deps with hyprland-packages

* flake: make systems overrideable

* flake: packages: inherit from overlaid pkgsFor
2023-08-12 15:22:37 +03:00
vaxerski
3f7f4207a6 config: add vrr per-display 2023-08-11 17:37:57 +02:00
UserSv4
8a7ce59ad4 internal: Fix grouped windows not being properly focused on activation (#2925)
* Fix grouped windows not being properly focused on activation

This bug could happen if you:
1. Open two Chromium windows in a single group
2. Open some tabs in both of the windows
3. Using tabs search (Ctrl+Shift+A) try to switch to a tab in the second window from the first one.
When this happens any window focus would be lost (hyprctl activewindow starts to output "Invalid") and also the mouse cursor would become centered relatively to the second window.

* Update Compositor.cpp
2023-08-11 17:27:09 +02:00
vaxerski
60b548296d internal: move backtrace to specific func 2023-08-11 17:22:19 +02:00
MightyPlaza
901236a535 rules: center window improvements (#2935)
* center window improvements
	modified:   src/config/ConfigManager.cpp
	modified:   src/events/Windows.cpp
	modified:   src/managers/KeybindManager.cpp

* remove redundant line
	modified:   src/events/Windows.cpp

* simplify code
	modified:   src/events/Windows.cpp
	modified:   src/managers/KeybindManager.cpp
2023-08-11 16:54:16 +02:00
vaxerski
e4e8ae8f88 dwindle: disallow togglesplit on fullscreen 2023-08-10 22:01:34 +02:00
MightyPlaza
c4c3b590e5 toplevel: patches group toplevel-activated (#2931)
* patches group toplevel-activated

	modified:   src/Compositor.cpp
	modified:   src/Window.cpp

* remove redundant call

	modified:   src/Compositor.cpp

* fix style
	modified:   src/Compositor.cpp
2023-08-10 20:06:39 +02:00
vaxerski
126792584f renderer: don't add workspace offset to pinned 2023-08-09 22:15:37 +02:00
vaxerski
cbb899740c rules: add layer and window xray rules 2023-08-09 22:03:31 +02:00
rewine
fe9453c643 Nix: enable systemd only when it's available on hostPlatform 2023-08-09 20:25:28 +03:00
vaxerski
d7209b90bb renderer: remember extents before removing a window and use them for dt
fixes #2351
2023-08-09 14:28:04 +02:00
vaxerski
47430411d6 hyprctl: remove log 2023-08-09 14:10:54 +02:00
Mihai Fufezan
ec269622fc flake.lock: update xdph 2023-08-08 21:50:28 +03:00
Gonçalo Duarte
12cb109137 Nix: fix nvidia patch for dual gpu system
* this fix it most important for laptops with dgpu
 * remove post patch line wlroots.nix

Signed-off-by: Gonçalo Duarte <gonegrier.duarte@gmail.com>
2023-08-08 21:27:05 +03:00
vaxerski
8e04a80e60 toplevelexport: minor fixes to dmabuf 2023-08-08 19:10:53 +02:00
MightyPlaza
6295cbe9cb keybinds: Keep aspect ratio (#2907) 2023-08-08 18:52:20 +02:00
vaxerski
b68292340c hyprctl: fix old request methods 2023-08-08 18:41:00 +02:00
vaxerski
ab73183cb2 config: adjust default background color 2023-08-08 18:04:46 +02:00
vaxerski
36052abd33 hyprctl: add --instance 2023-08-08 18:04:24 +02:00
0x455241
b3393c429f background: add background color option (#2915)
Co-authored-by: 0x455241 <>
2023-08-08 18:00:11 +02:00
vaxerski
c748f36939 internal: add lock files and hyprctl instances 2023-08-08 16:16:40 +02:00
Michael
ad3b8dddf9 keybinds: Only call fclose() when we have a valid file. (#2908)
Signed-off-by: Michael Pacheco <git@michaelpacheco.org>
2023-08-08 16:07:15 +02:00
Michael
cebab759d5 Close keymap files. Fixes #2904 (#2905)
Signed-off-by: Michael Pacheco <git@michaelpacheco.org>
2023-08-07 19:34:15 +02:00
vaxerski
deeeb33c5f macros: fix missing include 2023-08-07 18:48:08 +02:00
vaxerski
261c3307f7 internal: cleanup headers in helpers/ 2023-08-07 13:36:14 +02:00
vaxerski
6e53c47e68 renderer: fix missing premultiplication for border multisampling 2023-08-06 20:46:00 +02:00
vaxerski
6c10c38481 renderer: fully switch to premultiplied alpha 2023-08-06 20:33:36 +02:00
vaxerski
a077b7a92e animationmgr: avoid redundant ticks 2023-08-05 23:29:33 +02:00
MightyPlaza
b925f1b497 fix workspace change focus (#2891) 2023-08-05 20:53:13 +02:00
Mihai Fufezan
46cf4eb837 Nix: bump wlroots 2023-08-04 14:58:16 +00:00
Mihai Fufezan
79ce387cb8 CI: update auto commit author 2023-08-04 17:41:42 +03:00
vaxerski
ef0d97153a xdgoutput: manually destroy manager resource 2023-08-04 14:07:41 +02:00
vaxerski
2e6693fbb6 compositor: update window rules on workspace move 2023-08-03 21:59:12 +02:00
romanstingler
7d98181ade xwayland: drop wlr_xwayland_surface.events.set_pid (#2884)
Co-authored-by: Roman Stingler <roman.stingler@waterdrop.com>
2023-08-03 21:40:56 +02:00
vaxerski
7a2027d1fd input: fix and unify client checking in mouseRequests 2023-08-03 18:44:07 +02:00
vaxerski
9654749244 props: bump version to 0.28.0 2023-08-03 18:00:10 +02:00
vaxerski
da46e01b97 config: update default config for new blur changes 2023-08-03 15:16:37 +02:00
Vaxry
d96f8ff0fe renderer: Various Blur Improvements (#2877)
* move blur to its own category

* blur improvements, contrast, brightness, noise
2023-08-03 15:11:10 +02:00
vaxerski
5c50fac907 windowrules: add workspace param 2023-08-02 13:21:38 +02:00
vaxerski
51cda87fe4 hyprctl: rerender on cursor_zoom_factor dynamic calls 2023-08-01 18:08:53 +02:00
vaxerski
da0c74cdf0 config: schedule frame for mons on reload 2023-08-01 15:47:56 +02:00
vaxerski
08651736ad keybinds: add toggle to dpms 2023-07-30 16:46:37 +02:00
Mihai Fufezan
bf0d8ab4a3 NixOS module: check system version for fonts 2023-07-29 23:05:35 +03:00
rewine
a805905a49 Nix: move wayland-scanner to nativeBuildInputs (#2816) 2023-07-29 16:31:01 +03:00
vaxerski
f61a714320 renderer: cleanup old redundancies in CFramebuffer 2023-07-29 13:27:40 +02:00
Po-Yeh Chen
77818e3457 xwayland: Add temporary fix for #2808 by adding nullptr check. (#2829)
* Add temporary fix for #2808 by adding nullptr check.

* Remove redundency.
2023-07-28 17:12:24 +02:00
Alfred Wingate
2ea7d10d04 assets/meson.build: install new wallpapers
* Previous changes forgot to update meson with the new wallpapers.

70dae78c1b
9bad2a8180

Signed-off-by: Alfred Wingate <parona@protonmail.com>
2023-07-27 13:25:40 +03:00
Gioele Pannetto
ef26f711c9 Added git tag in json version command (#2821) 2023-07-27 10:51:04 +02:00
Okirshen
c36c30c17b Renamed deprecated value in nix config
See 83793ca898 for more info.
2023-07-27 11:36:35 +03:00
vaxerski
a9b8e2159c renderer: reset scissor after renderTexturePrimitive 2023-07-25 13:33:08 +02:00
vaxerski
4173d2ccf6 input: fix styling 2023-07-25 11:49:36 +02:00
Mihai Fufezan
427321c5ab Nix: bump nixpkgs
Nix: bump wlroots
2023-07-25 10:27:41 +03:00
vaxerski
f5913135c6 input: add support for cursor-shape-v1 2023-07-24 18:50:17 +02:00
vaxerski
76d4a50af3 deps: update wlroots 2023-07-24 18:34:25 +02:00
vaxerski
603de16f9a renderer: adjust distribution of backgrounds 2023-07-24 18:30:00 +02:00
ferrreo
f6b340cc19 init: Fix for issue #2797 (#2799)
* Fix for issue #2797

* Fix for issue #2797

* Fix for issue #2797
2023-07-24 18:26:24 +02:00
memchr
76c6e09e39 keybinds: Make moveintogroup locking check configurable (#2796)
* groups: revert to the old moveintogroup behaviour, ignore m_sGroupData.locked

* groups: Make moveintogroup locking check configurable
2023-07-24 18:25:10 +02:00
vaxerski
9bad2a8180 backgrounds: add hypr chan var 2 2023-07-24 18:22:39 +02:00
MightyPlaza
6db3c4ef5e layout: no_border_when_only-improvements (#2791) 2023-07-24 12:13:40 +02:00
psentee
2bbe3aa122 nix: use final.hyprland instead of prev.hyprland in waybar-hyprland
Currently, waybar-hyprland package adds `prev.hyprland` to `$PATH`. This is nixpkgs' default hyprland, not hyprland injected by this overlay. I'd expect we want waybar-hyprland to depend on what's in `pkgs.hyprland` after this (and possibly user's other overlays) are applied – which is `final.hyprland`.
2023-07-23 23:19:57 +03:00
Mily
9fc5f4c48b init: Request SCHED_RR using CAP_SYS_NICE and add Python to nix dev shell (#2690)
* nix: add python3 to devShell

* init: request SCHED_RR scheduling policy

* init: checks if host supports reseting scheduler on fork

* init: make gainRealTime more compatible with other OSes

* init: remove linux-only code
2023-07-23 20:51:00 +02:00
MightyPlaza
50e6f368ff windowrules: implements nomaximizerequest (#2785)
* Window.hpp

* ConfigManager.cpp

* Windows.cpp

* fix maximize event
2023-07-23 19:47:41 +02:00
vaxerski
975c4175b2 hyprctl: unify and sanitize ver commit msg better 2023-07-23 19:43:15 +02:00
vaxerski
af395a8f55 windowrules: fix opacity override 2023-07-23 16:03:59 +02:00
vaxerski
90f69782ee window: fix segfault in boundingbox 2023-07-23 16:02:35 +02:00
vaxerski
5a64c73e05 render: use primitive end() only when no screen shader is present 2023-07-23 15:54:27 +02:00
end-4
9845f99b60 add config option to enable/disable new intuitive resizing (#2774)
dwindle:smart_resizing = 1 by default
== 1 then use new resizing
else use old resizing
2023-07-23 15:50:09 +02:00
MightyPlaza
d3bba2489d render: Border fixes (#2781)
* Window.cpp

* layout

* CHyprGroupBarDecoration.cpp
2023-07-23 15:49:49 +02:00
Rachel Knight
b21644b611 input: Fix #2376 mouse movement bug in XWayland (#2776) 2023-07-22 19:31:36 +02:00
vaxerski
b70553cf46 opengl: fix warn 2023-07-22 19:26:56 +02:00
vaxerski
1a7fb1572a renderer: disable init anim on disabled animations 2023-07-22 19:26:44 +02:00
outfoxxed
375e8385ee Fix background occlusion ignoring monitor position (#2771) 2023-07-22 10:19:51 +02:00
vaxerski
27dd07f1b8 windowrules: improve opacity 2023-07-21 19:05:00 +02:00
vaxerski
263b9c6e39 socket1: add a timeout for requests 2023-07-21 17:20:23 +02:00
vaxerski
d7e9eb65e2 renderer: use primitive rendering for copying buffers 2023-07-21 17:11:54 +02:00
Mihai Fufezan
0af97636fa Nix/HM module: solve conflict with upstream HM module 2023-07-21 15:55:56 +03:00
vaxerski
1ec0b7b59a forms: bring back auto labels 2023-07-20 21:54:57 +02:00
vaxerski
f864b15427 background: add option to force hypr chan 2023-07-20 21:01:07 +02:00
vaxerski
61dc0909ae layout: use warp() instead of setValue() 2023-07-20 20:03:27 +02:00
MightyPlaza
ca54ceff6f groups: add use_current_group_pos (#2759) 2023-07-20 19:48:32 +02:00
vaxerski
6c1f4faff2 animationmgr: avoid looping over all avars in favor of only active ones 2023-07-20 19:26:10 +02:00
vaxerski
7940f779e9 cmakelists: move tracy to debug section 2023-07-20 18:29:37 +02:00
vaxerski
a3f6a72a51 region: allow ctor from pixman_box32_t 2023-07-20 18:27:28 +02:00
vaxerski
d2a8b8c2de renderer: cleanup back buffer skip checks 2023-07-20 18:27:14 +02:00
vaxerski
833d73df09 shaders: short-circuit rounding if radius <= 0 2023-07-20 18:18:53 +02:00
vaxerski
23eda1411b renderer: scale box for occlusion 2023-07-20 18:12:29 +02:00
vaxerski
ff598b0827 renderer: don't occlude when pre-blur is queued 2023-07-20 18:03:47 +02:00
vaxerski
e5dd133808 cmake: fix compile 2023-07-20 17:57:02 +02:00
vaxerski
a3e1e5e8ba tracy: add more opengl zones 2023-07-20 17:51:38 +02:00
vaxerski
a921c5b89e Debug: add tracy 2023-07-20 17:47:49 +02:00
vaxerski
948855a984 renderer: add canSkipBackBufferClear 2023-07-20 14:11:05 +02:00
vaxerski
547305c7ed opengl: adjust blend and reduce the usage of clear 2023-07-20 13:49:28 +02:00
vaxerski
b65adf8d4a toplevelexport: support dmabuf + various fixes 2023-07-20 12:42:25 +02:00
fufexan
3a1496b4eb Nix: bump wlroots 2023-07-20 11:20:22 +03:00
Mihai Fufezan
a58b70ca07 CI: update scripts 2023-07-20 11:20:22 +03:00
Mihai Fufezan
91e3c654d3 Nix: move patches to subdir 2023-07-20 11:20:22 +03:00
vaxerski
7091d4e597 animationmanager: optimize avar state 2023-07-19 22:40:03 +02:00
vaxerski
80cd2ef3d7 renderer: remove unused var 2023-07-19 21:10:42 +02:00
vaxerski
2c2314faa0 renderer: take workspace offset into account for occlusion 2023-07-19 21:08:49 +02:00
vaxerski
88c2a02773 render: avoid allocating mirrorfb for no reason 2023-07-19 21:04:45 +02:00
Vaxry
89b87158db internal: Wrap regions (#2750) 2023-07-19 20:09:49 +02:00
vaxerski
ce9896204a renderer: fix rounding in renderSurface 2023-07-19 20:06:19 +02:00
vaxerski
f4f0f35c5b renderer: add occlusion for back layers 2023-07-19 16:13:55 +02:00
vaxerski
b08b72358a props: bump ver to 0.27.2 2023-07-19 13:31:35 +02:00
vaxerski
aac75ddcbf screencopy: guard region buffer values in frameDamage 2023-07-19 13:10:41 +02:00
outfoxxed
5cd5631fb2 Add bringWindowToTop function to IHyprLayout (#2747)
* Add bringWindowToTop function to IHyprLayout

* Rename `bringWindowToTop` to `requestFocusForWindow`

* Fix doc
2023-07-19 12:39:45 +02:00
vaxerski
b8a7b09092 screencopy: use wlr_buffer api for shm copies 2023-07-19 12:24:41 +02:00
vaxerski
81f4a4f471 screencopy: improve shm handling 2023-07-19 00:51:38 +02:00
vaxerski
2623364dbd no_xwayland: fix redef 2023-07-19 00:33:47 +02:00
MightyPlaza
3b03597784 keybinds: movegroupwindow-improvement (#2740)
* movegroupwindow-improvement

* use std::swap
2023-07-19 00:30:10 +02:00
vaxerski
ce9c5fd722 render: set refresh to 0 for both wl and x11 backends 2023-07-19 00:28:15 +02:00
vaxerski
f2999e84b9 render: set refresh to 0 for wayland backend outputs 2023-07-19 00:02:57 +02:00
vaxerski
2fed1badbf props: update ver to 0.27.1 2023-07-18 21:44:49 +02:00
Aaron Blasko
7c1dacea09 only return 0 when using -h (#2738) 2023-07-18 21:00:08 +02:00
vaxerski
08310b4af9 issues: add form templates 2023-07-18 16:51:14 +02:00
vaxerski
16fd9084ea screencopy: nullcheck for empty buffer 2023-07-18 15:52:53 +02:00
vaxerski
0ba28a46fd monitor: unplug all callbacks in ~dtor 2023-07-18 15:36:27 +02:00
Vaxry
8370a7fcc4 internal: Protocol C++ Wraps + XDGOutput impl (#2733)
move to our own xdgoutput impl instead of wlr's
2023-07-18 15:30:28 +02:00
vaxerski
629e61c7a5 monitor: disconnect bind on disconnect 2023-07-18 15:22:49 +02:00
vaxerski
2e323a5671 renderer: use correct wlr sample func 2023-07-18 12:25:48 +02:00
Jan Beich
8c9e2e1ff1 deps: update wlroots (#2734) 2023-07-18 12:13:59 +02:00
István Donkó
5c8a20be77 fix: handle window change directions in fullscreen (#2728) 2023-07-18 12:12:50 +02:00
Tuur Vanhoutte
d2eb4fee76 Avoid connected monitor reusing unavailable ID (#2731) 2023-07-18 12:12:05 +02:00
vaxerski
4537860079 layout: recalculate monitor instead of window in updateDynamicRules 2023-07-18 11:49:57 +02:00
vaxerski
7f47655f60 layout: recalc window on dynamic rule update 2023-07-18 00:11:43 +02:00
vaxerski
2c7b2ad6ca windowrules: add border size rule 2023-07-18 00:11:29 +02:00
MightyPlaza
ddb8c89776 Allow empty args in hyprctl dispatch (#2724) 2023-07-16 21:01:06 +02:00
MightyPlaza
cacdb424a9 massive-fix (#2725) 2023-07-16 21:00:38 +02:00
vaxerski
b156a9654f build: add asan enable status flag 2023-07-16 17:06:05 +02:00
vaxerski
3229862dd4 xwayland: guard monitor validity in xwayland scale overriding 2023-07-15 23:10:05 +02:00
vaxerski
06563d7034 popups: update parent pos on commit 2023-07-15 18:27:21 +02:00
vaxerski
459afcc47f idle: fix reverse flag for new idle protocol 2023-07-14 20:02:31 +02:00
Lennard Hofmann
06f5910365 Make bind modmask case-insensitive (#2714) 2023-07-14 18:39:53 +02:00
MightyPlaza
b159634ef9 move/resize window (#2706) 2023-07-13 20:20:40 +02:00
MightyPlaza
db2367bf33 update groub decos (#2705) 2023-07-13 20:17:14 +02:00
vaxerski
f8def68e7e idle: implement new protocol 2023-07-13 18:05:34 +02:00
vaxerski
9f7382bca4 keybinds: add movegroupwindow 2023-07-13 17:55:25 +02:00
Daniel Adolfsson
d3a644d81c Dwindle: Make resize more intuitive (#2681)
* improved resize

* clang-format

* rewrite

* almost legacy behavior when using CORNER_NONE
2023-07-13 16:52:11 +02:00
vaxerski
70dae78c1b background: add mascot versions 2023-07-13 14:32:30 +02:00
vaxerski
5e577acf51 props: bump ver to 0.27.0 2023-07-12 13:11:11 +02:00
zakk4223
21f64b6660 Keep new mapped layer's alpha zero if the workspace has a fullscreen window (#2686)
Co-authored-by: Zakk <zakk@rsdio.com>
2023-07-12 12:58:45 +02:00
vaxerski
7a7e3ee6d9 screencopy: don't send frames on commits w/o a buffer 2023-07-12 00:30:42 +02:00
vaxerski
9c9f56743e groupbar: fix vram leak 2023-07-11 20:57:38 +02:00
Daniel Adolfsson
64e7d5345d Add support for smart splitting (#2676)
* Add support for smart splitting

* clang-format

* smart_split default to 0, and make smart_split behave like preserve_split
2023-07-11 13:37:25 +02:00
MightyPlaza
29d017f54b monitor desc default workspace but working now (#2678)
* fix desc check

* fixes crashes when nulptr
2023-07-11 11:29:19 +02:00
vaxerski
26579fa962 texture: fix styling 2023-07-11 00:27:13 +02:00
vaxerski
0c61a1530f plugins: fix config value usage in init 2023-07-10 14:13:23 +02:00
vaxerski
da7ea2b33d pluginapi: add configReloaded event 2023-07-10 13:54:06 +02:00
vaxerski
382af06406 render: resize subsurfaces with size resizes 2023-07-10 13:32:57 +02:00
vaxerski
515a363ecd render: move lastFrameDamage to CMonitor 2023-07-10 13:21:00 +02:00
vaxerski
fe54dcb4eb screencopy: send original damage, avoid extents 2023-07-10 13:17:21 +02:00
vaxerski
42f46aeac5 config: minor path handling fixes 2023-07-10 13:10:34 +02:00
MightyPlaza
4cc0e6de90 monitor desc default workspace (#2673) 2023-07-10 07:53:03 +02:00
MightyPlaza
d9f7f039e1 monitor desc support (#2670)
* monitor desc

* monitor desc
2023-07-09 23:10:35 +02:00
Tuur Vanhoutte
b99ac063ea Reuse same ID when reconnecting monitor, otherwise use minimum available ID (#2666)
Fixes #2601
2023-07-09 23:08:40 +02:00
vaxerski
b33d82734f input: schedule frame on mouse move 2023-07-09 00:44:32 +02:00
Ed Younis
f49af187bc Xdg config home support (#2047)
* config: Add support for XDG_CONFIG_HOME

Contributes-to: #1040
Co-authored-by: Björn Bidar <bjorn.bidar@thaodan.de>
Signed-off-by: Björn Bidar <bjorn.bidar@thaodan.de>

* config: Log used config file

* config: Add GetConfigDir and minor fixes

* config: fixed minor nitpicks

---------

Signed-off-by: Björn Bidar <bjorn.bidar@thaodan.de>
Co-authored-by: Björn Bidar <bjorn.bidar@thaodan.de>
2023-07-07 19:19:35 +02:00
vaxerski
e632bf176b config: fix reading touchpad values to non-touchpad per-device cfgs 2023-07-06 16:26:38 +02:00
Mykola Perehudov
41358c6fb5 Cleanup compositor deadcode (#2657)
* Remove dead code as it is a part of CCompositor::cleanup

* Unify sd_notify logic with Compositor lifetime
2023-07-06 15:24:49 +02:00
Mykola Perehudov
bbedb065e1 eventmanager: drop obsoleted ignore events flag (#2660)
This flag became obsoleted in commit
287e6c4ede
2023-07-06 15:23:11 +02:00
Mihai Fufezan
bc34713b29 Nix CI: fix typo 2023-07-06 13:02:56 +03:00
Mykola Perehudov
0c974b7236 Avoid passing control unix socket descriptors to children (#2656)
Add SOCK_CLOEXEC flags to server side connection FDs to make them
closed during execve(2).
2023-07-06 11:39:02 +02:00
nexec
8407a9af0a Close socket2 client descriptor on hangup (#2654) 2023-07-06 00:18:44 +02:00
Mihai Fufezan
c4f288582b flake.lock: update nixpkgs 2023-07-06 01:14:09 +03:00
Mihai Fufezan
981c71e60a Nix CI: split inputs and wlroots updating
Now there are separate update scripts for wlroots and for all other
inputs.
2023-07-05 16:46:02 +03:00
vaxerski
86e487e003 input: remove old redundant code 2023-07-05 13:20:40 +02:00
MightyPlaza
34d845da13 typo (#2643) 2023-07-04 22:03:19 +02:00
vaxerski
07d7962c7f swipe: fix mixup of r/m 2023-07-04 12:34:22 +02:00
vaxerski
18f9fb5e0f rules: add stayfocused 2023-07-04 12:05:25 +02:00
vaxerski
6f91997f06 layout: improve time restraints in window drag 2023-07-04 11:49:24 +02:00
MightyPlaza
283a8e77aa screenshot fix (#2640) 2023-07-04 11:40:28 +02:00
MightyPlaza
50755d26d4 lockgroups fix (#2636) 2023-07-03 15:53:04 +02:00
MightyPlaza
05047f60f4 groupbar fixes (#2630)
Fixes multiple groupbar decoration issues:

  -  togglegroup removes fullscreen to avoid to avoid weird state
 -   fixes issue where a group had multiple windows with head = true
 -   fixes issue where merging 2 groups would cause a window to have 2 groupbar decorations
  -  fixes issue where merging a group with more than 1 window into another group would make windows have no groupbar decoration
  -  fixes issue where ungrouping windows could just move them into another group on the same workspace


---------

Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
2023-07-03 12:49:56 +02:00
vaxerski
738ec900f4 config: fix floating rules with floating-by-rule windows 2023-07-02 13:02:48 +02:00
vaxerski
86ca283352 gestures: add workspace_swipe_use_r 2023-07-01 16:30:36 +02:00
vaxerski
6c28388420 layout: minor style fixes 2023-07-01 16:28:17 +02:00
vaxerski
e96fcb31f0 layout: set pseudo to float size in new window 2023-06-30 11:29:06 +02:00
Mihai Fufezan
64fc19cc81 Nix/portals.patch: conditionally check portals 2023-06-30 10:13:39 +03:00
vaxerski
1012e2735a shader: remove useless comment 2023-06-29 23:20:10 +02:00
MightyPlaza
990ad854bd Reloads animated decoration values set on window rules (#2594)
* Reloads dynamic window rules

* Update ConfigManager.cpp

* Update ConfigManager.cpp

* Reloads animated decoration values set on window rules

Reloads animated decoration values like border color and opacity set on window rule on config reload.
2023-06-28 11:40:16 +02:00
vaxerski
d83296c7a9 renderer: damage decos on damageWindow 2023-06-27 13:23:58 +02:00
Mihai Fufezan
62c75883d1 Nix: patch portals search dir 2023-06-27 00:51:04 +03:00
MightyPlaza
7ed66abe57 Reloads dynamic window rules (#2585)
* Reloads dynamic window rules

* Update ConfigManager.cpp

* Update ConfigManager.cpp
2023-06-26 13:03:51 +02:00
vaxerski
4294456cdc xwayland: remove spaces from output names 2023-06-25 13:52:24 +02:00
Mihai Fufezan
a82559f185 flake.lock: update nixpkgs 2023-06-24 16:38:23 +03:00
vaxerski
01f85a09a9 xwayland: send zero scaling to xwayland if enabled 2023-06-23 21:42:44 +02:00
vaxerski
69fae18e63 damage: account for popups in getFullWindowBoundingBox 2023-06-23 13:54:01 +02:00
vaxerski
c241da5ea5 crashreporter: log tag 2023-06-23 13:22:38 +02:00
vaxerski
0283c498d6 xwayland: fix minor force_zero_scaling bugs 2023-06-22 21:43:31 +02:00
vaxerski
fc59cef1ee keybinds: remove old todo 2023-06-21 21:20:26 +02:00
vaxerski
2f875aec79 includes: move workspace protocol header to includes 2023-06-21 21:17:05 +02:00
vaxerski
cfa4086b0b configmgr: fix idiotic comparisons in device configs 2023-06-21 20:58:35 +02:00
vaxerski
cbe9bf0e69 compositor: move group members properly in moveWindowToWorkspaceSafe 2023-06-21 20:51:18 +02:00
vaxerski
83ad6b9af8 groupbar: fix damage calcs 2023-06-21 13:16:10 +02:00
vaxerski
cabdf38ce4 internal: minor style fixes 2023-06-20 21:35:54 +02:00
vaxerski
2295bbdd80 xwaylandmanager: fixup style 2023-06-18 18:14:52 +02:00
Shemig
74ca81cc79 Partial revert of Commit 302ec13: (#2539)
Fix crash when screen size is 0x0 (#2523)

Reason: The disable of a monitor with 0x0 size
is causing issuses with some users.

https://github.com/hyprwm/Hyprland/issues/2537

Left the defensive code to resolve the crash.
Will continue to investigate and find a solution for the
dell xps disabled monitor

Co-authored-by: giladsx <gilad@spectalix.com>
2023-06-17 18:49:37 +02:00
vaxerski
5ac625d7bd format: fix hooksystem 2023-06-16 18:45:14 +02:00
solopasha
1d902a4621 fix updating revision in wlroots.wrap
revision gets updated to the previous one, not current.
2023-06-15 23:32:52 +03:00
Shemig
302ec1372c Fix crash when screen size is 0x0 (#2523)
(When booting into laptop clam mode in dell XPS)
and also ignore any screen with size 0x0 in the first place

Co-authored-by: giladsx <gilad@spectalix.com>
2023-06-15 22:07:58 +02:00
vaxerski
d768226de9 [gha] bump flake inputs 2023-06-15 08:53:30 +00:00
vaxerski
c55c28ec7f deps: update wlroots 2023-06-15 10:45:20 +02:00
vaxerski
c4dec4f796 internal: damage window on change group 2023-06-14 19:44:51 +02:00
vaxerski
0f1911a8d4 opengl: fix invalid tex references to tex-less shader 2023-06-14 13:47:57 +02:00
vaxerski
e43f7fc98d shader: init uniforms to -1 2023-06-14 13:29:12 +02:00
vaxerski
fbabb105c3 gamma: use wlr's new gamma manager event 2023-06-14 13:26:47 +02:00
outfoxxed
f0e4f6622e Implement pass binds (#2503)
* Implement pass binds

Pass binds run the associated dispatcher but do not prevent windows
from receiving the bind.

* Fix pass binds not working properly with release binds

* Rename `pass` to `nonConsuming`
2023-06-14 13:08:56 +02:00
JManch
9a88c19f1a screenshader: fix uniform variable checks (#2513) 2023-06-14 13:03:20 +02:00
vaxerski
7762ac0173 toplevelexport: ignore defunct windows 2023-06-13 20:13:21 +02:00
vaxerski
e8c6d0f51e compositor: don't set dim percent on disabled dim 2023-06-13 18:51:49 +02:00
vaxerski
807b52b019 animationmgr: warp on equal start and goal 2023-06-13 18:50:45 +02:00
vaxerski
0e31eaa157 shadow: drop useless damageEntire() 2023-06-13 18:50:45 +02:00
memchr
24ed9b061f feat: add variable to customize locked group border color (#2507)
added variables:
- general:col.group_border_locked
- general:col.group_border_locked_active
2023-06-13 12:04:54 +02:00
vaxerski
528cfc2889 [gha] bump flake inputs 2023-06-12 16:47:13 +00:00
vaxerski
91fbee24da deps: update wlroots 2023-06-12 18:35:33 +02:00
vaxerski
6beb79f27b xwayland: add force_zero_scaling 2023-06-11 21:52:13 +02:00
vaxerski
64ce06a353 xwayland: add nearest neighbor filtering as an opt 2023-06-11 21:33:59 +02:00
end-4
e1edfde539 Allow setting alpha value for ignorezero layer rule (#2477)
* rename ignorezero to ignorealpha

* allow setting ignorealpha value

This commit allows setting a float value (0-1) for the ignorealpha layer rule.
Does not yet have error handling; invalid ignorealpha layer rule will crash Hyprland.

* add brackets i forgot to add

* prevent crash with invalid ignorealpha value

prevents hyprland from immediately crashing with invalid ignorealpha layer rule
does not log

* don't try to set ignoreAlphaValue if alpha value not specified

* add catch to try, reintroduce ignorezero

- added catch after try cuz i was an idiot
- re-add ignorezero as an alternative to ignorealpha to not introduce a breaking change

* add logging for failed ignorealpha layer rule

* fix get ignorealpha's get VALUE

* check npos and use empty()

* rename VALUE cuz no longer const

* format Shader.hpp
2023-06-11 19:30:31 +02:00
Nicola Guerrera
10fd75c833 zoom: multiply by scale only on mouseZoomUseMouse (#2495) 2023-06-10 23:00:41 +02:00
vaxerski
7932e42507 screenshader: add output uniform 2023-06-10 16:10:26 +02:00
Nicola Guerrera
003993337a calculate zoom_center based on monitor scale (#2482) 2023-06-10 12:28:00 +02:00
memchr
bca3068db2 feat: add lockactivegroup dispatcher (#2478)
* feat: add lockactivegroup dispatcher

The `lockactivewindow` dispatcher takes `lock`, `toggle` or `unlock` as arguments. When a group is locked, no window or group can be added to it, nor can it be added to another group, but the `moveintogroup` and `moveoutofgroup` dispatches are not affected.

Implementation details:

the lock is implement via `SGroupData.locked` flag (defaults to false).

The flag is only relevant to the group head, and upon the group head's succession, the flag will be passed down to the new head. Meanwhile, the old head's flag will be set to false.

The flag is set to false when a group is dismissed.

New condition checks have been added to the dwindle and master layout to check if target group is unlocked (and if the source is also a group and unlocked) before adding windows to the target group.

* refactor: `lockactivegroup dispatcher code ordering
2023-06-09 23:44:18 +02:00
vaxerski
cf37922d42 input: update surface input on changeworkspace 2023-06-09 12:20:40 +02:00
eriedaberrie
d123835ef5 main: fix segfault when -c is given with no other arguments (#2470) 2023-06-09 12:15:18 +02:00
Michał
7f753cab9a chore: fix typos (#2463)
Some typos when spelling Hyprland
2023-06-07 20:18:39 +02:00
Franz Berger
4afeedbd56 Fix fractional scale updates in some cases (#2447)
* fix fractional scale update in moveWorkspaceToMonitor

* fix fractional scale update in moveToWorkspace

* Revert "fix fractional scale update in moveWorkspaceToMonitor"

This reverts commit 6612197a38.

* Revert "fix fractional scale update in moveToWorkspace"

This reverts commit 75d9795a06.

* move fractional scale code to updateSurfaceOutputs

* remove duplicate check

* remove superfluous setPreferredScale()
2023-06-06 09:48:07 +02:00
vaxerski
10db5a4fdb xwayland: disconnect events on destroy
thanks Kirill Primak
2023-06-05 20:51:47 +02:00
vaxerski
1a4e6e6a4b window: recalc on deco remove 2023-06-05 09:49:21 +02:00
staz
e4e6ddb075 Make movetoworkspace register previous workspace (#2436)
* Make movetoworkspace register previous workspace

* style: no braces + format with clang-format
2023-06-05 09:44:13 +02:00
vaxerski
4ef684f615 hyprctl: recalc layout on setprop 2023-06-04 21:35:23 +02:00
vaxerski
2629cfeeab layouts: make aware of borderSize prop 2023-06-04 21:35:23 +02:00
vaxerski
d83e5b8409 internal: make borderSize prop overridable 2023-06-04 21:35:23 +02:00
vaxerski
df98db5092 [gha] bump flake inputs 2023-06-03 16:07:31 +00:00
vaxerski
d87010f300 deps: update wlroots 2023-06-03 17:59:31 +02:00
vaxerski
c5a7202cd9 noxwl: add missing stubs 2023-06-03 13:01:32 +02:00
vaxerski
70e4162dcc [gha] bump flake inputs 2023-06-03 10:28:25 +00:00
vaxerski
147e962370 deps: update wlroots 2023-06-03 12:20:28 +02:00
Cyril Levis
d7db7040d4 feat: add ipc set title window event (#2419)
* feat: add ipc set title window event

* chore: add EMIT_HOOK_EVENT and change event name
2023-06-03 11:18:49 +02:00
vaxerski
67be8d89b5 [gha] build man pages 2023-06-03 09:11:37 +00:00
asdfer
18956144d5 Update ISSUE_GUIDELINES.md faq link to the wiki (#2424)
Co-authored-by: local <>
2023-06-03 11:11:13 +02:00
vaxerski
871ab24c6e internal: properly set monitor props on special windows 2023-06-02 20:14:34 +02:00
vaxerski
ce0f248d20 events: remove old comment 2023-06-02 19:50:02 +02:00
vaxerski
dd0bf87c01 [gha] bump flake inputs 2023-06-02 16:53:02 +00:00
vaxerski
6ba8310c13 deps: update wlroots 2023-06-02 18:44:05 +02:00
Sinkerine
ca3791fed8 [hyprctl] Expose the special workspace id and name of the monitor (#2392)
* [hyprctl] Expose the special workspace id of the monitor

So that we know if a special workspace is shown on a monitor

* [hyprctl] Add special workspace name to the output
2023-06-02 13:25:33 +02:00
vaxerski
9cf72a30fc debug: add WITH_ASAN flag in cmake 2023-06-01 17:08:11 +02:00
vaxerski
e76bd43f53 rules: add nodim 2023-05-31 21:11:20 +02:00
vaxerski
baf81cdc5d input: force focus on movefocus 2023-05-31 20:59:38 +02:00
vaxerski
9f72d508ae groupbars: fix damage calcs 2023-05-31 19:53:58 +02:00
vaxerski
1844e8adad [gha] bump flake inputs 2023-05-31 14:18:39 +00:00
vaxerski
b540d28849 deps: update wlroots 2023-05-31 16:09:25 +02:00
vaxerski
fd73a7f795 gradient: fix warn 2023-05-31 15:55:54 +02:00
vaxerski
51a930f802 version: bump to 0.26.0 2023-05-29 19:17:38 +02:00
vaxerski
a7cfbdb854 keybinds: fix tryMoveFocusToMonitor with special 2023-05-29 18:11:37 +02:00
vaxerski
1e3571eb5b layout: don't reset to floating size on drag tiled 2023-05-29 18:05:41 +02:00
vaxerski
5484411232 compositor: disallow sending pinned to special 2023-05-29 17:46:12 +02:00
Jan Beich
f1ad270ff8 vector: restore cmath include after 438d063ec6 (#2394)
src/helpers/Vector2D.cpp:27:26: error: no member named 'floor' in namespace 'std'
    return Vector2D(std::floor(x), std::floor(y));
                    ~~~~~^
src/helpers/Vector2D.cpp:27:41: error: no member named 'floor' in namespace 'std'
    return Vector2D(std::floor(x), std::floor(y));
                                   ~~~~~^
src/helpers/Vector2D.cpp:37:17: error: no member named 'sqrt' in namespace 'std'
    return std::sqrt(dx * dx + dy * dy);
           ~~~~~^
2023-05-29 15:12:00 +02:00
Jeremy Huang
b3a86952cf focus: fix #1675 window not scrollable after movefocus (#2390) 2023-05-29 09:52:36 +02:00
outfoxxed
409ff027f8 Fix UAF in animation end callback if callback deletes the animation (#2389)
Removes use after free when the end callback deletes the animation as
long as `m_bRemoveEndAfterRan` is false.
2023-05-29 09:51:58 +02:00
vaxerski
438d063ec6 vector: use c++ stdlib math functions instead of cmath 2023-05-28 22:50:13 +02:00
vaxerski
078ba6daa8 groupbars: add text color opt 2023-05-27 17:46:02 +02:00
Ruby Iris Juric
74b49de883 Add hyprland to waybar-hyprland path as fallback for hyprctl 2023-05-27 15:35:25 +03:00
Jeremy Huang
8afc2f45c7 focus: make cursor follow movewindow (#2374) 2023-05-27 12:16:50 +02:00
vaxerski
5f4659afef xdgshell: check and conform to rigid float sizes on commit 2023-05-26 14:49:03 +02:00
vaxerski
0887e2ee6e window: reveal current from group on toplevel activate 2023-05-26 13:44:59 +02:00
vaxerski
62e3953f5b master: guard monitor in recalc 2023-05-26 13:41:52 +02:00
vaxerski
9c9b74179c pluginapi: add separate window render events 2023-05-26 13:07:45 +02:00
vaxerski
a2bb95fc60 touch: fix double offset in local 2023-05-24 22:19:22 +02:00
vaxerski
12227d7b6a input: only configure newly added touch devices 2023-05-24 22:17:33 +02:00
vaxerski
a4c120d608 layouts: ignore direction forces on non-map 2023-05-24 19:23:10 +02:00
eriedaberrie
53285a75ad hyprctl: fix cut-off json outputs (#2352)
* hyprctl: fix cut-off json outputs

* Address comments
2023-05-24 17:46:56 +02:00
vaxerski
f877d68f4f launchanim: fix #2291 2023-05-24 15:49:31 +02:00
Xianhao Yu
5bfd5a9240 examples: fix incorrect link in per-device config comments (#2353) 2023-05-24 11:11:49 +02:00
vaxerski
eb1f832fce decos: recalc on add 2023-05-23 14:26:38 +02:00
vaxerski
799add8659 groupbars: fix reserved area on titles 2023-05-23 14:18:26 +02:00
vaxerski
90cb5fb672 groupbars: make gradients toggleable 2023-05-22 22:07:32 +02:00
vaxerski
d1ec314a03 groupbars: conserve VRAM by staticizing textures 2023-05-22 22:06:40 +02:00
vaxerski
7bcc01efb7 groupbars: fix minor alignment issues 2023-05-22 21:43:37 +02:00
vaxerski
206ac000b9 groupbars: add title and gradient rendering 2023-05-22 21:40:32 +02:00
vaxerski
1eb6cfd45c groupbar: make exclusive 2023-05-22 20:52:41 +02:00
vaxerski
088b4a68e6 moveActiveToWorkspace: update last window of old ws 2023-05-22 19:44:10 +02:00
vaxerski
086f724951 wlr_ext_workspaces: honor activate from client + format 2023-05-22 19:36:47 +02:00
Russell Greene
ad244190e0 1483: fix crash on last display disconnect (#2344) 2023-05-22 12:18:07 +02:00
maqrrr
9f8c5cb63c Fix broken pipe crash when event listener terminates (#2339) 2023-05-21 14:38:18 +02:00
vaxerski
5627b70981 input: reset cursor hide timer on tablet 2023-05-20 21:15:21 +02:00
vaxerski
79b8576df9 examples: update plugin makefile 2023-05-17 15:01:17 +01:00
vaxerski
ba714b3b71 examples: update plugin headers 2023-05-17 14:59:52 +01:00
Anthony Ruhier
d7935356da input: don't move monitor focus on wp change (#2320) 2023-05-17 13:32:59 +01:00
Anthony Ruhier
9ef7225532 don't swap workspaces if monitors are the same (#2322)
Return swapActiveWorkspaces early if MON1 and MON2 are equals, to avoid
buggy behavior.
2023-05-17 13:31:03 +01:00
outfoxxed
642030f959 Fix not finding function symbols for hooking (#2292)
Fixes no useful feedback about failing subcommand.
Fixes function hooks breaking when running under a path containing
spaces.

Replaced old usages with this function where possible.
Complex shell usages now use `execAndGetShell` which is equal to the
old function.
2023-05-16 23:39:14 +03:00
Mihai Fufezan
78826c6d18 meson & nix: install wlroots headers (#2287) 2023-05-16 20:50:18 +03:00
Eric_Luo
b5b9af508a bug fix (#2314)
fix float check logic

Co-authored-by: hnboy <hnywolf@gmail.ccom>
2023-05-16 17:43:04 +01:00
vaxerski
d68f8ea668 internal: make CAnimatedVariable non-move non-copy 2023-05-16 12:49:59 +01:00
vaxerski
5b84b0fb44 animationmgr: allow empty avars 2023-05-15 17:11:51 +01:00
Vaxry
621eac32d3 readme: update previews 2023-05-15 15:33:58 +01:00
vaxerski
824813fc6a internal: remove check for negative exact vector args 2023-05-15 15:16:06 +01:00
vaxerski
7c207243e4 input: check for matrix availability in touch config 2023-05-14 13:54:55 +01:00
vaxerski
b748b0734f input: don't refocus on closed window 2023-05-14 13:47:43 +01:00
vaxerski
896a78aaa0 lock: add allow_session_lock_restore 2023-05-13 12:36:36 +01:00
vaxerski
cc01550aff hyprctl: recalc layout on dynamic workspace 2023-05-12 01:16:27 +01:00
vaxerski
413a36a914 workspacerules: overwrite on existing 2023-05-12 01:15:32 +01:00
vaxerski
86ef85efae layershell: don't enter on unmapped ls 2023-05-12 01:07:46 +01:00
vaxerski
a483376591 pluginenv: copy built wlr headers 2023-05-11 20:17:26 +01:00
vaxerski
f2725a374a render: minor fixes to fullscreen rendering 2023-05-10 18:36:13 +01:00
vaxerski
7fde80f38e layers: fix wonky focus on multimon 2023-05-09 17:01:18 +01:00
vaxerski
cc4ccfdbfd internal: use i64 for workspaces in outofbounds 2023-05-09 14:08:05 +01:00
Andrei Alexeyev
2f87e4c2f3 renderer,config: add custom DRM modeline support (#2254)
This allows specifying custom display resolutions for the DRM backend.
This is useful for display overclocking, working around broken EDIDs,
etc. To use this feature, specify a modeline instead of a resolution
in the config, for example:

    monitor = DP-1, modeline 1071.101 3840 3848 3880 3920 2160 2263 2271 2277 +hsync -vsync, 0x0, 1

This example is a custom 3840x2160@120Hz mode with tightened timings.
I use it because the standard timings don't work with my monitor and GPU
combination (M28U with RX580).

The syntax is compatible with Sway and Xorg.
2023-05-09 14:01:45 +01:00
vaxerski
e7c2ea9724 layershell: focus if changed keyboard mode 2023-05-08 19:12:01 +01:00
scorpion-26
826dc61e5c Add "next on monitor or empty" workspace parameter (#2198)
* Add "next on monitor or empty" workspace parameter

Implements the following workspace parameter:
r+x/r-x (i.e. r+1): Behaves similar to the "m" parameter, but can also
select empty workspaces and it doesn't wrap around

* Improve code comments

* Implementation V2 for 'r' workspace param

* Rebase to upstream

Should fix CI

* Always set outName

* Include named workspaces

Currently only considers open/active named workspaces
2023-05-08 14:37:59 +01:00
vaxerski
a31dceb2c6 includes: remove redundant from screencopy 2023-05-07 00:11:33 +01:00
vaxerski
1ba7a09bf6 includes: use libdrm prefix for include 2023-05-07 00:11:01 +01:00
vaxerski
afe8d8dfec monitors: fix some bugs with re-plug 2023-05-06 16:50:15 +01:00
dtop129
7e5ba5e824 Fixed wrong focus changes when moving background workspaces (#2258) 2023-05-06 16:13:26 +01:00
vaxerski
83cd5e2ebd workspaces: minor fixes for multi-special 2023-05-06 16:10:51 +01:00
vaxerski
7f0738bcb3 varlist: allow using s for std::isspace 2023-05-06 01:16:20 +01:00
vaxerski
583b8842e7 configmanager: fix substr offset in default ws rule 2023-05-06 01:10:05 +01:00
Dashie
a8541d5f64 Add split preselection (#2240) 2023-05-06 01:02:18 +01:00
vaxerski
4ad03af544 compositor: don't focus pointer in focusWindow 2023-05-06 00:59:25 +01:00
vaxerski
0859944c9a input: add custom accel profiles 2023-05-05 16:06:13 +01:00
vaxerski
c0be1e2fd8 configmanager: remove useless log from handleWorkspaceRule 2023-05-05 15:42:02 +01:00
vaxerski
7b73a332ea configmanager: deprecate bindws 2023-05-05 15:41:25 +01:00
vaxerski
a5d63a0324 configmanager: store workspace rules as a deque 2023-05-05 15:33:31 +01:00
vaxerski
8435d6fc12 monitors: toggle special on changeworkspace with special 2023-05-05 15:01:31 +01:00
Mihai Fufezan
d1d4683c91 Issue template: request users to ping me for Nix 2023-05-05 11:46:20 +03:00
vaxerski
bf04c83e3d config: clear layer rules on reload 2023-05-04 18:28:45 +01:00
John Rinehart
0432804b18 Nix: expose/use flake's own hyprland-protocols in overlays.default (#2235) 2023-05-04 17:47:15 +03:00
solopasha
da093a8aec quote hash for the GIT_COMMIT_HASH macro (#2227)
otherwise compilation fails with smth like
```
../src/debug/../plugins/../defines.hpp:1:25:
error: ‘f27873a6f06dc2f87600edb890f3c38298bfb55f’ was not declared in this scope
```
2023-05-03 20:50:33 +01:00
160 changed files with 6100 additions and 3035 deletions

56
.github/ISSUE_TEMPLATE/bug.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Bug Report
description: Something is not working right
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Before opening a new issue, take a moment to search through the current open ones.
---
- type: input
id: ver
attributes:
label: Hyprland Version
description: "Paste here the output of `hyprctl version`."
placeholder: Hyprland, built from branch main at commit...
validations:
required: true
- type: dropdown
id: type
attributes:
label: Bug or Regression?
description: Is this a bug or a regression?
options:
- Bug
- Regression
validations:
required: true
- type: textarea
id: desc
attributes:
label: Description
description: "What went wrong?"
validations:
required: true
- type: textarea
id: repro
attributes:
label: How to reproduce
description: "How can someone else reproduce the issue?"
validations:
required: true
- type: textarea
id: logs
attributes:
label: Crash reports, logs, images, videos
description: |
Anything that can help. Please always ATTACH and not paste them.
Logs can be found in /tmp/hypr
Crash reports are stored in ~/.hyprland or $XDG_CACHE_HOME/hyprland

View File

@@ -1,12 +0,0 @@
---
name: Bug report
about: Found a bug? Report it here!
title: ''
labels: bug
assignees: ''
---
Please consult the issue guidelines at
https://github.com/vaxerski/Hyprland/blob/main/docs/ISSUE_GUIDELINES.md
BEFORE submitting.

19
.github/ISSUE_TEMPLATE/feature.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Feature Request
description: I'd like to request additional functionality
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Before opening a new issue, take a moment to search through the current open ones.
---
- type: textarea
id: desc
attributes:
label: Description
description: "Describe your idea"
validations:
required: true

View File

@@ -1,12 +0,0 @@
---
name: Feature request
about: Suggest a feature/change/idea
title: ''
labels: enhancement
assignees: ''
---
Please consult the issue guidelines at
https://github.com/vaxerski/Hyprland/blob/main/docs/ISSUE_GUIDELINES.md
BEFORE submitting.

View File

@@ -26,3 +26,6 @@ jobs:
name: Commit
with:
commit_message: "[gha] build man pages"
commit_user_name: Mihai Fufezan
commit_user_email: fufexan@protonmail.com
commit_author: Mihai Fufezan <fufexan@protonmail.com>

View File

@@ -0,0 +1,40 @@
name: "Nix update"
on:
schedule:
- cron: '0 0 * * *'
jobs:
update:
name: "inputs"
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v20
with:
install_url: https://nixos.org/nix/install
extra_nix_config: |
auto-optimise-store = true
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
experimental-features = nix-command flakes
- name: Update lockfile
run: nix/update-inputs.sh
- uses: cachix/cachix-action@v12
with:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build packages
run: nix flake check --print-build-logs --accept-flake-config
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[gha] Nix: bump inputs"
commit_user_name: Mihai Fufezan
commit_user_email: fufexan@protonmail.com
commit_author: Mihai Fufezan <fufexan@protonmail.com>

View File

@@ -1,13 +1,15 @@
name: "Nix: update lockfile"
name: "Nix update"
on: [push, workflow_dispatch]
jobs:
update:
name: "wlroots"
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v20
with:
@@ -16,14 +18,21 @@ jobs:
auto-optimise-store = true
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
experimental-features = nix-command flakes
- name: Update lockfile
run: nix/update-inputs.sh
run: nix/update-wlroots.sh
- uses: cachix/cachix-action@v12
with:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build Waybar-Hyprland
run: nix build .#waybar-hyprland --print-build-logs
- name: Build packages
run: nix flake check --print-build-logs --accept-flake-config
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[gha] bump flake inputs"
commit_message: "[gha] Nix: bump wlroots"
commit_user_name: Mihai Fufezan
commit_user_email: fufexan@protonmail.com
commit_author: Mihai Fufezan <fufexan@protonmail.com>

View File

@@ -18,7 +18,7 @@ jobs:
- name: Create tarball with submodules
id: tar
run: |
sed -i "1s/^/#define GIT_COMMIT_HASH $(git rev-parse HEAD)\n#define GIT_TAG \"$(git describe --tags)\"\n/" ./src/defines.hpp
sed -i "1s/^/#define GIT_COMMIT_HASH \"$(git rev-parse HEAD)\"\n#define GIT_TAG \"$(git describe --tags)\"\n/" ./src/macros.hpp
mkdir hyprland-source; mv ./* ./hyprland-source || tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz *
- id: whatrelease

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "subprojects/udis86"]
path = subprojects/udis86
url = https://github.com/canihavesomecoffee/udis86
[submodule "subprojects/tracy"]
path = subprojects/tracy
url = https://github.com/wolfpld/tracy

View File

@@ -96,9 +96,29 @@ add_executable(Hyprland ${SRCFILES})
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Setting debug flags")
target_link_libraries(Hyprland asan)
if (WITH_ASAN)
message(STATUS "Enabling ASan")
add_compile_options(-pg -no-pie -fno-builtin -fsanitize=address)
target_link_libraries(Hyprland asan)
add_compile_options(-fsanitize=address)
endif()
if(USE_TRACY)
message(STATUS "Tracy is turned on")
option( TRACY_ENABLE "" ON)
option( TRACY_ON_DEMAND "" ON)
add_subdirectory (subprojects/tracy)
target_link_libraries(Hyprland Tracy::TracyClient)
if(USE_TRACY_GPU)
message(STATUS "Tracy GPU Profiling is turned on")
add_compile_definitions(USE_TRACY_GPU)
endif()
endif()
add_compile_options(-pg -no-pie -fno-builtin)
add_link_options(-pg -no-pie -fno-builtin)
endif()
@@ -144,14 +164,14 @@ target_compile_definitions(Hyprland
"GIT_DIRTY=\"${GIT_DIRTY}\""
"GIT_TAG=\"${GIT_TAG}\"")
target_link_libraries(Hyprland rt)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
message(STATUS "Setting link libraries")
target_link_libraries(Hyprland rt PkgConfig::deps)
function(protocol protoPath protoName external)
if (external)
execute_process(
@@ -172,8 +192,6 @@ function(protocol protoPath protoName external)
endif()
endfunction()
target_link_libraries(Hyprland PkgConfig::deps)
target_link_libraries(Hyprland
${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.12032 # wlroots is provided by us
OpenGL::EGL
@@ -194,5 +212,7 @@ protocol("subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.
protocol("subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true)
protocol("stable/xdg-shell/xdg-shell.xml" "xdg-shell" false)
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
protocol("unstable/xdg-output/xdg-output-unstable-v1.xml" "xdg-output-unstable-v1" false)
protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false)
protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false)
protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)

View File

@@ -44,9 +44,7 @@ install:
cp -f ./hyprctl/hyprctl ${PREFIX}/bin
if [ ! -f ${PREFIX}/share/wayland-sessions/hyprland.desktop ]; then cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions; fi
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
cp ./assets/wall_* ${PREFIX}/share/hyprland
mkdir -p ${PREFIX}/share/man/man1
install -m644 ./docs/*.1 ${PREFIX}/share/man/man1
@@ -55,11 +53,14 @@ install:
mkdir -p ${PREFIX}/include/hyprland/protocols
mkdir -p ${PREFIX}/include/hyprland/wlroots
mkdir -p ${PREFIX}/share/pkgconfig
mkdir -p ${PREFIX}/share/xdg-desktop-portal
find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland
cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../..
cd subprojects/wlroots/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../../..
cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols
cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig
cp ./assets/hyprland-portals.conf ${PREFIX}/share/xdg-desktop-portal/
if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi
cleaninstall:
@@ -107,6 +108,7 @@ pluginenv:
find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland
cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../..
cd subprojects/wlroots/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../../..
cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols
cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig
if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi

View File

@@ -147,9 +147,9 @@ Although Hyprland is pretty stable, it may have some bugs.
<!----------------------------------{ Images }--------------------------------->
[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg
[Preview A]: https://i.ibb.co/SX7GbYR/winter-rice.png
[Preview B]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png
[Preview C]: https://i.imgur.com/pC6YF1Y.png
[Preview A]: https://cdn.discordapp.com/attachments/1091569872535814185/1107675866101723277/screenshot-summer.png
[Preview B]: https://i.ibb.co/SX7GbYR/winter-rice.png
[Preview C]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png
<!----------------------------------{ Badges }--------------------------------->

View File

@@ -0,0 +1,2 @@
[preferred]
default=hyprland

View File

@@ -1,5 +1,9 @@
wallpapers = ['wall_2K.png', 'wall_4K.png', 'wall_8K.png']
wallpaper_types = ['', 'anime_', 'anime2_']
foreach wallpaper : wallpapers
install_data(wallpapers, install_dir: join_paths(get_option('datadir'), 'hyprland'), install_tag: 'runtime')
foreach type : wallpaper_types
foreach size : [2, 4, 8]
install_data(f'wall_@type@@size@K.png', install_dir: join_paths(get_option('datadir'), 'hyprland'), install_tag: 'runtime')
endforeach
endforeach
install_data('hyprland-portals.conf', install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal'), install_tag: 'runtime')

BIN
assets/wall_anime2_2K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 KiB

BIN
assets/wall_anime2_4K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
assets/wall_anime2_8K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
assets/wall_anime_2K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

BIN
assets/wall_anime_4K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
assets/wall_anime_8K.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 2.9.2.1
.\"
.TH "Hyprland" "1" "03 Apr 2023" "" "Hyprland User Manual"
.TH "Hyprland" "1" "" "" "Hyprland User Manual"
.hy
.SH NAME
.PP

View File

@@ -2,7 +2,7 @@
First of all, please remember to:
- Check that your issue is not a duplicate
- Read the [FAQ](https://github.com/vaxerski/Hyprland/wiki/FAQ)
- Read the [FAQ](https://wiki.hyprland.org/FAQ/)
- Read the [Configuring Page](https://wiki.hyprland.org/Configuring/Configuring-Hyprland)
<br/>

View File

@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 2.9.2.1
.\"
.TH "hyprctl" "1" "03 Apr 2023" "" "hyprctl User Manual"
.TH "hyprctl" "1" "" "" "hyprctl User Manual"
.hy
.SH NAME
.PP

View File

@@ -3,6 +3,6 @@
# and that you have ran `make protocols` in the hl dir.
all:
g++ -shared -fPIC --no-gnu-unique main.cpp customLayout.cpp customDecoration.cpp -o examplePlugin.so -g -I "/usr/include/pixman-1" -I "/usr/include/libdrm" -I "${HYPRLAND_HEADERS}" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/include" -I "${HYPRLAND_HEADERS}/subprojects/wlroots/build/include" -std=c++23
$(CXX) -shared -fPIC --no-gnu-unique main.cpp customLayout.cpp customDecoration.cpp -o examplePlugin.so -g `pkg-config --cflags pixman-1 libdrm hyprland` -std=c++2b
clean:
rm ./examplePlugin.so

View File

@@ -1,6 +1,6 @@
#include "customDecoration.hpp"
#include "../../src/Window.hpp"
#include "../../src/Compositor.hpp"
#include <hyprland/src/Window.hpp>
#include <hyprland/src/Compositor.hpp>
#include "globals.hpp"
CCustomDecoration::CCustomDecoration(CWindow* pWindow) {

View File

@@ -2,7 +2,7 @@
#define WLR_USE_UNSTABLE
#include "../../src/render/decorations/IHyprWindowDecoration.hpp"
#include <hyprland/src/render/decorations/IHyprWindowDecoration.hpp>
class CCustomDecoration : public IHyprWindowDecoration {
public:

View File

@@ -1,5 +1,5 @@
#include "customLayout.hpp"
#include "../../src/Compositor.hpp"
#include <hyprland/src/Compositor.hpp>
#include "globals.hpp"
void CHyprCustomLayout::onWindowCreatedTiling(CWindow* pWindow) {

View File

@@ -2,7 +2,7 @@
#define WLR_USE_UNSTABLE
#include "../../src/layout/IHyprLayout.hpp"
#include <hyprland/src/layout/IHyprLayout.hpp>
struct SWindowData {
CWindow* pWindow = nullptr;

View File

@@ -1,5 +1,5 @@
#pragma once
#include <src/plugins/PluginAPI.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>
inline HANDLE PHANDLE = nullptr;

View File

@@ -2,8 +2,8 @@
#include "globals.hpp"
#include <src/Window.hpp>
#include <src/Compositor.hpp>
#include <hyprland/src/Window.hpp>
#include <hyprland/src/Compositor.hpp>
#include "customLayout.hpp"
#include "customDecoration.hpp"
@@ -77,8 +77,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "processMouseDownNormal");
g_pMouseDownHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*)&hkProcessMouseDownNormal);
static auto* const PBORDERCOLOR = HyprlandAPI::getConfigValue(PHANDLE, "plugin:example:border_color");
// fancy notifications
HyprlandAPI::addNotificationV2(PHANDLE, {{"text", "Example hint"}, {"time", (uint64_t)10000}, {"color", CColor(0.2, 0.2, 0.9, 1.0)}, {"icon", ICON_HINT}});
HyprlandAPI::addNotificationV2(
PHANDLE,
{{"text", "Example hint, color " + std::to_string(PBORDERCOLOR->intValue)}, {"time", (uint64_t)10000}, {"color", CColor{PBORDERCOLOR->intValue}}, {"icon", ICON_HINT}});
// Enable our hooks
g_pFocusHook->hook();

View File

@@ -55,10 +55,12 @@ decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 10
blur = true
blur_size = 3
blur_passes = 1
blur_new_optimizations = true
blur {
enabled = true
size = 3
passes = 1
}
drop_shadow = true
shadow_range = 4
@@ -98,7 +100,7 @@ gestures {
}
# Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
# See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more
device:epic-mouse-v1 {
sensitivity = -0.5
}

47
flake.lock generated
View File

@@ -4,14 +4,17 @@
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1681065697,
"narHash": "sha256-QPzwwlGKX95tl6ZEshboZbEwwAXww6lNLdVYd6T9Mrc=",
"lastModified": 1691753796,
"narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "4d29e48433270a2af06b8bc711ca1fe5109746cd",
"rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03",
"type": "github"
},
"original": {
@@ -22,11 +25,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1683014792,
"narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=",
"lastModified": 1692638711,
"narHash": "sha256-J0LgSFgJVGCC1+j5R2QndadWI1oumusg6hCtYAzLID4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42",
"rev": "91a22f76cd1716f9d0149e8a5c68424bb691de15",
"type": "github"
},
"original": {
@@ -40,25 +43,42 @@
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"nixpkgs": "nixpkgs",
"systems": "systems",
"wlroots": "wlroots",
"xdph": "xdph"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"wlroots": {
"flake": false,
"locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1682436395,
"narHash": "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=",
"lastModified": 1692976565,
"narHash": "sha256-eBKkG7tMxg92NskEn8dHRFY245JwjirWRoOZzW6DnUw=",
"owner": "wlroots",
"repo": "wlroots",
"rev": "6830bfc17fd94709e2cdd4da0af989f102a26e59",
"rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294",
"type": "gitlab"
},
"original": {
"host": "gitlab.freedesktop.org",
"owner": "wlroots",
"repo": "wlroots",
"rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294",
"type": "gitlab"
}
},
@@ -69,14 +89,17 @@
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1682439384,
"narHash": "sha256-zHDa8LCZs05TZHQSIZ3ucwyMPglBGHcqTBzfkLjYXTM=",
"lastModified": 1691841170,
"narHash": "sha256-RCTm1/MVWYPnReMgyp7tr2ogGYo/pvw38jZaFwemgPU=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "c0e233955568fbea4e859336f6d3d14d51294d7c",
"rev": "57a3a41ba6b358109e4fc25c6a4706b5f7d93c6b",
"type": "github"
},
"original": {

View File

@@ -4,19 +4,28 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux";
wlroots = {
url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org";
type = "gitlab";
host = "gitlab.freedesktop.org";
owner = "wlroots";
repo = "wlroots";
rev = "717ded9bb0191ea31bf4368be32e7a15fe1b8294";
flake = false;
};
hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
xdph = {
url = "github:hyprwm/xdg-desktop-portal-hyprland";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprland-protocols.follows = "hyprland-protocols";
};
};
@@ -24,38 +33,23 @@
outputs = inputs @ {
self,
nixpkgs,
systems,
...
}: let
lib = nixpkgs.lib.extend (import ./nix/lib.nix);
genSystems = lib.genAttrs [
# Add more systems if they are supported
"aarch64-linux"
"x86_64-linux"
];
pkgsFor = genSystems (system:
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
inherit system;
overlays = [
self.overlays.hyprland-packages
self.overlays.wlroots-hyprland
inputs.hyprland-protocols.overlays.default
localSystem = system;
overlays = with self.overlays; [
hyprland-packages
hyprland-extras
];
});
in {
overlays =
(import ./nix/overlays.nix {inherit self lib inputs;})
// {
default =
lib.mkJoinedOverlays
(with self.overlays; [
hyprland-packages
hyprland-extras
wlroots-hyprland
]);
};
overlays = import ./nix/overlays.nix {inherit self lib inputs;};
checks = genSystems (system:
checks = eachSystem (system:
(lib.filterAttrs
(n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n))
self.packages.${system})
@@ -63,16 +57,29 @@
inherit (self.packages.${system}) xdg-desktop-portal-hyprland;
});
packages = genSystems (system:
(self.overlays.default pkgsFor.${system} pkgsFor.${system})
// {
packages = eachSystem (system: {
default = self.packages.${system}.hyprland;
inherit
(pkgsFor.${system})
# hyprland-packages
hyprland
hyprland-unwrapped
hyprland-debug
hyprland-nvidia
# hyprland-extras
xdg-desktop-portal-hyprland
hyprland-share-picker
# dependencies
hyprland-protocols
wlroots-hyprland
udis86
;
});
devShells = genSystems (system: {
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [cmake];
nativeBuildInputs = with pkgsFor.${system}; [cmake python3];
buildInputs = [self.packages.${system}.wlroots-hyprland];
inputsFrom = [
self.packages.${system}.wlroots-hyprland
@@ -81,7 +88,7 @@
};
});
formatter = genSystems (system: pkgsFor.${system}.alejandra);
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
nixosModules.default = import ./nix/module.nix inputs;
homeManagerModules.default = import ./nix/hm-module.nix self;

View File

@@ -11,12 +11,16 @@
#include <unistd.h>
#include <ranges>
#include <algorithm>
#include <signal.h>
#include <iostream>
#include <string>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <filesystem>
#include <stdarg.h>
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
@@ -45,14 +49,77 @@ commands:
plugin
notify
globalshortcuts
instances
flags:
-j -> output in JSON
--batch -> execute a batch of commands, separated by ';'
--instance (-i) -> use a specific instance. Can be either signature or index in hyprctl instances (0, 1, etc)
)#";
#define PAD
std::string instanceSignature;
struct SInstanceData {
std::string id;
uint64_t time;
uint64_t pid;
std::string wlSocket;
bool valid = true;
};
std::vector<SInstanceData> instances() {
std::vector<SInstanceData> result;
for (const auto& el : std::filesystem::directory_iterator("/tmp/hypr")) {
if (el.is_directory())
continue;
// read lock
SInstanceData* data = &result.emplace_back();
data->id = el.path().string();
data->id = data->id.substr(data->id.find_last_of('/') + 1, data->id.find(".lock") - data->id.find_last_of('/') - 1);
data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1));
// read file
std::ifstream ifs(el.path().string());
int i = 0;
for (std::string line; std::getline(ifs, line); ++i) {
if (i == 0) {
data->pid = std::stoull(line);
} else if (i == 1) {
data->wlSocket = line;
} else
break;
}
ifs.close();
}
std::erase_if(result, [&](const auto& el) { return kill(el.pid, 0) != 0 && errno == ESRCH; });
std::sort(result.begin(), result.end(), [&](const auto& a, const auto& b) { return a.time < b.time; });
return result;
}
std::string getFormat(const char* fmt, ...) {
char* outputStr = nullptr;
va_list args;
va_start(args, fmt);
vasprintf(&outputStr, fmt, args);
va_end(args);
std::string output = std::string(outputStr);
free(outputStr);
return output;
}
void request(std::string arg, int minArgs = 0) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -68,20 +135,15 @@ void request(std::string arg, int minArgs = 0) {
return;
}
// get the instance signature
auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!instanceSig) {
if (instanceSignature.empty()) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)";
return;
}
std::string instanceSigStr = std::string(instanceSig);
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock";
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.socket.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
@@ -131,20 +193,15 @@ void requestHyprpaper(std::string arg) {
return;
}
// get the instance signature
auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!instanceSig) {
if (instanceSignature.empty()) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)";
return;
}
std::string instanceSigStr = std::string(instanceSig);
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.hyprpaper.sock";
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.hyprpaper.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
@@ -153,6 +210,9 @@ void requestHyprpaper(std::string arg) {
return;
}
arg = arg.substr(arg.find_first_of('/') + 1); // strip flags
arg = arg.substr(arg.find_first_of(' ') + 1); // strip "hyprpaper"
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length());
if (sizeWritten < 0) {
@@ -174,92 +234,42 @@ void requestHyprpaper(std::string arg) {
std::cout << std::string(buffer);
}
int dispatchRequest(int argc, char** argv) {
if (argc < 3) {
std::cout << "Usage: hyprctl dispatch <dispatcher> <arg>\n\
Execute a hyprland keybind dispatcher with the given argument";
return 1;
}
std::string rq = "/dispatch";
for (int i = 2; i < argc; i++) {
if (!strcmp(argv[i], "--"))
continue;
rq += " " + std::string(argv[i]);
}
request(rq);
return 0;
}
int keywordRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "Usage: hyprctl keyword <keyword> <arg>\n\
Execute a hyprland keyword with the given argument";
return 1;
}
std::string rq = "/keyword";
for (int i = 2; i < argc; i++)
rq += " " + std::string(argv[i]);
request(rq);
return 0;
}
int hyprpaperRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "Usage: hyprctl hyprpaper <command> <arg>\n\
Execute a hyprpaper command with the given argument";
return 1;
}
std::string rq = std::string(argv[2]) + " " + std::string(argv[3]);
requestHyprpaper(rq);
return 0;
}
int setcursorRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "Usage: hyprctl setcursor <theme> <size>\n\
Sets the cursor theme for everything except GTK and reloads the cursor";
return 1;
}
std::string rq = "setcursor ";
for (size_t i = 2; i < argc; ++i)
rq += std::string(argv[i]) + " ";
rq.pop_back();
request(rq);
return 0;
}
int outputRequest(int argc, char** argv) {
if (argc < 4) {
std::cout << "Usage: hyprctl output <mode> <name>\n\
creates / destroys a fake output\n\
with create, name is the backend name to use (available: auto, x11, wayland, headless)\n\
with destroy, name is the output name to destroy";
return 1;
}
std::string rq = "output " + std::string(argv[2]) + " " + std::string(argv[3]);
request(rq);
return 0;
}
void batchRequest(std::string arg) {
std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
request(rq);
}
void instancesRequest(bool json) {
std::string result = "";
// gather instance data
std::vector<SInstanceData> inst = instances();
if (!json) {
for (auto& el : inst) {
result += getFormat("instance %s:\n\ttime: %llu\n\tpid: %llu\n\twl socket: %s\n\n", el.id.c_str(), el.time, el.pid, el.wlSocket.c_str());
}
} else {
result += '[';
for (auto& el : inst) {
result += getFormat(R"#(
{
"instance": "%s",
"time": %llu,
"pid": %llu,
"wl_socket": "%s"
},)#",
el.id.c_str(), el.time, el.pid, el.wlSocket.c_str());
}
result.pop_back();
result += "\n]";
}
std::cout << result << "\n";
}
std::deque<std::string> splitArgs(int argc, char** argv) {
std::deque<std::string> result;
@@ -287,6 +297,8 @@ int main(int argc, char** argv) {
std::string fullRequest = "";
std::string fullArgs = "";
const auto ARGS = splitArgs(argc, argv);
bool json = false;
std::string overrideInstance = "";
for (auto i = 0; i < ARGS.size(); ++i) {
if (ARGS[i] == "--") {
@@ -298,8 +310,18 @@ int main(int argc, char** argv) {
// parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j";
json = true;
} else if (ARGS[i] == "--batch") {
fullRequest = "--batch ";
} else if (ARGS[i] == "--instance" || ARGS[i] == "-i") {
++i;
if (i >= ARGS.size()) {
printf("%s\n", USAGE.c_str());
return 1;
}
overrideInstance = ARGS[i];
} else {
printf("%s\n", USAGE.c_str());
return 1;
@@ -320,6 +342,35 @@ int main(int argc, char** argv) {
fullRequest = fullArgs + "/" + fullRequest;
if (overrideInstance.contains("_"))
instanceSignature = overrideInstance;
else if (!overrideInstance.empty()) {
if (!isNumber(overrideInstance, false)) {
std::cout << "instance invalid\n";
return 1;
}
const auto INSTANCENO = std::stoi(overrideInstance);
const auto INSTANCES = instances();
if (INSTANCENO < 0 || INSTANCENO >= INSTANCES.size()) {
std::cout << "no such instance\n";
return 1;
}
instanceSignature = INSTANCES[INSTANCENO].id;
} else {
const auto ISIG = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!ISIG) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE not set! (is hyprland running?)";
return 1;
}
instanceSignature = ISIG;
}
int exitStatus = 0;
if (fullRequest.contains("/--batch"))
@@ -356,6 +407,8 @@ int main(int argc, char** argv) {
request(fullRequest);
else if (fullRequest.contains("/globalshortcuts"))
request(fullRequest);
else if (fullRequest.contains("/instances"))
instancesRequest(json);
else if (fullRequest.contains("/switchxkblayout"))
request(fullRequest, 2);
else if (fullRequest.contains("/seterror"))
@@ -367,15 +420,15 @@ int main(int argc, char** argv) {
else if (fullRequest.contains("/notify"))
request(fullRequest, 2);
else if (fullRequest.contains("/output"))
exitStatus = outputRequest(argc, argv);
request(fullRequest, 2);
else if (fullRequest.contains("/setcursor"))
exitStatus = setcursorRequest(argc, argv);
request(fullRequest, 1);
else if (fullRequest.contains("/dispatch"))
exitStatus = dispatchRequest(argc, argv);
request(fullRequest, 1);
else if (fullRequest.contains("/keyword"))
exitStatus = keywordRequest(argc, argv);
request(fullRequest, 2);
else if (fullRequest.contains("/hyprpaper"))
exitStatus = hyprpaperRequest(argc, argv);
requestHyprpaper(fullRequest);
else if (fullRequest.contains("/--help"))
printf("%s", USAGE.c_str());
else {

View File

@@ -96,5 +96,5 @@ import('pkgconfig').generate(
url: 'https://github.com/hyprwm/Hyprland',
description: 'Hyprland header files',
install_dir: pkg_install_dir,
subdirs: ['', 'hyprland/protocols'],
subdirs: ['', 'hyprland/protocols', 'hyprland/wlroots'],
)

View File

@@ -2,8 +2,10 @@
lib,
stdenv,
pkg-config,
makeWrapper,
meson,
ninja,
binutils,
cairo,
git,
hyprland-protocols,
@@ -24,30 +26,28 @@
xcbutilwm,
xwayland,
debug ? false,
enableNvidiaPatches ? false,
enableXWayland ? true,
hidpiXWayland ? false,
legacyRenderer ? false,
nvidiaPatches ? false,
withSystemd ? true,
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
wrapRuntimeDeps ? true,
version ? "git",
commit,
}: let
assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) ''
Hyprland: cannot have hidpiXWayland when enableXWayland is false.
'';
in
assert assertXWayland;
# deprecated flags
nvidiaPatches ? false,
hidpiXWayland ? false,
}:
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been renamed `enableNvidiaPatches`";
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug";
pname = "hyprland${lib.optionalString enableNvidiaPatches "-nvidia"}${lib.optionalString debug "-debug"}";
inherit version;
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (
lib.hasSuffix ".nix" baseName
);
! (lib.hasSuffix ".nix" baseName);
src = lib.cleanSource ../.;
};
@@ -56,6 +56,8 @@ in
meson
ninja
pkg-config
makeWrapper
wayland-scanner
];
outputs = [
@@ -77,9 +79,8 @@ in
udis86
wayland
wayland-protocols
wayland-scanner
pciutils
(wlroots.override {inherit enableXWayland hidpiXWayland nvidiaPatches;})
(wlroots.override {inherit enableNvidiaPatches;})
]
++ lib.optionals enableXWayland [libxcb xcbutilwm xwayland]
++ lib.optionals withSystemd [systemd];
@@ -98,7 +99,7 @@ in
patches = [
# make meson use the provided wlroots instead of the git submodule
./meson-build.patch
./patches/meson-build.patch
];
postPatch = ''
@@ -113,6 +114,14 @@ in
}'
'';
postInstall = ''
ln -s ${wlroots}/include/wlr $dev/include/hyprland/wlroots
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [binutils pciutils]}
''}
'';
passthru.providedSessions = ["hyprland"];
meta = with lib; {

View File

@@ -7,10 +7,11 @@ self: {
cfg = config.wayland.windowManager.hyprland;
defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
inherit (cfg) nvidiaPatches;
inherit (cfg) enableNvidiaPatches;
};
in {
disabledModules = ["services/window-managers/hyprland.nix"];
meta.maintainers = [lib.maintainers.fufexan];
options.wayland.windowManager.hyprland = {
@@ -34,13 +35,12 @@ in {
defaultText = lib.literalExpression ''
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = config.wayland.windowManager.hyprland.xwayland.enable;
hidpiXWayland = config.wayland.windowManager.hyprland.xwayland.hidpi;
inherit (config.wayland.windowManager.hyprland) nvidiaPatches;
inherit (config.wayland.windowManager.hyprland) enableNvidiaPatches;
}
'';
description = lib.mdDoc ''
Hyprland package to use. Will override the 'xwayland' and
'nvidiaPatches' options.
'enableNvidiaPatches' options.
Defaults to the one provided by the flake. Set it to
{package}`pkgs.hyprland` to use the one provided by nixpkgs or
@@ -55,7 +55,7 @@ in {
type = with lib.types; listOf (either package path);
default = [];
description = lib.mdDoc ''
List of hyprlad plugins to use. Can either be packages or
List of Hyprland plugins to use. Can either be packages or
absolute plugin paths.
'';
};
@@ -65,7 +65,7 @@ in {
default = pkgs.stdenv.isLinux;
description = lib.mdDoc ''
Whether to enable {file}`hyprland-session.target` on
hyprland startup. This links to {file}`graphical-session.target`.
Hyprland startup. This links to {file}`graphical-session.target`.
Some important environment variables will be imported to systemd
and dbus user environment before reaching the target, including
- {env}`DISPLAY`
@@ -84,19 +84,9 @@ in {
'';
};
xwayland = {
enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
hidpi =
lib.mkEnableOption null
// {
description = lib.mdDoc ''
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
'';
};
};
xwayland.enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
nvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
enableNvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
extraConfig = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
@@ -117,10 +107,14 @@ in {
config = lib.mkIf cfg.enable {
warnings =
if (cfg.systemdIntegration || cfg.plugins != []) && cfg.extraConfig == null then
[ ''You have enabled hyprland.systemdIntegration or listed plugins in hyprland.plugins.
Your hyprland config will be linked by home manager.
Set hyprland.extraConfig or unset hyprland.systemdIntegration and hyprland.plugins to remove this warning.'' ]
if (cfg.systemdIntegration || cfg.plugins != []) && cfg.extraConfig == null
then [
''
You have enabled hyprland.systemdIntegration or listed plugins in hyprland.plugins.
Your Hyprland config will be linked by home manager.
Set hyprland.extraConfig or unset hyprland.systemdIntegration and hyprland.plugins to remove this warning.
''
]
else [];
home.packages =
@@ -136,9 +130,17 @@ in {
exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP && systemctl --user start hyprland-session.target
'')
+ lib.concatStrings (builtins.map (entry: let
plugin = if lib.types.package.check entry then "${entry}/lib/lib${entry.pname}.so" else entry;
in "plugin = ${plugin}\n") cfg.plugins)
+ (if cfg.extraConfig != null then cfg.extraConfig else "");
plugin =
if lib.types.package.check entry
then "${entry}/lib/lib${entry.pname}.so"
else entry;
in "plugin = ${plugin}\n")
cfg.plugins)
+ (
if cfg.extraConfig != null
then cfg.extraConfig
else ""
);
onChange = let
hyprlandPackage =
@@ -159,7 +161,7 @@ in {
systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
Unit = {
Description = "hyprland compositor session";
Description = "Hyprland compositor session";
Documentation = ["man:systemd.special(7)"];
BindsTo = ["graphical-session.target"];
Wants = ["graphical-session-pre.target"];
@@ -167,4 +169,9 @@ in {
};
};
};
imports = [
(lib.mkRemovedOptionModule ["wayland" "windowManager" "hyprland" "xwayland" "hidpi"]
"Support for this option has been removed. Refer to https://wiki.hyprland.org/Configuring/XWayland for more info")
];
}

View File

@@ -1,8 +0,0 @@
final: prev: let
lib = final;
mkJoinedOverlays = overlays: final: prev:
lib.foldl' (attrs: overlay: attrs // (overlay final prev)) {} overlays;
in prev // {
inherit mkJoinedOverlays;
}

View File

@@ -2,15 +2,17 @@ inputs: {
config,
lib,
pkgs,
options,
...
}:
with lib; let
cfg = config.programs.hyprland;
inherit (pkgs.stdenv.hostPlatform) system;
defaultHyprlandPackage = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
inherit (cfg) nvidiaPatches;
finalPortalPackage = cfg.portalPackage.override {
hyprland-share-picker = inputs.xdph.packages.${system}.hyprland-share-picker.override {
hyprland = cfg.finalPackage;
};
};
in {
# disables Nixpkgs Hyprland module to avoid conflicts
@@ -30,69 +32,70 @@ in {
'';
};
package = mkOption {
type = types.path;
default = defaultHyprlandPackage;
defaultText = literalExpression ''
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = config.programs.hyprland.xwayland.enable;
hidpiXWayland = config.programs.hyprland.xwayland.hidpi;
inherit (config.programs.hyprland) nvidiaPatches;
}
'';
example = literalExpression "pkgs.hyprland";
package = mkPackageOptionMD inputs.self.packages.${system} "hyprland" { };
finalPackage = mkOption {
type = types.package;
readOnly = true;
default = cfg.package.override {
enableXWayland = cfg.xwayland.enable;
enableNvidiaPatches = cfg.enableNvidiaPatches;
};
defaultText =
literalExpression
"`programs.hyprland.package` with applied configuration";
description = mdDoc ''
The Hyprland package to use.
Setting this option will make {option}`programs.hyprland.xwayland` and
{option}`programs.hyprland.nvidiaPatches` not work.
The Hyprland package after applying configuration.
'';
};
xwayland = {
enable = mkEnableOption (mdDoc "XWayland") // {default = true;};
hidpi =
portalPackage = mkPackageOptionMD inputs.xdph.packages.${system} "xdg-desktop-portal-hyprland" {};
xwayland.enable = mkEnableOption (mdDoc "support for XWayland") // {default = true;};
enableNvidiaPatches =
mkEnableOption null
// {
description = mdDoc ''
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
'';
description = mdDoc "Whether to apply patches to wlroots for better Nvidia support.";
};
};
nvidiaPatches = mkEnableOption (mdDoc "patching wlroots for better Nvidia support");
};
config = mkIf cfg.enable {
environment = {
systemPackages = [cfg.package];
environment.systemPackages = [cfg.finalPackage];
sessionVariables = {
NIXOS_OZONE_WL = mkDefault "1";
};
};
# NixOS changed the name of this attribute between NixOS 23.05 and
# 23.11
fonts = if builtins.hasAttr "enableDefaultPackages" options.fonts
then {enableDefaultPackages = mkDefault true;}
else {enableDefaultFonts = mkDefault true;};
fonts.enableDefaultFonts = mkDefault true;
hardware.opengl.enable = mkDefault true;
programs = {
dconf.enable = mkDefault true;
xwayland.enable = mkDefault true;
xwayland.enable = mkDefault cfg.xwayland.enable;
};
security.polkit.enable = true;
services.xserver.displayManager.sessionPackages = [cfg.package];
services.xserver.displayManager.sessionPackages = [cfg.finalPackage];
xdg.portal = {
enable = mkDefault true;
extraPortals = lib.mkIf (cfg.package != null) [
(inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland.override {
hyprland-share-picker = inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.hyprland-share-picker.override {
hyprland = cfg.package;
extraPortals = [finalPortalPackage];
};
})
};
imports = with lib; [
(
mkRemovedOptionModule
["programs" "hyprland" "xwayland" "hidpi"]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
)
(
mkRenamedOptionModule
["programs" "hyprland" "nvidiaPatches"]
["programs" "hyprland" "enableNvidiaPatches"]
)
];
};
};
}

View File

@@ -10,66 +10,62 @@
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
mkJoinedOverlays = overlays: final: prev:
lib.foldl' (attrs: overlay: attrs // (overlay final prev)) {} overlays;
in {
# Packages for variations of Hyprland, and its dependencies.
hyprland-packages = final: prev: {
# Contains what a user is most likely to care about:
# Hyprland itself, XDPH and the Share Picker.
default = mkJoinedOverlays (with self.overlays; [
hyprland-packages
hyprland-extras
]);
# Packages for variations of Hyprland, dependencies included.
hyprland-packages = mkJoinedOverlays [
# Dependencies
inputs.hyprland-protocols.overlays.default
self.overlays.wlroots-hyprland
self.overlays.udis86
# Hyprland packages themselves
(final: prev: {
hyprland = final.callPackage ./default.nix {
version =
props.version
+ "+date="
+ (mkDate (self.lastModifiedDate or "19700101"))
+ "_"
+ (self.shortRev or "dirty");
version = "${props.version}+date=${mkDate (self.lastModifiedDate or "19700101")}_${self.shortRev or "dirty"}";
wlroots = final.wlroots-hyprland;
commit = self.rev or "";
inherit (final) udis86 hyprland-protocols;
};
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprland-debug = final.hyprland.override {debug = true;};
hyprland-hidpi = final.hyprland.override {hidpiXWayland = true;};
hyprland-nvidia = final.hyprland.override {nvidiaPatches = true;};
hyprland-no-hidpi =
builtins.trace
"hyprland-no-hidpi was removed. Please use the default package."
hyprland-nvidia = final.hyprland.override {enableNvidiaPatches = true;};
hyprland-hidpi =
builtins.trace ''
hyprland-hidpi was removed. Please use the hyprland package.
For more information, refer to https://wiki.hyprland.org/Configuring/XWayland.
''
final.hyprland;
udis86 = final.callPackage ./udis86.nix {};
};
})
];
# Packages for extra software recommended for usage with Hyprland,
# including forked or patched packages for compatibility.
hyprland-extras = lib.mkJoinedOverlays [
# Include any inputs' specific overlays whose attributes should
# be re-exported by the Hyprland flake.
#
inputs.xdph.overlays.default
# Provides:
# - xdg-desktop-portal-hyprland
# - hyprland-share-picker
#
# Attributes for `hyprland-extras` defined by this flake can
# go in the oberlay below.
(final: prev: {
waybar-hyprland = prev.waybar.overrideAttrs (old: {
postPatch = ''
# use hyprctl to switch workspaces
sed -i 's/zext_workspace_handle_v1_activate(workspace_handle_);/const std::string command = "hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());/g' src/modules/wlr/workspace_manager.cpp
'';
mesonFlags = old.mesonFlags ++ ["-Dexperimental=true"];
});
})
hyprland-extras = mkJoinedOverlays [
inputs.xdph.overlays.xdg-desktop-portal-hyprland
inputs.xdph.overlays.hyprland-share-picker
];
udis86 = final: prev: {
udis86 = final.callPackage ./udis86.nix {};
};
# Patched version of wlroots for Hyprland.
# It is under a new package name so as to not conflict with
# the standard version in nixpkgs.
wlroots-hyprland = final: prev: {
wlroots-hyprland = final.callPackage ./wlroots.nix {
version =
mkDate (inputs.wlroots.lastModifiedDate or "19700101")
+ "_"
+ (inputs.wlroots.shortRev or "dirty");
version = "${mkDate (inputs.wlroots.lastModifiedDate or "19700101")}_${inputs.wlroots.shortRev or "dirty"}";
src = inputs.wlroots;
libdisplay-info = prev.libdisplay-info.overrideAttrs (old: {
version = "0.1.1+date=2023-03-02";
src = final.fetchFromGitLab {
@@ -80,6 +76,7 @@ in {
sha256 = "sha256-/q79o13Zvu7x02SBGu0W5yQznQ+p7ltZ9L6cMW5t/o4=";
};
});
libliftoff = prev.libliftoff.overrideAttrs (old: {
version = "0.5.0-dev";
src = final.fetchFromGitLab {

View File

@@ -0,0 +1,41 @@
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 9fe934f7..9662d4ee 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -176,7 +176,7 @@ static bool gles2_bind_buffer(struct wlr_renderer *wlr_renderer,
assert(wlr_egl_is_current(renderer->egl));
push_gles2_debug(renderer);
- glFlush();
+ glFinish();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
pop_gles2_debug(renderer);
diff --git a/types/output/render.c b/types/output/render.c
index 2e38919a..97f78608 100644
--- a/types/output/render.c
+++ b/types/output/render.c
@@ -240,22 +240,7 @@ bool output_pick_format(struct wlr_output *output,
}
uint32_t wlr_output_preferred_read_format(struct wlr_output *output) {
- struct wlr_renderer *renderer = output->renderer;
- assert(renderer != NULL);
-
- if (!renderer->impl->preferred_read_format || !renderer->impl->read_pixels) {
- return DRM_FORMAT_INVALID;
- }
-
- if (!wlr_output_attach_render(output, NULL)) {
- return false;
- }
-
- uint32_t fmt = renderer->impl->preferred_read_format(renderer);
-
- output_clear_back_buffer(output);
-
- return fmt;
+ return DRM_FORMAT_XRGB8888;
}
struct wlr_render_pass *wlr_output_begin_render_pass(struct wlr_output *output,

View File

@@ -1,21 +1,19 @@
#!/usr/bin/env -S nix shell nixpkgs#gawk nixpkgs#git nixpkgs#moreutils nixpkgs#jq nixpkgs#ripgrep -c bash
#!/usr/bin/env -S nix shell nixpkgs#jq -c bash
set -ex
# Update inputs when the Mesa version is outdated. We don't want
# incompatibilities between the user's system and Hyprland.
# get wlroots revision from submodule
SUB_REV=$(git submodule status | rg wlroots | awk '{ print substr($1,2)}')
# and from lockfile
CRT_REV=$(jq <flake.lock '.nodes.wlroots.locked.rev' -r)
# get the current Nixpkgs revision
REV=$(jq <flake.lock '.nodes.nixpkgs.locked.rev' -r)
# check versions for current and remote nixpkgs' mesa
CRT_VER=$(nix eval --raw github:nixos/nixpkgs/"$REV"#mesa.version)
NEW_VER=$(nix eval --raw github:nixos/nixpkgs/nixos-unstable#mesa.version)
if [ "$CRT_VER" != "$NEW_VER" ]; then
echo "Updating Mesa $CRT_VER -> $NEW_VER and flake inputs"
if [ "$SUB_REV" != "$CRT_REV" ]; then
# update inputs to latest versions
nix flake update
# update wlroots to submodule revision
nix flake lock --override-input wlroots "gitlab:wlroots/wlroots/$SUB_REV?host=gitlab.freedesktop.org"
# remove "dirty" mark from lockfile
jq <flake.lock 'del(.nodes.wlroots.original.rev)' | sponge flake.lock
else
echo "wlroots is up to date!"
echo "nixpkgs is up to date!"
fi

17
nix/update-wlroots.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env -S nix shell nixpkgs#gawk nixpkgs#git nixpkgs#gnused nixpkgs#ripgrep -c bash
# get wlroots revision from submodule
SUB_REV=$(git submodule status | rg wlroots | awk '{ print substr($1,2) }')
# and from lockfile
CRT_REV=$(rg rev flake.nix | awk '{ print substr($3, 2, 40) }')
if [ "$SUB_REV" != "$CRT_REV" ]; then
echo "Updating wlroots..."
# update wlroots to submodule revision
sed -Ei "s/\w{40}/$SUB_REV/g" flake.nix subprojects/wlroots.wrap
nix flake lock
echo "wlroots: $CRT_REV -> $SUB_REV"
else
echo "wlroots is up to date!"
fi

View File

@@ -1,76 +1,28 @@
{
lib,
version,
src,
#
wlroots,
xwayland,
fetchpatch,
lib,
hwdata,
libliftoff,
libdisplay-info,
hidpiXWayland ? true,
libliftoff,
enableXWayland ? true,
nvidiaPatches ? false,
enableNvidiaPatches ? 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 ""
);
wlroots.overrideAttrs (old: {
inherit version src enableXWayland;
pname = "${old.pname}-hyprland${lib.optionalString enableNvidiaPatches "-nvidia"}";
patches =
(old.patches or [])
++ (lib.optionals (enableXWayland && hidpiXWayland) [
# adapted from https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7
./wlroots-hidpi.patch
(fetchpatch {
url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff";
sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI=";
revert = true;
})
])
++ (lib.optionals nvidiaPatches [
(fetchpatch {
url = "https://aur.archlinux.org/cgit/aur.git/plain/0001-nvidia-format-workaround.patch?h=hyprland-nvidia-screenshare-git";
sha256 = "A9f1p5EW++mGCaNq8w7ZJfeWmvTfUm4iO+1KDcnqYX8=";
})
++ (lib.optionals enableNvidiaPatches [
./patches/wlroots-nvidia.patch
]);
postPatch =
(old.postPatch or "")
+ (
if nvidiaPatches
then ''
substituteInPlace render/gles2/renderer.c --replace "glFlush();" "glFinish();"
''
else ""
);
buildInputs = old.buildInputs ++ [hwdata libliftoff libdisplay-info];
NIX_CFLAGS_COMPILE = toString [
"-Wno-error=maybe-uninitialized"
];
}))
.override {
xwayland = xwayland.overrideAttrs (old: {
patches =
(old.patches or [])
++ (lib.optionals hidpiXWayland [
./xwayland-vsync.patch
./xwayland-hidpi.patch
]);
});
}
})

View File

@@ -1,3 +1,3 @@
{
"version": "0.25.0"
"version": "0.29.0"
}

View File

@@ -22,7 +22,9 @@ protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],

View File

@@ -1,6 +1,7 @@
#include "Compositor.hpp"
#include "helpers/Splashes.hpp"
#include <random>
#include <unordered_set>
#include "debug/HyprCtl.hpp"
#include "debug/CrashReporter.hpp"
#ifdef USES_SYSTEMD
@@ -11,11 +12,10 @@
int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal %d", signo);
if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL) {
if (signo == SIGTERM || signo == SIGINT || signo == SIGKILL)
g_pCompositor->cleanup();
}
return 0; // everything went fine
return 0;
}
void handleUnrecoverableSignal(int sig) {
@@ -98,6 +98,9 @@ void CCompositor::initServer() {
initManagers(STAGE_PRIORITY);
if (const auto ENV = getenv("HYPRLAND_TRACE"); ENV && std::string(ENV) == "1")
Debug::trace = true;
wlr_log_init(WLR_INFO, NULL);
const auto LOGWLR = getenv("HYPRLAND_LOG_WLR");
@@ -108,20 +111,20 @@ void CCompositor::initServer() {
if (!m_sWLRBackend) {
Debug::log(CRIT, "m_sWLRBackend was NULL!");
throw std::runtime_error("wlr_backend_autocreate() failed!");
throwError("wlr_backend_autocreate() failed!");
}
m_iDRMFD = wlr_backend_get_drm_fd(m_sWLRBackend);
if (m_iDRMFD < 0) {
Debug::log(CRIT, "Couldn't query the DRM FD!");
throw std::runtime_error("wlr_backend_get_drm_fd() failed!");
throwError("wlr_backend_get_drm_fd() failed!");
}
m_sWLRRenderer = wlr_gles2_renderer_create_with_drm_fd(m_iDRMFD);
if (!m_sWLRRenderer) {
Debug::log(CRIT, "m_sWLRRenderer was NULL!");
throw std::runtime_error("wlr_gles2_renderer_create_with_drm_fd() failed!");
throwError("wlr_gles2_renderer_create_with_drm_fd() failed!");
}
wlr_renderer_init_wl_shm(m_sWLRRenderer, m_sWLDisplay);
@@ -137,14 +140,14 @@ void CCompositor::initServer() {
if (!m_sWLRAllocator) {
Debug::log(CRIT, "m_sWLRAllocator was NULL!");
throw std::runtime_error("wlr_allocator_autocreate() failed!");
throwError("wlr_allocator_autocreate() failed!");
}
m_sWLREGL = wlr_gles2_renderer_get_egl(m_sWLRRenderer);
if (!m_sWLREGL) {
Debug::log(CRIT, "m_sWLREGL was NULL!");
throw std::runtime_error("wlr_gles2_renderer_get_egl() failed!");
throwError("wlr_gles2_renderer_get_egl() failed!");
}
m_sWLRCompositor = wlr_compositor_create(m_sWLDisplay, 6, m_sWLRRenderer);
@@ -153,10 +156,11 @@ void CCompositor::initServer() {
wlr_export_dmabuf_manager_v1_create(m_sWLDisplay);
wlr_data_control_manager_v1_create(m_sWLDisplay);
wlr_gamma_control_manager_v1_create(m_sWLDisplay);
wlr_primary_selection_v1_device_manager_create(m_sWLDisplay);
wlr_viewporter_create(m_sWLDisplay);
m_sWLRGammaCtrlMgr = wlr_gamma_control_manager_v1_create(m_sWLDisplay);
m_sWLROutputLayout = wlr_output_layout_create();
m_sWLROutputPowerMgr = wlr_output_power_manager_v1_create(m_sWLDisplay);
@@ -186,6 +190,7 @@ void CCompositor::initServer() {
m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend);
m_sWLRIdle = wlr_idle_create(m_sWLDisplay);
m_sWLRIdleNotifier = wlr_idle_notifier_v1_create(m_sWLDisplay);
m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);
@@ -193,7 +198,6 @@ void CCompositor::initServer() {
m_sWLRXDGDecoMgr = wlr_xdg_decoration_manager_v1_create(m_sWLDisplay);
wlr_server_decoration_manager_set_default_mode(m_sWLRServerDecoMgr, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
wlr_xdg_output_manager_v1_create(m_sWLDisplay, m_sWLROutputLayout);
m_sWLROutputMgr = wlr_output_manager_v1_create(m_sWLDisplay);
m_sWLRInhibitMgr = wlr_input_inhibit_manager_create(m_sWLDisplay);
@@ -238,9 +242,11 @@ void CCompositor::initServer() {
m_sWLRSessionLockMgr = wlr_session_lock_manager_v1_create(m_sWLDisplay);
m_sWLRCursorShapeMgr = wlr_cursor_shape_manager_v1_create(m_sWLDisplay, 1);
if (!m_sWLRHeadlessBackend) {
Debug::log(CRIT, "Couldn't create the headless backend");
throw std::runtime_error("wlr_headless_backend_create() failed!");
throwError("wlr_headless_backend_create() failed!");
}
wlr_single_pixel_buffer_manager_v1_create(m_sWLDisplay);
@@ -294,6 +300,8 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr");
addWLSignal(&m_sWLRActivation->events.request_activate, &Events::listen_activateXDG, m_sWLRActivation, "ActivationV1");
addWLSignal(&m_sWLRSessionLockMgr->events.new_lock, &Events::listen_newSessionLock, m_sWLRSessionLockMgr, "SessionLockMgr");
addWLSignal(&m_sWLRGammaCtrlMgr->events.set_gamma, &Events::listen_setGamma, m_sWLRGammaCtrlMgr, "GammaCtrlMgr");
addWLSignal(&m_sWLRCursorShapeMgr->events.request_set_shape, &Events::listen_setCursorShape, m_sWLRCursorShapeMgr, "CursorShapeMgr");
if (m_sWRLDRMLeaseMgr)
addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM");
@@ -306,8 +314,15 @@ void CCompositor::cleanup() {
if (!m_sWLDisplay || m_bIsShuttingDown)
return;
removeLockFile();
m_bIsShuttingDown = true;
#ifdef USES_SYSTEMD
if (sd_booted() > 0)
sd_notify(0, "STOPPING=1");
#endif
// unload all remaining plugins while the compositor is
// still in a normal working state.
g_pPluginSystem->unloadAllPlugins();
@@ -405,6 +420,23 @@ void CCompositor::initManagers(eManagersInitStage stage) {
}
}
void CCompositor::createLockFile() {
const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
std::ofstream ofs(PATH, std::ios::trunc);
ofs << m_iHyprlandPID << "\n" << m_szWLDisplaySocket << "\n";
ofs.close();
}
void CCompositor::removeLockFile() {
const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
if (std::filesystem::exists(PATH))
std::filesystem::remove(PATH);
}
void CCompositor::startCompositor() {
initAllSignals();
@@ -431,7 +463,7 @@ void CCompositor::startCompositor() {
if (m_szWLDisplaySocket.empty()) {
Debug::log(CRIT, "m_szWLDisplaySocket NULL!");
wlr_backend_destroy(m_sWLRBackend);
throw std::runtime_error("m_szWLDisplaySocket was null! (wl_display_add_socket and wl_display_add_socket_auto failed)");
throwError("m_szWLDisplaySocket was null! (wl_display_add_socket and wl_display_add_socket_auto failed)");
}
setenv("WAYLAND_DISPLAY", m_szWLDisplaySocket.c_str(), 1);
@@ -453,10 +485,10 @@ void CCompositor::startCompositor() {
Debug::log(CRIT, "Backend did not start!");
wlr_backend_destroy(m_sWLRBackend);
wl_display_destroy(m_sWLDisplay);
throw std::runtime_error("The backend could not start!");
throwError("The backend could not start!");
}
wlr_xcursor_manager_set_cursor_image(m_sWLRXCursorMgr, "left_ptr", m_sWLRCursor);
wlr_cursor_set_xcursor(m_sWLRCursor, m_sWLRXCursorMgr, "left_ptr");
#ifdef USES_SYSTEMD
if (sd_booted() > 0)
@@ -466,6 +498,8 @@ void CCompositor::startCompositor() {
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
#endif
createLockFile();
// This blocks until we are done.
Debug::log(LOG, "Hyprland is ready, running the event loop!");
wl_display_run(m_sWLDisplay);
@@ -487,7 +521,14 @@ CMonitor* CCompositor::getMonitorFromName(const std::string& name) {
return m.get();
}
}
return nullptr;
}
CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) {
for (auto& m : m_vMonitors) {
if (m->output->description && std::string(m->output->description).find(desc) == 0)
return m.get();
}
return nullptr;
}
@@ -793,6 +834,11 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
return;
}
if (pWindow && pWindow->isHidden() && pWindow->m_sGroupData.pNextWindow) {
// grouped, change the current to us
pWindow->setGroupCurrent(pWindow);
}
if (!pWindow || !windowValidMapped(pWindow)) {
const auto PLASTWINDOW = m_pLastWindow;
m_pLastWindow = nullptr;
@@ -864,10 +910,6 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
g_pXWaylandManager->activateWindow(pWindow, true); // sets the m_pLastWindow
// do pointer focus too
const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition.goalv();
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y);
updateWindowAnimatedDecorationValues(pWindow);
// Handle urgency hint on the workspace
@@ -889,6 +931,16 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
g_pLayoutManager->getCurrentLayout()->onWindowFocusChange(pWindow);
// TODO: implement this better
if (!PLASTWINDOW && pWindow->m_sGroupData.pNextWindow && pWindow->m_sGroupData.pNextWindow != pWindow) {
auto curr = pWindow;
do {
curr = curr->m_sGroupData.pNextWindow;
if (curr->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_activated(curr->m_phForeignToplevel, false);
} while (curr->m_sGroupData.pNextWindow != pWindow);
}
if (pWindow->m_phForeignToplevel)
wlr_foreign_toplevel_handle_v1_set_activated(pWindow->m_phForeignToplevel, true);
@@ -990,7 +1042,7 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords,
SLayerSurface** ppLayerSurfaceFound) {
for (auto& ls : *layerSurfaces | std::views::reverse) {
if (ls->fadingOut || !ls->layerSurface || (ls->layerSurface && !ls->layerSurface->mapped) || ls->alpha.fl() == 0.f)
if (ls->fadingOut || !ls->layerSurface || (ls->layerSurface && !ls->layerSurface->surface->mapped) || ls->alpha.fl() == 0.f)
continue;
auto SURFACEAT = wlr_layer_surface_v1_surface_at(ls->layerSurface, pos.x - ls->geometry.x, pos.y - ls->geometry.y, &sCoords->x, &sCoords->y);
@@ -1068,7 +1120,7 @@ bool CCompositor::isWorkspaceVisible(const int& w) {
if (m->activeWorkspace == w)
return true;
if (m->specialWorkspaceID && isWorkspaceSpecial(w))
if (m->specialWorkspaceID == w)
return true;
}
@@ -1093,14 +1145,20 @@ void CCompositor::sanityCheckWorkspaces() {
const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace((*it)->m_iID);
if ((*it)->m_bIsSpecialWorkspace && WINDOWSONWORKSPACE == 0) {
getMonitorFromID((*it)->m_iMonitorID)->setSpecialWorkspace(nullptr);
if ((WINDOWSONWORKSPACE == 0 && !isWorkspaceVisible((*it)->m_iID))) {
it = m_vWorkspaces.erase(it);
if ((*it)->m_bIsSpecialWorkspace) {
if ((*it)->m_fAlpha.fl() > 0.f /* don't abruptly end the fadeout */) {
++it;
continue;
}
if ((WINDOWSONWORKSPACE == 0 && !isWorkspaceVisible((*it)->m_iID))) {
const auto PMONITOR = getMonitorFromID((*it)->m_iMonitorID);
if (PMONITOR && PMONITOR->specialWorkspaceID == (*it)->m_iID)
PMONITOR->setSpecialWorkspace(nullptr);
}
it = m_vWorkspaces.erase(it);
continue;
}
@@ -1146,6 +1204,26 @@ CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
return nullptr;
}
CWindow* CCompositor::getTopLeftWindowOnWorkspace(const int& id) {
const auto PWORKSPACE = getWorkspaceByID(id);
if (!PWORKSPACE)
return nullptr;
const auto PMONITOR = getMonitorFromID(PWORKSPACE->m_iMonitorID);
for (auto& w : m_vWindows) {
if (w->m_iWorkspaceID != id || !w->m_bIsMapped || w->isHidden())
continue;
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
if (WINDOWIDEALBB.x <= PMONITOR->vecPosition.x + 1 && WINDOWIDEALBB.y <= PMONITOR->vecPosition.y + 1)
return w.get();
}
return nullptr;
}
bool CCompositor::doesSeatAcceptInput(wlr_surface* surface) {
if (g_pSessionLockManager->isSessionLocked()) {
if (g_pSessionLockManager->isSurfaceSessionLock(surface))
@@ -1490,6 +1568,15 @@ CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
return nullptr;
}
CWorkspace* CCompositor::getWorkspaceByWorkspaceHandle(const wlr_ext_workspace_handle_v1* handle) {
for (auto& ws : m_vWorkspaces) {
if (ws->m_pWlrHandle == handle)
return ws.get();
}
return nullptr;
}
bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
for (auto& m : m_vMonitors) {
if (VECINRECT(point, m->vecPosition.x, m->vecPosition.y, m->vecSize.x + m->vecPosition.x, m->vecSize.y + m->vecPosition.y))
@@ -1605,12 +1692,15 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
static auto* const INACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.inactive_border")->data.get();
static auto* const GROUPACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border_active")->data.get();
static auto* const GROUPINACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border")->data.get();
static auto* const GROUPACTIVELOCKEDCOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border_locked_active")->data.get();
static auto* const GROUPINACTIVELOCKEDCOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border_locked")->data.get();
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;
static auto* const PDIMENABLED = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
auto setBorderColor = [&](CGradientValueData grad) -> void {
if (grad == pWindow->m_cRealBorderColor)
@@ -1627,13 +1717,14 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
if (RENDERDATA.isBorderGradient)
setBorderColor(*RENDERDATA.borderGradient);
else {
const bool GROUPLOCKED = pWindow->m_sGroupData.pNextWindow ? pWindow->getGroupHead()->m_sGroupData.locked : false;
if (pWindow == m_pLastWindow) {
const auto* const ACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? ACTIVECOL : GROUPACTIVECOL;
const auto* const ACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? ACTIVECOL : (GROUPLOCKED ? GROUPACTIVELOCKEDCOL : GROUPACTIVECOL);
setBorderColor(pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying())) :
*ACTIVECOLOR);
} else {
const auto* const INACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? INACTIVECOL : GROUPINACTIVECOL;
const auto* const INACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? INACTIVECOL : (GROUPLOCKED ? GROUPINACTIVELOCKEDCOL : GROUPINACTIVECOL);
setBorderColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying())) :
*INACTIVECOLOR);
@@ -1660,7 +1751,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
}
// dim
if (pWindow == m_pLastWindow) {
if (pWindow == m_pLastWindow || pWindow->m_sAdditionalConfigData.forceNoDim || !*PDIMENABLED) {
pWindow->m_fDimPercent = 0;
} else {
pWindow->m_fDimPercent = *PDIMSTRENGTH;
@@ -1681,14 +1772,23 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
d->updateWindow(pWindow);
}
int CCompositor::getNextAvailableMonitorID() {
int64_t topID = -1;
for (auto& m : m_vRealMonitors) {
if ((int64_t)m->ID > topID)
topID = m->ID;
int CCompositor::getNextAvailableMonitorID(std::string const& name) {
// reuse ID if it's already in the map, and the monitor with that ID is not being used by another monitor
if (m_mMonitorIDMap.contains(name) && !std::any_of(m_vRealMonitors.begin(), m_vRealMonitors.end(), [&](auto m) { return m->ID == m_mMonitorIDMap[name]; }))
return m_mMonitorIDMap[name];
// otherwise, find minimum available ID that is not in the map
std::unordered_set<uint64_t> usedIDs;
for (auto const& monitor : m_vRealMonitors) {
usedIDs.insert(monitor->ID);
}
return topID + 1;
uint64_t nextID = 0;
while (usedIDs.count(nextID) > 0) {
nextID++;
}
m_mMonitorIDMap[name] = nextID;
return nextID;
}
void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) {
@@ -1755,7 +1855,7 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
updateFullscreenFadeOnWorkspace(PWORKSPACEB);
updateFullscreenFadeOnWorkspace(PWORKSPACEA);
g_pInputManager->refocus();
g_pInputManager->simulateMouseMovement();
// event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", PWORKSPACEA->m_szName + "," + pMonitorB->szName});
@@ -1863,7 +1963,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
const auto POLDMON = getMonitorFromID(pWorkspace->m_iMonitorID);
const bool SWITCHINGISACTIVE = POLDMON->activeWorkspace == pWorkspace->m_iID;
const bool SWITCHINGISACTIVE = POLDMON ? POLDMON->activeWorkspace == pWorkspace->m_iID : false;
// fix old mon
int nextWorkspaceOnMonitorID = -1;
@@ -1910,6 +2010,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
// additionally, move floating and fs windows manually
if (w->m_bIsMapped && !w->isHidden()) {
if (POLDMON) {
if (w->m_bIsFloating)
w->m_vRealPosition = w->m_vRealPosition.vec() - POLDMON->vecPosition + pMonitor->vecPosition;
@@ -1917,6 +2018,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
w->m_vRealPosition = pMonitor->vecPosition;
w->m_vRealSize = pMonitor->vecSize;
}
} else {
w->m_vRealPosition = Vector2D{(int)w->m_vRealPosition.goalv().x % (int)pMonitor->vecSize.x, (int)w->m_vRealPosition.goalv().y % (int)pMonitor->vecSize.y};
}
}
w->updateToplevel();
@@ -1935,24 +2039,26 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
pWorkspace->startAnim(true, true, true);
wlr_cursor_warp(m_sWLRCursor, nullptr, pMonitor->vecPosition.x + pMonitor->vecTransformedSize.x / 2, pMonitor->vecPosition.y + pMonitor->vecTransformedSize.y / 2);
g_pInputManager->simulateMouseMovement();
}
// finalize
if (POLDMON) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
updateFullscreenFadeOnWorkspace(getWorkspaceByID(POLDMON->activeWorkspace));
}
updateFullscreenFadeOnWorkspace(pWorkspace);
updateFullscreenFadeOnWorkspace(getWorkspaceByID(POLDMON->activeWorkspace));
g_pInputManager->refocus();
// event
g_pEventManager->postEvent(SHyprIPCEvent{"moveworkspace", pWorkspace->m_szName + "," + pMonitor->szName});
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<void*>{pWorkspace, pMonitor}));
}
bool CCompositor::workspaceIDOutOfBounds(const int& id) {
int lowestID = 99999;
int highestID = -99999;
bool CCompositor::workspaceIDOutOfBounds(const int64_t& id) {
int64_t lowestID = INT64_MAX;
int64_t highestID = INT64_MIN;
for (auto& w : m_vWorkspaces) {
if (w->m_bIsSpecialWorkspace)
@@ -1975,7 +2081,7 @@ void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) {
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
if (w->m_bFadingOut || w->m_bPinned)
if (w->m_bFadingOut || w->m_bPinned || w->m_bIsFullscreen)
continue;
if (!FULLSCREEN)
@@ -1987,10 +2093,12 @@ void CCompositor::updateFullscreenFadeOnWorkspace(CWorkspace* pWorkspace) {
const auto PMONITOR = getMonitorFromID(pWorkspace->m_iMonitorID);
if (pWorkspace->m_iID == PMONITOR->activeWorkspace) {
for (auto& ls : PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
if (!ls->fadingOut)
ls->alpha = FULLSCREEN && pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL ? 0.f : 1.f;
}
}
}
void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode mode) {
@@ -2016,7 +2124,7 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode
g_pXWaylandManager->setWindowFullscreen(pWindow, pWindow->m_bIsFullscreen && mode == FULLSCREEN_FULL);
pWindow->updateDynamicRules();
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
updateWindowAnimatedDecorationValues(pWindow);
// make all windows on the same workspace under the fullscreen window
for (auto& w : m_vWindows) {
@@ -2217,11 +2325,6 @@ Vector2D CCompositor::parseWindowVectorArgsRelative(const std::string& args, con
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);
}
@@ -2313,7 +2416,7 @@ bool CCompositor::isWorkspaceSpecial(const int& id) {
}
int CCompositor::getNewSpecialID() {
int highest = -100;
int highest = SPECIAL_WORKSPACE_START;
for (auto& ws : m_vWorkspaces) {
if (ws->m_bIsSpecialWorkspace && ws->m_iID > highest) {
highest = ws->m_iID;
@@ -2324,28 +2427,16 @@ int CCompositor::getNewSpecialID() {
}
void CCompositor::performUserChecks() {
static constexpr auto BAD_PORTALS = {"kde", "gnome"};
static auto* const PSUPPRESSPORTAL = &g_pConfigManager->getConfigValuePtr("misc:suppress_portal_warnings")->intValue;
if (!*PSUPPRESSPORTAL) {
if (std::ranges::any_of(BAD_PORTALS, [&](const std::string& portal) { return std::filesystem::exists("/usr/share/xdg-desktop-portal/portals/" + portal + ".portal"); })) {
// bad portal detected
g_pHyprNotificationOverlay->addNotification("You have one or more incompatible xdg-desktop-portal impls installed. Please remove incompatible ones to avoid issues.",
CColor(0), 15000, ICON_ERROR);
}
if (std::filesystem::exists("/usr/share/xdg-desktop-portal/portals/hyprland.portal") && std::filesystem::exists("/usr/share/xdg-desktop-portal/portals/wlr.portal")) {
g_pHyprNotificationOverlay->addNotification("You have xdg-desktop-portal-hyprland and -wlr installed simultaneously. Please uninstall one to avoid issues.", CColor(0),
15000, ICON_ERROR);
}
}
// empty
}
void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace) {
if (!pWindow || !pWorkspace)
return;
if (pWindow->m_bPinned && pWorkspace->m_bIsSpecialWorkspace)
return;
const bool FULLSCREEN = pWindow->m_bIsFullscreen;
const auto FULLSCREENMODE = getWorkspaceByID(pWindow->m_iWorkspaceID)->m_efFullscreenMode;
@@ -2354,6 +2445,7 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
pWindow->moveToWorkspace(pWorkspace->m_iID);
pWindow->updateToplevel();
pWindow->updateDynamicRules();
if (!pWindow->m_bIsFloating) {
g_pLayoutManager->getCurrentLayout()->onWindowRemovedTiling(pWindow);
@@ -2372,6 +2464,93 @@ void CCompositor::moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorks
pWindow->m_vRealPosition = POSTOMON + PWORKSPACEMONITOR->vecPosition;
}
if (pWindow->m_sGroupData.pNextWindow) {
CWindow* next = pWindow->m_sGroupData.pNextWindow;
while (next != pWindow) {
next->moveToWorkspace(pWorkspace->m_iID);
next->updateToplevel();
next = next->m_sGroupData.pNextWindow;
}
}
if (FULLSCREEN)
setWindowFullscreen(pWindow, true, FULLSCREENMODE);
}
CWindow* CCompositor::getForceFocus() {
for (auto& w : m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || !isWorkspaceVisible(w->m_iWorkspaceID))
continue;
if (!w->m_bStayFocused)
continue;
return w.get();
}
return nullptr;
}
void CCompositor::notifyIdleActivity() {
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
wlr_idle_notifier_v1_notify_activity(g_pCompositor->m_sWLRIdleNotifier, g_pCompositor->m_sSeat.seat);
}
void CCompositor::setIdleActivityInhibit(bool enabled) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, enabled);
wlr_idle_notifier_v1_set_inhibited(g_pCompositor->m_sWLRIdleNotifier, !enabled);
}
void CCompositor::arrangeMonitors() {
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
std::vector<CMonitor*> toArrange;
std::vector<CMonitor*> arranged;
for (auto& m : m_vMonitors)
toArrange.push_back(m.get());
Debug::log(LOG, "arrangeMonitors: %llu to arrange", toArrange.size());
for (auto it = toArrange.begin(); it != toArrange.end();) {
auto m = *it;
if (m->activeMonitorRule.offset != Vector2D{-INT32_MAX, -INT32_MAX}) {
// explicit.
Debug::log(LOG, "arrangeMonitors: %s explicit [%.2f, %.2f]", m->szName.c_str(), m->activeMonitorRule.offset.x, m->activeMonitorRule.offset.y);
m->moveTo(m->activeMonitorRule.offset);
arranged.push_back(m);
it = toArrange.erase(it);
if (it == toArrange.end())
break;
continue;
}
++it;
}
// auto left
int maxOffset = 0;
for (auto& m : arranged) {
if (m->vecPosition.x + m->vecSize.x > maxOffset)
maxOffset = m->vecPosition.x + m->vecSize.x;
}
for (auto& m : toArrange) {
Debug::log(LOG, "arrangeMonitors: %s auto [%i, %.2f]", m->szName.c_str(), maxOffset, 0);
m->moveTo({maxOffset, 0});
maxOffset += m->vecSize.x;
}
// reset maxOffset (reuse)
// and set xwayland positions aka auto for all
maxOffset = 0;
for (auto& m : m_vMonitors) {
Debug::log(LOG, "arrangeMonitors: %s xwayland [%i, %.2f]", m->szName.c_str(), maxOffset, 0);
m->vecXWaylandPosition = {maxOffset, 0};
maxOffset += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x);
}
}

View File

@@ -28,8 +28,7 @@
#include "hyprerror/HyprError.hpp"
#include "plugins/PluginSystem.hpp"
enum eManagersInitStage
{
enum eManagersInitStage {
STAGE_PRIORITY = 0,
STAGE_LATE
};
@@ -54,6 +53,7 @@ class CCompositor {
wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout;
wlr_idle* m_sWLRIdle;
wlr_idle_notifier_v1* m_sWLRIdleNotifier;
wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor;
@@ -84,6 +84,8 @@ class CCompositor {
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
wlr_backend* m_sWLRHeadlessBackend;
wlr_session_lock_manager_v1* m_sWLRSessionLockMgr;
wlr_gamma_control_manager_v1* m_sWLRGammaCtrlMgr;
wlr_cursor_shape_manager_v1* m_sWLRCursorShapeMgr;
// ------------------------------------------------- //
std::string m_szWLDisplaySocket = "";
@@ -99,9 +101,13 @@ class CCompositor {
std::vector<CWindow*> m_vWindowsFadingOut;
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
std::unordered_map<std::string, uint64_t> m_mMonitorIDMap;
void initServer();
void startCompositor();
void cleanup();
void createLockFile();
void removeLockFile();
wlr_surface* m_pLastFocus = nullptr;
CWindow* m_pLastWindow = nullptr;
@@ -121,6 +127,7 @@ class CCompositor {
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(CWindow*);
@@ -144,12 +151,14 @@ class CCompositor {
CWorkspace* getWorkspaceByID(const int&);
CWorkspace* getWorkspaceByName(const std::string&);
CWorkspace* getWorkspaceByString(const std::string&);
CWorkspace* getWorkspaceByWorkspaceHandle(const wlr_ext_workspace_handle_v1*);
void sanityCheckWorkspaces();
void updateWorkspaceWindowDecos(const int&);
int getWindowsOnWorkspace(const int&);
CWindow* getUrgentWindow();
bool hasUrgentWindowOnWorkspace(const int&);
CWindow* getFirstWindowOnWorkspace(const int&);
CWindow* getTopLeftWindowOnWorkspace(const int&);
CWindow* getFullscreenWindowOnWorkspace(const int&);
bool doesSeatAcceptInput(wlr_surface*);
bool isWindowActive(CWindow*);
@@ -165,11 +174,11 @@ class CCompositor {
CMonitor* getMonitorInDirection(const char&);
void updateAllWindowsAnimatedDecorationValues();
void updateWindowAnimatedDecorationValues(CWindow*);
int getNextAvailableMonitorID();
int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int&);
bool workspaceIDOutOfBounds(const int64_t&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void updateFullscreenFadeOnWorkspace(CWorkspace*);
CWindow* getX11Parent(CWindow*);
@@ -191,6 +200,10 @@ class CCompositor {
int getNewSpecialID();
void performUserChecks();
void moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace);
CWindow* getForceFocus();
void notifyIdleActivity();
void setIdleActivityInhibit(bool inhibit);
void arrangeMonitors();
std::string explicitConfigPath;

View File

@@ -20,4 +20,6 @@ enum eRenderStage
RENDER_LAST_MOMENT, /* Last moment to render with the gl context */
RENDER_POST, /* After rendering is finished, gl context not available anymore */
RENDER_POST_MIRROR, /* After rendering a mirror */
RENDER_PRE_WINDOW, /* Before rendering a window (any pass) Note some windows (e.g. tiled) may have 2 passes (main & popup) */
RENDER_POST_WINDOW, /* After rendering a window (any pass) */
};

View File

@@ -22,15 +22,19 @@ CWindow::~CWindow() {
}
}
wlr_box CWindow::getFullWindowBoundingBox() {
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
SWindowDecorationExtents CWindow::getFullWindowExtents() {
if (m_bFadingOut)
return m_eOriginalClosedExtents;
const int BORDERSIZE = getRealBorderSize();
if (m_sAdditionalConfigData.dimAround) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
return {{m_vRealPosition.vec().x - PMONITOR->vecPosition.x, m_vRealPosition.vec().y - PMONITOR->vecPosition.y},
{PMONITOR->vecSize.x - (m_vRealPosition.vec().x - PMONITOR->vecPosition.x), PMONITOR->vecSize.y - (m_vRealPosition.vec().y - PMONITOR->vecPosition.y)}};
}
SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 2, *PBORDERSIZE + 2}, {*PBORDERSIZE + 2, *PBORDERSIZE + 2}};
SWindowDecorationExtents maxExtents = {{BORDERSIZE + 2, BORDERSIZE + 2}, {BORDERSIZE + 2, BORDERSIZE + 2}};
for (auto& wd : m_dWindowDecorations) {
@@ -49,7 +53,48 @@ wlr_box CWindow::getFullWindowBoundingBox() {
maxExtents.bottomRight.y = EXTENTS.bottomRight.y;
}
// Add extents to the real base BB and return
if (m_pWLSurface.exists() && !m_bIsX11) {
wlr_box surfaceExtents = {0, 0, 0, 0};
// TODO: this could be better, perhaps make a getFullWindowRegion?
wlr_xdg_surface_for_each_popup_surface(
m_uSurface.xdg,
[](wlr_surface* surf, int sx, int sy, void* data) {
wlr_box* pSurfaceExtents = (wlr_box*)data;
if (sx < pSurfaceExtents->x)
pSurfaceExtents->x = sx;
if (sy < pSurfaceExtents->y)
pSurfaceExtents->y = sy;
if (sx + surf->current.width > pSurfaceExtents->width)
pSurfaceExtents->width = sx + surf->current.width - pSurfaceExtents->x;
if (sy + surf->current.height > pSurfaceExtents->height)
pSurfaceExtents->height = sy + surf->current.height - pSurfaceExtents->y;
},
&surfaceExtents);
if (-surfaceExtents.x > maxExtents.topLeft.x)
maxExtents.topLeft.x = -surfaceExtents.x;
if (-surfaceExtents.y > maxExtents.topLeft.y)
maxExtents.topLeft.y = -surfaceExtents.y;
if (surfaceExtents.x + surfaceExtents.width > m_pWLSurface.wlr()->current.width + maxExtents.bottomRight.x)
maxExtents.bottomRight.x = surfaceExtents.x + surfaceExtents.width - m_pWLSurface.wlr()->current.width;
if (surfaceExtents.y + surfaceExtents.height > m_pWLSurface.wlr()->current.height + maxExtents.bottomRight.y)
maxExtents.bottomRight.y = surfaceExtents.y + surfaceExtents.height - m_pWLSurface.wlr()->current.height;
}
return maxExtents;
}
wlr_box CWindow::getFullWindowBoundingBox() {
if (m_sAdditionalConfigData.dimAround) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
}
auto maxExtents = getFullWindowExtents();
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x, m_vRealPosition.vec().y - maxExtents.topLeft.y,
m_vRealSize.vec().x + maxExtents.topLeft.x + maxExtents.bottomRight.x, m_vRealSize.vec().y + maxExtents.topLeft.y + maxExtents.bottomRight.y};
@@ -89,14 +134,14 @@ wlr_box CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
}
wlr_box CWindow::getWindowInputBox() {
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
const int BORDERSIZE = getRealBorderSize();
if (m_sAdditionalConfigData.dimAround) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
}
SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 2, *PBORDERSIZE + 2}, {*PBORDERSIZE + 2, *PBORDERSIZE + 2}};
SWindowDecorationExtents maxExtents = {{BORDERSIZE + 2, BORDERSIZE + 2}, {BORDERSIZE + 2, BORDERSIZE + 2}};
for (auto& wd : m_dWindowDecorations) {
@@ -145,16 +190,22 @@ void CWindow::updateWindowDecos() {
for (auto& wd : m_dWindowDecorations)
wd->updateWindow(this);
bool recalc = false;
for (auto& wd : m_vDecosToRemove) {
for (auto it = m_dWindowDecorations.begin(); it != m_dWindowDecorations.end(); it++) {
if (it->get() == wd) {
it = m_dWindowDecorations.erase(it);
recalc = true;
if (it == m_dWindowDecorations.end())
break;
}
}
}
if (recalc)
g_pLayoutManager->getCurrentLayout()->recalculateWindow(this);
m_vDecosToRemove.clear();
}
@@ -197,7 +248,7 @@ void CWindow::createToplevelHandle() {
// handle events
hyprListener_toplevelActivate.initCallback(
&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) { g_pCompositor->focusWindow(this); }, this, "Toplevel");
&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) { g_pLayoutManager->getCurrentLayout()->requestFocusForWindow(this); }, this, "Toplevel");
hyprListener_toplevelFullscreen.initCallback(
&m_phForeignToplevel->events.request_fullscreen,
@@ -268,6 +319,14 @@ void CWindow::updateSurfaceOutputs() {
wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendLeaveIter, PLASTMONITOR->output);
wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendEnterIter, PNEWMONITOR->output);
wlr_surface_for_each_surface(
m_pWLSurface.wlr(),
[](wlr_surface* surf, int x, int y, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID);
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f);
},
this);
}
void CWindow::moveToWorkspace(int workspaceID) {
@@ -276,9 +335,10 @@ void CWindow::moveToWorkspace(int workspaceID) {
m_iWorkspaceID = workspaceID;
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
updateSpecialRenderData();
if (PWORKSPACE) {
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%lx,%s", this, PWORKSPACE->m_szName.c_str())});
EMIT_HOOK_EVENT("moveWindow", (std::vector<void*>{this, PWORKSPACE}));
@@ -289,19 +349,8 @@ void CWindow::moveToWorkspace(int workspaceID) {
m_pSwallowed->m_iMonitorID = m_iMonitorID;
}
if (PMONITOR)
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(m_pWLSurface.wlr(), PMONITOR->scale);
if (!m_bIsMapped)
return;
wlr_surface_for_each_surface(
m_pWLSurface.wlr(),
[](wlr_surface* surf, int x, int y, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID);
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f);
},
this);
// update xwayland coords
g_pXWaylandManager->setWindowSize(this, m_vRealSize.vec());
}
CWindow* CWindow::X11TransientFor() {
@@ -388,7 +437,8 @@ void CWindow::onMap() {
g_pCompositor->m_vWindowFocusHistory.push_back(this);
hyprListener_unmapWindow.initCallback(m_bIsX11 ? &m_uSurface.xwayland->events.unmap : &m_uSurface.xdg->events.unmap, &Events::listener_unmapWindow, this, "CWindow");
hyprListener_unmapWindow.initCallback(m_bIsX11 ? &m_uSurface.xwayland->surface->events.unmap : &m_uSurface.xdg->surface->events.unmap, &Events::listener_unmapWindow, this,
"CWindow");
}
void CWindow::onBorderAngleAnimEnd(void* ptr) {
@@ -426,6 +476,8 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
m_sAdditionalConfigData.forceNoBorder = true;
} else if (r.szRule == "noshadow") {
m_sAdditionalConfigData.forceNoShadow = true;
} else if (r.szRule == "nodim") {
m_sAdditionalConfigData.forceNoDim = true;
} else if (r.szRule == "forcergbx") {
m_sAdditionalConfigData.forceRGBX = true;
} else if (r.szRule == "opaque") {
@@ -435,24 +487,38 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
try {
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
} catch (std::exception& e) { Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
} else if (r.szRule.find("bordersize") == 0) {
try {
m_sAdditionalConfigData.borderSize = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
} catch (std::exception& e) { Debug::log(ERR, "Bordersize rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
} else if (r.szRule.find("opacity") == 0) {
try {
CVarList vars(r.szRule, 0, ' ');
for (size_t i = 1 /* first item is "opacity" */; i < vars.size(); ++i) {
if (i == 1) {
// first arg, alpha
m_sSpecialRenderData.alpha = std::stof(vars[i]);
} else {
if (vars[i] == "override") {
if (i == 2) {
int opacityIDX = 0;
for (auto& r : vars) {
if (r == "opacity")
continue;
if (r == "override") {
if (opacityIDX == 1) {
m_sSpecialRenderData.alphaOverride = true;
} else {
m_sSpecialRenderData.alphaInactiveOverride = true;
}
} else if (opacityIDX == 2)
m_sSpecialRenderData.alphaInactiveOverride = true;
} else {
m_sSpecialRenderData.alphaInactive = std::stof(vars[i]);
if (opacityIDX == 0) {
m_sSpecialRenderData.alpha = std::stof(r);
m_sSpecialRenderData.alphaInactive = std::stof(r);
} else if (opacityIDX == 1) {
m_sSpecialRenderData.alphaInactive = std::stof(r);
m_sSpecialRenderData.alphaInactiveOverride = false;
} else {
throw std::runtime_error("more than 2 alpha values");
}
opacityIDX++;
}
}
} catch (std::exception& e) { Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
@@ -475,6 +541,14 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
} catch (std::exception& e) { Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
} else if (r.szRule == "dimaround") {
m_sAdditionalConfigData.dimAround = true;
} else if (r.szRule == "keepaspectratio") {
m_sAdditionalConfigData.keepAspectRatio = true;
} else if (r.szRule.find("xray") == 0) {
CVarList vars(r.szRule, 0, ' ');
try {
m_sAdditionalConfigData.xray = configStringToInt(vars[1]);
} catch (...) {}
}
}
@@ -486,6 +560,7 @@ void CWindow::updateDynamicRules() {
m_sAdditionalConfigData.forceNoBlur = false;
m_sAdditionalConfigData.forceNoBorder = false;
m_sAdditionalConfigData.forceNoShadow = false;
m_sAdditionalConfigData.forceNoDim = false;
if (!m_sAdditionalConfigData.forceOpaqueOverridden)
m_sAdditionalConfigData.forceOpaque = false;
m_sAdditionalConfigData.forceNoAnims = false;
@@ -493,40 +568,43 @@ void CWindow::updateDynamicRules() {
m_sAdditionalConfigData.rounding = -1;
m_sAdditionalConfigData.dimAround = false;
m_sAdditionalConfigData.forceRGBX = false;
m_sAdditionalConfigData.borderSize = -1;
m_sAdditionalConfigData.keepAspectRatio = false;
m_sAdditionalConfigData.xray = -1;
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(this);
for (auto& r : WINDOWRULES) {
applyDynamicRule(r);
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
}
// check if the point is "hidden" under a rounded corner of the window
// it is assumed that the point is within the real window box (m_vRealPosition, m_vRealSize)
// otherwise behaviour is undefined
bool CWindow::isInCurvedCorner(double x, double y) {
static auto* const ROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
static auto* const BORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
if (BORDERSIZE >= ROUNDING || ROUNDING == 0)
const int ROUNDING = rounding();
if (getRealBorderSize() >= ROUNDING)
return false;
// (x0, y0), (x0, y1), ... are the center point of rounding at each corner
double x0 = m_vRealPosition.vec().x + *ROUNDING;
double y0 = m_vRealPosition.vec().y + *ROUNDING;
double x1 = m_vRealPosition.vec().x + m_vRealSize.vec().x - *ROUNDING;
double y1 = m_vRealPosition.vec().y + m_vRealSize.vec().y - *ROUNDING;
double x0 = m_vRealPosition.vec().x + ROUNDING;
double y0 = m_vRealPosition.vec().y + ROUNDING;
double x1 = m_vRealPosition.vec().x + m_vRealSize.vec().x - ROUNDING;
double y1 = m_vRealPosition.vec().y + m_vRealSize.vec().y - ROUNDING;
if (x < x0 && y < y0) {
return Vector2D{x0, y0}.distance(Vector2D{x, y}) > (double)*ROUNDING;
return Vector2D{x0, y0}.distance(Vector2D{x, y}) > (double)ROUNDING;
}
if (x > x1 && y < y0) {
return Vector2D{x1, y0}.distance(Vector2D{x, y}) > (double)*ROUNDING;
return Vector2D{x1, y0}.distance(Vector2D{x, y}) > (double)ROUNDING;
}
if (x < x0 && y > y1) {
return Vector2D{x0, y1}.distance(Vector2D{x, y}) > (double)*ROUNDING;
return Vector2D{x0, y1}.distance(Vector2D{x, y}) > (double)ROUNDING;
}
if (x > x1 && y > y1) {
return Vector2D{x1, y1}.distance(Vector2D{x, y}) > (double)*ROUNDING;
return Vector2D{x1, y1}.distance(Vector2D{x, y}) > (double)ROUNDING;
}
return false;
@@ -602,7 +680,7 @@ void CWindow::setGroupCurrent(CWindow* pWindow) {
g_pCompositor->setWindowFullscreen(PCURRENT, false, WORKSPACE->m_efFullscreenMode);
PCURRENT->setHidden(true);
pWindow->setHidden(false);
pWindow->setHidden(false); // can remove m_pLastWindow
g_pLayoutManager->getCurrentLayout()->replaceWindowDataWith(PCURRENT, pWindow);
@@ -618,34 +696,61 @@ void CWindow::setGroupCurrent(CWindow* pWindow) {
if (FULLSCREEN)
g_pCompositor->setWindowFullscreen(pWindow, true, WORKSPACE->m_efFullscreenMode);
g_pHyprRenderer->damageWindow(pWindow);
}
void CWindow::insertWindowToGroup(CWindow* pWindow) {
const auto PHEAD = getGroupHead();
const auto PTAIL = getGroupTail();
static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("misc:group_insert_after_current")->intValue;
if (pWindow->m_sGroupData.pNextWindow) {
std::vector<CWindow*> members;
CWindow* curr = pWindow;
do {
const auto PLAST = curr;
members.push_back(curr);
curr = curr->m_sGroupData.pNextWindow;
PLAST->m_sGroupData.pNextWindow = nullptr;
PLAST->m_sGroupData.head = false;
} while (curr != pWindow);
for (auto& w : members) {
insertWindowToGroup(w);
}
const auto BEGINAT = *USECURRPOS ? this : getGroupTail();
const auto ENDAT = *USECURRPOS ? m_sGroupData.pNextWindow : getGroupHead();
if (!pWindow->m_sGroupData.pNextWindow) {
BEGINAT->m_sGroupData.pNextWindow = pWindow;
pWindow->m_sGroupData.pNextWindow = ENDAT;
pWindow->m_sGroupData.head = false;
return;
}
PTAIL->m_sGroupData.pNextWindow = pWindow;
pWindow->m_sGroupData.pNextWindow = PHEAD;
const auto SHEAD = pWindow->getGroupHead();
const auto STAIL = pWindow->getGroupTail();
setGroupCurrent(pWindow);
SHEAD->m_sGroupData.head = false;
BEGINAT->m_sGroupData.pNextWindow = SHEAD;
STAIL->m_sGroupData.pNextWindow = ENDAT;
}
CWindow* CWindow::getGroupPrevious() {
CWindow* curr = m_sGroupData.pNextWindow;
while (curr != this && curr->m_sGroupData.pNextWindow != this)
curr = curr->m_sGroupData.pNextWindow;
return curr;
}
void CWindow::switchWithWindowInGroup(CWindow* pWindow) {
if (!m_sGroupData.pNextWindow || !pWindow->m_sGroupData.pNextWindow)
return;
if (m_sGroupData.pNextWindow == pWindow) { // A -> this -> pWindow -> B >> A -> pWindow -> this -> B
getGroupPrevious()->m_sGroupData.pNextWindow = pWindow;
m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow;
pWindow->m_sGroupData.pNextWindow = this;
} else if (pWindow->m_sGroupData.pNextWindow == this) { // A -> pWindow -> this -> B >> A -> this -> pWindow -> B
pWindow->getGroupPrevious()->m_sGroupData.pNextWindow = this;
pWindow->m_sGroupData.pNextWindow = m_sGroupData.pNextWindow;
m_sGroupData.pNextWindow = pWindow;
} else { // A -> this -> B | C -> pWindow -> D >> A -> pWindow -> B | C -> this -> D
std::swap(m_sGroupData.pNextWindow, pWindow->m_sGroupData.pNextWindow);
std::swap(getGroupPrevious()->m_sGroupData.pNextWindow, pWindow->getGroupPrevious()->m_sGroupData.pNextWindow);
}
std::swap(m_sGroupData.head, pWindow->m_sGroupData.head);
std::swap(m_sGroupData.locked, pWindow->m_sGroupData.locked);
}
void CWindow::updateGroupOutputs() {
@@ -670,6 +775,14 @@ Vector2D CWindow::middle() {
}
bool CWindow::opaque() {
if (m_fAlpha.fl() != 1.f || m_fActiveInactiveAlpha.fl() != 1.f)
return false;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
if (PWORKSPACE->m_fAlpha.fl() != 1.f)
return false;
if (m_bIsX11)
return !m_uSurface.xwayland->has_alpha;
@@ -677,9 +790,44 @@ bool CWindow::opaque() {
return true;
const auto EXTENTS = pixman_region32_extents(&m_uSurface.xdg->surface->opaque_region);
if (EXTENTS->x2 - EXTENTS->x1 >= m_uSurface.xdg->surface->current.buffer_width
&& EXTENTS->y2 - EXTENTS->y1 >= m_uSurface.xdg->surface->current.buffer_height)
if (EXTENTS->x2 - EXTENTS->x1 >= m_uSurface.xdg->surface->current.buffer_width && EXTENTS->y2 - EXTENTS->y1 >= m_uSurface.xdg->surface->current.buffer_height)
return true;
return false;
}
float CWindow::rounding() {
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
float rounding = m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_sAdditionalConfigData.rounding.toUnderlying();
return rounding;
}
void CWindow::updateSpecialRenderData() {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID);
const auto WORKSPACERULE = PWORKSPACE ? g_pConfigManager->getWorkspaceRuleFor(PWORKSPACE) : SWorkspaceRule{};
bool border = true;
if (m_bIsFloating && g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue == 1)
border = false;
m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(border);
m_sSpecialRenderData.borderSize = WORKSPACERULE.borderSize.value_or(-1);
m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
m_sSpecialRenderData.rounding = WORKSPACERULE.rounding.value_or(true);
m_sSpecialRenderData.shadow = WORKSPACERULE.shadow.value_or(true);
}
int CWindow::getRealBorderSize() {
if (!m_sSpecialRenderData.border || m_sAdditionalConfigData.forceNoBorder)
return 0;
if (m_sAdditionalConfigData.borderSize.toUnderlying() != -1)
return m_sAdditionalConfigData.borderSize.toUnderlying();
if (m_sSpecialRenderData.borderSize.toUnderlying() != -1)
return m_sSpecialRenderData.borderSize.toUnderlying();
return g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
}

View File

@@ -100,10 +100,11 @@ struct SWindowSpecialRenderData {
CWindowOverridableVar<int64_t> inactiveBorderColor = -1; // -1 means unset
// set by the layout
int borderSize = -1;
CWindowOverridableVar<int> borderSize = -1; // -1 means unset
bool rounding = true;
bool border = true;
bool decorate = true;
bool shadow = true;
};
struct SWindowAdditionalConfigData {
@@ -116,10 +117,14 @@ struct SWindowAdditionalConfigData {
CWindowOverridableVar<bool> forceNoAnims = false;
CWindowOverridableVar<bool> forceNoBorder = false;
CWindowOverridableVar<bool> forceNoShadow = false;
CWindowOverridableVar<bool> forceNoDim = false;
CWindowOverridableVar<bool> windowDanceCompat = false;
CWindowOverridableVar<bool> noMaxSize = false;
CWindowOverridableVar<bool> dimAround = false;
CWindowOverridableVar<bool> forceRGBX = false;
CWindowOverridableVar<bool> keepAspectRatio = false;
CWindowOverridableVar<int> xray = -1; // -1 means unset, takes precedence over the renderdata one
CWindowOverridableVar<int> borderSize = -1; // -1 means unset, takes precedence over the renderdata one
};
struct SWindowRule {
@@ -133,6 +138,7 @@ struct SWindowRule {
int bFloating = -1;
int bFullscreen = -1;
int bPinned = -1;
std::string szWorkspace = ""; // empty means any
};
class CWindow {
@@ -158,6 +164,8 @@ class CWindow {
DYNLISTENER(toplevelActivate);
DYNLISTENER(toplevelFullscreen);
DYNLISTENER(setOverrideRedirect);
DYNLISTENER(associateX11);
DYNLISTENER(dissociateX11);
// DYNLISTENER(newSubsurfaceWindow);
CWLSurface m_pWLSurface;
@@ -188,7 +196,7 @@ class CWindow {
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(0, 0);
uint64_t m_iTags = 0;
bool m_bFirstMap = false; // for layouts
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false;
@@ -214,15 +222,17 @@ class CWindow {
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
float m_fX11SurfaceScaledBy = 1.f;
//
// For nofocus
bool m_bNoFocus = false;
bool m_bNoInitialFocus = false;
// initial fullscreen and fullscreen disabled
// Fullscreen and Maximize
bool m_bWantsInitialFullscreen = false;
bool m_bNoFullscreenRequest = false;
bool m_bNoMaximizeRequest = false;
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
@@ -238,6 +248,7 @@ class CWindow {
bool m_bReadyToDelete = false;
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
Vector2D m_vOriginalClosedSize; // drawing the closing animations
SWindowDecorationExtents m_eOriginalClosedExtents;
// For pinned (sticky) windows
bool m_bPinned = false;
@@ -274,6 +285,9 @@ class CWindow {
// swallowing
CWindow* m_pSwallowed = nullptr;
// focus stuff
bool m_bStayFocused = false;
// for toplevel monitor events
uint64_t m_iLastToplevelMonitorID = -1;
uint64_t m_iLastSurfaceMonitorID = -1;
@@ -285,6 +299,7 @@ class CWindow {
struct SGroupData {
CWindow* pNextWindow = nullptr; // nullptr means no grouping. Self means single group.
bool head = false;
bool locked = false;
} m_sGroupData;
// For the list lookup
@@ -295,6 +310,7 @@ class CWindow {
// methods
wlr_box getFullWindowBoundingBox();
SWindowDecorationExtents getFullWindowExtents();
wlr_box getWindowInputBox();
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
void updateWindowDecos();
@@ -316,6 +332,10 @@ class CWindow {
SWindowDecorationExtents getFullWindowReservedArea();
Vector2D middle();
bool opaque();
float rounding();
int getRealBorderSize();
void updateSpecialRenderData();
void onBorderAngleAnimEnd(void* ptr);
bool isInCurvedCorner(double x, double y);
@@ -324,9 +344,11 @@ class CWindow {
CWindow* getGroupHead();
CWindow* getGroupTail();
CWindow* getGroupCurrent();
CWindow* getGroupPrevious();
void setGroupCurrent(CWindow* pWindow);
void insertWindowToGroup(CWindow* pWindow);
void updateGroupOutputs();
void switchWithWindowInGroup(CWindow* pWindow);
private:
// For hidden windows and stuff

View File

@@ -2,13 +2,12 @@
#include "../defines.hpp"
#include <vector>
enum eConfigValueDataTypes
{
enum eConfigValueDataTypes {
CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0
};
interface ICustomConfigValueData {
class ICustomConfigValueData {
public:
virtual ~ICustomConfigValueData() = 0;
@@ -38,7 +37,8 @@ class CGradientValueData : public ICustomConfigValueData {
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;
bool operator==(const CGradientValueData& other) {
//
bool operator==(const CGradientValueData& other) const {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false;

View File

@@ -18,19 +18,13 @@ CConfigManager::CConfigManager() {
configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444);
configValues["general:col.group_border"].data = std::make_shared<CGradientValueData>(0x66777700);
configValues["general:col.group_border_active"].data = std::make_shared<CGradientValueData>(0x66ffff00);
configValues["general:col.group_border_locked"].data = std::make_shared<CGradientValueData>(0x66775500);
configValues["general:col.group_border_locked_active"].data = std::make_shared<CGradientValueData>(0x66ff5500);
setDefaultVars();
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);
configPaths.emplace_back(getMainConfigPath());
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
Debug::disableTime = &configValues["debug:disable_time"].intValue;
@@ -38,6 +32,23 @@ CConfigManager::CConfigManager() {
populateEnvironment();
}
std::string CConfigManager::getConfigDir() {
static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
std::string configPath;
if (!xdgConfigHome)
configPath = getenv("HOME") + std::string("/.config");
else
configPath = xdgConfigHome;
return configPath;
}
std::string CConfigManager::getMainConfigPath() {
if (!g_pCompositor->explicitConfigPath.empty())
return g_pCompositor->explicitConfigPath;
return getConfigDir() + "/hypr/" + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
}
void CConfigManager::populateEnvironment() {
environmentVariables.clear();
for (char** env = environ; *env; ++env) {
@@ -62,6 +73,8 @@ void CConfigManager::setDefaultVars() {
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
((CGradientValueData*)configValues["general:col.group_border"].data.get())->reset(0x66777700);
((CGradientValueData*)configValues["general:col.group_border_active"].data.get())->reset(0x66ffff00);
((CGradientValueData*)configValues["general:col.group_border_locked"].data.get())->reset(0x66775500);
((CGradientValueData*)configValues["general:col.group_border_locked_active"].data.get())->reset(0x66ff5500);
configValues["general:cursor_inactive_timeout"].intValue = 0;
configValues["general:no_cursor_warps"].intValue = 0;
configValues["general:no_focus_fallback"].intValue = 0;
@@ -72,6 +85,7 @@ void CConfigManager::setDefaultVars() {
configValues["misc:disable_hyprland_logo"].intValue = 0;
configValues["misc:disable_splash_rendering"].intValue = 0;
configValues["misc:force_hypr_chan"].intValue = 0;
configValues["misc:vfr"].intValue = 1;
configValues["misc:vrr"].intValue = 0;
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
@@ -86,13 +100,20 @@ void CConfigManager::setDefaultVars() {
configValues["misc:swallow_exception_regex"].strValue = STRVAL_EMPTY;
configValues["misc:focus_on_activate"].intValue = 0;
configValues["misc:no_direct_scanout"].intValue = 1;
configValues["misc:moveintogroup_lock_check"].intValue = 0;
configValues["misc:hide_cursor_on_touch"].intValue = 1;
configValues["misc:mouse_move_focuses_monitor"].intValue = 1;
configValues["misc:suppress_portal_warnings"].intValue = 0;
configValues["misc:render_ahead_of_time"].intValue = 0;
configValues["misc:render_ahead_safezone"].intValue = 1;
configValues["misc:cursor_zoom_factor"].floatValue = 1.f;
configValues["misc:cursor_zoom_rigid"].intValue = 0;
configValues["misc:allow_session_lock_restore"].intValue = 0;
configValues["misc:group_insert_after_current"].intValue = 1;
configValues["misc:render_titles_in_groupbar"].intValue = 1;
configValues["misc:groupbar_titles_font_size"].intValue = 8;
configValues["misc:groupbar_gradients"].intValue = 1;
configValues["misc:groupbar_text_color"].intValue = 0xffffffff;
configValues["misc:background_color"].intValue = 0xff111111;
configValues["debug:int"].intValue = 0;
configValues["debug:log_damage"].intValue = 0;
@@ -103,14 +124,19 @@ void CConfigManager::setDefaultVars() {
configValues["debug:enable_stdout_logs"].intValue = 0;
configValues["debug:damage_tracking"].intValue = DAMAGE_TRACKING_FULL;
configValues["debug:manual_crash"].intValue = 0;
configValues["debug:suppress_errors"].intValue = 0;
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 = 1;
configValues["decoration:blur_xray"].intValue = 0;
configValues["decoration:blur:enabled"].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 = 1;
configValues["decoration:blur:xray"].intValue = 0;
configValues["decoration:blur:noise"].floatValue = 0.0117;
configValues["decoration:blur:contrast"].floatValue = 0.8916;
configValues["decoration:blur:brightness"].floatValue = 0.8172;
configValues["decoration:blur:special"].intValue = 1;
configValues["decoration:active_opacity"].floatValue = 1;
configValues["decoration:inactive_opacity"].floatValue = 1;
configValues["decoration:fullscreen_opacity"].floatValue = 1;
@@ -132,12 +158,15 @@ void CConfigManager::setDefaultVars() {
configValues["dwindle:pseudotile"].intValue = 0;
configValues["dwindle:force_split"].intValue = 0;
configValues["dwindle:permanent_direction_override"].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["dwindle:default_split_ratio"].floatValue = 1.f;
configValues["dwindle:smart_split"].intValue = 0;
configValues["dwindle:smart_resizing"].intValue = 1;
configValues["master:special_scale_factor"].floatValue = 0.8f;
configValues["master:mfact"].floatValue = 0.55f;
@@ -197,8 +226,14 @@ void CConfigManager::setDefaultVars() {
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
configValues["gestures:workspace_swipe_direction_lock"].intValue = 1;
configValues["gestures:workspace_swipe_direction_lock_threshold"].intValue = 10;
configValues["gestures:workspace_swipe_forever"].intValue = 0;
configValues["gestures:workspace_swipe_numbered"].intValue = 0;
configValues["gestures:workspace_swipe_use_r"].intValue = 0;
configValues["xwayland:use_nearest_neighbor"].intValue = 1;
configValues["xwayland:force_zero_scaling"].intValue = 0;
configValues["autogenerated"].intValue = 0;
}
@@ -286,9 +321,7 @@ void CConfigManager::init() {
loadConfigLoadVars();
const char* const ENVHOME = getenv("HOME");
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
const std::string CONFIGPATH = getMainConfigPath();
struct stat fileStat;
int err = stat(CONFIGPATH.c_str(), &fileStat);
@@ -350,8 +383,10 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
CONFIGENTRY = &it->second;
}
if (!CONFIGENTRY)
if (!CONFIGENTRY) {
m_vFailedPluginConfigValues.emplace_back(std::make_pair<>(COMMAND, VALUE));
return; // silent ignore
}
} else {
CONFIGENTRY = &configValues.at(COMMAND);
}
@@ -469,6 +504,58 @@ void CConfigManager::handleRawExec(const std::string& command, const std::string
g_pKeybindManager->spawn(args);
}
static bool parseModeLine(const std::string& modeline, drmModeModeInfo& mode) {
auto args = CVarList(modeline, 0, 's');
auto keyword = args[0];
std::transform(keyword.begin(), keyword.end(), keyword.begin(), ::tolower);
if (keyword != "modeline")
return false;
if (args.size() < 10) {
Debug::log(ERR, "modeline parse error: expected at least 9 arguments, got %i", args.size() - 1);
return false;
}
int argno = 1;
mode.type = DRM_MODE_TYPE_USERDEF;
mode.clock = std::stof(args[argno++]) * 1000;
mode.hdisplay = std::stoi(args[argno++]);
mode.hsync_start = std::stoi(args[argno++]);
mode.hsync_end = std::stoi(args[argno++]);
mode.htotal = std::stoi(args[argno++]);
mode.vdisplay = std::stoi(args[argno++]);
mode.vsync_start = std::stoi(args[argno++]);
mode.vsync_end = std::stoi(args[argno++]);
mode.vtotal = std::stoi(args[argno++]);
mode.vrefresh = mode.clock * 1000.0 * 1000.0 / mode.htotal / mode.vtotal;
static std::unordered_map<std::string, uint32_t> flagsmap = {
{"+hsync", DRM_MODE_FLAG_PHSYNC},
{"-hsync", DRM_MODE_FLAG_NHSYNC},
{"+vsync", DRM_MODE_FLAG_PVSYNC},
{"-vsync", DRM_MODE_FLAG_NVSYNC},
};
for (; argno < static_cast<int>(args.size()); argno++) {
auto key = args[argno];
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
auto it = flagsmap.find(key);
if (it != flagsmap.end())
mode.flags |= it->second;
else
Debug::log(ERR, "invalid flag %s in modeline", it->first.c_str());
}
snprintf(mode.name, sizeof(mode.name), "%dx%d@%d", mode.hdisplay, mode.vdisplay, mode.vrefresh / 1000);
return true;
}
void CConfigManager::handleMonitor(const std::string& command, const std::string& args) {
// get the monitor config
@@ -530,6 +617,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
newrule.resolution = Vector2D(-1, -1);
} else if (ARGS[1].find("highres") == 0) {
newrule.resolution = Vector2D(-1, -2);
} else if (parseModeLine(ARGS[1], newrule.drmMode)) {
newrule.resolution = Vector2D(newrule.drmMode.hdisplay, newrule.drmMode.vdisplay);
newrule.refreshRate = newrule.drmMode.vrefresh / 1000;
} else {
newrule.resolution.x = stoi(ARGS[1].substr(0, ARGS[1].find_first_of('x')));
newrule.resolution.y = stoi(ARGS[1].substr(ARGS[1].find_first_of('x') + 1, ARGS[1].find_first_of('@')));
@@ -539,15 +629,10 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
}
if (ARGS[2].find("auto") == 0) {
newrule.offset = Vector2D(-1, -1);
newrule.offset = Vector2D(-INT32_MAX, -INT32_MAX);
} else {
newrule.offset.x = stoi(ARGS[2].substr(0, ARGS[2].find_first_of('x')));
newrule.offset.y = stoi(ARGS[2].substr(ARGS[2].find_first_of('x') + 1));
if (newrule.offset.x < 0 || newrule.offset.y < 0) {
parseError = "invalid offset. Offset cannot be negative.";
newrule.offset = Vector2D();
}
}
if (ARGS[3].find("auto") == 0) {
@@ -573,6 +658,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
} else if (ARGS[argno] == "transform") {
newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
argno++;
} else if (ARGS[argno] == "vrr") {
newrule.vrr = std::stoi(ARGS[argno + 1]);
argno++;
} else if (ARGS[argno] == "workspace") {
std::string name = "";
int wsId = getWorkspaceIDFromString(ARGS[argno + 1], name);
@@ -583,7 +671,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
wsRule.workspaceName = name;
wsRule.workspaceId = wsId;
m_mWorkspaceRules[wsId] = wsRule;
m_dWorkspaceRules.emplace_back(wsRule);
argno++;
} else {
Debug::log(ERR, "Config error: invalid monitor syntax");
@@ -706,6 +794,8 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
bool release = false;
bool repeat = false;
bool mouse = false;
bool nonConsuming = false;
bool transparent = false;
const auto BINDARGS = command.substr(4);
for (auto& arg : BINDARGS) {
@@ -717,6 +807,10 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
repeat = true;
} else if (arg == 'm') {
mouse = true;
} else if (arg == 'n') {
nonConsuming = true;
} else if (arg == 't') {
transparent = true;
} else {
parseError = "bind: invalid flag";
return;
@@ -774,11 +868,12 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
if (KEY != "") {
if (isNumber(KEY) && std::stoi(KEY) > 9)
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse});
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
else if (KEY.find("code:") == 0 && isNumber(KEY.substr(5)))
g_pKeybindManager->addKeybind(SKeybind{"", std::stoi(KEY.substr(5)), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse});
g_pKeybindManager->addKeybind(
SKeybind{"", std::stoi(KEY.substr(5)), MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
else
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse});
g_pKeybindManager->addKeybind(SKeybind{KEY, -1, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap, release, repeat, mouse, nonConsuming, transparent});
}
}
@@ -795,14 +890,15 @@ void CConfigManager::handleUnbind(const std::string& command, const std::string&
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("minsize") != 0 &&
RULE.find("maxsize") != 0 && RULE.find("pseudo") != 0 && RULE.find("monitor") != 0 && RULE.find("idleinhibit") != 0 && RULE != "nofocus" && RULE != "noblur" &&
RULE != "noshadow" && RULE != "noborder" && RULE != "center" && RULE != "opaque" && RULE != "forceinput" && RULE != "fullscreen" && RULE != "nofullscreenrequest" &&
RULE != "fakefullscreen" && RULE != "nomaxsize" && RULE != "pin" && RULE != "noanim" && RULE != "dimaround" && RULE != "windowdance" && RULE != "maximize" &&
RULE.find("animation") != 0 && RULE.find("rounding") != 0 && RULE.find("workspace") != 0 && RULE.find("bordercolor") != 0 && RULE != "forcergbx" &&
RULE != "noinitialfocus");
RULE != "noshadow" && RULE != "nodim" && RULE != "noborder" && RULE != "opaque" && RULE != "forceinput" && RULE != "fullscreen" && RULE != "nofullscreenrequest" &&
RULE != "nomaximizerequest" && RULE != "fakefullscreen" && RULE != "nomaxsize" && RULE != "pin" && RULE != "noanim" && RULE != "dimaround" && RULE != "windowdance" &&
RULE != "maximize" && RULE != "keepaspectratio" && RULE.find("animation") != 0 && RULE.find("rounding") != 0 && RULE.find("workspace") != 0 &&
RULE.find("bordercolor") != 0 && RULE != "forcergbx" && RULE != "noinitialfocus" && RULE != "stayfocused" && RULE.find("bordersize") != 0 && RULE.find("xray") != 0 &&
RULE.find("center") != 0);
}
bool layerRuleValid(const std::string& RULE) {
return !(RULE != "noanim" && RULE != "blur" && RULE != "ignorezero");
return !(RULE != "noanim" && RULE != "blur" && RULE.find("ignorealpha") != 0 && RULE.find("ignorezero") != 0 && RULE.find("xray") != 0);
}
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
@@ -826,6 +922,9 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
return;
}
if (RULE.find("size") == 0 || RULE.find("maxsize") == 0 || RULE.find("minsize") == 0)
m_dWindowRules.push_front({RULE, VALUE});
else
m_dWindowRules.push_back({RULE, VALUE});
}
@@ -878,9 +977,10 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
const auto FLOATPOS = VALUE.find("floating:");
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
const auto PINNEDPOS = VALUE.find("pinned:");
const auto WORKSPACEPOS = VALUE.find("workspace:");
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos &&
PINNEDPOS == std::string::npos) {
PINNEDPOS == std::string::npos && WORKSPACEPOS == std::string::npos) {
Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str());
parseError = "Invalid rulev2 syntax: " + VALUE;
return;
@@ -903,6 +1003,8 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
min = FULLSCREENPOS;
if (PINNEDPOS > pos && PINNEDPOS < min)
min = PINNEDPOS;
if (WORKSPACEPOS > pos && WORKSPACEPOS < min)
min = PINNEDPOS;
result = result.substr(0, min - pos);
@@ -914,58 +1016,52 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
return result;
};
if (CLASSPOS != std::string::npos) {
if (CLASSPOS != std::string::npos)
rule.szClass = extract(CLASSPOS + 6);
}
if (TITLEPOS != std::string::npos) {
if (TITLEPOS != std::string::npos)
rule.szTitle = extract(TITLEPOS + 6);
}
if (X11POS != std::string::npos) {
if (X11POS != std::string::npos)
rule.bX11 = extract(X11POS + 9) == "1" ? 1 : 0;
}
if (FLOATPOS != std::string::npos) {
if (FLOATPOS != std::string::npos)
rule.bFloating = extract(FLOATPOS + 9) == "1" ? 1 : 0;
}
if (FULLSCREENPOS != std::string::npos) {
if (FULLSCREENPOS != std::string::npos)
rule.bFullscreen = extract(FULLSCREENPOS + 11) == "1" ? 1 : 0;
}
if (PINNEDPOS != std::string::npos) {
if (PINNEDPOS != std::string::npos)
rule.bPinned = extract(PINNEDPOS + 7) == "1" ? 1 : 0;
}
if (WORKSPACEPOS != std::string::npos)
rule.szWorkspace = extract(WORKSPACEPOS + 10);
if (RULE == "unset") {
std::erase_if(m_dWindowRules, [&](const SWindowRule& other) {
if (!other.v2) {
return other.szClass == rule.szClass && !rule.szClass.empty();
} else {
if (!rule.szClass.empty() && rule.szClass != other.szClass) {
if (!rule.szClass.empty() && rule.szClass != other.szClass)
return false;
}
if (!rule.szTitle.empty() && rule.szTitle != other.szTitle) {
if (!rule.szTitle.empty() && rule.szTitle != other.szTitle)
return false;
}
if (rule.bX11 != -1 && rule.bX11 != other.bX11) {
if (rule.bX11 != -1 && rule.bX11 != other.bX11)
return false;
}
if (rule.bFloating != -1 && rule.bFloating != other.bFloating) {
if (rule.bFloating != -1 && rule.bFloating != other.bFloating)
return false;
}
if (rule.bFullscreen != -1 && rule.bFullscreen != other.bFullscreen) {
if (rule.bFullscreen != -1 && rule.bFullscreen != other.bFullscreen)
return false;
}
if (rule.bPinned != -1 && rule.bPinned != other.bPinned) {
if (rule.bPinned != -1 && rule.bPinned != other.bPinned)
return false;
if (!rule.szWorkspace.empty() && rule.szWorkspace != other.szWorkspace)
return false;
}
return true;
}
@@ -973,6 +1069,9 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
return;
}
if (RULE.find("size") == 0 || RULE.find("maxsize") == 0 || RULE.find("minsize") == 0)
m_dWindowRules.push_front(rule);
else
m_dWindowRules.push_back(rule);
}
@@ -1033,12 +1132,12 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
}
wsRule.monitor = first_ident;
wsRule.workspaceString = wsIdent;
wsRule.isDefault = true; // backwards compat
rules = value.substr(WORKSPACE_DELIM + 1);
}
auto assignRule = [&](std::string rule) {
size_t delim = std::string::npos;
Debug::log(INFO, "found workspacerule: %s", rule.c_str());
if ((delim = rule.find("gapsin:")) != std::string::npos)
wsRule.gapsIn = std::stoi(rule.substr(delim + 7));
else if ((delim = rule.find("gapsout:")) != std::string::npos)
@@ -1047,12 +1146,16 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
wsRule.borderSize = std::stoi(rule.substr(delim + 11));
else if ((delim = rule.find("border:")) != std::string::npos)
wsRule.border = configStringToInt(rule.substr(delim + 7));
else if ((delim = rule.find("shadow:")) != std::string::npos)
wsRule.shadow = configStringToInt(rule.substr(delim + 7));
else if ((delim = rule.find("rounding:")) != std::string::npos)
wsRule.rounding = configStringToInt(rule.substr(delim + 9));
else if ((delim = rule.find("decorate:")) != std::string::npos)
wsRule.decorate = configStringToInt(rule.substr(delim + 9));
else if ((delim = rule.find("monitor:")) != std::string::npos)
wsRule.monitor = rule.substr(delim + 8);
else if ((delim = rule.find("default:")) != std::string::npos)
wsRule.isDefault = configStringToInt(rule.substr(delim + 8));
};
size_t pos = 0;
@@ -1066,7 +1169,13 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
wsRule.workspaceId = id;
wsRule.workspaceName = name;
m_mWorkspaceRules[id] = wsRule;
const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return other.workspaceString == wsRule.workspaceString; });
if (IT == m_dWorkspaceRules.end())
m_dWorkspaceRules.emplace_back(wsRule);
else
*IT = wsRule;
}
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
@@ -1131,16 +1240,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
}
void CConfigManager::handleBindWS(const std::string& command, const std::string& value) {
const auto ARGS = CVarList(value);
const auto FOUND = std::find_if(boundWorkspaces.begin(), boundWorkspaces.end(), [&](const auto& other) { return other.first == ARGS[0]; });
if (FOUND != boundWorkspaces.end()) {
FOUND->second = ARGS[1];
return;
}
boundWorkspaces.push_back({ARGS[0], ARGS[1]});
parseError = "bindws has been deprecated in favor of workspace rules, see the wiki -> workspace rules";
}
void CConfigManager::handleEnv(const std::string& command, const std::string& value) {
@@ -1376,56 +1476,57 @@ void CConfigManager::loadConfigLoadVars() {
configDynamicVars.clear();
deviceConfigs.clear();
m_dBlurLSNamespaces.clear();
boundWorkspaces.clear();
m_mWorkspaceRules.clear();
m_dWorkspaceRules.clear();
setDefaultAnimationVars(); // reset anims
m_vDeclaredPlugins.clear();
m_dLayerRules.clear();
m_vFailedPluginConfigValues.clear();
// paths
configPaths.clear();
std::string mainConfigPath = getMainConfigPath();
Debug::log(LOG, "Using config: %s", mainConfigPath.c_str());
configPaths.push_back(mainConfigPath);
std::string configPath = mainConfigPath.substr(0, mainConfigPath.find_last_of('/'));
// find_last_of never returns npos since main_config at least has /hypr/
std::string CONFIGPATH;
static const char* const ENVHOME = getenv("HOME");
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
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()) {
if (g_pCompositor->explicitConfigPath == "") {
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
if (!std::filesystem::is_directory(configPath)) {
Debug::log(WARN, "Creating config home directory");
try {
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
} catch (...) { /* Probably doesn't exist */
}
try {
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
std::filesystem::create_directories(CONFIGPARENTPATH);
std::filesystem::create_directories(configPath);
} catch (...) {
parseError = "Broken config file! (Could not create directory)";
parseError = "Broken config file! (Could not create config directory)";
return;
}
}
if (!std::filesystem::exists(mainConfigPath)) {
Debug::log(WARN, "No config file found; attempting to generate.");
std::ofstream ofs;
ofs.open(CONFIGPATH, std::ios::trunc);
ofs.open(mainConfigPath, std::ios::trunc);
ofs << AUTOCONFIG;
ofs.close();
}
std::ifstream ifs;
ifs.open(mainConfigPath);
if (!ifs.good()) {
Debug::log(WARN, "Config reading error. Attempting to generate, backing up old one if exists");
ifs.close();
if (std::filesystem::exists(mainConfigPath))
std::filesystem::rename(mainConfigPath, mainConfigPath + ".backup");
// Create default config
std::ofstream ofs;
ofs.open(mainConfigPath, std::ios::trunc);
ofs << AUTOCONFIG;
ofs.close();
ifs.open(CONFIGPATH);
// Try to re-open
ifs.open(mainConfigPath);
if (!ifs.good()) {
parseError = "Broken config file! (Could not open)";
return;
@@ -1438,17 +1539,17 @@ void CConfigManager::loadConfigLoadVars() {
while (std::getline(ifs, line)) {
// Read line by line.
try {
configCurrentPath = "~/.config/hypr/hyprland.conf";
configCurrentPath = mainConfigPath;
parseLine(line);
} catch (...) {
Debug::log(ERR, "Error reading line from config. Line:");
Debug::log(NONE, "%s", line.c_str());
parseError += "Config error at line " + std::to_string(linenum) + " (" + configCurrentPath + "): Line parsing error.";
parseError += "Config error at line " + std::to_string(linenum) + " (" + mainConfigPath + "): Line parsing error.";
}
if (parseError != "" && parseError.find("Config error at line") != 0) {
parseError = "Config error at line " + std::to_string(linenum) + " (" + configCurrentPath + "): " + parseError;
parseError = "Config error at line " + std::to_string(linenum) + " (" + mainConfigPath + "): " + parseError;
}
++linenum;
@@ -1472,10 +1573,10 @@ void CConfigManager::loadConfigLoadVars() {
g_pHyprOpenGL->m_bReloadScreenShader = true;
// parseError will be displayed next frame
if (parseError != "")
if (parseError != "" && !configValues["debug:suppress_errors"].intValue)
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
else if (configValues["autogenerated"].intValue == 1)
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Q -> kitty\nSUPER+M -> exit Hyprland",
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + mainConfigPath + " )\nSUPER+Q -> kitty\nSUPER+M -> exit Hyprland",
CColor(1.0, 1.0, 70.0 / 255.0, 1.0));
else
g_pHyprError->destroy();
@@ -1491,6 +1592,15 @@ void CConfigManager::loadConfigLoadVars() {
ensureVRR();
}
// Updates dynamic window and workspace rules
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped)
continue;
w->updateDynamicRules();
w->updateSpecialRenderData();
}
// Update window border colors
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
@@ -1514,6 +1624,8 @@ void CConfigManager::loadConfigLoadVars() {
// mark blur dirty
g_pHyprOpenGL->markBlurDirtyForMonitor(m.get());
g_pCompositor->scheduleFrameForMonitor(m.get());
// Force the compositor to fully re-render all monitors
m->forceFullFrames = 2;
}
@@ -1523,17 +1635,12 @@ void CConfigManager::loadConfigLoadVars() {
// update plugins
handlePluginLoads();
EMIT_HOOK_EVENT("configReloaded", nullptr);
}
void CConfigManager::tick() {
std::string CONFIGPATH;
if (g_pCompositor->explicitConfigPath.empty()) {
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;
}
std::string CONFIGPATH = getMainConfigPath();
if (!std::filesystem::exists(CONFIGPATH)) {
Debug::log(ERR, "Config doesn't exist??");
return;
@@ -1572,7 +1679,7 @@ SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) {
return copy;
}
SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) {
SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val, std::optional<bool> touchpad) {
std::lock_guard<std::mutex> lg(configmtx);
const auto it = deviceConfigs.find(dev);
@@ -1591,8 +1698,8 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co
if (foundIt == std::string::npos)
continue;
if (cv.first == "input:" + val || cv.first == "input:touchpad:" + cv.first || cv.first == "input:touchdevice:" + val || cv.first == "input:tablet:" + cv.first ||
cv.first == "input:tablet:" + val) {
if (cv.first == "input:" + val || (touchpad.value_or(true) && cv.first == "input:touchpad:" + val) || cv.first == "input:touchdevice:" + val ||
cv.first == "input:tablet:" + val || cv.first == "input:tablet:" + val) {
copy = cv.second;
}
}
@@ -1618,16 +1725,16 @@ std::string CConfigManager::getString(const std::string& v) {
return VAL;
}
int CConfigManager::getDeviceInt(const std::string& dev, const std::string& v) {
return getConfigValueSafeDevice(dev, v).intValue;
int CConfigManager::getDeviceInt(const std::string& dev, const std::string& v, std::optional<bool> touchpad) {
return getConfigValueSafeDevice(dev, v, touchpad).intValue;
}
float CConfigManager::getDeviceFloat(const std::string& dev, const std::string& v) {
return getConfigValueSafeDevice(dev, v).floatValue;
float CConfigManager::getDeviceFloat(const std::string& dev, const std::string& v, std::optional<bool> touchpad) {
return getConfigValueSafeDevice(dev, v, touchpad).floatValue;
}
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v) {
auto VAL = getConfigValueSafeDevice(dev, v).strValue;
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v, std::optional<bool> touchpad) {
auto VAL = getConfigValueSafeDevice(dev, v, touchpad).strValue;
if (VAL == STRVAL_EMPTY)
return "";
@@ -1676,18 +1783,14 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const std::string& name, const st
Debug::log(WARN, "No rules configured. Using the default hardcoded one.");
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-1, -1), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-INT32_MAX, -INT32_MAX), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
}
SWorkspaceRule CConfigManager::getWorkspaceRuleFor(CWorkspace* pWorkspace) {
if (m_mWorkspaceRules.contains(pWorkspace->m_iID)) {
return m_mWorkspaceRules.at(pWorkspace->m_iID);
}
const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.workspaceName == pWorkspace->m_szName; });
if (IT == m_mWorkspaceRules.end())
const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return other.workspaceName == pWorkspace->m_szName; });
if (IT == m_dWorkspaceRules.end())
return SWorkspaceRule{};
return IT->second;
return *IT;
}
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
@@ -1701,6 +1804,10 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
Debug::log(LOG, "Searching for matching rules for %s (title: %s)", appidclass.c_str(), title.c_str());
// since some rules will be applied later, we need to store some flags
bool hasFloating = pWindow->m_bIsFloating;
bool hasFullscreen = pWindow->m_bIsFullscreen;
for (auto& rule : m_dWindowRules) {
// check if we have a matching rule
if (!rule.v2) {
@@ -1743,12 +1850,12 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
}
if (rule.bFloating != -1) {
if (pWindow->m_bIsFloating != rule.bFloating)
if (hasFloating != rule.bFloating)
continue;
}
if (rule.bFullscreen != -1) {
if (pWindow->m_bIsFullscreen != rule.bFullscreen)
if (hasFullscreen != rule.bFullscreen)
continue;
}
@@ -1756,8 +1863,29 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
if (pWindow->m_bPinned != rule.bPinned)
continue;
}
} catch (...) {
Debug::log(ERR, "Regex error at %s", rule.szValue.c_str());
if (!rule.szWorkspace.empty()) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (!PWORKSPACE)
continue;
if (rule.szWorkspace.find("name:") == 0) {
if (PWORKSPACE->m_szName != rule.szWorkspace.substr(5))
continue;
} else {
// number
if (!isNumber(rule.szWorkspace))
throw std::runtime_error("szWorkspace not name: or number");
const int64_t ID = std::stoll(rule.szWorkspace);
if (PWORKSPACE->m_iID != ID)
continue;
}
}
} catch (std::exception& e) {
Debug::log(ERR, "Regex error at %s (%s)", rule.szValue.c_str(), e.what());
continue;
}
}
@@ -1766,6 +1894,11 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
Debug::log(LOG, "Window rule %s -> %s matched %lx [%s]", rule.szRule.c_str(), rule.szValue.c_str(), pWindow, pWindow->m_szTitle.c_str());
returns.push_back(rule);
if (rule.szRule == "float")
hasFloating = true;
else if (rule.szRule == "fullscreen")
hasFullscreen = true;
}
std::vector<uint64_t> PIDs = {(uint64_t)pWindow->getPID()};
@@ -1879,6 +2012,8 @@ void CConfigManager::performMonitorReload() {
g_pCompositor->m_bUnsafeState = false;
m_bWantsMonitorReload = false;
EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr);
}
SConfigValue* CConfigManager::getConfigValuePtr(const std::string& val) {
@@ -1943,7 +2078,9 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
if (!m->output)
return;
if (*PVRR == 0) {
const auto USEVRR = m->activeMonitorRule.vrr.has_value() ? m->activeMonitorRule.vrr.value() : *PVRR;
if (USEVRR == 0) {
if (m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 0);
@@ -1953,7 +2090,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
}
m->vrrActive = false;
return;
} else if (*PVRR == 1) {
} else if (USEVRR == 1) {
if (!m->vrrActive) {
wlr_output_enable_adaptive_sync(m->output, 1);
@@ -1968,7 +2105,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
}
m->vrrActive = true;
return;
} else if (*PVRR == 2) {
} else if (USEVRR == 2) {
/* fullscreen */
m->vrrActive = true;
@@ -2020,29 +2157,29 @@ void CConfigManager::addParseError(const std::string& err) {
}
CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
for (auto& [ws, mon] : boundWorkspaces) {
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
if (WSNAME == wsname) {
return g_pCompositor->getMonitorFromString(mon);
}
}
return nullptr;
auto monitor = getBoundMonitorStringForWS(wsname);
if (monitor.substr(0, 5) == "desc:")
return g_pCompositor->getMonitorFromDesc(monitor.substr(5));
else
return g_pCompositor->getMonitorFromName(monitor);
}
std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) {
for (auto& [ws, mon] : boundWorkspaces) {
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
for (auto& wr : m_dWorkspaceRules) {
const auto WSNAME = wr.workspaceName.find("name:") == 0 ? wr.workspaceName.substr(5) : wr.workspaceName;
if (WSNAME == wsname) {
return mon;
return wr.monitor;
}
}
return "";
}
const std::deque<SWorkspaceRule>& CConfigManager::getAllWorkspaceRules() {
return m_dWorkspaceRules;
}
void CConfigManager::addExecRule(const SExecRequestedRule& rule) {
execRequestedRules.push_back(rule);
}
@@ -2090,6 +2227,11 @@ void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name,
}
(*CONFIGMAPIT->second)[name] = value;
if (const auto IT = std::find_if(m_vFailedPluginConfigValues.begin(), m_vFailedPluginConfigValues.end(), [&](const auto& other) { return other.first == name; });
IT != m_vFailedPluginConfigValues.end()) {
configSetValueSafe(IT->first, IT->second);
}
}
void CConfigManager::removePluginConfig(HANDLE handle) {
@@ -2097,8 +2239,16 @@ void CConfigManager::removePluginConfig(HANDLE handle) {
}
std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.monitor == name; });
if (IT == m_mWorkspaceRules.end())
for (auto other = m_dWorkspaceRules.begin(); other != m_dWorkspaceRules.end(); ++other) {
if (other->isDefault) {
if (other->monitor == name)
return other->workspaceString;
if (other->monitor.substr(0, 5) == "desc:") {
auto monitor = g_pCompositor->getMonitorFromDesc(other->monitor.substr(5));
if (monitor && monitor->szName == name)
return other->workspaceString;
}
}
}
return "";
return IT->second.workspaceString;
}

View File

@@ -11,8 +11,10 @@
#include <algorithm>
#include <regex>
#include <optional>
#include <xf86drmMode.h>
#include "../Window.hpp"
#include "../helpers/WLClasses.hpp"
#include "../helpers/Monitor.hpp"
#include "defaultConfig.hpp"
#include "ConfigDataValues.hpp"
@@ -34,29 +36,19 @@ struct SConfigValue {
bool set = false; // used for device configs
};
struct SMonitorRule {
std::string name = "";
Vector2D resolution = Vector2D(1280, 720);
Vector2D offset = Vector2D(0, 0);
float scale = 1;
float refreshRate = 60;
bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
bool enable10bit = false;
};
struct SWorkspaceRule {
std::string monitor = "";
std::string workspaceString = "";
std::string workspaceName = "";
int workspaceId = -1;
bool isDefault = false;
std::optional<int64_t> gapsIn;
std::optional<int64_t> gapsOut;
std::optional<int64_t> borderSize;
std::optional<int> border;
std::optional<int> rounding;
std::optional<int> decorate;
std::optional<int> shadow;
};
struct SMonitorAdditionalReservedArea {
@@ -85,12 +77,23 @@ struct SExecRequestedRule {
class CVarList {
public:
/* passing 's' as a separator will use std::isspace */
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
std::string curitem = "";
std::string argZ = in;
const bool SPACESEP = separator == 's';
auto nextItem = [&]() {
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator);
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : ([&]() -> size_t {
if (!SPACESEP)
return argZ.find_first_of(separator);
uint64_t pos = -1;
while (!std::isspace(argZ[++pos]) && pos < argZ.length())
;
return pos < argZ.length() ? pos : std::string::npos;
}());
if (idx != std::string::npos) {
curitem = argZ.substr(0, idx);
@@ -153,14 +156,16 @@ class CConfigManager {
void setInt(const std::string&, int);
void setString(const std::string&, const std::string&);
int getDeviceInt(const std::string&, const std::string&);
float getDeviceFloat(const std::string&, const std::string&);
std::string getDeviceString(const std::string&, const std::string&);
int getDeviceInt(const std::string&, const std::string&, std::optional<bool> touchpad = {});
float getDeviceFloat(const std::string&, const std::string&, std::optional<bool> touchpad = {});
std::string getDeviceString(const std::string&, const std::string&, std::optional<bool> touchpad = {});
bool deviceConfigExists(const std::string&);
bool shouldBlurLS(const std::string&);
SConfigValue* getConfigValuePtr(const std::string&);
SConfigValue* getConfigValuePtrSafe(const std::string&);
static std::string getConfigDir();
static std::string getMainConfigPath();
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
SWorkspaceRule getWorkspaceRuleFor(CWorkspace*);
@@ -168,6 +173,7 @@ class CConfigManager {
CMonitor* getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&);
const std::deque<SWorkspaceRule>& getAllWorkspaceRules();
std::vector<SWindowRule> getMatchingRules(CWindow*);
std::vector<SLayerRule> getMatchingRules(SLayerSurface*);
@@ -216,8 +222,6 @@ class CConfigManager {
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
std::vector<std::pair<std::string, std::string>> boundWorkspaces;
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
std::vector<std::string> m_vDeclaredPlugins;
@@ -226,7 +230,7 @@ class CConfigManager {
bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules;
std::unordered_map<int, SWorkspaceRule> m_mWorkspaceRules;
std::deque<SWorkspaceRule> m_dWorkspaceRules;
std::deque<SWindowRule> m_dWindowRules;
std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
@@ -237,6 +241,8 @@ class CConfigManager {
std::vector<std::pair<std::string, std::string>> environmentVariables;
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
// internal methods
void setDefaultVars();
void setDefaultAnimationVars();
@@ -249,7 +255,7 @@ class CConfigManager {
void applyUserDefinedVars(std::string&, const size_t);
void loadConfigLoadVars();
SConfigValue getConfigValueSafe(const std::string&);
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&);
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&, std::optional<bool> touchpad);
void parseLine(std::string&);
void configSetValueSafe(const std::string&, const std::string&);
void handleDeviceConfig(const std::string&, const std::string&);

View File

@@ -64,10 +64,12 @@ decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 10
blur = yes
blur_size = 3
blur_passes = 1
blur_new_optimizations = on
blur {
enabled = true
size = 3
passes = 1
}
drop_shadow = yes
shadow_range = 4

View File

@@ -25,7 +25,8 @@ std::string getRandomMessage() {
"*thud*",
"Well this is awkward.",
"\"stable\"",
"I hope you didn't have any unsaved progress."};
"I hope you didn't have any unsaved progress.",
"All these computers..."};
std::random_device dev;
std::mt19937 engine(dev());
@@ -46,7 +47,7 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += getFormat("Hyprland received signal %d (%s)\n\n", sig, strsignal(sig));
finalCrashReport += getFormat("Version: %s\n\n", GIT_COMMIT_HASH);
finalCrashReport += getFormat("Version: %s\nTag: %s\n\n", GIT_COMMIT_HASH, GIT_TAG);
if (g_pPluginSystem && !g_pPluginSystem->getAllPlugins().empty()) {
finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n";
@@ -78,12 +79,7 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "Backtrace:\n";
void* bt[1024];
size_t btSize;
char** btSymbols;
btSize = backtrace(bt, 1024);
btSymbols = backtrace_symbols(bt, btSize);
const auto CALLSTACK = getBacktrace();
#if defined(KERN_PROC_PATHNAME)
int mib[] = {
@@ -110,20 +106,18 @@ void CrashReporter::createAndSaveCrash(int sig) {
const auto FPATH = std::filesystem::canonical("/proc/self/exe");
#endif
for (size_t i = 0; i < btSize; ++i) {
finalCrashReport += getFormat("\t#%lu | %s\n", i, btSymbols[i]);
for (size_t i = 0; i < CALLSTACK.size(); ++i) {
finalCrashReport += getFormat("\t#%lu | %s\n", i, CALLSTACK[i].desc.c_str());
#ifdef __clang__
const auto CMD = getFormat("llvm-addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)bt[i]);
const auto CMD = getFormat("llvm-addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)CALLSTACK[i].adr);
#else
const auto CMD = getFormat("addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)bt[i]);
const auto CMD = getFormat("addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)CALLSTACK[i].adr);
#endif
const auto ADDR2LINE = replaceInString(execAndGet(CMD.c_str()), "\n", "\n\t\t");
finalCrashReport += "\t\t" + ADDR2LINE.substr(0, ADDR2LINE.length() - 2);
}
free(btSymbols);
finalCrashReport += "\n\nLog tail:\n";
finalCrashReport += execAndGet(("cat \"" + Debug::logFile + "\" | tail -n 50").c_str());

View File

@@ -14,6 +14,20 @@
#include <sstream>
#include <string>
static void trimTrailingComma(std::string& str) {
if (!str.empty() && str.back() == ',')
str.pop_back();
}
static std::string getWorkspaceNameFromSpecialID(const int workspaceID) {
if (workspaceID == 0)
return "";
const auto* workspace = g_pCompositor->getWorkspaceByID(workspaceID);
if (!workspace)
return "";
return workspace->m_szName;
}
std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string result = "";
if (format == HyprCtl::FORMAT_JSON) {
@@ -40,6 +54,10 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
"id": %i,
"name": "%s"
},
"specialWorkspace": {
"id": %i,
"name": "%s"
},
"reserved": [%i, %i, %i, %i],
"scale": %.2f,
"transform": %i,
@@ -50,13 +68,13 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
m->ID, escapeJSONStrings(m->szName).c_str(), escapeJSONStrings(m->output->description ? m->output->description : "").c_str(),
(m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""), (m->output->serial ? m->output->serial : ""), (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,
escapeJSONStrings(g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName).c_str(), m->specialWorkspaceID,
escapeJSONStrings(getWorkspaceNameFromSpecialID(m->specialWorkspaceID)).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"),
(m->dpmsStatus ? "true" : "false"), (m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED ? "true" : "false"));
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "]";
} else {
@@ -64,14 +82,16 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
if (!m->output)
continue;
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tmake: %s\n\tmodel: %s\n\tserial: %s\n\tactive workspace: %i (%s)\n\treserved: %i "
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tmake: %s\n\tmodel: %s\n\tserial: %s\n\tactive workspace: %i (%s)\n\tspecial "
"workspace: %i (%s)\n\treserved: %i "
"%i %i %i\n\tscale: %.2f\n\ttransform: "
"%i\n\tfocused: %s\n\tdpmsStatus: %i\n\tvrr: %i\n\n",
m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y,
(m->output->description ? m->output->description : ""), (m->output->make ? m->output->make : ""), (m->output->model ? m->output->model : ""),
(m->output->serial ? m->output->serial : ""), m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(),
(int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale,
(int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus,
m->specialWorkspaceID, getWorkspaceNameFromSpecialID(m->specialWorkspaceID).c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y,
(int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform,
(m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus,
(int)(m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED));
}
}
@@ -175,9 +195,7 @@ std::string clientsRequest(HyprCtl::eHyprCtlOutputFormat format) {
result += getWindowData(w.get(), format);
}
// remove trailing comma
if (result != "[")
result.pop_back();
trimTrailingComma(result);
result += "]";
} else {
@@ -227,7 +245,7 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) {
result += ",";
}
result.pop_back();
trimTrailingComma(result);
result += "]";
} else {
for (auto& w : g_pCompositor->m_vWorkspaces) {
@@ -285,8 +303,7 @@ std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
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();
trimTrailingComma(result);
if (level.size() > 0)
result += "\n ";
@@ -296,14 +313,12 @@ std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
layerLevel++;
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "\n }\n},";
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "\n}\n";
@@ -347,8 +362,7 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f);
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "\n],\n";
result += "\"keyboards\": [\n";
@@ -371,8 +385,7 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
escapeJSONStrings(KM).c_str(), (k.active ? "true" : "false"));
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "\n],\n";
result += "\"tablets\": [\n";
@@ -409,8 +422,7 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
&d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
}
// remove trailing comma
result.pop_back();
trimTrailingComma(result);
result += "\n],\n";
result += "\"touch\": [\n";
@@ -424,9 +436,7 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
&d, d.name.c_str());
}
// remove trailing comma
if (result[result.size() - 1] == ',')
result.pop_back();
trimTrailingComma(result);
result += "\n],\n";
result += "\"switches\": [\n";
@@ -440,9 +450,7 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
&d, d.pWlrDevice ? d.pWlrDevice->name : "");
}
// remove trailing comma
if (result[result.size() - 1] == ',')
result.pop_back();
trimTrailingComma(result);
result += "\n]\n";
result += "}\n";
@@ -540,7 +548,7 @@ std::string animationsRequest(HyprCtl::eHyprCtlOutputFormat format) {
bz.first.c_str());
}
ret.pop_back();
trimTrailingComma(ret);
ret += "]]";
}
@@ -564,7 +572,7 @@ std::string globalShortcutsRequest(HyprCtl::eHyprCtlOutputFormat format) {
},)#",
escapeJSONStrings(sh.appid + ":" + sh.id).c_str(), escapeJSONStrings(sh.description).c_str());
}
ret.pop_back();
trimTrailingComma(ret);
ret += "]\n";
}
@@ -584,6 +592,8 @@ std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
ret += "r";
if (kb.repeat)
ret += "e";
if (kb.nonConsuming)
ret += "n";
ret += getFormat("\n\tmodmask: %u\n\tsubmap: %s\n\tkey: %s\n\tkeycode: %d\n\tdispatcher: %s\n\targ: %s\n\n", kb.modmask, kb.submap.c_str(), kb.key.c_str(), kb.keycode,
kb.handler.c_str(), kb.arg.c_str());
@@ -599,6 +609,7 @@ std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
"mouse": %s,
"release": %s,
"repeat": %s,
"non_consuming": %s,
"modmask": %u,
"submap": "%s",
"key": "%s",
@@ -606,10 +617,11 @@ std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
"dispatcher": "%s",
"arg": "%s"
},)#",
kb.locked ? "true" : "false", kb.mouse ? "true" : "false", kb.release ? "true" : "false", kb.repeat ? "true" : "false", kb.modmask,
escapeJSONStrings(kb.submap).c_str(), escapeJSONStrings(kb.key).c_str(), kb.keycode, escapeJSONStrings(kb.handler).c_str(), escapeJSONStrings(kb.arg).c_str());
kb.locked ? "true" : "false", kb.mouse ? "true" : "false", kb.release ? "true" : "false", kb.repeat ? "true" : "false", kb.nonConsuming ? "true" : "false",
kb.modmask, escapeJSONStrings(kb.submap).c_str(), escapeJSONStrings(kb.key).c_str(), kb.keycode, escapeJSONStrings(kb.handler).c_str(),
escapeJSONStrings(kb.arg).c_str());
}
ret.pop_back();
trimTrailingComma(ret);
ret += "]";
}
@@ -618,9 +630,12 @@ std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
auto commitMsg = removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE);
std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
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() + ").\nTag: " + GIT_TAG + "\n\nflags: (if any)\n";
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + " " + GIT_DIRTY + " (" + commitMsg +
").\nTag: " + GIT_TAG + "\n\nflags: (if any)\n";
#ifdef LEGACY_RENDERER
result += "legacyrenderer\n";
@@ -643,8 +658,9 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
"commit": "%s",
"dirty": %s,
"commit_message": "%s",
"tag": "%s",
"flags": [)#",
GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str());
GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg).c_str(), GIT_TAG);
#ifdef LEGACY_RENDERER
result += "\"legacyrenderer\",";
@@ -659,8 +675,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
result += "\"no xwayland\",";
#endif
if (result[result.length() - 1] == ',')
result.pop_back();
trimTrailingComma(result);
result += "]\n}";
@@ -676,7 +691,9 @@ std::string dispatchRequest(std::string in) {
const auto DISPATCHSTR = in.substr(0, in.find_first_of(' '));
const auto DISPATCHARG = in.substr(in.find_first_of(' ') + 1);
auto DISPATCHARG = std::string();
if ((int)in.find_first_of(' ') != -1)
DISPATCHARG = in.substr(in.find_first_of(' ') + 1);
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(DISPATCHSTR);
if (DISPATCHER == g_pKeybindManager->m_mDispatchers.end())
@@ -722,7 +739,7 @@ std::string dispatchKeyword(std::string in) {
}
// decorations will probably need a repaint
if (COMMAND.contains("decoration:") || COMMAND.contains("border")) {
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("cursor_zoom_factor")) {
for (auto& m : g_pCompositor->m_vMonitors) {
g_pHyprRenderer->damageMonitor(m.get());
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
@@ -961,6 +978,8 @@ std::string dispatchSetProp(std::string request) {
PWINDOW->m_sAdditionalConfigData.forceNoBorder.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "forcenoshadow") {
PWINDOW->m_sAdditionalConfigData.forceNoShadow.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "forcenodim") {
PWINDOW->m_sAdditionalConfigData.forceNoDim.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "windowdancecompat") {
PWINDOW->m_sAdditionalConfigData.windowDanceCompat.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "nomaxsize") {
@@ -981,6 +1000,10 @@ std::string dispatchSetProp(std::string request) {
PWINDOW->m_sSpecialRenderData.inactiveBorderColor.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "forcergbx") {
PWINDOW->m_sAdditionalConfigData.forceRGBX.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "bordersize") {
PWINDOW->m_sSpecialRenderData.borderSize.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else if (PROP == "keepaspectratio") {
PWINDOW->m_sAdditionalConfigData.keepAspectRatio.forceSetIgnoreLocked(configStringToInt(VAL), lock);
} else {
return "prop not found";
}
@@ -988,6 +1011,9 @@ std::string dispatchSetProp(std::string request) {
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
for (auto& m : g_pCompositor->m_vMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
return "ok";
}
@@ -1287,10 +1313,21 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
sockaddr_in clientAddress;
socklen_t clientSize = sizeof(clientAddress);
const auto ACCEPTEDCONNECTION = accept(HyprCtl::iSocketFD, (sockaddr*)&clientAddress, &clientSize);
const auto ACCEPTEDCONNECTION = accept4(HyprCtl::iSocketFD, (sockaddr*)&clientAddress, &clientSize, SOCK_CLOEXEC);
char readBuffer[1024];
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(ACCEPTEDCONNECTION, &fdset);
timeval timeout = {.tv_sec = 0, .tv_usec = 5000};
auto success = select(ACCEPTEDCONNECTION + 1, &fdset, nullptr, nullptr, &timeout);
if (success <= 0) {
close(ACCEPTEDCONNECTION);
return 0;
}
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';
@@ -1318,7 +1355,7 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
void HyprCtl::startHyprCtlSocket() {
iSocketFD = socket(AF_UNIX, SOCK_STREAM, 0);
iSocketFD = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (iSocketFD < 0) {
Debug::log(ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work.");

View File

@@ -33,6 +33,9 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
if (disableLogs && *disableLogs)
return;
if (level == TRACE && !trace)
return;
// log to a file
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
@@ -43,6 +46,7 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
case ERR: ofs << "[ERR] "; break;
case CRIT: ofs << "[CRITICAL] "; break;
case INFO: ofs << "[INFO] "; break;
case TRACE: ofs << "[TRACE] "; break;
default: break;
}

View File

@@ -4,14 +4,14 @@
#define LOGMESSAGESIZE 1024
enum LogLevel
{
enum LogLevel {
NONE = -1,
LOG = 0,
WARN,
ERR,
CRIT,
INFO
INFO,
TRACE
};
namespace Debug {
@@ -23,4 +23,5 @@ namespace Debug {
inline int64_t* disableLogs = nullptr;
inline int64_t* disableTime = nullptr;
inline bool disableStdout = false;
inline bool trace = false;
};

View File

@@ -0,0 +1,35 @@
#pragma once
#ifdef USE_TRACY_GPU
#include "Log.hpp"
#include <GL/gl.h>
#include <GLES2/gl2ext.h>
inline PFNGLQUERYCOUNTEREXTPROC glQueryCounter;
inline PFNGLGETQUERYOBJECTIVEXTPROC glGetQueryObjectiv;
inline PFNGLGETQUERYOBJECTUI64VEXTPROC glGetQueryObjectui64v;
#include "../../subprojects/tracy/public/tracy/TracyOpenGL.hpp"
inline void loadGLProc(void* pProc, const char* name) {
void* proc = (void*)eglGetProcAddress(name);
if (proc == NULL) {
Debug::log(CRIT, "[Tracy GPU Profiling] eglGetProcAddress(%s) failed", name);
abort();
}
*(void**)pProc = proc;
}
#define TRACY_GPU_CONTEXT TracyGpuContext
#define TRACY_GPU_ZONE(e) TracyGpuZone(e)
#define TRACY_GPU_COLLECT TracyGpuCollect
#else
#define TRACY_GPU_CONTEXT
#define TRACY_GPU_ZONE(e)
#define TRACY_GPU_COLLECT
#endif

View File

@@ -1,95 +1,5 @@
#include "includes.hpp"
#include "debug/Log.hpp"
#include "helpers/MiscFunctions.hpp"
#include "helpers/WLListener.hpp"
#include "helpers/Color.hpp"
#include "wlrunstable/wlr_ext_workspace_v1.hpp"
#include <utility>
#ifndef NDEBUG
#ifdef HYPRLAND_DEBUG
#define ISDEBUG true
#else
#define ISDEBUG false
#endif
#else
#define ISDEBUG false
#endif
#define LISTENER(name) \
void listener_##name(wl_listener*, void*); \
inline wl_listener listen_##name = {.notify = listener_##name}
#define DYNLISTENFUNC(name) void listener_##name(void*, void*)
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name
#define DYNMULTILISTENER(name) wl_listener listen_##name
#define VECINRECT(vec, x1, y1, x2, y2) ((vec).x >= (x1) && (vec).x <= (x2) && (vec).y >= (y1) && (vec).y <= (y2))
#define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < (delta))
#define PIXMAN_DAMAGE_FOREACH(region) \
int rectsNum = 0; \
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
for (int i = 0; i < rectsNum; ++i)
#define PIXMAN_REGION_FOREACH(region) PIXMAN_DAMAGE_FOREACH(region)
#define interface class
#define STICKS(a, b) abs((a) - (b)) < 2
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
#define HYPRATOM(name) \
{ name, 0 }
#ifndef __INTELLISENSE__
#define RASSERT(expr, reason, ...) \
if (!(expr)) { \
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \
getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \
([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
*((int*)nullptr) = 1; /* so that we crash and get a coredump */ \
}
#else
#define RASSERT(expr, reason, ...)
#endif
#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 "?"
#endif
#ifndef GIT_BRANCH
#define GIT_BRANCH "?"
#endif
#ifndef GIT_COMMIT_MESSAGE
#define GIT_COMMIT_MESSAGE "?"
#endif
#ifndef GIT_DIRTY
#define GIT_DIRTY "?"
#endif
#ifndef GIT_TAG
#define GIT_TAG "?"
#endif
#define SPECIAL_WORKSPACE_START (-99)
#define PI 3.14159265358979
#include "macros.hpp"

View File

@@ -122,19 +122,8 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (PWINDOW && PCONSTRAINT->positionHint != Vector2D{-1, -1}) {
if (PWINDOW->m_bIsX11) {
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_uSurface.xwayland->x,
PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->positionHint.y);
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
} else {
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_vRealPosition.vec().x,
PCONSTRAINT->positionHint.y + PWINDOW->m_vRealPosition.vec().y);
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
}
}
if (PWINDOW && PCONSTRAINT->positionHint != Vector2D{-1, -1})
g_pInputManager->warpMouseToConstraintMiddle(PCONSTRAINT);
PCONSTRAINT->pMouse->currentConstraint = nullptr;
}

View File

@@ -39,6 +39,7 @@ namespace Events {
DYNLISTENFUNC(destroyPopupXDG);
DYNLISTENFUNC(commitPopupXDG);
DYNLISTENFUNC(newPopupFromPopupXDG);
DYNLISTENFUNC(repositionPopupXDG);
// Surface XDG (window)
LISTENER(newXDGSurface);
@@ -59,6 +60,8 @@ namespace Events {
DYNLISTENFUNC(requestMinimize);
DYNLISTENFUNC(requestMaximize);
DYNLISTENFUNC(setOverrideRedirect);
DYNLISTENFUNC(associateX11);
DYNLISTENFUNC(dissociateX11);
// Window subsurfaces
// LISTENER(newSubsurfaceWindow);
@@ -101,6 +104,7 @@ namespace Events {
DYNLISTENFUNC(monitorDamage);
DYNLISTENFUNC(monitorNeedsFrame);
DYNLISTENFUNC(monitorCommit);
DYNLISTENFUNC(monitorBind);
// XWayland
LISTENER(readyXWayland);
@@ -164,4 +168,10 @@ namespace Events {
// Session Lock
LISTENER(newSessionLock);
// Gamma control
LISTENER(setGamma);
// Cursor shape
LISTENER(setCursorShape);
};

View File

@@ -44,8 +44,8 @@ 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->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_mapLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.map, &Events::listener_mapLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_unmapLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.unmap, &Events::listener_unmapLayerSurface, layerSurface, "layerSurface");
layerSurface->hyprListener_newPopup.initCallback(&WLRLAYERSURFACE->events.new_popup, &Events::listener_newPopup, layerSurface, "layerSurface");
layerSurface->layerSurface = WLRLAYERSURFACE;
@@ -109,9 +109,8 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
Debug::log(LOG, "LayerSurface %lx mapped", layersurface->layerSurface);
layersurface->layerSurface->mapped = true;
layersurface->mapped = true;
layersurface->keyboardExclusive = layersurface->layerSurface->current.keyboard_interactive;
layersurface->surface = layersurface->layerSurface->surface;
// anim
@@ -143,8 +142,11 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
if (layersurface->layerSurface->current.keyboard_interactive &&
(!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
const bool GRABSFOCUS = layersurface->layerSurface->current.keyboard_interactive &&
// don't focus if constrained
(!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint);
if (GRABSFOCUS) {
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
const auto LOCAL =
@@ -158,9 +160,11 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
layersurface->geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
const auto WORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
const bool FULLSCREEN = WORKSPACE->m_bHasFullscreenWindow && WORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
layersurface->alpha.setValue(0);
layersurface->alpha = 1.f;
layersurface->alpha = ((layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS) ? 0.f : 1.f);
layersurface->readyToDelete = false;
layersurface->fadingOut = false;
@@ -204,9 +208,6 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
g_pCompositor->addToFadingOutSafe(layersurface);
if (layersurface->layerSurface->mapped)
layersurface->layerSurface->mapped = false;
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
const bool WASLASTFOCUS = g_pCompositor->m_pLastFocus == layersurface->layerSurface->surface;
@@ -323,6 +324,22 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
}
}
if (layersurface->layerSurface->current.keyboard_interactive &&
(!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint) // don't focus if constrained
&& !layersurface->keyboardExclusive && layersurface->mapped) {
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
const auto LOCAL =
g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
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);
} else if (!layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint) &&
layersurface->keyboardExclusive) {
g_pInputManager->refocus();
}
layersurface->keyboardExclusive = layersurface->layerSurface->current.keyboard_interactive;
g_pHyprRenderer->damageSurface(layersurface->layerSurface->surface, layersurface->position.x, layersurface->position.y);
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale);

View File

@@ -110,8 +110,8 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
g_pInputManager->m_sDrag.dragIcon = wlrDrag->icon;
wlrDrag->icon->data = g_pInputManager->m_sDrag.dragIcon;
g_pInputManager->m_sDrag.hyprListener_mapIcon.initCallback(&wlrDrag->icon->events.map, &Events::listener_mapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
g_pInputManager->m_sDrag.hyprListener_unmapIcon.initCallback(&wlrDrag->icon->events.unmap, &Events::listener_unmapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
g_pInputManager->m_sDrag.hyprListener_mapIcon.initCallback(&wlrDrag->icon->surface->events.map, &Events::listener_mapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
g_pInputManager->m_sDrag.hyprListener_unmapIcon.initCallback(&wlrDrag->icon->surface->events.unmap, &Events::listener_unmapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
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");
@@ -214,3 +214,26 @@ void Events::listener_newSessionLock(wl_listener* listener, void* data) {
g_pSessionLockManager->onNewSessionLock((wlr_session_lock_v1*)data);
}
void Events::listener_setGamma(wl_listener* listener, void* data) {
Debug::log(LOG, "New Gamma event at %lx", data);
const auto E = (wlr_gamma_control_manager_v1_set_gamma_event*)data;
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(E->output);
if (!PMONITOR) {
Debug::log(ERR, "Gamma event object references non-existent output %lx ?", E->output);
return;
}
PMONITOR->gammaChanged = true;
g_pCompositor->scheduleFrameForMonitor(PMONITOR);
}
void Events::listener_setCursorShape(wl_listener* listener, void* data) {
const auto E = (wlr_cursor_shape_manager_v1_request_set_shape_event*)data;
g_pInputManager->processMouseRequest(E);
}

View File

@@ -28,7 +28,6 @@ void Events::listener_change(wl_listener* listener, void* data) {
const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output);
// TODO: clients off of disabled
wlr_box BOX;
wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m->output, &BOX);
@@ -77,7 +76,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
Debug::log(LOG, "Adding completely new monitor.");
PNEWMONITORWRAP = &g_pCompositor->m_vRealMonitors.emplace_back(std::make_shared<CMonitor>());
(*PNEWMONITORWRAP)->ID = g_pCompositor->getNextAvailableMonitorID();
(*PNEWMONITORWRAP)->ID = g_pCompositor->getNextAvailableMonitorID(OUTPUT->name);
}
const auto PNEWMONITOR = PNEWMONITORWRAP->get();
@@ -218,5 +217,12 @@ void Events::listener_monitorCommit(void* owner, void* data) {
const auto E = (wlr_output_event_commit*)data;
if (E->committed & WLR_OUTPUT_STATE_BUFFER) {
g_pProtocolManager->m_pScreencopyProtocolManager->onOutputCommit(PMONITOR, E);
g_pProtocolManager->m_pToplevelExportProtocolManager->onOutputCommit(PMONITOR, E);
}
}
void Events::listener_monitorBind(void* owner, void* data) {
;
}

View File

@@ -56,10 +56,11 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
pHyprPopup->popup = popup;
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_mapPopupXDG.initCallback(&popup->base->surface->events.map, &Events::listener_mapPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_unmapPopupXDG.initCallback(&popup->base->surface->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");
pHyprPopup->hyprListener_repositionPopupXDG.initCallback(&popup->events.reposition, &Events::listener_repositionPopupXDG, pHyprPopup, "HyprPopup");
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
@@ -170,6 +171,21 @@ void Events::listener_mapPopupXDG(void* owner, void* data) {
Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode %lx", PPOPUP->pSurfaceTree);
}
void Events::listener_repositionPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
Debug::log(LOG, "XDG Popup %lx asks for a reposition", PPOPUP);
int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
wlr_box extents;
wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
PPOPUP->lastPos = {lx - extents.x, ly - extents.y};
PPOPUP->repositionRequested = true;
}
void Events::listener_unmapPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
Debug::log(LOG, "XDG Popup unmapped");
@@ -202,9 +218,22 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
void Events::listener_commitPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
if (g_pCompositor->windowValidMapped(PPOPUP->parentWindow)) {
PPOPUP->lx = PPOPUP->parentWindow->m_vRealPosition.vec().x;
PPOPUP->ly = PPOPUP->parentWindow->m_vRealPosition.vec().y;
}
int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
wlr_box extents;
wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
if (PPOPUP->repositionRequested)
g_pHyprRenderer->damageBox(PPOPUP->lastPos.x, PPOPUP->lastPos.y, extents.width + 2, extents.height + 2);
PPOPUP->repositionRequested = false;
g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly);
}

View File

@@ -58,6 +58,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bFadingOut = false;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
PWINDOW->m_iX11Type = PWINDOW->m_bIsX11 ? (PWINDOW->m_uSurface.xwayland->override_redirect ? 2 : 1) : 1;
PWINDOW->m_bFirstMap = true;
if (g_pInputManager->m_bLastFocusOnLS) // waybar fix
g_pInputManager->releaseAllMouseButtons();
@@ -108,6 +109,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
(PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xwayland->fullscreen);
bool requestsFakeFullscreen = false;
bool requestsMaximize = false;
bool overridingNoFullscreen = false;
bool overridingNoMaximize = false;
bool shouldFocus = true;
bool workspaceSpecial = false;
@@ -139,10 +142,12 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
}
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace;
const auto PMONITORFROMID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
if (PWINDOW->m_iMonitorID != PMONITOR->ID) {
g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID));
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
PMONITOR = PMONITORFROMID;
}
Debug::log(ERR, "Rule monitor, applying to window %lx -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);
@@ -175,8 +180,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bNoInitialFocus = true;
} else if (r.szRule.find("nofullscreenrequest") == 0) {
PWINDOW->m_bNoFullscreenRequest = true;
} else if (r.szRule.find("nomaximizerequest") == 0) {
PWINDOW->m_bNoMaximizeRequest = true;
} else if (r.szRule == "fullscreen") {
requestsFullscreen = true;
overridingNoFullscreen = true;
} else if (r.szRule == "fakefullscreen") {
requestsFakeFullscreen = true;
} else if (r.szRule == "windowdance") {
@@ -189,6 +197,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bPinned = true;
} else if (r.szRule == "maximize") {
requestsMaximize = true;
overridingNoMaximize = true;
} else if (r.szRule == "stayfocused") {
PWINDOW->m_bStayFocused = true;
} else if (r.szRule.find("idleinhibit") == 0) {
auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
@@ -214,6 +225,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
}
PWINDOW->updateSpecialRenderData();
// disallow tiled pinned
if (PWINDOW->m_bPinned && !PWINDOW->m_bIsFloating)
PWINDOW->m_bPinned = false;
@@ -403,8 +416,13 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->setHidden(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;
} else if (r.szRule.find("center") == 0) {
auto RESERVEDOFFSET = Vector2D();
const auto ARGS = CVarList(r.szRule, 2, ' ');
if (ARGS[1] == "1")
RESERVEDOFFSET = (PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight) / 2.f;
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f + RESERVEDOFFSET;
}
}
@@ -429,15 +447,17 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
// check LS focus grab
const auto PFORCEFOCUS = g_pCompositor->getForceFocus();
const auto PLSFROMFOCUS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
if (PLSFROMFOCUS && PLSFROMFOCUS->layerSurface->current.keyboard_interactive)
PWINDOW->m_bNoInitialFocus = true;
if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus &&
(PWINDOW->m_iX11Type != 2 || (PWINDOW->m_bIsX11 && wlr_xwayland_or_surface_wants_focus(PWINDOW->m_uSurface.xwayland))) && !workspaceSilent) {
(PWINDOW->m_iX11Type != 2 || (PWINDOW->m_bIsX11 && wlr_xwayland_or_surface_wants_focus(PWINDOW->m_uSurface.xwayland))) && !workspaceSilent &&
(!PFORCEFOCUS || PFORCEFOCUS == PWINDOW)) {
g_pCompositor->focusWindow(PWINDOW);
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PACTIVEALPHA);
PWINDOW->m_fDimPercent.setValueAndWarp(*PDIMSTRENGTH);
PWINDOW->m_fDimPercent.setValueAndWarp(PWINDOW->m_sAdditionalConfigData.forceNoDim ? 0.f : *PDIMSTRENGTH);
} else {
PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PINACTIVEALPHA);
PWINDOW->m_fDimPercent.setValueAndWarp(0);
@@ -464,7 +484,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late");
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_minimize, &Events::listener_requestMinimize, PWINDOW,
"Xwayland Window Late");
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_maximize, &Events::listener_requestMaximize, PWINDOW,
PWINDOW->hyprListener_requestMaximize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_maximize, &Events::listener_requestMaximize, PWINDOW,
"Xwayland Window Late");
if (PWINDOW->m_iX11Type == 2)
@@ -480,7 +500,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_vRealPosition.setCallbackOnEnd(setAnimToMove);
PWINDOW->m_vRealSize.setCallbackOnEnd(setAnimToMove);
if ((requestsFullscreen || requestsMaximize || requestsFakeFullscreen) && !PWINDOW->m_bNoFullscreenRequest) {
if ((requestsFullscreen && (!PWINDOW->m_bNoFullscreenRequest || overridingNoFullscreen)) || (requestsMaximize && (!PWINDOW->m_bNoMaximizeRequest || overridingNoMaximize)) ||
requestsFakeFullscreen) {
// fix fullscreen on requested (basically do a switcheroo)
if (PWORKSPACE->m_bHasFullscreenWindow) {
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
@@ -491,6 +512,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bFakeFullscreenState = !PWINDOW->m_bFakeFullscreenState;
g_pXWaylandManager->setWindowFullscreen(PWINDOW, true);
} else {
overridingNoFullscreen = false;
overridingNoMaximize = false;
PWINDOW->m_vRealPosition.warp();
PWINDOW->m_vRealSize.warp();
g_pCompositor->setWindowFullscreen(PWINDOW, true, requestsFullscreen ? FULLSCREEN_FULL : FULLSCREEN_MAXIMIZED);
@@ -584,6 +607,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
}
PWINDOW->m_bFirstMap = false;
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);
@@ -634,8 +659,14 @@ void Events::listener_unmapWindow(void* owner, void* data) {
PWINDOW->hyprListener_requestMinimize.removeCallback();
}
if (PWINDOW->m_bIsFullscreen) {
if (PWINDOW->m_bIsFullscreen)
g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
if (PMONITOR) {
PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
PWINDOW->m_eOriginalClosedExtents = PWINDOW->getFullWindowExtents();
}
// Allow the renderer to catch the last frame.
@@ -679,11 +710,11 @@ void Events::listener_unmapWindow(void* owner, void* data) {
if (PWINDOWCANDIDATE != g_pCompositor->m_pLastWindow) {
if (!PWINDOWCANDIDATE)
g_pInputManager->refocus();
g_pInputManager->simulateMouseMovement();
else
g_pCompositor->focusWindow(PWINDOWCANDIDATE);
} else {
g_pInputManager->refocus();
g_pInputManager->simulateMouseMovement();
}
} else {
Debug::log(LOG, "Unmapped was not focused, ignoring a refocus.");
@@ -700,14 +731,6 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
// do the animation thing
if (PMONITOR) {
PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
}
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
@@ -736,9 +759,29 @@ void Events::listener_commitWindow(void* owner, void* data) {
PWINDOW->updateSurfaceOutputs();
g_pHyprRenderer->damageSurface(PWINDOW->m_pWLSurface.wlr(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y);
g_pHyprRenderer->damageSurface(PWINDOW->m_pWLSurface.wlr(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
PWINDOW->m_bIsX11 ? 1.0 / PWINDOW->m_fX11SurfaceScaledBy : 1.0);
// Debug::log(LOG, "Window %lx committed", PWINDOW); // SPAM!
if (PWINDOW->m_bIsX11 || !PWINDOW->m_bIsFloating || PWINDOW->m_bIsFullscreen)
return;
const auto ISRIGID = PWINDOW->m_uSurface.xdg->toplevel->current.max_height == PWINDOW->m_uSurface.xdg->toplevel->current.min_height &&
PWINDOW->m_uSurface.xdg->toplevel->current.max_width == PWINDOW->m_uSurface.xdg->toplevel->current.min_width;
if (!ISRIGID)
return;
const Vector2D REQUESTEDSIZE = {PWINDOW->m_uSurface.xdg->toplevel->current.max_width, PWINDOW->m_uSurface.xdg->toplevel->current.max_height};
if (REQUESTEDSIZE == PWINDOW->m_vReportedSize || REQUESTEDSIZE.x < 5 || REQUESTEDSIZE.y < 5)
return;
const Vector2D DELTA = PWINDOW->m_vReportedSize - REQUESTEDSIZE;
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.goalv() + DELTA / 2.0;
PWINDOW->m_vRealSize = REQUESTEDSIZE;
g_pXWaylandManager->setWindowSize(PWINDOW, REQUESTEDSIZE, true);
g_pHyprRenderer->damageWindow(PWINDOW);
}
void Events::listener_destroyWindow(void* owner, void* data) {
@@ -759,6 +802,8 @@ void Events::listener_destroyWindow(void* owner, void* data) {
PWINDOW->hyprListener_destroyWindow.removeCallback();
PWINDOW->hyprListener_configureX11.removeCallback();
PWINDOW->hyprListener_setOverrideRedirect.removeCallback();
PWINDOW->hyprListener_associateX11.removeCallback();
PWINDOW->hyprListener_dissociateX11.removeCallback();
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
@@ -783,6 +828,8 @@ void Events::listener_setTitleWindow(void* owner, void* data) {
return;
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
g_pEventManager->postEvent(SHyprIPCEvent{"windowtitle", getFormat("%lx", PWINDOW)});
EMIT_HOOK_EVENT("windowTitle", 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});
@@ -837,7 +884,7 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
} else {
if (!PWINDOW->m_uSurface.xwayland->mapped)
if (!PWINDOW->m_uSurface.xwayland->surface->mapped)
return;
if (!PWINDOW->m_bFakeFullscreenState)
@@ -932,7 +979,7 @@ void Events::listener_configureX11(void* owner, void* data) {
const auto E = (wlr_xwayland_surface_configure_event*)data;
if (!PWINDOW->m_uSurface.xwayland->mapped || !PWINDOW->m_bMappedX11) {
if (!PWINDOW->m_uSurface.xwayland->surface || !PWINDOW->m_uSurface.xwayland->surface->mapped || !PWINDOW->m_bMappedX11) {
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
return;
}
@@ -951,8 +998,17 @@ void Events::listener_configureX11(void* owner, void* data) {
else
PWINDOW->setHidden(true);
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords({E->x, E->y});
PWINDOW->m_vRealPosition.setValueAndWarp(LOGICALPOS);
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
if (*PXWLFORCESCALEZERO) {
if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR)
PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() / PMONITOR->scale);
}
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
PWINDOW->m_vSize = PWINDOW->m_vRealSize.vec();
@@ -992,17 +1048,29 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
return;
}
if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 ||
abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) {
Debug::log(LOG, "Unmanaged window %lx 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);
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y});
if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.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 %lx requests geometry update to %i %i %i %i", PWINDOW, (int)LOGICALPOS.x, (int)LOGICALPOS.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));
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(LOGICALPOS.x, LOGICALPOS.y));
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));
if (*PXWLFORCESCALEZERO) {
if (const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR)
PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() / PMONITOR->scale);
}
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
PWINDOW->m_vSize = PWINDOW->m_vRealSize.goalv();
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace;
g_pCompositor->moveWindowToTop(PWINDOW);
@@ -1019,6 +1087,18 @@ void Events::listener_setOverrideRedirect(void* owner, void* data) {
//}
}
void Events::listener_associateX11(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
PWINDOW->hyprListener_mapWindow.initCallback(&PWINDOW->m_uSurface.xwayland->surface->events.map, &Events::listener_mapWindow, PWINDOW, "XWayland Window");
}
void Events::listener_dissociateX11(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
PWINDOW->hyprListener_mapWindow.removeCallback();
}
void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
const auto XWSURFACE = (wlr_xwayland_surface*)data;
@@ -1034,7 +1114,8 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
PNEWWINDOW->m_pX11Parent = g_pCompositor->getX11Parent(PNEWWINDOW);
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_associateX11.initCallback(&XWSURFACE->events.associate, &Events::listener_associateX11, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_dissociateX11.initCallback(&XWSURFACE->events.dissociate, &Events::listener_dissociateX11, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_setOverrideRedirect.initCallback(&XWSURFACE->events.set_override_redirect, &Events::listener_setOverrideRedirect, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_configureX11.initCallback(&XWSURFACE->events.request_configure, &Events::listener_configureX11, PNEWWINDOW, "XWayland Window");
@@ -1052,7 +1133,7 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
const auto PNEWWINDOW = g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->surface->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");
PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XDGSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XDG Window");
}
@@ -1064,7 +1145,7 @@ void Events::listener_NewXDGDeco(wl_listener* listener, void* data) {
void Events::listener_requestMaximize(void* owner, void* data) {
const auto PWINDOW = (CWindow*)owner;
if (PWINDOW->m_bNoFullscreenRequest)
if (PWINDOW->m_bNoMaximizeRequest)
return;
Debug::log(LOG, "Maximize request for %lx", PWINDOW);

View File

@@ -51,13 +51,14 @@ CAnimatedVariable::~CAnimatedVariable() {
}
void CAnimatedVariable::unregister() {
g_pAnimationManager->m_lAnimatedVariables.remove(this);
std::erase_if(g_pAnimationManager->m_vAnimatedVariables, [&](const auto& other) { return other == this; });
m_bIsRegistered = false;
disconnectFromActive();
}
void CAnimatedVariable::registerVar() {
if (!m_bIsRegistered)
g_pAnimationManager->m_lAnimatedVariables.push_back(this);
g_pAnimationManager->m_vAnimatedVariables.push_back(this);
m_bIsRegistered = true;
}
@@ -79,3 +80,17 @@ float CAnimatedVariable::getCurveValue() {
return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT);
}
void CAnimatedVariable::connectToActive() {
g_pAnimationManager->scheduleTick(); // otherwise the animation manager will never pick this up
if (!m_bIsConnectedToActive)
g_pAnimationManager->m_vActiveAnimatedVariables.push_back(this);
m_bIsConnectedToActive = true;
}
void CAnimatedVariable::disconnectFromActive() {
std::erase_if(g_pAnimationManager->m_vActiveAnimatedVariables, [&](const auto& other) { return other == this; });
m_bIsConnectedToActive = false;
}

View File

@@ -1,7 +1,11 @@
#pragma once
#include "../defines.hpp"
#include <functional>
#include <any>
#include <chrono>
#include "Vector2D.hpp"
#include "Color.hpp"
#include "../macros.hpp"
enum ANIMATEDVARTYPE {
AVARTYPE_INVALID = -1,
@@ -30,6 +34,11 @@ class CAnimatedVariable {
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
void create(ANIMATEDVARTYPE, std::any val, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
CAnimatedVariable(const CAnimatedVariable&) = delete;
CAnimatedVariable(CAnimatedVariable&&) = delete;
CAnimatedVariable& operator=(const CAnimatedVariable&) = delete;
CAnimatedVariable& operator=(CAnimatedVariable&&) = delete;
~CAnimatedVariable();
void unregister();
@@ -141,17 +150,8 @@ class CAnimatedVariable {
}
// checks if an animation is in progress
bool isBeingAnimated() {
switch (m_eVarType) {
case AVARTYPE_FLOAT: return m_fValue != m_fGoal;
case AVARTYPE_VECTOR: return m_vValue != m_vGoal;
case AVARTYPE_COLOR: return m_cValue != m_cGoal;
default: UNREACHABLE();
}
UNREACHABLE();
return false; // just so that the warning is suppressed
inline bool isBeingAnimated() {
return m_bIsBeingAnimated;
}
void warp(bool endCallback = true) {
@@ -171,6 +171,8 @@ class CAnimatedVariable {
default: UNREACHABLE();
}
m_bIsBeingAnimated = false;
if (endCallback)
onAnimationEnd();
}
@@ -209,10 +211,17 @@ class CAnimatedVariable {
m_bRemoveBeginAfterRan = remove;
}
/* Sets the update callback, called every time the value is animated and a step is done
Warning: calling unregisterVar/registerVar in this handler will cause UB */
void setUpdateCallback(std::function<void(void* thisptr)> func) {
m_fUpdateCallback = func;
}
/* resets all callbacks. Does not call any. */
void resetAllCallbacks() {
m_fBeginCallback = nullptr;
m_fEndCallback = nullptr;
m_fUpdateCallback = nullptr;
m_bRemoveBeginAfterRan = false;
m_bRemoveEndAfterRan = false;
}
@@ -239,6 +248,7 @@ class CAnimatedVariable {
bool m_bDummy = true;
bool m_bIsRegistered = false;
bool m_bIsBeingAnimated = false;
std::chrono::system_clock::time_point animationBegin;
@@ -249,17 +259,30 @@ class CAnimatedVariable {
bool m_bRemoveBeginAfterRan = true;
std::function<void(void* thisptr)> m_fEndCallback;
std::function<void(void* thisptr)> m_fBeginCallback;
std::function<void(void* thisptr)> m_fUpdateCallback;
bool m_bIsConnectedToActive = false;
void connectToActive();
void disconnectFromActive();
// methods
void onAnimationEnd() {
m_bIsBeingAnimated = false;
disconnectFromActive();
if (m_fEndCallback) {
// loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false.
auto removeEndCallback = m_bRemoveEndAfterRan;
m_fEndCallback(this);
if (m_bRemoveEndAfterRan)
if (removeEndCallback)
m_fEndCallback = nullptr; // reset
}
}
void onAnimationBegin() {
m_bIsBeingAnimated = true;
connectToActive();
if (m_fBeginCallback) {
m_fBeginCallback(this);
if (m_bRemoveBeginAfterRan)

View File

@@ -1,5 +1,8 @@
#include "BezierCurve.hpp"
#include "../debug/Log.hpp"
#include "../macros.hpp"
#include <chrono>
#include <algorithm>
void CBezierCurve::setup(std::vector<Vector2D>* pVec) {

View File

@@ -1,7 +1,9 @@
#pragma once
#include "../defines.hpp"
#include <deque>
#include <array>
#include <vector>
#include "Vector2D.hpp"
constexpr int BAKEDPOINTS = 255;
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;

View File

@@ -1,5 +1,9 @@
#include "Color.hpp"
#include "../defines.hpp"
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
CColor::CColor() {}

View File

@@ -2,9 +2,11 @@
#include "../defines.hpp"
#include <algorithm>
#include "../Compositor.hpp"
#include <set>
#include <sys/utsname.h>
#include <iomanip>
#include <sstream>
#include <execinfo.h>
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/sysctl.h>
@@ -129,9 +131,9 @@ std::string absolutePath(const std::string& rawpath, const std::string& currentP
if (value[1] == '.') {
auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
value.replace(0, 2, parentDir);
value.replace(0, 2 + currentPath.empty(), parentDir);
} else {
value.replace(0, 1, currentDir);
value.replace(0, 1 + currentPath.empty(), currentDir);
}
}
@@ -242,7 +244,7 @@ bool isNumber(const std::string& str, bool allowfloat) {
if (point)
return false;
point = true;
break;
continue;
}
if (!std::isdigit(c))
@@ -305,7 +307,140 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
outName = PLASTWORKSPACE->m_szName;
return PLASTWORKSPACE->m_iID;
} else {
if ((in[0] == 'm' || in[0] == 'e') && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
if (in[0] == 'r' && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
if (!g_pCompositor->m_pLastMonitor) {
Debug::log(ERR, "Relative monitor workspace on monitor null!");
result = INT_MAX;
return result;
}
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
int remains = (int)result;
std::set<int> invalidWSes;
// Collect all the workspaces we can't jump to.
for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_bIsSpecialWorkspace || (ws->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)) {
// Can't jump to this workspace
invalidWSes.insert(ws->m_iID);
}
}
for (auto& rule : g_pConfigManager->getAllWorkspaceRules()) {
const auto PMONITOR = g_pCompositor->getMonitorFromName(rule.monitor);
if (!PMONITOR || PMONITOR->ID == g_pCompositor->m_pLastMonitor->ID) {
// Can't be invalid
continue;
}
// WS is bound to another monitor, can't jump to this
invalidWSes.insert(rule.workspaceId);
}
// Prepare all named workspaces in case when we need them
std::vector<int> namedWSes;
for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_bIsSpecialWorkspace || (ws->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID) || ws->m_iID >= 0)
continue;
namedWSes.push_back(ws->m_iID);
}
std::sort(namedWSes.begin(), namedWSes.end());
// Just take a blind guess at where we'll probably end up
int predictedWSID = g_pCompositor->m_pLastMonitor->activeWorkspace + remains;
int remainingWSes = 0;
char walkDir = in[1];
// sanitize. 0 means invalid oob in -
predictedWSID = std::max(predictedWSID, 0);
// Count how many invalidWSes are in between (how bad the prediction was)
int beginID = in[1] == '+' ? g_pCompositor->m_pLastMonitor->activeWorkspace + 1 : predictedWSID;
int endID = in[1] == '+' ? predictedWSID : g_pCompositor->m_pLastMonitor->activeWorkspace;
auto begin = invalidWSes.upper_bound(beginID - 1); // upper_bound is >, we want >=
for (auto it = begin; *it <= endID && it != invalidWSes.end(); it++) {
remainingWSes++;
}
// Handle named workspaces. They are treated like always before other workspaces
if (g_pCompositor->m_pLastMonitor->activeWorkspace < 0) {
// Behaviour similar to 'm'
// Find current
int currentItem = -1;
for (size_t i = 0; i < namedWSes.size(); i++) {
if (namedWSes[i] == g_pCompositor->m_pLastMonitor->activeWorkspace) {
currentItem = i;
break;
}
}
currentItem += remains;
currentItem = std::max(currentItem, 0);
if (currentItem >= (int)namedWSes.size()) {
// At the seam between namedWSes and normal WSes. Behave like r+[diff] at imaginary ws 0
int diff = currentItem - (namedWSes.size() - 1);
predictedWSID = diff;
int beginID = 1;
int endID = predictedWSID;
auto begin = invalidWSes.upper_bound(beginID - 1); // upper_bound is >, we want >=
for (auto it = begin; *it <= endID && it != invalidWSes.end(); it++) {
remainingWSes++;
}
walkDir = '+';
} else {
// We found our final ws.
remainingWSes = 0;
predictedWSID = namedWSes[currentItem];
}
}
// Go in the search direction for remainingWSes
// The performance impact is directly proportional to the number of open and bound workspaces
int finalWSID = predictedWSID;
if (walkDir == '-') {
int beginID = finalWSID;
int curID = finalWSID;
while (--curID > 0 && remainingWSes > 0) {
if (invalidWSes.find(curID) == invalidWSes.end()) {
remainingWSes--;
}
finalWSID = curID;
}
if (finalWSID <= 0 || invalidWSes.find(finalWSID) != invalidWSes.end()) {
if (namedWSes.size()) {
// Go to the named workspaces
// Need remainingWSes more
int namedWSIdx = namedWSes.size() - remainingWSes;
// Sanitze
namedWSIdx = std::clamp(namedWSIdx, 0, (int)namedWSes.size() - 1);
finalWSID = namedWSes[namedWSIdx];
} else {
// Couldn't find valid workspace in negative direction, search last first one back up positive direction
walkDir = '+';
// We know, that everything less than beginID is invalid, so don't bother with that
finalWSID = beginID;
remainingWSes = 1;
}
}
}
if (walkDir == '+') {
int curID = finalWSID;
while (++curID < INT32_MAX && remainingWSes > 0) {
if (invalidWSes.find(curID) == invalidWSes.end()) {
remainingWSes--;
}
finalWSID = curID;
}
}
result = finalWSID;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(result);
if (PWORKSPACE)
outName = g_pCompositor->getWorkspaceByID(result)->m_szName;
else
outName = std::to_string(finalWSID);
} else if ((in[0] == 'm' || in[0] == 'e') && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
bool onAllMonitors = in[0] == 'e';
if (!g_pCompositor->m_pLastMonitor) {
@@ -354,7 +489,6 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
result = validWSes[currentItem];
outName = g_pCompositor->getWorkspaceByID(validWSes[currentItem])->m_szName;
} else {
if (in[0] == '+' || in[0] == '-') {
if (g_pCompositor->m_pLastMonitor)
@@ -563,3 +697,25 @@ std::string replaceInString(std::string subject, const std::string& search, cons
}
return subject;
}
std::vector<SCallstackFrameInfo> getBacktrace() {
std::vector<SCallstackFrameInfo> callstack;
void* bt[1024];
size_t btSize;
char** btSymbols;
btSize = backtrace(bt, 1024);
btSymbols = backtrace_symbols(bt, btSize);
for (size_t i = 0; i < btSize; ++i) {
callstack.emplace_back(SCallstackFrameInfo{bt[i], std::string{btSymbols[i]}});
}
return callstack;
}
void throwError(const std::string& err) {
Debug::log(CRIT, "Critical error thrown: %s", err.c_str());
throw std::runtime_error(err);
}

View File

@@ -1,6 +1,15 @@
#pragma once
#include "../includes.hpp"
#include <string>
#include <wayland-server.h>
#include <wlr/util/box.h>
#include "Vector2D.hpp"
#include <vector>
struct SCallstackFrameInfo {
void* adr = nullptr;
std::string desc;
};
std::string absolutePath(const std::string&, const std::string&);
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, const std::string& ownerString);
@@ -20,3 +29,5 @@ float getPlusMinusKeywordResult(std::string in, float relative);
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
double normalizeAngleRad(double ang);
std::string replaceInString(std::string subject, const std::string& search, const std::string& replace);
std::vector<SCallstackFrameInfo> getBacktrace();
void throwError(const std::string& err);

View File

@@ -14,6 +14,14 @@ CMonitor::CMonitor() {
CMonitor::~CMonitor() {
wlr_damage_ring_finish(&damage);
hyprListener_monitorDestroy.removeCallback();
hyprListener_monitorFrame.removeCallback();
hyprListener_monitorStateRequest.removeCallback();
hyprListener_monitorDamage.removeCallback();
hyprListener_monitorNeedsFrame.removeCallback();
hyprListener_monitorCommit.removeCallback();
hyprListener_monitorBind.removeCallback();
}
void CMonitor::onConnect(bool noRule) {
@@ -23,12 +31,14 @@ void CMonitor::onConnect(bool noRule) {
hyprListener_monitorDamage.removeCallback();
hyprListener_monitorNeedsFrame.removeCallback();
hyprListener_monitorCommit.removeCallback();
hyprListener_monitorBind.removeCallback();
hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this);
hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this);
hyprListener_monitorStateRequest.initCallback(&output->events.request_state, &Events::listener_monitorStateRequest, this);
hyprListener_monitorDamage.initCallback(&output->events.damage, &Events::listener_monitorDamage, this);
hyprListener_monitorNeedsFrame.initCallback(&output->events.needs_frame, &Events::listener_monitorNeedsFrame, this);
hyprListener_monitorCommit.initCallback(&output->events.commit, &Events::listener_monitorCommit, this);
hyprListener_monitorBind.initCallback(&output->events.bind, &Events::listener_monitorBind, this);
if (m_bEnabled) {
wlr_output_enable(output, 1);
@@ -145,7 +155,7 @@ void CMonitor::onConnect(bool noRule) {
setupDefaultWS(monitorRule);
for (auto& ws : g_pCompositor->m_vWorkspaces) {
if (ws->m_szLastMonitor == szName) {
if (ws->m_szLastMonitor == szName || g_pCompositor->m_vMonitors.size() == 1 /* avoid lost workspaces on recover */) {
g_pCompositor->moveWorkspaceToMonitor(ws.get(), this);
ws->startAnim(true, true, true);
ws->m_szLastMonitor = "";
@@ -232,6 +242,7 @@ void CMonitor::onDisconnect() {
hyprListener_monitorDamage.removeCallback();
hyprListener_monitorNeedsFrame.removeCallback();
hyprListener_monitorCommit.removeCallback();
hyprListener_monitorBind.removeCallback();
for (size_t i = 0; i < 4; ++i) {
for (auto& ls : m_aLayerSurfaceLayers[i]) {
@@ -318,6 +329,10 @@ void CMonitor::addDamage(const pixman_region32_t* rg) {
g_pCompositor->scheduleFrameForMonitor(this);
}
void CMonitor::addDamage(const CRegion* rg) {
addDamage(const_cast<CRegion*>(rg)->pixman());
}
void CMonitor::addDamage(const wlr_box* box) {
static auto* const PZOOMFACTOR = &g_pConfigManager->getConfigValuePtr("misc:cursor_zoom_factor")->floatValue;
if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) {
@@ -474,6 +489,8 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
// remove from mvmonitors
std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; });
g_pCompositor->arrangeMonitors();
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
g_pCompositor->sanityCheckWorkspaces();
@@ -503,7 +520,10 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
return;
if (pWorkspace->m_bIsSpecialWorkspace) {
Debug::log(ERR, "BUG THIS: Attempted to changeWorkspace to special!");
if (specialWorkspaceID != pWorkspace->m_iID) {
Debug::log(LOG, "changeworkspace on special, togglespecialworkspace to id %i", pWorkspace->m_iID);
g_pKeybindManager->m_mDispatchers["togglespecialworkspace"](pWorkspace->m_szName == "special" ? "" : pWorkspace->m_szName);
}
return;
}
@@ -531,13 +551,27 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
}
}
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
if (const auto PLASTWINDOW = pWorkspace->getLastFocusedWindow(); PLASTWINDOW)
g_pCompositor->focusWindow(PLASTWINDOW);
else {
g_pCompositor->focusWindow(nullptr);
g_pInputManager->refocus();
CWindow* pWindow = nullptr;
if (*PFOLLOWMOUSE == 1)
pWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
if (!pWindow)
pWindow = g_pCompositor->getTopLeftWindowOnWorkspace(pWorkspace->m_iID);
if (!pWindow)
pWindow = g_pCompositor->getFirstWindowOnWorkspace(pWorkspace->m_iID);
g_pCompositor->focusWindow(pWindow);
}
g_pInputManager->simulateMouseMovement();
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
// set some flags and fire event
@@ -576,11 +610,23 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
return;
}
if (specialWorkspaceID) {
if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL)
EXISTINGSPECIAL->startAnim(false, false);
}
// open special
pWorkspace->m_iMonitorID = ID;
specialWorkspaceID = pWorkspace->m_iID;
pWorkspace->startAnim(true, true);
for (auto& w : g_pCompositor->m_vWindows) {
if (w->m_iWorkspaceID == pWorkspace->m_iID) {
w->m_iMonitorID = ID;
w->updateSurfaceOutputs();
}
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
if (const auto PLAST = pWorkspace->getLastFocusedWindow(); PLAST)
@@ -592,3 +638,10 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
void CMonitor::setSpecialWorkspace(const int& id) {
setSpecialWorkspace(g_pCompositor->getWorkspaceByID(id));
}
void CMonitor::moveTo(const Vector2D& pos) {
vecPosition = pos;
if (!isMirror())
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, output, (int)vecPosition.x, (int)vecPosition.y);
}

View File

@@ -6,9 +6,24 @@
#include <vector>
#include <array>
#include <memory>
#include <xf86drmMode.h>
#include "Timer.hpp"
#include "Region.hpp"
#include <optional>
struct SMonitorRule;
struct SMonitorRule {
std::string name = "";
Vector2D resolution = Vector2D(1280, 720);
Vector2D offset = Vector2D(0, 0);
float scale = 1;
float refreshRate = 60;
bool disabled = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
std::string mirrorOf = "";
bool enable10bit = false;
drmModeModeInfo drmMode = {};
std::optional<int> vrr;
};
class CMonitor {
public:
@@ -16,6 +31,7 @@ class CMonitor {
~CMonitor();
Vector2D vecPosition = Vector2D(-1, -1); // means unset
Vector2D vecXWaylandPosition = Vector2D(-1, -1); // means unset
Vector2D vecSize = Vector2D(0, 0);
Vector2D vecPixelSize = Vector2D(0, 0);
Vector2D vecTransformedSize = Vector2D(0, 0);
@@ -31,6 +47,8 @@ class CMonitor {
Vector2D vecReservedTopLeft = Vector2D(0, 0);
Vector2D vecReservedBottomRight = Vector2D(0, 0);
drmModeModeInfo customDrmMode = {};
// WLR stuff
wlr_damage_ring damage;
wlr_output* output = nullptr;
@@ -40,6 +58,7 @@ class CMonitor {
bool noFrameSchedule = false;
bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
bool gammaChanged = false;
bool dpmsStatus = true;
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
@@ -53,10 +72,14 @@ class CMonitor {
bool RATScheduled = false;
CTimer lastPresentationTimer;
SMonitorRule activeMonitorRule;
// mirroring
CMonitor* pMirrorOf = nullptr;
std::vector<CMonitor*> mirrors;
CRegion lastFrameDamage; // stores last frame damage
// for the special workspace. 0 means not open.
int specialWorkspaceID = 0;
@@ -68,6 +91,7 @@ class CMonitor {
DYNLISTENER(monitorDamage);
DYNLISTENER(monitorNeedsFrame);
DYNLISTENER(monitorCommit);
DYNLISTENER(monitorBind);
// hack: a group = workspaces on a monitor.
// I don't really care lol :P
@@ -77,6 +101,7 @@ class CMonitor {
void onConnect(bool noRule);
void onDisconnect();
void addDamage(const pixman_region32_t* rg);
void addDamage(const CRegion* rg);
void addDamage(const wlr_box* box);
void setMirror(const std::string&);
bool isMirror();
@@ -85,6 +110,7 @@ class CMonitor {
void changeWorkspace(const int& id, bool internal = false);
void setSpecialWorkspace(CWorkspace* const pWorkspace);
void setSpecialWorkspace(const int& id);
void moveTo(const Vector2D& pos);
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
bool m_bEnabled = false;

97
src/helpers/Region.cpp Normal file
View File

@@ -0,0 +1,97 @@
#include "Region.hpp"
#include <wlr/util/box.h>
CRegion::CRegion() {
pixman_region32_init(&m_rRegion);
}
CRegion::CRegion(pixman_region32_t* ref) {
pixman_region32_init(&m_rRegion);
pixman_region32_copy(&m_rRegion, ref);
}
CRegion::CRegion(double x, double y, double w, double h) {
pixman_region32_init_rect(&m_rRegion, x, y, w, h);
}
CRegion::CRegion(wlr_box* box) {
pixman_region32_init_rect(&m_rRegion, box->x, box->y, box->width, box->height);
}
CRegion::CRegion(pixman_box32_t* box) {
pixman_region32_init_rect(&m_rRegion, box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1);
}
CRegion::CRegion(const CRegion& other) {
pixman_region32_init(&m_rRegion);
pixman_region32_copy(&m_rRegion, const_cast<CRegion*>(&other)->pixman());
}
CRegion::CRegion(CRegion&& other) {
pixman_region32_init(&m_rRegion);
pixman_region32_copy(&m_rRegion, other.pixman());
}
CRegion::~CRegion() {
pixman_region32_fini(&m_rRegion);
}
CRegion& CRegion::clear() {
pixman_region32_clear(&m_rRegion);
return *this;
}
CRegion& CRegion::set(const CRegion& other) {
pixman_region32_copy(&m_rRegion, const_cast<CRegion*>(&other)->pixman());
return *this;
}
CRegion& CRegion::add(const CRegion& other) {
pixman_region32_union(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
return *this;
}
CRegion& CRegion::add(double x, double y, double w, double h) {
pixman_region32_union_rect(&m_rRegion, &m_rRegion, x, y, w, h);
return *this;
}
CRegion& CRegion::subtract(const CRegion& other) {
pixman_region32_subtract(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
return *this;
}
CRegion& CRegion::intersect(const CRegion& other) {
pixman_region32_intersect(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
return *this;
}
CRegion& CRegion::intersect(double x, double y, double w, double h) {
pixman_region32_intersect_rect(&m_rRegion, &m_rRegion, x, y, w, h);
return *this;
}
CRegion& CRegion::invert(pixman_box32_t* box) {
pixman_region32_inverse(&m_rRegion, &m_rRegion, box);
return *this;
}
CRegion& CRegion::translate(const Vector2D& vec) {
pixman_region32_translate(&m_rRegion, vec.x, vec.y);
return *this;
}
std::vector<pixman_box32_t> CRegion::getRects() const {
std::vector<pixman_box32_t> result;
int rectsNum = 0;
const auto RECTSARR = pixman_region32_rectangles(&m_rRegion, &rectsNum);
result.assign(RECTSARR, RECTSARR + rectsNum);
return result;
}
bool CRegion::empty() {
return !pixman_region32_not_empty(&m_rRegion);
}

55
src/helpers/Region.hpp Normal file
View File

@@ -0,0 +1,55 @@
#pragma once
#include <pixman.h>
#include <vector>
#include "Vector2D.hpp"
struct wlr_box;
class CRegion {
public:
/* Create an empty region */
CRegion();
/* Create from a reference. Copies, does not own. */
CRegion(pixman_region32_t* ref);
/* Create from a box */
CRegion(double x, double y, double w, double h);
/* Create from a wlr_box */
CRegion(wlr_box* box);
/* Create from a pixman_box32_t */
CRegion(pixman_box32_t* box);
CRegion(const CRegion&);
CRegion(CRegion&&);
~CRegion();
CRegion& operator=(CRegion&& other) {
pixman_region32_copy(&m_rRegion, other.pixman());
return *this;
}
CRegion& operator=(CRegion& other) {
pixman_region32_copy(&m_rRegion, other.pixman());
return *this;
}
CRegion& clear();
CRegion& set(const CRegion& other);
CRegion& add(const CRegion& other);
CRegion& add(double x, double y, double w, double h);
CRegion& subtract(const CRegion& other);
CRegion& intersect(const CRegion& other);
CRegion& intersect(double x, double y, double w, double h);
CRegion& translate(const Vector2D& vec);
CRegion& invert(pixman_box32_t* box);
bool empty();
std::vector<pixman_box32_t> getRects() const;
pixman_region32_t* pixman() {
return &m_rRegion;
}
private:
pixman_region32_t m_rRegion;
};

View File

@@ -1,9 +1,10 @@
#pragma once
#include <array>
#include <vector>
#include <string>
inline const std::vector<std::string> SPLASHES = {
// clang-format off
"Woo, animations!",
"It's like Hypr, but better.",
"Release 1.0 when?",
@@ -60,4 +61,5 @@ inline const std::vector<std::string> SPLASHES = {
"Thanks ThatOneCalculator!",
"The AUR packages always work, except for the times they don't.",
"Funny animation compositor woo"
// clang-format on
};

View File

@@ -150,13 +150,13 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) {
PNEWSUBSURFACE->pSubsurface = PSUBSURFACE;
PNEWSUBSURFACE->pParent = pNode;
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->events.map, &Events::listener_mapSubsurface, PNEWSUBSURFACE, "Subsurface");
PNEWSUBSURFACE->hyprListener_unmap.initCallback(&PSUBSURFACE->events.unmap, &Events::listener_unmapSubsurface, PNEWSUBSURFACE, "Subsurface");
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->surface->events.map, &Events::listener_mapSubsurface, PNEWSUBSURFACE, "Subsurface");
PNEWSUBSURFACE->hyprListener_unmap.initCallback(&PSUBSURFACE->surface->events.unmap, &Events::listener_unmapSubsurface, PNEWSUBSURFACE, "Subsurface");
PNEWSUBSURFACE->hyprListener_destroy.initCallback(&PSUBSURFACE->events.destroy, &Events::listener_destroySubsurface, PNEWSUBSURFACE, "Subsurface");
PNEWSUBSURFACE->pWindowOwner = pNode->pWindowOwner;
if (PSUBSURFACE->mapped)
if (PSUBSURFACE->surface->mapped)
listener_mapSubsurface(PNEWSUBSURFACE, nullptr);
wlr_subsurface* existingWlrSubsurface;
@@ -229,6 +229,8 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
addSurfaceGlobalOffset(pNode, &lx, &ly);
const double SCALE = pNode->pWindowOwner && pNode->pWindowOwner->m_bIsX11 ? 1.0 / pNode->pWindowOwner->m_fX11SurfaceScaledBy : 1.0;
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
// What this does is that basically, if the pNode is a child of some other node, on commit,
// it will also damage (check & damage if needed) all its siblings.
@@ -237,12 +239,12 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
const auto NODECOORDS = pNode->pSubsurface ? Vector2D(pNode->pSubsurface->pSubsurface->current.x, pNode->pSubsurface->pSubsurface->current.y) : Vector2D();
if (&cs != pNode->pSubsurface && cs.pSubsurface) {
g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y);
g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y, SCALE);
}
}
if (pNode->pSurface && pNode->pSurface->exists())
g_pHyprRenderer->damageSurface(pNode->pSurface->wlr(), lx, ly);
g_pHyprRenderer->damageSurface(pNode->pSurface->wlr(), lx, ly, SCALE);
}
void Events::listener_destroySubsurface(void* owner, void* data) {

View File

@@ -26,6 +26,7 @@ struct SSurfaceTreeNode {
void* globalOffsetData;
CWindow* pWindowOwner = nullptr;
//
bool operator==(const SSurfaceTreeNode& rhs) const {
return pSurface == rhs.pSurface;
}
@@ -43,6 +44,7 @@ struct SSubsurface {
CWindow* pWindowOwner = nullptr;
//
bool operator==(const SSubsurface& rhs) const {
return pSubsurface == rhs.pSubsurface;
}

View File

@@ -15,3 +15,7 @@ int CTimer::getMillis() {
float CTimer::getSeconds() {
return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count() / 1000.f;
}
const std::chrono::system_clock::time_point& CTimer::chrono() const {
return m_tpLastReset;
}

View File

@@ -1,12 +1,13 @@
#pragma once
#include "../defines.hpp"
#include <chrono>
class CTimer {
public:
void reset();
float getSeconds();
int getMillis();
const std::chrono::system_clock::time_point& chrono() const;
private:
std::chrono::system_clock::time_point m_tpLastReset;

View File

@@ -16,7 +16,7 @@ Vector2D::~Vector2D() {}
double Vector2D::normalize() {
// get max abs
const auto max = abs(x) > abs(y) ? abs(x) : abs(y);
const auto max = std::abs(x) > std::abs(y) ? std::abs(x) : std::abs(y);
x /= max;
y /= max;
@@ -24,16 +24,24 @@ double Vector2D::normalize() {
return max;
}
Vector2D Vector2D::floor() {
return Vector2D((int)x, (int)y);
Vector2D Vector2D::floor() const {
return Vector2D(std::floor(x), std::floor(y));
}
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) const {
return Vector2D(std::clamp(this->x, min.x, max.x < min.x ? INFINITY : max.x), std::clamp(this->y, min.y, max.y < min.y ? INFINITY : max.y));
}
double Vector2D::distance(const Vector2D& other) {
double Vector2D::distance(const Vector2D& other) const {
double dx = x - other.x;
double dy = y - other.y;
return std::sqrt(dx * dx + dy * dy);
}
bool Vector2D::inTriangle(const Vector2D& p1, const Vector2D& p2, const Vector2D& p3) const {
const auto a = ((p2.y - p3.y) * (x - p3.x) + (p3.x - p2.x) * (y - p3.y)) / ((p2.y - p3.y) * (p1.x - p3.x) + (p3.x - p2.x) * (p1.y - p3.y));
const auto b = ((p3.y - p1.y) * (x - p3.x) + (p1.x - p3.x) * (y - p3.y)) / ((p2.y - p3.y) * (p1.x - p3.x) + (p3.x - p2.x) * (p1.y - p3.y));
const auto c = 1 - a - b;
return 0 <= a && a <= 1 && 0 <= b && b <= 1 && 0 <= c && c <= 1;
}

View File

@@ -1,6 +1,6 @@
#pragma once
#include <math.h>
#include <cmath>
class Vector2D {
public:
@@ -43,9 +43,19 @@ class Vector2D {
return Vector2D(this->x / a.x, this->y / a.y);
}
double distance(const Vector2D& other);
bool operator>(const Vector2D& a) const {
return this->x > a.x && this->y > a.y;
}
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D());
bool operator<(const Vector2D& a) const {
return this->x < a.x && this->y < a.y;
}
Vector2D floor();
double distance(const Vector2D& other) const;
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D()) const;
Vector2D floor() const;
bool inTriangle(const Vector2D& p1, const Vector2D& p2, const Vector2D& p3) const;
};

View File

@@ -10,14 +10,31 @@ SLayerSurface::SLayerSurface() {
void SLayerSurface::applyRules() {
noAnimations = false;
forceBlur = false;
ignoreZero = false;
ignoreAlpha = false;
ignoreAlphaValue = 0.f;
xray = -1;
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
if (rule.rule == "noanim")
noAnimations = true;
else if (rule.rule == "blur")
forceBlur = true;
else if (rule.rule == "ignorezero")
ignoreZero = true;
else if (rule.rule.find("ignorealpha") == 0 || rule.rule.find("ignorezero") == 0) {
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
std::string alphaValue = "";
if (FIRST_SPACE_POS != std::string::npos)
alphaValue = rule.rule.substr(FIRST_SPACE_POS + 1);
try {
ignoreAlpha = true;
if (!alphaValue.empty())
ignoreAlphaValue = std::stof(alphaValue);
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
} else if (rule.rule.find("xray") == 0) {
CVarList vars{rule.rule, 0, ' '};
try {
xray = configStringToInt(vars[1]);
} catch (...) {}
}
}
}

View File

@@ -7,6 +7,7 @@
#include "SubsurfaceTree.hpp"
#include "AnimatedVariable.hpp"
#include "WLSurface.hpp"
#include "Region.hpp"
struct SLayerRule {
std::string targetNamespace = "";
@@ -21,6 +22,8 @@ struct SLayerSurface {
wlr_layer_surface_v1* layerSurface;
wl_list link;
bool keyboardExclusive = false;
CWLSurface surface;
std::list<CWLSurface> popupSurfaces;
@@ -47,7 +50,9 @@ struct SLayerSurface {
bool noAnimations = false;
bool forceBlur = false;
bool ignoreZero = false;
int xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
// For the list lookup
bool operator==(const SLayerSurface& rhs) const {
@@ -141,7 +146,7 @@ struct SMouse {
wlr_pointer_constraint_v1* currentConstraint = nullptr;
bool constraintActive = false;
pixman_region32_t confinedTo;
CRegion confinedTo;
std::string name = "";
@@ -186,10 +191,14 @@ struct SXDGPopup {
DYNLISTENER(mapPopupXDG);
DYNLISTENER(unmapPopupXDG);
DYNLISTENER(commitPopupXDG);
DYNLISTENER(repositionPopupXDG);
double lx;
double ly;
Vector2D lastPos = {};
bool repositionRequested = false;
SSurfaceTreeNode* pSurfaceTree = nullptr;
// For the list lookup
@@ -237,6 +246,7 @@ struct STablet {
std::string name = "";
//
bool operator==(const STablet& b) const {
return wlrDevice == b.wlrDevice;
}
@@ -299,6 +309,7 @@ struct SSwipeGesture {
double delta = 0;
int initialDirection = 0;
float avgSpeed = 0;
int speedPoints = 0;

View File

@@ -1,7 +1,8 @@
#pragma once
#include "../includes.hpp"
#include <string>
#include <functional>
#include <wayland-server.h>
class CHyprWLListener {
public:

View File

@@ -1,7 +1,6 @@
#pragma once
#include "../defines.hpp"
class CWLSurface {
public:
CWLSurface() = default;

View File

@@ -36,7 +36,7 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
m_vRenderOffset.registerVar();
m_fAlpha.registerVar();
g_pEventManager->postEvent({"createworkspace", m_szName}, true);
g_pEventManager->postEvent({"createworkspace", m_szName});
EMIT_HOOK_EVENT("createWorkspace", this);
}
@@ -51,14 +51,51 @@ CWorkspace::~CWorkspace() {
m_pWlrHandle = nullptr;
}
g_pEventManager->postEvent({"destroyworkspace", m_szName}, true);
g_pEventManager->postEvent({"destroyworkspace", m_szName});
EMIT_HOOK_EVENT("destroyWorkspace", this);
}
void CWorkspace::startAnim(bool in, bool left, bool instant) {
const auto ANIMSTYLE = m_fAlpha.m_pConfig->pValues->internalStyle;
if (ANIMSTYLE == "fade") {
if (ANIMSTYLE.find("slidefade") == 0) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
float movePerc = 100.f;
if (ANIMSTYLE.find("%") != std::string::npos) {
try {
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
}
m_fAlpha.setValueAndWarp(1.f);
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
if (ANIMSTYLE.find("slidefadevert") == 0) {
if (in) {
m_fAlpha.setValueAndWarp(0.f);
m_vRenderOffset.setValueAndWarp(Vector2D(0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
m_fAlpha = 1.f;
m_vRenderOffset = Vector2D(0, 0);
} else {
m_fAlpha.setValueAndWarp(1.f);
m_fAlpha = 0.f;
m_vRenderOffset = Vector2D(0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
}
} else {
if (in) {
m_fAlpha.setValueAndWarp(0.f);
m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0));
m_fAlpha = 1.f;
m_vRenderOffset = Vector2D(0, 0);
} else {
m_fAlpha.setValueAndWarp(1.f);
m_fAlpha = 0.f;
m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0);
}
}
} else if (ANIMSTYLE == "fade") {
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
if (in) {
@@ -94,6 +131,17 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
}
}
if (m_bIsSpecialWorkspace) {
// required for open/close animations
if (in) {
m_fAlpha.setValueAndWarp(0.f);
m_fAlpha = 1.f;
} else {
m_fAlpha.setValueAndWarp(1.f);
m_fAlpha = 0.f;
}
}
if (instant) {
m_vRenderOffset.warp();
m_fAlpha.warp();

View File

@@ -1,10 +1,11 @@
#pragma once
#include "../defines.hpp"
#include "AnimatedVariable.hpp"
#include <string>
#include "../defines.hpp"
#include "../wlrunstable/wlr_ext_workspace_v1.hpp"
enum eFullscreenMode : uint8_t
{
enum eFullscreenMode : uint8_t {
FULLSCREEN_FULL = 0,
FULLSCREEN_MAXIMIZED
};

View File

@@ -112,11 +112,12 @@ struct wlr_xwayland_surface {
struct wl_signal map;
struct wl_signal unmap;
struct wl_signal associate;
struct wl_signal dissociate;
struct wl_signal set_title;
struct wl_signal set_class;
struct wl_signal set_role;
struct wl_signal set_parent;
struct wl_signal set_pid;
struct wl_signal set_startup_id;
struct wl_signal set_window_type;
struct wl_signal set_hints;

View File

@@ -103,8 +103,10 @@ extern "C" {
#include <wlr/backend/wayland.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_cursor_shape_v1.h>
#include <drm_fourcc.h>
#include <libdrm/drm_fourcc.h>
#if WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
@@ -145,3 +147,4 @@ extern "C" {
#include "helpers/Vector2D.hpp"
#include "ext-workspace-unstable-v1-protocol.h"
#include "wlrunstable/wlr_ext_workspace_v1.hpp"

View File

@@ -3,3 +3,27 @@
bool Init::isSudo() {
return getuid() != geteuid() || !geteuid();
}
void Init::gainRealTime() {
const int minPrio = sched_get_priority_min(SCHED_RR);
int old_policy;
struct sched_param param;
if (pthread_getschedparam(pthread_self(), &old_policy, &param)) {
Debug::log(WARN, "Failed to get old pthread scheduling priority");
return;
}
param.sched_priority = minPrio;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &param)) {
Debug::log(WARN, "Failed to change process scheduling strategy");
return;
}
pthread_atfork(NULL, NULL, []() {
const struct sched_param param = {.sched_priority = 0};
if (pthread_setschedparam(pthread_self(), SCHED_OTHER, &param))
Debug::log(WARN, "Failed to reset process scheduling strategy");
});
}

View File

@@ -4,4 +4,5 @@
namespace Init {
bool isSudo();
void gainRealTime();
};

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