Compare commits

...

692 Commits

Author SHA1 Message Date
Vaxry
ea2501d455 props: bump version to 0.41.0 2024-06-10 16:23:06 +02:00
Aqa-Ib
7ba2c31822 github: improve the chances of the user specifying bug or regression (#6399) 2024-06-10 15:25:01 +02:00
zakk4223
cef6aad28f groupbar: Fix window title rendering (#6392) 2024-06-10 12:20:18 +02:00
outfoxxed
89a3c90613 wlr-foreign-toplevel: fix fullscreen failing and add output support (#6360)
* wlr-foreign-toplevel: fix fullscreen failing and add output support

* fix for core protocol rewrite
2024-06-10 12:16:38 +02:00
memchr
b16af45c4a build: ProtocolManager missing header LIstener.hpp (#6391) 2024-06-10 12:15:25 +02:00
Vaxry
1423707dbe output: remove wl_output globals for mirrored displays
ref #6387
2024-06-10 00:06:42 +02:00
diniamo
121c6ac3ea hyprctl: add --quiet flag (#6380) 2024-06-09 21:16:29 +02:00
Vaxry
722b846ac5 egl: assume implicit modifiers are available for old drivers
fixes #6367
2024-06-09 21:10:46 +02:00
Vaxry
4168b8c17b seat: fix pointer frame events not being sent correctly
fixes #6384
2024-06-09 17:23:28 +02:00
DrummyFloyd
1f71d5f5c1 ci: add auto labels on PR (#6369)
* ci: add auto labels

* ci(labeler): add glob for src/protocols

* ci: adapt to vaxerski request
2024-06-09 15:53:05 +02:00
Mykola Perehudov
bf75723f27 helpers: fix misuse of syscalls in sd namespace (#6379) 2024-06-09 09:43:39 +02:00
Vaxry
c62f0015ae hyprpm: print and fail on missing packages during configure
instead of failing later with something like exit code 2, print out what's missing
2024-06-09 09:42:14 +02:00
Vaxry
9994b73ad0 buffer: track asynchronous buffers and don't release them until unref
synchronous buffers are read instantly and we can release them, but asynchronous ones have to be locked until they are unref'd from .current to avoid reading from a buffer after .release()
2024-06-08 17:27:56 +02:00
void0red
d724556b7e input: fix virtual devices not updating capabilities (#6366)
Signed-off-by: void0red <void0red@gmail.com>
2024-06-08 17:15:57 +02:00
memchr
7789caad39 build: include missing header: "debug/Log.hpp" in Format.cpp (#6365) 2024-06-08 16:25:01 +02:00
Vaxry
3fb079a2a3 renderer: allow custom uv for surface no-blur passes 2024-06-08 16:16:43 +02:00
Vaxry
211353dc34 core: verify surface roles on creation of objects 2024-06-08 12:03:47 +02:00
Vaxry
10e02076b1 wayland: fix invalid wl_output_mode dimensions sent 2024-06-08 11:50:44 +02:00
Vaxry
5b6d54cae0 xdg_shell: ignore outdated ack_configure events 2024-06-08 10:57:37 +02:00
Vaxry
6967a31450 wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl

it's the final countdown
2024-06-08 10:07:59 +02:00
Vaxry
c31d9ef417 xdg_shell: fix nested xdg_positioner calculations
ref #6240
2024-06-07 20:24:09 +02:00
Vaxry
6b6b02c27a seat: send events to all bound seats for a client
some apps are legitimately braindead and bind wl_seat a bazillion times and expect the events to be sent to all of them

ref #6159
2024-06-07 20:24:06 +02:00
John M. Harris, Jr
40ce17bbbd gestures: Add gestures:workspace_swipe_min_fingers option (#6342)
When gestures:workspace_swipe_min_fingers is enabled,
gestures:workspace_swipe_fingers is considered to be the minimum
number of fingers required to swipe.

This behavior is more similar to sway and macOS's default behavior.

For example, this allows you to set workspace_swipe_fingers to 3,
but swipe with 4 or more fingers instead of 3.
2024-06-07 19:54:08 +02:00
memchr
41e1147dfc input: add cursor:persistent_warps to maintain relative position within a window (#6338)
Allows the cursor to return to its last relative position within a window when the window is refocused.

Allows the cursor to retain its relative position within a window when the window is swapped, moved, changed workspace, added to or removed from groups.

controlled with cursor:persistent_warps
2024-06-07 19:52:15 +02:00
Vaxry
9bc00897fc xdg_shell: improve xdg_positioner slide behavior
ref #6240
2024-06-07 19:46:51 +02:00
Vaxry
d6337146bb xdg_shell: improve xdg_positioner resize calculations
ref #6240
2024-06-07 18:42:38 +02:00
John M. Harris, Jr
429cff340d hookSystem: Make needsDeadCleanup volatile (#6356)
The value of needsDeadCleanup would be clobbered after longjmp,
having an undefined value.
2024-06-07 18:31:27 +02:00
Tom Englund
af5f24929d core: free more memory on destruction (#6348)
* pointermgr: add destructor to state and free buf

if the pointer has a buffer set it wont be freed upon destruction, make
asan more happy by adding a destructor and wlr_buf_unlock it on exit.

* cursormgr: free the animation timer event source

properly free the animation timer event source on destruction.

* compositor: free the critsig event source on exit

properly free the critical signal event source on exit.

* popup: clang format style

clang format.
2024-06-06 20:27:09 +02:00
giskard
c95845b148 log: log with local timezone (#6331)
* log: log with local timezone

* log: backward compatability for clang 17 with libc++
2024-06-05 18:30:46 +02:00
phonetic112
82099fd1c0 hyprctl: Allow setting name for custom/headless outputs (#6319) 2024-06-05 18:26:38 +02:00
Vaxry
155fe6f165 popup: minor safety improvements 2024-06-05 16:53:49 +02:00
memchr
fefa55d406 build: fix non-pch build (#6337) 2024-06-05 10:42:44 +02:00
Vaxry
098ac916a6 deps: update wlroots
closes #6328
2024-06-04 15:57:45 +02:00
Agent00Ming
d0a224a491 seat: discrete round away from zero + high res scrolling (#6317)
* Discrete scrolling round away from zero
e.deltaDiscrete can be multiples of 30 instead of the usual 120 causing
the rounded value to be 0 when too small causing erratic scrolling.

* Send value120 alongside discrete
Fixes sensitivity issues for clients that support value120 axis events
2024-06-03 22:47:02 +02:00
Vaxry
5517cc506b xwayland: don't destroy server client
this potentially leaks, but avoids a UAF

ref #6323
2024-06-03 21:13:38 +02:00
Vaxry
0ac0f32671 toplevelexport: avoid locking software cursors during render
this may trigger a render begin/end and fuck up the pass

fixes #6277
2024-06-03 21:10:31 +02:00
Vaxry
b30c7125d7 window: avoid nullptr deref on monitor in box helpers
fixes #6321
2024-06-03 21:09:18 +02:00
vaxerski
3fd6c1b30e layout: fix centering of new floating windows
ref #6154
2024-06-03 18:46:20 +02:00
Tom Englund
eaecf7db14 core: fix a few asan reported issues and a coredump on exit (#6285)
* xwayland: add destructor to CXWM and free resource

the wl_event_resource was running upon destruction of the compositor
causing a null pointer segfault in onX11Event so ensure the event is
removed upon destruction, also free the memory allocated by
xcb_errors_context_new and finally call xcb_disconnect on the connection
to free the fd and its memory.

* hyprctl: dont leak the fd on destruction

add a destructor and properly free the fd on destruction

* eventloop: add destructor and free event source

properly free the wl_event_source upon destruction.
2024-06-03 18:46:20 +02:00
wouter@wouterbijlsma.nl
e08195d240 Fix initial xdg-decoration toplevel decoration mode negotiation
Clients using zxdg_decoration_manager_v1::get_toplevel_decoration may
expect a receiving a zxdg_toplevel_decoration_v1::configure event to
determine the initial decoration mode, without having to go through a
zxdg_toplevel_decoration_v1::set_mode request. Hyprland was not sending
this event, resulting in unwanted decorations being drawn.

Specifically, clients using libdecor, e.g. applications using recent
GLFW, would draw GTK decorations with artefacts. This change fixes
these.
2024-06-02 23:11:55 +02:00
vaxerski
66acdfe2ad seat: don't send keymap on empty device 2024-06-02 18:38:36 +02:00
shezdy
0ebb43c1a3 renderer: fix xwayland solitary rechecks (#6295) 2024-06-01 20:45:30 +02:00
vaxerski
a54ab30160 cmake: make xcb-errors required
fixes #6290
2024-05-31 22:07:00 +02:00
obivan
df6ebe358b pointer: Include monitor scaling in HW hotspot calculation (#6283) 2024-05-31 12:38:52 +02:00
vaxerski
a60c7283e6 xwayland: verify new xsurf is valid in prop reads
fixes #6250
2024-05-29 09:34:25 +02:00
giskard
ebf258788e config: add tag dispacther and window rule (#6211) 2024-05-28 23:37:24 +02:00
Ikalco
73b133d015 hyprctl: Make setcursor better (support XCursor themes, give fail message) (#6097)
* add support for changing to X cursor themes

* use new hyprcursor abi for options

* remove unneeded struct
2024-05-28 23:35:18 +02:00
Connor Wong
722d537a91 windows: make new_window_takes_over_fullscreen use the new window's workspace (#6263)
* fix new_window_takes_over_fullscreen behavior

* missed a few things
2024-05-27 22:45:32 +02:00
AERDU
506d0c06e6 compositor: change monitor focus when no_warps is enabled (#6260)
fixes focus between monitors when moving using directions with no_warps = true
2024-05-27 22:45:14 +02:00
Flafy
546a486bab hyprctl: add delimiter to hyprctl batch command (#6261)
adds a delimiter of 3 newlines to separate different command outputs
2024-05-27 22:31:35 +02:00
Jan Beich
db5d39a66f meson: add more xcb-* dependencies after addd3e7f1a
ld: error: undefined symbol: xcb_icccm_get_wm_hints_from_reply
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::readProp(CSharedPointer<CXWaylandSurface>, unsigned int, xcb_get_property_reply_t*))

ld: error: undefined symbol: xcb_icccm_get_wm_size_hints_from_reply
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::readProp(CSharedPointer<CXWaylandSurface>, unsigned int, xcb_get_property_reply_t*))

ld: error: undefined symbol: xcb_errors_get_name_for_major_code
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::handleError(xcb_value_error_t*))

ld: error: undefined symbol: xcb_errors_get_name_for_minor_code
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::handleError(xcb_value_error_t*))

ld: error: undefined symbol: xcb_errors_get_name_for_error
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::handleError(xcb_value_error_t*))

ld: error: undefined symbol: xcb_xfixes_id
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_composite_id
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_res_id
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_xfixes_query_version
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_xfixes_query_version_reply
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_res_query_version
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_res_query_version_reply
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::gatherResources())

ld: error: undefined symbol: xcb_render_query_pict_formats
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::getRenderFormat())

ld: error: undefined symbol: xcb_render_query_pict_formats_reply
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::getRenderFormat())

ld: error: undefined symbol: xcb_render_query_pict_formats_formats_iterator
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::getRenderFormat())

ld: error: undefined symbol: xcb_render_pictforminfo_next
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::getRenderFormat())

ld: error: undefined symbol: xcb_errors_context_new
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::CXWM())

ld: error: undefined symbol: xcb_composite_redirect_subwindows
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::CXWM())

ld: error: undefined symbol: xcb_xfixes_select_selection_input
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::initSelection())

ld: error: undefined symbol: xcb_render_create_picture
>>> referenced by XWM.cpp
>>>               src/Hyprland.p/xwayland_XWM.cpp.o:(CXWM::setCursor(unsigned char*, unsigned int, Vector2D const&, Vector2D const&))

ld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
2024-05-27 12:24:37 +03:00
Gabriel Ford
553232a3e4 hyprctl: Add Config Flag to hyprctl systeminfo (#6160) 2024-05-25 22:46:07 +02:00
Vaxry
addd3e7f1a xwayland: move to hyprland impl (#6086) 2024-05-25 22:43:51 +02:00
zjeffer
a71207434c Add custom cmake target for installheaders
This will ensure the correct headers are generated before trying to
install them.
2024-05-25 23:03:27 +03:00
zjeffer
71c2ff3105 Reapply "CMake: use add_custom_command for generating protocols (#6104)"
This reverts commit e419ef1873.
2024-05-25 23:03:27 +03:00
vaxerski
90f262aada pointer: remove dividing hotspot by scale
fixes #6117
2024-05-25 20:43:38 +02:00
Mihai Fufezan
2ff95bba3f flake.lock: update 2024-05-24 23:51:08 +03:00
Can
ce17961aad keybinds: Added new dispatcher (sendshortcut) (#6174) 2024-05-24 20:58:26 +02:00
vaxerski
6d67b84469 monitor: avoid UB on undefined auto dir
ref #6217
2024-05-24 20:56:53 +02:00
thejch
0d6eae0523 pointer: add back nvidia hardware cursor quirks (#6220) 2024-05-24 20:50:22 +02:00
vaxerski
52684b7d90 window: fix invalid env buffer size in getEnv 2024-05-24 20:40:15 +02:00
Tom Englund
4e42107d25 pointermgr: ensure compositor exist on destroy (#6216)
on exit of hyprland the CMonitor destroy signal comes after the
compositor has been destructed, causing a heap use after free. add if
check to ensure compositor exist and isnt shutting down when its
triggered.
2024-05-23 21:19:14 +02:00
Alessio Molinari
eea0a6a704 internal: Replace monitor rule when disabling head. (#6136)
Closes #5978
2024-05-23 21:15:31 +02:00
System64
255272ea18 debug: Add ARM GPU info (#6212)
Added a simple way to get basic info about the GPU on ARM based systems
2024-05-23 18:04:39 +02:00
Ming-Chuan
df80fbf706 tablet: fix mapping when mapped region is specified (#6206)
When `region_size` is set in the config (non-empty
`boundBox`), cursor is mapped to wrong coordinate because
`CBox::translate` mutates `TAB->boundBox`, making all subsequent coordinate
calculations wrong.

This also fixes the edge case where user sets `region_position` but
not `region_size`.
2024-05-23 13:52:32 +02:00
shezdy
25b9446949 internal: save previous workspace before change (#6202) 2024-05-23 13:01:12 +02:00
vaxerski
7ad9116de8 [gha] Nix: update inputs 2024-05-22 22:43:47 +00:00
vaxerski
62401d5b3f screencopy: use a simple renderer for frame passing 2024-05-23 00:42:16 +02:00
vaxerski
3775776a07 window: guard monitor in bounding box calculations
fixes #6190
2024-05-22 22:37:16 +02:00
shezdy
155ae3721c keybinds: Add option to disable window direction monitor fallback (#6182)
* add monitor fallback option

* format
2024-05-22 21:51:46 +02:00
giskard
93fea89043 renderer: render fonts with pango, add global font_family config option (#6138) 2024-05-22 10:09:36 +02:00
Mihai Fufezan
e419ef1873 Revert "CMake: use add_custom_command for generating protocols (#6104)"
Fixes https://github.com/hyprwm/Hyprland/issues/6115.
2024-05-21 21:29:56 +03:00
giskard
3c907f7830 build: update meson, cmake setup
- meson
. fix run_command() check warning
. drop lines for compatability, as it's already using c++23

- cmake
. generate `compile_commands.json` by default
. position independent build: __FILE__
2024-05-21 20:36:07 +03:00
Mihai Fufezan
4daa5c0658 flake.lock: update 2024-05-21 19:17:34 +03:00
vaxerski
baef55da1d xdg-shell: fixup positioner behavior with slide and resize
if sliding and resizing, include the slide in the resize to avoid off-screen surfaces.

fixes #6150
2024-05-21 14:50:33 +02:00
Vaxry
f8857e6072 input: find surface pos correctly when mouse drag is active
fixes #6144
2024-05-18 21:20:01 +01:00
Gabriel Ford
c21a5a9340 layout: Fix shrinking pseudotile windows. (#6143) 2024-05-18 19:28:48 +01:00
Vaxry
2ead1fd221 virtual-keyboard: emit event before finishing keyboard
ref #6123
2024-05-17 20:07:33 +01:00
Vaxry
49485ba36a pointer: damage in software mode on cursor image changes
fixes #6126
2024-05-17 20:04:17 +01:00
Vaxry
fe23d2b639 window: verify suppress flags in onUpdateState
ref #6108
2024-05-17 19:54:05 +01:00
Vaxry
9518cec833 popup: clip input region to surface size
fixes #6125
2024-05-17 19:43:56 +01:00
Vaxry
23cd4c7998 seat: update keymap/repeat info on keymap events from keebs
fixes #6114
2024-05-17 19:28:33 +01:00
Tuur Vanhoutte
0cb8fbe18e error: Add option to change position of HyprError bar (#3241) (#6111) 2024-05-17 19:06:51 +01:00
Vaxry
f21b6fe576 tablet: avoid null deref on an empty cursor set
fixes#6116
2024-05-17 14:51:06 +01:00
Yaroslav
f91431465b cmake: make gprof optional for debug builds (#6120)
This fixes the debug build on musl systems, as -pg option is specific to
glibc. Now we can build the project on such systems with -DUSE_GPROF=OFF
2024-05-17 11:06:31 +01:00
Yaroslav
a66cfe0fbe CMake: use add_custom_command for generating protocols (#6104)
This fixes an issue with build error in case of e.g.

$ rm protocols/*.{c,h}
$ cmake --build build

The workaround was to touch CMakeLists.txt. With this PR, protocol files
are properly regenerated with no extra efforts.

Also, resolve hyprwayland-scanner dependency via cmake instead
ofpkg-config.
2024-05-17 01:34:03 +03:00
Mihai Fufezan
7173f0c9e7 flake.lock: update
nix/overlays: remove merged wayland-protocols overlay

Fixes #6061
2024-05-17 00:03:25 +03:00
Vaxry
abbe71d26d pointer: don't update hw cursors on disabled displays 2024-05-16 19:34:36 +01:00
Vaxry
a2643e11a0 build: bump hw-s dep to 0.3.8 2024-05-16 18:35:48 +01:00
Agent00Ming
3ac0e7ead1 seat: Send discrete event when axis source is scroll wheel (#6103)
modified:   src/managers/SeatManager.cpp
	modified:   src/managers/input/InputManager.cpp

Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-05-16 13:30:55 +01:00
Gabriel Ford
d693c44836 keybinds: add keybind combos and add Left and Right mod distinction. (#5966) 2024-05-16 11:48:30 +01:00
zakk4223
ca0833c9ed decoration: Stacked group tabs (#5886)
* Stacked group tabs

* Fix index when creating groupbar title textures

* Changes for stacked dnd

* formatting

* Don't remove internal horizontal padding when calculating stacked bar
width
2024-05-16 11:38:10 +01:00
Vaxry
de9798fcf9 configmgr: shadow exec rules when window is unmapped
fixes #6091
2024-05-16 00:55:55 +01:00
Vaxry
7e8c0b7f30 seat: send axis_stop events after axis events
fixes #6090
2024-05-15 23:13:51 +01:00
Vaxry
9eec4cb670 sysd: add missing header
ref #6094
2024-05-15 23:01:50 +01:00
JManch
a8522db683 keybinds: fix empty on monitor for new workspaces (#6089) 2024-05-15 21:03:51 +01:00
Vaxry
b9c58b6e75 seat: send enter/leave events to all bound wl_seats for a client
fixes #6069

Will not send anything beyond enter/leave. If you depend on multiple seats sending you motion, button, etc, events, fix your app.
2024-05-15 19:33:42 +01:00
Raphael Tannous
3fe5280ce9 hyprctl: return exitStatus in requestHyprpaper() and request() (#6083) 2024-05-15 16:54:23 +01:00
Vaxry
3381e2b55b datadevice: guard surface in dnd for null
fixes #6076
2024-05-15 16:26:02 +01:00
Vaxry
7fbe05a250 inputmgr: send pointer motion on ffm != 1
fixes #6077
2024-05-15 16:22:45 +01:00
Sungyoon Cho
31890026ea wl_seat: send frame event after pointer leave (#6074) 2024-05-15 12:17:56 +01:00
Vaxry
94c20a1863 primary-selection: move to hyprland impl 2024-05-14 23:13:35 +01:00
Mihai Fufezan
3eeaea5be9 Meson: add wayland.xml proto 2024-05-14 23:13:35 +01:00
Vaxry
eed1361f39 wlr-data-device: move to hyprland impl 2024-05-14 23:13:35 +01:00
Vaxry
7eeee2c94e wl-data-device: move to hyprland impl 2024-05-14 23:13:35 +01:00
Vaxry
fc72df8e58 seatmgr: Add a grab class 2024-05-14 23:13:33 +01:00
Vaxry
0cfdde3d1a xdg-shell: move to new impl 2024-05-14 23:02:24 +01:00
Vaxry
121d3a7213 wl_seat: move to hyprland impl 2024-05-14 23:02:24 +01:00
Vaxry
4cdddcfe46 cursor: minor fixes for unhiding surfaces
the surface equality check is done in CPointerManager, the one in renderer can be wrong

fixes #5975
2024-05-14 16:45:12 +01:00
Sungyoon Cho
d0a4a0e0d8 input: fix modifier and leds (#6062) 2024-05-14 16:14:43 +01:00
Daniil
1584679004 xwayland: Remove delta for real position with xwayland zero scaling (#6057) 2024-05-14 13:33:20 +01:00
Vaxry
ba69652193 window: set sane default pseudo size 2024-05-13 22:21:06 +01:00
Vaxry
47874f09f4 cmake: remove forceful ffi and wayland deps for asan
fixes #6050
2024-05-13 15:29:18 +01:00
Vaxry
60be4298e1 makefile: fix wlroots headers dir 2024-05-13 15:16:10 +01:00
vaxerski
4c625ce673 [gha] Nix: update inputs 2024-05-13 13:58:35 +00:00
Paul
064bdb06f1 hyprctl: Add locked cmd to requests (#6042)
Co-authored-by: Leftas <info@leftas.dev>
2024-05-13 14:57:06 +01:00
Vaxry
fd35b35000 keybinds: fix pass
reverts #5967

fixes #6022
2024-05-12 16:01:01 +01:00
Mihai Fufezan
2ccd45a844 hyprpm: don't shallow clone on non-main branches 2024-05-12 17:49:50 +03:00
Mihai Fufezan
ff93820bbb Makefile: fix wlr dir 2024-05-12 17:49:50 +03:00
Mihai Fufezan
071f6977df wlroots: bump 2024-05-12 17:49:50 +03:00
Mihai Fufezan
c8ae9a2e83 Meson: fix Cflags 2024-05-12 17:49:50 +03:00
Mihai Fufezan
cee639d9df pkg-config: fix wlroots dir 2024-05-12 17:49:50 +03:00
Mihai Fufezan
6be765b7a1 Nix: fix pkgconfig prefix 2024-05-12 17:49:50 +03:00
Brenno Lemos
33a7b7bb6b core: fix on-empty workspace being called too often (#6026) 2024-05-12 00:03:32 +01:00
shezdy
15072831cf keybinds: fix release binds in submaps (#6025) 2024-05-12 00:02:26 +01:00
Vaxry
8562d38477 screencopy: don't spam sw cursor locks 2024-05-11 22:10:42 +01:00
Vaxry
494b9415a1 layersurface: avoid restack on identical layers
ref #6014
2024-05-11 18:31:50 +01:00
Vaxry
b6a7fb9e91 layersurface: fix invalid use of std::move
fixes #6014
2024-05-11 14:43:44 +01:00
Sungyoon Cho
3529fbc6d4 compositor: fix getMonitorFromVector getting wrong monitor (#6010) 2024-05-11 10:35:20 +01:00
Vaxry
ed3a888fc2 hyprpm: fix style 2024-05-10 23:56:54 +01:00
André Silva
a8ab1b1679 nix: build improvements (#5952)
* scripts: allow using existing variable values in generateVersion.sh

* nix: populate versioning variables

* nix: remove unused meson input

* nix: remove unnecessary hyprland-protocols dependency

* Nix: remove nixConfig from flake

It's more annoying than helpful.

* CI/Nix: fix PR build failure

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-05-11 01:51:53 +03:00
Vaxry
6e594e4416 hyprpm: force en_US locale for date calcs
ref #5994
2024-05-10 23:41:32 +01:00
Vaxry
19186de118 renderer: avoid locking during rendering
it can trigger pointermgr to render which fucks up our pass

fixes #5998
2024-05-10 23:38:46 +01:00
Vaxry
38911d6df4 box: fix noNegativeSize 2024-05-10 12:59:01 +01:00
underengineering
37a84c5223 socket2: fix events being reordered (#5955)
* socket2: fix events being reordered

* remove WL_EVENT_READABLE

* initialize eventSource in SClient

* add more logs

oopsie

* replace unordered_map with vector

* fix reordering when socket becomes writable before queue is flushed

* ignore EAGAIN when accepting connection

* use g_pEventManager
2024-05-10 12:32:50 +01:00
MightyPlaza
c19903eaf8 windowrules add focusonactivate (#5976)
modified:   src/config/ConfigManager.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
2024-05-10 12:27:54 +01:00
Vaxry
cc4ac52309 github: update issue template with new path 2024-05-10 12:22:47 +01:00
Vaxry
2549f0cc97 layersurface: reset popuphead after unmap
fixes #5980
2024-05-10 12:03:38 +01:00
Vaxry
3374229118 core: remove unused includes and fix warn 2024-05-10 03:20:26 +01:00
Vaxry
2ba6bb69c4 popups: fix breadthfirst and at
fixes #5977
2024-05-10 02:38:56 +01:00
Vaxry
db30ff63e6 popups: avoid infinite recursion in bf 2024-05-10 02:38:56 +01:00
Vaxry
a7e23d2f1e presentation-time: move to new impl 2024-05-10 02:38:54 +01:00
Vaxry
1753059b07 pointermgr: reset entered outputs when resetting surface
fixes #5970
2024-05-09 23:08:40 +01:00
Vaxry
b0861b6709 config: move various cursor-related vars to cursor: 2024-05-09 22:25:20 +01:00
sub-kek
7cf810b181 keybinds: Fix classic global keybinds(pass dispatcher) (#5967) 2024-05-09 22:05:13 +01:00
Mihai Fufezan
51b0da2c0d flake.lock: update 2024-05-10 00:04:15 +03:00
Vaxry
4f26ae70fd core: drop unused protocol impls
xdg_foreign is not used by hyprland

wlr_export_dmabuf is old, broken and unused as well
2024-05-09 22:02:19 +01:00
MightyPlaza
eeebbc0e7e groupbar: fix title scaling (#5969)
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.hpp
2024-05-09 22:02:19 +01:00
Vaxry
635a02d83f layer-shell: move to new impl
Also bumps the hw-s dep
2024-05-09 22:02:18 +01:00
MightyPlaza
85f7f69046 decorations: fix groupbar input (#5963)
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.hpp
2024-05-09 19:19:32 +01:00
Vaxry
fe4737fb9d pointer: don't calculate hw hotspot for missing hw cursors
ref #5964
2024-05-09 19:17:04 +01:00
Vaxry
d7aed240db text-input-v3: atomically enable/disable on commit 2024-05-09 14:27:48 +01:00
Vaxry
c98acaed62 virtual-keyboard: release keys before destroy 2024-05-09 14:07:21 +01:00
Ikalco
67a5377b41 core: remove wayland sockets on exit (#5959) 2024-05-09 13:39:15 +01:00
Vaxry
84e8d1810d Tablet: move to new impl
Ring and strip are not implemented. Will I implement this? God fucking knows. Nobody seems to have that anyways.
2024-05-09 13:37:39 +01:00
Vaxry
ed411f53bd cursor: move to a hyprland impl
This moves wlr_cursor to a completely new impl mostly under
CPointerManager

Also adds beginSimple to OpenGL for simple render passes (e.g. cursor)
2024-05-09 13:37:39 +01:00
Vaxry
e4e84064f2 xdg-activation: keep tokens after the resource is dead
fixes #5957
2024-05-08 22:17:17 +01:00
Ikalco
6a988d9276 core: cleanup environment on exit (#5941) 2024-05-08 18:11:08 +01:00
Vaxry
d1ad490cda cmake: fix .pc file inputs (#5946) 2024-05-08 15:24:02 +01:00
William Gray
36d32973dd keybinds: add empty on monitor and next empty flags (#5936)
* empty on monitor

* add flag for next empty

* clang-format changes

* next also uses m_pLastMonitor
2024-05-08 13:30:20 +01:00
giskard
70b5e6df70 meson: require hyprwayland-scanner >= 0.3.5 2024-05-08 09:11:54 +03:00
Vaxry
5e7925eaeb foreign-toplevel: bypass no activate focus checks
ref #5939

those are used by focus switchers so they should bypass stuff like focus_on_activate = false
2024-05-08 01:31:22 +01:00
Username404-59
57a12476de internal: Add missing errno.h include to SdDaemon.cpp (#5938)
Fixes clang
2024-05-07 23:13:58 +01:00
Vaxry
601210878d cmake: bump hw-s required ver to 0.3.5 2024-05-07 21:03:26 +01:00
Vaxry
22a86fd7a2 session-lock: don't allow events from rejected locks
fixes #5913
2024-05-07 18:43:00 +01:00
Vaxry
598bbd186b window: avoid uaf on updateWindow decos
TODO, make these pointers SP to avoid this in the future.

fixes #5909
2024-05-07 17:37:06 +01:00
Ikalco
6ccc22194c xkb: check value correctly with xkb_state_layout_index_is_active() (#5925) 2024-05-07 16:07:50 +01:00
Vaxry
ec092bd601 core: chase hyprwayland-scanner 2024-05-07 14:28:26 +01:00
Vaxry
2bcc8d303f eventloop: don't call lost timers 2024-05-07 13:30:41 +01:00
VPavliashvili
375e77e398 ipc: add togglegroup, moveintogroup and moveoutofgroup events (#5866) 2024-05-07 12:00:55 +01:00
Vaxry
96365309de deco-positioner: avoid infinite recalcs
fixes #5908
2024-05-07 11:53:29 +01:00
Vaxry
0acad88c3c foreign-toplevel-wlr: send current class and title on map
fixes #5910
2024-05-07 11:48:08 +01:00
Ikalco
57e76f91d9 keybinds: fix xkb keybind name to keysym comparison (#5917) 2024-05-07 07:20:06 +01:00
Vaxry
0c446ec5f4 memory: fix SP/WP hierarchy templates 2024-05-06 21:36:31 +01:00
Agent00Ming
fa69de8ab6 pointer-constraints: Remove unnecessary cursor warps (#5895)
modified:   src/protocols/PointerConstraints.cpp

Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-05-06 17:19:26 +01:00
outfoxxed
05e4a3f1a8 windows: Revert "window: set config only when both props end anims" (#5904)
This reverts commit 7617c03dfd,
fixing a bug that caused the bottom right corner of windows to
animate oddly.
2024-05-06 15:32:01 +01:00
Vaxry
a8a04c746b renderer: deny solitary during a session lock
closes #5906

fixes #5899
2024-05-06 02:24:11 +01:00
Ikalco
cddeec47a1 keybinds: make the keybind manager check for session lock (#5894) 2024-05-05 19:28:14 +01:00
Mihai Fufezan
c7fbc30bfd Nix: add missing deps
CMake used to warn about these deps so I've added them.

Also propagates wlroots' nativeBuildInputs.
2024-05-05 20:34:14 +03:00
Vaxry
1ed1ce9506 internal: new shared_ptr and weak_ptr implementation (#5883)
moves std::shared_ptrs to a new implementation

Advantages:
- you can dereference a weak_ptr directly. This will obviously segfault on a nullptr deref if it's expired.
   - this is useful to avoid the .lock() hell where we are 100% sure the pointer _should_ be valid. (and if it isn't, it should throw.)
- weak_ptrs are still valid while the SP is being destroyed.
   - reasoning: while an object (e.g. CWindow) is being destroyed, its `weak_ptr self` should be accessible (the sp is still alive, and so is CWindow), but it's not because by stl it's already expired (to prevent resurrection)
   - this impl solves it differently. w_p is expired, but can still be dereferenced and used. Creating `s_p`s is not possible anymore, though.
   - this is useful in destructors and callbacks.
2024-05-05 17:16:00 +01:00
Mihai Fufezan
589f758d94 CI/Nix: build with submodules
- Clone repo recursively
- Update Nix install action
- Remove wlroots update
2024-05-05 16:30:39 +03:00
Mihai Fufezan
f15513309b Nix: use CMake for builds instead of Meson
Build using submodules instead of patching the build process and using
Nix derivations of the subprojects.

From this commit on, you'll have to change the Hyprland flake url to
`git+https://github.com/hyprwm/Hyprland?submodules=1`
2024-05-05 16:30:39 +03:00
Mihai Fufezan
99aa34db6e CMake: install files (instead of Makefile) 2024-05-05 16:30:39 +03:00
Sungyoon Cho
03ebad3cbf idle-inhibit: enable idle inhibitor if no hl surface is associated (#5882) 2024-05-05 14:04:40 +01:00
outfoxxed
aaf35b9f1f protocols: add hyprland_focus_grab_v1 implementation (#5850)
* protocols: add hyprland_focus_grab_v1 implementation

* protocols/focus_grab: fix keyboard focus staying on unlisted windows

When creating a focus grab with layershell surfaces, the last active
toplevel kept keyboard focus.

* protocols/focus_grab: fix formatting

* protocols/focus_grab: try to pick surface for keyboard focus

* focus_grab: update keyboard focus to match spec

* Revert "protocols/focus_grab: try to pick surface for keyboard focus"

This reverts commit 090358d0d1.

* protocols/focus_grab: fix issues and match new spec

* kde-server-decoration: move to new impl

* protocols/focus_grab: review fixup

* Update hyprland-protocols

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-05-05 03:14:35 +01:00
Vaxry
62eadad20f kde-server-decoration: move to new impl 2024-05-05 02:00:55 +01:00
Vaxry
0b215c5f24 idle-inhibit: fix and cleanup visibility logic
fixes #5878
2024-05-04 23:46:10 +01:00
Vaxry
a3309b51a2 shadow: fix small pixel gaps between border
huge fix
2024-05-04 20:30:03 +01:00
Vaxry
cba1ade848 props: bump version to 0.40.0 2024-05-04 16:42:32 +01:00
Vaxry
c77b60c910 keyboard: prevent UAF in destroy events 2024-05-04 16:37:26 +01:00
Vaxry
c951c4f8a1 keyboard: check for wlr() validity before accessing
fixes #5873
2024-05-04 16:10:32 +01:00
Vaxry
25964e5a2b hid: don't access expired resources in virtual devices
fixes #5868
2024-05-04 12:36:02 +01:00
JManch
2d40046f24 windows: set fullscreen border size to 0 (#5865) 2024-05-04 12:07:36 +01:00
thejch
40201a760a workspacerule: Fix monitor settings being deleted when merging ws rules (#5864)
* fix deleting monitor settings when merging rules

* use empty and workspace invalid
2024-05-04 02:18:04 +01:00
Vaxry
a3b4923c42 input: ignore destroyed devices in static events
fixes #5863
2024-05-04 00:48:25 +01:00
Vaxry
1237732b97 input: Introduce basic hyprland HID classes
Implements an intermediary HID class for mice, keyboards and touch devices, removing the old structs from WLClasses.hpp

Yes, virtual ones are duplicated a bit, but will likely be de-duped once wlr_input_device is not used anymore.
2024-05-03 22:40:27 +01:00
William Gray
1d2acbe193 config: add absolute monitor workspace selectors (#5848)
* add absolute monitor workspace selectors

* implement absolute for `r`

* format code
2024-05-03 18:38:00 +01:00
Tom Englund
1c73beaf9b inputmgr: dont double free on hotplug (#5855)
* inputmgr: dont double free on hotplug

since we are also unrefing the state on hotplugging the keyboard set the
state to nullptr so the destructor if case actually catches its been
already freed.

* keybindgmgr: dont double free on layout switching

d5bf153 added keymap unref at the end of updateXKBTranslationState to
not leak it when exiting, only it causes updateXKBTranslationState to
double free when changing layouts. since its already freed. remove the
unneeded extra xkb_keymap_unref.
2024-05-03 18:10:41 +01:00
Vaxry
8a2269272b output-management: move to new impl 2024-05-03 18:08:04 +01:00
Tom Englund
d5bf15387a internal: fix a few asan reported leaks on exit of hyprland (#5852)
* notifications: free cairo images on destruction

asan reports a leak on exit if we dont free the image we created in the
draw function. add a destructor and free images on exit.

* compositor: destroy wlroots types on exit

there are a few types not being destroyed on exit and causing a leak on
exit in wlroots reported by asan, add those.

* cursormgr: ensure we destroy cursor mgr on exit

add a destructor and call wlr_xcursor_manager_destroy on the manager on
destruction, leak reported by asan.

* keybindmgr: free state and keymap

add missing keymap_unref on creation, and add a destructor and free the
state on exit. leak reported by asan.

* skeyboard: add destructor and free state

free the state on destruction of keyboard, reported as leak by asan
2024-05-03 14:42:08 +01:00
Ikalco
387127b12a config: added option to choose the default monitor for the cursor (#5847)
* added option to choose the default monitor that the cursor will appear in upon startup

* fix: don't set cursor to default monitor after startup

* refactor to checkDefaultCursorWarp also fix focus
2024-05-03 02:39:19 +01:00
Vaxry
41cf94faaa format: fix clang-format 2024-05-03 02:04:08 +01:00
Gabriel Ford
0623cfabc9 windowrules: Fix Floating Grouped Windows Crash and Bug. (#5826)
* Don't unhide grouped items.

* Remove head check as that wasn't always correct.

* Replace lock with expired()

* Remove set hidden from max size.
2024-05-03 02:00:58 +01:00
Vaxry
2755297670 virtual-pointer: move to new impl 2024-05-03 01:52:05 +01:00
Vaxry
7d49819b5e virtual-keyboard: destroy on vdestroy event 2024-05-03 00:54:32 +01:00
Vaxry
6aa2d123ae virtual-keyboard: move to new impl 2024-05-03 00:31:48 +01:00
Vaxry
a3ca016d42 cursor-shape: use - instead of _ in shapes
ref #5824
2024-05-02 16:21:33 +01:00
Vaxry
eeb78ef965 fractional: set scale before configure
fixes #5842
2024-05-02 15:13:47 +01:00
Vaxry
8427824719 cursormgr: attempt using - instead of _ for failed cursors before fallback
web uses -, and thus some themes might use - too. Attempt replacing _ with - before assuming a shape is missing.
2024-05-02 14:47:10 +01:00
thejch
d0229d6e1e layout: limit updates when mouse animate drag is enabled (#5838) 2024-05-02 14:28:51 +01:00
Vaxry
56de72f357 internal: store matched windowrules and emit event
new event for plugins, windowUpdateRules
2024-05-02 02:18:01 +01:00
Mihai Fufezan
02bfb2857e flake.lock: update 2024-05-01 22:00:26 +03:00
Vaxry
0237e39f74 protocols: utilize hyprwayland-scanner 0.3.3 functions
stuff like ::version(), ::client(), ::error() etc
2024-05-01 19:40:35 +01:00
Vaxry
47b087950d hyprctl: fix instances path
fixes #5831
2024-05-01 16:47:38 +01:00
Vaxry
8bcccf9f0f ime-v2: move to new impl 2024-05-01 16:41:17 +01:00
Vaxry
4ed6b69b68 socket2: fix empty activewindowv2 events
fixes #5827
2024-05-01 13:57:32 +01:00
zakk4223
d2899a6c27 layout: Trigger layout recalcuation on deco position/size change (#5821)
* Trigger layout recalcuation on deco position/size change

* Remove now unneeded code

* Formatting
2024-05-01 12:59:40 +01:00
Vaxry
ed58cc4c31 sessionLock: remove m_pLastFocus on destroy of surface
fixes #5822
2024-05-01 02:33:36 +01:00
Vaxry
3d09c6d526 makefile: fix old headers only being copied 2024-05-01 00:32:42 +01:00
Vaxry
70ebc3add3 sessionLock: call wlr_surface_map/_unmap on the surface manually
fixes unmapped subsurfaces etc

ref #5816
2024-04-30 21:59:07 +01:00
Vaxry
a09103cd38 sessionLock: set locked after emitting event
ref #5816
2024-04-30 21:20:06 +01:00
Vaxry
dbb8b294d6 sessionLock: fix incorrect protocol error raised
fixes #5816
2024-04-30 20:02:30 +01:00
Vaxry
1f6657f037 keybinds: check for special workspace equality before switching
fixes #5814
2024-04-30 16:42:31 +01:00
Vaxry
90e1411315 session-lock: move to new impl 2024-04-30 16:34:09 +01:00
Vaxry
d7a48cf478 hyprctl: use XDG_RUNTIME_DIR if available
fixes #5813
2024-04-30 14:17:35 +01:00
Jan Beich
07e070012b CrashReporter: unbreak build on FreeBSD (#5786)
* CrashReporter: skip Linux field on BSDs after 90a53aed59

In file included from src/debug/CrashReporter.cpp:10:
src/debug/signal-safe.hpp:113:17: error: no member named 'sa_restorer' in 'sigaction'
            act.sa_restorer = NULL;
            ~~~ ^

* CrashReporter: ensure *argv[] is NULL-terminated after 90a53aed59

execv() may fail with EFAULT otherwise.

* hyprpm: add missing header after 335015fe2d

hyprpm/src/core/PluginManager.cpp:165:43: error: use of undeclared identifier 'getuid'
  165 |     const std::string USERNAME = getpwuid(getuid())->pw_name;
      |                                           ^
hyprpm/src/core/PluginManager.cpp:431:45: error: use of undeclared identifier 'getuid'
  431 |     const std::string USERNAME   = getpwuid(getuid())->pw_name;
      |                                             ^
hyprpm/src/core/PluginManager.cpp:558:43: error: use of undeclared identifier 'getuid'
  558 |     const std::string USERNAME = getpwuid(getuid())->pw_name;
      |                                           ^
2024-04-30 14:14:31 +01:00
Sungyoon Cho
801437cd54 hyprctl: add missing json string escapes (#5811) 2024-04-30 14:13:36 +01:00
Vaxry
62ae2b3f40 pluginAPI/hooks: Remove dependency on cc from the hooksystem (#5801)
* Remove dependency on cc from the hooksystem

* Nix: remove cc from wrapper

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-04-30 02:54:43 +01:00
Vaxry
5edc32930d layerSurface: refactor/move to a memory-safe impl
Makes all the pointers smart to avoid memory issues
Refactors layerSurface code to live inside desktop/layersurface
2024-04-30 02:41:27 +01:00
Vaxry
5e6f7b1cdb cursor-shape: allow duplicate devices per pointer resource
fixes #5798
2024-04-30 00:05:29 +01:00
Vaxry
f2b03e9679 ext-idle-notify: move to new impl 2024-04-29 17:50:07 +01:00
Vaxry
86133983a9 xdg-activation: move to new impl 2024-04-29 16:43:24 +01:00
Vaxry
39595aaca3 hyprctl: make commits wrapped in quotes in json 2024-04-29 16:10:26 +01:00
thejch
a783cd8f40 log: Add some colors to stdout log 🔴🟡🟢🔵🟣 (#5778)
* add colored log

* add config option

* make it dynamic
2024-04-29 16:07:35 +01:00
Vaxry
33e0bb1478 wlr-output-power: move to new impl 2024-04-29 01:38:24 +01:00
Vaxry
a5a6480917 core: Move /tmp/hypr to $XDG_RUNTIME_DIR/hypr (#5788)
Moves the directory containing sockets and logs.
Also restructures lockfiles a bit.

For consumers, check if `$XDG_RUNTIME_DIR/hypr` exists. If so, use it. If not, use the old `/tmp/hypr`.
2024-04-28 22:25:24 +01:00
Vaxry
d20ee31210 hyprpm: fix updating headers
oopsie daisy
2024-04-28 21:32:22 +01:00
Vaxry
95a5e75c26 hooksystem: check for existing random outdir 2024-04-28 21:20:10 +01:00
Vaxry
335015fe2d hyprpm: fix for multi-user + improve directory structure 2024-04-28 20:27:44 +01:00
Vaxry
f7815dab42 compositor: more fs safety around tmp directories
HIS now includes a random bit, and hyprland will bail if /tmp/hypr is not a directory or if /tmp/hypr/his exists
2024-04-28 20:06:40 +01:00
Vaxry
b164e67d8b core: prefer mkdir over create_directory and permissions 2024-04-28 18:58:31 +01:00
Vaxry
28c8561924 hooksystem: use a random 700 directory for assembler 2024-04-28 18:28:19 +01:00
Vaxry
82a6fba6ec tokenmgr: separate getRandomUUID from registerNewToken 2024-04-28 18:17:48 +01:00
Vaxry
2e763764bf pointer-constraints: don't warp on entering a confined pointer
ref #5774
2024-04-27 21:15:33 +01:00
virchau13
90a53aed59 CrashReporter: fix deadlocks by making it mostly async-signal-safe (#5771)
`CrashReporter::createAndSaveCrash()` is not async-signal-safe,
resulting in random deadlocks/double-crashes during Hyprland crashes.
This changes the function to be (mostly) async-signal-safe.
2024-04-27 17:38:48 +01:00
niki-on-github
55490637aa windowrules: add subtract window option to move rule (#5770)
Co-authored-by: nix <nix@local>
2024-04-27 17:34:19 +01:00
Vaxry
e400a288d0 pointer-constraints: remove emoji to fix clang
fixes #5765
2024-04-27 13:27:24 +01:00
Vaxry
bca7804bb6 internal: Window storage rework - part 1 (#5762)
* Window storage rework - part 1

* format

* remove useless include

* fix pch

* format

* fix crash in dwindle

* fix vram leak

* prefer .expired() for bool checks
2024-04-27 12:43:12 +01:00
Vaxry
25aec3ac8c pointer-constraints: move to new impl 2024-04-27 03:17:04 +01:00
Vaxry
f94264928a swipe: fix crashes with invalid distance
fixes #5758
2024-04-26 19:11:28 +01:00
Vaxry
d9ec2785cb wlr-foreign-toplevel: send done after property changes
fixes #5753
2024-04-26 13:14:50 +01:00
Vaxry
1d40af64d3 text-input-v3: move to new impl 2024-04-25 23:27:44 +01:00
eriedaberrie
e87227e00a config: Default unconfigured monitors to open to the right (#5741)
* config: default unconfigured monitors to open to the right

* monitor: improve logging for auto positioning
2024-04-25 22:07:50 +01:00
eriedaberrie
faa9017043 renderer: fix rounding of the size of fractionally scaled monitors (#5748) 2024-04-25 18:52:49 +01:00
Vaxry
0652a20bd3 events: set window initial* before searching for rules 2024-04-25 16:57:11 +01:00
Vaxry
9fc3cb5629 foreign-toplevel: fix bad_any_cast in moveWindow
fixes #5740
2024-04-25 16:35:09 +01:00
Vaxry
01df3b73d8 shortcuts-inhibitor: move to new impl 2024-04-25 14:32:35 +01:00
Vaxry
ecf282d331 wlr-foreign-toplevel: move to new impl 2024-04-25 01:10:43 +01:00
zakk4223
72e31d3335 idle-inhibit: Always recheck idle inhibitors on creation and deletion (#5738)
Formatting
2024-04-25 00:05:19 +01:00
Vaxry
3878f806ff pointer-gestures: move to new impl 2024-04-24 21:36:56 +01:00
Vaxry
d86eec332f idle-inhibit: don't destroy inhibitor on surface destroy
fixes #5731
2024-04-24 19:15:01 +01:00
Vaxry
4540d8ccd5 style: fix clang-format 2024-04-24 16:45:54 +01:00
Vaxry
d27b5985c1 scripts: fix asan patch 2024-04-24 16:44:15 +01:00
Vaxry
932a0cd777 cmake: require hyprwayland-scanner 0.3.0 2024-04-24 16:39:18 +01:00
Virt
9fe409800b renderer: Fix mirrored displays when transformed and preserve aspect ratio (#5697)
* renderer: transform mirror buffer and preserve mirror aspect ratio

* renderer: render mirrors directly from offloadFB

* renderer: fix formatting

* renderer: use monitorMirrorFB again, but properly damage mirrors

* renderer: clean mirrors after reload and support cursor zoom mirroring
2024-04-24 16:29:41 +01:00
Vaxry
8aecd4f253 cursormgr: fix misscaled cursors on fractional 2024-04-24 16:18:38 +01:00
Vaxry
608eff600d tokens: add more modes to initial_workspace_tracking
1 is single-shot, 2 is persistent

fixes #5732
2024-04-24 16:16:52 +01:00
Agent00Ming
81bb4eb2f6 workspace: Fix duplication of "special:" in special workspace name (#5729)
* Fix duplication of "special:" in special workspace name
	modified:   src/desktop/Workspace.cpp

* Track default special workspace name as special:special
This is to fix the edge cases with the previous commit without breaking
user configs.

	modified:   src/helpers/MiscFunctions.cpp

---------

Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-04-24 16:07:22 +01:00
Vaxry
e5fa0007a5 foreign: fix no-pch builds 2024-04-24 16:03:56 +01:00
Vaxry
29b0529542 nix: bump inputs 2024-04-24 15:50:43 +01:00
Vaxry
0d1bb65c75 ext-foreign-toplevel: add implementation 2024-04-24 15:48:06 +01:00
Vaxry
34413d1f36 tokens: fix initial workspace token ignoring special
ref #5726
2024-04-24 02:06:13 +01:00
drendog
31d055f6d4 input: fix active keyboard for seat after destroying one (#5725)
* fix: manage active keyboard for seat after destroying one

* chore: clang-format
2024-04-23 23:30:35 +01:00
Vaxry
d119513749 renderer: fix safety around sendFrameEventsToWorkspace
ref #5718
2024-04-23 21:15:37 +01:00
Vaxry
bb4646bbdf compositor: properly update workspace in moveWindowToWorkspaceSafe
fixes #5714
2024-04-23 16:38:12 +01:00
Vaxry
a2366f78f0 renderer: send frame events to apps on empty damage renders
fixes #5711
2024-04-23 16:08:54 +01:00
Vaxry
cf3596a96d renderer: avoid rendering frame if finalDamage is empty 2024-04-23 12:29:01 +01:00
Vaxry
4f1214c7e9 windows: don't force workspace change on same tracked workspace 2024-04-23 11:37:20 +01:00
thejch
aab1df50ab CI: add no PCH build (#5708) 2024-04-23 11:02:51 +03:00
Mihai Fufezan
5fdd0bceac Meson & Nix: add libuuid dep 2024-04-23 07:01:20 +03:00
Vaxry
5262292abc cmake: add uuid to deps 2024-04-23 02:22:30 +01:00
Gabriel Ford
c3ec16f494 config: Add More Monitor 'Auto' Positions. (#5670)
* Reverse Window Positioning.

* Cleanup old comments and logs.

* Finish Splitting Left and Right offset.

* Forgot to add Auto Left to ConfigManager

* Fix problems with auto_left.

* Nearly finish up and down.

* Finish draft of all four dirs. Testing now.

* Change Y value in moveTo for up and down.

* Format, comment, and cleanup.

* Address Vaxry's feedback.

* Add check to see if auto position is first rule.

* Run clang-format.
2024-04-23 01:49:25 +01:00
Vaxry
29308b94ca windows: add misc:initial_workspace_tracking
By default enabled, will track the initial opened workspace of a window spawned for 2 minutes or until it's moved to a different workspace.

For example: you run a launcher and open an app on workspace 1, but quickly switch to workspace 2. The app will now open on workspace 1 regardless of your switch.
2024-04-23 01:49:23 +01:00
Vaxry
7778f01194 managers: Add a TokenManager 2024-04-23 01:28:27 +01:00
fred21O4
da839f20f1 CI/Nix: use hyprland cachix (#5701) 2024-04-22 23:58:27 +03:00
PostCyberPunk
855a516596 core: add libinput backend support for headless session (#5699) 2024-04-22 18:48:18 +01:00
Vaxry
012a2802e0 Protocols: implement protoLog 2024-04-22 18:44:25 +01:00
Vaxry
741c75d907 gamma-control: move to new impl 2024-04-22 18:21:03 +01:00
Vaxry
dafc9ed4eb pluginsystem: fix unhooking on exit 2024-04-22 15:57:03 +01:00
Vaxry
e91513a5e8 pluginapi: unregister callbacks on lost ptrs 2024-04-22 15:50:23 +01:00
Vaxry
450343b7b8 pluginsystem: unload entire plugin before calling dlclose()
fixes #5689
2024-04-22 15:46:43 +01:00
Matteo Quadrino
e1644e91ea config: polish default config file (#5672)
* polish default config file

polish default config, making it prettier by separating it in sections, and adding links to the wiki for each section.
No configuration was altered, I only made it prettier and more beginner friendly.
I propose this should also be used as the autogenerated config file at installation.

* update default config according to suggestions

* Update defaultConfig.hpp to match example

* remove some whitespace

* match default config

* restored string terminator
2024-04-22 10:31:29 +01:00
Mihai Fufezan
cbed4fa5ec flake.lock: update 2024-04-22 12:20:46 +03:00
Mihai Fufezan
a4f38a07d7 Nix: override wayland-protocols until merged 2024-04-22 00:38:28 +03:00
vaxerski
019d4900cb [gha] Nix: update wlroots 2024-04-21 20:34:55 +00:00
Vaxry
448e3208ca deps: update wlroots 2024-04-21 21:34:04 +01:00
Vaxry
8afdb8403b style: fix clang-format 2024-04-21 21:29:37 +01:00
Tom Englund
f041d763ae relative-pointer: fix missing header for g_pCompositor (#5681) 2024-04-21 21:24:07 +01:00
Vaxry
f587c3e0ba alpha-modifier: add support for protocol 2024-04-21 21:21:22 +01:00
Vaxry
87173bd09d protocols: fix for hyprwayland-scanner update 2024-04-21 21:20:48 +01:00
Vaxry
ed69502ff6 xdg-decoration: move to new impl 2024-04-21 20:04:58 +01:00
Vaxry
4954dcbbb3 relative-pointer: move to new impl 2024-04-21 19:30:23 +01:00
Vaxry
55f1f3fedf protocols: minor style improvements to new impls 2024-04-21 19:29:45 +01:00
Vaxry
75c87bde3c ci: Fix CI (#5679) 2024-04-21 18:33:03 +01:00
Vaxry
d9fe1d0f58 idle-inhibit: move to new impl 2024-04-21 16:54:52 +01:00
Vaxry
e823b5d693 Window: add destroy signal 2024-04-21 16:54:50 +01:00
SoSeDiK
e69bc5b870 config: Expand on window matching (#5518)
* Expand on window matching

* Requested changes
2024-04-21 15:19:59 +01:00
thejch
f47c89d495 git: ignore wlroots dirty (#5674) 2024-04-21 15:18:43 +01:00
Vaxry
93e5d7ca5a input: check for focused_client being null before reading its client
ref #5673
2024-04-21 15:17:12 +01:00
André Silva
1ce21fdb3e nix: fix missing git in wlroots build 2024-04-21 15:54:23 +03:00
Vaxry
4dc07c4378 keybinds: clear repeat source on mouse inputs
fixes #5671
2024-04-21 12:50:37 +01:00
vaxerski
8ca28dd510 [gha] Nix: update wlroots 2024-04-21 11:40:48 +00:00
Vaxry
9ce9bd9b0f deps: bump wlroots 2024-04-21 12:39:50 +01:00
thejch
7c3bd4c19f workspace: Add fullscreen workspace selector (#5640)
* add fullscreen selector

* use stoi
2024-04-21 01:50:08 +01:00
Vaxry
30e4b404f2 cursor-shape: move to new impl 2024-04-21 01:49:23 +01:00
Vaxry
a141bbbea5 helpers: Add new C++ Signal and Listener classes
A memory-safe alternative to wl_signal
2024-04-21 01:47:45 +01:00
fufexan
a10a6fff55 [gha] Nix: update inputs 2024-04-21 00:03:53 +00:00
Vaxry
4ad739ec63 HookSystem: improve callback safety 2024-04-20 20:16:42 +01:00
Vaxry
1055e6bee6 wayland-protocol: remove unused CWaylandResource 2024-04-20 19:40:01 +01:00
Vaxry
84ee839ca6 XDG-Output: move to hyprwayland-scanner 2024-04-20 19:39:59 +01:00
Yaroslav
a945346064 core: remove libsystemd dependency (#5660)
* remove libsystemd dependency

as per Lennart Poettering's advice:
https://github.com/systemd/systemd/issues/32028#issuecomment-2031366922

* fix naming for systemd helper functions

* rename vars according to code style

* Nix: update meson patch

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-04-20 18:50:07 +01:00
Vaxry
ea47e8c92a Fractional-scale: move to new impl 2024-04-20 14:19:16 +01:00
Vaxry
ea95449402 core: Move tearing to hyprwayland-scanner (#5657)
Adds a new dependency: hyprwayland-scanner https://github.com/hyprwm/hyprwayland-scanner

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-04-20 13:25:29 +01:00
Gabriel Ford
5c97b96278 config: Allow more sensible input options for enabling animations. (#5659)
* Add check for on/off and true/false.

* Cleanup feature and comment it out.

* Use already created helper function for this.

* Fix comparing int to char* ptr
2024-04-20 12:26:48 +01:00
thejch
10caa03ce5 config: merge all rules set for the same workspace selection (#5656) 2024-04-20 02:20:16 +01:00
Vaxry
1ebc32f5f4 tearing-control: search through all valid windows
ref #5655
2024-04-20 00:08:49 +01:00
Vaxry
b52a49b4c4 tearing-control: hyprland impl (#5655)
* tearing: hl impl

* format
2024-04-19 22:16:35 +01:00
Yixun Lan
1016faea53 misc: fix autocompletions for meson (hyprctl/hyprpm)
Signed-off-by: Julien Roy <julien@jroy.ca>
2024-04-19 21:09:10 +03:00
Sungyoon Cho
dd39cd7e42 windows: recalculate monitor after updating windows (#5647)
Recalculate monitor after updating windows, so layout render doesn't get
overridden.
2024-04-19 18:46:16 +01:00
zakk4223
4d0a635237 workspace: Add 'v' flag for workspace selector that counts only visible windows (#5628)
* Add 'v' flag for workspace selector: counts only visible windows

* extra commit because I'm dumb

* guard
2024-04-19 02:44:51 +01:00
Epikastema
82222342f1 shaders: Use sin-less hash for noise (#5607) 2024-04-17 19:01:50 +01:00
Thomas Lindae
78b04c3a76 hyprctl: fix activewindow request not showing workspace name (#5623) 2024-04-17 17:44:46 +01:00
Maarten de Vries
e57a2d7ec8 keybindmgr: add optional silent suffix to movewindow. (#5597)
With the `silent` suffix, the focus remains on the current position in
the layout or the current monitor, instead of following the moved
window. When combined with `movewindow mon:X`, this this allows you to
get the same behavior as xmonad's `windowToScreen` command.
2024-04-17 12:04:16 +01:00
Vaxry
e8e02e81e8 README: minor cleanup 2024-04-16 20:36:21 +01:00
Vaxry
fe7b748eb6 props: bump version to 0.39.1 2024-04-16 17:01:03 +01:00
Vaxry
eeca50e3dc hyprpm: err out on missing runtime deps 2024-04-16 16:59:06 +01:00
vaxerski
9a66514e26 hyprpm: shallow since a week before commit date
timezones, etc.

ref #5612
2024-04-16 15:41:11 +01:00
vaxerski
32555e98dd window: remove input ref on unmap
ref #5605
2024-04-16 15:17:54 +01:00
Mihai Fufezan
79a139c949 flake.lock: update 2024-04-15 23:57:27 +03:00
FUFSoB
c99803af15 notifications: fix notifications on manually rotated monitor (#5599) 2024-04-15 21:47:39 +01:00
Vaxry
02cbf049d2 hyprpm: checkout branch and rev separately
sometimes the branch is garbled by incorrect packaging
2024-04-15 19:16:25 +01:00
Vaxry
ccbdce7c85 input: send an empty relative event after constraint motion events
ref #4015
2024-04-15 17:22:25 +01:00
Vaxry
3dbf8e936e cursor: add hyprcursor loggers 2024-04-15 16:45:08 +01:00
Vaxry
d1c2d524a0 misc: fix autocompletions for meson (hyprctl/hyprpm)
Signed-off-by: Florian sp1rit <sp1rit@disroot.org>
2024-04-15 16:02:22 +01:00
Jan Beich
2ea367839b build: Unbreak build on FreeBSD by adjusting dependencies (#5595)
* deps: add epoll-shim for some BSDs after 863c7b6072

ld: error: undefined symbol: timerfd_create
>>> referenced by EventLoopManager.cpp
>>>               src/Hyprland.p/managers_eventLoop_EventLoopManager.cpp.o:(CEventLoopManager::CEventLoopManager())

ld: error: undefined symbol: timerfd_settime
>>> referenced by EventLoopManager.cpp
>>>               src/Hyprland.p/managers_eventLoop_EventLoopManager.cpp.o:(CEventLoopManager::nudgeTimers())

See also
https://github.com/freebsd/freebsd-src/commit/af93fea71038
https://github.com/netbsd/src/commit/75f1bc6655cf

* deps: drop unused xcb-image after 45945a3e7d

$ pkg install <hyprland dependencies>
$ pkg install meson jq `pkg rquery %dn wlroots` hwdata
$ gmake all
[...]
-- Checking for modules 'xcb;xwayland;xcb-util;xcb-render;xcb-image;xcb-xfixes;xcb-icccm;xcb-composite;xcb-res;xcb-ewmh'
--   Package 'xcb-image' not found
CMake Error at /usr/local/share/cmake/Modules/FindPkgConfig.cmake:619 (message):
  The following required packages were not found:

   - xcb-image

Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindPkgConfig.cmake:841 (_pkg_check_modules_internal)
  CMakeLists.txt:177 (pkg_check_modules)

See also
https://github.com/swaywm/wlroots/commit/ae7c3f3d1c56
2024-04-15 14:42:17 +01:00
Vaxry
1719905e7f CI: unshallow on checkout before sourcing the tarball 2024-04-15 02:05:45 +01:00
Vaxry
ce4c36392d hyprpm: minor fixes to hyprpm for shallow and versioned clones 2024-04-15 01:57:10 +01:00
vaxerski
67f47fbdcc [gha] Nix: update wlroots 2024-04-14 20:33:15 +00:00
thejch
043a40cd7a deps: update wlroots (#5592) 2024-04-14 21:32:19 +01:00
LivingCodeX
fd7ea4f27c constraint: Fix xwl cursor locking for scaled monitors (#5587)
* Fix xwl cursor locking for scaled monitors

* Add null check for window

* Replace m_fLastScale with m_fX11SurfaceScaledBy

* Improve code style

* Improve code style via clang-format
2024-04-14 21:31:50 +01:00
Vaxry
e93fbd7c4f props: bump ver to 0.39.0 2024-04-14 19:48:28 +01:00
go0d1uck
83ab0f2d66 keybindmgr: fix workspace_back_and_forth (#5585) 2024-04-14 14:54:00 +01:00
MightyPlaza
0634aaeac6 renderer: remove border on fullscreen (#5577)
modified:   src/render/Renderer.cpp
2024-04-14 00:16:26 +01:00
André Silva
61fe47189b build: update asan patch (#5562) 2024-04-13 22:13:08 +01:00
Yaroslav
9e4b2efe7e cmake: Some small cmake cleanups (#5572)
* remove unnecessary include

* cmake: use pkg_get_variable

We can find wayland-scanner executable and wayland-protocols dir by
taking advantage of this function, so no need to use find_program or
manually call pkgconf executable.

* cmake: remove explicit rdynamic option

CMAKE_ENABLE_EXPORTS=ON already implies rdynamic so it's redundant to
set the latter explicitly.

Also, CMAKE_ENABLE_EXPORTS is superseded by
CMAKE_EXECUTABLE_ENABLE_EXPORTS in cmake 3.27.

* cmake: make xcb-errors dep optional

xcb-errors is being used in wlroots, where it's optional. So make it
optional in hyprland as well
2024-04-13 14:40:28 +01:00
thejch
d96501442f core: Fix double special workspace (#5574)
* fix double special name

* fix special on another monitor

* remove extra stuff
2024-04-13 14:39:20 +01:00
thejch
582d6233c8 workspace: fix workspace name selector returning true early (#5571) 2024-04-13 01:55:17 +01:00
thejch
34396f55a2 master: change the mfact dispatcher to use splitratio (#4766)
* master layout: change the mfact dispatcher to use splitratio

* add space for concat
2024-04-13 01:54:18 +01:00
Vaxry
0c513ba91b CI: fix packaging 2024-04-12 20:46:21 +01:00
Vaxry
dd6fdf49d9 window: always unref workspace on unmap
fixes #5563
2024-04-12 19:52:01 +01:00
Vaxry
ddcdb56f2c CI: fix arch 2024-04-12 19:50:36 +01:00
bvr-yr
32147f5e91 hyprpm: fix wlroots path (#5567) 2024-04-12 19:49:33 +01:00
Mihai Fufezan
d8d0d3b20b Nix & Meson: switch to wlroots-hyprland 2024-04-12 20:39:00 +03:00
Vaxry
382b6d3f6b makefile: move wlr headers dir 2024-04-12 18:07:04 +01:00
Vaxry
0a70ccd099 Makefile: remove refs to libwlroots 2024-04-12 17:58:18 +01:00
vaxerski
e1e11f5a87 [gha] Nix: update wlroots 2024-04-12 15:32:45 +00:00
Vaxry
45945a3e7d deps: move from wlroots to wlroots-hyprland 2024-04-12 16:31:50 +01:00
Vaxry
b1a9430289 inhibitor: always destroy on window unmap
ref #5555
2024-04-12 00:18:58 +01:00
Jan-Peter Dhallé
e0a7cf5c30 master: fix full height when all windows master (#5549) 2024-04-12 00:05:30 +01:00
Vaxry
185a3b4881 swipe: nuke numbered
fixes #5424

use_r instead
2024-04-11 12:46:19 +01:00
TheOnlyMrCat
47e5b41fea renderer: Add dimaround layer rule (#4643) 2024-04-11 12:41:18 +01:00
Vaxry
ac0f3411c1 macros: fix no pch warning 2024-04-11 02:13:05 +01:00
Vaxry
abc131ec7b configmgr: fix header priority 2024-04-11 02:12:29 +01:00
Ben Landon
558d1be7e3 hyprpm: Improve Hyprpm Update Performance (#5530)
* hyprpm: only clone the required history

* hyprpm: don't include tracy when building headers in release mode

* chore: remove old, commented-out code

See https://github.com/hyprwm/Hyprland/pull/4585#discussion_r1474780294

* chore: format code properly
2024-04-10 17:33:50 +01:00
SoSeDiK
0b2f7a1b2f cursor: Fallback to xcursor if failed to render hyprcursor (#5534) 2024-04-10 17:29:17 +01:00
Sungyoon Cho
c35fa9bacc workspace: update windows when selector match could change (#5533)
* workspace: update windows when group updates

* workspace: update windows when floating toggle

* workspace: update windows when stop dragging window by mouse
2024-04-10 17:26:11 +01:00
Vaxry
b573c20125 monitor: add workspace null check to visible flag
ref #5524
2024-04-10 17:21:45 +01:00
JManch
303b9956b2 hyprctl: print monitor disabled status (#5525) 2024-04-10 09:50:00 +01:00
SoSeDiK
1343aa865d config: Don't override fullscreen opacity if only two opacities are provided (#5512) 2024-04-09 16:22:44 +01:00
SoSeDiK
f2addfb404 props: Parse border color props as gradient (#5513) 2024-04-09 16:14:53 +01:00
Sungyoon Cho
fcac25bcc2 workspace: Add count group flag in windowCount workspace selector prop (#5499)
* Add groupCount workspace selector prop

* Intergrate groupCount with windowCount
2024-04-09 12:08:38 +01:00
ErrorNoInternet
f6786f04d2 hyprpm: install shell completions 2024-04-09 12:38:06 +03:00
ErrorNoInternet
c7b87e0aed hyprctl: fix fish completions 2024-04-09 12:38:06 +03:00
postsolar
d0d1ba5918 hyprctl: fix zsh completions
The file missed a line required by all ZSH completions in order to be automatically loaded
2024-04-09 07:08:54 +03:00
dranull
a06272ae55 input: Option for handling off-window axis events (#4177) 2024-04-08 23:35:21 +01:00
Mihai Fufezan
277f2bb76a Nix: add pkgconf 2024-04-08 20:54:06 +03:00
Vaxry
0457c2e348 pkg-config -> pkgconf for hyprpm and cmake 2024-04-08 20:54:06 +03:00
Tom Englund
125a8f7e07 workspace: fix crash on destruction of compositor (#5495)
when the compositor destructs because of exiting hyprland the
hookmanager and eventmanager is already destroyed, add an if check in
the destructor of workspace so it doesnt segfault on exit.
2024-04-08 18:28:11 +01:00
Vaxry
63e3668529 style: run clang-format 2024-04-08 15:33:02 +01:00
Tom Englund
db91d949f7 compositor: move wl_display_destroy_clients (#5498)
if enough clients are open when destructing the compositor destroying
clients will emit a wl_surface_unmap that a WLListener catches and doing
so it calls listener_unmapLayerSurface that tries to iterate over input
manager that is already destroyed, move the destruction of clients above
g_pInputManager.reset() and removeAllSignals() to ensure we dont
segfault at exit.
2024-04-08 15:32:31 +01:00
Vaxry
785d9d9521 config: verify string length in wrv2 before calling back
ref #5431
2024-04-08 15:27:13 +01:00
SoSeDiK
43b96f03b5 props: Allow setting per-window fullscreen opacity (#5470) 2024-04-07 23:19:02 +01:00
MightyPlaza
df1a3a978d input: don't remove pinned focus on workspace change (#5486)
modified:   src/helpers/Monitor.cpp
2024-04-07 23:13:56 +01:00
Vaxry
7d989f2cf0 damageSurface: don't correct smallVec twice 2024-04-07 22:25:34 +01:00
Vaxry
863c7b6072 eventloop: move timers to an event loop fd
fixes #5481
2024-04-07 21:55:29 +01:00
Mihai Fufezan
c0d283016b flake.lock: update
Contains hyprcursor 1.6
2024-04-07 22:52:10 +03:00
LOSEARDES77
20899d0df2 hyprpm: add shell completions (#5423)
* hyprpm: add completions

* hyprctl: correct spell mistakes

* Apply fixes

* makefile: correct shell completion paths

* makefile: remove complletions on uninstalling
2024-04-07 19:39:46 +03:00
Yaroslav Lelkin
b50182326c cmake: make sure that OpenGL::EGL is populated
bump cmake version cause 3.27 is the version where "... COMPONENTS
GLESx" option is introduced. See
https://cmake.org/cmake/help/latest/module/FindOpenGL.html
2024-04-07 19:08:25 +03:00
thejch
89f775aec2 master: fix crash (#5472) 2024-04-07 15:21:12 +01:00
Junxuan Liao
d657b59f70 IME: fix IME popup mouse inputs (again) (#5417)
`lastBoxLocal`'s size should be the actual popup's size instead of the cursor
rectangle's size. Also, the rectangle position is now relative to the popup.
(Actually fixes #5255 imho.)

One thing #3922 missed was handling focus held by buttons. Let's hope I get
it right this time.
2024-04-07 15:15:50 +01:00
Vaxry
f2a848cbcc core: Event loop rework (#5466)
* Event loop rework

* revert missed
2024-04-07 03:31:51 +01:00
thejch
9f1604e4b0 input: Dont set active monitor when simulating mouse movement (#5465)
* fix mouse simulation switching focusedmon

* fix some warnings with wrong enum
2024-04-07 01:07:21 +01:00
thejch
e80bccad51 master: fix workspace orientation not being restored after workspace rule no longer applies (#5463) 2024-04-06 23:49:38 +01:00
Vaxry
ff114cf6f9 input: fix focus on maximized bg surfaces 2024-04-06 18:59:23 +01:00
Vaxry
d846e82832 makefile: add patch option to make asan 2024-04-06 18:50:04 +01:00
Vaxry
fa79aacea3 constraint: fix possible uaf on double destruction
ref #5448
2024-04-06 18:43:17 +01:00
fred21O4
265c7924d8 flake.nix: add hyprcursor follows (#5435)
fixes a duplicate hyprlang instance sometimes being created due to hyprcursor not following hyprlands instance
2024-04-06 19:18:43 +03:00
Mihai Fufezan
3d64b0e9f0 flake.lock: update 2024-04-06 19:09:37 +03:00
Sungyoon Cho
04d067d78b IME: fix race condition on closing window (#5455) 2024-04-06 15:54:02 +01:00
staz
1596e2d1f7 workspacerules: add back on-created-empty functionality (#5452)
* workspacerules: add back on-created-empty functionality

* clang format

* workspacerules: spawn on-created-empty window while initializing CWorkspace

* clang format

* configManager: fix typo

---------

Co-authored-by: Your Name <you@example.com>
2024-04-06 15:53:32 +01:00
Vaxry
6cea710ac8 scripts: switch to branch --show-current for branch in generateVersion 2024-04-06 15:40:06 +01:00
Vaxry
f081a4300f input: fixup background layer checking on maximized 2024-04-06 15:18:58 +01:00
Vaxry
159444c45b compositor: fix ghost fadingOut windows remaining after cleanup 2024-04-06 14:59:30 +01:00
Vaxry
f8c22916ab compositor: remove windows from fadingOut properly 2024-04-06 14:51:35 +01:00
Vaxry
24734fbf1d subsurface: init existing subsurfaces on children creations
fixes #5333
2024-04-06 03:09:20 +01:00
Vaxry
dab149e4a6 core: fix compile without pch
fixes #5445
2024-04-05 21:23:28 +01:00
Vaxry
b5b1c0137d CColor: fix getAsHex 2024-04-05 21:23:06 +01:00
Vaxry
094bce8118 core: simplify sanityCheckWorkspaces 2024-04-05 19:43:51 +01:00
Vaxry
4909b0f350 monitor: unset visible flag from ws on disconnect
ref #5443
2024-04-05 19:25:40 +01:00
Vaxry
965a2e5b21 hooksystem: attempt allocating pages in linear order 2024-04-05 17:16:09 +01:00
Vaxry
f815a33f64 workspace: remove monitor and visible flags on inert 2024-04-05 16:57:49 +01:00
Vaxry
0051b078a1 monitor: check for invalid workspaces in onConnect
ref #5443
2024-04-05 16:57:49 +01:00
thejch
1e8f57c734 workspacerules: fix workspace rule loops (#5433) 2024-04-05 16:54:30 +01:00
Martin Sundhaug
942172d2dc hooksystem: Fix miscalculation in comment (#5442) 2024-04-05 12:56:53 +01:00
bvr-yr
baad44b4ca hyprpm: fix incorrect commits number parsing (#5437) 2024-04-05 04:40:44 +01:00
Vaxry
12d75c0c26 hyprpm: ignore version checks for shallow clones 2024-04-05 03:00:34 +01:00
Vaxry
1ae592fcd9 hyprpm: add support for minimum versions 2024-04-05 00:46:37 +01:00
Vaxry
51b3148f09 hyprpm: print more info on build failures 2024-04-05 00:23:05 +01:00
Vaxry
1454c6213e window: fix invalid last workspace id
ref #5432
2024-04-04 22:49:15 +01:00
Vaxry
ec2cc79c65 renderer: avoid double-rendering ls-es on fadingOut
fixes #5295
2024-04-04 22:43:57 +01:00
Vaxry
0569b9c300 hooksystem: manually map trampoline addresses
better patching of rip calls as we are close enough to just change them up
2024-04-04 18:50:37 +01:00
Vaxry
cba9c5ff95 core: fix visibility flags in moveWorkspaceToMonitor
fixes #5416
2024-04-04 18:30:50 +01:00
Sungyoon Cho
c4b660a339 IME: fix crash on restarting IME (#5428) 2024-04-04 17:34:04 +01:00
Vaxry
4f3e90ad2d popups: more safety in damage checking 2024-04-04 16:42:30 +01:00
end-4
9b8ef9206d layers: separate anim configs for open/close (#5421) 2024-04-04 16:41:09 +01:00
zakk4223
846162cce1 hyprpm: Use proper path to update repo when processing user provided revision (#5414) 2024-04-04 16:33:36 +01:00
Mihai Fufezan
81766647f2 hyprctl: fix grammar mistakes in completions 2024-04-04 10:49:25 +03:00
LOSEARDES77
1b43cd5231 hyprctl: Add shell completions (#5404) 2024-04-04 10:21:20 +03:00
Vaxry
b7d71bc0e1 keybinds: fix spammy warning 2024-04-04 01:16:47 +01:00
Vaxry
9cf563065a layouts: add missing include 2024-04-04 01:10:46 +01:00
Vaxry
36a8ae9bda input: allow focus to bottom layers on maximized in reserved 2024-04-03 21:57:19 +01:00
Micovec
949eb42613 hyprctl: improve help pages (#5385) 2024-04-03 23:41:10 +03:00
Vaxry
d605e47511 renderer: block screen shader on screencopy 2024-04-03 21:35:16 +01:00
Vaxry
10146f5ec5 core: fix some crash conditions around workspace ptrs in CWindow
ref #5402, supersedes #5409
2024-04-03 20:42:38 +01:00
Vaxry
d88d589880 swipe: add events 2024-04-03 19:20:47 +01:00
Vaxry
93915502d2 blur: block modif only on no new optimize 2024-04-03 17:08:11 +01:00
Vaxry
91061a2084 opengl: fix modif in blur 2024-04-03 15:08:29 +01:00
Vaxry
64964c4e3b renderer: render back layer for workspace-less passes 2024-04-03 14:28:15 +01:00
Vaxry
3981f85e94 opengl: log framebuffer errors 2024-04-03 14:24:15 +01:00
Vaxry
efdc1af044 renderer: some fixes for renderModif 2024-04-03 14:09:58 +01:00
Vaxry
347b839034 workspaces: add visible flag 2024-04-03 10:09:48 +01:00
thejch
fbdaf74a82 master: fix swapped workspaces (#5397) 2024-04-03 01:22:59 +01:00
thejch
3965faafac master: fix center resizing (#5394) 2024-04-03 01:22:27 +01:00
MightyPlaza
153c8f35ce workspace: fix special unnamed workspace rules (#5390)
modified:   src/desktop/Workspace.cpp
2024-04-02 22:58:45 +01:00
Vaxry
ef23ef60c5 Workspace/core: Refactor workspace storage (#5380)
* refactor workspaces to use ptrs

* clang-format
2024-04-02 20:32:39 +01:00
Vaxry
fc0a7af7ba IME: fix blurry ime on scaled
ref #5387
2024-04-02 16:10:55 +01:00
Vaxry
05eb2d4af2 master: guard window in moveWindowTo
fixes #5374
2024-04-02 12:46:15 +01:00
Sungyoon Cho
04a35891a1 IME: fix incorrect popup damage (#5383) 2024-04-02 12:22:41 +01:00
Vaxry
2e5b146e57 workspace: remove lastFocusedWindow on unmap 2024-04-02 12:10:03 +01:00
Vaxry
af3a61a4e4 core: assert attempted UAFs in windowExists
in prep of removing the thing altogether
2024-04-02 01:15:58 +01:00
Jan Beich
c377caee7a hyprerror: align 32-bit types after 4c796683c0 (#5375)
src/hyprerror/HyprError.cpp:64:33: error: no matching function for call to 'min'
    const auto   VISLINECOUNT = std::min(LINECOUNT, *LINELIMIT);
                                ^~~~~~~~
/usr/include/c++/v1/__algorithm/min.h:40:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('int' vs. 'long long')
min(const _Tp& __a, const _Tp& __b)
^
/usr/include/c++/v1/__algorithm/min.h:51:1: note: candidate template ignored: could not match 'initializer_list<_Tp>' against 'int'
min(initializer_list<_Tp> __t, _Compare __comp)
^
/usr/include/c++/v1/__algorithm/min.h:60:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided
min(initializer_list<_Tp> __t)
^
/usr/include/c++/v1/__algorithm/min.h:31:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
2024-04-01 21:18:18 +01:00
Vaxry
3875679755 props: bump ver to 0.38.0 2024-04-01 19:30:37 +01:00
Sungyoon Cho
db1506130b IME: Fix ime popup coordinates and artifacts (#5373)
* ime: fix incorrect popup coordinate

* ime: fix popup artifacts
2024-04-01 16:37:59 +01:00
Vaxry
108163f1e5 animations: simplify window loop 2024-04-01 16:22:24 +01:00
thejch
7513c0cea5 renderer: Fix layer and window damage sometimes missing 1 frame (#5370)
* fix the layer and window damage missing 1 frame sometimes

* remove extra loop
2024-04-01 16:21:45 +01:00
thejch
800dbf71b0 renderer: Fix rendering when swiping workspaces (#5367)
* fix rendering on swiping

* add alpha check

* fix floating fs check
2024-04-01 16:16:18 +01:00
Vaxry
416b3d6167 socket2: sanitize data for newlines 2024-04-01 03:54:11 +01:00
thejch
ef7ac53e99 master: Make master workspace orientation rule dynamic (#5339)
* make master workspace orientation rule dynamic

* fix rebase

* fix special ws resizing

* style
2024-04-01 03:02:47 +01:00
thejch
9ae0c47a21 deco: fix groupbar offset (#5364) 2024-04-01 02:58:21 +01:00
Sungyoon Cho
ecc1f22e05 textinput: fix typo (#5365) 2024-04-01 00:41:00 +01:00
Micovec
8cb38d41d2 hyprctl: fix plugin list on no plugins (#5357) 2024-03-31 21:45:22 +01:00
Vaxry
9e8f051896 avar: minor fixes 2024-03-31 21:43:08 +01:00
Vaxry
64c8ba2fb1 avar: fix warp onEnd conditions
ref #5348
2024-03-31 21:34:11 +01:00
Vaxry
4156b55cf9 textinput: send deactivate on disable ti
ref #5288
2024-03-31 21:30:36 +01:00
thejch
e1e41e5448 reenderer: Add 1 border damage to fix number rounding issues (#5343)
* add 1 to border damage to avoid rounding issues

* add 1 to rounding too
2024-03-31 14:59:22 +01:00
thejch
16a9c16d9f renderer/animations: Fix various inaccurate damage tracking issues and offsets (#5297) 2024-03-31 02:14:26 +01:00
Zach DeCook
1cc9a44318 input: Fix incorrect keyboard focus taken when no window was present (#5337)
A non-keyboard layer never needs keyboard focus
2024-03-31 00:50:25 +00:00
thejch
5e8c25d498 core: match all workspace rules instead of the first one only (#5340) 2024-03-31 00:49:53 +00:00
Aqa-Ib
1aed45f61d core: Fix resizeparams (#5262)
* Revert a94b902

* Fix resizeparams using CVarList

* clang-format

* fix

* Use 's' as delimiter

* remove size checks

* fix tabs

* fix mixing tabs and spaces
2024-03-31 00:48:39 +00:00
Vaxry
77f26997fd IME: don't assert on lock mismatch, just fix it 2024-03-30 17:01:02 +00:00
thejch
906e498144 dispatchers: open special ws on active monitor instead of mouse monitor (#5330) 2024-03-30 16:58:18 +00:00
thejch
a17d7ba87b dispatchers: fix swap workspaces wrong positioning of floating windows (#5328) 2024-03-30 16:57:43 +00:00
Vaxry
6fb8f50205 hyprpm: avoid crashes on corrupted headers
ref #5329
2024-03-30 03:09:22 +00:00
Vaxry
54376d7b5f compositor: remove windows from fading out on destroy
ref #5321
2024-03-29 19:07:18 +00:00
Vaxry
3d1bf1405e keybinds: add binds:disable_keybind_grabbing
fixes #5273
2024-03-29 18:57:16 +00:00
Muhamed Hobi
53aa184d20 makefile: Remove old headers first (#5316)
Windows.cpp was moved and I found myself having both versions in my include. Clear out the headers before dumping new ones.
2024-03-29 14:07:33 +00:00
Vaxry
fcd9d77b64 layout: improve initial size prediction for floating 2024-03-29 00:43:50 +00:00
Vaxry
2930c5cb6f animvar: fixup update callbacks and cleanup 2024-03-29 00:23:23 +00:00
Mihai Fufezan
d8429eebc6 flake.lock: update
Fixes #5301
2024-03-28 18:44:00 +02:00
MightyPlaza
187caf4187 layers: don't change workspace on layer restore focus (#5308)
modified:   src/events/Layers.cpp
2024-03-28 14:15:34 +00:00
MightyPlaza
647d5a4ffc layers: fix bottom slide animation (#5307)
modified:   src/helpers/WLClasses.cpp
2024-03-28 14:14:27 +00:00
Vaxry
2571875453 format: fix format 2024-03-28 02:28:22 +00:00
MightyPlaza
c24034eb9d core: fix fullscreen + floating focus change (#5291)
modified:   src/Compositor.cpp
2024-03-28 02:08:21 +00:00
Vaxry
0869f65b0b input: add misc:hide_cursor_on_key_press
fixes #3045
2024-03-28 02:07:06 +00:00
Vaxry
132ab8d035 layers: add animation direction overrides
fixes #5285
2024-03-28 01:39:29 +00:00
vaxerski
93d0511471 layershell: update render pos and size in arrange
fixes #5258
2024-03-27 16:30:08 +00:00
Sungyoon Cho
ae52b7f468 textinput: fix ime when opening multiple windows (#5281) 2024-03-26 15:16:09 +00:00
Khalid
9b7ae25ae8 hyprctl: output json with --batch if requested (#5277) 2024-03-26 13:38:54 +00:00
vaxerski
1a0b8d1263 renderer: minor fixes to misaligned reported surface rendering
fixes #5257
2024-03-26 13:35:03 +00:00
Vaxry
a9d7526aae core: ensure m_pLastMonitor validity over unsafe state
ref #5241
2024-03-26 02:26:19 +00:00
thejch
414e37996d github: fix github issue template crash dir (#5269) 2024-03-26 02:21:31 +00:00
Vaxry
ae17e900e7 layer-shell: render popups above everything 2024-03-25 16:20:30 +00:00
Vaxry
ca17a89d86 renderer: allow blurring ls popups 2024-03-25 16:09:02 +00:00
thejch
356414639f core: fix missing workspace events during swapping (#5251) 2024-03-25 01:50:41 +00:00
dmayle
6b28bf563e keybinds: Fix exit trigger by moving it to monitor.frame (#5240) 2024-03-25 01:46:59 +00:00
thejch
8001b96bb5 renderer: dont render fullscreen special on wrong monitor (#5249) 2024-03-25 01:41:56 +00:00
Vaxry
89543e8e3c cursormgr: don't set x theme in changeTheme 2024-03-24 20:48:56 +00:00
Brett Alcox
03e99f93ae renderer: forward decl for b_pch=false (#5250) 2024-03-24 20:38:10 +00:00
Vaxry
294ff8609f cursormgr: log theme loading failures 2024-03-24 19:39:56 +00:00
Vaxry
1e82d5a04d ime: fix build without pch 2024-03-24 17:19:35 +00:00
Vaxry
5cc4bf699c IME: Refactor and fixup popups 2024-03-24 16:08:25 +00:00
Vaxry
acf15e5579 text-input: reset lock counter on surface destroy
fixes #5231
2024-03-24 15:00:00 +00:00
Vaxry
86dc46ffea animationmgr: use realpos and size for border damage
fixes #5239
2024-03-24 03:09:46 +00:00
Vaxry
09e1128da2 cursormgr: initialize size to 0
Because the ctor expects that. Ref #5237
2024-03-24 02:21:36 +00:00
Vaxry
432924b372 xwayland: assign wlr_surface on associate 2024-03-24 02:21:36 +00:00
thejch
c7fbea3368 animations: Fix animation issue in focusworkspaceoncurrentmonitor (#5202)
* dont render when workspace offset

* add guard

* can remove useless code now if workspace offset is not taken into account

* clang-format

* when special workspace is moved, set anim to move

* add offset back

* make it a configurable option because some folks apparently can't align their monitors correctly and may not want this feature😔

* remove config option
2024-03-23 22:14:50 +00:00
Vaxry
295128ab2a window: assign surface on create
ref #5076
2024-03-23 22:10:37 +00:00
Sungyoon Cho
2d5fda4810 input: fix crash with text-input-v1 (#5234) 2024-03-23 21:12:27 +00:00
Vaxry
0d91f82d83 config: be a bit louder in the disabled log warning 2024-03-23 21:11:00 +00:00
Khalid
059e85ae69 input: Add options to set tablet's active area (#5199)
* Add options to set tablet's active area

* Set tablet's active area in `setTabletConfigs`

* Fix formatting for new variables in ConfigManager

* Report tablet's physical size with hyprctl
2024-03-23 20:31:03 +00:00
fufexan
0dfdb6678f [gha] Nix: update inputs 2024-03-23 00:03:18 +00:00
Vaxry
9f2ed02f35 IME/TI: Fixes and refactoring
Fixes #5189
2024-03-22 23:08:52 +00:00
Vaxry
8c88689faf IME: guard unfocused TIs in leave 2024-03-22 18:58:28 +00:00
Vaxry
568b352b23 cmakelists: remove oopsie 2024-03-22 18:52:07 +00:00
Vaxry
d2b42e29c6 IME: fix crashes with destroyed text-inputs
ref #5189
2024-03-22 18:45:28 +00:00
Vaxry
461757e2fb scripts: fix asan patch 2024-03-22 18:45:28 +00:00
MightyPlaza
397e08c16a input: focus window on mouse down on groupbar (#5224)
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
2024-03-22 17:41:20 +00:00
Holger Schurig
c7c0e795d2 CGradientValueData: fix toString() method (#5220) 2024-03-22 17:34:51 +00:00
drendog
9bad62b85f layershell: release all mouse buttons before focus on new ls (#5219) 2024-03-22 01:28:50 +00:00
Philipp Schilk
a94b902bef windowrules: Fix resizeparams parsing. (#5206)
Parsing of resizeparams/relative vec2 did not correctly handle
multiple spaces between x and y arguments, causing the following
to fail to parse:

bind = $mainMod CTRL, h, resizeactive,  10       0

This is unexpected, because most other config values are whitespace
insensitive.
2024-03-21 15:18:24 +00:00
Andrey Donets
997ee82bdf hyprctl: add missing commands to usage (#5211) 2024-03-21 14:57:06 +00:00
Praneeth Jain
f1d06b773f hyprpm: add missing newline (#5207) 2024-03-21 14:50:19 +00:00
jill
ee00cb1dd8 opengl: report shader compilation errors from screen_shader (#5138)
* opengl: report shader compilation errors from screen_shader

* opengl: prefer .data()

* opengl: move shader error logging to logError

* opengl: quick glGetShaderiv -> glGetProgramiv fix

* opengl: typo fix

* opengl: format fixes

* opengl: minor compile fixes

* opengl: logError -> logShaderError
2024-03-21 14:46:23 +00:00
zakk4223
4c796683c0 config: Config error limit/hyprctl (#5165)
* Add error_limit to limit the number of config error messages shown in notification

* Add configerrors hyprctl command

* Formatting

* Formatting for not my code

* Use CVarList, add escapeJSONStrings

* Add indication there are more undisplayed errors

* Restore suppress_errors; move getErrors() to ConfigManager

* Formatting, wtf

* Format
2024-03-21 01:55:13 +00:00
Brett Alcox
214ec82ba7 build: fix builds without pch (#5198) 2024-03-21 01:54:10 +00:00
Horror Proton
bfc95e992d swipe: fix nullptr in onSwipeUpdate (#5191) 2024-03-20 18:13:31 +00:00
Nathan Hadley
d904f51716 README: Fix Preview B image (#5188) 2024-03-20 18:11:40 +00:00
Vaxry
361357095c workspace: fix selectors with special:
fixes #5187
2024-03-20 18:06:03 +00:00
Khalid
9ddf1b105e tablet: Add left_handed option for tablets (#5178)
* Add left_handed option for tablets

* Update left_handed tablet option's fallback string
2024-03-20 04:00:43 +00:00
thejch
95ac8a34b1 workspace: fix integer overflow in selector parser (#5177) 2024-03-20 02:33:39 +00:00
Vaxry
8593c45be3 refactor: move window.hpp to desktop/ 2024-03-20 01:44:51 +00:00
Vaxry
f6038837bc constraint: do not disable constraints in destroy
fixes #5170
2024-03-20 01:30:41 +00:00
Vaxry
07ab3b8cd6 hyprpm: log shell in build without fails 2024-03-19 22:12:55 +00:00
Vaxry
05cd6d3df1 config/workspace: added workspace selectors 2024-03-19 20:56:20 +00:00
Vaxry
c32b2331d1 constraint: set active flag before propagating props
fixes #5170
2024-03-19 18:55:17 +00:00
phonetic112
bcba3951f4 input: Only limit drag resizes (#5164)
* only limit drag resizes

* change to not equals

* remove extra parentheses
2024-03-19 16:03:31 +00:00
joshua
5c1097cbc1 IME: Improve handling of text-input and ime-relay (#5147)
* input: Handling multiple surfaces for the text-input-v1 protocol implementation and imporve InputMethodRelay logic

fixes #2708

* clang-format

* minor style nits

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-03-19 15:54:33 +00:00
Epilepsy Gatherings
05c84304cc github: remove redundant instruction (#5163)
v0.34.0 is pretty old at this point.
2024-03-19 02:53:51 +00:00
Vaxry
7617c03dfd window: set config only when both props end anims 2024-03-19 02:53:13 +00:00
thejch
e6532ba024 animations: Fix incorrect animation when manually moving a window when its being created (#5141)
* fix incorrect rendering when manually moving a window when its being created

* add setAnimationsToMove
2024-03-19 02:52:52 +00:00
Vaxry
7a31c954e5 tablet: minor focus fixes
ref #3004
2024-03-19 02:45:11 +00:00
Vaxry
49f5fd59ad opengl: minor adjustment to getPreferredReadFormat
fixes #4791
2024-03-19 02:42:39 +00:00
Vaxry
7283dde878 screenShader: allow camel for screensize
ref #5059
2024-03-18 23:51:32 +00:00
Vaxry
4ffcdc41ff animations: fix layer slide with fade
fixes #5151
2024-03-18 18:29:57 +00:00
Vaxry
4b74123649 socket2: add pin event
fixes #4778
2024-03-18 18:11:20 +00:00
Vaxry
5eb33ff4d8 screenshader: add screen_size uniform
fixes #5059
2024-03-18 16:35:22 +00:00
Vaxry
7587cadd0a renderer: add support for gles3.2 screen shaders 2024-03-18 04:15:04 +00:00
Vaxry
c34ad12183 cursormgr: scale hotspot with buffer 2024-03-17 19:00:21 +00:00
Vaxry
30c5911718 renderer: minor fixups for misaligned surface rendering offsets
fixes #5136
2024-03-17 16:08:59 +00:00
Zach DeCook
3c21f5e07b swipe: Touchscreen workspace swipe (#4489)
* Workspace Swipe: Refactor update and end functions

* Touch: Implement workspace swipe better

ignoring additional fingers and new touches

allow gaps-right and gaps-left to be different
2024-03-17 15:43:59 +00:00
djvs
3ed3b34c4a keybinds: add Dispatchers for "force float" and "force tiling" (non-toggle) (#5137)
---------

Co-authored-by: djvs <djvs@users.noreply.github.com>
2024-03-17 15:41:43 +00:00
Vaxry
e68c07d809 renderer: don't render window on other mons during anim in
fixes #5139
2024-03-17 01:05:26 +00:00
thejch
0387528c56 master: fix moving fullscreen workspace and remove duplicate code (#5131) 2024-03-17 00:15:12 +00:00
Vaxry
0e87a08e15 renderer: disable surface adjustments for misaligned reported when manual resizing
ref #5135
2024-03-16 17:56:09 +00:00
Vaxry
3162739e1b renderer: don't translate surface box on interactive resizes with non-updated sizes
closes #5135
2024-03-16 17:12:29 +00:00
Omar
e566be7847 LICENSE: Update year (#5132)
Updating the license year from 2022-2023 to 2022-2024
2024-03-16 16:57:45 +00:00
Mihai Fufezan
bd332a79e7 Nix: match derivation to Nixpkgs 2024-03-16 18:12:42 +02:00
Vaxry
c5e28ebcfe props: bump ver 0.37.1 2024-03-16 14:51:49 +00:00
thejch
c942ce6dce renderer: add better multi monitor animations (#5126) 2024-03-16 14:49:34 +00:00
Vaxry
5e5d7e2abc renderer: fix non-reported sizes window box calculations
fixed #5129
2024-03-16 14:37:07 +00:00
Vaxry
19c90048d6 props: bump ver to 0.37.0 2024-03-15 23:58:39 +00:00
Vaxry
3f5f5f5491 splashes: add 2ya splash 2024-03-15 23:58:22 +00:00
Vaxry
2a2da6082e renderer: fix invalid access on non-assigned surfaces
fixes #5125
2024-03-15 21:29:20 +00:00
Vaxry
c4f52d1979 master: fix invalid config usage 2024-03-15 19:31:33 +00:00
Vaxry
38576d651a renderer: adjust surface dimensions for oversized not-yet ackd surface sizes
supersedes #5104
2024-03-15 19:23:51 +00:00
drendog
72d78eff95 sessionlock: refocus after destroy focused surface (#5117)
* fix: refocus after destroy focused surface

* refactor: minor refactor on refocus loop condition

* refactor: minor refactor on condition

* style: format code
2024-03-15 18:44:17 +00:00
Maximilian Seidler
a958884b52 lock: fix red screen issues with multiple monitors (#5100)
* lock: use uint64_t for iMonitorID

* lock: move activateLock to onNewSessionLock

* lock: add red screen fade

* lock: damage when fading the red screen and delay for screencopy

* lock: remove redundant scheduleFrameForMonitor
2024-03-15 16:17:13 +00:00
Vaxry
bb933dcf04 popup: avoid damage loops with commits
fixes #5118
2024-03-15 15:55:30 +00:00
thejch
bc15a8f600 renderer: Allow headless mode in hyprland (#4794)
* allow headless

* clang-format

* fix redundant logic lol
2024-03-15 14:28:14 +00:00
Mihai Fufezan
6c24cee88f flake.lock: update 2024-03-15 11:13:27 +02:00
Mihai Fufezan
d00c658405 Nix: add wrapping back
Ref: https://github.com/hyprwm/hyprland-plugins/issues/93
2024-03-15 10:11:56 +02:00
Vaxry
dc44bd7113 ci: remove codeql
bullshit, useless, and only fails for no reason
2024-03-15 03:32:24 +00:00
Vaxry
045c3fbd85 subsurface: fix visibility check
ref #5113
2024-03-14 20:42:33 +00:00
Vaxry
b7b13623ba subsurface/popup: expand on map/unmap to add buffering
ref #5113
2024-03-14 20:21:58 +00:00
Vaxry
164e92f8e3 internal: minor fixups for fading out xwayland windows
fixes #4935
2024-03-14 18:25:28 +00:00
Vaxry
3e67ee0f5f events: ignore setTitle when title didn't change 2024-03-13 15:38:24 +00:00
djvs
893c55217b input: only override dragging corner on floating (#5092)
Co-authored-by: djvs <djvs@users.noreply.github.com>
2024-03-13 03:38:32 +00:00
djvs
c58fcfbce2 input: add general:resize_corner for manual resizing (#5090)
* Resize corner config thing

* clang-format

---------

Co-authored-by: djvs <djvs@users.noreply.github.com>
2024-03-13 02:43:22 +00:00
thejch
7ea555da7f master: Fix master layout window focus and scroll (#5074)
* fix master switch window scrolling

* fix some more dispatchers and remove some duplicate code

* refactor and remove duplicate code

* fix focusmonitor: https://github.com/hyprwm/Hyprland/issues/5006#issuecomment-1986977255

* change check
2024-03-13 02:09:20 +00:00
Mihai Fufezan
6c53d4d82f Nix: remove hyprland-unwrapped leftover 2024-03-12 21:35:41 +02:00
Vaxry
5da9591775 config: more safety around monitor keyword
ref https://github.com/hyprwm/hyprland-wiki/issues/523
2024-03-12 15:37:46 +00:00
Ikko Eltociear Ashimine
f1ec0ba467 keybinds: Fix typo (#5081)
minor fix
2024-03-12 15:26:42 +00:00
Vaxry
a065b481f3 cursormgr: use XCURSOR_THEME for x themes 2024-03-11 20:33:26 +00:00
Lucas Reis
0fc9d45e4b core: Fix typo and check grandchild PID in spawn() (#5070) 2024-03-11 19:31:39 +00:00
Vaxry
66330281ff config: report errors from sourced files 2024-03-11 01:39:00 +00:00
Vaxry
220144276b layout: unfullscreen on toggle into tiled fullscreen
fixes a bug where the tiled window would be on top
2024-03-10 22:31:49 +00:00
Vaxry
0a1632a79f dwindle: preserve fs state on switchWindows
fixes #2842
2024-03-10 22:27:23 +00:00
NotAShelf
981296f101 flake: bump inputs (#5066) 2024-03-10 19:52:54 +00:00
Vaxry
0c28d4e334 window: prevent vector modification segfault while iterating
oops, updateWindow can modify the vec
2024-03-10 16:56:42 +00:00
Matt Wyatt
335506d555 constraints: only warp cursor on deactivate if constraint is locked. (#5056) 2024-03-09 23:19:48 +00:00
Vaxry
b0f98a3d3e compositor: reject focus to noFocus OR xwayland windows
fixes #4922
2024-03-09 22:39:23 +00:00
Vaxry
2ed032a7fd xwayland: fix no_xwayland compiles 2024-03-09 22:37:49 +00:00
Vaxry
739c5bc98c cursormgr: fix invalid access to hyprcursor in xwayland init
fixes #5048
2024-03-09 21:54:33 +00:00
Vaxry
26cd1bf949 input: fix minor default cursor reset conditions 2024-03-09 18:12:55 +00:00
Vaxry
18a35b1406 cursormgr: fix memory leak with cursor buffers 2024-03-09 18:04:33 +00:00
Vaxry
7e41e5146d cursormgr: add fallbacks for unknown cursors 2024-03-09 18:00:37 +00:00
Vaxry
c3882bb832 internal: Support libhyprcursor (#5009)
woo

---------

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2024-03-09 16:52:59 +00:00
Vaxry
e7a5db4852 xwayland: Set xwayland's name prop (#4924)
* set xwayland name

* [gha] Nix: update wlroots

* fix

---------

Co-authored-by: vaxerski <vaxerski@users.noreply.github.com>
2024-03-09 16:47:57 +00:00
Vaxry
a01949dd28 deco: fix warnings 2024-03-09 16:39:38 +00:00
vaxerski
fa886d8b11 [gha] Nix: update wlroots 2024-03-09 16:36:19 +00:00
Vaxry
3f58e77e75 deps: update wlroots 2024-03-09 16:35:35 +00:00
Vaxry
300d77edd9 keybinds: track submap at press for keypresses
fixes #5037
2024-03-09 16:08:07 +00:00
Vaxry
c9ea600baa layer-shell: allow for popup creation before map
ref https://github.com/jjsullivan5196/wvkbd/issues/65
2024-03-09 15:32:36 +00:00
Vaxry
3e930a568a format: fix format 2024-03-09 03:09:25 +00:00
Vaxry
024d4ddc74 input: scale local coords in constraints
fixes #5029
2024-03-08 22:51:28 +00:00
Vaxry
717d5b3cc2 hyprctl: hide unmapped windows without -a 2024-03-08 17:47:12 +00:00
Vaxry
0a4ade01d3 format: make ci happy 2024-03-08 17:40:28 +00:00
Aaron
5920c6a6b8 socket2: Add 5 IPC event with support for workspace ID (#5022)
- `moveworkspacev2`:    returns workspaceID,workspaceName,monitorName
- `movewindowv2`:       returns windowAddress,workspaceID,workspaceName
- `createWorkspacev2`:  returns workspaceID,workspaceName
- `destroyWorkspacev2`: returns workspaceID,workspaceName
- `workspacev2`:        returns workspaceID,workspaceName

- Include workspaceID as a parameter in CWorkspace constructor to support `createWorkspacev2`.

Resolves #4929
2024-03-08 17:39:53 +00:00
Vaxry
4c34e4aac2 windowrules: minor improvements to min/max size
fixes #5017
2024-03-08 17:10:38 +00:00
Fazzi
d1c80c31c8 README: change dwl link to new codeberg link (#5026) 2024-03-08 16:30:42 +00:00
Epilepsy Gatherings
1290507ac4 windowrules: check if floating when resizing from maxsize (#5019)
* check if floating

* use return
2024-03-08 14:54:45 +00:00
Epilepsy Gatherings
e52d3fa852 windowrules: Make min/maxsize rules dynamic (#4775)
* rebase

* simplify and remove prop

* Stuff

- add back win prop
- change minsize defaults
- change request formatting for setprop

* style fix

* remove empty line

* change defaults

* redo string to vec

* remove redundant parsing

* change to vec

* support commas

* remove static rules

* take out garbage

* format

* don't allow commas and resize on setprop

* use isNumber
2024-03-08 02:24:44 +00:00
ItsDrike
ceecdd0fd5 hyprctl: Fix incorrect invalid fontsize kwarg response (#5013) 2024-03-07 23:34:33 +00:00
thejch
6c4e2489a0 layout: Fix toggling fullscreen special workspace on different monitor (#5000)
* fix toggling fullscreen special ws on different monitor

* add for dwindle

* fix change regular workspace when special fullscreen
2024-03-07 13:27:58 +00:00
thejch
bf71026b8d master: change active monitor when moving windows around (#5001) 2024-03-07 13:23:22 +00:00
Mihai Fufezan
77161fdbef flake.lock: update 2024-03-07 11:03:43 +02:00
Mihai Fufezan
ce072638e9 Nix: use propagatedBuildInputs instead of wrapping
This way, users that want to wrap Hyprland themselves won't have the
issues of double-wrapping.
2024-03-07 11:02:18 +02:00
Vaxry
95769a3c54 compositor: update state after moving to workspace
fixes #4987
2024-03-06 21:33:55 +00:00
ItsDrike
067df84388 notify: Add custom fontsize support for notifications (#4981)
* Add custom fontsize support for notifications

* Remove debug stuff

* Use original default font size

* Handle fontsize as keyword arg

* Use CVarList::join instead of for loop

* Use size_t for msgidx
2024-03-06 21:20:26 +00:00
Vaxry
8e2a62e53b events: apply monitor state on sessionActive
ref #4839
2024-03-06 18:14:59 +00:00
Vaxry
669ea8a373 ci: pack hyprpm to the release tar 2024-03-06 15:26:58 +00:00
ItsDrike
082bf00254 hyprpm: Add support for specifying exact git revisions for plugin repo (#4983)
* hyprpm(feat): support specifying exact git revs

* Mention git rev argument in help

* Mention git rev arg is optional

* Wrap text
2024-03-06 12:01:04 +00:00
outfoxxed
d6f1b151b2 animations: fix m_Goal not being set after #4911 (#4992) 2024-03-06 10:14:13 +00:00
bvr-yr
fb87e332c5 input: fix window move stutter by introducing additional checks for low-hz monitors (#4553)
* resize-limiter: add additional check for low-hz monitors

* simplify checker

* add comment

* rename variable
2024-03-06 00:15:44 +00:00
Zach DeCook
b1e2ca04a0 CrashReporter: Fix compilation with musl libc (#4805)
It can be assumed this doesn't function correctly:
my 'configuration does not support execinfo.h', so I have no backtrace to test against
2024-03-05 22:51:34 +00:00
Vaxry
05dd204c5f window: ignore surface updates in unsafe / on invalid monitors 2024-03-05 20:46:08 +00:00
Vaxry
31e1287da2 subsurface: don't update transform on unmap
fixes #4969
2024-03-05 20:45:23 +00:00
Vaxry
a4c1f4a03d popup: send scale on map
fixes #4972
2024-03-05 20:42:29 +00:00
Grant Ammons
0ee69058c4 config: Add input:scroll_factor configuration (#4980)
* Allow for input:scroll_factor configuration

This PR will allow for a `scroll_factor` configuration within an `input`
block.  The purpose is to control the scroll factor of external mice.

Closes #2574.

* clang-format
2024-03-05 19:18:53 +00:00
Junxuan Liao
f8a081b56d layout: warp the cursor when focusing windows (#4982)
Similar to the `focuswindow` dispatcher, when focusing a window with
wlr-foreign-toplevel-management, the cursor should be warped. Otherwise, the
focus is lost immediately after the cursor moves.
2024-03-05 17:56:06 +00:00
Vaxry
bdfa8ab856 hyprctl: print format and modes
fixes #4971
2024-03-05 13:55:38 +00:00
Junxuan Liao
08152477dc monitor: remove commas from short description (#4970)
Since `hyprctl monitor` shows szShortDescription now, it needs to be sanitized.
(See #2457)

Also, monitor selectors are now compared against szShortDescription and
szDescription to avoid re-striping the string.
2024-03-05 13:41:51 +00:00
Vaxry
12985fa0d8 surface: fix damage tearing feedback
fixes #4935
2024-03-05 00:21:37 +00:00
thejch
9c48c322d4 keybinds: Allow fullscreen/maximize in special workspace (#4921)
* allow fullscreen/maximize in special workspace

* remove duplicate code

* hide top layer

* fix special fullscreen deco

* edit

* fix fade top layer when toggle special

* remove double render
2024-03-04 23:29:45 +00:00
Vaxry
7a76ab01d1 input: send motion to confined cursors 2024-03-04 23:07:16 +00:00
musjj
f3c92e75c8 CI/Nix: attempt to fix broken cache (#4963)
DeterminateSystems/nix-installer-action is causing hash inconsistency between CI & local build.
2024-03-04 20:33:42 +02:00
Tom Benham
07c7235b72 keybinds: Better handling of workspace_back_and_forth (#4952)
* Removed redundant boolean condition

* Better handling of workspace_back_and_forth when using focusworkspaceoncurrentmonitor dispatcher

* Fixed config acquisition

---------

Co-authored-by: Tom Benham <tom.benham@quadrille.fr>
2024-03-04 17:05:20 +00:00
Vaxry
12da0fc84f hyprctl: parse custom types in getoption 2024-03-04 10:36:38 +00:00
Isaiah Hamilton
9d89b7109d config: update per device input configs link (#4951) 2024-03-03 23:00:28 +00:00
Vaxry
063708df26 config: improve config value infrastructure 2024-03-03 18:41:38 +00:00
JManch
8ccbd272cc compositor: ignore grab extend behind special workspaces (#4944)
* compositor: ignore grab extend behind special workspaces

* ignore the window entirely
2024-03-03 17:04:39 +00:00
thejch
28272d2d74 master: Fix animate resize (#4942)
* fix master animate resize

* fix some other pointers
2024-03-03 17:03:23 +00:00
Vaxry
c701767038 xkb: handle invalid keymaps in updateXKBTranslationState
fixes #4941
2024-03-03 17:02:15 +00:00
Vaxry
cc94123fa7 renderer: minor fixes to transformations 2024-03-03 02:18:06 +00:00
Julien Roy
2a08f2ba84 opengl: fix compilation on legacy renderer (#4928) 2024-03-03 00:31:36 +00:00
Vaxry
689fced8b9 windowrules: fix center
fixes #4934
2024-03-03 00:22:40 +00:00
Epilepsy Gatherings
acf0b536a6 xwayland: disable initial focus for xwayland dialogs (#4936) 2024-03-03 00:18:53 +00:00
JManch
1762e9c6ec renderer: respect forceNoBlur when rendering small surface windows (#4932) 2024-03-03 00:17:40 +00:00
Tobias Zimmermann
964f1a438d keybinds: Add the 'catchall' keyword that matches all keys (#4930)
* Add the 'catchall' keyword that matches all keys

This keyword can be used to define arbitrary keybinds. The only special
behavior that it exhibits is that it matches every key, including
modifier keys. Any flags still apply normally.

This commit also fixes an issue that keys bound via the code:KEYCODE
format were not unbound correctly.

* Disallow catchall keybinds outside of submaps

A catchall keybind outside a submap would prevent essentially all key
events from going through to applications and would be difficult to
remove again.
2024-03-03 00:17:02 +00:00
JManch
508262b7db events: update render data after workspace window rule (#4931) 2024-03-02 22:15:07 +00:00
Vaxry
d72ea5f2a7 input: Rewritten pointer constraints (#4889)
* rewritten constraints

* send pointer enter on activate if not pointer focus

* minor cleanup

* simulate movement on commit

* don't ignore oneshot prop

* various fixes

* dont send motion on confined

* update pos hint on region change
2024-03-02 21:04:55 +00:00
Vaxry
328ab43165 hyprpm: don't copy .so if file doesn't exist
ref #4926
2024-03-02 19:06:09 +00:00
Vaxry
d2289d8327 xdg: minor improvements to initial size reporting
fixes #4918
2024-03-02 18:53:17 +00:00
ItsDrike
be89d6faa9 notifs: Implement notification dimissing (#4790) 2024-03-02 18:12:31 +00:00
Vaxry
8811f4b69a drag: check min size for reisze drags
fixes #4920
2024-03-02 15:25:32 +00:00
Vaxry
52db216608 events: don't switch to active workspace on workspace rule 2024-03-02 15:20:40 +00:00
ves
1e311c947e Nix: add missing dependencies for make asan (#4919) 2024-03-02 17:02:33 +02:00
Vaxry
7ce781e87c keybinds: better follow xkb translation state
fixes #4908
2024-03-02 01:46:55 +00:00
GartoxFR
b2c3440477 animations: Refactor AnimatedVariable (#4911)
* animation: Refactor AnimatedVariable

This commit decomposes the AnimatedVariable class into a base class
with the common attribute to all variable types and a templated derived
type containing strongly typed info on the type being animated.

Access to the typed version is perfomed using the visitor pattern. A
utility is provided to build a visitor on the fly using lambdas.

Adding a new type to be animated should just be a matter of adding the
typed in the list defined by the ANIMABLE_TYPES macro

The size of the commit is justified by the API change in the
AnimatedVariable class. No more vec(), fl() or col() method but a unified
value() method.

* animation: Remove visitor pattern

* animation: Fix coding style

* animation: Fix coding style
2024-03-02 00:35:17 +00:00
Vaxry
f115ba94d2 xwayland: set scaledBy for unmanaged windows in map 2024-03-01 23:04:34 +00:00
Brett Alcox
6e3a494d1d core: add additional headers for Popup.cpp and InputMethodRelay.hpp (#4909) 2024-03-01 20:07:36 +00:00
Vaxry
555afea73c makefile: add config to make asan 2024-03-01 14:16:56 +00:00
Vaxry
4937352761 makefile: add asan 2024-03-01 14:14:28 +00:00
Vaxry
f590505daf popup: minor fixes to xdg geometries
fixes #4900
2024-02-29 21:51:50 +00:00
Vaxry
f801d15947 configmgr: fix compile on 32-bit archs
fixes #4895
2024-02-29 21:33:39 +00:00
Vaxry
e63b4b18aa renderer: force a few render frames on init anim end
fixes #4875
2024-02-29 19:04:40 +00:00
Vaxry
1698d336f2 core: fix crashes on access of deleted wlr_ surface
ref fixes #4893
2024-02-29 17:23:44 +00:00
Vaxry
fbba8757cb window: remove unused list 2024-02-29 16:16:03 +00:00
Vaxry
6916d0a6a3 surface: unify owners 2024-02-29 15:07:14 +00:00
Anton Samokhvalov
bcec082a1c build: fix libc++/clang build (#4886) 2024-02-29 15:01:56 +00:00
Vaxry
2e111c8cf9 xdg: rewrite entire popup implementation 2024-02-29 14:26:02 +00:00
Vaxry
b39dcfa497 refactor: move a few things to desktop/ 2024-02-29 13:03:38 +00:00
Vaxry
4bff762d97 xwaylandmgr: don't read xwayland surface from unmapped xwayland 2024-02-29 01:21:23 +00:00
Vaxry
b1c0f1cc01 subsurface: Rewrite the subsurface tree (#4877) 2024-02-29 00:03:28 +00:00
Vaxry
1e7eb3a5a5 xdg: check for floating conditions before sending tiled size hint
ref #4871
2024-02-28 23:14:50 +00:00
Vaxry
097f561e41 surfacetree: Revert "subsurfaceTree: assign surfaces to a CWLSurface"
This reverts commit 51b1b17fcb.

Crash issues, fixes #4874
2024-02-28 19:42:04 +00:00
Vaxry
a31433c215 renderer: damage whole ring on failed commit
fixes #4770
2024-02-28 18:00:02 +00:00
Vaxry
51b1b17fcb subsurfaceTree: assign surfaces to a CWLSurface
fixes #4872
2024-02-28 17:53:17 +00:00
Vaxry
29cdd7de1f layers: minor fixes for new animations 2024-02-28 15:59:45 +00:00
Vaxry
4bc669f933 layers: add fully featured animations
Adds configs and layerrules to handle them

alas fixes #981

I have cooked
2024-02-28 15:00:40 +00:00
vaxerski
f4f3aa2e50 layout: add size prediction for initial xdg commits
fixes #4022
2024-02-28 11:45:43 +00:00
JManch
c198d744b7 keybinds: unconstrain mouse on focusmonitor and cyclenext (#4863) 2024-02-28 00:52:45 +00:00
356 changed files with 40717 additions and 14761 deletions

View File

@@ -9,11 +9,26 @@ body:
---
- 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: ver
attributes:
label: Hyprland Version
description: "Paste here the output of `hyprctl version`. For hyprland after 0.34.0, paste `hyprctl systeminfo` instead."
label: System Info and Version
description: |
Paste the output of `hyprctl systeminfo -c` here (If you are on a
version that shows you help menu, omit the `-c` and attach config files
to the issue). If you have configs outside of the main config shown
here, please attach.
value: "<details>
<summary>System/Version info</summary>
@@ -29,17 +44,6 @@ body:
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:
@@ -62,6 +66,6 @@ body:
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
Logs can be found in $XDG_RUNTIME_DIR/hypr
Crash reports are stored in ~/.cache/hyprland or $XDG_CACHE_HOME/hyprland

View File

@@ -24,6 +24,7 @@ runs:
glslang \
go \
hyprlang \
hyprcursor \
jq \
libc++ \
libdisplay-info \
@@ -43,6 +44,7 @@ runs:
pango \
pixman \
pkgconf \
pugixml \
scdoc \
seatd \
systemd \
@@ -51,7 +53,20 @@ runs:
wayland-protocols \
xcb-util-errors \
xcb-util-renderutil \
xcb-util-wm
xcb-util-wm \
xcb-util \
xcb-util-image \
libzip \
librsvg
- name: Get hyprwayland-scanner-git
shell: bash
run: |
git clone https://github.com/hyprwm/hyprwayland-scanner --recursive
cd hyprwayland-scanner
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --install build
- name: Get Xorg pacman pkgs
shell: bash

83
.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,83 @@
assets:
- changed-files:
- any-glob-to-any-file: "assets/**"
docs:
- changed-files:
- any-glob-to-any-file: "docs/**"
hyprctl:
- changed-files:
- any-glob-to-any-file: "hyprctl/**"
hyprpm:
- changed-files:
- any-glob-to-any-file: "hyprpm/**"
nix:
- changed-files:
- any-glob-to-any-file: "nix/**"
protocols:
- changed-files:
- any-glob-to-any-file: ["protocols/**", "src/protocols/**"]
core:
- changed-files:
- any-glob-to-any-file: "src/**"
config:
- changed-files:
- any-glob-to-any-file: "src/config/**"
debug:
- changed-files:
- any-glob-to-any-file: "src/debug/**"
desktop:
- changed-files:
- any-glob-to-any-file: "src/desktop/**"
devices:
- changed-files:
- any-glob-to-any-file: "src/devices/**"
events:
- changed-files:
- any-glob-to-any-file: "src/events/**"
helpers:
- changed-files:
- any-glob-to-any-file: "src/helpers/**"
hyprerror:
- changed-files:
- any-glob-to-any-file: "src/hyprerror/**"
init:
- changed-files:
- any-glob-to-any-file: "src/init/**"
layout:
- changed-files:
- any-glob-to-any-file: "src/layout/**"
managers:
- changed-files:
- any-glob-to-any-file: "src/managers/**"
pch:
- changed-files:
- any-glob-to-any-file: "src/pch/**"
plugins:
- changed-files:
- any-glob-to-any-file: "src/plugins/**"
render:
- changed-files:
- any-glob-to-any-file: "src/render/**"
xwayland:
- changed-files:
- any-glob-to-any-file: "src/xwayland/**"

View File

@@ -31,7 +31,7 @@ jobs:
cp ./LICENSE hyprland/
cp build/Hyprland hyprland/
cp build/hyprctl/hyprctl hyprland/
cp subprojects/wlroots/build/libwlroots.so.13032 hyprland/
cp build/hyprpm/hyprpm hyprland/
cp build/Hyprland hyprland/
cp -r example/ hyprland/
cp -r assets/ hyprland/
@@ -63,6 +63,25 @@ jobs:
- name: Compile
run: ninja -C build
no-pch:
name: "Build Hyprland without precompiled headers (Arch)"
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Checkout repository actions
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Setup base
uses: ./.github/actions/setup_base
with:
INSTALL_XORG_PKGS: true
- name: Compile
run: make nopch
noxwayland:
name: "Build Hyprland in pure Wayland (Arch)"
runs-on: ubuntu-latest

12
.github/workflows/labeler.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5

View File

@@ -18,12 +18,13 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
submodules: recursive
- uses: DeterminateSystems/nix-installer-action@main
- uses: cachix/install-nix-action@v26
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v12
with:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build .#${{ matrix.package }} -L
- run: nix build '.?submodules=1#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"

View File

@@ -3,13 +3,13 @@ name: Nix
on: [push, pull_request, workflow_dispatch]
jobs:
wlroots:
if: github.event_name != 'pull_request'
uses: ./.github/workflows/nix-update-wlroots.yml
update-inputs:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/nix-update-inputs.yml
secrets: inherit
build:
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
needs: wlroots
needs: update-inputs
uses: ./.github/workflows/nix-build.yml
secrets: inherit

View File

@@ -1,8 +1,10 @@
name: Nix
on:
schedule:
- cron: '0 0 * * *' # check daily
workflow_call:
secrets:
PAT:
required: true
jobs:
update:
@@ -22,8 +24,3 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[gha] Nix: update inputs"
update-build:
needs: update
uses: ./.github/workflows/nix-build.yml
secrets: inherit

View File

@@ -1,26 +0,0 @@
name: Nix
on:
workflow_call:
secrets:
PAT:
required: true
jobs:
update:
name: wlroots
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
- uses: DeterminateSystems/nix-installer-action@main
- name: Update lockfile
run: nix/update-wlroots.sh
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[gha] Nix: update wlroots"

View File

@@ -18,6 +18,7 @@ jobs:
- name: Generate version
id: genversion
run: |
git fetch --unshallow || echo "failed unshallowing"
bash -c scripts/generateVersion.sh
mv scripts/generateVersion.sh scripts/generateVersion.sh.bak

View File

@@ -24,44 +24,3 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
codeql:
name: CodeQL
runs-on: ubuntu-latest
container:
image: archlinux
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository actions
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Setup base
uses: ./.github/actions/setup_base
with:
INSTALL_XORG_PKGS: true
- name: Build Hyprland
run: |
make all
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

4
.gitignore vendored
View File

@@ -17,8 +17,8 @@ result*
.cache
*.o
*-protocol.c
*-protocol.h
protocols/*.c*
protocols/*.h*
.ccls-cache
*.so

7
.gitmodules vendored
View File

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

281
CMakeLists.txt Executable file → Normal file
View File

@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.19)
cmake_minimum_required(VERSION 3.27)
include(CheckIncludeFile)
include(ExternalProject)
include(GNUInstallDirs)
# Get version
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS)
@@ -12,7 +15,8 @@ project(Hyprland
set(HYPRLAND_VERSION ${VER})
set(PREFIX ${CMAKE_INSTALL_PREFIX})
configure_file(hyprland.pc.in hyprland.pc @ONLY)
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
configure_file(hyprland.pc.in hyprland.pc @ONLY)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
@@ -23,8 +27,6 @@ message(STATUS "Gathering git info")
execute_process(
COMMAND ./scripts/generateVersion.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
#
#
# udis
add_subdirectory("subprojects/udis86")
@@ -32,8 +34,6 @@ add_subdirectory("subprojects/udis86")
# wlroots
message(STATUS "Setting up wlroots")
include(ExternalProject)
if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILDTYPE_LOWER)
if(BUILDTYPE_LOWER STREQUAL "release")
@@ -54,26 +54,24 @@ else()
endif()
ExternalProject_Add(
wlroots
PREFIX ${CMAKE_SOURCE_DIR}/subprojects/wlroots
SOURCE_DIR ${CMAKE_SOURCE_DIR}/subprojects/wlroots
PATCH_COMMAND sed -E -i -e "s/(soversion = .*$)/soversion = 13032/g" meson.build
CONFIGURE_COMMAND meson setup --reconfigure build --buildtype=${BUILDTYPE_LOWER} -Dwerror=false -Dxwayland=$<IF:$<BOOL:${NO_XWAYLAND}>,disabled,enabled> -Dexamples=false -Drenderers=gles2 $<IF:$<BOOL:${WITH_ASAN}>,-Db_sanitize=address,-Db_sanitize=none>
wlroots-hyprland
PREFIX ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland
SOURCE_DIR ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland
CONFIGURE_COMMAND meson setup --reconfigure build --buildtype=${BUILDTYPE_LOWER} -Dwerror=false -Dxwayland=$<IF:$<BOOL:${NO_XWAYLAND}>,disabled,enabled> -Dexamples=false -Drenderers=gles2 -Dbackends=drm,libinput $<IF:$<BOOL:${WITH_ASAN}>,-Db_sanitize=address,-Db_sanitize=none>
BUILD_COMMAND ninja -C build
BUILD_ALWAYS true
BUILD_IN_SOURCE true
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.13032
INSTALL_COMMAND echo "wlroots: install not needed"
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
INSTALL_COMMAND echo "wlroots-hyprland: install not needed"
)
find_program(WaylandScanner NAMES wayland-scanner)
find_package(PkgConfig REQUIRED)
pkg_get_variable(WaylandScanner wayland-scanner wayland_scanner)
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
execute_process(
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
pkg_get_variable(WAYLAND_SERVER_DIR wayland-server pkgdatadir)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake")
@@ -86,24 +84,41 @@ endif()
include_directories(
.
"src/"
"subprojects/wlroots/include/"
"subprojects/wlroots/build/include/"
"subprojects/wlroots-hyprland/include/"
"subprojects/wlroots-hyprland/build/include/"
"subprojects/udis86/"
"protocols/")
set(CMAKE_CXX_STANDARD 23)
add_compile_definitions(WLR_USE_UNSTABLE)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith)
add_link_options(-rdynamic)
set(CMAKE_ENABLE_EXPORTS TRUE)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
-Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
message(STATUS "Checking deps...")
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo libdrm xkbcommon libinput pango pangocairo pixman-1 hyprlang>=0.3.2) # we do not check for wlroots, as we provide it ourselves
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
if(LEGACY_RENDERER)
set(GLES_VERSION "GLES2")
else()
set(GLES_VERSION "GLES3")
endif()
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
pkg_check_modules(deps REQUIRED IMPORTED_TARGET
xkbcommon uuid
wayland-server wayland-client wayland-cursor wayland-protocols
cairo pango pangocairo pixman-1
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
hyprlang>=0.3.2 hyprcursor>=0.1.7
)
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
file(GLOB_RECURSE SRCFILES "src/*.cpp")
set(TRACY_CPP_FILES "")
if(USE_TRACY)
@@ -112,7 +127,9 @@ if(USE_TRACY)
endif()
add_executable(Hyprland ${SRCFILES} ${TRACY_CPP_FILES})
add_dependencies(Hyprland wlroots)
add_dependencies(Hyprland wlroots-hyprland)
set(USE_GPROF ON)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Setting debug flags")
@@ -139,8 +156,12 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
endif()
endif()
add_compile_options(-pg -no-pie -fno-builtin)
add_link_options(-pg -no-pie -fno-builtin)
add_compile_options(-fno-pie -fno-builtin)
add_link_options(-no-pie -fno-builtin)
if(USE_GPROF)
add_compile_options(-pg)
add_link_options(-pg)
endif()
endif()
check_include_file("execinfo.h" EXECINFOH)
@@ -155,6 +176,12 @@ if(HAVE_LIBEXECINFO)
target_link_libraries(Hyprland execinfo)
endif()
check_include_file("sys/timerfd.h" HAS_TIMERFD)
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
if(NOT HAS_TIMERFD AND epoll_FOUND)
target_link_libraries(Hyprland PkgConfig::epoll)
endif()
if(LEGACY_RENDERER)
message(STATUS "Using the legacy GLES2 renderer!")
add_compile_definitions(LEGACY_RENDERER)
@@ -165,27 +192,15 @@ if(NO_XWAYLAND)
add_compile_definitions(NO_XWAYLAND)
else()
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
pkg_check_modules(xcbdep REQUIRED IMPORTED_TARGET xcb)
target_link_libraries(Hyprland PkgConfig::xcbdep)
pkg_check_modules(xdeps REQUIRED IMPORTED_TARGET xcb xwayland xcb-util xcb-render xcb-xfixes xcb-icccm xcb-composite xcb-res xcb-ewmh xcb-errors)
target_link_libraries(Hyprland PkgConfig::xdeps)
endif()
if(NO_SYSTEMD)
message(STATUS "SYSTEMD support is disabled...")
else()
message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined) checking deps...")
check_include_file("systemd/sd-daemon.h" SYSTEMDH)
if(SYSTEMDH)
pkg_check_modules(LIBSYSTEMD libsystemd)
if (LIBSYSTEMD_FOUND)
add_compile_definitions(USES_SYSTEMD)
target_link_libraries(Hyprland "${LIBSYSTEMD_LIBRARIES}")
message(STATUS "Systemd found")
else()
message(WARNING "Systemd support requested but systemd libraries were not found")
endif()
else()
message(WARNING "Systemd support requested but systemd headers were not found")
endif()
message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...")
add_compile_definitions(USES_SYSTEMD)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
@@ -200,51 +215,169 @@ message(STATUS "Setting link libraries")
target_link_libraries(Hyprland rt PkgConfig::deps)
# used by `make installheaders`, to ensure the headers are generated
add_custom_target(generate-protocol-headers)
function(protocol protoPath protoName external)
if (external)
execute_process(
COMMAND ${WaylandScanner} server-header ${protoPath} protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c)
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
else()
execute_process(
COMMAND ${WaylandScanner} server-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c)
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h
COMMAND ${WaylandScanner} server-header ${path} protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c
COMMAND ${WaylandScanner} private-code ${path} protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h)
endfunction()
function(protocolNew protoPath protoName external)
if (external)
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner ${path}/${protoName}.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp protocols/${protoName}.hpp)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
endfunction()
function(protocolWayland)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
COMMAND hyprwayland-scanner --wayland-enums ${WAYLAND_SERVER_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
endfunction()
target_link_libraries(Hyprland
${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.13032 # wlroots is provided by us
${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
OpenGL::EGL
OpenGL::GL
Threads::Threads
libudis86
uuid
)
protocol("protocols/idle.xml" "idle" true)
protocol("protocols/pointer-constraints-unstable-v1.xml" "pointer-constraints-unstable-v1" true)
protocol("protocols/tablet-unstable-v2.xml" "tablet-unstable-v2" true)
protocol("protocols/wlr-foreign-toplevel-management-unstable-v1.xml" "wlr-foreign-toplevel-management-unstable-v1" true)
protocol("protocols/wlr-layer-shell-unstable-v1.xml" "wlr-layer-shell-unstable-v1" true)
protocol("protocols/wlr-output-power-management-unstable-v1.xml" "wlr-output-power-management-unstable-v1" true)
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
protocol("subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true)
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("staging/tearing-control/tearing-control-v1.xml" "tearing-control-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)
protocolNew("protocols" "wlr-gamma-control-unstable-v1" true)
protocolNew("protocols" "wlr-foreign-toplevel-management-unstable-v1" true)
protocolNew("protocols" "wlr-output-power-management-unstable-v1" true)
protocolNew("protocols" "virtual-keyboard-unstable-v1" true)
protocolNew("protocols" "wlr-virtual-pointer-unstable-v1" true)
protocolNew("protocols" "input-method-unstable-v2" true)
protocolNew("protocols" "wlr-output-management-unstable-v1" true)
protocolNew("protocols" "kde-server-decoration" true)
protocolNew("protocols" "wlr-data-control-unstable-v1" true)
protocolNew("subprojects/hyprland-protocols/protocols" "hyprland-focus-grab-v1" true)
protocolNew("protocols" "wlr-layer-shell-unstable-v1" true)
protocolNew("protocols" "wayland-drm" true)
protocolNew("staging/tearing-control" "tearing-control-v1" false)
protocolNew("staging/fractional-scale" "fractional-scale-v1" false)
protocolNew("unstable/xdg-output" "xdg-output-unstable-v1" false)
protocolNew("staging/cursor-shape" "cursor-shape-v1" false)
protocolNew("unstable/idle-inhibit" "idle-inhibit-unstable-v1" false)
protocolNew("unstable/relative-pointer" "relative-pointer-unstable-v1" false)
protocolNew("unstable/xdg-decoration" "xdg-decoration-unstable-v1" false)
protocolNew("staging/alpha-modifier" "alpha-modifier-v1" false)
protocolNew("staging/ext-foreign-toplevel-list" "ext-foreign-toplevel-list-v1" false)
protocolNew("unstable/pointer-gestures" "pointer-gestures-unstable-v1" false)
protocolNew("unstable/keyboard-shortcuts-inhibit" "keyboard-shortcuts-inhibit-unstable-v1" false)
protocolNew("unstable/text-input" "text-input-unstable-v3" false)
protocolNew("unstable/pointer-constraints" "pointer-constraints-unstable-v1" false)
protocolNew("staging/xdg-activation" "xdg-activation-v1" false)
protocolNew("staging/ext-idle-notify" "ext-idle-notify-v1" false)
protocolNew("staging/ext-session-lock" "ext-session-lock-v1" false)
protocolNew("stable/tablet" "tablet-v2" false)
protocolNew("stable/presentation-time" "presentation-time" false)
protocolNew("stable/xdg-shell" "xdg-shell" false)
protocolNew("unstable/primary-selection" "primary-selection-unstable-v1" false)
protocolNew("staging/xwayland-shell" "xwayland-shell-v1" false)
protocolNew("stable/viewporter" "viewporter" false)
protocolNew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
protocolWayland()
# tools
add_subdirectory(hyprctl)
add_subdirectory(hyprpm)
# binary and symlink
install(TARGETS Hyprland)
install(CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_BINDIR}/Hyprland \
${CMAKE_INSTALL_BINDIR}/hyprland
)"
)
# session file
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/wayland-sessions)
# wallpapers
file(GLOB_RECURSE WALLPAPERS "assets/wall*")
install(FILES ${WALLPAPERS}
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)
# default config
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)
# portal config
install(FILES ${CMAKE_SOURCE_DIR}/assets/hyprland-portals.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/xdg-desktop-portal)
# man pages
file(GLOB_RECURSE MANPAGES "docs/*.1")
install(FILES ${MANPAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
# pkgconfig entry
install(FILES ${CMAKE_BINARY_DIR}/hyprland.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
# wlroots headers
set(HEADERS_WLR "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/include/wlr")
install(DIRECTORY ${HEADERS_WLR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h")
# config.h and version.h
set(HEADERS_WLR_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/build/include/wlr")
install(DIRECTORY ${HEADERS_WLR_ROOT}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland/wlr
FILES_MATCHING PATTERN "*.h")
# protocol headers
set(HEADERS_PROTO "${CMAKE_CURRENT_SOURCE_DIR}/protocols")
install(DIRECTORY ${HEADERS_PROTO}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")
# hyprland headers
set(HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")
install(DIRECTORY ${HEADERS_SRC}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2022-2023, vaxerski
Copyright (c) 2022-2024, vaxerski
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -2,71 +2,42 @@ PREFIX = /usr/local
legacyrenderer:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build
legacyrendererdebug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build
release:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Release --target all
chmod -R 777 ./build
debug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --build ./build --config Debug --target all
chmod -R 777 ./build
nopch:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all
clear:
rm -rf build
rm -f ./protocols/*-protocol.h ./protocols/*-protocol.c
rm -rf ./subprojects/wlroots/build
rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp
rm -rf ./subprojects/wlroots-hyprland/build
all:
@if [[ "$EUID" = 0 ]]; then echo -en "Avoid running $(MAKE) all as sudo.\n"; fi
$(MAKE) clear
$(MAKE) release
install:
@if [ ! -f ./build/Hyprland ]; then echo -en "You need to run $(MAKE) all first.\n" && exit 1; fi
@echo -en "!NOTE: Please note make install does not compile Hyprland and only installs the already built files."
mkdir -p ${PREFIX}/share/wayland-sessions
mkdir -p ${PREFIX}/bin
cp -f ./build/Hyprland ${PREFIX}/bin
cp -f ./build/hyprctl/hyprctl ${PREFIX}/bin
cp -f ./build/hyprpm/hyprpm ${PREFIX}/bin
chmod 755 ${PREFIX}/bin/Hyprland
chmod 755 ${PREFIX}/bin/hyprctl
chmod 755 ${PREFIX}/bin/hyprpm
cd ${PREFIX}/bin && ln -sf Hyprland hyprland
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* ${PREFIX}/share/hyprland
mkdir -p ${PREFIX}/share/xdg-desktop-portal
cp ./assets/hyprland-portals.conf ${PREFIX}/share/xdg-desktop-portal
mkdir -p ${PREFIX}/share/man/man1
install -m644 ./docs/*.1 ${PREFIX}/share/man/man1
mkdir -p ${PREFIX}/lib/
cp ./subprojects/wlroots/build/libwlroots.so.13032 ${PREFIX}/lib/
$(MAKE) installheaders
cmake --install ./build
uninstall:
rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop
rm -f ${PREFIX}/bin/Hyprland
rm -f ${PREFIX}/bin/hyprland
rm -f ${PREFIX}/bin/hyprctl
rm -f ${PREFIX}/bin/hyprpm
rm -f ${PREFIX}/lib/libwlroots.so.13032
rm -rf ${PREFIX}/share/hyprland
rm -f ${PREFIX}/share/man/man1/Hyprland.1
rm -f ${PREFIX}/share/man/man1/hyprctl.1
xargs rm < ./build/install_manifest.txt
pluginenv:
@echo -en "$(MAKE) pluginenv has been deprecated.\nPlease run $(MAKE) all && sudo $(MAKE) installheaders\n"
@@ -75,15 +46,19 @@ pluginenv:
installheaders:
@if [ ! -f ./src/version.h ]; then echo -en "You need to run $(MAKE) all first.\n" && exit 1; fi
# remove previous headers from hyprpm's dir
rm -fr ${PREFIX}/include/hyprland
mkdir -p ${PREFIX}/include/hyprland
mkdir -p ${PREFIX}/include/hyprland/protocols
mkdir -p ${PREFIX}/include/hyprland/wlroots
mkdir -p ${PREFIX}/include/hyprland/wlr
mkdir -p ${PREFIX}/share/pkgconfig
cmake --build ./build --config Release --target generate-protocol-headers
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
cd subprojects/wlroots-hyprland/include/wlr && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../..
cd subprojects/wlroots-hyprland/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../..
cp ./protocols/*.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
@@ -106,3 +81,27 @@ man:
--variable=section:1 \
--from rst \
--to man > ./docs/hyprctl.1
asan:
@echo -en "!!WARNING!!\nOnly run this in the TTY.\n"
@pidof Hyprland > /dev/null && echo -ne "Refusing to run with Hyprland running.\n" || echo ""
@pidof Hyprland > /dev/null && exit 1 || echo ""
rm -rf ./wayland
git reset --hard
@echo -en "If you want to apply a patch, input its path (leave empty for none):\n"
@read patchvar
@if [-n "$patchvar"]; then patch -p1 < $patchvar || echo ""; else echo "No patch specified"; fi
git clone --recursive https://gitlab.freedesktop.org/wayland/wayland
cd wayland && patch -p1 < ../scripts/waylandStatic.diff && meson setup build --buildtype=debug -Db_sanitize=address -Ddocumentation=false && ninja -C build && cd ..
cp ./wayland/build/src/libwayland-server.a .
@echo "Wayland done"
patch -p1 < ./scripts/hyprlandStaticAsan.diff
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DWITH_ASAN:STRING=True -DUSE_TRACY:STRING=False -DUSE_TRACY_GPU:STRING=False -S . -B ./build -G Ninja
cmake --build ./build --config Debug --target all
@echo "Hyprland done"
ASAN_OPTIONS="detect_odr_violation=0,log_path=asan.log" HYPRLAND_NO_CRASHREPORTER=1 ./build/Hyprland -c ~/.config/hypr/hyprland.conf

View File

@@ -10,7 +10,6 @@
[![Badge Pull Requests]][Pull Requests]
[![Badge Issues]][Issues]
![Badge Hi Mom]<br>
[![Badge Discord]][Discord]
<br>
@@ -45,11 +44,11 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
- Tearing support for better gaming performance
- Easily expandable and readable codebase
- Fast and active development
- Not scared to provide bleeding-edge features
- Not afraid to provide bleeding-edge features
- Config reloaded instantly upon saving
- Fully dynamic workspaces
- Two built-in layouts and more available as plugins
- Closely follows `wlroots-git`
- Uses forked wlroots with QoL patches
- Global keybinds passed to your apps of choice
- Tiling/pseudotiling/floating/fullscreen windows
- Special workspaces (scratchpads)
@@ -103,7 +102,6 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
<!----------------------------------------------------------------------------->
[Configure]: https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
[Discord]: https://discord.gg/hQ9XvMUjjr
[Stars]: https://starchart.cc/hyprwm/Hyprland
[Hypr]: https://github.com/hyprwm/Hypr
@@ -124,13 +122,13 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
[Wayfire]: https://github.com/WayfireWM/wayfire
[TinyWl]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/tinywl/tinywl.c
[Sway]: https://github.com/swaywm/sway
[DWL]: https://github.com/djpohly/dwl
[DWL]: https://codeberg.org/dwl/dwl
<!----------------------------------{ Images }--------------------------------->
[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg
[Preview A]: https://i.ibb.co/C1yTb0r/falf.png
[Preview B]: https://cdn.discordapp.com/attachments/1091569872535814185/1107675866101723277/screenshot-summer.png
[Preview B]: https://linfindel.github.io/cdn/hyprland-preview-b.png
[Preview C]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png
@@ -138,7 +136,6 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
[Badge Workflow]: https://github.com/hyprwm/Hyprland/actions/workflows/ci.yaml/badge.svg
[Badge Discord]: https://img.shields.io/badge/Join%20the-Discord%20server-6666ff
[Badge Issues]: https://img.shields.io/github/issues/hyprwm/Hyprland
[Badge Pull Requests]: https://img.shields.io/github/issues-pr/hyprwm/Hyprland
[Badge Language]: https://img.shields.io/github/languages/top/hyprwm/Hyprland

View File

@@ -34,16 +34,16 @@ If your bug crashes Hyprland, append additionally:
## Obtaining the Hyprland log
If you are in a TTY, and the hyprland session that crashed was the last one you launched, the log will be printed with
```
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 1)/hyprland.log
cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 1)/hyprland.log
```
feel free to send it to a file, save, copy, etc.
if you are in a Hyprland session, and you want the log of the last session, use
```
cat /tmp/hypr/$(ls -t /tmp/hypr/ | head -n 2 | tail -n 1)/hyprland.log
cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 2 | tail -n 1)/hyprland.log
```
basically, directories in /tmp/hypr are your sessions.
basically, directories in $XDG_RUNTIME_DIR/hypr are your sessions.
## Obtaining the Hyprland Crash Report (v0.22.0beta and up)

View File

@@ -1,70 +1,97 @@
# This is an example Hyprland config file.
#
# Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
#
# Please note not all available settings / options are set here.
# For a full list, see the wiki
#
# You can split this configuration into multiple files
# Create your files separately and then link them to this file like this:
# source = ~/.config/hypr/myColors.conf
################
### MONITORS ###
################
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,auto
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
###################
### MY PROGRAMS ###
###################
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# See https://wiki.hyprland.org/Configuring/Keywords/
# Set programs that you use
$terminal = kitty
$fileManager = dolphin
$menu = wofi --show drun
# Some default env vars.
#################
### AUTOSTART ###
#################
# Autostart necessary processes (like notifications daemons, status bars, etc.)
# Or execute your favorite apps at launch like this:
# exec-once = $terminal
# exec-once = nm-applet &
# exec-once = waybar & hyprpaper & firefox
#############################
### ENVIRONMENT VARIABLES ###
#############################
# See https://wiki.hyprland.org/Configuring/Environment-variables/
env = XCURSOR_SIZE,24
env = QT_QPA_PLATFORMTHEME,qt5ct # change to qt6ct if you have that
env = HYPRCURSOR_SIZE,24
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
#####################
### LOOK AND FEEL ###
#####################
touchpad {
natural_scroll = false
}
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}
general {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
# Refer to https://wiki.hyprland.org/Configuring/Variables/
# https://wiki.hyprland.org/Configuring/Variables/#general
general {
gaps_in = 5
gaps_out = 20
border_size = 2
# https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors
col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border = rgba(595959aa)
layout = dwindle
# Set to true enable resizing windows by clicking and dragging on borders and gaps
resize_on_border = false
# Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
allow_tearing = false
layout = dwindle
}
# https://wiki.hyprland.org/Configuring/Variables/#decoration
decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 10
# Change transparency of focused and unfocused windows
active_opacity = 1.0
inactive_opacity = 1.0
drop_shadow = true
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
# https://wiki.hyprland.org/Configuring/Variables/#blur
blur {
enabled = true
size = 3
@@ -72,17 +99,13 @@ decoration {
vibrancy = 0.1696
}
drop_shadow = true
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
}
# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
enabled = true
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
@@ -94,25 +117,48 @@ animations {
animation = workspaces, 1, 6, default
}
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = true # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # you probably want this
pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # You probably want this
}
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
}
gestures {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = false
# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :(
}
misc {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
#############
### INPUT ###
#############
# https://wiki.hyprland.org/Configuring/Variables/#input
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
touchpad {
natural_scroll = false
}
}
# https://wiki.hyprland.org/Configuring/Variables/#gestures
gestures {
workspace_swipe = false
}
# Example per-device config
@@ -122,16 +168,13 @@ device {
sensitivity = -0.5
}
# Example windowrule v1
# windowrule = float, ^(kitty)$
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.
####################
### KEYBINDINGSS ###
####################
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Q, exec, $terminal
@@ -184,3 +227,19 @@ bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
##############################
### WINDOWS AND WORKSPACES ###
##############################
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules
# Example windowrule v1
# windowrule = float, ^(kitty)$
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.

98
flake.lock generated
View File

@@ -1,7 +1,10 @@
{
"nodes": {
"hyprland-protocols": {
"hyprcursor": {
"inputs": {
"hyprlang": [
"hyprlang"
],
"nixpkgs": [
"nixpkgs"
],
@@ -9,6 +12,31 @@
"systems"
]
},
"locked": {
"lastModified": 1717181720,
"narHash": "sha256-yv+QZWsusu/NWjydkxixHC2g+tIJ9v+xkE2EiVpJj6g=",
"owner": "hyprwm",
"repo": "hyprcursor",
"rev": "9e27a2c2ceb1e0b85bd55b0afefad196056fe87c",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprcursor",
"type": "github"
}
},
"hyprland-protocols": {
"inputs": {
"nixpkgs": [
"xdph",
"nixpkgs"
],
"systems": [
"xdph",
"systems"
]
},
"locked": {
"lastModified": 1691753796,
"narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=",
@@ -33,11 +61,11 @@
]
},
"locked": {
"lastModified": 1708787654,
"narHash": "sha256-7ACgM3ZuAhPqurXHUvR2nWMRcnmzGGPjLK6q4DSTelI=",
"lastModified": 1716473782,
"narHash": "sha256-+qLn4lsHU6iL3+HTo1gTQ1tWzet8K9h+IfVemzEQZj8=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "0fce791ba2334aca183f2ed42399518947550d0d",
"rev": "87d5d984109c839482b88b4795db073eb9ed446f",
"type": "github"
},
"original": {
@@ -46,13 +74,36 @@
"type": "github"
}
},
"hyprwayland-scanner": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1717784906,
"narHash": "sha256-YxmfxHfWed1fosaa7fC1u7XoKp1anEZU+7Lh/ojRKoM=",
"owner": "hyprwm",
"repo": "hyprwayland-scanner",
"rev": "0f30f9eca6e404130988554accbb64d1c9ec877d",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprwayland-scanner",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1708807242,
"narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=",
"lastModified": 1717602782,
"narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a",
"rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6",
"type": "github"
},
"original": {
@@ -64,11 +115,11 @@
},
"root": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"hyprcursor": "hyprcursor",
"hyprlang": "hyprlang",
"hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": "nixpkgs",
"systems": "systems",
"wlroots": "wlroots",
"xdph": "xdph"
}
},
@@ -87,30 +138,9 @@
"type": "github"
}
},
"wlroots": {
"flake": false,
"locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1708558866,
"narHash": "sha256-Mz6hCtommq7RQfcPnxLINigO4RYSNt23HeJHC6mVmWI=",
"owner": "wlroots",
"repo": "wlroots",
"rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5",
"type": "gitlab"
},
"original": {
"host": "gitlab.freedesktop.org",
"owner": "wlroots",
"repo": "wlroots",
"rev": "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5",
"type": "gitlab"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": [
"hyprland-protocols"
],
"hyprland-protocols": "hyprland-protocols",
"hyprlang": [
"hyprlang"
],
@@ -122,11 +152,11 @@
]
},
"locked": {
"lastModified": 1708696469,
"narHash": "sha256-shh5wmpeYy3MmsBfkm4f76yPsBDGk6OLYRVG+ARy2F0=",
"lastModified": 1716290197,
"narHash": "sha256-1u9Exrc7yx9qtES2brDh7/DDZ8w8ap1nboIOAtCgeuM=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "1b713911c2f12b96c2574474686e4027ac4bf826",
"rev": "91e48d6acd8a5a611d26f925e51559ab743bc438",
"type": "github"
},
"original": {

View File

@@ -7,19 +7,11 @@
# <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux";
wlroots = {
type = "gitlab";
host = "gitlab.freedesktop.org";
owner = "wlroots";
repo = "wlroots";
rev = "0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5";
flake = false;
};
hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
hyprcursor = {
url = "github:hyprwm/hyprcursor";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprlang.follows = "hyprlang";
};
hyprlang = {
@@ -28,11 +20,16 @@
inputs.systems.follows = "systems";
};
hyprwayland-scanner = {
url = "github:hyprwm/hyprwayland-scanner";
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";
inputs.hyprlang.follows = "hyprlang";
};
};
@@ -71,17 +68,12 @@
# hyprland-packages
hyprland
hyprland-unwrapped
hyprland-debug
hyprland-legacy-renderer
hyprland-unwrapped
# hyprland-extras
xdg-desktop-portal-hyprland
# dependencies
hyprland-protocols
wlroots-hyprland
udis86
;
});
@@ -91,13 +83,9 @@
stdenv = pkgsFor.${system}.gcc13Stdenv;
} {
name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [cmake python3];
buildInputs = [self.packages.${system}.wlroots-hyprland];
nativeBuildInputs = with pkgsFor.${system}; [expat libxml2];
hardeningDisable = ["fortify"];
inputsFrom = [
self.packages.${system}.wlroots-hyprland
self.packages.${system}.hyprland
];
inputsFrom = [pkgsFor.${system}.hyprland];
};
});
@@ -106,9 +94,4 @@
nixosModules.default = import ./nix/module.nix inputs;
homeManagerModules.default = import ./nix/hm-module.nix self;
};
nixConfig = {
extra-substituters = ["https://hyprland.cachix.org"];
extra-trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
};
}

View File

@@ -5,4 +5,17 @@ project(
DESCRIPTION "Control utility for Hyprland"
)
add_executable(hyprctl "main.cpp")
add_executable(hyprctl "main.cpp")
# binary
install(TARGETS hyprctl)
# shell completions
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.bash
DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions
RENAME hyprctl)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.fish
DESTINATION ${CMAKE_INSTALL_DATADIR}/fish/vendor_completions.d)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.zsh
DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions
RENAME _hyprctl)

159
hyprctl/Strings.hpp Normal file
View File

@@ -0,0 +1,159 @@
#pragma once
const std::string_view USAGE = R"#(usage: hyprctl [flags] <command> [args...|--help]
commands:
activewindow Gets the active window name and its properties
activeworkspace Gets the active workspace and its properties
animations Gets the current config'd info about animations
and beziers
binds Lists all registered binds
clients Lists all windows with their properties
configerrors Lists all current config parsing errors
cursorpos Gets the current cursor position in global layout
coordinates
decorations <window_regex> Lists all decorations and their info
devices Lists all connected keyboards and mice
dismissnotify [amount] Dismisses all or up to AMOUNT notifications
dispatch <dispatcher> [args] Issue a dispatch to call a keybind
dispatcher with arguments
getoption <option> Gets the config option status (values)
globalshortcuts Lists all global shortcuts
hyprpaper ... Issue a hyprpaper request
instances Lists all running instances of Hyprland with
their info
keyword <name> <value> Issue a keyword to call a config keyword
dynamically
kill Issue a kill to get into a kill mode, where you can
kill an app by clicking on it. You can exit it
with ESCAPE
layers Lists all the surface layers
layouts Lists all layouts available (including plugin'd ones)
monitors Lists active outputs with their properties,
'monitors all' lists active and inactive outputs
notify ... Sends a notification using the built-in Hyprland
notification system
output ... Allows you to add and remove fake outputs to your
preferred backend
plugin ... Issue a plugin request
reload [config-only] Issue a reload to force reload the config. Pass
'config-only' to disable monitor reload
rollinglog Prints tail of the log
setcursor <theme> <size> Sets the cursor theme and reloads the cursor
manager
seterror <color> <message...> Sets the hyprctl error string. Color has
the same format as in colors in config. Will reset
when Hyprland's config is reloaded
setprop ... Sets a window property
splash Get the current splash
switchxkblayout ... Sets the xkb layout index for a keyboard
systeminfo Get system info
version Prints the hyprland version, meaning flags, commit
and branch of build.
workspacerules Lists all workspace rules
workspaces Lists all workspaces with their properties
flags:
-j Output in JSON
-r Refresh state after issuing command (e.g. for
updating variables)
--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)
--quiet (-q) Disable the output of hyprctl
--help:
Can be used to print command's arguments that did not fit into this page
(three dots))#";
const std::string_view HYPRPAPER_HELP = R"#(usage: hyprctl [flags] hyprpaper <request>
requests:
listactive Lists all active images
listloaded Lists all loaded images
preload <path> Preloads image
unload <path> Unloads image. Pass 'all' as path to unload all images
wallpaper Issue a wallpaper to call a config wallpaper dynamically
flags:
See 'hyprctl --help')#";
const std::string_view NOTIFY_HELP = R"#(usage: hyprctl [flags] notify <icon> <time_ms> <color> <message...>
icon:
Integer of value:
0 Warning
1 Info
2 Hint
3 Error
4 Confused
5 Ok
6 or -1 No icon
time_ms:
Time to display notification in milliseconds
color:
Notification color. Format is the same as for colors in hyprland.conf. Use
0 for default color for icon
message:
Notification message
flags:
See 'hyprctl --help')#";
const std::string_view OUTPUT_HELP = R"#(usage: hyprctl [flags] output <create <backend> | remove <name>>
create <backend>:
Creates new virtual output. Possible values for backend: wayland, x11,
headless or auto.
remove <name>:
Removes virtual output. Pass the output's name, as found in
'hyprctl monitors'
flags:
See 'hyprctl --help')#";
const std::string_view PLUGIN_HELP = R"#(usage: hyprctl [flags] plugin <request>
requests:
load <path> Loads a plugin. Path must be absolute
unload <path> Unloads a plugin. Path must be absolute
list Lists all loaded plugins
flags:
See 'hyprctl --help')#";
const std::string_view SETPROP_HELP = R"#(usage: hyprctl [flags] setprop <regex> <property> <value> [lock]
regex:
Regular expression by which a window will be searched
property:
See https://wiki.hyprland.org/Configuring/Using-hyprctl/#setprop for list
of properties
value:
Property value
lock:
Optional argument. If lock is not added, will be unlocked. Locking means a
dynamic windowrule cannot override this setting.
flags:
See 'hyprctl --help')#";
const std::string_view SWITCHXKBLAYOUT_HELP = R"#(usage: [flags] switchxkblayout <device> <cmd>
device:
You can find the device using 'hyprctl devices' command
cmd:
'next' for next, 'prev' for previous, or ID for a specific one. IDs are
assigned based on their order in config file (keyboard_layout),
starting from 0
flags:
See 'hyprctl --help')#";

127
hyprctl/hyprctl.bash Normal file
View File

@@ -0,0 +1,127 @@
_hyprctl_cmd_2 () {
hyprctl monitors | grep Monitor | awk '{ print $2 }'
}
_hyprctl_cmd_3 () {
hyprpm list | grep "Plugin" | awk '{print $4}'
}
_hyprctl_cmd_0 () {
hyprctl clients | grep class | awk '{print $2}'
}
_hyprctl_cmd_1 () {
hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}'
}
_hyprctl () {
if [[ $(type -t _get_comp_words_by_ref) != function ]]; then
echo _get_comp_words_by_ref: function not defined. Make sure the bash-completions system package is installed
return 1
fi
local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
local -a literals=("cyclenext" "globalshortcuts" "cursorpos" "bordersize" "renameworkspace" "animationstyle" "focuswindow" "0" "auto" "swapnext" "forceallowsinput" "moveactive" "activebordercolor" "alphafullscreen" "wayland" "layers" "minsize" "monitors" "1" "kill" "settiled" "3" "focusmonitor" "swapwindow" "moveoutofgroup" "notify" "movecursor" "setcursor" "seterror" "movecurrentworkspacetomonitor" "4" "nomaxsize" "forcenoanims" "setprop" "-i" "-q" "togglefloating" "workspacerules" "movetoworkspace" "disable" "setignoregrouplock" "workspaces" "movegroupwindow" "closewindow" "0" "--instance" "binds" "movewindow" "splitratio" "alpha" "denywindowfromgroup" "workspace" "configerrors" "togglegroup" "getoption" "forceopaque" "keepaspectratio" "killactive" "pass" "decorations" "devices" "focuscurrentorlast" "submap" "global" "alphafullscreenoverride" "forcerendererreload" "movewindowpixel" "headless" "version" "dpms" "resizeactive" "moveintogroup" "5" "alphaoverride" "setfloating" "rollinglog" "::=" "rounding" "layouts" "moveworkspacetomonitor" "exec" "alphainactiveoverride" "alterzorder" "fakefullscreen" "nofocus" "keyword" "forcenoborder" "forcenodim" "--quiet" "pin" "output" "forcenoblur" "togglespecialworkspace" "fullscreen" "toggleopaque" "focusworkspaceoncurrentmonitor" "next" "changegroupactive" "-j" "instances" "execr" "exit" "clients" "all" "--batch" "dismissnotify" "inactivebordercolor" "switchxkblayout" "movetoworkspacesilent" "tagwindow" "movewindoworgroup" "-r" "movefocus" "focusurgentorlast" "remove" "activeworkspace" "dispatch" "create" "centerwindow" "2" "hyprpaper" "-1" "reload" "alphainactive" "systeminfo" "plugin" "dimaround" "activewindow" "swapactiveworkspaces" "splash" "sendshortcut" "maxsize" "lockactivegroup" "windowdancecompat" "forceopaqueoverriden" "lockgroups" "movecursortocorner" "x11" "prev" "1" "resizewindowpixel" "forcenoshadow")
declare -A literal_transitions
literal_transitions[0]="([105]=1 [75]=2 [33]=3 [35]=4 [1]=2 [2]=2 [78]=2 [107]=5 [37]=2 [111]=4 [41]=2 [46]=2 [115]=2 [85]=6 [116]=8 [52]=2 [88]=4 [54]=2 [90]=9 [120]=2 [122]=2 [124]=2 [15]=2 [59]=10 [60]=2 [17]=11 [125]=12 [19]=2 [127]=2 [129]=2 [25]=13 [68]=2 [98]=4 [99]=2 [27]=2 [28]=14 [102]=2 [104]=4)"
literal_transitions[3]="([73]=17 [13]=2 [32]=17 [55]=17 [56]=17 [91]=17 [106]=2 [123]=2 [77]=1 [16]=2 [126]=17 [3]=1 [5]=2 [64]=17 [131]=2 [133]=17 [81]=17 [134]=17 [84]=17 [31]=17 [49]=2 [12]=2 [86]=17 [10]=17 [87]=17 [141]=17)"
literal_transitions[7]="([105]=1 [75]=2 [33]=3 [1]=2 [2]=2 [78]=2 [107]=5 [37]=2 [41]=2 [46]=2 [115]=2 [85]=6 [116]=8 [52]=2 [54]=2 [90]=9 [120]=2 [122]=2 [124]=2 [15]=2 [59]=10 [60]=2 [17]=11 [125]=12 [19]=2 [127]=2 [129]=2 [25]=13 [68]=2 [99]=2 [27]=2 [28]=14 [102]=2)"
literal_transitions[8]="([101]=2 [130]=2 [132]=2 [0]=2 [74]=2 [36]=2 [108]=2 [109]=2 [38]=2 [110]=2 [4]=2 [79]=2 [40]=2 [80]=2 [113]=2 [6]=2 [42]=2 [43]=2 [82]=2 [83]=2 [47]=2 [48]=2 [9]=2 [50]=2 [51]=2 [53]=2 [11]=2 [112]=2 [89]=2 [118]=2 [57]=2 [92]=2 [58]=2 [93]=2 [94]=2 [61]=2 [62]=2 [128]=2 [95]=2 [63]=2 [20]=2 [97]=2 [22]=2 [23]=2 [65]=2 [66]=2 [135]=2 [136]=2 [24]=2 [26]=2 [69]=2 [100]=2 [70]=2 [140]=2 [29]=2 [71]=2)"
literal_transitions[9]="([117]=20 [114]=16)"
literal_transitions[11]="([103]=2)"
literal_transitions[13]="([21]=1 [119]=1 [30]=1 [139]=1 [121]=1 [44]=1 [72]=1)"
literal_transitions[14]="([39]=2)"
literal_transitions[15]="([138]=2 [96]=2)"
literal_transitions[17]="([18]=2 [7]=2)"
literal_transitions[18]="([76]=19)"
literal_transitions[19]="([34]=4 [45]=4)"
literal_transitions[20]="([8]=2 [67]=2 [14]=2 [137]=2)"
declare -A match_anything_transitions
match_anything_transitions=([1]=2 [0]=7 [6]=2 [15]=2 [10]=2 [5]=15 [14]=18 [7]=7 [2]=18 [16]=2 [12]=2 [11]=18)
declare -A subword_transitions
local state=0
local word_index=1
while [[ $word_index -lt $cword ]]; do
local word=${words[$word_index]}
if [[ -v "literal_transitions[$state]" ]]; then
declare -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
local word_matched=0
for literal_id in $(seq 0 $((${#literals[@]} - 1))); do
if [[ ${literals[$literal_id]} = "$word" ]]; then
if [[ -v "state_transitions[$literal_id]" ]]; then
state=${state_transitions[$literal_id]}
word_index=$((word_index + 1))
word_matched=1
break
fi
fi
done
if [[ $word_matched -ne 0 ]]; then
continue
fi
fi
if [[ -v "match_anything_transitions[$state]" ]]; then
state=${match_anything_transitions[$state]}
word_index=$((word_index + 1))
continue
fi
return 1
done
local prefix="${words[$cword]}"
local shortest_suffix="$word"
for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
local char="${COMP_WORDBREAKS:$i:1}"
local candidate="${word##*$char}"
if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
shortest_suffix=$candidate
fi
done
local superfluous_prefix=""
if [[ "$shortest_suffix" != "$word" ]]; then
local superfluous_prefix=${word%$shortest_suffix}
fi
if [[ -v "literal_transitions[$state]" ]]; then
local state_transitions_initializer=${literal_transitions[$state]}
declare -A state_transitions
eval "state_transitions=$state_transitions_initializer"
for literal_id in "${!state_transitions[@]}"; do
local literal="${literals[$literal_id]}"
if [[ $literal = "${prefix}"* ]]; then
local completion=${literal#"$superfluous_prefix"}
COMPREPLY+=("$completion ")
fi
done
fi
declare -A commands
commands=([5]=1 [16]=2 [12]=3 [10]=0)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local completions=()
mapfile -t completions < <(_hyprctl_cmd_${command_id} "$prefix" | cut -f1)
for item in "${completions[@]}"; do
if [[ $item = "${prefix}"* ]]; then
COMPREPLY+=("$item")
fi
done
fi
return 0
}
complete -o nospace -F _hyprctl hyprctl

220
hyprctl/hyprctl.fish Normal file
View File

@@ -0,0 +1,220 @@
function _hyprctl_3
set 1 $argv[1]
hyprctl monitors | grep Monitor | awk '{ print $2 }'
end
function _hyprctl_4
set 1 $argv[1]
hyprpm list | grep "Plugin" | awk '{print $4}'
end
function _hyprctl_1
set 1 $argv[1]
hyprctl clients | grep class | awk '{print $2}'
end
function _hyprctl_2
set 1 $argv[1]
hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}'
end
function _hyprctl
set COMP_LINE (commandline --cut-at-cursor)
set COMP_WORDS
echo $COMP_LINE | read --tokenize --array COMP_WORDS
if string match --quiet --regex '.*\s$' $COMP_LINE
set COMP_CWORD (math (count $COMP_WORDS) + 1)
else
set COMP_CWORD (count $COMP_WORDS)
end
set --local literals "cyclenext" "globalshortcuts" "cursorpos" "bordersize" "renameworkspace" "animationstyle" "focuswindow" "0" "auto" "swapnext" "forceallowsinput" "moveactive" "activebordercolor" "alphafullscreen" "wayland" "layers" "minsize" "monitors" "1" "kill" "settiled" "3" "focusmonitor" "swapwindow" "moveoutofgroup" "notify" "movecursor" "setcursor" "seterror" "movecurrentworkspacetomonitor" "4" "nomaxsize" "forcenoanims" "setprop" "-i" "-q" "togglefloating" "workspacerules" "movetoworkspace" "disable" "setignoregrouplock" "workspaces" "movegroupwindow" "closewindow" "0" "--instance" "binds" "movewindow" "splitratio" "alpha" "denywindowfromgroup" "workspace" "configerrors" "togglegroup" "getoption" "forceopaque" "keepaspectratio" "killactive" "pass" "decorations" "devices" "focuscurrentorlast" "submap" "global" "alphafullscreenoverride" "forcerendererreload" "movewindowpixel" "headless" "version" "dpms" "resizeactive" "moveintogroup" "5" "alphaoverride" "setfloating" "rollinglog" "::=" "rounding" "layouts" "moveworkspacetomonitor" "exec" "alphainactiveoverride" "alterzorder" "fakefullscreen" "nofocus" "keyword" "forcenoborder" "forcenodim" "--quiet" "pin" "output" "forcenoblur" "togglespecialworkspace" "fullscreen" "toggleopaque" "focusworkspaceoncurrentmonitor" "next" "changegroupactive" "-j" "instances" "execr" "exit" "clients" "all" "--batch" "dismissnotify" "inactivebordercolor" "switchxkblayout" "movetoworkspacesilent" "tagwindow" "movewindoworgroup" "-r" "movefocus" "focusurgentorlast" "remove" "activeworkspace" "dispatch" "create" "centerwindow" "2" "hyprpaper" "-1" "reload" "alphainactive" "systeminfo" "plugin" "dimaround" "activewindow" "swapactiveworkspaces" "splash" "sendshortcut" "maxsize" "lockactivegroup" "windowdancecompat" "forceopaqueoverriden" "lockgroups" "movecursortocorner" "x11" "prev" "1" "resizewindowpixel" "forcenoshadow"
set --local descriptions
set descriptions[1] "Focus the next window on a workspace"
set descriptions[3] "Get the current cursor pos in global layout coordinates"
set descriptions[5] "Rename a workspace"
set descriptions[7] "Focus the first window matching"
set descriptions[10] "Swap the focused window with the next window"
set descriptions[12] "Move the active window"
set descriptions[16] "List the layers"
set descriptions[18] "List active outputs with their properties"
set descriptions[20] "Get into a kill mode, where you can kill an app by clicking on it"
set descriptions[21] "Set the current window's floating state to false"
set descriptions[22] "ERROR"
set descriptions[23] "Focus a monitor"
set descriptions[24] "Swap the active window with another window"
set descriptions[25] "Move the active window out of a group"
set descriptions[26] "Send a notification using the built-in Hyprland notification system"
set descriptions[27] "Move the cursor to a specified position"
set descriptions[28] "Set the cursor theme and reloads the cursor manager"
set descriptions[29] "Set the hyprctl error string"
set descriptions[30] "Move the active workspace to a monitor"
set descriptions[31] "CONFUSED"
set descriptions[34] "Set a property of a window"
set descriptions[35] "Specify the Hyprland instance"
set descriptions[36] "Disable output"
set descriptions[37] "Toggle the current window's floating state"
set descriptions[38] "Get the list of defined workspace rules"
set descriptions[39] "Move the focused window to a workspace"
set descriptions[41] "Temporarily enable or disable binds:ignore_group_lock"
set descriptions[42] "List all workspaces with their properties"
set descriptions[43] "Swap the active window with the next or previous in a group"
set descriptions[44] "Close a specified window"
set descriptions[45] "WARNING"
set descriptions[46] "Specify the Hyprland instance"
set descriptions[47] "List all registered binds"
set descriptions[48] "Move the active window in a direction or to a monitor"
set descriptions[49] "Change the split ratio"
set descriptions[51] "Prohibit the active window from becoming or being inserted into group"
set descriptions[52] "Change the workspace"
set descriptions[53] "List all current config parsing errors"
set descriptions[54] "Toggle the current active window into a group"
set descriptions[55] "Get the config option status (values)"
set descriptions[58] "Close the active window"
set descriptions[59] "Pass the key to a specified window"
set descriptions[60] "List all decorations and their info"
set descriptions[61] "List all connected keyboards and mice"
set descriptions[62] "Switch focus from current to previously focused window"
set descriptions[63] "Change the current mapping group"
set descriptions[64] "Execute a Global Shortcut using the GlobalShortcuts portal"
set descriptions[66] "Force the renderer to reload all resources and outputs"
set descriptions[67] "Move a selected window"
set descriptions[69] "Print the Hyprland version: flags, commit and branch of build"
set descriptions[70] "Set all monitors' DPMS status"
set descriptions[71] "Resize the active window"
set descriptions[72] "Move the active window into a group"
set descriptions[73] "OK"
set descriptions[75] "Set the current window's floating state to true"
set descriptions[76] "Print tail of the log"
set descriptions[79] "List all layouts available (including plugin ones)"
set descriptions[80] "Move a workspace to a monitor"
set descriptions[81] "Execute a shell command"
set descriptions[83] "Modify the window stack order of the active or specified window"
set descriptions[84] "Toggle the focused window's internal fullscreen state"
set descriptions[86] "Issue a keyword to call a config keyword dynamically"
set descriptions[89] "Disable output"
set descriptions[90] "Pin a window"
set descriptions[91] "Allows adding/removing fake outputs to a specific backend"
set descriptions[93] "Toggle a special workspace on/off"
set descriptions[94] "Toggle the focused window's fullscreen state"
set descriptions[95] "Toggle the current window to always be opaque"
set descriptions[96] "Focus the requested workspace"
set descriptions[98] "Switch to the next window in a group"
set descriptions[99] "Output in JSON format"
set descriptions[100] "List all running Hyprland instances and their info"
set descriptions[101] "Execute a raw shell command"
set descriptions[102] "Exit the compositor with no questions asked"
set descriptions[103] "List all windows with their properties"
set descriptions[105] "Execute a batch of commands separated by ;"
set descriptions[106] "Dismiss all or up to amount of notifications"
set descriptions[108] "Set the xkb layout index for a keyboard"
set descriptions[109] "Move window doesnt switch to the workspace"
set descriptions[110] "Apply a tag to the window"
set descriptions[111] "Behave as moveintogroup"
set descriptions[112] "Refresh state after issuing the command"
set descriptions[113] "Move the focus in a direction"
set descriptions[114] "Focus the urgent window or the last window"
set descriptions[116] "Get the active workspace name and its properties"
set descriptions[117] "Issue a dispatch to call a keybind dispatcher with an arg"
set descriptions[119] "Center the active window"
set descriptions[120] "HINT"
set descriptions[121] "Interact with hyprpaper if present"
set descriptions[122] "No Icon"
set descriptions[123] "Force reload the config"
set descriptions[125] "Print system info"
set descriptions[126] "Interact with a plugin"
set descriptions[128] "Get the active window name and its properties"
set descriptions[129] "Swap the active workspaces between two monitors"
set descriptions[130] "Print the current random splash"
set descriptions[131] "On shortcut X sends shortcut Y to a specified window"
set descriptions[133] "Lock the focused group"
set descriptions[136] "Lock the groups"
set descriptions[137] "Move the cursor to the corner of the active window"
set descriptions[140] "INFO"
set descriptions[141] "Resize a selected window"
set --local literal_transitions
set literal_transitions[1] "set inputs 106 76 34 36 2 3 79 108 38 112 42 47 116 86 117 53 89 55 91 121 123 125 16 60 61 18 126 20 128 130 26 69 99 100 28 29 103 105; set tos 2 3 4 5 3 3 3 6 3 5 3 3 3 7 9 3 5 3 10 3 3 3 3 11 3 12 13 3 3 3 14 3 5 3 3 15 3 5"
set literal_transitions[4] "set inputs 74 14 33 56 57 92 107 124 78 17 127 4 6 65 132 134 82 135 85 32 50 13 87 11 88 142; set tos 18 3 18 18 18 18 3 3 2 3 18 2 3 18 3 18 18 18 18 18 3 3 18 18 18 18"
set literal_transitions[8] "set inputs 106 76 34 2 3 79 108 38 42 47 116 86 117 53 55 91 121 123 125 16 60 61 18 126 20 128 130 26 69 100 28 29 103; set tos 2 3 4 3 3 3 6 3 3 3 3 7 9 3 3 10 3 3 3 3 11 3 12 13 3 3 3 14 3 3 3 15 3"
set literal_transitions[9] "set inputs 102 131 133 1 75 37 109 110 39 111 5 80 41 81 114 7 43 44 83 84 48 49 10 51 52 54 12 113 90 119 58 93 59 94 95 62 63 129 96 64 21 98 23 24 66 67 136 137 25 27 70 101 71 141 30 72; set tos 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3"
set literal_transitions[10] "set inputs 118 115; set tos 21 17"
set literal_transitions[12] "set inputs 104; set tos 3"
set literal_transitions[14] "set inputs 22 120 31 140 122 45 73; set tos 2 2 2 2 2 2 2"
set literal_transitions[15] "set inputs 40; set tos 3"
set literal_transitions[16] "set inputs 139 97; set tos 3 3"
set literal_transitions[18] "set inputs 19 8; set tos 3 3"
set literal_transitions[19] "set inputs 77; set tos 20"
set literal_transitions[20] "set inputs 35 46; set tos 5 5"
set literal_transitions[21] "set inputs 9 68 15 138; set tos 3 3 3 3"
set --local match_anything_transitions_from 2 1 7 16 11 6 15 8 3 17 13 12
set --local match_anything_transitions_to 3 8 3 3 3 16 19 8 19 3 3 19
set --local state 1
set --local word_index 2
while test $word_index -lt $COMP_CWORD
set --local -- word $COMP_WORDS[$word_index]
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
eval $literal_transitions[$state]
if contains -- $word $literals
set --local literal_matched 0
for literal_id in (seq 1 (count $literals))
if test $literals[$literal_id] = $word
set --local index (contains --index -- $literal_id $inputs)
set state $tos[$index]
set word_index (math $word_index + 1)
set literal_matched 1
break
end
end
if test $literal_matched -ne 0
continue
end
end
end
if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state]
set --local index (contains --index -- $state $match_anything_transitions_from)
set state $match_anything_transitions_to[$index]
set word_index (math $word_index + 1)
continue
end
return 1
end
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
eval $literal_transitions[$state]
for literal_id in $inputs
if test -n $descriptions[$literal_id]
printf '%s\t%s\n' $literals[$literal_id] $descriptions[$literal_id]
else
printf '%s\n' $literals[$literal_id]
end
end
end
set command_states 6 17 13 11
set command_ids 2 3 4 1
if contains $state $command_states
set --local index (contains --index $state $command_states)
set --local function_id $command_ids[$index]
set --local function_name _hyprctl_$function_id
set --local --erase inputs
set --local --erase tos
$function_name "$COMP_WORDS[$COMP_CWORD]"
end
return 0
end
complete --command hyprctl --no-files --arguments "(_hyprctl)"

151
hyprctl/hyprctl.usage Normal file
View File

@@ -0,0 +1,151 @@
# This is a file feeded to complgen to generate bash/fish/zsh completions
# Repo: https://github.com/adaszko/complgen
# Generate completion scripts: "complgen aot --bash-script hyprctl.bash --fish-script hyprctl.fish --zsh-script hyprctl.zsh ./hyprctl.usage"
hyprctl [<OPTIONS>]... <ARGUMENTS>
<OPTIONS> ::= (-i | --instance) "Specify the Hyprland instance"
| (-j) "Output in JSON format"
| (-r) "Refresh state after issuing the command"
| (--batch) "Execute a batch of commands separated by ;"
| (-q | --quiet) "Disable output"
;
<WINDOWS> ::= {{{ hyprctl clients | grep class | awk '{print $2}' }}};
<AVAILABLE_PLUGINS> ::= {{{ hyprpm list | grep "Plugin" | awk '{print $4}' }}};
<MONITORS> ::= {{{ hyprctl monitors | grep Monitor | awk '{ print $2 }' }}};
<KEYBOARDS> ::= {{{ hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' }}};
<NOTIFICATION_TYPES> ::= (0) "WARNING"
| (1) "INFO"
| (2) "HINT"
| (3) "ERROR"
| (4) "CONFUSED"
| (5) "OK"
| (-1) "No Icon"
;
<PROPS> ::= (animationstyle)
| (rounding <NUM>)
| (bordersize <NUM>)
| (forcenoblur (0 | 1))
| (forceopaque (0 | 1))
| (forceopaqueoverriden (0 | 1))
| (forceallowsinput (0 | 1))
| (forcenoanims (0 | 1))
| (forcenoborder (0 | 1))
| (forcenodim (0 | 1))
| (forcenoshadow (0 | 1))
| (nofocus (0 | 1))
| (windowdancecompat (0 | 1))
| (nomaxsize (0 | 1))
| (minsize)
| (maxsize)
| (dimaround (0 | 1))
| (keepaspectratio (0 | 1))
| (alphaoverride (0 | 1))
| (alpha)
| (alphainactiveoverride (0 | 1))
| (alphainactive)
| (alphafullscreenoverride (0 | 1))
| (alphafullscreen)
| (activebordercolor)
| (inactivebordercolor)
;
<ARGUMENTS> ::= (activewindow) "Get the active window name and its properties"
| (activeworkspace) "Get the active workspace name and its properties"
| (binds) "List all registered binds"
| (clients) "List all windows with their properties"
| (configerrors) "List all current config parsing errors"
| (cursorpos) "Get the current cursor pos in global layout coordinates"
| (decorations <WINDOWS>) "List all decorations and their info"
| (devices) "List all connected keyboards and mice"
| (dismissnotify <NUM>) "Dismiss all or up to amount of notifications"
| (dispatch <DISPATCHERS>) "Issue a dispatch to call a keybind dispatcher with an arg"
| (getoption) "Get the config option status (values)"
| (globalshortcuts) ""
| (hyprpaper) "Interact with hyprpaper if present"
| (instances) "List all running Hyprland instances and their info"
| (keyword <KEYWORDS>) "Issue a keyword to call a config keyword dynamically"
| (kill) "Get into a kill mode, where you can kill an app by clicking on it"
| (layers) "List the layers"
| (layouts) "List all layouts available (including plugin ones)"
| (monitors [all]) "List active outputs with their properties"
| (notify <NOTIFICATION_TYPES> <NUM>) "Send a notification using the built-in Hyprland notification system"
| (output (create (wayland | x11 | headless | auto) | remove <MONITORS>)) "Allows adding/removing fake outputs to a specific backend"
| (plugin <AVAILABLE_PLUGINS>) "Interact with a plugin"
| (reload) "Force reload the config"
| (rollinglog) "Print tail of the log"
| (setcursor) "Set the cursor theme and reloads the cursor manager"
| (seterror [disable]) "Set the hyprctl error string"
| (setprop <PROPS>) "Set a property of a window"
| (splash) "Print the current random splash"
| (switchxkblayout <KEYBOARDS> (next | prev | <NUM>)) "Set the xkb layout index for a keyboard"
| (systeminfo) "Print system info"
| (version) "Print the Hyprland version: flags, commit and branch of build"
| (workspacerules) "Get the list of defined workspace rules"
| (workspaces) "List all workspaces with their properties"
;
<DISPATCHERS> ::= (exec) "Execute a shell command"
| (execr) "Execute a raw shell command"
| (pass) "Pass the key to a specified window"
| (sendshortcut) "On shortcut X sends shortcut Y to a specified window"
| (killactive) "Close the active window"
| (closewindow) "Close a specified window"
| (workspace) "Change the workspace"
| (movetoworkspace) "Move the focused window to a workspace"
| (movetoworkspacesilent) "Move window doesnt switch to the workspace"
| (togglefloating) "Toggle the current window's floating state"
| (setfloating) "Set the current window's floating state to true"
| (settiled) "Set the current window's floating state to false"
| (fullscreen) "Toggle the focused window's fullscreen state"
| (fakefullscreen) "Toggle the focused window's internal fullscreen state"
| (dpms) "Set all monitors' DPMS status"
| (pin) "Pin a window"
| (movefocus) "Move the focus in a direction"
| (movewindow) "Move the active window in a direction or to a monitor"
| (swapwindow) "Swap the active window with another window"
| (centerwindow) "Center the active window"
| (resizeactive) "Resize the active window"
| (moveactive) "Move the active window"
| (resizewindowpixel) "Resize a selected window"
| (movewindowpixel) "Move a selected window"
| (cyclenext) "Focus the next window on a workspace"
| (swapnext) "Swap the focused window with the next window"
| (tagwindow) "Apply a tag to the window"
| (focuswindow) "Focus the first window matching"
| (focusmonitor) "Focus a monitor"
| (splitratio) "Change the split ratio"
| (toggleopaque) "Toggle the current window to always be opaque"
| (movecursortocorner) "Move the cursor to the corner of the active window"
| (movecursor) "Move the cursor to a specified position"
| (renameworkspace) "Rename a workspace"
| (exit) "Exit the compositor with no questions asked"
| (forcerendererreload) "Force the renderer to reload all resources and outputs"
| (movecurrentworkspacetomonitor) "Move the active workspace to a monitor"
| (focusworkspaceoncurrentmonitor) "Focus the requested workspace"
| (moveworkspacetomonitor) "Move a workspace to a monitor"
| (swapactiveworkspaces) "Swap the active workspaces between two monitors"
| (alterzorder) "Modify the window stack order of the active or specified window"
| (togglespecialworkspace) "Toggle a special workspace on/off"
| (focusurgentorlast) "Focus the urgent window or the last window"
| (togglegroup) "Toggle the current active window into a group"
| (changegroupactive) "Switch to the next window in a group"
| (focuscurrentorlast) "Switch focus from current to previously focused window"
| (lockgroups) "Lock the groups"
| (lockactivegroup) "Lock the focused group"
| (moveintogroup) "Move the active window into a group"
| (moveoutofgroup) "Move the active window out of a group"
| (movewindoworgroup) "Behave as moveintogroup"
| (movegroupwindow) "Swap the active window with the next or previous in a group"
| (denywindowfromgroup) "Prohibit the active window from becoming or being inserted into group"
| (setignoregrouplock) "Temporarily enable or disable binds:ignore_group_lock"
| (global) "Execute a Global Shortcut using the GlobalShortcuts portal"
| (submap) "Change the current mapping group"
;

253
hyprctl/hyprctl.zsh Normal file
View File

@@ -0,0 +1,253 @@
_hyprctl_cmd_2 () {
hyprctl monitors | grep Monitor | awk '{ print $2 }'
}
_hyprctl_cmd_3 () {
hyprpm list | grep "Plugin" | awk '{print $4}'
}
_hyprctl_cmd_0 () {
hyprctl clients | grep class | awk '{print $2}'
}
_hyprctl_cmd_1 () {
hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}'
}
_hyprctl () {
local -a literals=("cyclenext" "globalshortcuts" "cursorpos" "bordersize" "renameworkspace" "animationstyle" "focuswindow" "0" "auto" "swapnext" "forceallowsinput" "moveactive" "activebordercolor" "alphafullscreen" "wayland" "layers" "minsize" "monitors" "1" "kill" "settiled" "3" "focusmonitor" "swapwindow" "moveoutofgroup" "notify" "movecursor" "setcursor" "seterror" "movecurrentworkspacetomonitor" "4" "nomaxsize" "forcenoanims" "setprop" "-i" "-q" "togglefloating" "workspacerules" "movetoworkspace" "disable" "setignoregrouplock" "workspaces" "movegroupwindow" "closewindow" "0" "--instance" "binds" "movewindow" "splitratio" "alpha" "denywindowfromgroup" "workspace" "configerrors" "togglegroup" "getoption" "forceopaque" "keepaspectratio" "killactive" "pass" "decorations" "devices" "focuscurrentorlast" "submap" "global" "alphafullscreenoverride" "forcerendererreload" "movewindowpixel" "headless" "version" "dpms" "resizeactive" "moveintogroup" "5" "alphaoverride" "setfloating" "rollinglog" "::=" "rounding" "layouts" "moveworkspacetomonitor" "exec" "alphainactiveoverride" "alterzorder" "fakefullscreen" "nofocus" "keyword" "forcenoborder" "forcenodim" "--quiet" "pin" "output" "forcenoblur" "togglespecialworkspace" "fullscreen" "toggleopaque" "focusworkspaceoncurrentmonitor" "next" "changegroupactive" "-j" "instances" "execr" "exit" "clients" "all" "--batch" "dismissnotify" "inactivebordercolor" "switchxkblayout" "movetoworkspacesilent" "tagwindow" "movewindoworgroup" "-r" "movefocus" "focusurgentorlast" "remove" "activeworkspace" "dispatch" "create" "centerwindow" "2" "hyprpaper" "-1" "reload" "alphainactive" "systeminfo" "plugin" "dimaround" "activewindow" "swapactiveworkspaces" "splash" "sendshortcut" "maxsize" "lockactivegroup" "windowdancecompat" "forceopaqueoverriden" "lockgroups" "movecursortocorner" "x11" "prev" "1" "resizewindowpixel" "forcenoshadow")
local -A descriptions
descriptions[1]="Focus the next window on a workspace"
descriptions[3]="Get the current cursor pos in global layout coordinates"
descriptions[5]="Rename a workspace"
descriptions[7]="Focus the first window matching"
descriptions[10]="Swap the focused window with the next window"
descriptions[12]="Move the active window"
descriptions[16]="List the layers"
descriptions[18]="List active outputs with their properties"
descriptions[20]="Get into a kill mode, where you can kill an app by clicking on it"
descriptions[21]="Set the current window's floating state to false"
descriptions[22]="ERROR"
descriptions[23]="Focus a monitor"
descriptions[24]="Swap the active window with another window"
descriptions[25]="Move the active window out of a group"
descriptions[26]="Send a notification using the built-in Hyprland notification system"
descriptions[27]="Move the cursor to a specified position"
descriptions[28]="Set the cursor theme and reloads the cursor manager"
descriptions[29]="Set the hyprctl error string"
descriptions[30]="Move the active workspace to a monitor"
descriptions[31]="CONFUSED"
descriptions[34]="Set a property of a window"
descriptions[35]="Specify the Hyprland instance"
descriptions[36]="Disable output"
descriptions[37]="Toggle the current window's floating state"
descriptions[38]="Get the list of defined workspace rules"
descriptions[39]="Move the focused window to a workspace"
descriptions[41]="Temporarily enable or disable binds:ignore_group_lock"
descriptions[42]="List all workspaces with their properties"
descriptions[43]="Swap the active window with the next or previous in a group"
descriptions[44]="Close a specified window"
descriptions[45]="WARNING"
descriptions[46]="Specify the Hyprland instance"
descriptions[47]="List all registered binds"
descriptions[48]="Move the active window in a direction or to a monitor"
descriptions[49]="Change the split ratio"
descriptions[51]="Prohibit the active window from becoming or being inserted into group"
descriptions[52]="Change the workspace"
descriptions[53]="List all current config parsing errors"
descriptions[54]="Toggle the current active window into a group"
descriptions[55]="Get the config option status (values)"
descriptions[58]="Close the active window"
descriptions[59]="Pass the key to a specified window"
descriptions[60]="List all decorations and their info"
descriptions[61]="List all connected keyboards and mice"
descriptions[62]="Switch focus from current to previously focused window"
descriptions[63]="Change the current mapping group"
descriptions[64]="Execute a Global Shortcut using the GlobalShortcuts portal"
descriptions[66]="Force the renderer to reload all resources and outputs"
descriptions[67]="Move a selected window"
descriptions[69]="Print the Hyprland version: flags, commit and branch of build"
descriptions[70]="Set all monitors' DPMS status"
descriptions[71]="Resize the active window"
descriptions[72]="Move the active window into a group"
descriptions[73]="OK"
descriptions[75]="Set the current window's floating state to true"
descriptions[76]="Print tail of the log"
descriptions[79]="List all layouts available (including plugin ones)"
descriptions[80]="Move a workspace to a monitor"
descriptions[81]="Execute a shell command"
descriptions[83]="Modify the window stack order of the active or specified window"
descriptions[84]="Toggle the focused window's internal fullscreen state"
descriptions[86]="Issue a keyword to call a config keyword dynamically"
descriptions[89]="Disable output"
descriptions[90]="Pin a window"
descriptions[91]="Allows adding/removing fake outputs to a specific backend"
descriptions[93]="Toggle a special workspace on/off"
descriptions[94]="Toggle the focused window's fullscreen state"
descriptions[95]="Toggle the current window to always be opaque"
descriptions[96]="Focus the requested workspace"
descriptions[98]="Switch to the next window in a group"
descriptions[99]="Output in JSON format"
descriptions[100]="List all running Hyprland instances and their info"
descriptions[101]="Execute a raw shell command"
descriptions[102]="Exit the compositor with no questions asked"
descriptions[103]="List all windows with their properties"
descriptions[105]="Execute a batch of commands separated by ;"
descriptions[106]="Dismiss all or up to amount of notifications"
descriptions[108]="Set the xkb layout index for a keyboard"
descriptions[109]="Move window doesnt switch to the workspace"
descriptions[110]="Apply a tag to the window"
descriptions[111]="Behave as moveintogroup"
descriptions[112]="Refresh state after issuing the command"
descriptions[113]="Move the focus in a direction"
descriptions[114]="Focus the urgent window or the last window"
descriptions[116]="Get the active workspace name and its properties"
descriptions[117]="Issue a dispatch to call a keybind dispatcher with an arg"
descriptions[119]="Center the active window"
descriptions[120]="HINT"
descriptions[121]="Interact with hyprpaper if present"
descriptions[122]="No Icon"
descriptions[123]="Force reload the config"
descriptions[125]="Print system info"
descriptions[126]="Interact with a plugin"
descriptions[128]="Get the active window name and its properties"
descriptions[129]="Swap the active workspaces between two monitors"
descriptions[130]="Print the current random splash"
descriptions[131]="On shortcut X sends shortcut Y to a specified window"
descriptions[133]="Lock the focused group"
descriptions[136]="Lock the groups"
descriptions[137]="Move the cursor to the corner of the active window"
descriptions[140]="INFO"
descriptions[141]="Resize a selected window"
local -A literal_transitions
literal_transitions[1]="([106]=2 [76]=3 [34]=4 [36]=5 [2]=3 [3]=3 [79]=3 [108]=6 [38]=3 [112]=5 [42]=3 [47]=3 [116]=3 [86]=7 [117]=9 [53]=3 [89]=5 [55]=3 [91]=10 [121]=3 [123]=3 [125]=3 [16]=3 [60]=11 [61]=3 [18]=12 [126]=13 [20]=3 [128]=3 [130]=3 [26]=14 [69]=3 [99]=5 [100]=3 [28]=3 [29]=15 [103]=3 [105]=5)"
literal_transitions[4]="([74]=18 [14]=3 [33]=18 [56]=18 [57]=18 [92]=18 [107]=3 [124]=3 [78]=2 [17]=3 [127]=18 [4]=2 [6]=3 [65]=18 [132]=3 [134]=18 [82]=18 [135]=18 [85]=18 [32]=18 [50]=3 [13]=3 [87]=18 [11]=18 [88]=18 [142]=18)"
literal_transitions[8]="([106]=2 [76]=3 [34]=4 [2]=3 [3]=3 [79]=3 [108]=6 [38]=3 [42]=3 [47]=3 [116]=3 [86]=7 [117]=9 [53]=3 [55]=3 [91]=10 [121]=3 [123]=3 [125]=3 [16]=3 [60]=11 [61]=3 [18]=12 [126]=13 [20]=3 [128]=3 [130]=3 [26]=14 [69]=3 [100]=3 [28]=3 [29]=15 [103]=3)"
literal_transitions[9]="([102]=3 [131]=3 [133]=3 [1]=3 [75]=3 [37]=3 [109]=3 [110]=3 [39]=3 [111]=3 [5]=3 [80]=3 [41]=3 [81]=3 [114]=3 [7]=3 [43]=3 [44]=3 [83]=3 [84]=3 [48]=3 [49]=3 [10]=3 [51]=3 [52]=3 [54]=3 [12]=3 [113]=3 [90]=3 [119]=3 [58]=3 [93]=3 [59]=3 [94]=3 [95]=3 [62]=3 [63]=3 [129]=3 [96]=3 [64]=3 [21]=3 [98]=3 [23]=3 [24]=3 [66]=3 [67]=3 [136]=3 [137]=3 [25]=3 [27]=3 [70]=3 [101]=3 [71]=3 [141]=3 [30]=3 [72]=3)"
literal_transitions[10]="([118]=21 [115]=17)"
literal_transitions[12]="([104]=3)"
literal_transitions[14]="([22]=2 [120]=2 [31]=2 [140]=2 [122]=2 [45]=2 [73]=2)"
literal_transitions[15]="([40]=3)"
literal_transitions[16]="([139]=3 [97]=3)"
literal_transitions[18]="([19]=3 [8]=3)"
literal_transitions[19]="([77]=20)"
literal_transitions[20]="([35]=5 [46]=5)"
literal_transitions[21]="([9]=3 [68]=3 [15]=3 [138]=3)"
local -A match_anything_transitions
match_anything_transitions=([2]=3 [1]=8 [7]=3 [16]=3 [11]=3 [6]=16 [15]=19 [8]=8 [3]=19 [17]=3 [13]=3 [12]=19)
declare -A subword_transitions
local state=1
local word_index=2
while [[ $word_index -lt $CURRENT ]]; do
if [[ -v "literal_transitions[$state]" ]]; then
local -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
local word=${words[$word_index]}
local word_matched=0
for ((literal_id = 1; literal_id <= $#literals; literal_id++)); do
if [[ ${literals[$literal_id]} = "$word" ]]; then
if [[ -v "state_transitions[$literal_id]" ]]; then
state=${state_transitions[$literal_id]}
word_index=$((word_index + 1))
word_matched=1
break
fi
fi
done
if [[ $word_matched -ne 0 ]]; then
continue
fi
fi
if [[ -v "match_anything_transitions[$state]" ]]; then
state=${match_anything_transitions[$state]}
word_index=$((word_index + 1))
continue
fi
return 1
done
completions_no_description_trailing_space=()
completions_no_description_no_trailing_space=()
completions_trailing_space=()
suffixes_trailing_space=()
descriptions_trailing_space=()
completions_no_trailing_space=()
suffixes_no_trailing_space=()
descriptions_no_trailing_space=()
if [[ -v "literal_transitions[$state]" ]]; then
local -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
for literal_id in ${(k)state_transitions}; do
if [[ -v "descriptions[$literal_id]" ]]; then
completions_trailing_space+=("${literals[$literal_id]}")
suffixes_trailing_space+=("${literals[$literal_id]}")
descriptions_trailing_space+=("${descriptions[$literal_id]}")
else
completions_no_description_trailing_space+=("${literals[$literal_id]}")
fi
done
fi
local -A commands=([6]=1 [17]=2 [13]=3 [11]=0)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local output=$(_hyprctl_cmd_${command_id} "${words[$CURRENT]}")
local -a command_completions=("${(@f)output}")
for line in ${command_completions[@]}; do
local parts=(${(@s: :)line})
if [[ -v "parts[2]" ]]; then
completions_trailing_space+=("${parts[1]}")
suffixes_trailing_space+=("${parts[1]}")
descriptions_trailing_space+=("${parts[2]}")
else
completions_no_description_trailing_space+=("${parts[1]}")
fi
done
fi
local maxlen=0
for suffix in ${suffixes_trailing_space[@]}; do
if [[ ${#suffix} -gt $maxlen ]]; then
maxlen=${#suffix}
fi
done
for suffix in ${suffixes_no_trailing_space[@]}; do
if [[ ${#suffix} -gt $maxlen ]]; then
maxlen=${#suffix}
fi
done
for ((i = 1; i <= $#suffixes_trailing_space; i++)); do
if [[ -z ${descriptions_trailing_space[$i]} ]]; then
descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}}"
else
descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}} -- ${descriptions_trailing_space[$i]}"
fi
done
for ((i = 1; i <= $#suffixes_no_trailing_space; i++)); do
if [[ -z ${descriptions_no_trailing_space[$i]} ]]; then
descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}}"
else
descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}} -- ${descriptions_no_trailing_space[$i]}"
fi
done
compadd -Q -a completions_no_description_trailing_space
compadd -Q -S ' ' -a completions_no_description_no_trailing_space
compadd -l -Q -a -d descriptions_trailing_space completions_trailing_space
compadd -l -Q -S '' -a -d descriptions_no_trailing_space completions_no_trailing_space
return 0
}
compdef _hyprctl hyprctl

View File

@@ -8,6 +8,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <pwd.h>
#include <unistd.h>
#include <ranges>
#include <algorithm>
@@ -22,50 +23,14 @@
#include <deque>
#include <filesystem>
#include <stdarg.h>
#include <regex>
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
commands:
activewindow
activeworkspace
binds
clients
cursorpos
decorations
devices
dispatch
getoption
globalshortcuts
hyprpaper
instances
keyword
kill
layers
layouts
monitors
notify
plugin
reload
setcursor
seterror
setprop
splash
switchxkblayout
systeminfo
version
workspacerules
workspaces
flags:
-j -> output in JSON
-r -> refresh state after issuing command (e.g. for updating variables)
--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)
)#";
#include "Strings.hpp"
#define PAD
std::string instanceSignature;
bool quiet = false;
struct SInstanceData {
std::string id;
@@ -75,24 +40,41 @@ struct SInstanceData {
bool valid = true;
};
void log(std::string str) {
if (quiet)
return;
std::cout << str;
}
std::string getRuntimeDir() {
const auto XDG = getenv("XDG_RUNTIME_DIR");
if (!XDG) {
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
return "/run/user/" + USERID + "/hypr";
}
return std::string{XDG} + "/hypr";
}
std::vector<SInstanceData> instances() {
std::vector<SInstanceData> result;
for (const auto& el : std::filesystem::directory_iterator("/tmp/hypr")) {
if (el.is_directory() || !el.path().string().ends_with(".lock"))
for (const auto& el : std::filesystem::directory_iterator(getRuntimeDir())) {
if (!el.is_directory() || !std::filesystem::exists(el.path().string() + "/hyprland.lock"))
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->id = el.path().filename().string();
try {
data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1));
data->time = std::stoull(data->id.substr(data->id.find_first_of('_') + 1, data->id.find_last_of('_') - (data->id.find_first_of('_') + 1)));
} catch (std::exception& e) { continue; }
// read file
std::ifstream ifs(el.path().string());
std::ifstream ifs(el.path().string() + "/hyprland.lock");
int i = 0;
for (std::string line; std::getline(ifs, line); ++i) {
@@ -116,43 +98,45 @@ std::vector<SInstanceData> instances() {
return result;
}
void request(std::string arg, int minArgs = 0) {
int request(std::string arg, int minArgs = 0) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
if (ARGS < minArgs) {
std::cout << "Not enough arguments, expected at least " << minArgs;
return;
log("Not enough arguments, expected at least " + minArgs);
return -1;
}
if (SERVERSOCKET < 0) {
std::cout << "Couldn't open a socket (1)";
return;
log("Couldn't open a socket (1)");
return 1;
}
if (instanceSignature.empty()) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)";
return;
log("HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)");
return 2;
}
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.socket.sock";
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.socket.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) {
std::cout << "Couldn't connect to " << socketPath << ". (3)";
return;
log("Couldn't connect to " + socketPath + ". (3)");
return 3;
}
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length());
if (sizeWritten < 0) {
std::cout << "Couldn't write (4)";
return;
log("Couldn't write (4)");
return 4;
}
std::string reply = "";
@@ -161,8 +145,8 @@ void request(std::string arg, int minArgs = 0) {
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
std::cout << "Couldn't read (5)";
return;
log("Couldn't read (5)");
return 5;
}
reply += std::string(buffer, sizeWritten);
@@ -170,40 +154,44 @@ void request(std::string arg, int minArgs = 0) {
while (sizeWritten == 8192) {
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
std::cout << "Couldn't read (5)";
return;
log("Couldn't read (5)");
return 5;
}
reply += std::string(buffer, sizeWritten);
}
close(SERVERSOCKET);
std::cout << reply;
log(reply);
return 0;
}
void requestHyprpaper(std::string arg) {
int requestHyprpaper(std::string arg) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) {
std::cout << "Couldn't open a socket (1)";
return;
log("Couldn't open a socket (1)");
return 1;
}
if (instanceSignature.empty()) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)";
return;
log("HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)");
return 2;
}
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.hyprpaper.sock";
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.hyprpaper.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) {
std::cout << "Couldn't connect to " << socketPath << ". (3)";
return;
log("Couldn't connect to " + socketPath + ". (3)");
return 3;
}
arg = arg.substr(arg.find_first_of('/') + 1); // strip flags
@@ -212,8 +200,8 @@ void requestHyprpaper(std::string arg) {
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length());
if (sizeWritten < 0) {
std::cout << "Couldn't write (4)";
return;
log("Couldn't write (4)");
return 4;
}
char buffer[8192] = {0};
@@ -221,18 +209,25 @@ void requestHyprpaper(std::string arg) {
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
std::cout << "Couldn't read (5)";
return;
log("Couldn't read (5)");
return 5;
}
close(SERVERSOCKET);
std::cout << std::string(buffer);
log(std::string(buffer));
return 0;
}
void batchRequest(std::string arg) {
std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
void batchRequest(std::string arg, bool json) {
std::string commands = arg.substr(arg.find_first_of(" ") + 1);
if (json) {
commands = "j/" + std::regex_replace(commands, std::regex(";\\s*"), ";j/");
}
std::string rq = "[[BATCH]]" + commands;
request(rq);
}
@@ -263,7 +258,7 @@ void instancesRequest(bool json) {
result += "\n]";
}
std::cout << result << "\n";
log(result + "\n");
}
std::deque<std::string> splitArgs(int argc, char** argv) {
@@ -285,7 +280,7 @@ int main(int argc, char** argv) {
bool parseArgs = true;
if (argc < 2) {
printf("%s\n", USAGE.c_str());
std::cout << USAGE << std::endl;
return 1;
}
@@ -308,19 +303,45 @@ int main(int argc, char** argv) {
json = true;
} else if (ARGS[i] == "-r" && !fullArgs.contains("r")) {
fullArgs += "r";
} else if (ARGS[i] == "-a" && !fullArgs.contains("a")) {
fullArgs += "a";
} else if ((ARGS[i] == "-c" || ARGS[i] == "--config") && !fullArgs.contains("c")) {
fullArgs += "c";
} 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());
std::cout << USAGE << std::endl;
return 1;
}
overrideInstance = ARGS[i];
} else if (ARGS[i] == "-q" || ARGS[i] == "--quiet") {
quiet = true;
} else if (ARGS[i] == "--help") {
const std::string& cmd = ARGS[0];
if (cmd == "hyprpaper") {
std::cout << HYPRPAPER_HELP << std::endl;
} else if (cmd == "notify") {
std::cout << NOTIFY_HELP << std::endl;
} else if (cmd == "output") {
std::cout << OUTPUT_HELP << std::endl;
} else if (cmd == "plugin") {
std::cout << PLUGIN_HELP << std::endl;
} else if (cmd == "setprop") {
std::cout << SETPROP_HELP << std::endl;
} else if (cmd == "switchxkblayout") {
std::cout << SWITCHXKBLAYOUT_HELP << std::endl;
} else {
std::cout << USAGE << std::endl;
}
return 1;
} else {
printf("%s\n", USAGE.c_str());
std::cout << USAGE << std::endl;
return 1;
}
@@ -331,7 +352,7 @@ int main(int argc, char** argv) {
}
if (fullRequest.empty()) {
printf("%s\n", USAGE.c_str());
std::cout << USAGE << std::endl;
return 1;
}
@@ -349,7 +370,7 @@ int main(int argc, char** argv) {
instanceSignature = overrideInstance;
else if (!overrideInstance.empty()) {
if (!isNumber(overrideInstance, false)) {
std::cout << "instance invalid\n";
log("instance invalid\n");
return 1;
}
@@ -358,7 +379,7 @@ int main(int argc, char** argv) {
const auto INSTANCES = instances();
if (INSTANCENO < 0 || static_cast<std::size_t>(INSTANCENO) >= INSTANCES.size()) {
std::cout << "no such instance\n";
log("no such instance\n");
return 1;
}
@@ -367,7 +388,7 @@ int main(int argc, char** argv) {
const auto ISIG = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!ISIG) {
std::cout << "HYPRLAND_INSTANCE_SIGNATURE not set! (is hyprland running?)\n";
log("HYPRLAND_INSTANCE_SIGNATURE not set! (is hyprland running?)\n");
return 1;
}
@@ -377,35 +398,37 @@ int main(int argc, char** argv) {
int exitStatus = 0;
if (fullRequest.contains("/--batch"))
batchRequest(fullRequest);
batchRequest(fullRequest, json);
else if (fullRequest.contains("/hyprpaper"))
requestHyprpaper(fullRequest);
exitStatus = requestHyprpaper(fullRequest);
else if (fullRequest.contains("/switchxkblayout"))
request(fullRequest, 2);
exitStatus = request(fullRequest, 2);
else if (fullRequest.contains("/seterror"))
request(fullRequest, 1);
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/setprop"))
request(fullRequest, 3);
exitStatus = request(fullRequest, 3);
else if (fullRequest.contains("/plugin"))
request(fullRequest, 1);
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/dismissnotify"))
exitStatus = request(fullRequest, 0);
else if (fullRequest.contains("/notify"))
request(fullRequest, 2);
exitStatus = request(fullRequest, 2);
else if (fullRequest.contains("/output"))
request(fullRequest, 2);
exitStatus = request(fullRequest, 2);
else if (fullRequest.contains("/setcursor"))
request(fullRequest, 1);
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/dispatch"))
request(fullRequest, 1);
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/keyword"))
request(fullRequest, 2);
exitStatus = request(fullRequest, 2);
else if (fullRequest.contains("/decorations"))
request(fullRequest, 1);
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/--help"))
printf("%s", USAGE.c_str());
std::cout << USAGE << std::endl;
else {
request(fullRequest);
exitStatus = request(fullRequest);
}
printf("\n");
std::cout << std::flush;
return exitStatus;
}

View File

@@ -1,3 +1,7 @@
executable('hyprctl', 'main.cpp',
install: true
)
install_data('hyprctl.bash', install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'), install_tag: 'runtime', rename: 'hyprctl')
install_data('hyprctl.fish', install_dir: join_paths(get_option('datadir'), 'fish/vendor_completions.d'), install_tag: 'runtime')
install_data('hyprctl.zsh', install_dir: join_paths(get_option('datadir'), 'zsh/site-functions'), install_tag: 'runtime', rename: '_hyprctl')

View File

@@ -1,8 +1,7 @@
prefix="@PREFIX@"
includedir="${prefix}/include"
prefix=@PREFIX@/@INCLUDEDIR@
Name: Hyprland
URL: https://github.com/hyprwm/Hyprland
Description: Hyprland header files
Version: @HYPRLAND_VERSION@
Cflags: -I"${includedir}/hyprland/protocols" -I"${includedir}/hyprland/wlroots" -I"${includedir}"
Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland -I${prefix}/hyprland/wlr

View File

@@ -14,3 +14,16 @@ pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
add_executable(hyprpm ${SRCFILES})
target_link_libraries(hyprpm PUBLIC PkgConfig::tomlplusplus)
# binary
install(TARGETS hyprpm)
# shell completions
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.bash
DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions
RENAME hyprpm)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.fish
DESTINATION ${CMAKE_INSTALL_DATADIR}/fish/vendor_completions.d)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.zsh
DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions
RENAME _hyprpm)

106
hyprpm/hyprpm.bash Normal file
View File

@@ -0,0 +1,106 @@
_hyprpm_cmd_0 () {
hyprpm list | grep Plugin | awk '{print $4}'
}
_hyprpm () {
if [[ $(type -t _get_comp_words_by_ref) != function ]]; then
echo _get_comp_words_by_ref: function not defined. Make sure the bash-completions system package is installed
return 1
fi
local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
declare -A literal_transitions
literal_transitions[0]="([9]=6 [2]=2 [7]=6 [8]=6 [4]=6 [10]=2 [11]=3 [5]=2 [13]=6 [3]=3 [14]=2 [15]=6 [6]=2)"
literal_transitions[1]="([10]=2 [11]=3 [3]=3 [2]=2 [14]=2 [5]=2 [6]=2)"
literal_transitions[4]="([1]=5)"
literal_transitions[5]="([0]=6 [12]=6)"
declare -A match_anything_transitions
match_anything_transitions=([3]=2 [2]=4 [0]=1 [1]=1)
declare -A subword_transitions
local state=0
local word_index=1
while [[ $word_index -lt $cword ]]; do
local word=${words[$word_index]}
if [[ -v "literal_transitions[$state]" ]]; then
declare -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
local word_matched=0
for literal_id in $(seq 0 $((${#literals[@]} - 1))); do
if [[ ${literals[$literal_id]} = "$word" ]]; then
if [[ -v "state_transitions[$literal_id]" ]]; then
state=${state_transitions[$literal_id]}
word_index=$((word_index + 1))
word_matched=1
break
fi
fi
done
if [[ $word_matched -ne 0 ]]; then
continue
fi
fi
if [[ -v "match_anything_transitions[$state]" ]]; then
state=${match_anything_transitions[$state]}
word_index=$((word_index + 1))
continue
fi
return 1
done
local prefix="${words[$cword]}"
local shortest_suffix="$word"
for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
local char="${COMP_WORDBREAKS:$i:1}"
local candidate="${word##*$char}"
if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
shortest_suffix=$candidate
fi
done
local superfluous_prefix=""
if [[ "$shortest_suffix" != "$word" ]]; then
local superfluous_prefix=${word%$shortest_suffix}
fi
if [[ -v "literal_transitions[$state]" ]]; then
local state_transitions_initializer=${literal_transitions[$state]}
declare -A state_transitions
eval "state_transitions=$state_transitions_initializer"
for literal_id in "${!state_transitions[@]}"; do
local literal="${literals[$literal_id]}"
if [[ $literal = "${prefix}"* ]]; then
local completion=${literal#"$superfluous_prefix"}
COMPREPLY+=("$completion ")
fi
done
fi
declare -A commands
commands=([3]=0)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local completions=()
mapfile -t completions < <(_hyprpm_cmd_${command_id} "$prefix" | cut -f1)
for item in "${completions[@]}"; do
if [[ $item = "${prefix}"* ]]; then
COMPREPLY+=("$item")
fi
done
fi
return 0
}
complete -o nospace -F _hyprpm hyprpm

109
hyprpm/hyprpm.fish Normal file
View File

@@ -0,0 +1,109 @@
function _hyprpm_1
set 1 $argv[1]
hyprpm list | grep Plugin | awk '{print $4}'
end
function _hyprpm
set COMP_LINE (commandline --cut-at-cursor)
set COMP_WORDS
echo $COMP_LINE | read --tokenize --array COMP_WORDS
if string match --quiet --regex '.*\s$' $COMP_LINE
set COMP_CWORD (math (count $COMP_WORDS) + 1)
else
set COMP_CWORD (count $COMP_WORDS)
end
set --local literals "-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f"
set --local descriptions
set descriptions[1] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[3] "List all installed plugins"
set descriptions[4] "Unload a plugin"
set descriptions[5] "Show help menu"
set descriptions[6] "Check and update all plugins if needed"
set descriptions[7] "Install a new plugin repository from git"
set descriptions[8] "Enable too much loggin"
set descriptions[9] "Enable too much loggin"
set descriptions[10] "Force an operation ignoring checks (e.g. update -f)"
set descriptions[11] "Remove a plugin repository"
set descriptions[12] "Load a plugin"
set descriptions[13] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[14] "Show help menu"
set descriptions[15] "Reload all plugins"
set descriptions[16] "Force an operation ignoring checks (e.g. update -f)"
set --local literal_transitions
set literal_transitions[1] "set inputs 10 3 8 9 5 11 12 6 14 4 15 16 7; set tos 7 3 7 7 7 3 4 3 7 4 3 7 3"
set literal_transitions[2] "set inputs 11 12 4 3 15 6 7; set tos 3 4 4 3 3 3 3"
set literal_transitions[5] "set inputs 2; set tos 6"
set literal_transitions[6] "set inputs 1 13; set tos 7 7"
set --local match_anything_transitions_from 4 3 1 2
set --local match_anything_transitions_to 3 5 2 2
set --local state 1
set --local word_index 2
while test $word_index -lt $COMP_CWORD
set --local -- word $COMP_WORDS[$word_index]
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
eval $literal_transitions[$state]
if contains -- $word $literals
set --local literal_matched 0
for literal_id in (seq 1 (count $literals))
if test $literals[$literal_id] = $word
set --local index (contains --index -- $literal_id $inputs)
set state $tos[$index]
set word_index (math $word_index + 1)
set literal_matched 1
break
end
end
if test $literal_matched -ne 0
continue
end
end
end
if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state]
set --local index (contains --index -- $state $match_anything_transitions_from)
set state $match_anything_transitions_to[$index]
set word_index (math $word_index + 1)
continue
end
return 1
end
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
eval $literal_transitions[$state]
for literal_id in $inputs
if test -n $descriptions[$literal_id]
printf '%s\t%s\n' $literals[$literal_id] $descriptions[$literal_id]
else
printf '%s\n' $literals[$literal_id]
end
end
end
set command_states 4
set command_ids 1
if contains $state $command_states
set --local index (contains --index $state $command_states)
set --local function_id $command_ids[$index]
set --local function_name _hyprpm_$function_id
set --local --erase inputs
set --local --erase tos
$function_name "$COMP_WORDS[$COMP_CWORD]"
end
return 0
end
complete --command hyprpm --no-files --arguments "(_hyprpm)"

19
hyprpm/hyprpm.usage Normal file
View File

@@ -0,0 +1,19 @@
hyprpm [<FLAGS>]... <ARGUMENT>
<FLAGS> ::= (--notify | -n) "Send a hyprland notification for important events (e.g. load fail)"
| (--help | -h) "Show help menu"
| (--verbose | -v) "Enable too much loggin"
| (--force | -f) "Force an operation ignoring checks (e.g. update -f)"
;
<ARGUMENT> ::= (add) "Install a new plugin repository from git"
| (remove) "Remove a plugin repository"
| (update) "Check and update all plugins if needed"
| (list) "List all installed plugins"
| (enable <PLUGINS>) "Load a plugin"
| (disable <PLUGINS>) "Unload a plugin"
| (reload) "Reload all plugins"
;
<PLUGINS> ::= {{{ hyprpm list | grep Plugin | awk '{print $4}' }}};

151
hyprpm/hyprpm.zsh Normal file
View File

@@ -0,0 +1,151 @@
#compdef hyprpm
_hyprpm_cmd_0 () {
hyprpm list | grep Plugin | awk '{print $4}'
}
_hyprpm () {
local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
local -A descriptions
descriptions[1]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[3]="List all installed plugins"
descriptions[4]="Unload a plugin"
descriptions[5]="Show help menu"
descriptions[6]="Check and update all plugins if needed"
descriptions[7]="Install a new plugin repository from git"
descriptions[8]="Enable too much loggin"
descriptions[9]="Enable too much loggin"
descriptions[10]="Force an operation ignoring checks (e.g. update -f)"
descriptions[11]="Remove a plugin repository"
descriptions[12]="Load a plugin"
descriptions[13]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[14]="Show help menu"
descriptions[15]="Reload all plugins"
descriptions[16]="Force an operation ignoring checks (e.g. update -f)"
local -A literal_transitions
literal_transitions[1]="([10]=7 [3]=3 [8]=7 [9]=7 [5]=7 [11]=3 [12]=4 [6]=3 [14]=7 [4]=4 [15]=3 [16]=7 [7]=3)"
literal_transitions[2]="([11]=3 [12]=4 [4]=4 [3]=3 [15]=3 [6]=3 [7]=3)"
literal_transitions[5]="([2]=6)"
literal_transitions[6]="([1]=7 [13]=7)"
local -A match_anything_transitions
match_anything_transitions=([4]=3 [3]=5 [1]=2 [2]=2)
declare -A subword_transitions
local state=1
local word_index=2
while [[ $word_index -lt $CURRENT ]]; do
if [[ -v "literal_transitions[$state]" ]]; then
local -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
local word=${words[$word_index]}
local word_matched=0
for ((literal_id = 1; literal_id <= $#literals; literal_id++)); do
if [[ ${literals[$literal_id]} = "$word" ]]; then
if [[ -v "state_transitions[$literal_id]" ]]; then
state=${state_transitions[$literal_id]}
word_index=$((word_index + 1))
word_matched=1
break
fi
fi
done
if [[ $word_matched -ne 0 ]]; then
continue
fi
fi
if [[ -v "match_anything_transitions[$state]" ]]; then
state=${match_anything_transitions[$state]}
word_index=$((word_index + 1))
continue
fi
return 1
done
completions_no_description_trailing_space=()
completions_no_description_no_trailing_space=()
completions_trailing_space=()
suffixes_trailing_space=()
descriptions_trailing_space=()
completions_no_trailing_space=()
suffixes_no_trailing_space=()
descriptions_no_trailing_space=()
if [[ -v "literal_transitions[$state]" ]]; then
local -A state_transitions
eval "state_transitions=${literal_transitions[$state]}"
for literal_id in ${(k)state_transitions}; do
if [[ -v "descriptions[$literal_id]" ]]; then
completions_trailing_space+=("${literals[$literal_id]}")
suffixes_trailing_space+=("${literals[$literal_id]}")
descriptions_trailing_space+=("${descriptions[$literal_id]}")
else
completions_no_description_trailing_space+=("${literals[$literal_id]}")
fi
done
fi
local -A commands=([4]=0)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local output=$(_hyprpm_cmd_${command_id} "${words[$CURRENT]}")
local -a command_completions=("${(@f)output}")
for line in ${command_completions[@]}; do
local parts=(${(@s: :)line})
if [[ -v "parts[2]" ]]; then
completions_trailing_space+=("${parts[1]}")
suffixes_trailing_space+=("${parts[1]}")
descriptions_trailing_space+=("${parts[2]}")
else
completions_no_description_trailing_space+=("${parts[1]}")
fi
done
fi
local maxlen=0
for suffix in ${suffixes_trailing_space[@]}; do
if [[ ${#suffix} -gt $maxlen ]]; then
maxlen=${#suffix}
fi
done
for suffix in ${suffixes_no_trailing_space[@]}; do
if [[ ${#suffix} -gt $maxlen ]]; then
maxlen=${#suffix}
fi
done
for ((i = 1; i <= $#suffixes_trailing_space; i++)); do
if [[ -z ${descriptions_trailing_space[$i]} ]]; then
descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}}"
else
descriptions_trailing_space[$i]="${(r($maxlen)( ))${suffixes_trailing_space[$i]}} -- ${descriptions_trailing_space[$i]}"
fi
done
for ((i = 1; i <= $#suffixes_no_trailing_space; i++)); do
if [[ -z ${descriptions_no_trailing_space[$i]} ]]; then
descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}}"
else
descriptions_no_trailing_space[$i]="${(r($maxlen)( ))${suffixes_no_trailing_space[$i]}} -- ${descriptions_no_trailing_space[$i]}"
fi
done
compadd -Q -a completions_no_description_trailing_space
compadd -Q -S ' ' -a completions_no_description_no_trailing_space
compadd -l -Q -a -d descriptions_trailing_space completions_trailing_space
compadd -l -Q -S '' -a -d descriptions_no_trailing_space completions_no_trailing_space
return 0
}
if [[ $ZSH_EVAL_CONTEXT =~ :file$ ]]; then
compdef _hyprpm hyprpm
else
_hyprpm
fi

View File

@@ -45,12 +45,14 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
{"repository", toml::table{
{"name", repo.name},
{"hash", repo.hash},
{"url", repo.url}
{"url", repo.url},
{"rev", repo.rev}
}}
};
for (auto& p : repo.plugins) {
// copy .so to the good place
std::filesystem::copy_file(p.filename, PATH + "/" + p.name + ".so");
if (std::filesystem::exists(p.filename))
std::filesystem::copy_file(p.filename, PATH + "/" + p.name + ".so");
DATA.emplace(p.name, toml::table{
{"filename", p.name + ".so"},
@@ -177,12 +179,14 @@ std::vector<SPluginRepository> DataState::getAllRepositories() {
const auto NAME = STATE["repository"]["name"].value_or("");
const auto URL = STATE["repository"]["url"].value_or("");
const auto REV = STATE["repository"]["rev"].value_or("");
const auto HASH = STATE["repository"]["hash"].value_or("");
SPluginRepository repo;
repo.hash = HASH;
repo.name = NAME;
repo.url = URL;
repo.rev = REV;
for (const auto& [key, val] : STATE) {
if (key == "repository")

View File

@@ -75,6 +75,7 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
for (auto& plugin : m_vPlugins) {
plugin.description = manifest[plugin.name]["description"].value_or("?");
plugin.output = manifest[plugin.name]["output"].value_or("?");
plugin.since = manifest[plugin.name]["since_hyprland"].value_or(0);
auto authors = manifest[plugin.name]["authors"].as_array();
if (authors) {
for (auto&& a : *authors) {

View File

@@ -19,6 +19,7 @@ class CManifest {
std::vector<std::string> authors;
std::vector<std::string> buildSteps;
std::string output;
int since = 0;
bool failed = false;
};

View File

@@ -12,6 +12,7 @@ struct SPlugin {
struct SPluginRepository {
std::string url;
std::string rev;
std::string name;
std::vector<SPlugin> plugins;
std::string hash;

View File

@@ -12,6 +12,11 @@
#include <algorithm>
#include <format>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
#include <toml++/toml.hpp>
static std::string removeBeginEndSpacesTabs(std::string str) {
@@ -70,17 +75,52 @@ SHyprlandVersion CPluginManager::getHyprlandVersion() {
std::string hlbranch = HLVERCALL.substr(HLVERCALL.find("from branch") + 12);
hlbranch = hlbranch.substr(0, hlbranch.find(" at commit "));
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "parsed commit " << hlcommit << " at branch " << hlbranch << "\n";
std::string hldate = HLVERCALL.substr(HLVERCALL.find("Date: ") + 6);
hldate = hldate.substr(0, hldate.find("\n"));
ver = SHyprlandVersion{hlbranch, hlcommit};
std::string hlcommits;
if (HLVERCALL.contains("commits:")) {
hlcommits = HLVERCALL.substr(HLVERCALL.find("commits:") + 9);
hlcommits = hlcommits.substr(0, hlcommits.find(" "));
}
int commits = 0;
try {
commits = std::stoi(hlcommits);
} catch (...) { ; }
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "parsed commit " << hlcommit << " at branch " << hlbranch << " on " << hldate << ", commits " << commits << "\n";
ver = SHyprlandVersion{hlbranch, hlcommit, hldate, commits};
return ver;
}
bool CPluginManager::addNewPluginRepo(const std::string& url) {
bool CPluginManager::createSafeDirectory(const std::string& path) {
if (path.empty() || !path.starts_with("/tmp"))
return false;
if (std::filesystem::exists(path))
std::filesystem::remove_all(path);
if (std::filesystem::exists(path))
return false;
if (mkdir(path.c_str(), S_IRWXU) < 0)
return false;
return true;
}
bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& rev) {
const auto HLVER = getHyprlandVersion();
if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
return false;
}
if (DataState::pluginRepoExists(url)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Repository already installed.\n";
return false;
@@ -118,22 +158,37 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
if (!std::filesystem::exists("/tmp/hyprpm")) {
std::filesystem::create_directory("/tmp/hyprpm");
std::filesystem::permissions("/tmp/hyprpm", std::filesystem::perms::all, std::filesystem::perm_options::replace);
} else if (!std::filesystem::is_directory("/tmp/hyprpm")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for hyprpm\n";
return false;
}
if (std::filesystem::exists("/tmp/hyprpm/new")) {
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " old plugin repo build files found in temp directory, removing.");
std::filesystem::remove_all("/tmp/hyprpm/new");
const std::string USERNAME = getpwuid(getuid())->pw_name;
m_szWorkingPluginDirectory = "/tmp/hyprpm/" + USERNAME;
if (!createSafeDirectory(m_szWorkingPluginDirectory)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for repo\n";
return false;
}
progress.printMessageAbove(std::string{Colors::RESET} + " → Cloning " + url);
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + url + " new");
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + url + " " + USERNAME);
if (!std::filesystem::exists("/tmp/hyprpm/new")) {
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. shell returned:\n" << ret << "\n";
return false;
}
if (!rev.empty()) {
std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules " + rev);
if (ret.compare(0, 6, "fatal:") == 0) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not check out revision " << rev << ". shell returned:\n" << ret << "\n";
return false;
}
}
progress.m_iSteps = 1;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " cloned");
progress.m_szCurrentMessage = "Reading the manifest";
@@ -141,12 +196,12 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
std::unique_ptr<CManifest> pManifest;
if (std::filesystem::exists("/tmp/hyprpm/new/hyprpm.toml")) {
if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprpm.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprpm manifest");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, "/tmp/hyprpm/new/hyprpm.toml");
} else if (std::filesystem::exists("/tmp/hyprpm/new/hyprload.toml")) {
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, m_szWorkingPluginDirectory + "/hyprpm.toml");
} else if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprload.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprload manifest");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, "/tmp/hyprpm/new/hyprload.toml");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, m_szWorkingPluginDirectory + "/hyprload.toml");
}
if (!pManifest) {
@@ -185,7 +240,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " commit pin " + plugin + " matched hl, resetting");
execAndGet("cd /tmp/hyprpm/new/ && git reset --hard --recurse-submodules " + plugin);
execAndGet("cd " + m_szWorkingPluginDirectory + " && git reset --hard --recurse-submodules " + plugin);
}
}
@@ -207,21 +262,29 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
for (auto& p : pManifest->m_vPlugins) {
std::string out;
if (p.since > HLVER.commits && HLVER.commits >= 1 /* for --depth 1 clones, we can't check this. */) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n");
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::RESET} + " → Building " + p.name);
for (auto& bs : p.buildSteps) {
std::string cmd = std::format("cd /tmp/hyprpm/new && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", DataState::getHeadersPath(), bs);
std::string cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
}
if (!std::filesystem::exists("/tmp/hyprpm/new/" + p.output)) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Plugin " + p.name + " failed to build.\n");
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/" + p.output)) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Plugin " + p.name + " failed to build.\n" +
" This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update "
"first.\n Try re-running with -v to see "
"more verbose output.\n");
p.failed = true;
continue;
}
@@ -235,14 +298,15 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
// add repo toml to DataState
SPluginRepository repo;
std::string repohash = execAndGet("cd /tmp/hyprpm/new/ && git rev-parse HEAD");
std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
if (repohash.length() > 0)
repohash.pop_back();
repo.name = pManifest->m_sRepository.name.empty() ? url.substr(url.find_last_of('/') + 1) : pManifest->m_sRepository.name;
repo.url = url;
repo.rev = rev;
repo.hash = repohash;
for (auto& p : pManifest->m_vPlugins) {
repo.plugins.push_back(SPlugin{p.name, "/tmp/hyprpm/new/" + p.output, false, p.failed});
repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed});
}
DataState::addNewPluginRepo(repo);
@@ -255,7 +319,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
std::cout << "\n";
// remove build files
std::filesystem::remove_all("/tmp/hyprpm/new");
std::filesystem::remove_all(m_szWorkingPluginDirectory);
return true;
}
@@ -289,7 +353,7 @@ eHeadersErrors CPluginManager::headersValid() {
return HEADERS_MISSING;
// find headers commit
std::string cmd = std::format("PKG_CONFIG_PATH=\"{}/share/pkgconfig\" pkg-config --cflags --keep-system-cflags hyprland", DataState::getHeadersPath());
std::string cmd = std::format("PKG_CONFIG_PATH=\"{}/share/pkgconfig\" pkgconf --cflags --keep-system-cflags hyprland", DataState::getHeadersPath());
auto headers = execAndGet(cmd.c_str());
if (!headers.contains("-I/"))
@@ -307,7 +371,7 @@ eHeadersErrors CPluginManager::headersValid() {
else
headers = "";
if (PATH.ends_with("protocols") || PATH.ends_with("wlroots"))
if (PATH.ends_with("protocols") || PATH.ends_with("wlroots-hyprland"))
continue;
verHeader = removeBeginEndSpacesTabs(PATH.substr(2)) + "/hyprland/src/version.h";
@@ -325,7 +389,12 @@ eHeadersErrors CPluginManager::headersValid() {
std::string verHeaderContent((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
ifs.close();
std::string hash = verHeaderContent.substr(verHeaderContent.find("#define GIT_COMMIT_HASH") + 23);
const auto HASHPOS = verHeaderContent.find("#define GIT_COMMIT_HASH");
if (HASHPOS == std::string::npos || HASHPOS + 23 >= verHeaderContent.length())
return HEADERS_CORRUPTED;
std::string hash = verHeaderContent.substr(HASHPOS + 23);
hash = hash.substr(0, hash.find_first_of('\n'));
hash = hash.substr(hash.find_first_of('"') + 1);
hash = hash.substr(0, hash.find_first_of('"'));
@@ -342,6 +411,11 @@ bool CPluginManager::updateHeaders(bool force) {
const auto HLVER = getHyprlandVersion();
if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not update. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
return false;
}
if (!std::filesystem::exists("/tmp/hyprpm")) {
std::filesystem::create_directory("/tmp/hyprpm");
std::filesystem::permissions("/tmp/hyprpm", std::filesystem::perms::all, std::filesystem::perm_options::replace);
@@ -358,16 +432,35 @@ bool CPluginManager::updateHeaders(bool force) {
progress.m_szCurrentMessage = "Cloning the hyprland repository";
progress.print();
if (std::filesystem::exists("/tmp/hyprpm/hyprland")) {
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " old hyprland source files found in temp directory, removing.");
std::filesystem::remove_all("/tmp/hyprpm/hyprland");
const std::string USERNAME = getpwuid(getuid())->pw_name;
const auto WORKINGDIR = "/tmp/hyprpm/hyprland-" + USERNAME;
if (!createSafeDirectory(WORKINGDIR)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for hl\n";
return false;
}
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " Cloning https://github.com/hyprwm/hyprland, this might take a moment.");
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive https://github.com/hyprwm/hyprland hyprland");
const bool bShallow = HLVER.branch == "main" || HLVER.branch == "";
if (!std::filesystem::exists("/tmp/hyprpm/hyprland")) {
// let us give a bit of leg-room for shallowing
// due to timezones, etc.
const std::string SHALLOW_DATE =
removeBeginEndSpacesTabs(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+\%a \%b \%d \%H:\%M:\%S \%Y'");
if (m_bVerbose && bShallow)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "will shallow since: " + SHALLOW_DATE);
std::string ret =
execAndGet("cd /tmp/hyprpm && git clone --recursive https://github.com/hyprwm/hyprland hyprland-" + USERNAME + (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""));
if (!std::filesystem::exists(WORKINGDIR)) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Clone failed. Retrying without shallow.");
ret = execAndGet("cd /tmp/hyprpm && git clone --recursive https://github.com/hyprwm/hyprland hyprland-" + USERNAME);
}
if (!std::filesystem::exists(WORKINGDIR + "/.git")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the hyprland repository. shell returned:\n" << ret << "\n";
return false;
}
@@ -377,11 +470,15 @@ bool CPluginManager::updateHeaders(bool force) {
progress.m_szCurrentMessage = "Checking out sources";
progress.print();
ret =
execAndGet("cd /tmp/hyprpm/hyprland && git checkout " + HLVER.branch + " 2>&1 && git submodule update --init 2>&1 && git reset --hard --recurse-submodules " + HLVER.hash);
ret = execAndGet("cd " + WORKINGDIR + " && git checkout " + HLVER.branch + " 2>&1");
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "git returned: " + ret);
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "git returned (co): " + ret);
ret = execAndGet("cd " + WORKINGDIR + " && git rm subprojects/tracy && git submodule update --init 2>&1 && git reset --hard --recurse-submodules " + HLVER.hash);
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "git returned (rs): " + ret);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " checked out to running ver");
progress.m_iSteps = 3;
@@ -393,14 +490,23 @@ bool CPluginManager::updateHeaders(bool force) {
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "setting PREFIX for cmake to " + DataState::getHeadersPath());
ret = execAndGet(
std::format("cd /tmp/hyprpm/hyprland && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=\"{}\" -S . -B ./build -G Ninja",
DataState::getHeadersPath()));
ret = execAndGet(std::format("cd {} && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=\"{}\" -S . -B ./build -G Ninja", WORKINGDIR,
DataState::getHeadersPath()));
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "cmake returned: " + ret);
if (ret.contains("required packages were not found")) {
// missing deps, let the user know.
std::string missing = ret.substr(ret.find("The following required packages were not found:"));
missing = missing.substr(0, missing.find("Call Stack"));
missing = missing.substr(0, missing.find_last_of('\n'));
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not configure the hyprland source, cmake complained:\n" << missing << "\n";
return false;
}
// le hack. Wlroots has to generate its build/include
ret = execAndGet("cd /tmp/hyprpm/hyprland/subprojects/wlroots && meson setup -Drenderers=gles2 -Dexamples=false build");
ret = execAndGet("cd " + WORKINGDIR + "/subprojects/wlroots-hyprland && meson setup -Drenderers=gles2 -Dexamples=false build");
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "meson returned: " + ret);
@@ -409,12 +515,8 @@ bool CPluginManager::updateHeaders(bool force) {
progress.m_szCurrentMessage = "Installing sources";
progress.print();
// progress.printMessageAbove(
// std::string{Colors::YELLOW} + "!" + Colors::RESET +
// " in order to install the sources, you will need to input your password.\n If nothing pops up, make sure you have polkit and an authentication daemon running.");
std::string cmd = std::format("sed -i -e \"s#PREFIX = /usr/local#PREFIX = {}#\" /tmp/hyprpm/hyprland/Makefile && cd /tmp/hyprpm/hyprland && make installheaders",
DataState::getHeadersPath());
std::string cmd =
std::format("sed -i -e \"s#PREFIX = /usr/local#PREFIX = {}#\" {}/Makefile && cd {} && make installheaders", DataState::getHeadersPath(), WORKINGDIR, WORKINGDIR);
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "installation will run: " + cmd);
@@ -424,7 +526,7 @@ bool CPluginManager::updateHeaders(bool force) {
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "installer returned: " << ret << "\n";
// remove build files
std::filesystem::remove_all("/tmp/hyprpm/hyprland");
std::filesystem::remove_all(WORKINGDIR);
auto HEADERSVALID = headersValid();
if (HEADERSVALID == HEADERS_OK) {
@@ -471,6 +573,9 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.m_szCurrentMessage = "Updating repositories";
progress.print();
const std::string USERNAME = getpwuid(getuid())->pw_name;
m_szWorkingPluginDirectory = "/tmp/hyprpm/" + USERNAME;
for (auto& repo : REPOS) {
bool update = forceUpdateAll;
@@ -480,23 +585,30 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.printMessageAbove(std::string{Colors::RESET} + " → checking for updates for " + repo.name);
if (std::filesystem::exists("/tmp/hyprpm/update")) {
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " old update build files found in temp directory, removing.");
std::filesystem::remove_all("/tmp/hyprpm/update");
}
createSafeDirectory(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::RESET} + " → Cloning " + repo.url);
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + repo.url + " update");
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + repo.url + " " + USERNAME);
if (!std::filesystem::exists("/tmp/hyprpm/update")) {
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " could not clone repo: shell returned:\n" + ret;
return false;
}
if (!repo.rev.empty()) {
progress.printMessageAbove(std::string{Colors::RESET} + " → Plugin has revision set, resetting: " + repo.rev);
std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules " + repo.rev);
if (ret.compare(0, 6, "fatal:") == 0) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " could not check out revision " + repo.rev + ": shell returned:\n" + ret;
return false;
}
}
if (!update) {
// check if git has updates
std::string hash = execAndGet("cd /tmp/hyprpm/update && git rev-parse HEAD");
std::string hash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
if (!hash.empty())
hash.pop_back();
@@ -504,7 +616,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
}
if (!update) {
std::filesystem::remove_all("/tmp/hyprpm/update");
std::filesystem::remove_all(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " repository " + repo.name + " is up-to-date.");
progress.m_iSteps++;
progress.print();
@@ -520,12 +632,12 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
std::unique_ptr<CManifest> pManifest;
if (std::filesystem::exists("/tmp/hyprpm/update/hyprpm.toml")) {
if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprpm.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprpm manifest");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, "/tmp/hyprpm/update/hyprpm.toml");
} else if (std::filesystem::exists("/tmp/hyprpm/update/hyprload.toml")) {
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, m_szWorkingPluginDirectory + "/hyprpm.toml");
} else if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprload.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprload manifest");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, "/tmp/hyprpm/update/hyprload.toml");
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, m_szWorkingPluginDirectory + "/hyprload.toml");
}
if (!pManifest) {
@@ -538,8 +650,8 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
continue;
}
if (!pManifest->m_sRepository.commitPins.empty()) {
// check commit pins
if (repo.rev.empty() && !pManifest->m_sRepository.commitPins.empty()) {
// check commit pins unless a revision is specified
progress.printMessageAbove(std::string{Colors::RESET} + " → Manifest has " + std::to_string(pManifest->m_sRepository.commitPins.size()) + " pins, checking");
@@ -549,52 +661,59 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " commit pin " + plugin + " matched hl, resetting");
execAndGet("cd /tmp/hyprpm/update/ && git reset --hard --recurse-submodules " + plugin);
execAndGet("cd " + m_szWorkingPluginDirectory + " && git reset --hard --recurse-submodules " + plugin);
}
}
bool failed = false;
for (auto& p : pManifest->m_vPlugins) {
std::string out;
if (p.since > HLVER.commits && HLVER.commits >= 1000 /* for shallow clones, we can't check this. 1000 is an arbitrary number I chose. */) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n");
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::RESET} + " → Building " + p.name);
for (auto& bs : p.buildSteps) {
std::string cmd = std::format("cd /tmp/hyprpm/update && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", DataState::getHeadersPath(), bs);
std::string cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
}
if (!std::filesystem::exists("/tmp/hyprpm/update/" + p.output)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Plugin " << p.name << " failed to build.\n";
failed = true;
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
break;
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/" + p.output)) {
std::cerr << "\n"
<< Colors::RED << "" << Colors::RESET << " Plugin " << p.name << " failed to build.\n"
<< " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update first.\n Try "
"re-running with -v to see more verbose "
"output.\n";
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " built " + p.name + " into " + p.output);
}
if (failed)
continue;
// add repo toml to DataState
SPluginRepository newrepo = repo;
newrepo.plugins.clear();
execAndGet(
"cd /tmp/hyprpm/update/ && git pull --recurse-submodules && git reset --hard --recurse-submodules"); // repo hash in the state.toml has to match head and not any pin
std::string repohash = execAndGet("cd /tmp/hyprpm/update && git rev-parse HEAD");
execAndGet("cd " + m_szWorkingPluginDirectory +
" && git pull --recurse-submodules && git reset --hard --recurse-submodules"); // repo hash in the state.toml has to match head and not any pin
std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
if (repohash.length() > 0)
repohash.pop_back();
newrepo.hash = repohash;
for (auto& p : pManifest->m_vPlugins) {
const auto OLDPLUGINIT = std::find_if(repo.plugins.begin(), repo.plugins.end(), [&](const auto& other) { return other.name == p.name; });
newrepo.plugins.push_back(SPlugin{p.name, "/tmp/hyprpm/update/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
newrepo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
}
DataState::removePluginRepo(newrepo.name);
DataState::addNewPluginRepo(newrepo);
std::filesystem::remove_all("/tmp/hyprpm/update");
std::filesystem::remove_all(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " updated " + repo.name);
}
@@ -768,3 +887,13 @@ std::string CPluginManager::headerError(const eHeadersErrors err) {
return std::string{Colors::RED} + "" + Colors::RESET + " Unknown header error. Please run hyprpm update to fix those.\n";
}
bool CPluginManager::hasDeps() {
std::vector<std::string> deps = {"meson", "cpio", "cmake"};
for (auto& d : deps) {
if (!execAndGet("which " + d + " 2>&1").contains("/"))
return false;
}
return true;
}

View File

@@ -32,11 +32,13 @@ enum ePluginLoadStateReturn {
struct SHyprlandVersion {
std::string branch;
std::string hash;
std::string date;
int commits = 0;
};
class CPluginManager {
public:
bool addNewPluginRepo(const std::string& url);
bool addNewPluginRepo(const std::string& url, const std::string& rev);
bool removePluginRepo(const std::string& urlOrName);
eHeadersErrors headersValid();
@@ -54,10 +56,17 @@ class CPluginManager {
void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message);
bool hasDeps();
bool m_bVerbose = false;
// will delete recursively if exists!!
bool createSafeDirectory(const std::string& path);
private:
std::string headerError(const eHeadersErrors err);
std::string m_szWorkingPluginDirectory = "";
};
inline std::unique_ptr<CPluginManager> g_pPluginManager;
inline std::unique_ptr<CPluginManager> g_pPluginManager;

View File

@@ -11,7 +11,8 @@
const std::string HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
add [url] Install a new plugin repository from git
add [url] [git rev] Install a new plugin repository from git. Git revision
is optional, when set, commit locks are ignored.
remove [url/name] Remove an installed plugin repository
enable [name] Enable a plugin
disable [name] Disable a plugin
@@ -55,7 +56,7 @@ int main(int argc, char** argv, char** envp) {
force = true;
std::cout << Colors::RED << "!" << Colors::RESET << " Using --force, I hope you know what you are doing.\n";
} else {
std::cerr << "Unrecognized option " << ARGS[i];
std::cerr << "Unrecognized option " << ARGS[i] << "\n";
return 1;
}
} else {
@@ -77,7 +78,12 @@ int main(int argc, char** argv, char** envp) {
return 1;
}
return g_pPluginManager->addNewPluginRepo(command[1]) ? 0 : 1;
std::string rev = "";
if (command.size() >= 3) {
rev = command[2];
}
return g_pPluginManager->addNewPluginRepo(command[1], rev) ? 0 : 1;
} else if (command[0] == "remove") {
if (ARGS.size() < 2) {
std::cerr << Colors::RED << "" << Colors::RESET << " Not enough args for remove.\n";

View File

@@ -8,3 +8,7 @@ executable('hyprpm', src,
],
install : true
)
install_data('../hyprpm.bash', install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'), install_tag: 'runtime', rename: 'hyprpm')
install_data('../hyprpm.fish', install_dir: join_paths(get_option('datadir'), 'fish/vendor_completions.d'), install_tag: 'runtime')
install_data('../hyprpm.zsh', install_dir: join_paths(get_option('datadir'), 'zsh/site-functions'), install_tag: 'runtime', rename: '_hyprpm')

View File

@@ -5,20 +5,9 @@ project('Hyprland', 'cpp', 'c',
'default_library=static',
'optimization=3',
'buildtype=release',
'debug=false'
# 'cpp_std=c++23' # not yet supported by meson, as of version 0.63.0
])
# clang v14.0.6 uses C++2b instead of C++23, so we've gotta account for that
# replace the following with a project default option once meson gets support for C++23
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.has_argument('-std=c++23')
add_global_arguments('-std=c++23', language: 'cpp')
elif cpp_compiler.has_argument('-std=c++2b')
add_global_arguments('-std=c++2b', language: 'cpp')
else
error('Could not configure current C++ compiler (' + cpp_compiler.get_id() + ' ' + cpp_compiler.version() + ') with required C++ standard (C++23)')
endif
'debug=false',
'cpp_std=c++23',
])
add_project_arguments(
[
@@ -26,16 +15,24 @@ add_project_arguments(
'-Wno-unused-value',
'-Wno-missing-field-initializers',
'-Wno-narrowing',
'-Wno-pointer-arith',
],
language: 'cpp')
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.check_header('execinfo.h')
add_project_arguments('-DHAS_EXECINFO', language: 'cpp')
endif
wlroots = subproject('wlroots', default_options: ['examples=false', 'renderers=gles2'])
wlroots = subproject('wlroots-hyprland', default_options: ['examples=false', 'renderers=gles2'])
have_xwlr = wlroots.get_variable('features').get('xwayland')
xcb_dep = dependency('xcb', required: get_option('xwayland'))
xcb_composite_dep = dependency('xcb-composite', required: get_option('xwayland'))
xcb_errors_dep = dependency('xcb-errors', required: get_option('xwayland'))
xcb_icccm_dep = dependency('xcb-icccm', required: get_option('xwayland'))
xcb_render_dep = dependency('xcb-render', required: get_option('xwayland'))
xcb_res_dep = dependency('xcb-res', required: get_option('xwayland'))
xcb_xfixes_dep = dependency('xcb-xfixes', required: get_option('xwayland'))
cmake = import('cmake')
udis = cmake.subproject('udis86')
@@ -51,14 +48,10 @@ if not have_xwayland
endif
backtrace_dep = cpp_compiler.find_library('execinfo', required: false)
systemd_dep = dependency('libsystemd', required: get_option('systemd'))
epoll_dep = dependency('epoll-shim', required: false) # timerfd on BSDs
if get_option('systemd').enabled()
if systemd_dep.found()
add_project_arguments('-DUSES_SYSTEMD', language: 'cpp')
else
error('Cannot enable systemd in Hyprland: libsystemd was not found')
endif
add_project_arguments('-DUSES_SYSTEMD', language: 'cpp')
endif
if get_option('legacy_renderer').enabled()
@@ -69,7 +62,7 @@ if get_option('buildtype') == 'debug'
add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp')
endif
version_h = run_command('sh', '-c', 'scripts/generateVersion.sh')
version_h = run_command('sh', '-c', 'scripts/generateVersion.sh', check: true)
globber = run_command('find', 'src', '-name', '*.h*', check: true)
headers = globber.stdout().strip().split('\n')
@@ -93,5 +86,5 @@ import('pkgconfig').generate(
url: 'https://github.com/hyprwm/Hyprland',
description: 'Hyprland header files',
install_dir: pkg_install_dir,
subdirs: ['', 'hyprland/protocols', 'hyprland/wlroots'],
subdirs: ['', 'hyprland/protocols', 'hyprland', 'hyprland/wlr'],
)

View File

@@ -2,23 +2,34 @@
lib,
stdenv,
pkg-config,
pkgconf,
makeWrapper,
meson,
cmake,
ninja,
binutils,
cairo,
expat,
fribidi,
git,
hyprland-protocols,
hyprcursor,
hyprlang,
hyprwayland-scanner,
jq,
libGL,
libdatrie,
libdrm,
libexecinfo,
libinput,
libxcb,
libselinux,
libsepol,
libthai,
libuuid,
libxkbcommon,
mesa,
pango,
pciutils,
pcre2,
python3,
systemd,
tomlplusplus,
udis86,
@@ -26,7 +37,7 @@
wayland-protocols,
wayland-scanner,
wlroots,
xcbutilwm,
xorg,
xwayland,
debug ? false,
enableXWayland ? true,
@@ -56,13 +67,31 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov
src = lib.cleanSource ../.;
};
nativeBuildInputs = [
jq
meson
ninja
pkg-config
makeWrapper
wayland-scanner
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
# Remove extra @PREFIX@ to fix pkg-config paths
sed -i "s#@PREFIX@/##g" hyprland.pc.in
'';
DATE = date;
HASH = commit;
DIRTY = if commit == "" then "dirty" else "";
nativeBuildInputs = lib.concatLists [
[
hyprwayland-scanner
jq
makeWrapper
cmake
ninja
pkg-config
python3
wayland-scanner
]
# introduce this later so that cmake takes precedence
wlroots.nativeBuildInputs
];
outputs = [
@@ -71,73 +100,62 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov
"dev"
];
buildInputs =
buildInputs = lib.concatLists [
wlroots.buildInputs
udis86.buildInputs
[
cairo
expat
fribidi
git
hyprland-protocols
hyprcursor.dev
hyprlang
libdrm
libGL
libdrm
libdatrie
libinput
libselinux
libsepol
libthai
libuuid
libxkbcommon
mesa
pango
pciutils
pcre2
tomlplusplus
udis86
wayland
wayland-protocols
wlroots
]
++ lib.optionals enableXWayland [libxcb xcbutilwm xwayland]
++ lib.optionals withSystemd [systemd];
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
];
mesonBuildType =
cmakeBuildType =
if debug
then "debug"
else "release";
then "Debug"
else "RelWithDebInfo";
mesonAutoFeatures = "disabled";
mesonFlags = builtins.concatLists [
(lib.optional enableXWayland "-Dxwayland=enabled")
(lib.optional legacyRenderer "-Dlegacy_renderer=enabled")
(lib.optional withSystemd "-Dsystemd=enabled")
cmakeFlags = [
(lib.cmakeBool "NO_XWAYLAND" (!enableXWayland))
(lib.cmakeBool "LEGACY_RENDERER" legacyRenderer)
(lib.cmakeBool "NO_SYSTEMD" (!withSystemd))
];
patches = [
# make meson use the provided wlroots instead of the git submodule
./patches/meson-build.patch
];
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
# Generate version.h
cp src/version.h.in src/version.h
substituteInPlace src/version.h \
--replace "@HASH@" '${commit}' \
--replace "@BRANCH@" "" \
--replace "@MESSAGE@" "" \
--replace "@DATE@" "${date}" \
--replace "@TAG@" "" \
--replace "@DIRTY@" '${
if commit == ""
then "dirty"
else ""
}'
'';
postInstall = ''
ln -s ${wlroots}/include/wlr $dev/include/hyprland/wlroots
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [
stdenv.cc
binutils
pciutils
pkgconf
]}
''}
'';
@@ -145,10 +163,10 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov
passthru.providedSessions = ["hyprland"];
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
homepage = "https://github.com/hyprwm/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
platforms = wlroots.meta.platforms;
mainProgram = "Hyprland";
};
}

View File

@@ -21,10 +21,11 @@ in {
# Packages for variations of Hyprland, dependencies included.
hyprland-packages = lib.composeManyExtensions [
# Dependencies
inputs.hyprland-protocols.overlays.default
inputs.hyprcursor.overlays.default
inputs.hyprlang.overlays.default
self.overlays.wlroots-hyprland
self.overlays.udis86
inputs.hyprwayland-scanner.overlays.default
self.overlays.xwayland
# Hyprland packages themselves
(final: prev: let
date = mkDate (self.lastModifiedDate or "19700101");
@@ -33,19 +34,20 @@ in {
stdenv = final.gcc13Stdenv;
version = "${props.version}+date=${date}_${self.shortRev or "dirty"}";
commit = self.rev or "";
wlroots = final.wlroots-hyprland; # explicit override until decided on breaking change of the name
udis86 = final.udis86-hyprland; # explicit override until decided on breaking change of the name
inherit date;
};
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprland-debug = final.hyprland.override {debug = true;};
hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;};
# deprecated packages
hyprland-nvidia =
builtins.trace ''
hyprland-nvidia was removed. Please use the hyprland package.
Nvidia patches are no longer needed.
''
final.hyprland;
hyprland-hidpi =
builtins.trace ''
hyprland-hidpi was removed. Please use the hyprland package.
@@ -61,17 +63,13 @@ in {
inputs.xdph.overlays.xdg-desktop-portal-hyprland
];
udis86 = final: prev: {
udis86-hyprland = 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"}";
src = inputs.wlroots;
};
# Patches XWayland's pkgconfig file to not include Cflags or includedir
# The above two variables trip up CMake and the build fails
xwayland = final: prev: {
xwayland = prev.xwayland.overrideAttrs (old: {
postInstall = ''
sed -i '/includedir/d' $out/lib/pkgconfig/xwayland.pc
'';
});
};
}

View File

@@ -1,60 +0,0 @@
diff --git a/meson.build b/meson.build
index 1d2c7f9f..c5ef4e67 100644
--- a/meson.build
+++ b/meson.build
@@ -33,20 +33,7 @@ if cpp_compiler.check_header('execinfo.h')
add_project_arguments('-DHAS_EXECINFO', language: 'cpp')
endif
-wlroots = subproject('wlroots', default_options: ['examples=false', 'renderers=gles2'])
-have_xwlr = wlroots.get_variable('features').get('xwayland')
-xcb_dep = dependency('xcb', required: get_option('xwayland'))
-
-cmake = import('cmake')
-udis = cmake.subproject('udis86')
-udis86 = udis.dependency('libudis86')
-
-if get_option('xwayland').enabled() and not have_xwlr
- error('Cannot enable Xwayland in Hyprland: wlroots has been built without Xwayland support')
-endif
-have_xwayland = xcb_dep.found() and have_xwlr
-
-if not have_xwayland
+if get_option('xwayland').disabled()
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
endif
@@ -69,8 +56,6 @@ if get_option('buildtype') == 'debug'
add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp')
endif
-version_h = run_command('sh', '-c', 'scripts/generateVersion.sh')
-
globber = run_command('find', 'src', '-name', '*.h*', check: true)
headers = globber.stdout().strip().split('\n')
foreach file : headers
diff --git a/src/meson.build b/src/meson.build
index 45701f5f..3505cefe 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -9,17 +9,17 @@ executable('Hyprland', src,
server_protos,
dependency('wayland-server'),
dependency('wayland-client'),
- wlroots.get_variable('wlroots'),
+ dependency('wlroots'),
dependency('cairo'),
dependency('hyprlang', version: '>= 0.3.2'),
dependency('libdrm'),
dependency('egl'),
dependency('xkbcommon'),
dependency('libinput'),
- xcb_dep,
+ dependency('xcb', required: get_option('xwayland')),
backtrace_dep,
systemd_dep,
- udis86,
+ dependency('udis86'),
dependency('pixman-1'),
dependency('gl', 'opengl'),

View File

@@ -1,32 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
python3,
}:
stdenv.mkDerivation {
pname = "udis86";
version = "unstable-2022-10-13";
src = fetchFromGitHub {
owner = "canihavesomecoffee";
repo = "udis86";
rev = "5336633af70f3917760a6d441ff02d93477b0c86";
hash = "sha256-HifdUQPGsKQKQprByeIznvRLONdOXeolOsU5nkwIv3g=";
};
nativeBuildInputs = [autoreconfHook python3];
configureFlags = ["--enable-shared"];
outputs = ["bin" "out" "dev" "lib"];
meta = with lib; {
homepage = "https://udis86.sourceforge.net";
license = licenses.bsd2;
mainProgram = "udcli";
description = "Easy-to-use, minimalistic x86 disassembler library (libudis86)";
platforms = platforms.all;
};
}

View File

@@ -1,13 +0,0 @@
{
version,
src,
wlroots,
enableXWayland ? true,
}:
wlroots.overrideAttrs (old: {
inherit version src enableXWayland;
pname = "${old.pname}-hyprland";
patches = [ ]; # don't inherit old.patches
})

View File

@@ -1,3 +1,3 @@
{
"version": "0.36.0"
"version": "0.41.0"
}

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="idle">
<copyright><![CDATA[
Copyright (C) 2015 Martin Gräßlin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]></copyright>
<interface name="org_kde_kwin_idle" version="1">
<description summary="User idle time manager">
This interface allows to monitor user idle time on a given seat. The interface
allows to register timers which trigger after no user activity was registered
on the seat for a given interval. It notifies when user activity resumes.
This is useful for applications wanting to perform actions when the user is not
interacting with the system, e.g. chat applications setting the user as away, power
management features to dim screen, etc..
</description>
<request name="get_idle_timeout">
<arg name="id" type="new_id" interface="org_kde_kwin_idle_timeout"/>
<arg name="seat" type="object" interface="wl_seat"/>
<arg name="timeout" type="uint" summary="The idle timeout in msec"/>
</request>
</interface>
<interface name="org_kde_kwin_idle_timeout" version="1">
<request name="release" type="destructor">
<description summary="release the timeout object"/>
</request>
<request name="simulate_user_activity">
<description summary="Simulates user activity for this timeout, behaves just like real user activity on the seat"/>
</request>
<event name="idle">
<description summary="Triggered when there has not been any user activity in the requested idle time interval"/>
</event>
<event name="resumed">
<description summary="Triggered on the first user activity after an idle event"/>
</event>
</interface>
</protocol>

View File

@@ -0,0 +1,494 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="input_method_unstable_v2">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2011 Intel Corporation
Copyright © 2012-2013 Collabora, Ltd.
Copyright © 2012, 2013 Intel Corporation
Copyright © 2015, 2016 Jan Arne Petersen
Copyright © 2017, 2018 Red Hat, Inc.
Copyright © 2018 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Protocol for creating input methods">
This protocol allows applications to act as input methods for compositors.
An input method context is used to manage the state of the input method.
Text strings are UTF-8 encoded, their indices and lengths are in bytes.
This document adheres to the RFC 2119 when using words like "must",
"should", "may", etc.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwp_input_method_v2" version="1">
<description summary="input method">
An input method object allows for clients to compose text.
The objects connects the client to a text input in an application, and
lets the client to serve as an input method for a seat.
The zwp_input_method_v2 object can occupy two distinct states: active and
inactive. In the active state, the object is associated to and
communicates with a text input. In the inactive state, there is no
associated text input, and the only communication is with the compositor.
Initially, the input method is in the inactive state.
Requests issued in the inactive state must be accepted by the compositor.
Because of the serial mechanism, and the state reset on activate event,
they will not have any effect on the state of the next text input.
There must be no more than one input method object per seat.
</description>
<enum name="error">
<entry name="role" value="0" summary="wl_surface has another role"/>
</enum>
<event name="activate">
<description summary="input method has been requested">
Notification that a text input focused on this seat requested the input
method to be activated.
This event serves the purpose of providing the compositor with an
active input method.
This event resets all state associated with previous enable, disable,
surrounding_text, text_change_cause, and content_type events, as well
as the state associated with set_preedit_string, commit_string, and
delete_surrounding_text requests. In addition, it marks the
zwp_input_method_v2 object as active, and makes any existing
zwp_input_popup_surface_v2 objects visible.
The surrounding_text, and content_type events must follow before the
next done event if the text input supports the respective
functionality.
State set with this event is double-buffered. It will get applied on
the next zwp_input_method_v2.done event, and stay valid until changed.
</description>
</event>
<event name="deactivate">
<description summary="deactivate event">
Notification that no focused text input currently needs an active
input method on this seat.
This event marks the zwp_input_method_v2 object as inactive. The
compositor must make all existing zwp_input_popup_surface_v2 objects
invisible until the next activate event.
State set with this event is double-buffered. It will get applied on
the next zwp_input_method_v2.done event, and stay valid until changed.
</description>
</event>
<event name="surrounding_text">
<description summary="surrounding text event">
Updates the surrounding plain text around the cursor, excluding the
preedit text.
If any preedit text is present, it is replaced with the cursor for the
purpose of this event.
The argument text is a buffer containing the preedit string, and must
include the cursor position, and the complete selection. It should
contain additional characters before and after these. There is a
maximum length of wayland messages, so text can not be longer than 4000
bytes.
cursor is the byte offset of the cursor within the text buffer.
anchor is the byte offset of the selection anchor within the text
buffer. If there is no selected text, anchor must be the same as
cursor.
If this event does not arrive before the first done event, the input
method may assume that the text input does not support this
functionality and ignore following surrounding_text events.
Values set with this event are double-buffered. They will get applied
and set to initial values on the next zwp_input_method_v2.done
event.
The initial state for affected fields is empty, meaning that the text
input does not support sending surrounding text. If the empty values
get applied, subsequent attempts to change them may have no effect.
</description>
<arg name="text" type="string"/>
<arg name="cursor" type="uint"/>
<arg name="anchor" type="uint"/>
</event>
<event name="text_change_cause">
<description summary="indicates the cause of surrounding text change">
Tells the input method why the text surrounding the cursor changed.
Whenever the client detects an external change in text, cursor, or
anchor position, it must issue this request to the compositor. This
request is intended to give the input method a chance to update the
preedit text in an appropriate way, e.g. by removing it when the user
starts typing with a keyboard.
cause describes the source of the change.
The value set with this event is double-buffered. It will get applied
and set to its initial value on the next zwp_input_method_v2.done
event.
The initial value of cause is input_method.
</description>
<arg name="cause" type="uint" enum="zwp_text_input_v3.change_cause"/>
</event>
<event name="content_type">
<description summary="content purpose and hint">
Indicates the content type and hint for the current
zwp_input_method_v2 instance.
Values set with this event are double-buffered. They will get applied
on the next zwp_input_method_v2.done event.
The initial value for hint is none, and the initial value for purpose
is normal.
</description>
<arg name="hint" type="uint" enum="zwp_text_input_v3.content_hint"/>
<arg name="purpose" type="uint" enum="zwp_text_input_v3.content_purpose"/>
</event>
<event name="done">
<description summary="apply state">
Atomically applies state changes recently sent to the client.
The done event establishes and updates the state of the client, and
must be issued after any changes to apply them.
Text input state (content purpose, content hint, surrounding text, and
change cause) is conceptually double-buffered within an input method
context.
Events modify the pending state, as opposed to the current state in use
by the input method. A done event atomically applies all pending state,
replacing the current state. After done, the new pending state is as
documented for each related request.
Events must be applied in the order of arrival.
Neither current nor pending state are modified unless noted otherwise.
</description>
</event>
<request name="commit_string">
<description summary="commit string">
Send the commit string text for insertion to the application.
Inserts a string at current cursor position (see commit event
sequence). The string to commit could be either just a single character
after a key press or the result of some composing.
The argument text is a buffer containing the string to insert. There is
a maximum length of wayland messages, so text can not be longer than
4000 bytes.
Values set with this event are double-buffered. They must be applied
and reset to initial on the next zwp_text_input_v3.commit request.
The initial value of text is an empty string.
</description>
<arg name="text" type="string"/>
</request>
<request name="set_preedit_string">
<description summary="pre-edit string">
Send the pre-edit string text to the application text input.
Place a new composing text (pre-edit) at the current cursor position.
Any previously set composing text must be removed. Any previously
existing selected text must be removed. The cursor is moved to a new
position within the preedit string.
The argument text is a buffer containing the preedit string. There is
a maximum length of wayland messages, so text can not be longer than
4000 bytes.
The arguments cursor_begin and cursor_end are counted in bytes relative
to the beginning of the submitted string buffer. Cursor should be
hidden by the text input when both are equal to -1.
cursor_begin indicates the beginning of the cursor. cursor_end
indicates the end of the cursor. It may be equal or different than
cursor_begin.
Values set with this event are double-buffered. They must be applied on
the next zwp_input_method_v2.commit event.
The initial value of text is an empty string. The initial value of
cursor_begin, and cursor_end are both 0.
</description>
<arg name="text" type="string"/>
<arg name="cursor_begin" type="int"/>
<arg name="cursor_end" type="int"/>
</request>
<request name="delete_surrounding_text">
<description summary="delete text">
Remove the surrounding text.
before_length and after_length are the number of bytes before and after
the current cursor index (excluding the preedit text) to delete.
If any preedit text is present, it is replaced with the cursor for the
purpose of this event. In effect before_length is counted from the
beginning of preedit text, and after_length from its end (see commit
event sequence).
Values set with this event are double-buffered. They must be applied
and reset to initial on the next zwp_input_method_v2.commit request.
The initial values of both before_length and after_length are 0.
</description>
<arg name="before_length" type="uint"/>
<arg name="after_length" type="uint"/>
</request>
<request name="commit">
<description summary="apply state">
Apply state changes from commit_string, set_preedit_string and
delete_surrounding_text requests.
The state relating to these events is double-buffered, and each one
modifies the pending state. This request replaces the current state
with the pending state.
The connected text input is expected to proceed by evaluating the
changes in the following order:
1. Replace existing preedit string with the cursor.
2. Delete requested surrounding text.
3. Insert commit string with the cursor at its end.
4. Calculate surrounding text to send.
5. Insert new preedit text in cursor position.
6. Place cursor inside preedit text.
The serial number reflects the last state of the zwp_input_method_v2
object known to the client. The value of the serial argument must be
equal to the number of done events already issued by that object. When
the compositor receives a commit request with a serial different than
the number of past done events, it must proceed as normal, except it
should not change the current state of the zwp_input_method_v2 object.
</description>
<arg name="serial" type="uint"/>
</request>
<request name="get_input_popup_surface">
<description summary="create popup surface">
Creates a new zwp_input_popup_surface_v2 object wrapping a given
surface.
The surface gets assigned the "input_popup" role. If the surface
already has an assigned role, the compositor must issue a protocol
error.
</description>
<arg name="id" type="new_id" interface="zwp_input_popup_surface_v2"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="grab_keyboard">
<description summary="grab hardware keyboard">
Allow an input method to receive hardware keyboard input and process
key events to generate text events (with pre-edit) over the wire. This
allows input methods which compose multiple key events for inputting
text like it is done for CJK languages.
The compositor should send all keyboard events on the seat to the grab
holder via the returned wl_keyboard object. Nevertheless, the
compositor may decide not to forward any particular event. The
compositor must not further process any event after it has been
forwarded to the grab holder.
Releasing the resulting wl_keyboard object releases the grab.
</description>
<arg name="keyboard" type="new_id"
interface="zwp_input_method_keyboard_grab_v2"/>
</request>
<event name="unavailable">
<description summary="input method unavailable">
The input method ceased to be available.
The compositor must issue this event as the only event on the object if
there was another input_method object associated with the same seat at
the time of its creation.
The compositor must issue this request when the object is no longer
usable, e.g. due to seat removal.
The input method context becomes inert and should be destroyed after
deactivation is handled. Any further requests and events except for the
destroy request must be ignored.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy the text input">
Destroys the zwp_text_input_v2 object and any associated child
objects, i.e. zwp_input_popup_surface_v2 and
zwp_input_method_keyboard_grab_v2.
</description>
</request>
</interface>
<interface name="zwp_input_popup_surface_v2" version="1">
<description summary="popup surface">
This interface marks a surface as a popup for interacting with an input
method.
The compositor should place it near the active text input area. It must
be visible if and only if the input method is in the active state.
The client must not destroy the underlying wl_surface while the
zwp_input_popup_surface_v2 object exists.
</description>
<event name="text_input_rectangle">
<description summary="set text input area position">
Notify about the position of the area of the text input expressed as a
rectangle in surface local coordinates.
This is a hint to the input method telling it the relative position of
the text being entered.
</description>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>
<request name="destroy" type="destructor"/>
</interface>
<interface name="zwp_input_method_keyboard_grab_v2" version="1">
<!-- Closely follows wl_keyboard version 6 -->
<description summary="keyboard grab">
The zwp_input_method_keyboard_grab_v2 interface represents an exclusive
grab of the wl_keyboard interface associated with the seat.
</description>
<event name="keymap">
<description summary="keyboard mapping">
This event provides a file descriptor to the client which can be
memory-mapped to provide a keyboard mapping description.
</description>
<arg name="format" type="uint" enum="wl_keyboard.keymap_format"
summary="keymap format"/>
<arg name="fd" type="fd" summary="keymap file descriptor"/>
<arg name="size" type="uint" summary="keymap size, in bytes"/>
</event>
<event name="key">
<description summary="key event">
A key was pressed or released.
The time argument is a timestamp with millisecond granularity, with an
undefined base.
</description>
<arg name="serial" type="uint" summary="serial number of the key event"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="key" type="uint" summary="key that produced the event"/>
<arg name="state" type="uint" enum="wl_keyboard.key_state"
summary="physical state of the key"/>
</event>
<event name="modifiers">
<description summary="modifier and group state">
Notifies clients that the modifier and/or group state has changed, and
it should update its local state.
</description>
<arg name="serial" type="uint" summary="serial number of the modifiers event"/>
<arg name="mods_depressed" type="uint" summary="depressed modifiers"/>
<arg name="mods_latched" type="uint" summary="latched modifiers"/>
<arg name="mods_locked" type="uint" summary="locked modifiers"/>
<arg name="group" type="uint" summary="keyboard layout"/>
</event>
<request name="release" type="destructor">
<description summary="release the grab object"/>
</request>
<event name="repeat_info">
<description summary="repeat rate and delay">
Informs the client about the keyboard's repeat rate and delay.
This event is sent as soon as the zwp_input_method_keyboard_grab_v2
object has been created, and is guaranteed to be received by the
client before any key press event.
Negative values for either rate or delay are illegal. A rate of zero
will disable any repeating (regardless of the value of delay).
This event can be sent later on as well with a new value if necessary,
so clients should continue listening for the event past the creation
of zwp_input_method_keyboard_grab_v2.
</description>
<arg name="rate" type="int"
summary="the rate of repeating keys in characters per second"/>
<arg name="delay" type="int"
summary="delay in milliseconds since key down until repeating starts"/>
</event>
</interface>
<interface name="zwp_input_method_manager_v2" version="1">
<description summary="input method manager">
The input method manager allows the client to become the input method on
a chosen seat.
No more than one input method must be associated with any seat at any
given time.
</description>
<request name="get_input_method">
<description summary="request an input method object">
Request a new input zwp_input_method_v2 object associated with a given
seat.
</description>
<arg name="seat" type="object" interface="wl_seat"/>
<arg name="input_method" type="new_id" interface="zwp_input_method_v2"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the input method manager">
Destroys the zwp_input_method_manager_v2 object.
The zwp_input_method_v2 objects originating from it remain valid.
</description>
</request>
</interface>
</protocol>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="server_decoration">
<copyright><![CDATA[
SPDX-FileCopyrightText: 2015 Martin Gräßlin
SPDX-License-Identifier: LGPL-2.1-or-later
]]></copyright>
<interface name="org_kde_kwin_server_decoration_manager" version="1">
<description summary="Server side window decoration manager">
This interface allows to coordinate whether the server should create
a server-side window decoration around a wl_surface representing a
shell surface (wl_shell_surface or similar). By announcing support
for this interface the server indicates that it supports server
side decorations.
Use in conjunction with zxdg_decoration_manager_v1 is undefined.
</description>
<request name="create">
<description summary="Create a server-side decoration object for a given surface">
When a client creates a server-side decoration object it indicates
that it supports the protocol. The client is supposed to tell the
server whether it wants server-side decorations or will provide
client-side decorations.
If the client does not create a server-side decoration object for
a surface the server interprets this as lack of support for this
protocol and considers it as client-side decorated. Nevertheless a
client-side decorated surface should use this protocol to indicate
to the server that it does not want a server-side deco.
</description>
<arg name="id" type="new_id" interface="org_kde_kwin_server_decoration"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<enum name="mode">
<description summary="Possible values to use in request_mode and the event mode."/>
<entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
<entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
<entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
</enum>
<event name="default_mode">
<description summary="The default mode used on the server">
This event is emitted directly after binding the interface. It contains
the default mode for the decoration. When a new server decoration object
is created this new object will be in the default mode until the first
request_mode is requested.
The server may change the default mode at any time.
</description>
<arg name="mode" type="uint" summary="The default decoration mode applied to newly created server decorations."/>
</event>
</interface>
<interface name="org_kde_kwin_server_decoration" version="1">
<request name="release" type="destructor">
<description summary="release the server decoration object"/>
</request>
<enum name="mode">
<description summary="Possible values to use in request_mode and the event mode."/>
<entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
<entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
<entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
</enum>
<request name="request_mode">
<description summary="The decoration mode the surface wants to use."/>
<arg name="mode" type="uint" summary="The mode this surface wants to use."/>
</request>
<event name="mode">
<description summary="The new decoration mode applied by the server">
This event is emitted directly after the decoration is created and
represents the base decoration policy by the server. E.g. a server
which wants all surfaces to be client-side decorated will send Client,
a server which wants server-side decoration will send Server.
The client can request a different mode through the decoration request.
The server will acknowledge this by another event with the same mode. So
even if a server prefers server-side decoration it's possible to force a
client-side decoration.
The server may emit this event at any time. In this case the client can
again request a different mode. It's the responsibility of the server to
prevent a feedback loop.
</description>
<arg name="mode" type="uint" summary="The decoration mode applied to the surface by the server."/>
</event>
</interface>
</protocol>

View File

@@ -17,27 +17,60 @@ wayland_scanner = find_program(
wayland_scanner_dep.get_variable('wayland_scanner'),
native: true,
)
hyprwayland_scanner_dep = dependency('hyprwayland-scanner', version: '>=0.3.8', native: true)
hyprwayland_scanner = find_program(
hyprwayland_scanner_dep.get_variable('hyprwayland_scanner'),
native: true,
)
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'],
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],
['wlr-screencopy-unstable-v1.xml'],
['pointer-constraints-unstable-v1.xml'],
['tablet-unstable-v2.xml'],
['idle.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
]
new_protocols = [
['wlr-gamma-control-unstable-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],
['input-method-unstable-v2.xml'],
['virtual-keyboard-unstable-v1.xml'],
['wlr-virtual-pointer-unstable-v1.xml'],
['wlr-output-management-unstable-v1.xml'],
['kde-server-decoration.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wayland-drm.xml'],
['wlr-data-control-unstable-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-focus-grab-v1.xml'],
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/relative-pointer/relative-pointer-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'],
[wl_protocol_dir, 'staging/alpha-modifier/alpha-modifier-v1.xml'],
[wl_protocol_dir, 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml'],
[wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v3.xml'],
[wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'],
[wl_protocol_dir, 'staging/xdg-activation/xdg-activation-v1.xml'],
[wl_protocol_dir, 'staging/ext-idle-notify/ext-idle-notify-v1.xml'],
[wl_protocol_dir, 'staging/ext-session-lock/ext-session-lock-v1.xml'],
[wl_protocol_dir, 'stable/tablet/tablet-v2.xml'],
[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'],
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/primary-selection/primary-selection-unstable-v1.xml'],
[wl_protocol_dir, 'staging/xwayland-shell/xwayland-shell-v1.xml'],
[wl_protocol_dir, 'stable/viewporter/viewporter.xml'],
[wl_protocol_dir, 'stable/linux-dmabuf/linux-dmabuf-v1.xml'],
]
wl_protos_src = []
wl_protos_headers = []
foreach p : protocols
xml = join_paths(p)
wl_protos_src += custom_target(
@@ -56,15 +89,43 @@ foreach p : protocols
)
endforeach
wayland_server = dependency('wayland-server', version: '>=1.20.0')
new_wl_protos = []
foreach p : new_protocols
xml = join_paths(p)
new_wl_protos += custom_target(
xml.underscorify(),
input: xml,
install: true,
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
command: [hyprwayland_scanner, '@INPUT@', '@OUTDIR@'],
)
endforeach
wayland_server_dep = dependency('wayland-server', version: '>=1.20.0')
wayland_server_dir = wayland_server_dep.get_variable('pkgdatadir')
wl_server_protos = [
wayland_server_dir / 'wayland.xml'
]
wl_server_protos_gen = []
foreach p : wl_server_protos
wl_server_protos_gen += custom_target(
p.underscorify(),
input: p,
install: false,
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
command: [hyprwayland_scanner, '--wayland-enums', '@INPUT@', '@OUTDIR@'],
)
endforeach
lib_server_protos = static_library(
'server_protos',
wl_protos_src + wl_protos_headers,
dependencies: wayland_server.partial_dependency(compile_args: true),
wl_protos_src + wl_protos_headers + new_wl_protos + wl_server_protos_gen,
dependencies: wayland_server_dep.partial_dependency(compile_args: true),
)
server_protos = declare_dependency(
link_with: lib_server_protos,
sources: wl_protos_headers,
sources: wl_protos_headers + new_wl_protos,
)

View File

@@ -1,339 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="pointer_constraints_unstable_v1">
<copyright>
Copyright © 2014 Jonas Ådahl
Copyright © 2015 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="protocol for constraining pointer motions">
This protocol specifies a set of interfaces used for adding constraints to
the motion of a pointer. Possible constraints include confining pointer
motions to a given region, or locking it to its current position.
In order to constrain the pointer, a client must first bind the global
interface "wp_pointer_constraints" which, if a compositor supports pointer
constraints, is exposed by the registry. Using the bound global object, the
client uses the request that corresponds to the type of constraint it wants
to make. See wp_pointer_constraints for more details.
Warning! The protocol described in this file is experimental and backward
incompatible changes may be made. Backward compatible changes may be added
together with the corresponding interface version bump. Backward
incompatible changes are done by bumping the version number in the protocol
and interface names and resetting the interface version. Once the protocol
is to be declared stable, the 'z' prefix and the version number in the
protocol and interface names are removed and the interface version number is
reset.
</description>
<interface name="zwp_pointer_constraints_v1" version="1">
<description summary="constrain the movement of a pointer">
The global interface exposing pointer constraining functionality. It
exposes two requests: lock_pointer for locking the pointer to its
position, and confine_pointer for locking the pointer to a region.
The lock_pointer and confine_pointer requests create the objects
wp_locked_pointer and wp_confined_pointer respectively, and the client can
use these objects to interact with the lock.
For any surface, only one lock or confinement may be active across all
wl_pointer objects of the same seat. If a lock or confinement is requested
when another lock or confinement is active or requested on the same surface
and with any of the wl_pointer objects of the same seat, an
'already_constrained' error will be raised.
</description>
<enum name="error">
<description summary="wp_pointer_constraints error values">
These errors can be emitted in response to wp_pointer_constraints
requests.
</description>
<entry name="already_constrained" value="1"
summary="pointer constraint already requested on that surface"/>
</enum>
<enum name="lifetime">
<description summary="constraint lifetime">
These values represent different lifetime semantics. They are passed
as arguments to the factory requests to specify how the constraint
lifetimes should be managed.
</description>
<entry name="oneshot" value="1">
<description summary="the pointer constraint is defunct once deactivated">
A oneshot pointer constraint will never reactivate once it has been
deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
<entry name="persistent" value="2">
<description summary="the pointer constraint may reactivate">
A persistent pointer constraint may again reactivate once it has
been deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the pointer constraints manager object">
Used by the client to notify the server that it will no longer use this
pointer constraints object.
</description>
</request>
<request name="lock_pointer">
<description summary="lock pointer to a position">
The lock_pointer request lets the client request to disable movements of
the virtual pointer (i.e. the cursor), effectively locking the pointer
to a position. This request may not take effect immediately; in the
future, when the compositor deems implementation-specific constraints
are satisfied, the pointer lock will be activated and the compositor
sends a locked event.
The protocol provides no guarantee that the constraints are ever
satisfied, and does not require the compositor to send an error if the
constraints cannot ever be satisfied. It is thus possible to request a
lock that will never activate.
There may not be another pointer constraint of any kind requested or
active on the surface for any of the wl_pointer objects of the seat of
the passed pointer when requesting a lock. If there is, an error will be
raised. See general pointer lock documentation for more details.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the lock to activate. It is up to the compositor whether to
warp the pointer or require some kind of user interaction for the lock
to activate. If the region is null the surface input region is used.
A surface may receive pointer focus without the lock being activated.
The request creates a new object wp_locked_pointer which is used to
interact with the lock as well as receive updates about its state. See
the the description of wp_locked_pointer for further information.
Note that while a pointer is locked, the wl_pointer objects of the
corresponding seat will not emit any wl_pointer.motion events, but
relative motion events will still be emitted via wp_relative_pointer
objects of the same seat. wl_pointer.axis and wl_pointer.button events
are unaffected.
</description>
<arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be locked"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="lock lifetime"/>
</request>
<request name="confine_pointer">
<description summary="confine pointer to a region">
The confine_pointer request lets the client request to confine the
pointer cursor to a given region. This request may not take effect
immediately; in the future, when the compositor deems implementation-
specific constraints are satisfied, the pointer confinement will be
activated and the compositor sends a confined event.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the confinement to activate. It is up to the compositor
whether to warp the pointer or require some kind of user interaction for
the confinement to activate. If the region is null the surface input
region is used.
The request will create a new object wp_confined_pointer which is used
to interact with the confinement as well as receive updates about its
state. See the the description of wp_confined_pointer for further
information.
</description>
<arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be confined"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="confinement lifetime"/>
</request>
</interface>
<interface name="zwp_locked_pointer_v1" version="1">
<description summary="receive relative pointer motion events">
The wp_locked_pointer interface represents a locked pointer state.
While the lock of this object is active, the wl_pointer objects of the
associated seat will not emit any wl_pointer.motion events.
This object will send the event 'locked' when the lock is activated.
Whenever the lock is activated, it is guaranteed that the locked surface
will already have received pointer focus and that the pointer will be
within the region passed to the request creating this object.
To unlock the pointer, send the destroy request. This will also destroy
the wp_locked_pointer object.
If the compositor decides to unlock the pointer the unlocked event is
sent. See wp_locked_pointer.unlock for details.
When unlocking, the compositor may warp the cursor position to the set
cursor position hint. If it does, it will not result in any relative
motion events emitted via wp_relative_pointer.
If the surface the lock was requested on is destroyed and the lock is not
yet activated, the wp_locked_pointer object is now defunct and must be
destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the locked pointer object">
Destroy the locked pointer object. If applicable, the compositor will
unlock the pointer.
</description>
</request>
<request name="set_cursor_position_hint">
<description summary="set the pointer cursor position hint">
Set the cursor position hint relative to the top left corner of the
surface.
If the client is drawing its own cursor, it should update the position
hint to the position of its own cursor. A compositor may use this
information to warp the pointer upon unlock in order to avoid pointer
jumps.
The cursor position hint is double buffered. The new hint will only take
effect when the associated surface gets it pending state applied. See
wl_surface.commit for details.
</description>
<arg name="surface_x" type="fixed"
summary="surface-local x coordinate"/>
<arg name="surface_y" type="fixed"
summary="surface-local y coordinate"/>
</request>
<request name="set_region">
<description summary="set a new lock region">
Set a new region used to lock the pointer.
The new lock region is double-buffered. The new lock region will
only take effect when the associated surface gets its pending state
applied. See wl_surface.commit for details.
For details about the lock region, see wp_locked_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="locked">
<description summary="lock activation event">
Notification that the pointer lock of the seat's pointer is activated.
</description>
</event>
<event name="unlocked">
<description summary="lock deactivation event">
Notification that the pointer lock of the seat's pointer is no longer
active. If this is a oneshot pointer lock (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer lock (see
wp_pointer_constraints.lifetime) this pointer lock may again
reactivate in the future.
</description>
</event>
</interface>
<interface name="zwp_confined_pointer_v1" version="1">
<description summary="confined pointer object">
The wp_confined_pointer interface represents a confined pointer state.
This object will send the event 'confined' when the confinement is
activated. Whenever the confinement is activated, it is guaranteed that
the surface the pointer is confined to will already have received pointer
focus and that the pointer will be within the region passed to the request
creating this object. It is up to the compositor to decide whether this
requires some user interaction and if the pointer will warp to within the
passed region if outside.
To unconfine the pointer, send the destroy request. This will also destroy
the wp_confined_pointer object.
If the compositor decides to unconfine the pointer the unconfined event is
sent. The wp_confined_pointer object is at this point defunct and should
be destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the confined pointer object">
Destroy the confined pointer object. If applicable, the compositor will
unconfine the pointer.
</description>
</request>
<request name="set_region">
<description summary="set a new confine region">
Set a new region used to confine the pointer.
The new confine region is double-buffered. The new confine region will
only take effect when the associated surface gets its pending state
applied. See wl_surface.commit for details.
If the confinement is active when the new confinement region is applied
and the pointer ends up outside of newly applied region, the pointer may
warped to a position within the new confinement region. If warped, a
wl_pointer.motion event will be emitted, but no
wp_relative_pointer.relative_motion event.
The compositor may also, instead of using the new region, unconfine the
pointer.
For details about the confine region, see wp_confined_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="confined">
<description summary="pointer confined">
Notification that the pointer confinement of the seat's pointer is
activated.
</description>
</event>
<event name="unconfined">
<description summary="pointer unconfined">
Notification that the pointer confinement of the seat's pointer is no
longer active. If this is a oneshot pointer confinement (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer confinement (see
wp_pointer_constraints.lifetime) this pointer confinement may again
reactivate in the future.
</description>
</event>
</interface>
</protocol>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="virtual_keyboard_unstable_v1">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2013 Intel Corporation
Copyright © 2012-2013 Collabora, Ltd.
Copyright © 2018 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwp_virtual_keyboard_v1" version="1">
<description summary="virtual keyboard">
The virtual keyboard provides an application with requests which emulate
the behaviour of a physical keyboard.
This interface can be used by clients on its own to provide raw input
events, or it can accompany the input method protocol.
</description>
<request name="keymap">
<description summary="keyboard mapping">
Provide a file descriptor to the compositor which can be
memory-mapped to provide a keyboard mapping description.
Format carries a value from the keymap_format enumeration.
</description>
<arg name="format" type="uint" summary="keymap format"/>
<arg name="fd" type="fd" summary="keymap file descriptor"/>
<arg name="size" type="uint" summary="keymap size, in bytes"/>
</request>
<enum name="error">
<entry name="no_keymap" value="0" summary="No keymap was set"/>
</enum>
<request name="key">
<description summary="key event">
A key was pressed or released.
The time argument is a timestamp with millisecond granularity, with an
undefined base. All requests regarding a single object must share the
same clock.
Keymap must be set before issuing this request.
State carries a value from the key_state enumeration.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="key" type="uint" summary="key that produced the event"/>
<arg name="state" type="uint" summary="physical state of the key"/>
</request>
<request name="modifiers">
<description summary="modifier and group state">
Notifies the compositor that the modifier and/or group state has
changed, and it should update state.
The client should use wl_keyboard.modifiers event to synchronize its
internal state with seat state.
Keymap must be set before issuing this request.
</description>
<arg name="mods_depressed" type="uint" summary="depressed modifiers"/>
<arg name="mods_latched" type="uint" summary="latched modifiers"/>
<arg name="mods_locked" type="uint" summary="locked modifiers"/>
<arg name="group" type="uint" summary="keyboard layout"/>
</request>
<request name="destroy" type="destructor" since="1">
<description summary="destroy the virtual keyboard keyboard object"/>
</request>
</interface>
<interface name="zwp_virtual_keyboard_manager_v1" version="1">
<description summary="virtual keyboard manager">
A virtual keyboard manager allows an application to provide keyboard
input events as if they came from a physical keyboard.
</description>
<enum name="error">
<entry name="unauthorized" value="0" summary="client not authorized to use the interface"/>
</enum>
<request name="create_virtual_keyboard">
<description summary="Create a new virtual keyboard">
Creates a new virtual keyboard associated to a seat.
If the compositor enables a keyboard to perform arbitrary actions, it
should present an error when an untrusted client requests a new
keyboard.
</description>
<arg name="seat" type="object" interface="wl_seat"/>
<arg name="id" type="new_id" interface="zwp_virtual_keyboard_v1"/>
</request>
</interface>
</protocol>

189
protocols/wayland-drm.xml Normal file
View File

@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="drm">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2011 Intel Corporation
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that\n the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<!-- drm support. This object is created by the server and published
using the display's global event. -->
<interface name="wl_drm" version="2">
<enum name="error">
<entry name="authenticate_fail" value="0"/>
<entry name="invalid_format" value="1"/>
<entry name="invalid_name" value="2"/>
</enum>
<enum name="format">
<!-- The drm format codes match the #defines in drm_fourcc.h.
The formats actually supported by the compositor will be
reported by the format event. New codes must not be added,
unless directly taken from drm_fourcc.h. -->
<entry name="c8" value="0x20203843"/>
<entry name="rgb332" value="0x38424752"/>
<entry name="bgr233" value="0x38524742"/>
<entry name="xrgb4444" value="0x32315258"/>
<entry name="xbgr4444" value="0x32314258"/>
<entry name="rgbx4444" value="0x32315852"/>
<entry name="bgrx4444" value="0x32315842"/>
<entry name="argb4444" value="0x32315241"/>
<entry name="abgr4444" value="0x32314241"/>
<entry name="rgba4444" value="0x32314152"/>
<entry name="bgra4444" value="0x32314142"/>
<entry name="xrgb1555" value="0x35315258"/>
<entry name="xbgr1555" value="0x35314258"/>
<entry name="rgbx5551" value="0x35315852"/>
<entry name="bgrx5551" value="0x35315842"/>
<entry name="argb1555" value="0x35315241"/>
<entry name="abgr1555" value="0x35314241"/>
<entry name="rgba5551" value="0x35314152"/>
<entry name="bgra5551" value="0x35314142"/>
<entry name="rgb565" value="0x36314752"/>
<entry name="bgr565" value="0x36314742"/>
<entry name="rgb888" value="0x34324752"/>
<entry name="bgr888" value="0x34324742"/>
<entry name="xrgb8888" value="0x34325258"/>
<entry name="xbgr8888" value="0x34324258"/>
<entry name="rgbx8888" value="0x34325852"/>
<entry name="bgrx8888" value="0x34325842"/>
<entry name="argb8888" value="0x34325241"/>
<entry name="abgr8888" value="0x34324241"/>
<entry name="rgba8888" value="0x34324152"/>
<entry name="bgra8888" value="0x34324142"/>
<entry name="xrgb2101010" value="0x30335258"/>
<entry name="xbgr2101010" value="0x30334258"/>
<entry name="rgbx1010102" value="0x30335852"/>
<entry name="bgrx1010102" value="0x30335842"/>
<entry name="argb2101010" value="0x30335241"/>
<entry name="abgr2101010" value="0x30334241"/>
<entry name="rgba1010102" value="0x30334152"/>
<entry name="bgra1010102" value="0x30334142"/>
<entry name="yuyv" value="0x56595559"/>
<entry name="yvyu" value="0x55595659"/>
<entry name="uyvy" value="0x59565955"/>
<entry name="vyuy" value="0x59555956"/>
<entry name="ayuv" value="0x56555941"/>
<entry name="xyuv8888" value="0x56555958"/>
<entry name="nv12" value="0x3231564e"/>
<entry name="nv21" value="0x3132564e"/>
<entry name="nv16" value="0x3631564e"/>
<entry name="nv61" value="0x3136564e"/>
<entry name="yuv410" value="0x39565559"/>
<entry name="yvu410" value="0x39555659"/>
<entry name="yuv411" value="0x31315559"/>
<entry name="yvu411" value="0x31315659"/>
<entry name="yuv420" value="0x32315559"/>
<entry name="yvu420" value="0x32315659"/>
<entry name="yuv422" value="0x36315559"/>
<entry name="yvu422" value="0x36315659"/>
<entry name="yuv444" value="0x34325559"/>
<entry name="yvu444" value="0x34325659"/>
<entry name="abgr16f" value="0x48344241"/>
<entry name="xbgr16f" value="0x48344258"/>
</enum>
<!-- Call this request with the magic received from drmGetMagic().
It will be passed on to the drmAuthMagic() or
DRIAuthConnection() call. This authentication must be
completed before create_buffer could be used. -->
<request name="authenticate">
<arg name="id" type="uint"/>
</request>
<!-- Create a wayland buffer for the named DRM buffer. The DRM
surface must have a name using the flink ioctl -->
<request name="create_buffer">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="uint"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="stride" type="uint"/>
<arg name="format" type="uint"/>
</request>
<!-- Create a wayland buffer for the named DRM buffer. The DRM
surface must have a name using the flink ioctl -->
<request name="create_planar_buffer">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="uint"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
<!-- Notification of the path of the drm device which is used by
the server. The client should use this device for creating
local buffers. Only buffers created from this device should
be be passed to the server using this drm object's
create_buffer request. -->
<event name="device">
<arg name="name" type="string"/>
</event>
<event name="format">
<arg name="format" type="uint"/>
</event>
<!-- Raised if the authenticate request succeeded -->
<event name="authenticated"/>
<enum name="capability" since="2">
<description summary="wl_drm capability bitmask">
Bitmask of capabilities.
</description>
<entry name="prime" value="1" summary="wl_drm prime available"/>
</enum>
<event name="capabilities">
<arg name="value" type="uint"/>
</event>
<!-- Version 2 additions -->
<!-- Create a wayland buffer for the prime fd. Use for regular and planar
buffers. Pass 0 for offset and stride for unused planes. -->
<request name="create_prime_buffer" since="2">
<arg name="id" type="new_id" interface="wl_buffer"/>
<arg name="name" type="fd"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="format" type="uint"/>
<arg name="offset0" type="int"/>
<arg name="stride0" type="int"/>
<arg name="offset1" type="int"/>
<arg name="stride1" type="int"/>
<arg name="offset2" type="int"/>
<arg name="stride2" type="int"/>
</request>
</interface>
</protocol>

View File

@@ -0,0 +1,278 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_data_control_unstable_v1">
<copyright>
Copyright © 2018 Simon Ser
Copyright © 2019 Ivan Molodetskikh
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<description summary="control data devices">
This protocol allows a privileged client to control data devices. In
particular, the client will be able to manage the current selection and take
the role of a clipboard manager.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_data_control_manager_v1" version="2">
<description summary="manager to control data devices">
This interface is a manager that allows creating per-seat data device
controls.
</description>
<request name="create_data_source">
<description summary="create a new data source">
Create a new data source.
</description>
<arg name="id" type="new_id" interface="zwlr_data_control_source_v1"
summary="data source to create"/>
</request>
<request name="get_data_device">
<description summary="get a data device for a seat">
Create a data device that can be used to manage a seat's selection.
</description>
<arg name="id" type="new_id" interface="zwlr_data_control_device_v1"/>
<arg name="seat" type="object" interface="wl_seat"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>
<interface name="zwlr_data_control_device_v1" version="2">
<description summary="manage a data device for a seat">
This interface allows a client to manage a seat's selection.
When the seat is destroyed, this object becomes inert.
</description>
<request name="set_selection">
<description summary="copy data to the selection">
This request asks the compositor to set the selection to the data from
the source on behalf of the client.
The given source may not be used in any further set_selection or
set_primary_selection requests. Attempting to use a previously used
source is a protocol error.
To unset the selection, set the source to NULL.
</description>
<arg name="source" type="object" interface="zwlr_data_control_source_v1"
allow-null="true"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy this data device">
Destroys the data device object.
</description>
</request>
<event name="data_offer">
<description summary="introduce a new wlr_data_control_offer">
The data_offer event introduces a new wlr_data_control_offer object,
which will subsequently be used in either the
wlr_data_control_device.selection event (for the regular clipboard
selections) or the wlr_data_control_device.primary_selection event (for
the primary clipboard selections). Immediately following the
wlr_data_control_device.data_offer event, the new data_offer object
will send out wlr_data_control_offer.offer events to describe the MIME
types it offers.
</description>
<arg name="id" type="new_id" interface="zwlr_data_control_offer_v1"/>
</event>
<event name="selection">
<description summary="advertise new selection">
The selection event is sent out to notify the client of a new
wlr_data_control_offer for the selection for this device. The
wlr_data_control_device.data_offer and the wlr_data_control_offer.offer
events are sent out immediately before this event to introduce the data
offer object. The selection event is sent to a client when a new
selection is set. The wlr_data_control_offer is valid until a new
wlr_data_control_offer or NULL is received. The client must destroy the
previous selection wlr_data_control_offer, if any, upon receiving this
event.
The first selection event is sent upon binding the
wlr_data_control_device object.
</description>
<arg name="id" type="object" interface="zwlr_data_control_offer_v1"
allow-null="true"/>
</event>
<event name="finished">
<description summary="this data control is no longer valid">
This data control object is no longer valid and should be destroyed by
the client.
</description>
</event>
<!-- Version 2 additions -->
<event name="primary_selection" since="2">
<description summary="advertise new primary selection">
The primary_selection event is sent out to notify the client of a new
wlr_data_control_offer for the primary selection for this device. The
wlr_data_control_device.data_offer and the wlr_data_control_offer.offer
events are sent out immediately before this event to introduce the data
offer object. The primary_selection event is sent to a client when a
new primary selection is set. The wlr_data_control_offer is valid until
a new wlr_data_control_offer or NULL is received. The client must
destroy the previous primary selection wlr_data_control_offer, if any,
upon receiving this event.
If the compositor supports primary selection, the first
primary_selection event is sent upon binding the
wlr_data_control_device object.
</description>
<arg name="id" type="object" interface="zwlr_data_control_offer_v1"
allow-null="true"/>
</event>
<request name="set_primary_selection" since="2">
<description summary="copy data to the primary selection">
This request asks the compositor to set the primary selection to the
data from the source on behalf of the client.
The given source may not be used in any further set_selection or
set_primary_selection requests. Attempting to use a previously used
source is a protocol error.
To unset the primary selection, set the source to NULL.
The compositor will ignore this request if it does not support primary
selection.
</description>
<arg name="source" type="object" interface="zwlr_data_control_source_v1"
allow-null="true"/>
</request>
<enum name="error" since="2">
<entry name="used_source" value="1"
summary="source given to set_selection or set_primary_selection was already used before"/>
</enum>
</interface>
<interface name="zwlr_data_control_source_v1" version="1">
<description summary="offer to transfer data">
The wlr_data_control_source object is the source side of a
wlr_data_control_offer. It is created by the source client in a data
transfer and provides a way to describe the offered data and a way to
respond to requests to transfer the data.
</description>
<enum name="error">
<entry name="invalid_offer" value="1"
summary="offer sent after wlr_data_control_device.set_selection"/>
</enum>
<request name="offer">
<description summary="add an offered MIME type">
This request adds a MIME type to the set of MIME types advertised to
targets. Can be called several times to offer multiple types.
Calling this after wlr_data_control_device.set_selection is a protocol
error.
</description>
<arg name="mime_type" type="string"
summary="MIME type offered by the data source"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy this source">
Destroys the data source object.
</description>
</request>
<event name="send">
<description summary="send the data">
Request for data from the client. Send the data as the specified MIME
type over the passed file descriptor, then close it.
</description>
<arg name="mime_type" type="string" summary="MIME type for the data"/>
<arg name="fd" type="fd" summary="file descriptor for the data"/>
</event>
<event name="cancelled">
<description summary="selection was cancelled">
This data source is no longer valid. The data source has been replaced
by another data source.
The client should clean up and destroy this data source.
</description>
</event>
</interface>
<interface name="zwlr_data_control_offer_v1" version="1">
<description summary="offer to transfer data">
A wlr_data_control_offer represents a piece of data offered for transfer
by another client (the source client). The offer describes the different
MIME types that the data can be converted to and provides the mechanism
for transferring the data directly from the source client.
</description>
<request name="receive">
<description summary="request that the data is transferred">
To transfer the offered data, the client issues this request and
indicates the MIME type it wants to receive. The transfer happens
through the passed file descriptor (typically created with the pipe
system call). The source client writes the data in the MIME type
representation requested and then closes the file descriptor.
The receiving client reads from the read end of the pipe until EOF and
then closes its end, at which point the transfer is complete.
This request may happen multiple times for different MIME types.
</description>
<arg name="mime_type" type="string"
summary="MIME type desired by receiver"/>
<arg name="fd" type="fd" summary="file descriptor for data transfer"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy this offer">
Destroys the data offer object.
</description>
</request>
<event name="offer">
<description summary="advertise offered MIME type">
Sent immediately after creating the wlr_data_control_offer object.
One event per offered MIME type.
</description>
<arg name="mime_type" type="string" summary="offered MIME type"/>
</event>
</interface>
</protocol>

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_gamma_control_unstable_v1">
<copyright>
Copyright © 2015 Giulio camuffo
Copyright © 2018 Simon Ser
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<description summary="manage gamma tables of outputs">
This protocol allows a privileged client to set the gamma tables for
outputs.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_gamma_control_manager_v1" version="1">
<description summary="manager to create per-output gamma controls">
This interface is a manager that allows creating per-output gamma
controls.
</description>
<request name="get_gamma_control">
<description summary="get a gamma control for an output">
Create a gamma control that can be used to adjust gamma tables for the
provided output.
</description>
<arg name="id" type="new_id" interface="zwlr_gamma_control_v1"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>
<interface name="zwlr_gamma_control_v1" version="1">
<description summary="adjust gamma tables for an output">
This interface allows a client to adjust gamma tables for a particular
output.
The client will receive the gamma size, and will then be able to set gamma
tables. At any time the compositor can send a failed event indicating that
this object is no longer valid.
There can only be at most one gamma control object per output, which
has exclusive access to this particular output. When the gamma control
object is destroyed, the gamma table is restored to its original value.
</description>
<event name="gamma_size">
<description summary="size of gamma ramps">
Advertise the size of each gamma ramp.
This event is sent immediately when the gamma control object is created.
</description>
<arg name="size" type="uint" summary="number of elements in a ramp"/>
</event>
<enum name="error">
<entry name="invalid_gamma" value="1" summary="invalid gamma tables"/>
</enum>
<request name="set_gamma">
<description summary="set the gamma table">
Set the gamma table. The file descriptor can be memory-mapped to provide
the raw gamma table, which contains successive gamma ramps for the red,
green and blue channels. Each gamma ramp is an array of 16-byte unsigned
integers which has the same length as the gamma size.
The file descriptor data must have the same length as three times the
gamma size.
</description>
<arg name="fd" type="fd" summary="gamma table file descriptor"/>
</request>
<event name="failed">
<description summary="object no longer valid">
This event indicates that the gamma control is no longer valid. This
can happen for a number of reasons, including:
- The output doesn't support gamma tables
- Setting the gamma tables failed
- Another client already has exclusive gamma control for this output
- The compositor has transferred gamma control to another client
Upon receiving this event, the client should destroy this object.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy this control">
Destroys the gamma control object. If the object is still valid, this
restores the original gamma tables.
</description>
</request>
</interface>
</protocol>

View File

@@ -25,7 +25,7 @@
THIS SOFTWARE.
</copyright>
<interface name="zwlr_layer_shell_v1" version="4">
<interface name="zwlr_layer_shell_v1" version="5">
<description summary="create surfaces that are layers of the desktop">
Clients can use this interface to assign the surface_layer role to
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
@@ -100,7 +100,7 @@
</request>
</interface>
<interface name="zwlr_layer_surface_v1" version="4">
<interface name="zwlr_layer_surface_v1" version="5">
<description summary="layer metadata interface">
An interface that may be implemented by a wl_surface, for surfaces that
are designed to be rendered as a layer of a stacked desktop-like
@@ -367,6 +367,7 @@
<entry name="invalid_size" value="1" summary="size is invalid"/>
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
<entry name="invalid_exclusive_edge" value="4" summary="exclusive edge is invalid given the surface anchors"/>
</enum>
<enum name="anchor" bitfield="true">
@@ -386,5 +387,21 @@
</description>
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
</request>
<!-- Version 5 additions -->
<request name="set_exclusive_edge" since="5">
<description summary="set the edge the exclusive zone will be applied to">
Requests an edge for the exclusive zone to apply. The exclusive
edge will be automatically deduced from anchor points when possible,
but when the surface is anchored to a corner, it will be necessary
to set it explicitly to disambiguate, as it is not possible to deduce
which one of the two corner edges should be used.
The edge must be one the surface is anchored to, otherwise the
invalid_exclusive_edge protocol error will be raised.
</description>
<arg name="edge" type="uint" enum="anchor"/>
</request>
</interface>
</protocol>

View File

@@ -0,0 +1,601 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_output_management_unstable_v1">
<copyright>
Copyright © 2019 Purism SPC
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<description summary="protocol to configure output devices">
This protocol exposes interfaces to obtain and modify output device
configuration.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_output_manager_v1" version="4">
<description summary="output device configuration manager">
This interface is a manager that allows reading and writing the current
output device configuration.
Output devices that display pixels (e.g. a physical monitor or a virtual
output in a window) are represented as heads. Heads cannot be created nor
destroyed by the client, but they can be enabled or disabled and their
properties can be changed. Each head may have one or more available modes.
Whenever a head appears (e.g. a monitor is plugged in), it will be
advertised via the head event. Immediately after the output manager is
bound, all current heads are advertised.
Whenever a head's properties change, the relevant wlr_output_head events
will be sent. Not all head properties will be sent: only properties that
have changed need to.
Whenever a head disappears (e.g. a monitor is unplugged), a
wlr_output_head.finished event will be sent.
After one or more heads appear, change or disappear, the done event will
be sent. It carries a serial which can be used in a create_configuration
request to update heads properties.
The information obtained from this protocol should only be used for output
configuration purposes. This protocol is not designed to be a generic
output property advertisement protocol for regular clients. Instead,
protocols such as xdg-output should be used.
</description>
<event name="head">
<description summary="introduce a new head">
This event introduces a new head. This happens whenever a new head
appears (e.g. a monitor is plugged in) or after the output manager is
bound.
</description>
<arg name="head" type="new_id" interface="zwlr_output_head_v1"/>
</event>
<event name="done">
<description summary="sent all information about current configuration">
This event is sent after all information has been sent after binding to
the output manager object and after any subsequent changes. This applies
to child head and mode objects as well. In other words, this event is
sent whenever a head or mode is created or destroyed and whenever one of
their properties has been changed. Not all state is re-sent each time
the current configuration changes: only the actual changes are sent.
This allows changes to the output configuration to be seen as atomic,
even if they happen via multiple events.
A serial is sent to be used in a future create_configuration request.
</description>
<arg name="serial" type="uint" summary="current configuration serial"/>
</event>
<request name="create_configuration">
<description summary="create a new output configuration object">
Create a new output configuration object. This allows to update head
properties.
</description>
<arg name="id" type="new_id" interface="zwlr_output_configuration_v1"/>
<arg name="serial" type="uint"/>
</request>
<request name="stop">
<description summary="stop sending events">
Indicates the client no longer wishes to receive events for output
configuration changes. However the compositor may emit further events,
until the finished event is emitted.
The client must not send any more requests after this one.
</description>
</request>
<event name="finished" type="destructor">
<description summary="the compositor has finished with the manager">
This event indicates that the compositor is done sending manager events.
The compositor will destroy the object immediately after sending this
event, so it will become invalid and the client should release any
resources associated with it.
</description>
</event>
</interface>
<interface name="zwlr_output_head_v1" version="4">
<description summary="output device">
A head is an output device. The difference between a wl_output object and
a head is that heads are advertised even if they are turned off. A head
object only advertises properties and cannot be used directly to change
them.
A head has some read-only properties: modes, name, description and
physical_size. These cannot be changed by clients.
Other properties can be updated via a wlr_output_configuration object.
Properties sent via this interface are applied atomically via the
wlr_output_manager.done event. No guarantees are made regarding the order
in which properties are sent.
</description>
<event name="name">
<description summary="head name">
This event describes the head name.
The naming convention is compositor defined, but limited to alphanumeric
characters and dashes (-). Each name is unique among all wlr_output_head
objects, but if a wlr_output_head object is destroyed the same name may
be reused later. The names will also remain consistent across sessions
with the same hardware and software configuration.
Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do
not assume that the name is a reflection of an underlying DRM
connector, X11 connection, etc.
If the compositor implements the xdg-output protocol and this head is
enabled, the xdg_output.name event must report the same name.
The name event is sent after a wlr_output_head object is created. This
event is only sent once per object, and the name does not change over
the lifetime of the wlr_output_head object.
</description>
<arg name="name" type="string"/>
</event>
<event name="description">
<description summary="head description">
This event describes a human-readable description of the head.
The description is a UTF-8 string with no convention defined for its
contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11
output via :1'. However, do not assume that the name is a reflection of
the make, model, serial of the underlying DRM connector or the display
name of the underlying X11 connection, etc.
If the compositor implements xdg-output and this head is enabled,
the xdg_output.description must report the same description.
The description event is sent after a wlr_output_head object is created.
This event is only sent once per object, and the description does not
change over the lifetime of the wlr_output_head object.
</description>
<arg name="description" type="string"/>
</event>
<event name="physical_size">
<description summary="head physical size">
This event describes the physical size of the head. This event is only
sent if the head has a physical size (e.g. is not a projector or a
virtual device).
</description>
<arg name="width" type="int" summary="width in millimeters of the output"/>
<arg name="height" type="int" summary="height in millimeters of the output"/>
</event>
<event name="mode">
<description summary="introduce a mode">
This event introduces a mode for this head. It is sent once per
supported mode.
</description>
<arg name="mode" type="new_id" interface="zwlr_output_mode_v1"/>
</event>
<event name="enabled">
<description summary="head is enabled or disabled">
This event describes whether the head is enabled. A disabled head is not
mapped to a region of the global compositor space.
When a head is disabled, some properties (current_mode, position,
transform and scale) are irrelevant.
</description>
<arg name="enabled" type="int" summary="zero if disabled, non-zero if enabled"/>
</event>
<event name="current_mode">
<description summary="current mode">
This event describes the mode currently in use for this head. It is only
sent if the output is enabled.
</description>
<arg name="mode" type="object" interface="zwlr_output_mode_v1"/>
</event>
<event name="position">
<description summary="current position">
This events describes the position of the head in the global compositor
space. It is only sent if the output is enabled.
</description>
<arg name="x" type="int"
summary="x position within the global compositor space"/>
<arg name="y" type="int"
summary="y position within the global compositor space"/>
</event>
<event name="transform">
<description summary="current transformation">
This event describes the transformation currently applied to the head.
It is only sent if the output is enabled.
</description>
<arg name="transform" type="int" enum="wl_output.transform"/>
</event>
<event name="scale">
<description summary="current scale">
This events describes the scale of the head in the global compositor
space. It is only sent if the output is enabled.
</description>
<arg name="scale" type="fixed"/>
</event>
<event name="finished">
<description summary="the head has disappeared">
This event indicates that the head is no longer available. The head
object becomes inert. Clients should send a destroy request and release
any resources associated with it.
</description>
</event>
<!-- Version 2 additions -->
<event name="make" since="2">
<description summary="head manufacturer">
This event describes the manufacturer of the head.
This must report the same make as the wl_output interface does in its
geometry event.
Together with the model and serial_number events the purpose is to
allow clients to recognize heads from previous sessions and for example
load head-specific configurations back.
It is not guaranteed this event will be ever sent. A reason for that
can be that the compositor does not have information about the make of
the head or the definition of a make is not sensible in the current
setup, for example in a virtual session. Clients can still try to
identify the head by available information from other events but should
be aware that there is an increased risk of false positives.
It is not recommended to display the make string in UI to users. For
that the string provided by the description event should be preferred.
</description>
<arg name="make" type="string"/>
</event>
<event name="model" since="2">
<description summary="head model">
This event describes the model of the head.
This must report the same model as the wl_output interface does in its
geometry event.
Together with the make and serial_number events the purpose is to
allow clients to recognize heads from previous sessions and for example
load head-specific configurations back.
It is not guaranteed this event will be ever sent. A reason for that
can be that the compositor does not have information about the model of
the head or the definition of a model is not sensible in the current
setup, for example in a virtual session. Clients can still try to
identify the head by available information from other events but should
be aware that there is an increased risk of false positives.
It is not recommended to display the model string in UI to users. For
that the string provided by the description event should be preferred.
</description>
<arg name="model" type="string"/>
</event>
<event name="serial_number" since="2">
<description summary="head serial number">
This event describes the serial number of the head.
Together with the make and model events the purpose is to allow clients
to recognize heads from previous sessions and for example load head-
specific configurations back.
It is not guaranteed this event will be ever sent. A reason for that
can be that the compositor does not have information about the serial
number of the head or the definition of a serial number is not sensible
in the current setup. Clients can still try to identify the head by
available information from other events but should be aware that there
is an increased risk of false positives.
It is not recommended to display the serial_number string in UI to
users. For that the string provided by the description event should be
preferred.
</description>
<arg name="serial_number" type="string"/>
</event>
<!-- Version 3 additions -->
<request name="release" type="destructor" since="3">
<description summary="destroy the head object">
This request indicates that the client will no longer use this head
object.
</description>
</request>
<!-- Version 4 additions -->
<enum name="adaptive_sync_state" since="4">
<entry name="disabled" value="0" summary="adaptive sync is disabled"/>
<entry name="enabled" value="1" summary="adaptive sync is enabled"/>
</enum>
<event name="adaptive_sync" since="4">
<description summary="current adaptive sync state">
This event describes whether adaptive sync is currently enabled for
the head or not. Adaptive sync is also known as Variable Refresh
Rate or VRR.
</description>
<arg name="state" type="uint" enum="adaptive_sync_state"/>
</event>
</interface>
<interface name="zwlr_output_mode_v1" version="3">
<description summary="output mode">
This object describes an output mode.
Some heads don't support output modes, in which case modes won't be
advertised.
Properties sent via this interface are applied atomically via the
wlr_output_manager.done event. No guarantees are made regarding the order
in which properties are sent.
</description>
<event name="size">
<description summary="mode size">
This event describes the mode size. The size is given in physical
hardware units of the output device. This is not necessarily the same as
the output size in the global compositor space. For instance, the output
may be scaled or transformed.
</description>
<arg name="width" type="int" summary="width of the mode in hardware units"/>
<arg name="height" type="int" summary="height of the mode in hardware units"/>
</event>
<event name="refresh">
<description summary="mode refresh rate">
This event describes the mode's fixed vertical refresh rate. It is only
sent if the mode has a fixed refresh rate.
</description>
<arg name="refresh" type="int" summary="vertical refresh rate in mHz"/>
</event>
<event name="preferred">
<description summary="mode is preferred">
This event advertises this mode as preferred.
</description>
</event>
<event name="finished">
<description summary="the mode has disappeared">
This event indicates that the mode is no longer available. The mode
object becomes inert. Clients should send a destroy request and release
any resources associated with it.
</description>
</event>
<!-- Version 3 additions -->
<request name="release" type="destructor" since="3">
<description summary="destroy the mode object">
This request indicates that the client will no longer use this mode
object.
</description>
</request>
</interface>
<interface name="zwlr_output_configuration_v1" version="4">
<description summary="output configuration">
This object is used by the client to describe a full output configuration.
First, the client needs to setup the output configuration. Each head can
be either enabled (and configured) or disabled. It is a protocol error to
send two enable_head or disable_head requests with the same head. It is a
protocol error to omit a head in a configuration.
Then, the client can apply or test the configuration. The compositor will
then reply with a succeeded, failed or cancelled event. Finally the client
should destroy the configuration object.
</description>
<enum name="error">
<entry name="already_configured_head" value="1"
summary="head has been configured twice"/>
<entry name="unconfigured_head" value="2"
summary="head has not been configured"/>
<entry name="already_used" value="3"
summary="request sent after configuration has been applied or tested"/>
</enum>
<request name="enable_head">
<description summary="enable and configure a head">
Enable a head. This request creates a head configuration object that can
be used to change the head's properties.
</description>
<arg name="id" type="new_id" interface="zwlr_output_configuration_head_v1"
summary="a new object to configure the head"/>
<arg name="head" type="object" interface="zwlr_output_head_v1"
summary="the head to be enabled"/>
</request>
<request name="disable_head">
<description summary="disable a head">
Disable a head.
</description>
<arg name="head" type="object" interface="zwlr_output_head_v1"
summary="the head to be disabled"/>
</request>
<request name="apply">
<description summary="apply the configuration">
Apply the new output configuration.
In case the configuration is successfully applied, there is no guarantee
that the new output state matches completely the requested
configuration. For instance, a compositor might round the scale if it
doesn't support fractional scaling.
After this request has been sent, the compositor must respond with an
succeeded, failed or cancelled event. Sending a request that isn't the
destructor is a protocol error.
</description>
</request>
<request name="test">
<description summary="test the configuration">
Test the new output configuration. The configuration won't be applied,
but will only be validated.
Even if the compositor succeeds to test a configuration, applying it may
fail.
After this request has been sent, the compositor must respond with an
succeeded, failed or cancelled event. Sending a request that isn't the
destructor is a protocol error.
</description>
</request>
<event name="succeeded">
<description summary="configuration changes succeeded">
Sent after the compositor has successfully applied the changes or
tested them.
Upon receiving this event, the client should destroy this object.
If the current configuration has changed, events to describe the changes
will be sent followed by a wlr_output_manager.done event.
</description>
</event>
<event name="failed">
<description summary="configuration changes failed">
Sent if the compositor rejects the changes or failed to apply them. The
compositor should revert any changes made by the apply request that
triggered this event.
Upon receiving this event, the client should destroy this object.
</description>
</event>
<event name="cancelled">
<description summary="configuration has been cancelled">
Sent if the compositor cancels the configuration because the state of an
output changed and the client has outdated information (e.g. after an
output has been hotplugged).
The client can create a new configuration with a newer serial and try
again.
Upon receiving this event, the client should destroy this object.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy the output configuration">
Using this request a client can tell the compositor that it is not going
to use the configuration object anymore. Any changes to the outputs
that have not been applied will be discarded.
This request also destroys wlr_output_configuration_head objects created
via this object.
</description>
</request>
</interface>
<interface name="zwlr_output_configuration_head_v1" version="4">
<description summary="head configuration">
This object is used by the client to update a single head's configuration.
It is a protocol error to set the same property twice.
</description>
<enum name="error">
<entry name="already_set" value="1" summary="property has already been set"/>
<entry name="invalid_mode" value="2" summary="mode doesn't belong to head"/>
<entry name="invalid_custom_mode" value="3" summary="mode is invalid"/>
<entry name="invalid_transform" value="4" summary="transform value outside enum"/>
<entry name="invalid_scale" value="5" summary="scale negative or zero"/>
<entry name="invalid_adaptive_sync_state" value="6" since="4"
summary="invalid enum value used in the set_adaptive_sync request"/>
</enum>
<request name="set_mode">
<description summary="set the mode">
This request sets the head's mode.
</description>
<arg name="mode" type="object" interface="zwlr_output_mode_v1"/>
</request>
<request name="set_custom_mode">
<description summary="set a custom mode">
This request assigns a custom mode to the head. The size is given in
physical hardware units of the output device. If set to zero, the
refresh rate is unspecified.
It is a protocol error to set both a mode and a custom mode.
</description>
<arg name="width" type="int" summary="width of the mode in hardware units"/>
<arg name="height" type="int" summary="height of the mode in hardware units"/>
<arg name="refresh" type="int" summary="vertical refresh rate in mHz or zero"/>
</request>
<request name="set_position">
<description summary="set the position">
This request sets the head's position in the global compositor space.
</description>
<arg name="x" type="int" summary="x position in the global compositor space"/>
<arg name="y" type="int" summary="y position in the global compositor space"/>
</request>
<request name="set_transform">
<description summary="set the transform">
This request sets the head's transform.
</description>
<arg name="transform" type="int" enum="wl_output.transform"/>
</request>
<request name="set_scale">
<description summary="set the scale">
This request sets the head's scale.
</description>
<arg name="scale" type="fixed"/>
</request>
<!-- Version 4 additions -->
<request name="set_adaptive_sync" since="4">
<description summary="enable/disable adaptive sync">
This request enables/disables adaptive sync. Adaptive sync is also
known as Variable Refresh Rate or VRR.
</description>
<arg name="state" type="uint" enum="zwlr_output_head_v1.adaptive_sync_state"/>
</request>
</interface>
</protocol>

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_virtual_pointer_unstable_v1">
<copyright>
Copyright © 2019 Josef Gajdusek
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwlr_virtual_pointer_v1" version="2">
<description summary="virtual pointer">
This protocol allows clients to emulate a physical pointer device. The
requests are mostly mirror opposites of those specified in wl_pointer.
</description>
<enum name="error">
<entry name="invalid_axis" value="0"
summary="client sent invalid axis enumeration value" />
<entry name="invalid_axis_source" value="1"
summary="client sent invalid axis source enumeration value" />
</enum>
<request name="motion">
<description summary="pointer relative motion event">
The pointer has moved by a relative amount to the previous request.
Values are in the global compositor space.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="dx" type="fixed" summary="displacement on the x-axis"/>
<arg name="dy" type="fixed" summary="displacement on the y-axis"/>
</request>
<request name="motion_absolute">
<description summary="pointer absolute motion event">
The pointer has moved in an absolute coordinate frame.
Value of x can range from 0 to x_extent, value of y can range from 0
to y_extent.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="x" type="uint" summary="position on the x-axis"/>
<arg name="y" type="uint" summary="position on the y-axis"/>
<arg name="x_extent" type="uint" summary="extent of the x-axis"/>
<arg name="y_extent" type="uint" summary="extent of the y-axis"/>
</request>
<request name="button">
<description summary="button event">
A button was pressed or released.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="button" type="uint" summary="button that produced the event"/>
<arg name="state" type="uint" enum="wl_pointer.button_state" summary="physical state of the button"/>
</request>
<request name="axis">
<description summary="axis event">
Scroll and other axis requests.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="axis" type="uint" enum="wl_pointer.axis" summary="axis type"/>
<arg name="value" type="fixed" summary="length of vector in touchpad coordinates"/>
</request>
<request name="frame">
<description summary="end of a pointer event sequence">
Indicates the set of events that logically belong together.
</description>
</request>
<request name="axis_source">
<description summary="axis source event">
Source information for scroll and other axis.
</description>
<arg name="axis_source" type="uint" enum="wl_pointer.axis_source" summary="source of the axis event"/>
</request>
<request name="axis_stop">
<description summary="axis stop event">
Stop notification for scroll and other axes.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="axis" type="uint" enum="wl_pointer.axis" summary="the axis stopped with this event"/>
</request>
<request name="axis_discrete">
<description summary="axis click event">
Discrete step information for scroll and other axes.
This event allows the client to extend data normally sent using the axis
event with discrete value.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="axis" type="uint" enum="wl_pointer.axis" summary="axis type"/>
<arg name="value" type="fixed" summary="length of vector in touchpad coordinates"/>
<arg name="discrete" type="int" summary="number of steps"/>
</request>
<request name="destroy" type="destructor" since="1">
<description summary="destroy the virtual pointer object"/>
</request>
</interface>
<interface name="zwlr_virtual_pointer_manager_v1" version="2">
<description summary="virtual pointer manager">
This object allows clients to create individual virtual pointer objects.
</description>
<request name="create_virtual_pointer">
<description summary="Create a new virtual pointer">
Creates a new virtual pointer. The optional seat is a suggestion to the
compositor.
</description>
<arg name="seat" type="object" interface="wl_seat" allow-null="true"/>
<arg name="id" type="new_id" interface="zwlr_virtual_pointer_v1"/>
</request>
<request name="destroy" type="destructor" since="1">
<description summary="destroy the virtual pointer manager"/>
</request>
<!-- Version 2 additions -->
<request name="create_virtual_pointer_with_output" since="2">
<description summary="Create a new virtual pointer">
Creates a new virtual pointer. The seat and the output arguments are
optional. If the seat argument is set, the compositor should assign the
input device to the requested seat. If the output argument is set, the
compositor should map the input device to the requested output.
</description>
<arg name="seat" type="object" interface="wl_seat" allow-null="true"/>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
<arg name="id" type="new_id" interface="zwlr_virtual_pointer_v1"/>
</request>
</interface>
</protocol>

View File

@@ -1,12 +1,13 @@
#!/bin/sh
cp -fr ./src/version.h.in ./src/version.h
HASH=$(git rev-parse HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
MESSAGE=$(git show ${GIT_COMMIT_HASH} | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g')
DATE=$(git show ${GIT_COMMIT_HASH} --no-patch --format=%cd --date=local)
DIRTY=$(git diff-index --quiet HEAD -- || echo dirty)
TAG=$(git describe --tags)
HASH=${HASH-$(git rev-parse HEAD)}
BRANCH=${BRANCH-$(git branch --show-current)}
MESSAGE=${MESSAGE-$(git show | head -n 5 | tail -n 1 | sed -e 's/#//g' -e 's/\"//g')}
DATE=${DATE-$(git show --no-patch --format=%cd --date=local)}
DIRTY=${DIRTY-$(git diff-index --quiet HEAD -- || echo dirty)}
TAG=${TAG-$(git describe --tags)}
COMMITS=${COMMITS-$(git rev-list --count HEAD)}
sed -i -e "s#@HASH@#${HASH}#" ./src/version.h
sed -i -e "s#@BRANCH@#${BRANCH}#" ./src/version.h
@@ -14,3 +15,4 @@ sed -i -e "s#@MESSAGE@#${MESSAGE}#" ./src/version.h
sed -i -e "s#@DATE@#${DATE}#" ./src/version.h
sed -i -e "s#@DIRTY@#${DIRTY}#" ./src/version.h
sed -i -e "s#@TAG@#${TAG}#" ./src/version.h
sed -i -e "s#@COMMITS@#${COMMITS}#" ./src/version.h

View File

@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f54cdf5d..ad7c3e73 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -130,6 +130,8 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Enabling ASan")
target_link_libraries(Hyprland asan)
+ pkg_check_modules(ffidep REQUIRED IMPORTED_TARGET libffi)
+ target_link_libraries(Hyprland ${CMAKE_SOURCE_DIR}/libwayland-server.a PkgConfig::ffidep)
target_compile_options(Hyprland PUBLIC -fsanitize=address)
endif()

View File

@@ -0,0 +1,23 @@
diff --git a/src/meson.build b/src/meson.build
index 5d04334..6645eec 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -170,7 +170,7 @@ if get_option('libraries')
error('We probably need to bump the SONAME of libwayland-server and -client')
endif
- wayland_server = library(
+ wayland_server = static_library(
'wayland-server',
sources: [
wayland_server_protocol_core_h,
@@ -180,9 +180,6 @@ if get_option('libraries')
'wayland-shm.c',
'event-loop.c'
],
- # To avoid an unnecessary SONAME bump, wayland 1.x.y produces
- # libwayland-server.so.0.x.y.
- version: '.'.join(['0', wayland_version[1], wayland_version[2]]),
dependencies: [
epoll_dep,
ffi_dep,

File diff suppressed because it is too large Load Diff

View File

@@ -21,16 +21,19 @@
#include "debug/HyprDebugOverlay.hpp"
#include "debug/HyprNotificationOverlay.hpp"
#include "helpers/Monitor.hpp"
#include "helpers/Workspace.hpp"
#include "Window.hpp"
#include "desktop/Workspace.hpp"
#include "desktop/Window.hpp"
#include "render/Renderer.hpp"
#include "render/OpenGL.hpp"
#include "hyprerror/HyprError.hpp"
#include "plugins/PluginSystem.hpp"
#include "helpers/Watchdog.hpp"
class CWLSurfaceResource;
enum eManagersInitStage {
STAGE_PRIORITY = 0,
STAGE_BASICINIT,
STAGE_LATE
};
@@ -40,64 +43,36 @@ class CCompositor {
~CCompositor();
// ------------------ WLR BASICS ------------------ //
wl_display* m_sWLDisplay;
wl_event_loop* m_sWLEventLoop;
wlr_backend* m_sWLRBackend;
wlr_session* m_sWLRSession;
wlr_renderer* m_sWLRRenderer;
wlr_allocator* m_sWLRAllocator;
wlr_compositor* m_sWLRCompositor;
wlr_subcompositor* m_sWLRSubCompositor;
wlr_data_device_manager* m_sWLRDataDevMgr;
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout;
wlr_idle_notifier_v1* m_sWLRIdleNotifier;
wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor;
wlr_xcursor_manager* m_sWLRXCursorMgr;
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
wlr_output_manager_v1* m_sWLROutputMgr;
wlr_presentation* m_sWLRPresentation;
wlr_keyboard_shortcuts_inhibit_manager_v1* m_sWLRKbShInhibitMgr;
wlr_egl* m_sWLREGL;
int m_iDRMFD;
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
wlr_tablet_manager_v2* m_sWLRTabletManager;
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
wlr_input_method_manager_v2* m_sWLRIMEMgr;
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
wlr_xdg_activation_v1* m_sWLRActivation;
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;
wlr_tearing_control_manager_v1* m_sWLRTearingControlMgr;
wl_display* m_sWLDisplay;
wl_event_loop* m_sWLEventLoop;
wlr_backend* m_sWLRBackend;
wlr_session* m_sWLRSession;
wlr_renderer* m_sWLRRenderer;
wlr_allocator* m_sWLRAllocator;
wlr_compositor* m_sWLRCompositor;
wlr_subcompositor* m_sWLRSubCompositor;
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_egl* m_sWLREGL;
int m_iDRMFD;
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
wlr_backend* m_sWLRHeadlessBackend;
// ------------------------------------------------- //
std::string m_szHyprTempDataRoot = "";
std::string m_szWLDisplaySocket = "";
std::string m_szInstanceSignature = "";
std::string m_szInstancePath = "";
std::string m_szCurrentSplash = "error";
std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
std::vector<std::unique_ptr<CWindow>> m_vWindows;
std::vector<std::unique_ptr<SXDGPopup>> m_vXDGPopups;
std::vector<std::unique_ptr<CWorkspace>> m_vWorkspaces;
std::vector<std::unique_ptr<SSubsurface>> m_vSubsurfaces;
std::vector<CWindow*> m_vWindowsFadingOut;
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
std::vector<SP<CMonitor>> m_vMonitors;
std::vector<SP<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
std::vector<PHLWINDOW> m_vWindows;
std::vector<PHLLS> m_vLayers;
std::vector<PHLWORKSPACE> m_vWorkspaces;
std::vector<PHLWINDOWREF> m_vWindowsFadingOut;
std::vector<PHLLSREF> m_vSurfacesFadingOut;
std::unordered_map<std::string, uint64_t> m_mMonitorIDMap;
@@ -107,13 +82,11 @@ class CCompositor {
void createLockFile();
void removeLockFile();
wlr_surface* m_pLastFocus = nullptr;
CWindow* m_pLastWindow = nullptr;
CMonitor* m_pLastMonitor = nullptr;
WP<CWLSurfaceResource> m_pLastFocus;
PHLWINDOWREF m_pLastWindow;
WP<CMonitor> m_pLastMonitor;
std::vector<CWindow*> m_vWindowFocusHistory; // first element is the most recently focused.
SSeat m_sSeat;
std::vector<PHLWINDOWREF> m_vWindowFocusHistory; // first element is the most recently focused.
bool m_bReadyToProcess = false;
bool m_bSessionActive = true;
@@ -121,120 +94,102 @@ class CCompositor {
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bNextIsUnsafe = false; // because wlroots
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state
bool m_bExitTriggered = false; // For exit dispatcher
bool m_bIsShuttingDown = false;
// ------------------------------------------------- //
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(CWindow*);
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
bool windowExists(CWindow*);
bool windowValidMapped(CWindow*);
bool monitorExists(CMonitor*);
CWindow* vectorToWindowUnified(const Vector2D&, uint8_t properties, CWindow* pIgnoreWindow = nullptr);
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
SIMEPopup* vectorToIMEPopup(const Vector2D& pos, std::list<SIMEPopup>& popups);
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
Vector2D vectorToSurfaceLocal(const Vector2D&, CWindow*, wlr_surface*);
CMonitor* getMonitorFromOutput(wlr_output*);
CMonitor* getRealMonitorFromOutput(wlr_output*);
CWindow* getWindowForPopup(wlr_xdg_popup*);
CWindow* getWindowFromSurface(wlr_surface*);
CWindow* getWindowFromHandle(uint32_t);
CWindow* getWindowFromZWLRHandle(wl_resource*);
bool isWorkspaceVisible(const int&);
CWorkspace* getWorkspaceByID(const int&);
CWorkspace* getWorkspaceByName(const std::string&);
CWorkspace* getWorkspaceByString(const std::string&);
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*);
void changeWindowZOrder(CWindow*, bool);
void cleanupFadingOut(const int& monid);
CWindow* getWindowInDirection(CWindow*, char);
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false, std::optional<bool> floating = {});
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false, std::optional<bool> floating = {});
int getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&);
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
CWindow* getConstraintWindow(SMouse*);
CMonitor* getMonitorInDirection(const char&);
CMonitor* getMonitorInDirection(CMonitor*, const char&);
void updateAllWindowsAnimatedDecorationValues();
void updateWorkspaceWindows(const int64_t& id);
void updateWindowAnimatedDecorationValues(CWindow*);
int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*, bool noWarpCursor = false);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int64_t&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void updateFullscreenFadeOnWorkspace(CWorkspace*);
CWindow* getX11Parent(CWindow*);
void scheduleFrameForMonitor(CMonitor*);
void addToFadingOutSafe(SLayerSurface*);
void addToFadingOutSafe(CWindow*);
CWindow* getWindowByRegex(const std::string&);
void warpCursorTo(const Vector2D&, bool force = false);
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
void closeWindow(CWindow*);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&);
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const int&, const std::string& name = "");
void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&);
int getNewSpecialID();
void performUserChecks();
void moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace);
CWindow* getForceFocus();
void notifyIdleActivity();
void setIdleActivityInhibit(bool inhibit);
void arrangeMonitors();
void enterUnsafeState();
void leaveUnsafeState();
void setPreferredScaleForSurface(wlr_surface* pSurface, double scale);
void setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform);
void updateSuspendedStates();
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(PHLWINDOW);
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
bool monitorExists(CMonitor*);
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, CMonitor* monitor, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);
CMonitor* getMonitorFromOutput(wlr_output*);
CMonitor* getRealMonitorFromOutput(wlr_output*);
PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>);
PHLWINDOW getWindowFromHandle(uint32_t);
bool isWorkspaceVisible(PHLWORKSPACE);
PHLWORKSPACE getWorkspaceByID(const int&);
PHLWORKSPACE getWorkspaceByName(const std::string&);
PHLWORKSPACE getWorkspaceByString(const std::string&);
void sanityCheckWorkspaces();
void updateWorkspaceWindowDecos(const int&);
void updateWorkspaceSpecialRenderData(const int&);
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
int getGroupsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
PHLWINDOW getUrgentWindow();
bool hasUrgentWindowOnWorkspace(const int&);
PHLWINDOW getFirstWindowOnWorkspace(const int&);
PHLWINDOW getTopLeftWindowOnWorkspace(const int&);
PHLWINDOW getFullscreenWindowOnWorkspace(const int&);
bool isWindowActive(PHLWINDOW);
void changeWindowZOrder(PHLWINDOW, bool);
void cleanupFadingOut(const int& monid);
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
int getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&);
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
CMonitor* getMonitorInDirection(const char&);
CMonitor* getMonitorInDirection(CMonitor*, const char&);
void updateAllWindowsAnimatedDecorationValues();
void updateWorkspaceWindows(const int64_t& id);
void updateWindowAnimatedDecorationValues(PHLWINDOW);
int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int64_t&);
void setWindowFullscreen(PHLWINDOW, bool, eFullscreenMode mode = FULLSCREEN_INVALID);
void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
PHLWINDOW getX11Parent(PHLWINDOW);
void scheduleFrameForMonitor(CMonitor*);
void addToFadingOutSafe(PHLLS);
void addToFadingOutSafe(PHLWINDOW);
PHLWINDOW getWindowByRegex(const std::string&);
void warpCursorTo(const Vector2D&, bool force = false);
PHLLS getLayerSurfaceFromSurface(SP<CWLSurfaceResource>);
void closeWindow(PHLWINDOW);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&);
PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = "", bool isEmtpy = true); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const int&, const std::string& name = "");
void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&);
int getNewSpecialID();
void performUserChecks();
void moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWorkspace);
PHLWINDOW getForceFocus();
void arrangeMonitors();
void enterUnsafeState();
void leaveUnsafeState();
void setPreferredScaleForSurface(SP<CWLSurfaceResource> pSurface, double scale);
void setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform);
void updateSuspendedStates();
PHLWINDOW windowForCPointer(CWindow*);
std::string explicitConfigPath;
std::string explicitConfigPath;
private:
void initAllSignals();
void removeAllSignals();
void setRandomSplash();
void initManagers(eManagersInitStage stage);
void prepareFallbackOutput();
void initAllSignals();
void removeAllSignals();
void cleanEnvironment();
void setRandomSplash();
void initManagers(eManagersInitStage stage);
void prepareFallbackOutput();
uint64_t m_iHyprlandPID = 0;
uint64_t m_iHyprlandPID = 0;
wl_event_source* m_critSigSource = nullptr;
};
inline std::unique_ptr<CCompositor> g_pCompositor;
// For XWayland
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {HYPRATOM("_NET_WM_WINDOW_TYPE"),
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION"),
HYPRATOM("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE")};

View File

@@ -70,3 +70,5 @@ struct SHyprCtlCommand {
bool exact = true;
std::function<std::string(eHyprCtlOutputFormat, std::string)> fn;
};
typedef std::function<void(void*, SCallbackInfo&, std::any)> HOOK_CALLBACK_FN;

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,8 @@ class ICustomConfigValueData {
virtual ~ICustomConfigValueData() = 0;
virtual eConfigValueDataTypes getDataType() = 0;
virtual std::string toString() = 0;
};
class CGradientValueData : public ICustomConfigValueData {
@@ -51,6 +53,16 @@ class CGradientValueData : public ICustomConfigValueData {
return true;
}
virtual std::string toString() {
std::string result;
for (auto& c : m_vColors) {
result += std::format("{:x} ", c.getAsHex());
}
result += std::format("{}deg", (int)(m_fAngle * 180.0 / M_PI));
return result;
}
};
class CCssGapData : public ICustomConfigValueData {
@@ -103,4 +115,8 @@ class CCssGapData : public ICustomConfigValueData {
virtual eConfigValueDataTypes getDataType() {
return CVD_TYPE_CSS_VALUE;
}
virtual std::string toString() {
return std::format("{} {} {} {}", top, right, bottom, left);
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -13,10 +13,11 @@
#include <optional>
#include <functional>
#include <xf86drmMode.h>
#include "../Window.hpp"
#include "../helpers/WLClasses.hpp"
#include "../helpers/Monitor.hpp"
#include "../helpers/VarList.hpp"
#include "../desktop/Window.hpp"
#include "../desktop/LayerSurface.hpp"
#include "defaultConfig.hpp"
#include "ConfigDataValues.hpp"
@@ -102,17 +103,18 @@ class CConfigManager {
void onPluginLoadUnload(const std::string& name, bool load);
static std::string getConfigDir();
static std::string getMainConfigPath();
const std::string getConfigString();
SMonitorRule getMonitorRuleFor(const CMonitor&);
SWorkspaceRule getWorkspaceRuleFor(CWorkspace*);
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&);
const std::deque<SWorkspaceRule>& getAllWorkspaceRules();
std::vector<SWindowRule> getMatchingRules(CWindow*, bool dynamic = true);
std::vector<SLayerRule> getMatchingRules(SLayerSurface*);
std::vector<SWindowRule> getMatchingRules(PHLWINDOW, bool dynamic = true, bool shadowExec = false);
std::vector<SLayerRule> getMatchingRules(PHLLS);
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@@ -126,6 +128,8 @@ class CConfigManager {
void dispatchExecOnce();
void performMonitorReload();
void appendMonitorRule(const SMonitorRule&);
bool replaceMonitorRule(const SMonitorRule&);
bool m_bWantsMonitorReload = false;
bool m_bForceReload = false;
bool m_bNoMonitorReload = false;
@@ -141,6 +145,7 @@ class CConfigManager {
void addExecRule(const SExecRequestedRule&);
void handlePluginLoads();
std::string getErrors();
// keywords
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
@@ -192,6 +197,7 @@ class CConfigManager {
std::deque<std::string> firstExecRequests;
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
std::string m_szConfigErrors = "";
// internal methods
void setAnimForChildren(SAnimationPropertyConfig* const);
@@ -201,6 +207,7 @@ class CConfigManager {
std::optional<std::string> verifyConfigExists();
void postConfigReload(const Hyprlang::CParseResult& result);
void reload();
SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&);
};
inline std::unique_ptr<CConfigManager> g_pConfigManager;

View File

@@ -0,0 +1,73 @@
#pragma once
#include <string>
#include <typeindex>
#include <hyprlang.hpp>
#include "../debug/Log.hpp"
#include "../macros.hpp"
#include "ConfigManager.hpp"
template <typename T>
class CConfigValue {
public:
CConfigValue(const std::string& val) {
const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val.c_str());
p_ = PVHYPRLANG->getDataStaticPtr();
#ifdef HYPRLAND_DEBUG
// verify type
const auto ANY = PVHYPRLANG->getValue();
const auto TYPE = std::type_index(ANY.type());
// exceptions
const bool STRINGEX = (typeid(T) == typeid(std::string) && TYPE == typeid(Hyprlang::STRING));
const bool CUSTOMEX = (typeid(T) == typeid(Hyprlang::CUSTOMTYPE) && (TYPE == typeid(Hyprlang::CUSTOMTYPE*) || TYPE == typeid(void*) /* dunno why it does this? */));
RASSERT(typeid(T) == TYPE || STRINGEX || CUSTOMEX, "Mismatched type in CConfigValue<T>, got {} but has {}", typeid(T).name(), TYPE.name());
#endif
}
T* ptr() const {
return *(T* const*)p_;
}
T operator*() const {
return *ptr();
}
private:
void* const* p_ = nullptr;
};
template <>
inline std::string* CConfigValue<std::string>::ptr() const {
RASSERT(false, "Impossible to implement ptr() of CConfigValue<std::string>");
return nullptr;
}
template <>
inline std::string CConfigValue<std::string>::operator*() const {
return std::string{*(Hyprlang::STRING*)p_};
}
template <>
inline Hyprlang::STRING* CConfigValue<Hyprlang::STRING>::ptr() const {
return (Hyprlang::STRING*)p_;
}
template <>
inline Hyprlang::STRING CConfigValue<Hyprlang::STRING>::operator*() const {
return *(Hyprlang::STRING*)p_;
}
template <>
inline Hyprlang::CUSTOMTYPE* CConfigValue<Hyprlang::CUSTOMTYPE>::ptr() const {
return *(Hyprlang::CUSTOMTYPE* const*)p_;
}
template <>
inline Hyprlang::CUSTOMTYPE CConfigValue<Hyprlang::CUSTOMTYPE>::operator*() const {
RASSERT(false, "Impossible to implement operator* of CConfigValue<Hyprlang::CUSTOMTYPE>, use ptr()");
return *ptr();
}

View File

@@ -9,87 +9,116 @@ inline const std::string AUTOCONFIG = R"#(
# OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
# #######################################################################################
#
autogenerated = 1 # remove this line to remove the warning
# This is an example Hyprland config file.
# Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
# Please note not all available settings / options are set here.
# For a full list, see the wiki
#
autogenerated = 1 # remove this line to remove the warning
# You can split this configuration into multiple files
# Create your files separately and then link them to this file like this:
# source = ~/.config/hypr/myColors.conf
################
### MONITORS ###
################
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,auto
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
###################
### MY PROGRAMS ###
###################
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# See https://wiki.hyprland.org/Configuring/Keywords/
# Set programs that you use
$terminal = kitty
$fileManager = dolphin
$menu = wofi --show drun
# Some default env vars.
#################
### AUTOSTART ###
#################
# Autostart necessary processes (like notifications daemons, status bars, etc.)
# Or execute your favorite apps at launch like this:
# exec-once = $terminal
# exec-once = nm-applet &
# exec-once = waybar & hyprpaper & firefox
#############################
### ENVIRONMENT VARIABLES ###
#############################
# See https://wiki.hyprland.org/Configuring/Environment-variables/
env = XCURSOR_SIZE,24
env = QT_QPA_PLATFORMTHEME,qt5ct # change to qt6ct if you have that
env = HYPRCURSOR_SIZE,24
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
#####################
### LOOK AND FEEL ###
#####################
touchpad {
natural_scroll = no
}
sensitivity = 0 # -1.0 to 1.0, 0 means no modification.
}
general {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
# Refer to https://wiki.hyprland.org/Configuring/Variables/
# https://wiki.hyprland.org/Configuring/Variables/#general
general {
gaps_in = 5
gaps_out = 20
border_size = 2
# https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors
col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border = rgba(595959aa)
layout = dwindle
# Set to true enable resizing windows by clicking and dragging on borders and gaps
resize_on_border = false
# Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
allow_tearing = false
layout = dwindle
}
# https://wiki.hyprland.org/Configuring/Variables/#decoration
decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 10
# Change transparency of focused and unfocused windows
active_opacity = 1.0
inactive_opacity = 1.0
drop_shadow = true
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
# https://wiki.hyprland.org/Configuring/Variables/#blur
blur {
enabled = true
size = 3
passes = 1
vibrancy = 0.1696
}
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
}
# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
enabled = yes
enabled = true
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
@@ -101,51 +130,71 @@ animations {
animation = workspaces, 1, 6, default
}
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # You probably want this
}
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
}
gestures {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = off
# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :(
}
misc {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
#############
### INPUT ###
#############
# https://wiki.hyprland.org/Configuring/Variables/#input
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
touchpad {
natural_scroll = false
}
}
# https://wiki.hyprland.org/Configuring/Variables/#gestures
gestures {
workspace_swipe = false
}
# 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 {
name = epic-mouse-v1
sensitivity = -0.5
}
# Example windowrule v1
# windowrule = float, ^(kitty)$
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.
####################
### KEYBINDINGSS ###
####################
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Q, exec, $terminal
bind = $mainMod, C, killactive,
bind = $mainMod, M, exit,
bind = $mainMod, C, killactive,
bind = $mainMod, M, exit,
bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating,
bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
@@ -191,4 +240,20 @@ bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
##############################
### WINDOWS AND WORKSPACES ###
##############################
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules
# Example windowrule v1
# windowrule = float, ^(kitty)$
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.
)#";

View File

@@ -1,59 +1,127 @@
#include "CrashReporter.hpp"
#include <random>
#include <fcntl.h>
#include <sys/utsname.h>
#include <fstream>
#include <signal.h>
#include <link.h>
#include <time.h>
#include <errno.h>
#include <sys/stat.h>
#include "../plugins/PluginSystem.hpp"
#include "../signal-safe.hpp"
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/sysctl.h>
#endif
std::string getRandomMessage() {
static char const* const MESSAGES[] = {"Sorry, didn't mean to...",
"This was an accident, I swear!",
"Calm down, it was a misinput! MISINPUT!",
"Oops",
"Vaxry is going to be upset.",
"Who tried dividing by zero?!",
"Maybe you should try dusting your PC in the meantime?",
"I tried so hard, and got so far...",
"I don't feel so good...",
"*thud*",
"Well this is awkward.",
"\"stable\"",
"I hope you didn't have any unsaved progress.",
"All these computers..."};
const std::vector<std::string> MESSAGES = {"Sorry, didn't mean to...",
"This was an accident, I swear!",
"Calm down, it was a misinput! MISINPUT!",
"Oops",
"Vaxry is going to be upset.",
"Who tried dividing by zero?!",
"Maybe you should try dusting your PC in the meantime?",
"I tried so hard, and got so far...",
"I don't feel so good...",
"*thud*",
"Well this is awkward.",
"\"stable\"",
"I hope you didn't have any unsaved progress.",
"All these computers..."};
// <random> is not async-signal-safe, fake it with time(NULL) instead
char const* getRandomMessage() {
return MESSAGES[time(NULL) % (sizeof(MESSAGES) / sizeof(MESSAGES[0]))];
}
std::random_device dev;
std::mt19937 engine(dev());
std::uniform_int_distribution<> distribution(0, MESSAGES.size() - 1);
return MESSAGES[distribution(engine)];
[[noreturn]] inline void exit_with_error(char const* err) {
write(STDERR_FILENO, err, strlen(err));
// perror() is not signal-safe, but we use it here
// because if the crash-handler already crashed, it can't get any worse.
perror("");
abort();
}
void CrashReporter::createAndSaveCrash(int sig) {
int reportFd;
// get the backtrace
const int PID = getpid();
// We're in the signal handler, so we *only* have stack memory.
// To save as much stack memory as possible,
// destroy things as soon as possible.
{
MaxLengthCString<255> reportPath;
std::string finalCrashReport = "";
const auto HOME = sig_getenv("HOME");
const auto CACHE_HOME = sig_getenv("XDG_CACHE_HOME");
if (CACHE_HOME && CACHE_HOME[0] != '\0') {
reportPath += CACHE_HOME;
reportPath += "/hyprland";
} else if (HOME && HOME[0] != '\0') {
reportPath += HOME;
reportPath += "/.cache/hyprland";
} else {
exit_with_error("$CACHE_HOME and $HOME not set, nowhere to report crash\n");
return;
}
int ret = mkdir(reportPath.get_str(), S_IRWXU);
//__asm__("int $3");
if (ret < 0 && errno != EEXIST) {
exit_with_error("failed to mkdir() crash report directory\n");
}
reportPath += "/hyprlandCrashReport";
reportPath.write_num(getpid());
reportPath += ".txt";
{
BufFileWriter<64> stderr(2);
stderr += "Hyprland has crashed :( Consult the crash report at ";
if (!reportPath.boundsExceeded()) {
stderr += reportPath.get_str();
} else {
stderr += "[ERROR: Crash report path does not fit into memory! Check if your $CACHE_HOME/$HOME is too deeply nested. Max 255 characters.]";
}
stderr += " for more information.\n";
stderr.flush();
}
reportFd = open(reportPath.get_str(), O_WRONLY | O_CREAT, S_IRWXU);
if (reportFd < 0) {
exit_with_error("Failed to open crash report path for writing");
}
}
BufFileWriter<512> finalCrashReport(reportFd);
finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n";
finalCrashReport += getRandomMessage() + "\n\n";
finalCrashReport += getRandomMessage();
finalCrashReport += "\n\n";
finalCrashReport += std::format("Hyprland received signal {} ({})\n\n", sig, (const char*)strsignal(sig));
finalCrashReport += "Hyprland received signal ";
finalCrashReport.writeNum(sig);
finalCrashReport += '(';
finalCrashReport += sig_strsignal(sig);
finalCrashReport += ")\nVersion: ";
finalCrashReport += GIT_COMMIT_HASH;
finalCrashReport += "\nTag: ";
finalCrashReport += GIT_TAG;
finalCrashReport += "\n\n";
finalCrashReport += std::format("Version: {}\nTag: {}\n\n", GIT_COMMIT_HASH, GIT_TAG);
if (g_pPluginSystem && !g_pPluginSystem->getAllPlugins().empty()) {
if (g_pPluginSystem && g_pPluginSystem->pluginCount() > 0) {
finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n";
for (auto& p : g_pPluginSystem->getAllPlugins()) {
finalCrashReport += std::format("\t{} ({}) {}\n", p->name, p->author, p->version);
size_t count = g_pPluginSystem->pluginCount();
CPlugin* plugins[count];
g_pPluginSystem->sig_getPlugins(plugins, count);
for (size_t i = 0; i < count; i++) {
auto p = plugins[i];
finalCrashReport += '\t';
finalCrashReport += p->name;
finalCrashReport += " (";
finalCrashReport += p->author;
finalCrashReport += ") ";
finalCrashReport += p->version;
finalCrashReport += '\n';
}
finalCrashReport += "\n\n";
@@ -61,21 +129,36 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "System info:\n";
struct utsname unameInfo;
uname(&unameInfo);
{
struct utsname unameInfo;
uname(&unameInfo);
finalCrashReport += std::format("\tSystem name: {}\n\tNode name: {}\n\tRelease: {}\n\tVersion: {}\n\n", std::string{unameInfo.sysname}, std::string{unameInfo.nodename},
std::string{unameInfo.release}, std::string{unameInfo.version});
finalCrashReport += "\tSystem name: ";
finalCrashReport += unameInfo.sysname;
finalCrashReport += "\n\tNode name: ";
finalCrashReport += unameInfo.nodename;
finalCrashReport += "\n\tRelease: ";
finalCrashReport += unameInfo.release;
finalCrashReport += "\n\tVersion: ";
finalCrashReport += unameInfo.version;
finalCrashReport += "\n\n";
}
finalCrashReport += "GPU:\n\t";
#if defined(__DragonFly__) || defined(__FreeBSD__)
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
finalCrashReport.writeCmdOutput("pciconf -lv | fgrep -A4 vga");
#else
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
finalCrashReport.writeCmdOutput("lspci -vnn | grep VGA");
#endif
finalCrashReport += "GPU:\n\t" + GPUINFO;
finalCrashReport += "\n\nos-release:\n";
finalCrashReport.writeCmdOutput("cat /etc/os-release | sed 's/^/\t/'");
finalCrashReport += std::format("\n\nos-release:\n\t{}\n\n\n", replaceInString(execAndGet("cat /etc/os-release"), "\n", "\n\t"));
// dladdr1()/backtrace_symbols()/this entire section allocates, and hence is NOT async-signal-safe.
// Make sure that we save the current known crash report information,
// so that if we are caught in a deadlock during a call to malloc(),
// there is still something to debug from.
finalCrashReport.flush();
finalCrashReport += "Backtrace:\n";
@@ -108,18 +191,23 @@ void CrashReporter::createAndSaveCrash(int sig) {
std::string addrs = "";
for (size_t i = 0; i < CALLSTACK.size(); ++i) {
#ifdef __GLIBC__
// convert in memory address to VMA address
Dl_info info;
struct link_map* linkMap;
dladdr1((void*)CALLSTACK[i].adr, &info, (void**)&linkMap, RTLD_DL_LINKMAP);
size_t vmaAddr = (size_t)CALLSTACK[i].adr - linkMap->l_addr;
#else
// musl doesn't define dladdr1
size_t vmaAddr = (size_t)CALLSTACK[i].adr;
#endif
addrs += std::format("0x{:x} ", vmaAddr);
}
#ifdef __clang__
const auto CMD = std::format("llvm-addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
#else
const auto CMD = std::format("addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
const auto CMD = std::format("addr2line -e {} -Cf {}", FPATH.c_str(), addrs);
#endif
const auto ADDR2LINE = execAndGet(CMD.c_str());
@@ -127,7 +215,10 @@ void CrashReporter::createAndSaveCrash(int sig) {
std::stringstream ssin(ADDR2LINE);
for (size_t i = 0; i < CALLSTACK.size(); ++i) {
finalCrashReport += std::format("\t#{} | {}", i, CALLSTACK[i].desc);
finalCrashReport += "\t#";
finalCrashReport.writeNum(i);
finalCrashReport += " | ";
finalCrashReport += CALLSTACK[i].desc;
std::string functionInfo;
std::string fileLineInfo;
std::getline(ssin, functionInfo);
@@ -137,32 +228,5 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "\n\nLog tail:\n";
finalCrashReport += Debug::rollingLog.substr(Debug::rollingLog.find("\n") + 1);
const auto HOME = getenv("HOME");
const auto CACHE_HOME = getenv("XDG_CACHE_HOME");
if (!HOME)
return;
std::ofstream ofs;
std::string reportDir;
if (!CACHE_HOME || std::string(CACHE_HOME).empty())
reportDir = std::string(HOME) + "/.cache/hyprland";
else
reportDir = std::string(CACHE_HOME) + "/hyprland";
if (!std::filesystem::exists(reportDir))
std::filesystem::create_directory(reportDir);
const auto path = reportDir + "/hyprlandCrashReport" + std::to_string(PID) + ".txt";
ofs.open(path, std::ios::trunc);
ofs << finalCrashReport;
ofs.close();
Debug::disableStdout = false;
Debug::log(CRIT, "Hyprland has crashed :( Consult the crash report at {} for more information.", path);
finalCrashReport += std::string_view(Debug::rollingLog).substr(Debug::rollingLog.find("\n") + 1);
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,18 +8,25 @@
class CHyprCtl {
public:
CHyprCtl();
~CHyprCtl();
std::string makeDynamicCall(const std::string& input);
std::shared_ptr<SHyprCtlCommand> registerCommand(SHyprCtlCommand cmd);
void unregisterCommand(const std::shared_ptr<SHyprCtlCommand>& cmd);
std::string getReply(std::string);
std::string makeDynamicCall(const std::string& input);
SP<SHyprCtlCommand> registerCommand(SHyprCtlCommand cmd);
void unregisterCommand(const SP<SHyprCtlCommand>& cmd);
std::string getReply(std::string);
int m_iSocketFD = -1;
int m_iSocketFD = -1;
struct {
bool all = false;
bool sysInfoConfig = false;
} m_sCurrentRequestParams;
private:
void startHyprCtlSocket();
void startHyprCtlSocket();
std::vector<std::shared_ptr<SHyprCtlCommand>> m_vCommands;
std::vector<SP<SHyprCtlCommand>> m_vCommands;
wl_event_source* m_eventSource = nullptr;
};
inline std::unique_ptr<CHyprCtl> g_pHyprCtl;
inline std::unique_ptr<CHyprCtl> g_pHyprCtl;

View File

@@ -1,6 +1,12 @@
#include <pango/pangocairo.h>
#include "HyprDebugOverlay.hpp"
#include "config/ConfigValue.hpp"
#include "../Compositor.hpp"
CHyprDebugOverlay::CHyprDebugOverlay() {
m_pTexture = makeShared<CTexture>();
}
void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_dLastRenderTimes.push_back(µs / 1000.f);
@@ -33,7 +39,7 @@ void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
m_pMonitor = pMonitor;
// anim data too
const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor : g_pCompositor->m_pLastMonitor;
const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor : g_pCompositor->m_pLastMonitor.get();
if (PMONITORFORTICKS) {
if (m_dLastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->refreshRate)
m_dLastAnimationTicks.pop_front();
@@ -47,11 +53,6 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
if (!m_pMonitor)
return 0;
int yOffset = offset;
cairo_text_extents_t cairoExtents;
float maxX = 0;
std::string text = "";
// get avg fps
float avgFrametime = 0;
float maxFrametime = 0;
@@ -105,23 +106,49 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
float varAnimMgrTick = maxAnimMgrTick - minAnimMgrTick;
avgAnimMgrTick /= m_dLastAnimationTicks.size() == 0 ? 1 : m_dLastAnimationTicks.size();
const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
const float idealFPS = m_dLastFrametimes.size();
const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
const float idealFPS = m_dLastFrametimes.size();
cairo_select_font_face(g_pDebugOverlay->m_pCairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
static auto fontFamily = CConfigValue<std::string>("misc:font_family");
PangoLayout* layoutText = pango_cairo_create_layout(g_pDebugOverlay->m_pCairo);
PangoFontDescription* pangoFD = pango_font_description_new();
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 10);
pango_font_description_set_family(pangoFD, (*fontFamily).c_str());
pango_font_description_set_style(pangoFD, PANGO_STYLE_NORMAL);
pango_font_description_set_weight(pangoFD, PANGO_WEIGHT_NORMAL);
float maxTextW = 0;
int fontSize = 0;
auto cr = g_pDebugOverlay->m_pCairo;
auto showText = [cr, layoutText, pangoFD, &maxTextW, &fontSize](const char* text, int size) {
if (fontSize != size) {
pango_font_description_set_absolute_size(pangoFD, size * PANGO_SCALE);
pango_layout_set_font_description(layoutText, pangoFD);
fontSize = size;
}
pango_layout_set_text(layoutText, text, -1);
pango_cairo_show_layout(cr, layoutText);
int textW = 0, textH = 0;
pango_layout_get_size(layoutText, &textW, &textH);
textW /= PANGO_SCALE;
textH /= PANGO_SCALE;
if (textW > maxTextW)
maxTextW = textW;
// move to next line
cairo_rel_move_to(cr, 0, fontSize + 1);
};
const int MARGIN_TOP = 8;
const int MARGIN_LEFT = 4;
cairo_move_to(cr, MARGIN_LEFT, MARGIN_TOP + offset);
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 1.f, 1.f, 1.f, 1.f);
yOffset += 10;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = m_pMonitor->szName;
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 16);
std::string text;
showText(m_pMonitor->szName.c_str(), 10);
if (FPS > idealFPS * 0.95f)
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 0.2f, 1.f, 0.2f, 1.f);
@@ -130,57 +157,35 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
else
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 1.f, 0.2f, 0.2f, 1.f);
yOffset += 17;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = std::format("{} FPS", (int)FPS);
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
showText(text.c_str(), 16);
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 10);
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 1.f, 1.f, 1.f, 1.f);
yOffset += 11;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = std::format("Avg Frametime: {:.2f}ms (var {:.2f}ms)", avgFrametime, varFrametime);
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
showText(text.c_str(), 10);
yOffset += 11;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = std::format("Avg Rendertime: {:.2f}ms (var {:.2f}ms)", avgRenderTime, varRenderTime);
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
showText(text.c_str(), 10);
yOffset += 11;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = std::format("Avg Rendertime (No Overlay): {:.2f}ms (var {:.2f}ms)", avgRenderTimeNoOverlay, varRenderTimeNoOverlay);
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
showText(text.c_str(), 10);
yOffset += 11;
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
text = std::format("Avg Anim Tick: {:.2f}ms (var {:.2f}ms) ({:.2f} TPS)", avgAnimMgrTick, varAnimMgrTick, 1.0 / (avgAnimMgrTick / 1000.0));
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
if (cairoExtents.width > maxX)
maxX = cairoExtents.width;
showText(text.c_str(), 10);
yOffset += 11;
pango_font_description_free(pangoFD);
g_object_unref(layoutText);
double posX = 0, posY = 0;
cairo_get_current_point(cr, &posX, &posY);
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset - 1, (int)maxX + 2,
yOffset - offset + 2};
m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x + MARGIN_LEFT - 1, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset + MARGIN_TOP - 1,
(int)maxTextW + 2, posY - offset - MARGIN_TOP + 2};
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
return yOffset - offset;
return posY - offset;
}
void CHyprDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
@@ -221,8 +226,8 @@ void CHyprDebugOverlay::draw() {
// copy the data to an OpenGL texture we have
const auto DATA = cairo_image_surface_get_data(m_pCairoSurface);
m_tTexture.allocate();
glBindTexture(GL_TEXTURE_2D, m_tTexture.m_iTexID);
m_pTexture->allocate();
glBindTexture(GL_TEXTURE_2D, m_pTexture->m_iTexID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -234,5 +239,5 @@ void CHyprDebugOverlay::draw() {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
CBox pMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f);
g_pHyprOpenGL->renderTexture(m_pTexture, &pMonBox, 1.f);
}

View File

@@ -31,6 +31,7 @@ class CHyprMonitorDebugOverlay {
class CHyprDebugOverlay {
public:
CHyprDebugOverlay();
void draw();
void renderData(CMonitor*, float µs);
void renderDataNoOverlay(CMonitor*, float µs);
@@ -42,7 +43,7 @@ class CHyprDebugOverlay {
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;
CTexture m_tTexture;
SP<CTexture> m_pTexture;
friend class CHyprMonitorDebugOverlay;
friend class CHyprRenderer;

View File

@@ -1,55 +1,66 @@
#include <numeric>
#include <pango/pangocairo.h>
#include "HyprNotificationOverlay.hpp"
#include "../Compositor.hpp"
#include <pango/pangocairo.h>
#include "../config/ConfigValue.hpp"
inline auto iconBackendFromLayout(PangoLayout* layout) {
// preference: Nerd > FontAwesome > text
auto eIconBackendChecks = std::array<eIconBackend, 2>{ICONS_BACKEND_NF, ICONS_BACKEND_FA};
for (auto iconID : eIconBackendChecks) {
auto iconsText = std::accumulate(ICONS_ARRAY[iconID].begin(), ICONS_ARRAY[iconID].end(), std::string());
pango_layout_set_text(layout, iconsText.c_str(), -1);
if (pango_layout_get_unknown_glyphs_count(layout) == 0)
return iconID;
}
return ICONS_BACKEND_NONE;
}
CHyprNotificationOverlay::CHyprNotificationOverlay() {
g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
if (m_dNotifications.size() == 0)
return;
g_pHyprRenderer->damageBox(&m_bLastDamage);
});
// check for the icon backend
std::string fonts = execAndGet("fc-list");
std::string fontsLower = fonts;
std::transform(fontsLower.begin(), fontsLower.end(), fontsLower.begin(), [&](char& i) { return std::tolower(i); });
size_t index = 0;
if (index = fontsLower.find("nerd"); index != std::string::npos) {
m_eIconBackend = ICONS_BACKEND_NF;
} else if (index = fontsLower.find("font awesome"); index != std::string::npos) {
m_eIconBackend = ICONS_BACKEND_FA;
} else if (index = fontsLower.find("fontawesome"); index != std::string::npos) {
m_eIconBackend = ICONS_BACKEND_FA;
} else {
return;
}
const auto LASTNEWLINE = fonts.find_last_of('\n', index);
const auto COLON = fonts.find(':', LASTNEWLINE);
const auto COMMA = fonts.find(',', COLON);
const auto NEWLINE = fonts.find('\n', COLON);
const auto LASTCHAR = COMMA < NEWLINE ? COMMA : NEWLINE;
m_szIconFontName = fonts.substr(COLON + 2, LASTCHAR - (COLON + 2));
m_pTexture = makeShared<CTexture>();
}
void CHyprNotificationOverlay::addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon) {
CHyprNotificationOverlay::~CHyprNotificationOverlay() {
if (m_pCairo)
cairo_destroy(m_pCairo);
if (m_pCairoSurface)
cairo_surface_destroy(m_pCairoSurface);
}
void CHyprNotificationOverlay::addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon, const float fontSize) {
const auto PNOTIF = m_dNotifications.emplace_back(std::make_unique<SNotification>()).get();
PNOTIF->text = text;
PNOTIF->color = color == CColor(0) ? ICONS_COLORS[icon] : color;
PNOTIF->started.reset();
PNOTIF->timeMs = timeMs;
PNOTIF->icon = icon;
PNOTIF->timeMs = timeMs;
PNOTIF->icon = icon;
PNOTIF->fontSize = fontSize;
for (auto& m : g_pCompositor->m_vMonitors) {
g_pCompositor->scheduleFrameForMonitor(m.get());
}
}
void CHyprNotificationOverlay::dismissNotifications(const int amount) {
if (amount == -1)
m_dNotifications.clear();
else {
const int AMT = std::min(amount, static_cast<int>(m_dNotifications.size()));
for (int i = 0; i < AMT; ++i) {
m_dNotifications.pop_front();
}
}
}
CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
static constexpr auto ANIM_DURATION_MS = 600.0;
static constexpr auto ANIM_LAG_MS = 100.0;
@@ -61,28 +72,24 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
float offsetY = 10;
float maxWidth = 0;
const auto SCALE = pMonitor->scale;
const auto FONTSIZE = std::clamp((int)(13.f * ((pMonitor->vecPixelSize.x * SCALE) / 1920.f)), 8, 40);
const auto SCALE = pMonitor->scale;
const auto MONSIZE = pMonitor->vecTransformedSize;
const auto MONSIZE = pMonitor->vecPixelSize;
static auto fontFamily = CConfigValue<std::string>("misc:font_family");
cairo_text_extents_t cairoExtents;
int iconW = 0, iconH = 0;
PangoLayout* layout = pango_cairo_create_layout(m_pCairo);
PangoFontDescription* pangoFD = pango_font_description_new();
PangoLayout* pangoLayout;
PangoFontDescription* pangoFD;
pango_font_description_set_family(pangoFD, (*fontFamily).c_str());
pango_font_description_set_style(pangoFD, PANGO_STYLE_NORMAL);
pango_font_description_set_weight(pangoFD, PANGO_WEIGHT_NORMAL);
pangoLayout = pango_cairo_create_layout(m_pCairo);
pangoFD = pango_font_description_from_string(("Sans " + std::to_string(FONTSIZE * ICON_SCALE)).c_str());
pango_layout_set_font_description(pangoLayout, pangoFD);
cairo_select_font_face(m_pCairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(m_pCairo, FONTSIZE);
const auto PBEZIER = g_pAnimationManager->getBezier("default");
const auto iconBackendID = iconBackendFromLayout(layout);
const auto PBEZIER = g_pAnimationManager->getBezier("default");
for (auto& notif : m_dNotifications) {
const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD;
const auto FONTSIZE = std::clamp((int)(notif->fontSize * ((pMonitor->vecPixelSize.x * SCALE) / 1920.f)), 8, 40);
// first rect (bg, col)
const float FIRSTRECTANIMP =
@@ -105,31 +112,37 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
const float THIRDRECTPERC = notif->started.getMillis() / notif->timeMs;
// get text size
cairo_text_extents(m_pCairo, notif->text.c_str(), &cairoExtents);
const auto ICON = ICONS_ARRAY[m_eIconBackend][notif->icon];
const auto ICON = ICONS_ARRAY[iconBackendID][notif->icon];
const auto ICONCOLOR = ICONS_COLORS[notif->icon];
pango_layout_set_text(pangoLayout, ICON.c_str(), -1);
pango_layout_set_font_description(pangoLayout, pangoFD);
pango_cairo_update_layout(m_pCairo, pangoLayout);
pango_layout_get_size(pangoLayout, &iconW, &iconH);
int iconW = 0, iconH = 0;
pango_font_description_set_absolute_size(pangoFD, PANGO_SCALE * FONTSIZE * ICON_SCALE);
pango_layout_set_font_description(layout, pangoFD);
pango_layout_set_text(layout, ICON.c_str(), -1);
pango_layout_get_size(layout, &iconW, &iconH);
iconW /= PANGO_SCALE;
iconH /= PANGO_SCALE;
cairo_set_source_rgba(m_pCairo, notif->color.r, notif->color.g, notif->color.b, notif->color.a);
int textW = 0, textH = 0;
pango_font_description_set_absolute_size(pangoFD, PANGO_SCALE * FONTSIZE);
pango_layout_set_font_description(layout, pangoFD);
pango_layout_set_text(layout, notif->text.c_str(), -1);
pango_layout_get_size(layout, &textW, &textH);
textW /= PANGO_SCALE;
textH /= PANGO_SCALE;
const auto NOTIFSIZE = Vector2D{cairoExtents.width + 20 + iconW + 2 * ICONPADFORNOTIF, cairoExtents.height + 10};
const auto NOTIFSIZE = Vector2D{textW + 20 + iconW + 2 * ICONPADFORNOTIF, textH + 10};
// draw rects
cairo_set_source_rgba(m_pCairo, notif->color.r, notif->color.g, notif->color.b, notif->color.a);
cairo_rectangle(m_pCairo, MONSIZE.x - (NOTIFSIZE.x + NOTIF_LEFTBAR_SIZE) * FIRSTRECTPERC, offsetY, (NOTIFSIZE.x + NOTIF_LEFTBAR_SIZE) * FIRSTRECTPERC, NOTIFSIZE.y);
cairo_fill(m_pCairo);
cairo_set_source_rgb(m_pCairo, 0.f, 0.f, 0.f);
cairo_rectangle(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC, offsetY, NOTIFSIZE.x * SECONDRECTPERC, NOTIFSIZE.y);
cairo_fill(m_pCairo);
cairo_set_source_rgba(m_pCairo, notif->color.r, notif->color.g, notif->color.b, notif->color.a);
cairo_rectangle(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC + 3, offsetY + NOTIFSIZE.y - 4, THIRDRECTPERC * (NOTIFSIZE.x - 6), 2);
cairo_fill(m_pCairo);
@@ -147,15 +160,16 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
// draw icon
cairo_set_source_rgb(m_pCairo, 1.f, 1.f, 1.f);
cairo_move_to(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC + NOTIF_LEFTBAR_SIZE + ICONPADFORNOTIF - 1, offsetY + std::round((NOTIFSIZE.y - iconH - 4) / 2.0));
pango_cairo_show_layout(m_pCairo, pangoLayout);
cairo_move_to(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC + NOTIF_LEFTBAR_SIZE + ICONPADFORNOTIF - 1, offsetY - 2 + std::round((NOTIFSIZE.y - iconH) / 2.0));
pango_layout_set_text(layout, ICON.c_str(), -1);
pango_cairo_show_layout(m_pCairo, layout);
}
// draw text
cairo_set_font_size(m_pCairo, FONTSIZE);
cairo_set_source_rgb(m_pCairo, 1.f, 1.f, 1.f);
cairo_move_to(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC + NOTIF_LEFTBAR_SIZE + iconW + 2 * ICONPADFORNOTIF, offsetY + FONTSIZE + (FONTSIZE / 10.0));
cairo_show_text(m_pCairo, notif->text.c_str());
cairo_move_to(m_pCairo, MONSIZE.x - NOTIFSIZE.x * SECONDRECTPERC + NOTIF_LEFTBAR_SIZE + iconW + 2 * ICONPADFORNOTIF, offsetY - 2 + std::round((NOTIFSIZE.y - textH) / 2.0));
pango_layout_set_text(layout, notif->text.c_str(), -1);
pango_cairo_show_layout(m_pCairo, layout);
// adjust offset and move on
offsetY += NOTIFSIZE.y + 10;
@@ -165,7 +179,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
}
pango_font_description_free(pangoFD);
g_object_unref(pangoLayout);
g_object_unref(layout);
// cleanup notifs
std::erase_if(m_dNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
@@ -175,16 +189,19 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
if (m_pLastMonitor != pMonitor || !m_pCairo || !m_pCairoSurface) {
const auto MONSIZE = pMonitor->vecTransformedSize;
if (m_pLastMonitor != pMonitor || m_vecLastSize != MONSIZE || !m_pCairo || !m_pCairoSurface) {
if (m_pCairo && m_pCairoSurface) {
cairo_destroy(m_pCairo);
cairo_surface_destroy(m_pCairoSurface);
}
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, MONSIZE.x, MONSIZE.y);
m_pCairo = cairo_create(m_pCairoSurface);
m_pLastMonitor = pMonitor;
m_vecLastSize = MONSIZE;
}
// Draw the notifications
@@ -212,8 +229,8 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
// copy the data to an OpenGL texture we have
const auto DATA = cairo_image_surface_get_data(m_pCairoSurface);
m_tTexture.allocate();
glBindTexture(GL_TEXTURE_2D, m_tTexture.m_iTexID);
m_pTexture->allocate();
glBindTexture(GL_TEXTURE_2D, m_pTexture->m_iTexID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -222,12 +239,12 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
#endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, MONSIZE.x, MONSIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
CBox pMonBox = {0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y};
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 1.f);
CBox pMonBox = {0, 0, MONSIZE.x, MONSIZE.y};
g_pHyprOpenGL->renderTexture(m_pTexture, &pMonBox, 1.f);
}
bool CHyprNotificationOverlay::hasAny() {
return !m_dNotifications.empty();
}
}

View File

@@ -31,16 +31,19 @@ struct SNotification {
std::string text = "";
CColor color;
CTimer started;
float timeMs = 0;
eIcons icon = ICON_NONE;
float timeMs = 0;
eIcons icon = ICON_NONE;
float fontSize = 13.f;
};
class CHyprNotificationOverlay {
public:
CHyprNotificationOverlay();
~CHyprNotificationOverlay();
void draw(CMonitor* pMonitor);
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE);
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f);
void dismissNotifications(const int amount);
bool hasAny();
private:
@@ -53,11 +56,9 @@ class CHyprNotificationOverlay {
cairo_t* m_pCairo = nullptr;
CMonitor* m_pLastMonitor = nullptr;
Vector2D m_vecLastSize = Vector2D(-1, -1);
CTexture m_tTexture;
eIconBackend m_eIconBackend = ICONS_BACKEND_NONE;
std::string m_szIconFontName = "Sans";
SP<CTexture> m_pTexture;
};
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;

View File

@@ -6,7 +6,7 @@
#include <iostream>
void Debug::init(const std::string& IS) {
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
logFile = IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
}
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
@@ -32,3 +32,57 @@ void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
if (!disableStdout)
std::cout << output << "\n";
}
void Debug::log(LogLevel level, std::string str) {
if (level == TRACE && !trace)
return;
if (shuttingDown)
return;
std::string coloredStr = str;
switch (level) {
case LOG:
str = "[LOG] " + str;
coloredStr = str;
break;
case WARN:
str = "[WARN] " + str;
coloredStr = "\033[1;33m" + str + "\033[0m"; // yellow
break;
case ERR:
str = "[ERR] " + str;
coloredStr = "\033[1;31m" + str + "\033[0m"; // red
break;
case CRIT:
str = "[CRITICAL] " + str;
coloredStr = "\033[1;35m" + str + "\033[0m"; // magenta
break;
case INFO:
str = "[INFO] " + str;
coloredStr = "\033[1;32m" + str + "\033[0m"; // green
break;
case TRACE:
str = "[TRACE] " + str;
coloredStr = "\033[1;34m" + str + "\033[0m"; // blue
break;
default: break;
}
rollingLog += str + "\n";
if (rollingLog.size() > ROLLING_LOG_SIZE)
rollingLog = rollingLog.substr(rollingLog.size() - ROLLING_LOG_SIZE);
if (!disableLogs || !**disableLogs) {
// log to a file
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
ofs << str << "\n";
ofs.close();
}
// log it to the stdout too.
if (!disableStdout)
std::cout << ((coloredLogs && !**coloredLogs) ? str : coloredStr) << "\n";
}

View File

@@ -27,10 +27,15 @@ namespace Debug {
inline bool disableStdout = false;
inline bool trace = false;
inline bool shuttingDown = false;
inline int64_t* const* coloredLogs = nullptr;
inline std::string rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
void init(const std::string& IS);
//
void log(LogLevel level, std::string str);
template <typename... Args>
void log(LogLevel level, std::format_string<Args...> fmt, Args&&... args) {
if (level == TRACE && !trace)
@@ -41,25 +46,16 @@ namespace Debug {
std::string logMsg = "";
switch (level) {
case LOG: logMsg += "[LOG] "; break;
case WARN: logMsg += "[WARN] "; break;
case ERR: logMsg += "[ERR] "; break;
case CRIT: logMsg += "[CRITICAL] "; break;
case INFO: logMsg += "[INFO] "; break;
case TRACE: logMsg += "[TRACE] "; break;
default: break;
}
// print date and time to the ofs
if (disableTime && !**disableTime) {
#ifndef _LIBCPP_VERSION
logMsg += std::format("[{:%T}] ", std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())});
const auto zt = std::chrono::zoned_time{std::chrono::current_zone(), std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
#else
auto c = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
logMsg += std::format("{:%H}:{:%M}:{:%S}", c.hours(), c.minutes(), c.subseconds());
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
#endif
logMsg += std::format("[{}] ", hms);
}
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
@@ -69,22 +65,7 @@ namespace Debug {
// 3. this is actually what std::format in stdlib does
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
rollingLog += logMsg + "\n";
if (rollingLog.size() > ROLLING_LOG_SIZE)
rollingLog = rollingLog.substr(rollingLog.size() - ROLLING_LOG_SIZE);
if (!disableLogs || !**disableLogs) {
// log to a file
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
ofs << logMsg << "\n";
ofs.close();
}
// log it to the stdout too.
if (!disableStdout)
std::cout << logMsg << "\n";
log(level, logMsg);
}
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);

View File

@@ -3,3 +3,4 @@
#include "helpers/WLListener.hpp"
#include "helpers/Color.hpp"
#include "macros.hpp"
#include "desktop/DesktopTypes.hpp"

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../macros.hpp"
class CWorkspace;
class CWindow;
class CLayerSurface;
/* Shared pointer to a workspace */
typedef SP<CWorkspace> PHLWORKSPACE;
/* Weak pointer to a workspace */
typedef WP<CWorkspace> PHLWORKSPACEREF;
/* Shared pointer to a window */
typedef SP<CWindow> PHLWINDOW;
/* Weak pointer to a window */
typedef WP<CWindow> PHLWINDOWREF;
/* Shared pointer to a layer surface */
typedef SP<CLayerSurface> PHLLS;
/* Weak pointer to a layer surface */
typedef WP<CLayerSurface> PHLLSREF;

View File

@@ -0,0 +1,515 @@
#include "LayerSurface.hpp"
#include "../Compositor.hpp"
#include "../events/Events.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../managers/SeatManager.hpp"
PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource));
CMonitor* pMonitor = resource->monitor.empty() ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->getMonitorFromName(resource->monitor);
pLS->surface->assign(resource->surface.lock(), pLS);
if (!pMonitor) {
Debug::log(ERR, "New LS has no monitor??");
return pLS;
}
if (pMonitor->pMirrorOf)
pMonitor = g_pCompositor->m_vMonitors.front().get();
pLS->self = pLS;
pLS->szNamespace = resource->layerNamespace;
pLS->layer = resource->current.layer;
pLS->popupHead = std::make_unique<CPopup>(pLS);
pLS->monitorID = pMonitor->ID;
pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS);
pLS->forceBlur = g_pConfigManager->shouldBlurLS(pLS->szNamespace);
pLS->alpha.create(g_pConfigManager->getAnimationPropertyConfig("fadeLayersIn"), pLS, AVARDAMAGE_ENTIRE);
pLS->realPosition.create(g_pConfigManager->getAnimationPropertyConfig("layersIn"), pLS, AVARDAMAGE_ENTIRE);
pLS->realSize.create(g_pConfigManager->getAnimationPropertyConfig("layersIn"), pLS, AVARDAMAGE_ENTIRE);
pLS->alpha.registerVar();
pLS->realPosition.registerVar();
pLS->realSize.registerVar();
pLS->registerCallbacks();
pLS->alpha.setValueAndWarp(0.f);
Debug::log(LOG, "LayerSurface {:x} (namespace {} layer {}) created on monitor {}", (uintptr_t)resource.get(), resource->layerNamespace, (int)pLS->layer, pMonitor->szName);
return pLS;
}
void CLayerSurface::registerCallbacks() {
alpha.setUpdateCallback([this](void*) {
if (dimAround)
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(monitorID));
});
}
CLayerSurface::CLayerSurface(SP<CLayerShellResource> resource_) : layerSurface(resource_) {
listeners.commit = layerSurface->events.commit.registerListener([this](std::any d) { onCommit(); });
listeners.map = layerSurface->events.map.registerListener([this](std::any d) { onMap(); });
listeners.unmap = layerSurface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
listeners.destroy = layerSurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
surface = CWLSurface::create();
}
CLayerSurface::~CLayerSurface() {
if (!g_pHyprOpenGL)
return;
if (surface)
surface->unassign();
g_pHyprRenderer->makeEGLCurrent();
std::erase_if(g_pHyprOpenGL->m_mLayerFramebuffers, [&](const auto& other) { return other.first.expired() || other.first.lock() == self.lock(); });
}
void CLayerSurface::onDestroy() {
Debug::log(LOG, "LayerSurface {:x} destroyed", (uintptr_t)layerSurface);
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
if (!g_pCompositor->getMonitorFromID(monitorID))
Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)");
if (!fadingOut) {
if (mapped) {
Debug::log(LOG, "Forcing an unmap of a LS that did a straight destroy!");
onUnmap();
} else {
Debug::log(LOG, "Removing LayerSurface that wasn't mapped.");
alpha.setValueAndWarp(0.f);
fadingOut = true;
g_pCompositor->addToFadingOutSafe(self.lock());
}
}
popupHead.reset();
noProcess = true;
// rearrange to fix the reserved areas
if (PMONITOR) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
PMONITOR->scheduledRecalc = true;
// and damage
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
}
readyToDelete = true;
layerSurface.reset();
if (surface)
surface->unassign();
}
void CLayerSurface::onMap() {
Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)layerSurface);
mapped = true;
keyboardExclusive = layerSurface->current.interactivity;
// fix if it changed its mon
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
if (!PMONITOR)
return;
applyRules();
PMONITOR->scheduledRecalc = true;
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
surface->resource()->enter(PMONITOR->self.lock());
if (layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
g_pInputManager->m_dExclusiveLSes.push_back(self);
const bool GRABSFOCUS = layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE &&
// don't focus if constrained
(g_pSeatManager->mouse.expired() || !g_pInputManager->isConstrained());
if (GRABSFOCUS) {
// TODO: use the new superb really very cool grab
g_pSeatManager->setGrab(nullptr);
g_pInputManager->releaseAllMouseButtons();
g_pCompositor->focusSurface(surface->resource());
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y);
g_pSeatManager->setPointerFocus(surface->resource(), LOCAL);
g_pInputManager->m_bEmptyFocusCursorSet = false;
}
position = Vector2D(geometry.x, geometry.y);
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
const auto WORKSPACE = PMONITOR->activeWorkspace;
const bool FULLSCREEN = WORKSPACE->m_bHasFullscreenWindow && WORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
startAnimation(!(layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS));
readyToDelete = false;
fadingOut = false;
g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", szNamespace});
EMIT_HOOK_EVENT("openLayer", self.lock());
g_pCompositor->setPreferredScaleForSurface(surface->resource(), PMONITOR->scale);
g_pCompositor->setPreferredTransformForSurface(surface->resource(), PMONITOR->transform);
}
void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)layerSurface);
g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", layerSurface->layerNamespace});
EMIT_HOOK_EVENT("closeLayer", self.lock());
std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });
if (!g_pInputManager->m_dExclusiveLSes.empty())
g_pCompositor->focusSurface(g_pInputManager->m_dExclusiveLSes[0]->surface->resource());
if (!g_pCompositor->getMonitorFromID(monitorID) || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(self.lock());
mapped = false;
startAnimation(false);
return;
}
// make a snapshot and start fade
g_pHyprOpenGL->makeLayerSnapshot(self.lock());
startAnimation(false);
mapped = false;
g_pCompositor->addToFadingOutSafe(self.lock());
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
const bool WASLASTFOCUS = g_pCompositor->m_pLastFocus == surface->resource();
surface.reset();
if (!PMONITOR)
return;
// refocus if needed
if (WASLASTFOCUS) {
g_pInputManager->releaseAllMouseButtons();
Vector2D surfaceCoords;
PHLLS pFoundLayerSurface;
SP<CWLSurfaceResource> foundSurface = nullptr;
g_pCompositor->m_pLastFocus.reset();
// find LS-es to focus
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
&surfaceCoords, &pFoundLayerSurface);
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
&surfaceCoords, &pFoundLayerSurface);
if (!foundSurface && g_pCompositor->m_pLastWindow.lock() && g_pCompositor->isWorkspaceVisible(g_pCompositor->m_pLastWindow->m_pWorkspace)) {
// if there isn't any, focus the last window
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock();
g_pCompositor->focusWindow(nullptr);
g_pCompositor->focusWindow(PLASTWINDOW);
} else {
// otherwise, full refocus
g_pInputManager->refocus();
}
}
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
geomFixed = {geometry.x + (int)PMONITOR->vecPosition.x, geometry.y + (int)PMONITOR->vecPosition.y, (int)layerSurface->surface->current.size.x,
(int)layerSurface->surface->current.size.y};
g_pHyprRenderer->damageBox(&geomFixed);
g_pInputManager->sendMotionEventsToFocused();
}
void CLayerSurface::onCommit() {
if (!layerSurface)
return;
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
if (!PMONITOR)
return;
if (layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
CBox geomFixed = {geometry.x, geometry.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
if (layerSurface->current.committed != 0) {
if (layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_LAYER) {
for (auto it = PMONITOR->m_aLayerSurfaceLayers[layer].begin(); it != PMONITOR->m_aLayerSurfaceLayers[layer].end(); it++) {
if (*it == self) {
if (layerSurface->current.layer == layer)
break;
PMONITOR->m_aLayerSurfaceLayers[layerSurface->current.layer].emplace_back(*it);
PMONITOR->m_aLayerSurfaceLayers[layer].erase(it);
break;
}
}
layer = layerSurface->current.layer;
if (layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
}
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
PMONITOR->scheduledRecalc = true;
} else {
position = Vector2D(geometry.x, geometry.y);
// update geom if it changed
if (layerSurface->surface->current.scale == 1 && PMONITOR->scale != 1.f && layerSurface->surface->current.viewport.hasDestination) {
// fractional scaling. Dirty hack.
geometry = {geometry.pos(), layerSurface->surface->current.viewport.destination};
} else {
// this is because some apps like e.g. rofi-lbonn can't fucking use the protocol correctly.
geometry = {geometry.pos(), layerSurface->surface->current.size};
}
}
if (realPosition.goal() != geometry.pos()) {
if (realPosition.isBeingAnimated())
realPosition = geometry.pos();
else
realPosition.setValueAndWarp(geometry.pos());
}
if (realSize.goal() != geometry.size()) {
if (realSize.isBeingAnimated())
realSize = geometry.size();
else
realSize.setValueAndWarp(geometry.size());
}
if (layerSurface->current.interactivity && (g_pSeatManager->mouse.expired() || !g_pInputManager->isConstrained()) // don't focus if constrained
&& !keyboardExclusive && mapped) {
g_pCompositor->focusSurface(surface->resource());
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y);
g_pSeatManager->setPointerFocus(surface->resource(), LOCAL);
g_pInputManager->m_bEmptyFocusCursorSet = false;
} else if (!layerSurface->current.interactivity && (g_pSeatManager->mouse.expired() || !g_pInputManager->isConstrained()) && keyboardExclusive) {
g_pInputManager->refocus();
}
keyboardExclusive = layerSurface->current.interactivity;
g_pHyprRenderer->damageSurface(surface->resource(), position.x, position.y);
g_pCompositor->setPreferredScaleForSurface(surface->resource(), PMONITOR->scale);
g_pCompositor->setPreferredTransformForSurface(surface->resource(), PMONITOR->transform);
}
void CLayerSurface::applyRules() {
noAnimations = false;
forceBlur = false;
ignoreAlpha = false;
ignoreAlphaValue = 0.f;
dimAround = false;
xray = -1;
animationStyle.reset();
for (auto& rule : g_pConfigManager->getMatchingRules(self.lock())) {
if (rule.rule == "noanim")
noAnimations = true;
else if (rule.rule == "blur")
forceBlur = true;
else if (rule.rule == "blurpopups")
forceBlurPopups = true;
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
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 == "dimaround") {
dimAround = true;
} else if (rule.rule.starts_with("xray")) {
CVarList vars{rule.rule, 0, ' '};
try {
xray = configStringToInt(vars[1]);
} catch (...) {}
} else if (rule.rule.starts_with("animation")) {
CVarList vars{rule.rule, 2, 's'};
animationStyle = vars[1];
}
}
}
void CLayerSurface::startAnimation(bool in, bool instant) {
const auto ANIMSTYLE = animationStyle.value_or(realPosition.m_pConfig->pValues->internalStyle);
if (in) {
realPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("layersIn");
realSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("layersIn");
alpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeLayersIn");
} else {
realPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("layersOut");
realSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("layersOut");
alpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeLayersOut");
}
if (ANIMSTYLE.starts_with("slide")) {
// get closest edge
const auto MIDDLE = geometry.middle();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(MIDDLE);
int force = -1;
CVarList args(ANIMSTYLE, 0, 's');
if (args.size() > 1) {
const auto ARG2 = args[1];
if (ARG2 == "top")
force = 0;
else if (ARG2 == "bottom")
force = 1;
else if (ARG2 == "left")
force = 2;
else if (ARG2 == "right")
force = 3;
}
const std::array<Vector2D, 4> edgePoints = {
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, 0},
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y},
PMONITOR->vecPosition + Vector2D{0, PMONITOR->vecSize.y},
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x, PMONITOR->vecSize.y / 2},
};
float closest = std::numeric_limits<float>::max();
int leader = force;
if (leader == -1) {
for (size_t i = 0; i < 4; ++i) {
float dist = MIDDLE.distance(edgePoints[i]);
if (dist < closest) {
leader = i;
closest = dist;
}
}
}
realSize.setValueAndWarp(geometry.size());
alpha.setValueAndWarp(in ? 0.f : 1.f);
alpha = in ? 1.f : 0.f;
Vector2D prePos;
switch (leader) {
case 0:
// TOP
prePos = {geometry.x, PMONITOR->vecPosition.y - geometry.h};
break;
case 1:
// BOTTOM
prePos = {geometry.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y};
break;
case 2:
// LEFT
prePos = {PMONITOR->vecPosition.x - geometry.w, geometry.y};
break;
case 3:
// RIGHT
prePos = {PMONITOR->vecPosition.x + PMONITOR->vecSize.x, geometry.y};
break;
default: UNREACHABLE();
}
if (in) {
realPosition.setValueAndWarp(prePos);
realPosition = geometry.pos();
} else {
realPosition.setValueAndWarp(geometry.pos());
realPosition = prePos;
}
} else if (ANIMSTYLE.starts_with("popin")) {
float minPerc = 0.f;
if (ANIMSTYLE.find("%") != std::string::npos) {
try {
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' '));
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) {
; // oops
}
}
minPerc *= 0.01;
const auto GOALSIZE = (geometry.size() * minPerc).clamp({5, 5});
const auto GOALPOS = geometry.pos() + (geometry.size() - GOALSIZE) / 2.f;
alpha.setValueAndWarp(in ? 0.f : 1.f);
alpha = in ? 1.f : 0.f;
if (in) {
realSize.setValueAndWarp(GOALSIZE);
realPosition.setValueAndWarp(GOALPOS);
realSize = geometry.size();
realPosition = geometry.pos();
} else {
realSize.setValueAndWarp(geometry.size());
realPosition.setValueAndWarp(geometry.pos());
realSize = GOALSIZE;
realPosition = GOALPOS;
}
} else {
// fade
realPosition.setValueAndWarp(geometry.pos());
realSize.setValueAndWarp(geometry.size());
alpha = in ? 1.f : 0.f;
}
if (!in)
fadingOut = true;
}
bool CLayerSurface::isFadedOut() {
if (!fadingOut)
return false;
return !realPosition.isBeingAnimated() && !realSize.isBeingAnimated() && !alpha.isBeingAnimated();
}
int CLayerSurface::popupsCount() {
if (!layerSurface || !mapped || fadingOut)
return 0;
int no = -1; // we have one dummy
popupHead->breadthfirst([](CPopup* p, void* data) { *(int*)data += 1; }, &no);
return no;
}

View File

@@ -0,0 +1,86 @@
#pragma once
#include <string>
#include "../defines.hpp"
#include "WLSurface.hpp"
#include "../helpers/AnimatedVariable.hpp"
struct SLayerRule {
std::string targetNamespace = "";
std::string rule = "";
};
class CLayerShellResource;
class CLayerSurface {
public:
static PHLLS create(SP<CLayerShellResource>);
private:
CLayerSurface(SP<CLayerShellResource>);
public:
~CLayerSurface();
void applyRules();
void startAnimation(bool in, bool instant = false);
bool isFadedOut();
int popupsCount();
CAnimatedVariable<Vector2D> realPosition;
CAnimatedVariable<Vector2D> realSize;
CAnimatedVariable<float> alpha;
WP<CLayerShellResource> layerSurface;
wl_list link;
bool keyboardExclusive = false;
SP<CWLSurface> surface;
bool mapped = false;
uint32_t layer = 0;
int monitorID = -1;
bool fadingOut = false;
bool readyToDelete = false;
bool noProcess = false;
bool noAnimations = false;
bool forceBlur = false;
bool forceBlurPopups = false;
int xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
bool dimAround = false;
std::optional<std::string> animationStyle;
PHLLSREF self;
CBox geometry = {0, 0, 0, 0};
Vector2D position;
std::string szNamespace = "";
std::unique_ptr<CPopup> popupHead;
void onDestroy();
void onMap();
void onUnmap();
void onCommit();
private:
struct {
CHyprSignalListener destroy;
CHyprSignalListener map;
CHyprSignalListener unmap;
CHyprSignalListener commit;
} listeners;
void registerCallbacks();
// For the list lookup
bool operator==(const CLayerSurface& rhs) const {
return layerSurface == rhs.layerSurface && monitorID == rhs.monitorID;
}
};

331
src/desktop/Popup.cpp Normal file
View File

@@ -0,0 +1,331 @@
#include "Popup.hpp"
#include "../config/ConfigValue.hpp"
#include "../Compositor.hpp"
#include "../protocols/LayerShell.hpp"
#include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include <ranges>
CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) {
initAllSignals();
}
CPopup::CPopup(PHLLS pOwner) : m_pLayerOwner(pOwner) {
initAllSignals();
}
CPopup::CPopup(SP<CXDGPopupResource> popup, CPopup* pOwner) : m_pParent(pOwner), m_pResource(popup) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(popup->surface->surface.lock(), this);
m_pLayerOwner = pOwner->m_pLayerOwner;
m_pWindowOwner = pOwner->m_pWindowOwner;
m_vLastSize = popup->surface->current.geometry.size();
unconstrain();
initAllSignals();
}
CPopup::~CPopup() {
if (m_pWLSurface)
m_pWLSurface->unassign();
}
void CPopup::initAllSignals() {
if (!m_pResource) {
if (!m_pWindowOwner.expired())
listeners.newPopup = m_pWindowOwner->m_pXDGSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else if (!m_pLayerOwner.expired())
listeners.newPopup = m_pLayerOwner->layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else
ASSERT(false);
return;
}
listeners.reposition = m_pResource->events.reposition.registerListener([this](std::any d) { this->onReposition(); });
listeners.map = m_pResource->surface->events.map.registerListener([this](std::any d) { this->onMap(); });
listeners.unmap = m_pResource->surface->events.unmap.registerListener([this](std::any d) { this->onUnmap(); });
listeners.dismissed = m_pResource->events.dismissed.registerListener([this](std::any d) { this->onUnmap(); });
listeners.destroy = m_pResource->surface->events.destroy.registerListener([this](std::any d) { this->onDestroy(); });
listeners.commit = m_pResource->surface->events.commit.registerListener([this](std::any d) { this->onCommit(); });
listeners.newPopup = m_pResource->surface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
}
void CPopup::onNewPopup(SP<CXDGPopupResource> popup) {
const auto POPUP = m_vChildren.emplace_back(std::make_unique<CPopup>(popup, this)).get();
Debug::log(LOG, "New popup at {:x}", (uintptr_t)POPUP);
}
void CPopup::onDestroy() {
m_bInert = true;
if (!m_pParent)
return; // head node
std::erase_if(m_pParent->m_vChildren, [this](const auto& other) { return other.get() == this; });
}
void CPopup::onMap() {
if (m_bMapped)
return;
m_bMapped = true;
m_vLastSize = m_pResource->surface->surface->current.size;
const auto COORDS = coordsGlobal();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
CBox box = m_pWLSurface->resource()->extends();
box.translate(COORDS).expand(4);
g_pHyprRenderer->damageBox(&box);
m_vLastPos = coordsRelativeToParent();
g_pInputManager->simulateMouseMovement();
m_pSubsurfaceHead = std::make_unique<CSubsurface>(this);
//unconstrain();
sendScale();
m_pResource->surface->surface->enter(PMONITOR->self.lock());
if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
}
void CPopup::onUnmap() {
if (!m_bMapped)
return;
if (!m_pResource || !m_pResource->surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and unmaps??");
onDestroy();
return;
}
m_vLastSize = m_pResource->surface->surface->current.size;
const auto COORDS = coordsGlobal();
CBox box = m_pWLSurface->resource()->extends();
box.translate(COORDS).expand(4);
g_pHyprRenderer->damageBox(&box);
m_pSubsurfaceHead.reset();
g_pInputManager->simulateMouseMovement();
if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
// damage all children
breadthfirst(
[](CPopup* p, void* data) {
if (!p->m_pResource)
return;
auto box = CBox{p->coordsGlobal(), p->size()};
g_pHyprRenderer->damageBox(&box);
},
nullptr);
}
void CPopup::onCommit(bool ignoreSiblings) {
if (!m_pResource || !m_pResource->surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and commits??");
onDestroy();
return;
}
if (m_pResource->surface->initialCommit) {
m_pResource->surface->scheduleConfigure();
return;
}
if (!m_pWindowOwner.expired() && (!m_pWindowOwner->m_bIsMapped || !m_pWindowOwner->m_pWorkspace->m_bVisible)) {
m_vLastSize = m_pResource->surface->surface->current.size;
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE)
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowOwner.lock());
return;
}
if (!m_pResource->surface->mapped)
return;
const auto COORDS = coordsGlobal();
const auto COORDSLOCAL = coordsRelativeToParent();
if (m_vLastSize != m_pResource->surface->surface->current.size || m_bRequestedReposition || m_vLastPos != COORDSLOCAL) {
CBox box = {localToGlobal(m_vLastPos), m_vLastSize};
g_pHyprRenderer->damageBox(&box);
m_vLastSize = m_pResource->surface->surface->current.size;
box = {COORDS, m_vLastSize};
g_pHyprRenderer->damageBox(&box);
m_vLastPos = COORDSLOCAL;
}
if (!ignoreSiblings && m_pSubsurfaceHead)
m_pSubsurfaceHead->recheckDamageForSubsurfaces();
g_pHyprRenderer->damageSurface(m_pWLSurface->resource(), COORDS.x, COORDS.y);
m_bRequestedReposition = false;
if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
}
void CPopup::onReposition() {
Debug::log(LOG, "Popup {:x} requests reposition", (uintptr_t)this);
m_bRequestedReposition = true;
m_vLastPos = coordsRelativeToParent();
unconstrain();
}
void CPopup::unconstrain() {
const auto COORDS = t1ParentCoords();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
if (!PMONITOR)
return;
CBox box = {PMONITOR->vecPosition.x - COORDS.x, PMONITOR->vecPosition.y - COORDS.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
m_pResource->applyPositioning(box, COORDS - PMONITOR->vecPosition);
}
Vector2D CPopup::coordsRelativeToParent() {
Vector2D offset;
if (!m_pResource)
return {};
CPopup* current = this;
offset -= current->m_pResource->surface->current.geometry.pos();
while (current->m_pParent && current->m_pResource) {
offset += current->m_pWLSurface->resource()->current.offset;
offset += current->m_pResource->geometry.pos();
current = current->m_pParent;
}
return offset;
}
Vector2D CPopup::coordsGlobal() {
return localToGlobal(coordsRelativeToParent());
}
Vector2D CPopup::localToGlobal(const Vector2D& rel) {
return t1ParentCoords() + rel;
}
Vector2D CPopup::t1ParentCoords() {
if (!m_pWindowOwner.expired())
return m_pWindowOwner->m_vRealPosition.value();
if (!m_pLayerOwner.expired())
return m_pLayerOwner->realPosition.value();
ASSERT(false);
return {};
}
void CPopup::recheckTree() {
CPopup* curr = this;
while (curr->m_pParent) {
curr = curr->m_pParent;
}
curr->recheckChildrenRecursive();
}
void CPopup::recheckChildrenRecursive() {
for (auto& c : m_vChildren) {
c->onCommit(true);
c->recheckChildrenRecursive();
}
}
Vector2D CPopup::size() {
return m_vLastSize;
}
void CPopup::sendScale() {
if (!m_pWindowOwner.expired())
g_pCompositor->setPreferredScaleForSurface(m_pWLSurface->resource(), m_pWindowOwner->m_pWLSurface->m_fLastScale);
else if (!m_pLayerOwner.expired())
g_pCompositor->setPreferredScaleForSurface(m_pWLSurface->resource(), m_pLayerOwner->surface->m_fLastScale);
else
UNREACHABLE();
}
bool CPopup::visible() {
if (!m_pWindowOwner.expired())
return g_pHyprRenderer->shouldRenderWindow(m_pWindowOwner.lock());
if (!m_pLayerOwner.expired())
return true;
if (m_pParent)
return m_pParent->visible();
return false;
}
void CPopup::bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data) {
for (auto& n : nodes) {
fn(n, data);
}
std::vector<CPopup*> nodes2;
for (auto& n : nodes) {
for (auto& c : n->m_vChildren) {
nodes2.push_back(c.get());
}
}
if (!nodes2.empty())
bfHelper(nodes2, fn, data);
}
void CPopup::breadthfirst(std::function<void(CPopup*, void*)> fn, void* data) {
std::vector<CPopup*> popups;
popups.push_back(this);
bfHelper(popups, fn, data);
}
CPopup* CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
std::vector<CPopup*> popups;
breadthfirst([](CPopup* popup, void* data) { ((std::vector<CPopup*>*)data)->push_back(popup); }, &popups);
for (auto& p : popups | std::views::reverse) {
if (!p->m_pResource)
continue;
if (!allowsInput) {
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size();
const auto BOX = CBox{p->coordsGlobal() + offset, size};
if (BOX.containsPoint(globalCoords))
return p;
} else {
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
const auto REGION =
CRegion{p->m_pWLSurface->resource()->current.input}.intersect(CBox{{}, p->m_pWLSurface->resource()->current.size}).translate(p->coordsGlobal() + offset);
if (REGION.containsPoint(globalCoords))
return p;
}
}
return nullptr;
}

84
src/desktop/Popup.hpp Normal file
View File

@@ -0,0 +1,84 @@
#pragma once
#include <vector>
#include <memory>
#include "Subsurface.hpp"
#include "../helpers/signal/Listener.hpp"
class CXDGPopupResource;
class CPopup {
public:
// dummy head nodes
CPopup(PHLWINDOW pOwner);
CPopup(PHLLS pOwner);
// real nodes
CPopup(SP<CXDGPopupResource> popup, CPopup* pOwner);
~CPopup();
Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();
Vector2D size();
void onNewPopup(SP<CXDGPopupResource> popup);
void onDestroy();
void onMap();
void onUnmap();
void onCommit(bool ignoreSiblings = false);
void onReposition();
void recheckTree();
bool visible();
// will also loop over this node
void breadthfirst(std::function<void(CPopup*, void*)> fn, void* data);
CPopup* at(const Vector2D& globalCoords, bool allowsInput = false);
//
SP<CWLSurface> m_pWLSurface;
private:
// T1 owners, each popup has to have one of these
PHLWINDOWREF m_pWindowOwner;
PHLLSREF m_pLayerOwner;
// T2 owners
CPopup* m_pParent = nullptr;
WP<CXDGPopupResource> m_pResource;
Vector2D m_vLastSize = {};
Vector2D m_vLastPos = {};
bool m_bRequestedReposition = false;
bool m_bInert = false;
bool m_bMapped = false;
//
std::vector<std::unique_ptr<CPopup>> m_vChildren;
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
struct {
CHyprSignalListener newPopup;
CHyprSignalListener destroy;
CHyprSignalListener map;
CHyprSignalListener unmap;
CHyprSignalListener commit;
CHyprSignalListener dismissed;
CHyprSignalListener reposition;
} listeners;
void initAllSignals();
void unconstrain();
void recheckChildrenRecursive();
void sendScale();
Vector2D localToGlobal(const Vector2D& rel);
Vector2D t1ParentCoords();
static void bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data);
};

206
src/desktop/Subsurface.cpp Normal file
View File

@@ -0,0 +1,206 @@
#include "Subsurface.hpp"
#include "../events/Events.hpp"
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../protocols/core/Subcompositor.hpp"
CSubsurface::CSubsurface(PHLWINDOW pOwner) : m_pWindowParent(pOwner) {
initSignals();
initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
}
CSubsurface::CSubsurface(CPopup* pOwner) : m_pPopupParent(pOwner) {
initSignals();
initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
}
CSubsurface::CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(pSubsurface->surface.lock(), this);
initSignals();
initExistingSubsurfaces(pSubsurface->surface.lock());
}
CSubsurface::CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, CPopup* pOwner) : m_pSubsurface(pSubsurface), m_pPopupParent(pOwner) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(pSubsurface->surface.lock(), this);
initSignals();
initExistingSubsurfaces(pSubsurface->surface.lock());
}
CSubsurface::~CSubsurface() {
hyprListener_newSubsurface.removeCallback();
if (!m_pSubsurface)
return;
hyprListener_commitSubsurface.removeCallback();
hyprListener_destroySubsurface.removeCallback();
}
void CSubsurface::initSignals() {
if (m_pSubsurface) {
listeners.commitSubsurface = m_pSubsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); });
listeners.destroySubsurface = m_pSubsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
listeners.mapSubsurface = m_pSubsurface->surface->events.map.registerListener([this](std::any d) { onMap(); });
listeners.unmapSubsurface = m_pSubsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
listeners.newSubsurface =
m_pSubsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
} else {
if (m_pWindowParent)
listeners.newSubsurface = m_pWindowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else if (m_pPopupParent)
listeners.newSubsurface = m_pPopupParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else
ASSERT(false);
}
}
void CSubsurface::checkSiblingDamage() {
if (!m_pParent)
return; // ??????????
const double SCALE = m_pWindowParent.lock() && m_pWindowParent->m_bIsX11 ? 1.0 / m_pWindowParent->m_fX11SurfaceScaledBy : 1.0;
for (auto& n : m_pParent->m_vChildren) {
if (n.get() == this)
continue;
const auto COORDS = n->coordsGlobal();
g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y, SCALE);
}
}
void CSubsurface::recheckDamageForSubsurfaces() {
for (auto& n : m_vChildren) {
const auto COORDS = n->coordsGlobal();
g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y);
}
}
void CSubsurface::onCommit() {
// no damaging if it's not visible
if (!m_pWindowParent.expired() && (!m_pWindowParent->m_bIsMapped || !m_pWindowParent->m_pWorkspace->m_bVisible)) {
m_vLastSize = m_pWLSurface->resource()->current.size;
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE)
Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowParent.lock());
return;
}
const auto COORDS = coordsGlobal();
g_pHyprRenderer->damageSurface(m_pWLSurface->resource(), COORDS.x, COORDS.y);
if (m_pPopupParent)
m_pPopupParent->recheckTree();
if (!m_pWindowParent.expired()) // I hate you firefox why are you doing this
m_pWindowParent->m_pPopupHead->recheckTree();
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
checkSiblingDamage();
if (m_vLastSize != m_pWLSurface->resource()->current.size) {
CBox box{COORDS, m_vLastSize};
g_pHyprRenderer->damageBox(&box);
m_vLastSize = m_pWLSurface->resource()->current.size;
box = {COORDS, m_vLastSize};
g_pHyprRenderer->damageBox(&box);
}
}
void CSubsurface::onDestroy() {
// destroy children
m_vChildren.clear();
m_bInert = true;
if (!m_pSubsurface)
return; // dummy node, nothing to do, it's the parent dying
// kill ourselves
std::erase_if(m_pParent->m_vChildren, [this](const auto& other) { return other.get() == this; });
}
void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
CSubsurface* PSUBSURFACE = nullptr;
if (!m_pWindowParent.expired())
PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pWindowParent.lock())).get();
else if (m_pPopupParent)
PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pPopupParent)).get();
ASSERT(PSUBSURFACE);
PSUBSURFACE->m_pParent = this;
}
void CSubsurface::onMap() {
m_vLastSize = m_pWLSurface->resource()->current.size;
const auto COORDS = coordsGlobal();
CBox box{COORDS, m_vLastSize};
box.expand(4);
g_pHyprRenderer->damageBox(&box);
if (!m_pWindowParent.expired())
m_pWindowParent->updateSurfaceScaleTransformDetails();
}
void CSubsurface::onUnmap() {
const auto COORDS = coordsGlobal();
CBox box{COORDS, m_vLastSize};
box.expand(4);
g_pHyprRenderer->damageBox(&box);
if (m_pWLSurface->resource() == g_pCompositor->m_pLastFocus)
g_pInputManager->releaseAllMouseButtons();
g_pInputManager->simulateMouseMovement();
// TODO: should this remove children? Currently it won't, only on .destroy
}
Vector2D CSubsurface::coordsRelativeToParent() {
if (!m_pSubsurface)
return {};
return m_pSubsurface->posRelativeToParent();
}
Vector2D CSubsurface::coordsGlobal() {
Vector2D coords = coordsRelativeToParent();
if (!m_pWindowParent.expired())
coords += m_pWindowParent->m_vRealPosition.value();
else if (m_pPopupParent)
coords += m_pPopupParent->coordsGlobal();
return coords;
}
void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) {
for (auto& s : pSurface->subsurfaces) {
if (!s || s->surface->hlSurface /* already assigned */)
continue;
onNewSubsurface(s.lock());
}
}
Vector2D CSubsurface::size() {
return m_pWLSurface->resource()->current.size;
}
bool CSubsurface::visible() {
if (!m_pWindowParent.expired())
return g_pHyprRenderer->shouldRenderWindow(m_pWindowParent.lock());
if (m_pPopupParent)
return m_pPopupParent->visible();
if (m_pParent)
return m_pParent->visible();
return false;
}

View File

@@ -0,0 +1,67 @@
#pragma once
#include "../defines.hpp"
#include <vector>
#include "WLSurface.hpp"
class CPopup;
class CWLSubsurfaceResource;
class CSubsurface {
public:
// root dummy nodes
CSubsurface(PHLWINDOW pOwner);
CSubsurface(CPopup* pOwner);
// real nodes
CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, CPopup* pOwner);
~CSubsurface();
Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();
Vector2D size();
void onCommit();
void onDestroy();
void onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface);
void onMap();
void onUnmap();
bool visible();
void recheckDamageForSubsurfaces();
private:
DYNLISTENER(destroySubsurface);
DYNLISTENER(commitSubsurface);
DYNLISTENER(newSubsurface);
struct {
CHyprSignalListener destroySubsurface;
CHyprSignalListener commitSubsurface;
CHyprSignalListener mapSubsurface;
CHyprSignalListener unmapSubsurface;
CHyprSignalListener newSubsurface;
} listeners;
WP<CWLSubsurfaceResource> m_pSubsurface;
SP<CWLSurface> m_pWLSurface;
Vector2D m_vLastSize = {};
// if nullptr, means it's a dummy node
CSubsurface* m_pParent = nullptr;
PHLWINDOWREF m_pWindowParent;
CPopup* m_pPopupParent = nullptr;
std::vector<std::unique_ptr<CSubsurface>> m_vChildren;
bool m_bInert = false;
void initSignals();
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
void checkSiblingDamage();
};

204
src/desktop/WLSurface.cpp Normal file
View File

@@ -0,0 +1,204 @@
#include "WLSurface.hpp"
#include "../Compositor.hpp"
#include "../protocols/core/Compositor.hpp"
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface) {
m_pResource = pSurface;
init();
m_bInert = false;
}
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, PHLWINDOW pOwner) {
m_pWindowOwner = pOwner;
m_pResource = pSurface;
init();
m_bInert = false;
}
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, PHLLS pOwner) {
m_pLayerOwner = pOwner;
m_pResource = pSurface;
init();
m_bInert = false;
}
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, CSubsurface* pOwner) {
m_pSubsurfaceOwner = pOwner;
m_pResource = pSurface;
init();
m_bInert = false;
}
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface, CPopup* pOwner) {
m_pPopupOwner = pOwner;
m_pResource = pSurface;
init();
m_bInert = false;
}
void CWLSurface::unassign() {
destroy();
}
CWLSurface::~CWLSurface() {
destroy();
}
bool CWLSurface::exists() const {
return m_pResource;
}
SP<CWLSurfaceResource> CWLSurface::resource() const {
return m_pResource.lock();
}
bool CWLSurface::small() const {
if (!validMapped(m_pWindowOwner) || !exists())
return false;
if (!m_pResource->current.buffer)
return false;
const auto O = m_pWindowOwner.lock();
return O->m_vReportedSize.x > m_pResource->current.buffer->size.x + 1 || O->m_vReportedSize.y > m_pResource->current.buffer->size.y + 1;
}
Vector2D CWLSurface::correctSmallVec() const {
if (!validMapped(m_pWindowOwner) || !exists() || !small() || m_bFillIgnoreSmall)
return {};
const auto SIZE = getViewporterCorrectedSize();
const auto O = m_pWindowOwner.lock();
return Vector2D{(O->m_vReportedSize.x - SIZE.x) / 2, (O->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_vRealSize.value() / O->m_vReportedSize);
}
Vector2D CWLSurface::getViewporterCorrectedSize() const {
if (!exists() || !m_pResource->current.buffer)
return {};
return m_pResource->current.viewport.hasDestination ? m_pResource->current.viewport.destination : m_pResource->current.buffer->size;
}
CRegion CWLSurface::logicalDamage() const {
if (!m_pResource->current.buffer)
return {};
CRegion damage = m_pResource->accumulateCurrentBufferDamage();
damage.transform(m_pResource->current.transform, m_pResource->current.buffer->size.x, m_pResource->current.buffer->size.y);
damage.scale(1.0 / m_pResource->current.scale);
const auto VPSIZE = getViewporterCorrectedSize();
const auto CORRECTVEC = correctSmallVec();
if (m_pResource->current.viewport.hasSource)
damage.intersect(m_pResource->current.viewport.source);
const auto SCALEDSRCSIZE =
m_pResource->current.viewport.hasSource ? m_pResource->current.viewport.source.size() * m_pResource->current.scale : m_pResource->current.buffer->size;
damage.scale({VPSIZE.x / SCALEDSRCSIZE.x, VPSIZE.y / SCALEDSRCSIZE.y});
damage.translate(CORRECTVEC);
return damage;
}
void CWLSurface::destroy() {
if (!m_pResource)
return;
events.destroy.emit();
m_pConstraint.reset();
listeners.destroy.reset();
m_pResource->hlSurface.reset();
m_pWindowOwner.reset();
m_pLayerOwner.reset();
m_pPopupOwner = nullptr;
m_pSubsurfaceOwner = nullptr;
m_bInert = true;
if (g_pHyprRenderer && g_pHyprRenderer->m_sLastCursorData.surf && g_pHyprRenderer->m_sLastCursorData.surf->get() == this)
g_pHyprRenderer->m_sLastCursorData.surf.reset();
m_pResource.reset();
Debug::log(LOG, "CWLSurface {:x} called destroy()", (uintptr_t)this);
}
void CWLSurface::init() {
if (!m_pResource)
return;
RASSERT(!m_pResource->hlSurface, "Attempted to duplicate CWLSurface ownership!");
m_pResource->hlSurface = self.lock();
listeners.destroy = m_pResource->events.destroy.registerListener([this](std::any d) { destroy(); });
Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this);
}
PHLWINDOW CWLSurface::getWindow() {
return m_pWindowOwner.lock();
}
PHLLS CWLSurface::getLayer() {
return m_pLayerOwner.lock();
}
CPopup* CWLSurface::getPopup() {
return m_pPopupOwner;
}
CSubsurface* CWLSurface::getSubsurface() {
return m_pSubsurfaceOwner;
}
bool CWLSurface::desktopComponent() {
return !m_pLayerOwner.expired() || !m_pWindowOwner.expired() || m_pSubsurfaceOwner || m_pPopupOwner;
}
std::optional<CBox> CWLSurface::getSurfaceBoxGlobal() {
if (!desktopComponent())
return {};
if (!m_pWindowOwner.expired())
return m_pWindowOwner->getWindowMainSurfaceBox();
if (!m_pLayerOwner.expired())
return m_pLayerOwner->geometry;
if (m_pPopupOwner)
return CBox{m_pPopupOwner->coordsGlobal(), m_pPopupOwner->size()};
if (m_pSubsurfaceOwner)
return CBox{m_pSubsurfaceOwner->coordsGlobal(), m_pSubsurfaceOwner->size()};
return {};
}
void CWLSurface::appendConstraint(WP<CPointerConstraint> constraint) {
m_pConstraint = constraint;
}
SP<CPointerConstraint> CWLSurface::constraint() {
return m_pConstraint.lock();
}
bool CWLSurface::visible() {
if (!m_pWindowOwner.expired())
return g_pHyprRenderer->shouldRenderWindow(m_pWindowOwner.lock());
if (!m_pLayerOwner.expired())
return true;
if (m_pPopupOwner)
return m_pPopupOwner->visible();
if (m_pSubsurfaceOwner)
return m_pSubsurfaceOwner->visible();
return true; // non-desktop, we don't know much.
}
SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
if (!pSurface)
return nullptr;
return pSurface->hlSurface.lock();
}

117
src/desktop/WLSurface.hpp Normal file
View File

@@ -0,0 +1,117 @@
#pragma once
#include "../defines.hpp"
#include "../helpers/Region.hpp"
#include "../helpers/signal/Signal.hpp"
class CSubsurface;
class CPopup;
class CPointerConstraint;
class CWLSurfaceResource;
class CWLSurface {
public:
static SP<CWLSurface> create() {
auto p = SP<CWLSurface>(new CWLSurface);
p->self = p;
return p;
}
~CWLSurface();
// anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD
void assign(SP<CWLSurfaceResource> pSurface);
void assign(SP<CWLSurfaceResource> pSurface, PHLWINDOW pOwner);
void assign(SP<CWLSurfaceResource> pSurface, PHLLS pOwner);
void assign(SP<CWLSurfaceResource> pSurface, CSubsurface* pOwner);
void assign(SP<CWLSurfaceResource> pSurface, CPopup* pOwner);
void unassign();
CWLSurface(const CWLSurface&) = delete;
CWLSurface(CWLSurface&&) = delete;
CWLSurface& operator=(const CWLSurface&) = delete;
CWLSurface& operator=(CWLSurface&&) = delete;
SP<CWLSurfaceResource> resource() const;
bool exists() const;
bool small() const; // means surface is smaller than the requested size
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
Vector2D getViewporterCorrectedSize() const;
CRegion logicalDamage() const;
bool visible();
// getters for owners.
PHLWINDOW getWindow();
PHLLS getLayer();
CPopup* getPopup();
CSubsurface* getSubsurface();
// desktop components misc utils
std::optional<CBox> getSurfaceBoxGlobal();
void appendConstraint(WP<CPointerConstraint> constraint);
SP<CPointerConstraint> constraint();
// allow stretching. Useful for plugins.
bool m_bFillIgnoreSmall = false;
// track surface data and avoid dupes
float m_fLastScale = 0;
int m_iLastScale = 0;
wl_output_transform m_eLastTransform = (wl_output_transform)-1;
//
CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) {
destroy();
m_pResource = pSurface;
init();
return *this;
}
bool operator==(const CWLSurface& other) const {
return other.resource() == resource();
}
bool operator==(const SP<CWLSurfaceResource> other) const {
return other == resource();
}
explicit operator bool() const {
return exists();
}
static SP<CWLSurface> fromResource(SP<CWLSurfaceResource> pSurface);
// used by the alpha-modifier protocol
float m_pAlphaModifier = 1.F;
struct {
CSignal destroy;
} events;
WP<CWLSurface> self;
private:
CWLSurface() = default;
bool m_bInert = true;
WP<CWLSurfaceResource> m_pResource;
PHLWINDOWREF m_pWindowOwner;
PHLLSREF m_pLayerOwner;
CPopup* m_pPopupOwner = nullptr;
CSubsurface* m_pSubsurfaceOwner = nullptr;
//
WP<CPointerConstraint> m_pConstraint;
void destroy();
void init();
bool desktopComponent();
struct {
CHyprSignalListener destroy;
} listeners;
friend class CPointerConstraint;
};

1539
src/desktop/Window.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,24 @@
#pragma once
#include "defines.hpp"
#include "helpers/SubsurfaceTree.hpp"
#include "helpers/AnimatedVariable.hpp"
#include "render/decorations/IHyprWindowDecoration.hpp"
#include <deque>
#include "config/ConfigDataValues.hpp"
#include "helpers/Vector2D.hpp"
#include "helpers/WLSurface.hpp"
#include "macros.hpp"
#include "managers/XWaylandManager.hpp"
#include <string>
#include "../config/ConfigDataValues.hpp"
#include "../defines.hpp"
#include "../helpers/AnimatedVariable.hpp"
#include "../helpers/Vector2D.hpp"
#include "../helpers/signal/Signal.hpp"
#include "../helpers/TagKeeper.hpp"
#include "../macros.hpp"
#include "../managers/XWaylandManager.hpp"
#include "../render/decorations/IHyprWindowDecoration.hpp"
#include "DesktopTypes.hpp"
#include "Popup.hpp"
#include "Subsurface.hpp"
#include "WLSurface.hpp"
class CXDGSurfaceResource;
class CXWaylandSurface;
enum eIdleInhibitMode {
IDLEINHIBIT_NONE = 0,
@@ -124,10 +133,12 @@ class CWindowOverridableVar {
};
struct SWindowSpecialRenderData {
CWindowOverridableVar<bool> alphaOverride = false;
CWindowOverridableVar<float> alpha = 1.f;
CWindowOverridableVar<bool> alphaInactiveOverride = false;
CWindowOverridableVar<float> alphaInactive = -1.f; // -1 means unset
CWindowOverridableVar<bool> alphaOverride = false;
CWindowOverridableVar<float> alpha = 1.f;
CWindowOverridableVar<bool> alphaInactiveOverride = false;
CWindowOverridableVar<float> alphaInactive = -1.f; // -1 means unset
CWindowOverridableVar<bool> alphaFullscreenOverride = false;
CWindowOverridableVar<float> alphaFullscreen = -1.f; // -1 means unset
CWindowOverridableVar<CGradientValueData> activeBorderColor = CGradientValueData(); // empty color vector means unset
CWindowOverridableVar<CGradientValueData> inactiveBorderColor = CGradientValueData(); // empty color vector means unset
@@ -141,26 +152,29 @@ struct SWindowSpecialRenderData {
};
struct SWindowAdditionalConfigData {
std::string animationStyle = std::string("");
CWindowOverridableVar<int> rounding = -1; // -1 means no
CWindowOverridableVar<bool> forceNoBlur = false;
CWindowOverridableVar<bool> forceOpaque = false;
CWindowOverridableVar<bool> forceOpaqueOverridden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
CWindowOverridableVar<bool> forceAllowsInput = false;
CWindowOverridableVar<bool> forceNoAnims = false;
CWindowOverridableVar<bool> forceNoBorder = false;
CWindowOverridableVar<bool> forceNoShadow = false;
CWindowOverridableVar<bool> forceNoDim = false;
CWindowOverridableVar<bool> noFocus = 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
CWindowOverridableVar<bool> forceTearing = false;
CWindowOverridableVar<bool> nearestNeighbor = false;
std::string animationStyle = std::string("");
CWindowOverridableVar<int> rounding = -1; // -1 means no
CWindowOverridableVar<bool> forceNoBlur = false;
CWindowOverridableVar<bool> forceOpaque = false;
CWindowOverridableVar<bool> forceOpaqueOverridden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
CWindowOverridableVar<bool> forceAllowsInput = false;
CWindowOverridableVar<bool> forceNoAnims = false;
CWindowOverridableVar<bool> forceNoBorder = false;
CWindowOverridableVar<bool> forceNoShadow = false;
CWindowOverridableVar<bool> forceNoDim = false;
CWindowOverridableVar<bool> noFocus = false;
CWindowOverridableVar<bool> windowDanceCompat = false;
CWindowOverridableVar<bool> noMaxSize = false;
CWindowOverridableVar<Vector2D> maxSize = Vector2D(std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
CWindowOverridableVar<Vector2D> minSize = Vector2D(20, 20);
CWindowOverridableVar<bool> dimAround = false;
CWindowOverridableVar<bool> forceRGBX = false;
CWindowOverridableVar<bool> keepAspectRatio = false;
CWindowOverridableVar<bool> focusOnActivate = 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
CWindowOverridableVar<bool> forceTearing = false;
CWindowOverridableVar<bool> nearestNeighbor = false;
};
struct SWindowRule {
@@ -172,58 +186,49 @@ struct SWindowRule {
std::string szClass;
std::string szInitialTitle;
std::string szInitialClass;
int bX11 = -1; // -1 means "ANY"
int bFloating = -1;
int bFullscreen = -1;
int bPinned = -1;
int bFocus = -1;
int iOnWorkspace = -1;
std::string szWorkspace = ""; // empty means any
std::string szTag;
int bX11 = -1; // -1 means "ANY"
int bFloating = -1;
int bFullscreen = -1;
int bPinned = -1;
int bFocus = -1;
std::string szOnWorkspace = ""; // empty means any
std::string szWorkspace = ""; // empty means any
};
struct SInitialWorkspaceToken {
PHLWINDOWREF primaryOwner;
std::string workspace;
};
class CWindow {
public:
CWindow();
static PHLWINDOW create(SP<CXDGSurfaceResource>);
static PHLWINDOW create(SP<CXWaylandSurface>);
private:
CWindow(SP<CXDGSurfaceResource> resource);
CWindow(SP<CXWaylandSurface> surface);
public:
~CWindow();
DYNLISTENER(commitWindow);
DYNLISTENER(mapWindow);
DYNLISTENER(unmapWindow);
DYNLISTENER(destroyWindow);
DYNLISTENER(setTitleWindow);
DYNLISTENER(setGeometryX11U);
DYNLISTENER(fullscreenWindow);
DYNLISTENER(newPopupXDG);
DYNLISTENER(requestMove);
DYNLISTENER(requestMinimize);
DYNLISTENER(requestMaximize);
DYNLISTENER(requestResize);
DYNLISTENER(activateX11);
DYNLISTENER(configureX11);
DYNLISTENER(toplevelClose);
DYNLISTENER(toplevelActivate);
DYNLISTENER(toplevelFullscreen);
DYNLISTENER(setOverrideRedirect);
DYNLISTENER(associateX11);
DYNLISTENER(dissociateX11);
DYNLISTENER(ackConfigure);
// DYNLISTENER(newSubsurfaceWindow);
SP<CWLSurface> m_pWLSurface;
CWLSurface m_pWLSurface;
std::list<CWLSurface> m_lPopupSurfaces;
struct {
CSignal destroy;
} events;
union {
wlr_xdg_surface* xdg;
wlr_xwayland_surface* xwayland;
} m_uSurface;
WP<CXDGSurfaceResource> m_pXDGSurface;
WP<CXWaylandSurface> m_pXWaylandSurface;
// this is the position and size of the "bounding box"
Vector2D m_vPosition = Vector2D(0, 0);
Vector2D m_vSize = Vector2D(0, 0);
// this is the real position and size used to draw the thing
CAnimatedVariable m_vRealPosition;
CAnimatedVariable m_vRealSize;
CAnimatedVariable<Vector2D> m_vRealPosition;
CAnimatedVariable<Vector2D> m_vRealSize;
// for not spamming the protocols
Vector2D m_vReportedPosition;
@@ -236,37 +241,44 @@ class CWindow {
Vector2D m_vLastFloatingSize;
Vector2D m_vLastFloatingPosition;
// for floating window offset in workspace animations
Vector2D m_vFloatingOffset = Vector2D(0, 0);
// this is used for pseudotiling
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(0, 0);
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(1280, 720);
bool m_bFirstMap = false; // for layouts
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false;
bool m_bDontSendFullscreen = false;
bool m_bWasMaximized = false;
uint64_t m_iMonitorID = -1;
std::string m_szTitle = "";
std::string m_szInitialTitle = "";
std::string m_szInitialClass = "";
int m_iWorkspaceID = -1;
// for recovering relative cursor position
Vector2D m_vRelativeCursorCoordsOnLastWarp = Vector2D(-1, -1);
bool m_bIsMapped = false;
bool m_bFirstMap = false; // for layouts
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false;
bool m_bDontSendFullscreen = false;
bool m_bWasMaximized = false;
uint64_t m_iMonitorID = -1;
std::string m_szTitle = "";
std::string m_szClass = "";
std::string m_szInitialTitle = "";
std::string m_szInitialClass = "";
PHLWORKSPACE m_pWorkspace;
bool m_bRequestsFloat = false;
bool m_bIsMapped = false;
bool m_bRequestsFloat = false;
// This is for fullscreen apps
bool m_bCreatedOverFullscreen = false;
// XWayland stuff
bool m_bIsX11 = false;
CWindow* m_pX11Parent = nullptr;
uint64_t m_iX11Type = 0;
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
float m_fX11SurfaceScaledBy = 1.f;
bool m_bIsX11 = false;
PHLWINDOWREF m_pX11Parent;
uint64_t m_iX11Type = 0;
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
float m_fX11SurfaceScaledBy = 1.f;
//
// For nofocus
@@ -276,23 +288,26 @@ class CWindow {
bool m_bWantsInitialFullscreen = false;
// bitfield eSuppressEvents
uint64_t m_eSuppressedEvents = SUPPRESS_NONE;
uint64_t m_eSuppressedEvents = SUPPRESS_NONE;
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
// desktop components
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
std::unique_ptr<CPopup> m_pPopupHead;
// Animated border
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
CAnimatedVariable m_fBorderFadeAnimationProgress;
CAnimatedVariable m_fBorderAngleAnimationProgress;
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
CAnimatedVariable<float> m_fBorderFadeAnimationProgress;
CAnimatedVariable<float> m_fBorderAngleAnimationProgress;
// Fade in-out
CAnimatedVariable m_fAlpha;
CAnimatedVariable<float> m_fAlpha;
bool m_bFadingOut = false;
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;
bool m_bAnimatingIn = false;
// For pinned (sticky) windows
bool m_bPinned = false;
@@ -304,12 +319,10 @@ class CWindow {
bool m_bFakeFullscreenState = false;
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
CWindow* m_pLastCycledWindow = nullptr;
// Foreign Toplevel proto
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
PHLWINDOWREF m_pLastCycledWindow;
// Window decorations
// TODO: make this a SP.
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
@@ -321,16 +334,16 @@ class CWindow {
std::vector<std::unique_ptr<IWindowTransformer>> m_vTransformers;
// for alpha
CAnimatedVariable m_fActiveInactiveAlpha;
CAnimatedVariable<float> m_fActiveInactiveAlpha;
// animated shadow color
CAnimatedVariable m_cRealShadowColor;
CAnimatedVariable<CColor> m_cRealShadowColor;
// animated tint
CAnimatedVariable m_fDimPercent;
CAnimatedVariable<float> m_fDimPercent;
// swallowing
CWindow* m_pSwallowed = nullptr;
PHLWINDOWREF m_pSwallowed;
// focus stuff
bool m_bStayFocused = false;
@@ -342,20 +355,29 @@ class CWindow {
// for idle inhibiting windows
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
// initial token. Will be unregistered on workspace change or timeout of 2 minutes
std::string m_szInitialWorkspaceToken = "";
// for groups
struct SGroupData {
CWindow* pNextWindow = nullptr; // nullptr means no grouping. Self means single group.
bool head = false;
bool locked = false; // per group lock
bool deny = false; // deny window from enter a group or made a group
PHLWINDOWREF pNextWindow; // nullptr means no grouping. Self means single group.
bool head = false;
bool locked = false; // per group lock
bool deny = false; // deny window from enter a group or made a group
} m_sGroupData;
uint16_t m_eGroupRules = GROUP_NONE;
bool m_bTearingHint = false;
// stores the currently matched window rules
std::vector<SWindowRule> m_vMatchedRules;
// window tags
CTagKeeper m_tags;
// For the list lookup
bool operator==(const CWindow& rhs) {
return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
return m_pXDGSurface == rhs.m_pXDGSurface && m_pXWaylandSurface == rhs.m_pXWaylandSurface && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
m_bFadingOut == rhs.m_bFadingOut;
}
@@ -373,12 +395,10 @@ class CWindow {
pid_t getPID();
IHyprWindowDecoration* getDecorationByType(eDecorationType);
void removeDecorationByType(eDecorationType);
void createToplevelHandle();
void destroyToplevelHandle();
void updateToplevel();
void updateSurfaceScaleTransformDetails();
void moveToWorkspace(int);
CWindow* X11TransientFor();
void updateSurfaceScaleTransformDetails(bool force = false);
void moveToWorkspace(PHLWORKSPACE);
PHLWINDOW X11TransientFor();
void onUnmap();
void onMap();
void setHidden(bool hidden);
@@ -392,35 +412,96 @@ class CWindow {
bool canBeTorn();
bool shouldSendFullscreenState();
void setSuspended(bool suspend);
bool visibleOnMonitor(CMonitor* pMonitor);
int workspaceID();
bool onSpecialWorkspace();
void activate(bool force = false);
int surfacesCount();
int getRealBorderSize();
void updateSpecialRenderData();
void updateSpecialRenderData(const struct SWorkspaceRule&);
void onBorderAngleAnimEnd(void* ptr);
bool isInCurvedCorner(double x, double y);
bool hasPopupAt(const Vector2D& pos);
int popupsCount();
void applyGroupRules();
void createGroup();
void destroyGroup();
CWindow* getGroupHead();
CWindow* getGroupTail();
CWindow* getGroupCurrent();
CWindow* getGroupPrevious();
CWindow* getGroupWindowByIndex(int);
PHLWINDOW getGroupHead();
PHLWINDOW getGroupTail();
PHLWINDOW getGroupCurrent();
PHLWINDOW getGroupPrevious();
PHLWINDOW getGroupWindowByIndex(int);
int getGroupSize();
bool canBeGroupedInto(CWindow* pWindow);
void setGroupCurrent(CWindow* pWindow);
void insertWindowToGroup(CWindow* pWindow);
bool canBeGroupedInto(PHLWINDOW pWindow);
void setGroupCurrent(PHLWINDOW pWindow);
void insertWindowToGroup(PHLWINDOW pWindow);
void updateGroupOutputs();
void switchWithWindowInGroup(CWindow* pWindow);
void switchWithWindowInGroup(PHLWINDOW pWindow);
void setAnimationsToMove();
void onWorkspaceAnimUpdate();
void onUpdateState();
void onUpdateMeta();
void onX11Configure(CBox box);
void onResourceChangeX11();
std::string fetchTitle();
std::string fetchClass();
void warpCursor();
// listeners
void onAck(uint32_t serial);
//
std::unordered_map<std::string, std::string> getEnv();
//
PHLWINDOWREF m_pSelf;
// make private once we move listeners to inside CWindow
struct {
CHyprSignalListener map;
CHyprSignalListener ack;
CHyprSignalListener unmap;
CHyprSignalListener commit;
CHyprSignalListener destroy;
CHyprSignalListener activate;
CHyprSignalListener configure;
CHyprSignalListener setGeometry;
CHyprSignalListener updateState;
CHyprSignalListener updateMetadata;
CHyprSignalListener resourceChange;
} listeners;
private:
// For hidden windows and stuff
bool m_bHidden = false;
bool m_bSuspended = false;
bool m_bHidden = false;
bool m_bSuspended = false;
int m_iLastWorkspace = WORKSPACE_INVALID;
};
inline bool valid(PHLWINDOW w) {
return w.get();
}
inline bool valid(PHLWINDOWREF w) {
return !w.expired();
}
inline bool validMapped(PHLWINDOW w) {
if (!valid(w))
return false;
return w->m_bIsMapped;
}
inline bool validMapped(PHLWINDOWREF w) {
if (!valid(w))
return false;
return w->m_bIsMapped;
}
/**
format specification
- 'x', only address, equivalent of (uintpr_t)CWindow*
@@ -430,7 +511,7 @@ class CWindow {
*/
template <typename CharT>
struct std::formatter<CWindow*, CharT> : std::formatter<CharT> {
struct std::formatter<PHLWINDOW, CharT> : std::formatter<CharT> {
bool formatAddressOnly = false;
bool formatWorkspace = false;
bool formatMonitor = false;
@@ -440,24 +521,24 @@ struct std::formatter<CWindow*, CharT> : std::formatter<CharT> {
FORMAT_FLAG('m', formatMonitor) //
FORMAT_FLAG('w', formatWorkspace) //
FORMAT_FLAG('c', formatClass),
CWindow*)
PHLWINDOW)
template <typename FormatContext>
auto format(CWindow* const& w, FormatContext& ctx) const {
auto format(PHLWINDOW const& w, FormatContext& ctx) const {
auto&& out = ctx.out();
if (formatAddressOnly)
return std::format_to(out, "{:x}", (uintptr_t)w);
return std::format_to(out, "{:x}", (uintptr_t)w.get());
if (!w)
return std::format_to(out, "[Window nullptr]");
std::format_to(out, "[");
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w, w->m_szTitle);
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w.get(), w->m_szTitle);
if (formatWorkspace)
std::format_to(out, ", workspace: {}", w->m_iWorkspaceID);
std::format_to(out, ", workspace: {}", w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID);
if (formatMonitor)
std::format_to(out, ", monitor: {}", w->m_iMonitorID);
if (formatClass)
std::format_to(out, ", class: {}", g_pXWaylandManager->getAppIDClass(w));
std::format_to(out, ", class: {}", w->m_szClass);
return std::format_to(out, "]");
}
};

507
src/desktop/Workspace.cpp Normal file
View File

@@ -0,0 +1,507 @@
#include "Workspace.hpp"
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special, bool isEmtpy) {
PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special, isEmtpy);
workspace->init(workspace);
return workspace;
}
CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special, bool isEmtpy) {
m_iMonitorID = monitorID;
m_iID = id;
m_szName = name;
m_bIsSpecialWorkspace = special;
m_bWasCreatedEmtpy = isEmtpy;
}
void CWorkspace::init(PHLWORKSPACE self) {
m_pSelf = self;
m_vRenderOffset.create(m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
self, AVARDAMAGE_ENTIRE);
m_fAlpha.create(AVARTYPE_FLOAT,
m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), self,
AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(1.f);
m_vRenderOffset.registerVar();
m_fAlpha.registerVar();
const auto RULEFORTHIS = g_pConfigManager->getWorkspaceRuleFor(self);
if (RULEFORTHIS.defaultName.has_value())
m_szName = RULEFORTHIS.defaultName.value();
m_pFocusedWindowHook = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any param) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(param);
if (PWINDOW == m_pLastFocusedWindow.lock())
m_pLastFocusedWindow.reset();
});
m_bInert = false;
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
m_bPersistent = WORKSPACERULE.isPersistent;
if (self->m_bWasCreatedEmtpy)
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
g_pKeybindManager->spawn(*cmd);
g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
EMIT_HOOK_EVENT("createWorkspace", this);
}
CWorkspace::~CWorkspace() {
m_vRenderOffset.unregister();
Debug::log(LOG, "Destroying workspace ID {}", m_iID);
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
if (g_pHookSystem)
g_pHookSystem->unhook(m_pFocusedWindowHook);
if (g_pEventManager) {
g_pEventManager->postEvent({"destroyworkspace", m_szName});
g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, 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;
static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
// set floating windows offset callbacks
m_vRenderOffset.setUpdateCallback([&](void*) {
for (auto& w : g_pCompositor->m_vWindows) {
if (!validMapped(w) || w->workspaceID() != m_iID)
continue;
w->onWorkspaceAnimUpdate();
};
});
if (ANIMSTYLE.starts_with("slidefade")) {
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.starts_with("slidefadevert")) {
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) {
m_fAlpha.setValueAndWarp(0.f);
m_fAlpha = 1.f;
} else {
m_fAlpha.setValueAndWarp(1.f);
m_fAlpha = 0.f;
}
} else if (ANIMSTYLE == "slidevert") {
// fallback is slide
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
const auto YDISTANCE = PMONITOR->vecSize.y + *PWORKSPACEGAP;
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
if (in) {
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? YDISTANCE : -YDISTANCE));
m_vRenderOffset = Vector2D(0, 0);
} else {
m_vRenderOffset = Vector2D(0, left ? -YDISTANCE : YDISTANCE);
}
} else {
// fallback is slide
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP;
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
if (in) {
m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0));
m_vRenderOffset = Vector2D(0, 0);
} else {
m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0);
}
}
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();
}
}
void CWorkspace::setActive(bool on) {
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
}
void CWorkspace::moveToMonitor(const int& id) {
; // empty until https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/40
}
PHLWINDOW CWorkspace::getLastFocusedWindow() {
if (!validMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->workspaceID() != m_iID)
return nullptr;
return m_pLastFocusedWindow.lock();
}
void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
if (!prev) {
m_sPrevWorkspace.iID = -1;
m_sPrevWorkspace.name = "";
return;
}
if (prev->m_iID == m_iID) {
Debug::log(LOG, "Tried to set prev workspace to the same as current one");
return;
}
m_sPrevWorkspace.iID = prev->m_iID;
m_sPrevWorkspace.name = prev->m_szName;
}
std::string CWorkspace::getConfigName() {
if (m_bIsSpecialWorkspace) {
return m_szName;
}
if (m_iID > 0)
return std::to_string(m_iID);
return "name:" + m_szName;
}
bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
auto selector = removeBeginEndSpacesTabs(selector_);
if (selector.empty())
return true;
if (isNumber(selector)) {
std::string wsname = "";
int wsid = getWorkspaceIDFromString(selector, wsname);
if (wsid == WORKSPACE_INVALID)
return false;
return wsid == m_iID;
} else if (selector.starts_with("name:")) {
return m_szName == selector.substr(5);
} else if (selector.starts_with("special")) {
return m_szName == selector;
} else {
// parse selector
for (size_t i = 0; i < selector.length(); ++i) {
const char& cur = selector[i];
if (std::isspace(cur))
continue;
// Allowed selectors:
// r - range: r[1-5]
// s - special: s[true]
// n - named: n[true] or n[s:string] or n[e:string]
// m - monitor: m[monitor_selector]
// w - windowCount: w[1-4] or w[1], optional flag t or f for tiled or floating and
// flag g to count groups instead of windows, e.g. w[t1-2], w[fg4]
// flag v will count only visible windows
// f - fullscreen state : f[-1], f[0], f[1], or f[2] for different fullscreen states
// -1: no fullscreen, 0: fullscreen, 1: maximized, 2: fullscreen without sending fs state to window
const auto NEXTSPACE = selector.find_first_of(' ', i);
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
i = std::min(NEXTSPACE, std::string::npos - 1);
if (cur == 'r') {
int from = 0, to = 0;
if (!prop.starts_with("r[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
if (!prop.contains("-")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
const auto DASHPOS = prop.find("-");
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
if (!isNumber(LHS) || !isNumber(RHS)) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
try {
from = std::stoll(LHS);
to = std::stoll(RHS);
} catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
if (to < from || to < 1 || from < 1) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
if (std::clamp(m_iID, from, to) != m_iID)
return false;
continue;
}
if (cur == 's') {
if (!prop.starts_with("s[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
const auto SHOULDBESPECIAL = configStringToInt(prop);
if ((bool)SHOULDBESPECIAL != m_bIsSpecialWorkspace)
return false;
continue;
}
if (cur == 'm') {
if (!prop.starts_with("m[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
const auto PMONITOR = g_pCompositor->getMonitorFromString(prop);
if (!(PMONITOR ? PMONITOR->ID == m_iMonitorID : false))
return false;
continue;
}
if (cur == 'n') {
if (!prop.starts_with("n[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
if (prop.starts_with("s:") && !m_szName.starts_with(prop.substr(2)))
return false;
if (prop.starts_with("e:") && !m_szName.ends_with(prop.substr(2)))
return false;
const auto WANTSNAMED = configStringToInt(prop);
if (WANTSNAMED != (m_iID <= -1337))
return false;
continue;
}
if (cur == 'w') {
int from = 0, to = 0;
if (!prop.starts_with("w[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
int wantsOnlyTiled = -1;
bool wantsCountGroup = false;
bool wantsCountVisible = false;
int flagCount = 0;
for (auto& flag : prop) {
if (flag == 't' && wantsOnlyTiled == -1) {
wantsOnlyTiled = 1;
flagCount++;
} else if (flag == 'f' && wantsOnlyTiled == -1) {
wantsOnlyTiled = 0;
flagCount++;
} else if (flag == 'g' && !wantsCountGroup) {
wantsCountGroup = true;
flagCount++;
} else if (flag == 'v' && !wantsCountVisible) {
wantsCountVisible = true;
flagCount++;
} else {
break;
}
}
prop = prop.substr(flagCount);
if (!prop.contains("-")) {
// try single
if (!isNumber(prop)) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
try {
from = std::stoll(prop);
} catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
int count;
if (wantsCountGroup)
count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else
count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
if (count != from)
return false;
continue;
}
const auto DASHPOS = prop.find("-");
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
if (!isNumber(LHS) || !isNumber(RHS)) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
try {
from = std::stoll(LHS);
to = std::stoll(RHS);
} catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
if (to < from || to < 1 || from < 1) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
int count;
if (wantsCountGroup)
count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else
count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
if (std::clamp(count, from, to) != count)
return false;
continue;
}
if (cur == 'f') {
if (!prop.starts_with("f[") || !prop.ends_with("]")) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
prop = prop.substr(2, prop.length() - 3);
int FSSTATE = -1;
try {
FSSTATE = std::stoi(prop);
} catch (std::exception& e) {
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
switch (FSSTATE) {
case -1: // no fullscreen
if (m_bHasFullscreenWindow)
return false;
break;
case 0: // fullscreen full
if (!m_bHasFullscreenWindow || m_efFullscreenMode != FULLSCREEN_FULL)
return false;
break;
case 1: // maximized
if (!m_bHasFullscreenWindow || m_efFullscreenMode != FULLSCREEN_MAXIMIZED)
return false;
break;
case 2: // fullscreen without sending fullscreen state to window
if (!m_bHasFullscreenWindow || m_efFullscreenMode != FULLSCREEN_FULL || !g_pCompositor->getFullscreenWindowOnWorkspace(m_iID) ||
!g_pCompositor->getFullscreenWindowOnWorkspace(m_iID)->m_bDontSendFullscreen)
return false;
break;
default: break;
}
continue;
}
Debug::log(LOG, "Invalid selector {}", selector);
return false;
}
return true;
}
UNREACHABLE();
return false;
}
void CWorkspace::markInert() {
m_bInert = true;
m_iID = WORKSPACE_INVALID;
m_iMonitorID = -1;
m_bVisible = false;
}
bool CWorkspace::inert() {
return m_bInert;
}

View File

@@ -1,8 +1,9 @@
#pragma once
#include "AnimatedVariable.hpp"
#include "../helpers/AnimatedVariable.hpp"
#include <string>
#include "../defines.hpp"
#include "DesktopTypes.hpp"
enum eFullscreenMode : int8_t {
FULLSCREEN_INVALID = -1,
@@ -14,7 +15,9 @@ class CWindow;
class CWorkspace {
public:
CWorkspace(int monitorID, std::string name, bool special = false);
static PHLWORKSPACE create(int id, int monitorID, std::string name, bool special = false, bool isEmtpy = true);
// use create() don't use this
CWorkspace(int id, int monitorID, std::string name, bool special = false, bool isEmpty = true);
~CWorkspace();
// Workspaces ID-based have IDs > 0
@@ -35,15 +38,18 @@ class CWorkspace {
wl_array m_wlrCoordinateArr;
// for animations
CAnimatedVariable m_vRenderOffset;
CAnimatedVariable m_fAlpha;
bool m_bForceRendering = false;
CAnimatedVariable<Vector2D> m_vRenderOffset;
CAnimatedVariable<float> m_fAlpha;
bool m_bForceRendering = false;
// allows damage to propagate.
bool m_bVisible = false;
// "scratchpad"
bool m_bIsSpecialWorkspace = false;
// last window
CWindow* m_pLastFocusedWindow = nullptr;
PHLWINDOWREF m_pLastFocusedWindow;
// user-set
bool m_bDefaultFloating = false;
@@ -52,16 +58,38 @@ class CWorkspace {
// last monitor (used on reconnect)
std::string m_szLastMonitor = "";
// Whether the user configured command for on-created-empty has been executed, if any
bool m_bOnCreatedEmptyExecuted = false;
bool m_bWasCreatedEmtpy = true;
bool m_bPersistent = false;
// Inert: destroyed and invalid. If this is true, release the ptr you have.
bool inert();
void startAnim(bool in, bool left, bool instant = false);
void setActive(bool on);
void moveToMonitor(const int&);
CWindow* getLastFocusedWindow();
void rememberPrevWorkspace(const CWorkspace* prevWorkspace);
PHLWINDOW getLastFocusedWindow();
void rememberPrevWorkspace(const PHLWORKSPACE& prevWorkspace);
std::string getConfigName();
bool matchesStaticSelector(const std::string& selector);
void markInert();
private:
void init(PHLWORKSPACE self);
SP<HOOK_CALLBACK_FN> m_pFocusedWindowHook;
bool m_bInert = true;
WP<CWorkspace> m_pSelf;
};
inline bool valid(const PHLWORKSPACE& ref) {
if (!ref)
return false;
return !ref->inert();
}

5
src/devices/IHID.cpp Normal file
View File

@@ -0,0 +1,5 @@
#include "IHID.hpp"
eHIDType IHID::getType() {
return HID_TYPE_UNKNOWN;
}

40
src/devices/IHID.hpp Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include <cstdint>
#include <string>
#include "../helpers/signal/Signal.hpp"
enum eHIDCapabilityType : uint32_t {
HID_INPUT_CAPABILITY_KEYBOARD = (1 << 0),
HID_INPUT_CAPABILITY_POINTER = (1 << 1),
HID_INPUT_CAPABILITY_TOUCH = (1 << 2),
HID_INPUT_CAPABILITY_TABLET = (1 << 3),
};
enum eHIDType {
HID_TYPE_UNKNOWN = 0,
HID_TYPE_POINTER,
HID_TYPE_KEYBOARD,
HID_TYPE_TOUCH,
HID_TYPE_TABLET,
HID_TYPE_TABLET_TOOL,
HID_TYPE_TABLET_PAD,
};
/*
Base class for a HID device.
This could be a keyboard, a mouse, or a touchscreen.
*/
class IHID {
public:
virtual ~IHID() {}
virtual uint32_t getCapabilities() = 0;
virtual eHIDType getType();
struct {
CSignal destroy;
} events;
std::string deviceName;
};

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