Compare commits

..

1077 commits

Author SHA1 Message Date
b41882c169
maybe do import?
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Nix / test (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
2026-03-07 15:45:46 +10:00
bcab43b181
bump glaze version
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Code Style (push) Waiting to run
Nix / update-inputs (push) Waiting to run
Nix / hyprland (push) Waiting to run
Nix / xdph (push) Blocked by required conditions
Nix / test (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
2026-03-07 14:59:09 +10:00
08e215c9bf
temp
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Code Style (push) Waiting to run
Nix / update-inputs (push) Waiting to run
Nix / hyprland (push) Waiting to run
Nix / xdph (push) Blocked by required conditions
Nix / test (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
2026-03-07 14:51:29 +10:00
UjinT34
4152ac76d0
renderer: refactor Texture, Framebuffer and Renderbuffer (#13437)
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Code Style (push) Waiting to run
Nix / update-inputs (push) Waiting to run
Nix / hyprland (push) Waiting to run
Nix / xdph (push) Blocked by required conditions
Nix / test (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
Part 1 of the renderer refactors
2026-03-06 21:44:10 +00:00
UjinT34
a5858018d8
renderer: shader variants refactor (#13434)
Part 0 of renderer reworks.
2026-03-06 21:05:10 +00:00
Mikhail
8685fd7b0c
dwindle: add rotatesplit layoutmsg and tests (#13235) 2026-03-06 20:47:48 +00:00
Logan Collins
1fa157cf6d
compositor: fix missing recheckWorkArea to prevent CReservedArea assert failure (#13590) 2026-03-06 20:47:39 +00:00
Virt
e0c5710059
layerrules: add dynamically registered rules for plugins (#13331)
* layerrules: add dynamically registered rules for plugins

* be gone

* layerrules: add layer tests with waybar

* fix: use kitty layers instead of waybar
2026-03-06 20:11:42 +00:00
Nikolai Nechaev
42f0a6005b
keybinds: Remove removed keybinds (#13605)
There seems to be no reason for them to remain.

But if they are kept, no notification appears to warn
a user that a dispatcher used in their config is no
longer valid. The config remains valid, but the bindings
do not work anymore.
2026-03-06 16:33:08 +00:00
JaSha256
ae9ca17b40
pointer: fix hardware cursor rendering on rotated/flipped monitors (#13574)
Replace the broken cairo_matrix_rotate() approach with explicit
per-transform pattern matrices for all 8 wl_output_transform values.
2026-03-05 15:14:23 +00:00
Vaxry
972f23efe8
screencopy: fix isOutputBeingSSd (#13586)
use sessions instead of pending frames
2026-03-05 15:14:13 +00:00
justin4046
4c60d9df70
desktop/rules: fix empty workspace handling (#13544) 2026-03-05 15:14:05 +00:00
Vaxry
b7dfb47566
config/descriptions: add missing desc entry 2026-03-05 14:10:22 +00:00
Thedudeman
3284dd729b
algo/scrolling: add config options for focus and swapcol wrapping (#13518) 2026-03-05 14:08:40 +00:00
Ikalco
803e81ac39
screenshare: improve destroy logic of objects (#13554) 2026-03-05 14:06:55 +00:00
Vũ Xuân Trường
34c7cc7d38
i18n: update Vietnamese translations (#13489) 2026-03-04 20:02:04 +00:00
Ikalco
c47ae950f4
screencopy: fix minor crash (#13566) 2026-03-04 20:01:37 +00:00
Harsh Narayan Jha
3f169ee5de
socket2: emit kill event (hyprctl kill) (#13104) 2026-03-04 20:00:00 +00:00
Vaxry
10754745a9
render/cm: add ICC profile pipeline (#12711)
Adds an ICC profile pipeline, loading via config and applying via 3D LUTs.
2026-03-04 19:50:28 +00:00
Florian "sp1rit
8271cfc97b
core: fix i586 build (#13550)
Signed-off-by: Florian "sp1rit"​ <sp1rit@disroot.org>
2026-03-04 11:33:44 +00:00
Vaxry
c11cadd8d6
desktop/window: don't group modals 2026-03-03 21:00:33 +00:00
Vaxry
dc4b082ee8
algo/scrolling: fix rare crash 2026-03-03 20:59:18 +00:00
André Silva
edf7098345
desktop/window: fix floating windows being auto-grouped (#13475)
---------

Co-authored-by: Aqa-Ib <16420574+Aqa-Ib@users.noreply.github.com>
2026-03-03 20:56:02 +00:00
Vaxry
7299a3b0d5
hyprctl: fix workspace dynamic effect reloading (#13537)
ref https://github.com/hyprwm/Hyprland/discussions/12806
2026-03-03 13:03:47 +00:00
Vaxry
b06a4b5e13
layout/windowTarget: override maximized box status in updateGeom (#13535)
ref https://github.com/hyprwm/Hyprland/discussions/13525
2026-03-03 12:33:46 +00:00
Vaxry
3faddf40d0
algo/dwindle: don't crash on empty swapsplit (#13533)
ref https://github.com/hyprwm/Hyprland/discussions/13530
2026-03-03 11:55:57 +00:00
Vaxry
a6e3a2478c
tests/workspace: fix one test case failing 2026-03-03 11:27:16 +00:00
Vaxry
ff0b706ea3
renderer: fix crash on mirrored outputs needing recalc (#13534)
ref https://github.com/hyprwm/Hyprland/discussions/13517
2026-03-03 11:25:58 +00:00
UjinT34
4f44df7b17
algo/master: fix crash after dpms (#13522) 2026-03-03 11:06:32 +00:00
Vaxry
be03497b82
layout/algos: use binds:window_direction_monitor_fallback for moves (#13508)
ref https://github.com/hyprwm/Hyprland/discussions/13473
2026-03-02 21:39:06 +00:00
Vaxry
ff20cbf89c
algo/scrolling: fix offset on removeTarget (#13515) 2026-03-02 21:23:24 +00:00
André Silva
fe0a202137
desktop/group: respect direction when moving window out of group (#13490) 2026-03-02 21:12:27 +00:00
Vaxry
75a815fbf2
algo/dwindle: use focal point correctly for x-ws moves (#13514) 2026-03-02 21:10:21 +00:00
Vaxry
3b7401b065
algo/scroll: improve directional moves (#13423) 2026-03-02 19:31:33 +00:00
Vaxry
d4d17d5d52
compositor: damage monitors on workspace attachment updates
ref https://github.com/hyprwm/Hyprland/discussions/13386
2026-03-02 19:26:06 +00:00
Mihai Fufezan
52ece2b017
treewide: alejandra -> nixfmt 2026-03-02 21:03:44 +02:00
Vaxry
d98f7ffaf5
layout: store and preserve size and pos after fullscreen (#13500)
ref https://github.com/hyprwm/Hyprland/discussions/13401
2026-03-02 18:57:09 +00:00
Vaxry
5f650f8ed9
layout/windowTarget: don't use swar on maximized (#13501) 2026-03-02 16:54:33 +00:00
Vaxry
9f98f7440b
algo/dwindle: add back splitratio (#13498) 2026-03-02 16:21:20 +00:00
Vaxry
5cb1281035
layout/windowTarget: damage before and after moves (#13496) 2026-03-02 12:52:22 +00:00
Thedudeman
743dffd638
layout/scroll: fix configuredWidths not setting properly on new workspaces (#13476) 2026-03-02 12:51:56 +00:00
Vaxry
5c370c3333
hyprpm: fix url sanitization in add
this could've been used to exec additional commands with hyprpm
2026-03-01 21:55:12 +00:00
Vaxry
cf0d256c13
layout/windowTarget: fix size_limits_tiled (#13445)
fucks up on scroll, also, wtf
2026-03-01 19:21:53 +00:00
Yujon Pradhananga
6ebafcf107
layout/scrolling: fix size_t underflow in idxForHeight (#13465) 2026-03-01 18:19:02 +00:00
Vaxry
8ad96a95d6
screencopy: fix nullptr deref if shm format is weird 2026-03-01 15:31:22 +00:00
Vaxry
f41e3c2203
scroll: clamp column widths properly
ref https://github.com/hyprwm/Hyprland/discussions/13458
2026-03-01 10:15:22 +00:00
Vaxry
f0a80ce5e0
keybinds: fixup changegroupactive 2026-03-01 10:12:15 +00:00
Vaxry
2928d6af0a
layouts: fix crash on missed relayout updates (#13444) 2026-02-28 23:06:27 +00:00
vaxerski
93aacfc0dc [gha] Nix: update inputs 2026-02-28 22:55:48 +00:00
Vaxry
19c263e53c
screencopy: scale window region for toplevel export (#13442) 2026-02-28 22:54:10 +00:00
Vaxry
a032090098
monitor: damage old special monitor on change
ref https://github.com/hyprwm/Hyprland/discussions/13419
2026-02-28 22:51:33 +00:00
Vaxry
0b55c55f4a
monitor: update pinned window states properly on changeWorkspace (#13441)
ref https://github.com/hyprwm/Hyprland/discussions/13440
2026-02-28 22:42:06 +00:00
Vaxry
85c2764f5e
deco/border: fix damageEntire 2026-02-28 22:03:14 +00:00
Zynix
c2bed4103c
monitor: keep workspace monitor bindings on full reconnect (#13384)
When all monitors disconnect, non-active workspaces could migrate to the wrong output after reconnect. Preserve workspace ownership and re-apply assigned monitor bindings on connect.
2026-02-28 21:49:47 +00:00
LionHeartP
82729db330
build: fix build on gcc 16.x after #6b2c08d (#13429) 2026-02-28 21:45:16 +00:00
Vaxry
f12904e641
layout/algo: fix swar on removing a target (#13427)
ref https://github.com/hyprwm/Hyprland/discussions/13422
2026-02-28 18:53:36 +00:00
Vaxry
b90c61c04f
compositor: fix focus edge detection (#13425)
fixes edge detection, making it more relaxed and intuitive
2026-02-28 18:53:26 +00:00
André Silva
e333a330c0
desktop/group: fix movegroupwindow not following focus (#13426) 2026-02-28 18:19:29 +00:00
Vaxry
1c64ef06d9
desktop/window: fix idealBB reserved (#13421)
ref https://github.com/hyprwm/Hyprland/discussions/12766\#discussioncomment-15955638
2026-02-28 16:55:34 +00:00
Vaxry
6b2c08d3e8
pointer: damage entire buffer in begin of rendering hw
ref #13391
2026-02-28 15:55:30 +00:00
Christian Fredrik Johnsen
db8509dfe2
build: remove auto-generated hyprctl/hw-protocols/ files during make clear (#13399) 2026-02-28 15:51:24 +00:00
Tom Englund
d2b9957fab
format: safeguard drmGetFormat functions (#13416)
they can return null if not found.
2026-02-28 15:29:22 +00:00
Vaxry
362ea7b0f3
hyprctl: fix buffer overflowing writes to the socket 2026-02-28 15:06:10 +00:00
Vaxry
f7114016c6
desktop/rule: fix matching for content type by str 2026-02-28 15:03:49 +00:00
Vaxry
0002f148c9
version: bump to 0.54.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Nix / test (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
2026-02-27 18:03:19 +00:00
ItsOhen
ffec41c426
desktop/rules: fix border colors not resetting. (#13382) 2026-02-27 17:59:47 +00:00
Vaxry
f624449c12
start: add --force-nixgl and check /run/opengl-driver (#13385) 2026-02-27 17:57:04 +00:00
ItsOhen
70cdd819e4
desktop/rules: use pid for exec rules (#13374) 2026-02-26 18:13:49 +00:00
Skidam
cc14dd1baf
xwayland: validate size hints before floating (#13361) 2026-02-26 16:42:49 +00:00
UjinT34
c71fbd854d
renderer: better sdr eotf settings (#12812) 2026-02-26 12:01:59 +00:00
Vaxry
0e9196867b
algo/dwindle: fix focal point not being properly used in movedTarget (#13373) 2026-02-26 12:00:05 +00:00
Vaxry
1e06ab464f
algo/master: fix orientation cycling (#13372) 2026-02-25 23:54:13 +00:00
Vaxry
623185170b
desktop/popup: avoid crash on null popup child in rechecking
ref #13352
2026-02-25 23:16:16 +00:00
Vaxry
d0583e1761
compositor: fix calculating x11 work area (#13347)
in a multimon scenario, due to our positioning hacks, and due to the fact work area is a rect anyways, likely wont make sense
2026-02-25 22:44:35 +00:00
fazzi
5b2efe54b1
input: use fresh cursor pos when sending motion events (#13366) 2026-02-25 22:41:50 +00:00
Skidam
457617b5a3
xwayland: normalize OR geometry to logical coords with force_zero_scaling (#13359)
Fixes X11 popups, tooltips, and menus showing black boxes on scaled monitors with xwayland:force_zero_scaling = 1 #13334
2026-02-25 12:29:12 +00:00
Vaxry
c60b3cb2ed
target: fix geometry for x11 floats 2026-02-24 19:01:51 +00:00
Vaxry
fbf67ef050
algo/scrolling: adjust focus callbacks to be more intuitive 2026-02-24 12:27:00 +00:00
Vaxry
be893a81b4
algo/master: fix master:orientation being a noop 2026-02-24 11:36:51 +00:00
Vaxry
5a80bc120a
algo/scrolling: fix crashes on destroying ws
ref #13324
2026-02-24 11:33:21 +00:00
vaxerski
a248805132 [gha] Nix: update inputs 2026-02-24 11:22:10 +00:00
Tom Englund
8ab4d1dc06
popup: check for expired weak ptr (#13352)
onCommit can destroy popups while the vector CPY still holds a weak ptr
to it, check if the weak ptr is still valid
2026-02-24 11:20:29 +00:00
Skidam
ae82a55400
view: send wl_surface.enter to subsurfaces of popups (#13353) 2026-02-24 11:20:04 +00:00
jmanc3
bc09504ea5
desktop/popup: fix use after free in Popup (#13335)
m_alpha was freed by fullyDestroy, but was then being touched because setCallbackOnEnd is activated by tick, which is the same function that updates animating variables

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2026-02-23 16:58:06 +00:00
ssareta
f4bc8c3a64
keybinds: fix unguarded member access in moveWindowOrGroup (#13337) 2026-02-23 16:29:44 +00:00
Vaxry
b88813c7ef
event: refactor HookSystem into a typed event bus (#13333)
Refactors the old HookSystem into a typed event bus with clear
separation,
discovery and types.
2026-02-22 23:30:10 +00:00
Ikalco
b4ee4674f9
protocols: implement image-capture-source-v1 and image-copy-capture-v1 (#11709)
Implements the new screencopy protocols
2026-02-22 12:30:11 +00:00
Vaxry
93dbf88426
pointermgr: revert "damage only the surface size (#13284)"
This reverts commit 13dab66b1d.
2026-02-22 12:23:27 +00:00
Vaxry
0eb4755a3e
example: fixup config for togglesplit 2026-02-21 21:35:11 +00:00
Vaxry
723870337f
layout: rethonk layouts from the ground up (#12890)
Rewrites layouts to be much smaller, and deal with much less annoying
BS. Improves the overall architecture, unifies handling of pseudotiling,
and various other improvements.
2026-02-21 21:30:39 +00:00
Vaxry
51f8849e54
github: add ai policy to mr template 2026-02-21 20:37:34 +00:00
Vaxry
b9b1eda2ef
hyprctl: adjust json case
should be camel
2026-02-21 20:30:16 +00:00
Tom Englund
13dab66b1d
pointermgr: damage only the surface size (#13284)
* pointermgr: damage only the surface size

CWaylandOutput returns a vector2d with -1, -1 set as a "no limit",
passing that down into beginSimple and the renderer it hits pixman bug
of invalid sizes and wrong rectangles gets created.

causing bunch of
*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed

set the damage either to cursor plane size or fallback to 256x256.

* pointermgr: dedup if hw cursorsize checks

dedup a bit if else casing
2026-02-21 20:29:00 +00:00
Tom Englund
9f59ed7868
multigpu: fix multi gpu checking (#13277)
* multigpu: fix multi gpu checking

drmFD() from allocators is not always equal, because we reopen them
inside AQ for refcounting, meaning they get duplicated and become their
own fds, so checking if fd1 == fd2 ends up wrong.

introduce sameGpu in MiscFunctions that checks the actual drmDevice
meaning we can now even check if a rendernode is the same gpu as a
display node if we want.

* multigpu: move sameGpu to DRM namespace

move sameGpu out of MiscFunctions to DRM namespace.
2026-02-21 20:27:59 +00:00
Vaxry
a20142bcce
xwayland/xwm: fix window closing when props race
we need to recheck before closing, ideally on change but that's later
2026-02-21 14:40:36 +00:00
Vaxry
d91952c555
wayland/output: return all bound wl_output instances in outputResourceFrom (#13315)
ref https://github.com/hyprwm/Hyprland/discussions/13301
2026-02-20 22:31:59 +00:00
Murat65536
8b17a7404b
config/descriptions: fix use_cpu_buffer (#13285) 2026-02-20 17:57:08 +00:00
Vaxry
9ea6d0e15f
desktop/popup: only remove reserved for window popups 2026-02-19 17:41:17 +00:00
Vaxry
a1e62dcb12
welcome: skip in safe mode 2026-02-19 01:12:48 +00:00
Vaxry
7a566942d5
versionKeeper: ignore minor rev version
no point in firing the update screen when no breaking changes happen on point releases
2026-02-19 01:05:28 +00:00
Vaxry
68456a5d9a
desktop/window: add stable id and use it for foreign 2026-02-19 00:49:43 +00:00
Skidam
184af52f24
config: support no_vrr rule on vrr 1 (#13250) 2026-02-18 14:48:56 +00:00
Tom Englund
1af260ecbe
compositor: dont unlock all states on empty commits (#13303)
we cant unlock all states on empty commits, at best tryProcess them.

for example if a state is locked and waiting for a fence to become readable,
and another commit comes in we cant unlock it until the fence has actually signaled.
2026-02-18 14:29:35 +00:00
Dominick DiMaggio
0de216e783
cm: block DS for scRGB in HDR mode (#13262) 2026-02-17 13:57:46 +00:00
Mihai Fufezan
661314e134 CI/c-f check: adapt jidicula script 2026-02-16 15:45:10 +02:00
ssareta
17fc159ae2
desktop/windowRule: use content rule as enum directly (#13275) 2026-02-16 12:15:50 +00:00
bea4dev
6716b8a0e3
xwayland: fix size mismatch for no scaling (#13263) 2026-02-15 17:50:03 +00:00
flyingpeakock
59f19e465b
nix: fix evaluation warnings, the xorg package set has been deprecated (#13231)
Co-authored-by: Philip Johansson <philip@phlipphlop.me>
2026-02-15 17:53:28 +02:00
Mihai Fufezan
e6ca141364
CI/c-f check: set older clang ver 2026-02-15 00:53:57 +02:00
Kamikadze
48176160ab
commit-timing: avoid use-after-free in timer callback (#13271) 2026-02-14 13:09:25 +00:00
Vaxry
e5a2b9e5b0
hyprctl: bump hyprpaper protocol to rev 2 (#12838) 2026-02-14 13:08:13 +00:00
garypippi
e80f705d76
compositor: guard null view() in getWindowFromSurface (#13255) 2026-02-13 23:52:15 +00:00
Tom Englund
1bf410e1fc
renderer: fix dgpu directscanout explicit sync (#13229)
* directscanout: fix dgpu directscanout explicit sync

without setting an infence, AQ doesnt explicit sync, nor recreate the
dgpu fence for the blit work. and as such attemptdirectscanout path
artifacts and breaks. create a dummy CEGLSync even tho we dont really
have any pending glwork to get a proper fence, and set it.

* monitor: dont use new scheduling if direct scanout

using the new_render_scheduling makes no sense in the direct scanout
path, add a if guard against it.
2026-02-13 23:52:00 +00:00
vaxerski
1c767de9da [gha] Nix: update inputs 2026-02-13 23:42:49 +00:00
Kirill Unitsaev
a8a8929bb4
i18n: update russian translation (#13247) 2026-02-13 23:40:57 +00:00
Yingjie Wang
eb0d3f9f01
cmake: use OpenGL::GLES3 when OpenGL::GL does not exist (#13260)
This will allow to build on some systems without X.
2026-02-13 23:40:30 +00:00
Kamikadze
81a029e504 hyprpm: exclude glaze from all targets during fetch 2026-02-12 00:12:42 +02:00
Mihai Fufezan
380d14998e nix: remove glaze patch
Signed-off-by: Tyr Heimdal <tyr.heimdal@warning.no>
2026-02-12 00:01:33 +02:00
Tyr Heimdal
fd48d102e1 Reapply "hyprpm: bump glaze version"
This reverts commit e92b20292b.
2026-02-12 00:01:33 +02:00
EvilLary
531fc43203
cmake: bump wayland-server version to 1.22.91 (#13242) 2026-02-11 12:05:58 +02:00
Vaxry
5b6c42ca70
dynamicPermManager: fix c+p fail 2026-02-10 15:13:25 +00:00
Vaxry
857a78ce4e
hyprpm: add full nix integration (#13189)
Adds nix integration to hyprpm: hyprpm will now detect nix'd hyprland and use nix develop instead

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2026-02-10 15:12:43 +00:00
Vaxry
339661229d
desktop/reserved: fix a possible reserved crash (#13207) 2026-02-10 14:59:21 +00:00
UjinT34
ff061d177e
protocols: commit and presentation timing fixes (#13174)
* move commit timing fields to surface state

* fix toTimespec init

* update sendQueued api

* update onPresented api

* set zero copy flag

* send clock id

* move presented calcs inside condition

* use only CLOCK_MONOTONIC for commit/presentation timings

* fix setSetTimestamp

* do not wait for commit timing while tearing

* proto config

* fix config defaults
2026-02-10 14:55:21 +00:00
ItsOhen
407a623801
hyprctl: add error messages to hyprctl hyprpaper wallpaper (#13234) 2026-02-10 14:52:31 +00:00
bea4dev
171ad7d338
input: fix kinetic scroll (#13233) 2026-02-10 14:51:51 +00:00
vaxerski
f16ebef003 [gha] Nix: update inputs 2026-02-09 12:53:15 +00:00
Aurelle
6507445787
layershell: restore focus to layer shell surface after popup is destroyed (#13225) 2026-02-09 12:51:25 +00:00
G36maid
f68ac7ef75
i18n: add Traditional Chinese (zh_TW) translations (#13210)
* i18n: add Traditional Chinese (zh_TW) translations

* i18n: add missing Simplified Chinese (zh_CN) translations
2026-02-07 13:27:10 +00:00
UjinT34
60f1c61323
protocols/dmabuf: fix DMA-BUF checks and events (#12965) 2026-02-07 12:40:08 +00:00
UjinT34
9f9dbb0dc5
renderer: allow tearing with DS with invisible cursors (#13155) 2026-02-07 12:38:01 +00:00
Vaxry
cfbbfb591a
popup: reposition with reserved taken into account
ref https://github.com/hyprwm/Hyprland/discussions/13194
2026-02-07 11:11:45 +00:00
Tom Englund
63eb6b3bda
opengl: add debug:gl_debugging (#13183)
add debug:gl_debugging so we can disable gl debugging entirerly,
both glGetError and enabling EGL_KHR_debug has its cost, we still have
EXT_create_context_robustness and glGetGraphicsResetStatus that should
catch context loss, and is generally cheap to call it only checks a flag
set.

glGetError might cause a implicit flush to get any pending calls sent to
the gpu.

however to get EGL_KHR_debug back enabled we now require a restart of
the compositor after changing debug:gl_debugging
2026-02-06 21:02:20 +00:00
EvilLary
8606bc255b
proto/shm: update wl_shm to v2 (#13187) 2026-02-06 17:08:30 +00:00
Yash Dodwani
562171ab66
i18n: add bengali translations (#13185) 2026-02-05 22:35:59 +00:00
Vaxry
9ce9ef2705
decorations/border: fix damage scheduling after #12665 2026-02-05 18:07:03 +00:00
UjinT34
02ff413002
monitor: fix DS deactivation (#13188) 2026-02-04 12:42:43 +00:00
UjinT34
1bc857b12c
fifo: miscellaneous fifo fixes (#13136)
* LOGM: clang-tidy fix

* fix fifo state and scheduling

* disable fifo_pending_workaround by default

* fix tearing

* fix "empty" commit skipping
2026-02-04 00:27:48 +00:00
EvilLary
cd7bdc7a43
hyprerror: add padding & adjust for scale when reserving area (#13158) 2026-02-03 20:44:41 +00:00
EvilLary
e123fd3e66
monitor: revert "remove disconnected monitor before unsafe state #12544" (#13154) 2026-02-03 20:44:18 +00:00
Łukasz Rek
30756d8718
gestures/fs: remove unneeded floating state switch (#13127) 2026-02-03 00:49:05 +00:00
UjinT34
9433060760
renderer: fix screen export back to srgb (#13148) 2026-02-02 20:33:03 +00:00
Vũ Xuân Trường
a0ec2e4daf
i18n: add Vietnamese translation (#13163) 2026-02-01 16:59:15 +00:00
Luke Barkess
d9d9d9358f
gestures: add cursor zoom (#13033) 2026-02-01 14:32:47 +00:00
ekhadley
95c8f8b299
input: fix edge grab resize logic for gaps_out > 0 (#13144) 2026-02-01 14:29:35 +00:00
Tom Englund
beeca9dacb
xwayland: ensure NO_XWAYLAND builds (#13160)
add , using xcb_atom_t = uint32_t;
2026-02-01 14:27:37 +00:00
Tom Englund
47f9035601
time: ensure type correctness and calculate nsec correctly (#13167)
use auto for nsecdur, assigning system_tp into steady_tp compiles but is
not correct. just change it to auto.

use {} initialization for timespec structs and returning std::pair.

in timediff, fromTimespec and toTimespec the else case was calculating
wrong. we need to correctly handle the borrow when the nanoseconds of
the first time are smaller than the second, by adding TIMESPEC_NSEC_PER_SEC
and decrementing the seconds.
2026-02-01 14:18:06 +00:00
jmanc3
db6114c6c5
renderer/pass: fix surface opaque region bounds used in occluding (#13124) 2026-01-31 13:39:22 +00:00
Szwagi
cbeb6984e7
renderer: fix mouse motion in VRR (#12665) 2026-01-31 13:37:01 +00:00
Tom Englund
4330b49a84
buffer: add move constructor and operator to CHLBufferReference (#13157)
add missing move constructor and operator, a lot of churn was done on
always copying CHLBufferReference, also add a self copy check.
2026-01-31 13:35:39 +00:00
Tom Englund
2ad7f6edd4
xwayland/xwm: get supported props on constructing surface (#13156)
not all clients supports WM_DELETE_WINDOW like glxgears, so get
supported props in constuctor of surface, and if not supported
forcefully kill the client.
2026-01-31 13:35:06 +00:00
Tom Englund
ec120d5732
opengl: set EGL_CONTEXT_RELEASE_BEHAVIOR_KHR if supported (#13114)
EGL_CONTEXT_RELEASE_BEHAVIOR_KHR determines what happends with implicit
flushes when context changes, on multigpu scenario we change context
frequently when blitting content. while we still rely on explicit sync
fences, the flush is destroying driver optimisations.

setting it to EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR essentially mean
just swap context and continue processing on the next context.
2026-01-30 19:42:01 +00:00
Tom Englund
fe6c213024
xwayland/xwm: fix _NET_WM_STATE_MAXIMIZED_VERT type (#13151)
add _ infront of the atom name. as it should be.
2026-01-30 19:35:52 +00:00
Zynix
b8fc0def97
xwayland/xwm: handle INCR clipboard transfer chunks correctly (#13125)
Handle XCB_PROPERTY_NEW_VALUE events for incremental selection transfers.
Previously only DELETE was handled, causing INCR transfers to fail after
the first chunk.
2026-01-30 14:14:17 +00:00
Zynix
c92fb5e85f
xwayland/xwm: prevent onWrite infinite loop and clean orphan transfers (#13122)
Fixes #11411

- Add return 0 after erasing completed non-incremental transfer to stop event source polling
- Add removeTransfer() helper to SXSelection for cleaning transfers by window ID
- Add removeTransfersForWindow() helper to CXWM for cleaning all selections at once
- Clean orphan transfers in handleDestroy before surface removal
- Clean orphan transfers in handlePropertyNotify on missing window or failed reply
- Add m_dndSelection to handleSelectionPropertyNotify cleanup loop
- Initialize SXTransfer members with safe defaults to prevent undefined behavior
- Fix race condition in getTransferData by using window ID lookup instead of index
2026-01-29 13:50:17 +00:00
Mihai Fufezan
7d209b2941
Nix: apply glaze patch 2026-01-29 13:16:59 +02:00
Mihai Fufezan
e92b20292b
Revert "hyprpm: bump glaze version"
This reverts commit 116537b494.

Re-apply when glaze 7.0.0 lands in Arch repos.

Relevant discussion: https://github.com/hyprwm/Hyprland/discussions/13043#discussioncomment-15636089
2026-01-29 13:14:05 +02:00
Mihai Fufezan
22e53345ba
flake.lock: update 2026-01-29 01:38:41 +02:00
Mihai Fufezan
116537b494
hyprpm: bump glaze version 2026-01-29 01:37:09 +02:00
jmanc3
c8b5023bb0
opengl: allow texture filter to be changed (#13078)
* opengl: allow texture filter to be changed

* format

* correct filter

* Moved from OpenGL.hpp to Texture.hpp

* Shortened names
2026-01-27 21:21:53 +00:00
ItsOhen
bcb34275ea
hyprctl: fix layerrules not being applied dynamically with hyprctl (#13080) 2026-01-27 12:13:29 +00:00
Tom Englund
21325f9385
eventLoop: various eventloopmgr fixes (#13091)
* eventloopmgr: use unordered_map for readableWaiters

use an unordered_map with the raw ptr as key, avoids any risk of
dangling ptrs.

* eventloopmgr: read the timerfd fd

the manpage for timerfd_create and read states this.

timefd_create creates a new timer object, and returns a file descriptor
that can be used to read the number of expirations that have occurred.

The FD becomes readable when the timer expires.

read removes the “readable” state from the FD.

so most likely it has somewhat worked because of the scheduleRecalc()
function.

* eventloopmgr: avoid unneeded std::function copy

move the idle functions instead of copying.

* eventloopmgr: remove event source before calling fn

if fn causes a dispatch/reentry its gonna cause UB inside libwayland
itself, remove the event source before calling the fn() avoids that
entirerly. even if a new dispatch occurs.

* eventloopmgr: check if timer fd is readable

check if timerfd is readable before calling read on it, so we dont end
up blocking on an accident, log an error if its not readable.

* eventloopmgr: revert unordered_map change

my mistake, the address wasnt changing on reallocations of the heap
object. the only issue i was triggering was the reentry path in fn()
2026-01-27 12:11:54 +00:00
Viorel Ciobotaru
50454c6d17
i18n: add Romanian translations (#13075) 2026-01-27 00:20:56 +02:00
Vaxry
c65c7614bc
hyprpm: fix build step execution 2026-01-24 20:00:56 +00:00
Naufal Hisyam Muzakki
891e029ba3
hyprctl: add overFullscreen field in hyprctl window debug (#13066) 2026-01-24 19:53:40 +00:00
Michał Minarowski
b1d1c9843f
hyprctl: remove trailing comma from json object (#13042) 2026-01-23 20:40:50 +00:00
Tom Englund
2a2c2b0e28
opengl/fb: use GL_DEPTH24_STENCIL8 instead of GL_STENCIL_INDEX8 (#13067)
older drivers lack support for GL_STENCIL_INDEX8 so use
GL_DEPTH24_STENCIL8 but explicitly disable the depth.
2026-01-23 20:09:39 +00:00
Vaxry
64db62d7e2
hyprpm: use provided pkgconf env if available
this is required for hyprpm to work under nix develop
2026-01-22 20:33:36 +00:00
UjinT34
82de66a030
renderer: fix frame sync (#13061)
* fix commit timing timer

* fix surface state lock/unlock

* debug state sync todos

* debug solitary vrr
2026-01-22 15:16:52 +00:00
Florent Charpentier
22fc8136a2
desktop/windowRule: allow expression in min_size/max_size (#12977) 2026-01-21 15:56:51 +00:00
Naufal Hisyam Muzakki
e7985ca4c4
desktop: restore invisible floating window alpha/opacity when focused over fullscreen (#12994) 2026-01-21 15:55:12 +00:00
UjinT34
6c3ebed76e
renderer: add surface shader variants with less branching and uniforms (#13030)
* shader variant features

* getSurfaceShader variant with feats

* split surface shaders by features

* cleanup old shaders
2026-01-21 15:54:14 +00:00
William Wernert
f9fb24577a
animation: reset tick state on session activation (#13024)
After suspend/wake, the animation tick timer state (m_lastTickValid,
m_tickScheduled) could be stale, causing framerate drops when blur is
enabled. This was introduced in 2b0fd417 which changed the animation
tick timing mechanism.

Reset the tick state when the session becomes active to ensure a clean
state for the animation system.
2026-01-21 15:54:02 +00:00
UjinT34
55f40ecc95
renderer: fix non shader cm reset (#13027) 2026-01-21 14:03:37 +00:00
Vaxry
441a8714c7
hyprpm: fix clang-format 2026-01-21 13:58:09 +00:00
Luke Barkess
57e6a57e6b
hyprerror: clear reserved area on destroy (#13046) 2026-01-21 13:57:36 +00:00
ArchSav
c44292c723
protocols/toplevelExport: Support transparency in toplevel export (#12824) 2026-01-20 15:32:32 +01:00
Mihai Fufezan
f0b6714539
Nix: re-enable hyprpm 2026-01-20 13:34:25 +02:00
Mihai Fufezan
8f547c6fa0
hyprpm: drop meson dep 2026-01-20 13:34:25 +02:00
Mihai Fufezan
d6e2ae0247
hyprpm,Makefile: drop cmake ninja build 2026-01-20 13:34:25 +02:00
Nikolai Nechaev
eb0480ba0d
tests: Test the no_focus_on_activate window rule (#13015) 2026-01-18 15:22:33 +01:00
Tom Englund
0896775f1b
pointermgr: remove onRenderBufferDestroy (#13008)
set the damage to cursor plane size instead of INT16_MAX and remove
onRenderbufferDestroy, renderbuffer already have a listener that
destroys when buffer is destroyed.
2026-01-18 13:51:14 +01:00
Tom Englund
c99eb23869
renderer: optimise shader usage further, split shaders and add more caching (#12992)
* shader: split CM rgba/rgbx into discard ones

make it branchless if we have no discards.

* shader: ensure we dont stall on vbo uv buffer

if we render a new texture before the previous was done gpu wise its
going to stall until done, call glBufferData to orphan the data.
this allows the driver to return a new memory block immediately
if the GPU is still reading from the previous one

* protocols: ensure we reset GL_PACK_ALIGNMENT

reset GL_PACK_ALIGNMENT back to the default initial value of 4

* shader: use unsigned short in VAO

loose a tiny bit of precision but gain massive bandwidth reductions.
use GL_UNSIGNED_SHORT and set it as normalized. clamp and round the UV
for uint16_t in customUv.

* shader: interleave vertex buffers

use std::array for fullverts, use a single interleaved buffer for
position and uv, should in theory improve cache locality. and also remove
the need to have two buffers around.

* shader: revert precision drop

we need the float precision because we might have 1.01 or similiar
floats entering CM shader maths, and rounding/clamping those means the
maths turns out wrong. so revert back to float, sadly higher bandwidth
usage.

* update doColorManagement api

* convert primaries to XYZ on cpu

* remove unused primaries uniform

---------

Co-authored-by: UjinT34 <ujint34@mail.ru>
2026-01-17 15:31:19 +01:00
Tom Englund
92a3b91999
anr: remove window on closewindow (#13007)
m_data was never cleaned and continously built up the m_data, remove
the entry on closeWindow.
2026-01-17 10:23:09 +01:00
Vaxry
36aa465a21
cmakelists: add fno-omit-frame-pointer for tracy builds 2026-01-16 16:59:46 +01:00
Vaxry
fec17e5e79
desktop/ruleApplicator: fix typo in border color rule parsing (#12995)
ref https://github.com/hyprwm/Hyprland/discussions/12746
2026-01-16 16:43:25 +01:00
Vaxry
eff484b96c
core: optimize some common branches 2026-01-16 16:40:48 +01:00
Vaxry
2e697ce2bf
cmakelists: don't require debug for tracy 2026-01-16 16:26:58 +01:00
Vaxry
0b13d398fe
desktop/window: avoid uaf on instant removal of a window
ref https://github.com/hyprwm/Hyprland/discussions/12999
2026-01-16 09:11:21 +01:00
Vaxry
ac9df44788
desktop/workspaceHistory: fix tracking for multiple monitors (#12979) 2026-01-15 17:00:47 +01:00
UjinT34
e0cf88809d
protocols/cm: Fix image description info events (#12781)
* fix image description info events

* always send some target primaries

* set edid values as target primaries and luminances

* init monitor image description

* set default luminances for tf

* fix BT1886 luminances

* fix mastering values and overrides

* set maxCLL & maxFALL

* typo

* add FALL & CLL to preferred HDR image description

* fix ref luminances
2026-01-13 16:44:36 +01:00
Tom Englund
e43f949f8a
shm: ensure we use right gl unpack alignment (#12975)
gl defaults to 4 and not all formats is divisible with 4 meaning its
going to pad out ouf bounds and cause issues. check if the stride is
divisible with 4 otherwise set it to 1, aka disable it.

GL_UNPACK_ALIGNMENT only takes 1,2,4,8 but formats like RGB888 has
bytesPerBlock 3.
2026-01-13 16:42:31 +01:00
Chris Naporlee
8d03fcc8d7
protocols/syncobj: fix DRM sync obj support logging (#12946) 2026-01-12 18:28:08 +01:00
Tom Englund
5e18111121
renderer: shader code refactor (#12926)
* shader: begin the shader refactor

make SShader a class and rename it to CShader, move createprogram,
compileshader, logshadererror to CShader.

* shader: move uniform creation to CShader

move uniform creation to CShader, reduces tons of duplicated effort,
however forcing uniform names to be same in all shaders.

* shader: move to array based frag handling

use an array with an enum so it gets easier dealing with multiple
shaders, move creating program to a for loop and array, reduces line of
code a lot.

* shader: use shared ptr for frags

with smart pointers we can now rename useProgram to useShader and return
the shader directly, means only place we have to decide the shader frag
is when calling useShader. easier for future shader splitting to reduce
branching.

* shader: move unneded public members to private

move structs and uniforms to private add a get/set for initialtime
and add a getUniformLocation to make the code tell what its doing,
instead of direct array getting when all we wanted to get was its value,
also limits the setting of uniformLocations to the createProgram as it should
be.

* shader: fix style nits

set first enum member to 0 , remove extra {}

* shader: dont show a failed notif on success

the logic got inverted in the refactor here.

* shader: split CM shader to rgba/rgbx variants

split shader to rgba/rgbx variants, use bool, and reduce branching.

* shader: split up blurprepare CM and non CM

split up blurprepare, remove skipcm, move gain to gain.glsl.
remove ternary operator and reduce branching by using step() and mix()
use vec3 for gain, make brightness a cheap mulitplication with max.

* shader: split up border to CM/noncm variants

splitup border shader to CM/noncm variant, move common used things to
border.glsl , there is room for optimisations here but its a complex
shader im putting it for future PR.

* shader: touchup blurfinish

make brightness a cheap multiplication instead of branching.
mod is redundant, fract in hash already returns a value in [0.0, 1.0]
2026-01-12 18:27:16 +01:00
Vaxry
fbf421df88
LICENSE: update year 2026-01-11 16:13:52 +01:00
zacoons
8f8b31e7a6
decoration: take desiredExtents on all sides into account (#12935) 2026-01-10 20:53:57 +01:00
Austin Horstman
81e7498ec2 nix: add hyprland-uwsm to passthru.providedSessions
Fix issue with displayManager `defaultSession` not accepting the
stringsince it's missing from the lookup it does
with`passthru.providedSessions`.
2026-01-10 01:09:41 +02:00
John Mylchreest
fa41c8229d
desktop/window: track explicit workspace assignments to prevent X11 configure overwrites (#12850)
* fix: track explicit workspace assignments to prevent X11 configure overwrites

Instead of only checking for special workspaces, track when workspaces are
explicitly assigned via window rules or user actions (movetoworkspace).
This prevents onX11ConfigureRequest from overwriting any explicit workspace
assignment based on window position.

Changes:
- Add m_workspaceExplicitlyAssigned flag to CWindow
- Set flag when window rules assign workspace
- Set flag when user moves window via dispatcher
- Check flag in onX11ConfigureRequest instead of just special workspace
- Add debug logging for explicit workspace assignments

* fix: simplify X11 configure request handling for special workspaces

X11 apps send configure requests with positions based on XWayland's
monitor layout, which could incorrectly move windows off special
workspaces.

Skip workspace reassignment when the window is on a special workspace
or staying on the same monitor, but always run z-order, fullscreen flag,
and damage logic since the configure request may include geometry changes.
2026-01-09 19:25:37 +01:00
John Mylchreest
5b1b79c29c
fix: handle fullscreen windows on special workspaces (#12851)
* fix: handle fullscreen windows on special workspaces

inFullscreenMode() only checked m_activeWorkspace, missing fullscreen
windows on special workspaces. This caused crashes and incorrect
behavior when fullscreen windows were on special workspaces.

Changes:
- inFullscreenMode() now checks special workspace first since it
  renders on top of regular workspaces
- Added getFullscreenWindow() helper to safely get fullscreen window
  from either active or special workspace
- Updated callers (shouldSkipScheduleFrameOnMouseEvent, Renderer,
  getFSImageDescription) to use the new helper
- Reset m_aboveFullscreen for layer surfaces when opening, closing,
  or stealing special workspaces between monitors

* test: add special workspace fullscreen detection tests

Add tests for the new special workspace fullscreen handling introduced
in the previous commit. The tests cover:

1. Fullscreen detection on special workspace - verifies that a window
   made fullscreen on a special workspace is correctly detected

2. Special workspace fullscreen precedence - verifies that when both
   regular and special workspaces have fullscreen windows, the special
   workspace window can be focused when the special workspace is opened

3. Toggle special workspace behavior - verifies that toggling the
   special workspace off properly hides it and returns focus to the
   regular workspace's fullscreen window

These tests exercise the key code paths modified in the fix:
- inFullscreenMode() checking special workspace first
- getFullscreenWindow() helper returning correct window
- Layer surface m_aboveFullscreen reset on special workspace toggle
2026-01-08 22:27:00 +01:00
Vaxry
eb623bd91d
animationMgr: avoid uaf in ::tick() if handleUpdate destroys AV
ref https://github.com/hyprwm/Hyprland/discussions/12840
2026-01-08 22:22:58 +01:00
Vaxry
3dcaadbdf5
desktop/ls: fix invalid clamp 2026-01-08 22:22:58 +01:00
Aaron Blasko
a649dbe4c4
main: add watchdog-fd and safe-mode options to help message (#12922)
Additionally, don't print the "you're not using start-hyprland" warning when using `--verify-config`
2026-01-08 17:50:11 +01:00
Vaxry
f767782e3f
desktop/reservedArea: clamp dynamic types to 0
ref https://github.com/hyprwm/Hyprland/discussions/12880
2026-01-08 12:25:39 +01:00
Vaxry
f54dd4da4a
desktop/reservedArea: clamp to 0
ref https://github.com/hyprwm/Hyprland/discussions/12880
2026-01-08 12:24:29 +01:00
Vaxry
3aa4e02720
config: don't crash on permission with a config check
ref #12872
2026-01-08 12:19:22 +01:00
Vaxry
8368566044
start: use nixGL if Hyprland is nix but not NixOS (#12845)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2026-01-08 10:57:56 +01:00
Tom Englund
918e2bb9be
renderer/gl: add internal gl formats and reduce internal driver format conversions (#12879)
* format: add internal formats for drm formats

cross referenced with weston and added internal formats and types for a
lot of missing ones. also added a isFormatYUV helper.

* framebuffer: ensure we use right internalformat

ensure we use the right internal format to avoid internal driver
blitting, also since we only attach the GL_STENCIL_ATTACHMENT we might
just aswell only use the GL_STENCIL_INDEX8 to not confuse drivers that
we want a depth aswell.

* texture: use external on yuv or non linear mods

using external makes us use the gpu's internal detiler.
and this is makes intel a lot happier then having to format convert it
to a linear format internally.

* shaders: add external support to CM frag

add external support to CM frag, and correct ext.frag typo.

* formats: remove duplicates and fix a typo in cm.frag

remove duplicate formats and a typo in cm.frag

* formats: add swizzle logic to all formats

add swizzle logic from weston for all formats and use it in shm texture
paths.

* format: more format changes

use monitor drm format instead of forcing something different.

* shader: remove external from cm.frag

drivers want this resolved at compiletime cant use both
samplerExternalOES and sampler2d and then runtime branch it.

* screencopy: swizzle textures in screencopy

swizzle textures in screencopy, to get the right colors when copying.

* screencopy: restore old behaviour

try restore old behaviour before the gles3 format changes.
glReadPixels had the wrong format, so i went to far trying to mitigate
it. should be like before now.
2026-01-07 19:53:42 +01:00
wbg
a383ca1866
groupbar: added group:groupbar:text_padding (#12818)
Co-authored-by: Roman Weinberger // ACL <roman.weinberger@acl.at>
2026-01-07 16:52:02 +01:00
Hiroki Tagato
f1652b2951
start: add parent-death handling for BSDs (#12863)
* Add parent-death handling for BSDs

prctl() is a system call specific to Linux. So we cannot use it on BSDs.

FreeBSD has a system call procctl() which is similar to prctl(). We can
use it with PROC_PDEATHSIG_CTL.

OpenBSD, NetBSD, and DragonFly BSD do not appear to have a similar
mechanism. So intead of relying on a system call, we need to manually
poll ppid to see if the parent process has died.

With the changes, the spawned Hyprland process is terminated when the
launcher process exits, matching Linux behavior as closely as possible
on BSD platforms.

* Remove ppid polling on OpenBSD, NetBSD, and DragonFly BSD
2026-01-06 14:38:25 +01:00
EvilLary
cbfbd9712a
anr: open anr dialog on parent's workspace (#12509) 2026-01-06 14:29:17 +01:00
ItsOhen
9817553c66
config: return windowrulev2 layerrulev2 error messages (#12847) 2026-01-06 00:00:14 +01:00
Vaxry
6fce2d7288
renderer/opengl: invalidate intermediate FBs post render, avoid stencil if possible (#12848) 2026-01-05 22:37:54 +01:00
Vaxry
107275238c desktop/ls: clamp layer from protocol 2026-01-05 18:53:29 +01:00
Vaxry
3b77c784e2 protocols/contentType: fix missing destroy 2026-01-05 18:53:29 +01:00
Vaxry
d46df728fd protocols/contentType: fix typo in already constructed check 2026-01-05 18:53:29 +01:00
Vaxry
8eb3ecc755 input/TI: avoid UAF in destroy 2026-01-05 18:53:29 +01:00
Vaxry
97c8a2f1cf protocolMgr: remove IME / virtual input protocols from sandbox whitelist 2026-01-05 18:53:29 +01:00
Vaxry
a492fa3866 desktop/window: catch bad any cast tokens 2026-01-05 18:53:29 +01:00
Vaxry
e165f84184 core/compositor: immediately do readable if adding waiter fails for scheduling state 2026-01-05 18:53:29 +01:00
Vaxry
686eda9d48 eventLoop: remove failed readable waiters 2026-01-05 18:53:29 +01:00
Vaxry
70c5fe5cd8 systemd/sdDaemon: fix incorrect strnlen 2026-01-05 18:53:29 +01:00
Vaxry
32978176b1 systemd/sdDaemon: initialize sockaddr_un 2026-01-05 18:53:29 +01:00
Vaxry
1761909bca mainLoopExecutor: fix incorrect pipe check 2026-01-05 18:53:29 +01:00
Hiroki Tagato
7d8f57083e
testers: add missing #include <unistd.h> (#12862)
FreeBSD clang needs the header to be included for read(), write(),
pipe(), close(), etc.
2026-01-05 16:42:35 +01:00
Vaxry
a3c8533d74
subprojects: bump tracy 2026-01-05 12:57:40 +01:00
Tom Englund
0b3b012817
framebuffer: revert viewport (#12842)
to much stuff are relying on the viewport being set like this, just
revert it to not regress further. this needs a overhaul.
2026-01-04 11:44:19 +01:00
vaxerski
583c4074a5 [gha] Nix: update inputs 2026-01-03 21:12:46 +00:00
Virt
922e53c68c
pluginsystem: fix crash when unloading plugin hyprctl commands (#12821) 2026-01-03 22:11:05 +01:00
Tom Englund
17bc3b83db
renderer/fb: dont forget to set m_drmFormat (#12833)
fab3370 accidently removed the setting of m_drmFormat, causing it to
think format changed on each alloc.
2026-01-03 16:48:43 +01:00
Tom Englund
fab3370254
renderer: minor framebuffer and renderbuffer changes (#12831)
* framebuffer: dont release if format or size changes

we dont have to release and recreate both the texture and framebuffer if
size or format changes, we can just bind the texture and call glTexImage2D
with the new format and size.

* framebuffer: set the alloced viewport size

if monitor size mismatch with the allocated m_size its going to set a
mismatched viewport and cause rendering issues. and if they are
mismatching there is a missing alloc call.

* renderbuffer: cleanup unneded binds

the renderbuffer is attached to the fbo and trying to rebind it in
bind() is causing unnecessery state changes, just bind the fbo.

add safeguard in the destructor, the constructor can return early on
failure and leave m_rbo empty or m_image as EGL_NO_IMAGE_KHR.
2026-01-03 15:13:01 +01:00
Dmytro Budnyk
ee67278038
hyprerror: fix horizontal overflow and damage box (#12719)
* hyprerror: fix horizontal overflow and damage box

* hyprerror: remove redundant m_queued preservation logic

The logic to save and restore m_queued into a temporary string 'q' was redundant because m_queued is explicitly cleared at the end of createQueued() (line 164). Restoring it to a non-empty state would cause createQueued() to be called every frame in draw(), which is not the intended behavior for the static error bar.

* Fixes style
2026-01-02 20:10:47 +01:00
Vaxry
b9bd9d147f
desktop/layerRuleApplicator: fix an epic c+p fail
ref https://github.com/hyprwm/Hyprland/discussions/12779
2026-01-02 18:17:35 +01:00
Vaxry
ec4beb1b39
core/xwaylandmgr: fix min/max clamp potentially crashing 2026-01-02 14:06:46 +01:00
Vaxry
31d3181e1e
dekstop/window: read static rules before guessing initial size if possible (#12783) 2026-01-01 21:49:57 +01:00
Vaxry
9b93d621b1
desktop/window: use workArea for idealBB (#12802) 2026-01-01 16:48:23 +01:00
Vaxry
bd7f9aad05
input/ti: avoid sending events to inactive TIs
ref https://github.com/hyprwm/Hyprland/discussions/12105
2026-01-01 14:48:32 +01:00
Vaxry
48a024e032
desktop/window: remove old fn defs 2025-12-31 18:17:10 +01:00
Vaxry
bd02178e96
desktop/LS: avoid creating an invalid LS if no monitor could be found (#12787) 2025-12-31 18:13:42 +01:00
skrmc
214fdb099c
input: guard null view() when processing mouse down (#12772) 2025-12-31 14:00:11 +01:00
ArchSav
d622c09d09
tester: fix sleeps waiting for too long (#12774) 2025-12-31 13:08:40 +01:00
Vaxry
529559712b
desktop/window: go back to the previously focused window in a group (#12763) 2025-12-30 18:02:34 +01:00
Vaxry
293d3e5de9
desktopAnimationMgr: fix slide direction
ref https://github.com/hyprwm/Hyprland/discussions/12744
2025-12-30 14:09:13 +01:00
ArchSav
f8464866eb
keybinds: add inhibiting gestures under shortcut inhibitors (#12692) 2025-12-30 13:45:56 +01:00
Vaxry
ea444c35bb
version: bump to 0.53.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Nix / test (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
2025-12-29 16:21:36 +01:00
UjinT34
6a055fc747
cm: allow force disabling WCG and HDR per monitor (#12733) 2025-12-28 14:44:04 +01:00
Ikalco
a8452705d6 gitignore: add hyprland.desktop generated by cmake 2025-12-27 23:23:32 +02:00
Aditya Singh
e5d20b56bc
keybinds: simulate mouse movement after bringing active window to top (#12703)
Fixes https://github.com/hyprwm/Hyprland/discussions/12702
2025-12-27 21:27:59 +01:00
UjinT34
5faa66d297
protocols/cm: fix CColorManagementSurface m_imageDescription init (#12734) 2025-12-27 20:25:57 +01:00
Vaxry
610c59dc34
opengl: properly combine transforms in renderTexture
ref #12666
2025-12-27 20:18:57 +01:00
UjinT34
e5f22c06b4
master: fix placement with center_ignores_reserved (#12695) 2025-12-27 19:17:51 +01:00
UjinT34
6d3b17ee83
render/cm: various updates, remove old protocols (#12693)
* fix named primaries

* default to gamma22

* mark mastering primaries as supported

* remove xx-cm and frog support

* immutable primaries and image descriptions

* clang-format
2025-12-27 18:01:46 +01:00
Vaxry
42447a50d6
rules/windowRuleApplicator: fix min/max size effects (#12491)
fixes #12412
2025-12-27 12:43:45 +01:00
Mr. Goferito
d7f26038ee
keybinds: fix multikey binds breaking after scroll wheel events (#12638) 2025-12-26 23:16:31 +01:00
Vaxry
33df518f97
input: fix pending perm keyboards being enabled
fixes #12359
2025-12-26 16:08:31 +01:00
Mihai Fufezan
9ea565054a
example/hyprland.desktop: fix path 2025-12-26 14:39:29 +02:00
Mihai Fufezan
1f1a39d46c example/hyprland.desktop: install with full path in Exec 2025-12-25 20:36:32 +02:00
Mihai Fufezan
14c49230cc Nix: re-enable uwsm desktop file 2025-12-25 20:36:32 +02:00
Vaxry
2525052779
start: avoid crash in dtor after forceQuit 2025-12-24 20:27:00 +01:00
Vaxry
f7f357f15f
keybindmgr: fix focusCurrentOrLast 2025-12-23 15:04:56 +01:00
Vaxry
abffe75088
desktop/window: improve fullscreen handling for grouped windows
fixes #12700
2025-12-22 17:53:28 +01:00
Vaxry
60efbf3f63
desktop/ls: only update the ls in question for commit to change layer 2025-12-21 23:50:53 +01:00
UjinT34
712bcfbce5
protocols/xdg-shell: fix crash on null parent in pin (#12694) 2025-12-21 14:21:51 +01:00
boinq
c87a1a7629
i18n: add Danish translation (#12333) 2025-12-20 22:18:22 +00:00
ArchSav
7bd207377c
window: automatically pin child windows (#12224) 2025-12-20 22:17:56 +00:00
Vaxry
b9bef69554
Desktop/history: Move history to desktop (#12676) 2025-12-20 22:16:13 +00:00
Vaxry
70f54a1e1b
animationmgr: avoid possible uaf in handling anim updates 2025-12-20 19:13:04 +00:00
EvilLary
f6c5c659a7
i18n: Add Arabic translations for safemode (#12670)
* i18n: Add Arabic translations for safemode

* update
2025-12-20 17:57:19 +00:00
vaxerski
c23a0c20a4 [gha] Nix: update inputs 2025-12-20 17:54:34 +00:00
dylanetaft
3bbbb5aaca
core: add missing headers (#12686) 2025-12-20 17:52:54 +00:00
fuyu147
315806f598
tablet: added option to hide cursor (#12525) 2025-12-19 16:14:22 +00:00
Vaxry
6175ecd4c4
debug: move to hyprutils' logger (#12673) 2025-12-18 17:23:24 +00:00
Vaxry
f88deb928a
compositor: warn on start via a log about start-hyprland 2025-12-17 19:26:25 +00:00
Lichie
18901b8e59
desktop/windowRule: force center and move rules to override each other (#12618) 2025-12-17 18:23:12 +00:00
Vaxry
7098558420
desktop/layer: store aboveFs property and use that 2025-12-16 16:32:37 +00:00
SASANO Takayoshi
59438908de
i18n: more natural Japanese translation (#12649)
* more natural Japanese translation

* src/i18n/Engine.cpp: change パーミッション -> 権限, fix TXT_KEY_SAFE_MODE_BUTTON_UNDERSTOOD Japanese translation

* src/i18n/Engine.cpp: clang-format processed
2025-12-16 16:13:26 +00:00
Vaxry
cbfdbe9fa1
desktop/popup: fix invalid surface coord 2025-12-16 15:56:04 +00:00
Vaxry
c94a981711
input: simplify mouseMoveUnified a tad 2025-12-16 15:55:54 +00:00
Vaxry
beb1b578e8
input: cleanup sendMotionEventsToFocused() 2025-12-16 15:18:53 +00:00
Vaxry
c5beecb2c3
desktop/popup: minor improvements 2025-12-16 15:18:53 +00:00
Lichie
6e09eb2e6c
desktop/windowRules: fix disabling binary window rules with override (#12635) 2025-12-15 22:19:13 +00:00
Mason Davy
6b491e4d6b
core/compositor: remove a monitor reset on cleanup (#12645)
I've tested this change with different modes from the monitor default
and validated that dpms still works, at least on my machine. If there's
a good reason why this exists, feel free to correct me, but this helps
get us closer to a flicker-free experience.
2025-12-15 21:37:48 +00:00
Mihai Fufezan
4036c37e55
hyprctl: add nix flag (#12653) 2025-12-15 15:59:08 +00:00
Maximilian Seidler
7ccc57eb7c
animation: migrate PHLANIMVAR from SP to UP (#12486) 2025-12-14 19:46:49 +00:00
jmanc3
e4a8f2b14f
renderer: add zoom with detached camera (#12548) 2025-12-14 19:42:02 +00:00
Luke Barkess
6535ff07c9
anr: don't create for anr dialogs (#12601) 2025-12-14 17:19:35 +00:00
Luke Barkess
05ccbb2f2d
hyprpm: added plugin author (#12594) 2025-12-14 17:16:58 +00:00
Vaxry
09e195d1f2
compositor: fix isPointOnReservedArea 2025-12-13 13:55:49 +00:00
Vaxry
fd5e790d08
compositor: return nullptr when cursor is outside of a maximized windows' box 2025-12-13 13:55:48 +00:00
Tom Englund
69db0bcae6
compositor: early return on no monitor (#12637)
getMonitorFromVector can return nullptr on empty m_monitors, as such is
the case when the compositor is going down and a surface exist. return
early in vectorToWindowUnified if that happends.
2025-12-12 12:47:56 +00:00
Tom Englund
8dfdcfb353
compositor: dont try to focus unmapped window (#12629)
* compositor: dont try to focus unmapped window

if lastwindow is unmapped it hits getWindowInDirection and nullptr
derefs window->m_workspace. and coredumps. triggered by dual monitor and
one client on each surface with a combination of animation and
killactive / movefocus keybind.

* keybindmgr: use newly added aliveAndVisible()

use newly added aliveAndVisible() over visible()
2025-12-11 23:59:47 +00:00
Dominick DiMaggio
5700736505
cm: handle CM for SDR content with cm=hdr, cm_sdr_eotf=2 (#12127) 2025-12-11 23:50:57 +00:00
Tom Englund
75f6435f70
window: only damage floating on clamped size change (#12633)
currently it damage the entire window if its floating and not x11 nor
fullscreen meaning damage isnt working at all for floating. im tracing
this back to a364df4 where the logic changed from damaging window only
if size was being forced to now unconditonally doing it.

change clampWindowSize to return as a bool if size changed and only
damage window if it got clamped.
2025-12-11 18:54:43 +00:00
Vaxry
5dd224805d
desktop/view: use aliveAndVisible for most things (#12631) 2025-12-11 16:29:26 +00:00
Vaxry
2ca7ad7efc
ci: disable comments for members 2025-12-11 12:40:02 +00:00
Vaxry
9aa313402b
protocols/datadevice: avoid double leave
ref https://github.com/hyprwm/Hyprland/discussions/12494
2025-12-11 00:50:45 +00:00
Maximilian Seidler
1ff801f5f3
Nix: fix glaze build for CI and devShell (#12616) 2025-12-11 00:32:51 +00:00
Tom Englund
3cf6dfd7e6
opengl: default initialize m_capStatus (#12619)
ubsan reports under wonky situation a runtime error of uninitialized
value lookups because of m_capStatus isnt initialized. so default
initialize it.

OpenGL.cpp:3331:26: runtime error: load of value 190, which is not a valid value for type 'bool'
2025-12-11 00:32:11 +00:00
EvilLary
f58c80fd39
monitor: remove monitor from list on disconnect before unsafestate (#12544) 2025-12-09 22:30:35 +00:00
Aureus
6712fb954f
cmake: only use system glaze package if above version 6.0.0 (#12559) 2025-12-09 12:44:02 +00:00
Vaxry
efe665b455
protocols/compositor: fix null deref on unassigned surface image desc
ref #12603
2025-12-08 22:49:53 +00:00
Vaxry
920353370b
desktop: cleanup, unify desktop elements as views (#12563) 2025-12-08 15:04:40 +00:00
Hasan Arthur Altuntaş
834f019bab
cmake: fail if scripts/generateShaderIncludes.sh fails (#12588) 2025-12-08 13:49:23 +00:00
Vaxry
a5b7c91329
ci: run pr comment in target 2025-12-07 21:05:10 +00:00
byddha
916e5d1aea
renderer/cm: make needsHDRupdate per-monitor state (#12564)
Co-authored-by: drzbida <55928036+drzbida@users.noreply.github.com>
2025-12-07 20:47:27 +00:00
Matias Paavilainen
9584b2d40e
i18n: Added Finnish translations (#12505)
* desktop/overridableVar: improve performance

drop usage of ::map which sucks performance-wise

* Added Finnish translations

* Revised translations, and fixed html tags.

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2025-12-07 20:47:20 +00:00
Dominick DiMaggio
532ca053d6
renderer/cm: higher-quality tonemapping (#12204) 2025-12-07 17:58:49 +00:00
Nikolai Nechaev
ca99e8228c
internal/start: More careful signal handling (#12573)
- Take out signal set up into a subroutine;

- Use `sigaction` instead of `signal` for consistent behavior across UNIX platforms;

- Enable a warning when a signal handler set up fails;

- Don't do anything to SIGKILL, since it cannot be handled.
2025-12-07 17:53:24 +00:00
Khing
8ca40479a7
desktop: Update Exec command for UWSM Hyprland desktop entry (#12580)
* Update Exec command for UWSM Hyprland desktop entry

This is from the comment in https://github.com/hyprwm/Hyprland/pull/12484 

https://github.com/hyprwm/Hyprland/pull/12484#issuecomment-3621979533

* Update hyprland-uwsm.desktop dumb me
2025-12-07 17:48:14 +00:00
Vaxry
c26e91f074
ci: fix yaml file 2025-12-07 17:29:07 +00:00
Nikolai Nechaev
76ac655c9e
CI: add the start PR label for start-hyprland (#12574) 2025-12-07 10:49:12 +00:00
Vaxry
f8d5aad1a1
tests: fix a test case 2025-12-06 12:42:26 +00:00
Vaxry
b8bb5e9bde
renderer: avoid crash on arrangeLayers for an empty mon 2025-12-06 11:34:04 +00:00
vaxerski
7797deb935 [gha] Nix: update inputs 2025-12-06 11:33:40 +00:00
Vaxry
d3c9c54b79
layouts: fix maximize size 2025-12-06 11:32:01 +00:00
norinorin
cedadf4fdc
cmake: fix XKBCOMMON variable typo (#12550) 2025-12-06 00:48:38 +00:00
Nikolai Nechaev
222dbe99d0
keybinds: fix previous workspace remembering (#12399)
* swipe: Fix previous workspace remembering in workspace gesture

Fixes a bug that previous workspace does not exist after swiping to a workspace

* tests: Test that `workspace previous` works after workspace gesture

* moveActiveToWorkspace: remember previous workspace unconditionally
2025-12-05 20:43:30 +00:00
EvilLary
ebe74be75a
dispatcher: include mirrors of monitor in dpms (#12552)
* dispatcher/dpms: include mirrors

* use m_realMonitors instead
2025-12-05 20:29:39 +00:00
Vaxry
afeda6cee6
ci: add new pr comment workflow 2025-12-05 20:29:02 +00:00
Vaxry
6a1daff5f3
example/config: use hyprshutdown if available 2025-12-05 17:48:45 +00:00
Vaxry
016eb7a23d
start: init start-hyprland and safe mode (#12484) 2025-12-05 15:40:03 +00:00
Zeide
ec6756f961
cmake: add missing space (#12549) 2025-12-05 15:03:10 +00:00
Vaxry
9264436f35
desktop: rewrite reserved area handling + improve tests (#12383) 2025-12-05 14:16:22 +00:00
SAM
d5c52ef58e
renderer/cm: fix typo on color simage description op (#12551)
fix: typo on color simage description op
2025-12-05 14:11:52 +00:00
Gilang ramadhan
52b3c8cbc6
i18n: add Indonesian translations (#12468) 2025-12-04 20:42:13 +00:00
Aivaz Latypov
279a07c2ce
i18n: add Tatar translations (#12538) 2025-12-04 18:06:17 +00:00
Hleb Shauchenka
17ae3fb704
pointer: apply locked pointer workaround only on xwayland (#12402) 2025-12-04 18:05:50 +00:00
Björn Kettunen
43ed0db3b3
cmake: track dependencies in pkgconfig file (#12543)
Depedencies where not tracked in the pkgconfig leading to programs
who scan dependencies using it to fail/not track them.

I noticed this while building Hyprland on openSUSE where the -devel
package didn't include the dependencies it once had when Meson was
used previously.
2025-12-04 18:04:20 +00:00
jmanc3
38f912c401
renderer: remove unnecessary assert from renderRoundedShadow (#12540) 2025-12-04 18:03:12 +00:00
Vaxry
9cd070fd31
hyprpm: check for abi strings in headersValid (#12504)
---------

Co-authored-by: Virt <41426325+VirtCode@users.noreply.github.com>
2025-12-04 18:00:15 +00:00
Vaxry
d9657a95cb
hyprctl: use new hyprpaper ipc format (#12537)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-12-04 17:59:47 +00:00
Vaxry
9b1891e476
desktop/overridableVar: fix possible crash 2025-12-03 22:43:26 +00:00
Vaxry
93e5e92b0a
crashReporter: cleanup code (#12534)
various code cleanups, reorders, move off of global NS
2025-12-03 16:01:45 +00:00
UjinT34
3cf0280b11
renderer: add quirks:prefer_hdr to fix HDR activation for some clients (#12436) 2025-12-03 01:30:43 +00:00
Vaxry
2cadc8abab
welcome: init welcome manager (#12409)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-12-02 22:26:43 +00:00
littleblack111
f82a8630d7
desktop/rules: tag static rule being ignored (#12514)
* chore: apply exec rules after removal and use CWindowRule

* refactor: unregister exec rules after applying them

Remove the unused toRemove vector and defer unregistering exec rules
until after applyStaticRule/applyDynamicRule so exec rules are applied
before being removed from the rule engine.
2025-12-01 16:47:59 +00:00
Honkazel
bb963fb002
protocols/cursor-shape: impl version 2 (#12270) 2025-11-30 15:05:31 +00:00
EvilLary
f11cf6f1de
renderer: fix uv sufrace calc with scales < 1 (#12481) 2025-11-29 21:16:49 +00:00
Vaxry
574ee71d56
desktop/overridableVar: improve performance
drop usage of ::map which sucks performance-wise
2025-11-29 17:17:24 +00:00
ふゆ
7e1e24fea6
i18n: fix typos/unnatural spellings in french translation (#12443) 2025-11-27 22:51:34 +00:00
Vaxry
68eecf61cd
desktop/windowRule: return reset props from resetProps and recheck them (#12458)
fixes #12457
2025-11-27 21:14:24 +00:00
Vaxry
f9742ab501
keybinds: restore pointer warp on switch
ref https://github.com/hyprwm/Hyprland/pull/12033#pullrequestreview-3516413924
2025-11-27 21:10:01 +00:00
sadbhav
e42185b83d
i18n: add Nepali translations (#12451) 2025-11-27 19:34:51 +00:00
SASANO Takayoshi
a51918fd27
src/protocols/types/DMABuffer.cpp: <sys/ioctl.h> is required for ioctl(), not only linux (#12483) 2025-11-27 15:52:04 +00:00
Hiroki Tagato
379ee99c68
window: implement CWindow::getEnv() for BSDs (#12462)
Some BSDs provide procfs to access kernel information. However, BSDs'
procfs does not provide information on a process' environment
variables. Instead sysctl(3) function is usually used for system
information retrieval on BSDs.
2025-11-26 22:12:50 +00:00
Tom Englund
4036e35e73
protocols/lock: fix missing output enter on surface (#12448) 2025-11-26 22:12:17 +00:00
Luke Barkess
d21f2e5729
config: move config parsers to VarList2 (#12465) 2025-11-26 22:11:29 +00:00
SASANO Takayoshi
4e5a284bc4
CMakeLists.txt: improve libudis86 and librt detection (#12472) 2025-11-26 22:10:02 +00:00
Tom Englund
210930bef9
buffers: revert state merging (#12461)
8e8bfbb0b1 added fifo and merged non
buffer states before comitting them, something about certain xwl non
buffer commits expects a commit to happend and causes regressions as in
low fps.
2025-11-25 22:51:51 +00:00
Nikolai Nechaev
40d8fa8491
compositor: Configurable behavior when window to be focused conflicts with fullscreen (#12033)
Renames `misc:new_window_takes_over_fullscreen` into
`misc:on_focus_under_fullscreen` and implements the following behavior:

- By default, when a tiling window is being focused on a workspace where
  a fullscreen/maximized window exists, respect
  the `misc:on_focus_under_fullscreen` config variable.
2025-11-25 22:44:26 +00:00
Tim
1c1746de61
i18n: add Croatian translations (#12374) 2025-11-25 14:21:45 +00:00
vaxerski
619e9d285b [gha] Nix: update inputs 2025-11-25 13:41:42 +00:00
Tomáš Zierl
ec3b3403e7
i18n: add Czech translations (#12428) 2025-11-25 13:40:25 +00:00
Vaxry
703394affb
protocols/workspace: avoid crash on inert outputs 2025-11-25 13:35:25 +00:00
Vaxry
fe6a855bbb
renderer: stop looping over null texture surfaces (#12446)
fixes #12445
2025-11-24 23:48:18 +00:00
EvilLary
475e87b351
windowrules: fix persistent_size not applying (#12441) 2025-11-24 23:48:10 +00:00
SASANO Takayoshi
3d7ea9c02f
CrashReporter.cpp: fix stderr conflict (#12440) 2025-11-24 20:11:15 +00:00
bea4dev
2b0fd417d3
animation: improve animations on multi refresh rate monitors (#12418) 2025-11-23 15:48:15 +00:00
OCbwoy3
56904edbd2
i18n: add Latvian translations (#12430) 2025-11-23 12:37:19 +00:00
Luke Barkess
e584a8bade
config: added locale config option (#12416) 2025-11-22 13:59:36 +00:00
Vaxry
2ac9ded2ac
ci: fix ai workflow for the nth time 2025-11-22 13:56:41 +00:00
Vaxry
abb2f7ee6f
renderer: fix render_unfocused 2025-11-21 18:48:45 +00:00
Vaxry
79a2781923
protocols/workspace: fix crash in initial group sending
fixes #12419
2025-11-21 14:46:05 +00:00
Mihai Fufezan
d66c9222b0
CI/AI translate: expose output 2025-11-21 14:17:16 +02:00
Pastilhas
b5a2ef77b7
i18n: add Português (Portugal) translation (#12328) 2025-11-20 23:37:00 +00:00
Hleb Shauchenka
c5d45b7653
hyprctl: fix no_vrr prop ref (#12410) 2025-11-20 22:40:39 +00:00
Vaxry
c249a9f4b8
windowrules: fix group rule recalcs (#12403) 2025-11-20 16:57:31 +00:00
Raúl Salinas
00cce1c8ff
i18n: improve Spanish translations for clarity and consistency (#12378)
* i18n: improve Spanish translations for clarity and consistency

Improve the Spanish translation strings in Engine.cpp by:

- Refining ANR (Application Not Responding) dialog to use "La aplicación"
  and change the terminate option to "Forzar cierre" for clarity
- Standardizing permission prompts with "¿Deseas...?" for consistency
- Rewording keyboard permission prompt: "permitir su uso" is clearer than
  "permitir su funcionamiento"
- Adding explicit reference to "permisos" in the persistence hint
- Improving Wayland app identification: "ID de cliente de Wayland" instead
  of "wayland client ID {wayland_id}"
- Enhancing environment variable notification with better punctuation and
  clarity ("gestionarse externamente" vs "estar gestionada externamente")
- Simplifying hyprland-guiutils message with direct, concise wording
- Rewriting failed assets lambda to be more natural and add context about
  distribution packagers
- Improving monitor-related messages with clearer tone and better sentence
  structure (monitor layout, mode fallback, auto-scale)
- Using "shader" instead of "sombreador" (more common in Spanish tech)
- Changing "10-bit" to "10 bits" for proper Spanish plural form

Overall tone improvements include consistent use of "tú" forms and clearer,
more natural Spanish phrasing throughout the user-facing messages.

* i18n: update Spanish error messages for clarity and support
2025-11-20 12:32:58 +00:00
Mihai Fufezan
6b8e3358d6
CI/AI translate: change path filter action 2025-11-20 14:31:11 +02:00
MithicSpirit
80b96a3166
hyprctl: show contentType in activewindow (#12214) 2025-11-20 12:01:07 +00:00
Aaron Blasko
f9d1da6667
i18n: slight update to it_IT translations (#12372) 2025-11-19 23:37:55 +00:00
Vaxry
7532115318
rule: nuke parseRelativeVector 2025-11-19 19:08:27 +00:00
Tetrapak
1c29d6b1ba
i18n: add Slovenian translation (#12369) 2025-11-19 18:33:44 +00:00
MyNameIsKitsune
d0503bea43
i18n: add Ukrainian translation (#12370) 2025-11-19 18:33:22 +00:00
Mihai Fufezan
fbb31503f1
CI/AI translate: fix yet again 2025-11-19 10:13:54 +02:00
xyrd
9f02dca8de
i18n: add Norwegian Bokmål translations (#12354) 2025-11-19 01:00:13 +00:00
Kamikadze
6a8d306992
examples: fix example config (#12394) 2025-11-18 17:54:54 +00:00
Vaxry
e4b40abce6
windowrules: bring back windowUpdateRules 2025-11-18 16:49:18 +00:00
KAGEYAM4
9495f989b4
hyprpm: remove -nn flag and make notification behaviour more consist… (#11272)
* [hyprpm] Remove -nn flag and make notification behaviour more consistent.

Before -> -nn turns on -n explicitly, and many notify() are ran without checking the flag.
After -> warning and error notification will always work, -n will only give visual confirmation that plugin loaded successfully, eye candy.

* [hyprpm] Add -nn breaking change fallback to nofity users.

Added deprecation warning for the --notify-fail flag.
2025-11-18 16:33:02 +00:00
fazzi
2c9c4d0905
windowrules: fix matching against xdgTag (#12393) 2025-11-18 16:32:33 +00:00
Mihai Fufezan
e15409bbeb
CMake: fix GIT_COMMIT_MESSAGE parsing 2025-11-18 17:50:10 +02:00
Guillermo Tomás Fernández Martín
312073ce79
CMake: add min version for xkbcommon 2025-11-18 17:46:14 +02:00
Vaxry
edc311544a
dwindle: Revert rework split logic to be fully gap-aware (#12047)
This reverts commit 151b5f6978.

Fixes #12380
2025-11-18 00:59:21 +00:00
Vaxry
37fe7b2efd
config: export version variable for versioned configs
fixes #12274
2025-11-17 18:43:04 +00:00
Vaxry
c2670e9ab9
windowrules: rewrite completely (#12269)
Reworks the window rule syntax completely

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-11-17 18:34:02 +00:00
Vaxry
95ee08b340
ci: fix translation ci again 2025-11-17 17:53:34 +00:00
Ali Ebadi
ff6d771be0
i18n: add Persian translations (#12361) 2025-11-17 17:47:35 +00:00
Vaxry
64e4e913e1
ci: fix translator ci 2025-11-17 16:57:17 +00:00
Martijn
ad52ba9c13
i18n: Add Dutch translations (#12326) 2025-11-17 13:34:57 +00:00
Mihai Fufezan
526aa1d020
CI/Nix: simplify cache config 2025-11-17 14:47:30 +02:00
Mihai Fufezan
5f0575737f
CI/AI translate: only run on src/i18n 2025-11-17 14:46:21 +02:00
27Onion Nebell
4695f85829
i18n: add Simplified Chinese translations (#12332) 2025-11-17 12:39:06 +00:00
Kosa Matyas
1796dbcdc3
i18n: Add hungarian translations (#12346) 2025-11-17 12:38:57 +00:00
Jochim
e354066945
groupbar: fix rounding logic for edge cases (#12366) 2025-11-17 12:13:29 +00:00
fufexan
2b14f27ca8 [gha] Nix: update inputs 2025-11-17 07:59:34 +00:00
Mihai Fufezan
68c23fbdaf CI: drop no_pch and make default, drop noxwayland 2025-11-17 09:58:14 +02:00
Mihai Fufezan
484d87d469 CI: drop meson build, simplify c-f check 2025-11-17 08:54:47 +02:00
Mihai Fufezan
cefa63c2af meson: drop 2025-11-17 08:54:47 +02:00
nnra
9d67511871
i18n: add Serbian Translations (#12341) 2025-11-16 23:59:05 +00:00
Darkiu1337
5265fa3be8
i18n: add pt_BR translations (#12351) 2025-11-16 23:58:54 +00:00
Antarip Barman
dfb4dcd55c
i18n: add Assamese translations (#12356) 2025-11-16 23:58:43 +00:00
Abdul
9d02fe9c23
i18n: add Arabic (ar) translations (#12352) 2025-11-16 23:58:23 +00:00
Aliaksiej
76edcfc66c
i18n: add Belarusian language (#12358) 2025-11-16 23:57:37 +00:00
Eren
11451d68b7
i18n: add Turkish translations (#12331) 2025-11-16 21:40:47 +00:00
Vaxry
3534dbdb89
ci: translation note fix 2025-11-16 21:19:36 +00:00
Lone Detective
6e2fe103bc
i18n: add Malayalam translations (#12345) 2025-11-16 21:18:17 +00:00
bea4dev
7910bc42af
renderer: fix fractional scale artifacts (#12287) 2025-11-16 21:17:05 +00:00
Aivaz Latypov
0770494ddf
i18n: add Russian translations (#12335) 2025-11-16 20:56:00 +00:00
Vaxry
49c0c97c5a
CI: fix translator 2025-11-16 20:55:15 +00:00
Vaxry
e948445f6e
CI: minor translation fixes 2025-11-16 20:22:07 +00:00
Álvaro Salcedo García
7a6177532b
i18n: add Spanish translations (#12334) 2025-11-16 20:09:08 +00:00
Vaxry
f0de61ca21
CI: run translator in pull_request_target for comment access 2025-11-16 19:34:36 +00:00
Vaxry
c02a6184d3
CI: add a fail note to translation ci 2025-11-16 19:32:26 +00:00
Vaxry
15b4b1dd91
ci: fix comment workflow for translations 2025-11-16 19:01:22 +00:00
Mihai Fufezan
a6b877fec2 CMake: prepopulate GIT vars from env 2025-11-16 20:33:01 +02:00
Mihai Fufezan
d2d1613e4f Nix: fix GIT_* env vars 2025-11-16 20:33:01 +02:00
Aditya An1l
c7e14ecd30
i18n: Add Hindi translations (#12324) 2025-11-16 18:28:50 +00:00
Vaxry
9321f52e07
CI: Add AI translation checks (#12342)
Adds AI-driven translation checks for translation MRs. Uses GPT-5-Mini.

Runs on a new translation MR, or can be manually triggered by me with "ai, please recheck"
2025-11-16 18:28:16 +00:00
Giacomo Zama
b04e8e00b0
cursor: fix m_cursorSurfaceInfo not being updated while a cursor override is set (#12327) 2025-11-16 17:43:55 +00:00
Lumine
5b373ea9f5
i18n: add French translations (#12330) 2025-11-16 17:10:40 +00:00
Virt
d52639fdfa
i18n: init german translations (#12323) 2025-11-16 15:54:43 +00:00
Vaxry
e616e595ae
i18n: init localization for ANR, Permissions and Notifications (#12316)
Adds localization support for en, it, pl and jp

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Co-authored-by: Aaron Blasko <blaskoazzolaaaron@gmail.com>
2025-11-16 14:51:14 +00:00
Jochim
cb47eb1d11
deco/groupbar: add groupbar blur (#12310) 2025-11-16 12:23:45 +00:00
Vaxry
9b006b2c85
plugin/hook: disallow multiple hooks per function (#12320)
this was never safe. After recent changes, it's become even less so. Just disallow it.

ref #11992
2025-11-16 12:01:48 +00:00
Alexandru Spînu
b35f78431f
cursor: ensure cursor reset on changed window states (#12301) 2025-11-15 19:23:32 +00:00
Lucas Ritzdorf
b62ab4b578
cmake,meson: fix inclusion of GPG info in Git commit info (#12302)
This manifested for me as a failure to build plugins with `hyprpm`, but
the root cause was GPG data getting incorporated into `src/version.h`,
like so:

```c
#define GIT_COMMIT_MESSAGE "gpg: Signature made Sun 09 Nov 2025 03:31:36 PM PST
gpg:                using EDDSA key E26A4A2AB9676F54149F8EAA665806380871D640
gpg: Can't check signature: No public key
version: bump to 0.52.1"
```

This affected both `GIT_COMMIT_MESSAGE` and `GIT_COMMIT_DATE`, since
those are generated via `git show` (which can generate that extra GPG
info if the user's personal Git config sets `log.showSignature`).

See: https://github.com/hyprwm/Hyprland/discussions/12282
2025-11-15 19:23:19 +00:00
Hiroki Tagato
43527d3634
internal: fix crash at startup on FreeBSD (#12298)
Hyprland at the latest commit crashes at starting up on FreeBSD with
SIGSEGV. Checking the validity of g_pXWayland->m_wm before calling
updateWorkArea() appears to fix the issue.
2025-11-13 22:06:34 +00:00
Hiroki Tagato
55a93b8a52
internal: put Linux-only header behind ifdef (#12300) 2025-11-13 22:06:25 +00:00
Vaxry
64ee8f8a72
layout: include reserved area in float fit (#12289)
Ref https://github.com/basecamp/omarchy/issues/3327
2025-11-13 00:08:04 +00:00
Vaxry
b77cbad502
screencopy: fix possible crash in renderMon() 2025-11-12 22:43:46 +00:00
Luke Barkess
308226a4fc
config/keybinds: add a submap universal keybind flag (#12100) 2025-11-11 22:59:21 +00:00
bea4dev
ee2168c665
renderer/ime: fix fcitx5 popup artifacts (#12263) 2025-11-11 20:43:43 +00:00
usering-around
c330d4334f
renderer: fix noscreenshare layerrule popups (#12260) 2025-11-11 20:42:53 +00:00
Tom Englund
cadf922417
presentation: only send sync output on presented (#12255)
as protocol states there is two events. 'presented' or 'discarded'.

wp_presentation_feedback::sync_output
As presentation can be synchronized to only one output at a time, this event tells which output it was.
This event is only sent prior to the presented event.
2025-11-11 20:00:59 +00:00
Chudnikov Alexander
ac8edc6a80
internal: fix subtractWindow typo for POSYSTR (#12259)
This type really pisses me off
2025-11-11 16:11:54 +00:00
Dominick DiMaggio
b2ea6b010c
renderer: Allow DS for surfaces with inert subsurfaces (#12133) 2025-11-11 12:18:15 +00:00
Mihai Fufezan
0b1d690676
flake.nix: update guiutils and override hw-s 2025-11-10 08:15:26 +02:00
Mihai Fufezan
2931184921
CI/release: populate git info (#12247) 2025-11-09 20:50:56 +00:00
Aurelle
0bd11d5eb9
protocols/layershell: do not raise protocol error if layer surface is not anchored (#12241) 2025-11-09 15:59:14 +00:00
nikromen
06b37c3907
protocols/outputMgmt: fix wlr-randr by defering success event until monitor reloads (#12236)
wlr-randr disconnects immediately after receiving success event, but
before applying the monitor configuration. This causes the state to be
lost when performMonitorReload() is called.

By postponing the success event until the call of the hook
monitorLayoutChanged we ensure the configuration to remain valid during
the reload process.
2025-11-08 23:45:53 +00:00
Mihai Fufezan
522edc8712
meson: fix version.h install location 2025-11-07 21:08:40 +02:00
Vaxry
f56ec180d3
version: bump to 0.52.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland with Meson (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (Arch) (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
Nix / test (push) Has been cancelled
2025-11-07 16:39:26 +00:00
UjinT34
fd50e78bc9
render/cm: change non_shader_cm ignore behavior and set default to it (#12210) 2025-11-07 15:58:25 +00:00
Vaxry
061981201d
core: qtutils -> guiutils (#12231)
* core: qtutils -> guiutils

* nix: qtutils -> guiutils

* flake.lock: update

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-11-07 15:48:13 +00:00
Dominick DiMaggio
3fc8cb828c
cm: follow preferred srgb eotf for screencopy (#12230) 2025-11-07 14:02:26 +00:00
Amadej Kastelic
1ca6058bda
chore: fix non-relative imports (#12228) 2025-11-06 20:32:08 +00:00
bea4dev
ca4b68e425
renderer: fix fractional scale artifact (#12219) 2025-11-06 19:18:16 +00:00
Tom Englund
8e8bfbb0b1
protocols: add Fifo-v1 and commit-timing-v1 (#12052)
* protocols: add Fifo-v1

introduce fifo-v1

* fifo: only present locked surfaces

dont present to unlocked surfaces and commit pending states from the
fifo protocol.

* fifo: cformat

cformat

* protocols: add committiming and surface state queue

introduce CSurfaceStateQueue and commit-timing-v1

* fifo: schedule a frame if waiting on barrier

if we are waiting on a barrier the state doesnt commit until the next
refresh cycle meaning the monitor might have no pending damage and we
never get onPresented to unlock the barrier, moment 22. so schedule a
frame.

* fifo: properly check monitor intersection

check for m_enteredoutputs or monitor intersection if client hasnt bound
one yet, and dont fifo lock it until the surface is mapped.

* buffer: try to merge states before committing them

try to merge states before committing them meaning way less churn and
surface commits if a surface sends multiple small ones while we wait for
buffer readyness from either fifo locks or simply fences.

* buffer: dont commit states past the buffer

certain changes are relative to the buffer attached, cant go beyond it
and apply those onto the next buffer.

* buffer: set the lockmask directly

cant use .lock since the state hasnt been queued yet, set the lockmask
directly when exporting buffer fence.

* fifo: dont fifo lock on tearing

dont fifo lock on tearing.

* buffer: queue the state directly

queue the state directly and use the .lock function instead of directly
modify the lockMask on the state.

* buffer: revert creating texture at commit time

fifo barriers introduces such long wait that upon commit time a
race happends with current xdg configure implentation that the buffer
and image is actually destroyed when entering commitState, doing it at
buffer creation time with EGL_PRESERVED_KHR means it sticks around until
we are done. so revert 82759d4 and 32f3233 for now.

* buffer: rename enum and lockreasons

eLockReason and LOCK_REASON_NONE.

* fifo: workaround direct scanout lock

workaround cursor commits causing fifo to get forever locked, this
entire thing needs to be worked out.
2025-11-06 13:25:49 +00:00
Alvaro Parker
c757fd375c
compositor: block parent window interaction when modal dialog children window is open (#12057) 2025-11-06 00:06:31 +00:00
vaxerski
46b71eda64 [gha] Nix: update inputs 2025-11-04 15:15:08 +00:00
André Silva
d82538c69f
protocols/dmabuf: handle null pointer in CLinuxDMABufV1Protocol::resetFormatTable (#12207) 2025-11-04 15:13:50 +00:00
Matteo Golinelli
8e9add2afd
sessionlock: fix crash when sendScale is called on a disconnected (#12171) 2025-10-31 00:15:18 +00:00
Vaxry
5e6cec962c
cursor: refactor override handling (#12166)
much cleaner and more reliable. Should fix https://github.com/hyprwm/Hyprland/issues/12088
2025-10-31 00:14:08 +00:00
Vaxry
6ade4d58ca
layout: fit floating window on toggle to float (#12139) 2025-10-29 23:21:28 +00:00
Vaxry
83a0a62004
protocols/core: round dnd drop surface box 2025-10-29 17:20:44 +00:00
Dominick DiMaggio
ff50dc36e9
renderer/cm: allow gamma 2.2 instead of sRGB EOTF (#12094) 2025-10-29 12:53:42 +00:00
jmanc3
ce9787b3f4
xwayland: set _NET_WORKAREA property (#12148) 2025-10-29 11:24:34 +00:00
Mihai Fufezan
9eb82774e5 Nix: build hyprtester along with hyprland 2025-10-29 12:18:29 +02:00
Mihai Fufezan
a2f48ea418 CMake: allow building hyprtester without running tests 2025-10-29 12:18:29 +02:00
Mihai Fufezan
309c3c7848
Nix/tests: wl-copy -> wl-clipboard 2025-10-27 23:49:49 +02:00
Mihai Fufezan
0907fdf49c
CI/release: run cmake configure 2025-10-27 23:47:35 +02:00
Vaxry
431325ff0c
config/rule: don't populate ID field for automatically id-managed workspaces 2025-10-27 21:29:35 +00:00
Mihai Fufezan
40831a90a0
Nix/tests: add wl-copy 2025-10-27 23:25:54 +02:00
Vaxry
b186d3bf1b
pass/surface: check for LS size anim for misaligned fractional 2025-10-27 17:22:04 +00:00
Vaxry
560c53d87d
monitor/dpms: fix possible invalid state
If dpms gets immediately re-enabled, a commit could fail, not schedule any frames anymore, and the monitor would be stuck off. Fix this by adding a timer to retry if commit fails.

ref #12045
2025-10-27 13:34:14 +00:00
Mihai Fufezan
fd42e9d082
CI/release: remove generateVersion call
Addresses https://github.com/hyprwm/Hyprland/pull/12110#issuecomment-3442583784
2025-10-26 21:27:49 +02:00
Dominick DiMaggio
17d0d696be
screencopy: wait longer to re-enable DS (#12135) 2025-10-26 18:57:20 +00:00
JS Deck
88e34d7dd2
IME: do not share keys/mods states from grabbed keyboards with ime keys/mods (#11917) 2025-10-26 18:54:48 +00:00
Vaxry
05aa4e1c54
compositor: check for monitor layout issues post rule apply
fixes #12108
2025-10-26 13:52:09 +00:00
Vaxry
748d2f656e
xdg-shell: implement invalid parent errors 2025-10-26 12:34:35 +00:00
Tom Englund
6ea4769b39
EGL: minor egl changes (#12132)
* opengl: use EGLint and we dont have to cast data

use EGLint in the attrib array and we dont have to cast the resulting
data.

* opengl: add linear to correct vector

drop empty check, what if we get mods that isnt linear. then it wont be
added, also add it to the result vector that we actually return.
2025-10-25 20:36:02 +01:00
Virt
72cbb7906a
layer-shell: fix fullscreen alpha when changing layers (#12124)
* layer-shell: fix fullscreen alpha when changing layers

* this is intended

* ooops

* ooops #2
2025-10-25 18:53:01 +01:00
Tom Englund
b6f946991d
meson: disable lto (#12129)
seems to accidently got enabled again in 019589e
2025-10-25 15:19:47 +01:00
ccos89
b10b966000
screencopy: fix missing XBGR2101010 format with screencopy_force_8b (#12125)
Adds missing DRM_FORMAT_XBGR2101010 to screencopy_force_8b that leads to
"no more input formats" Pipewire error for monitors set to 10-bit color
depth/where currentFormat is XBGR2101010.

Fixes implementation of #11623
Fixes hyprwm/xdg-desktop-portal-hyprland#270
Fixes hyprwm/xdg-desktop-portal-hyprland#102
2025-10-25 11:57:46 +01:00
Vaxry
da04afa44e
surface: fix xwayland zero scaling damage calcs (#12123) 2025-10-24 22:19:21 +01:00
Filip Mikina
34812c33db
hyprctl: include color management presets and sdr information (#12019)
* move string parsing for eCMType to its own namespace, similar to how
`src/protocols/types/ContentType.cpp` is done
* expose cm type and sdr settings in `hyprctl monitors`, format floats
to .2f
2025-10-24 20:18:39 +01:00
ItsOhen
117e38db35
cmake: fix git lookup for when building out of srcdir(#12116) 2025-10-24 19:13:38 +01:00
crossatko
151b5f6978
dwindle: rework split logic to be fully gap-aware (#12047) 2025-10-24 19:01:05 +01:00
vaxerski
aa5a239ac9 [gha] Nix: update inputs 2025-10-23 19:51:54 +00:00
nnra
019589e23f
build: replace generateVersion.sh (#12110)
* Implemented the CMake version of generateVersion.sh

* Made version.h.in compatible with the new build system and included version.h in helpers/MiscFunctions.cpp

* Deleted the scripts/generateVersion.sh as it's no longer needed

* Updated meson.build to match the new workflow

* Added an empty line between includes and namespaces that I accidentally removed
2025-10-23 20:50:32 +01:00
Vaxry
057695bc3f
desktopAnimationMgr: don't set fade 0 for members of a fs group (#12091)
fixes a flash of opacity that shouldnt be there
2025-10-22 11:32:42 +01:00
Vaxry
892f642f58
plugins: incorporate hyprdep ABI into plugin info (#12001) 2025-10-21 22:47:50 +01:00
Vaxry
d560c26419
internal: fix cf 2025-10-21 22:47:06 +01:00
Vaxry
02b0c563f3
xwm: attempt to guess mime in sendData for DnD 2025-10-21 19:11:18 +01:00
Vaxry
4926332c37
monitor: remove spammy trace log 2025-10-21 19:11:18 +01:00
Mozzarella32
46dab01bcc
renderer: add more uniforms to the screen shader (#11986)
These are: pointer_shape from the cursor-shape-v1 protocol prepared for v2, along with left_ptr...bottom_right_corner and killing (Hyprland specific)
           pointer_shape_previous with
           pointer_switch_time to blend between shapes
           pointer_size scaled size as used by the normal cursor
           pointer_pressed_positions[32] with
           pointer_pressed_times[32] and
           pointer_pressed_killed(32 bits) for click/touch animations and if they killed something
           pointer_inactive_timeout with
           pointer_last_active to smoothly fade the pointer out
           pointer_hidden to hide it when the cursor is hidden (excluding by cursor:invisible as this config value can be used to turn off the normal cursor, which is useful when drawing it with the screen shader)
2025-10-20 12:22:50 +01:00
vaxerski
474cd004df [gha] Nix: update inputs 2025-10-20 11:14:45 +00:00
0rtz
a4200acfa6
input: fix refocus on grab dismiss (#12014) 2025-10-20 12:13:27 +01:00
MithicSpirit
59ff7b2f89
dispatchers: add forceidle (#11922)
The forceidle dispatcher resets all ext-idle-notify timers as if the
user had been idle for the specified number of seconds. If a
notification has already fired, but would now be set with a nonzero
delay, then it is reset. Conversely, if a timer has not yet fired, but
would now be set to a nonpositive delay, then it is immediately fired.
This process ignores any existing inhibitors, but timers are otherwise
reset as normal if any new inhibitors are created or destroyed.
2025-10-19 13:54:27 +02:00
Vaxry
ba077d8ff0
renderer: clean up surface UV size calcs, fix issues (#12070) 2025-10-19 02:56:55 +02:00
Bang Lee
39d62e1487
protocols: fix output power protocol not sending mode confirmation (#12072)
Use setDPMS() instead of directly manipulating m_dpmsStatus to ensure the dpmsChanged event fires and protocol
clients receive mode change confirmation via sendMode().
2025-10-18 20:44:55 +02:00
Mozzarella32
6607c6440d
renderer: add 1fv and 2fv uniform support (#12080) 2025-10-18 13:34:33 +02:00
Mozzarella32
f3e13193a6
timer: constify methods (#12079) 2025-10-18 13:34:07 +02:00
Matteo Golinelli
8164b90bc2
config: fix crash when some configurations include non-integer values (#12056) 2025-10-16 15:33:06 +02:00
Vaxry
36c0477dd0
tests: disable shortcut test for ci 2025-10-16 14:32:26 +01:00
Virt
ab11af9664
ext-foreign-toplevel: remove stale entries when remapping (#12037) 2025-10-15 14:37:39 +02:00
Vaxry
e40873be51
renderer: add cursor:zoom_disable_aa for controlling AA on zoom (#12025) 2025-10-15 14:08:34 +02:00
Vaxry
60529e810d
renderer: round box in damageBox 2025-10-15 00:37:07 +01:00
Vaxry
f324a3a564
functionHook: fix distance check 2025-10-14 19:31:49 +01:00
Vaxry
ee5d05f0fc
hookSystem: fix anchor point for mmap 2025-10-14 13:39:22 +01:00
Mihai Fufezan
bbb83317c0 Nix: drop ninja for CMake build 2025-10-13 23:15:18 +03:00
Mihai Fufezan
0d6d19b280 Revert "nix: use meson"
This reverts commit d505b33665.
2025-10-13 23:15:18 +03:00
Mihai Fufezan
541ef60fd7 CMake: print pch messages based on var 2025-10-13 23:15:18 +03:00
Vaxry
4b55ec6830
windowrules: add modal prop (#12024)
adds a modal prop for targeting modal windows with rules
2025-10-13 13:16:48 +01:00
Richard Potter
7fcaf332e8
layouts: apply [min|max]size window rules to dwindle & master layouts (#11898)
Uses min/max rules in the tiled layouts, akin to pseudotiling
2025-10-13 13:08:40 +01:00
Mihai Fufezan
6582f42db8 meson: disable lto explicitly 2025-10-13 09:27:33 +03:00
Virt
ed93643021
core: disable lto for hyprland builds (#11972)
LTO has the tendency to remove functions completely by inlining them, which breaks function hooks.

Force disable LTO to not have plugins break.
2025-10-12 02:06:31 +02:00
ItsOhen
d599513d4a
config: add automatic closing to submaps (#11760)
* Allow submaps to auto reset to parent.

* Really should be a stack instead.

If hyprlang would allow for { } i would be so happy.

* Fixed: Somewhat better way to do it..

Lets you define what submap you want to go to instead.

* squash! Fixed: Somewhat better way to do it..

* God i hate cf..

* Force clang-format on the whole thing..

* Removed {}.

* Added tests

Tests and reset fix.
2025-10-11 02:40:18 +02:00
epsilonshmepsilon
6a01c399a9
input: add option to rotate device input (#11947) 2025-10-10 17:05:51 +02:00
Nikolai Nechaev
da31e82aab
internal: prevent early exit processes from being zombies (#11995)
Prevent `exec`/`exec-once` processes which terminate very early
(before Hyprland declares that it does not want to reap zombies)
from getting stuck as zombie processes.
2025-10-10 17:03:34 +02:00
Tom Englund
32f3233324
dmabuffer: ensure we only create one texture per buffer (#11990)
buffer can be recomitted, when moving texture creation from constructor
to committime it means same buffer recommit can cause a new texture
unless we store it per buffer and return the pointer for it.
2025-10-10 14:13:14 +02:00
Vaxry
2b0926dcd4
tests: disable one test as it fails on ci 2025-10-10 13:11:32 +01:00
Damino
b965fb2a40 flake.lock: bump hyprutils 2025-10-09 08:35:34 +03:00
Tom Englund
82759d4095
buffer: move texture creation to commit time (#11964)
* buffer: move texture creation to commit time

move creating texture away from buffer attach into commitstate in an
attempt to postpone gpu work until its really needed. best case scenario
gpu clocks have ramped up before because we are actively doing things
causing surface states and a commit to happend meaning less visible lag.

* buffer: simplify texture creation

make createTexture return a shared ptr directly, remove not needed
member variables as m_success and m_texture.
2025-10-08 22:25:55 +02:00
Linux User
0dc45b54f3
managers/helpers: add missing includes (#11969)
* managers: include string header

Fixes error `implicit instantiation of undefined template 'std::basic_string<char>'` on llvm/musl

* helpers: include unistd header

Fixes error `use of undeclared identifier 'pipe'` on llvm/musl
2025-10-08 22:24:40 +02:00
Nj0be
ba24547d3d
dispatchers: add set, unset and toggle to fullscreen (#11893)
Add set, unset and toggle to fullscreen
2025-10-08 11:07:55 +01:00
Tom Englund
5ba2d2217b
compositor: make wl_surface::frame follow pending states (#11953)
* compositor: make pending states store frame callbacks

move frame callbacks to pending states so they are only committed in the
order they came depending on the buffer wait for readyness.

* buffer: damage is relative to current commit

ensure the damage is only used once, or we are constantly redrawing
things on state commits that isnt a buffer.

thanks PlasmaPower.

* compositor: move callbacks back to compositor

move SSurfaceStateFrameCB back to compositor in the class
CWLCallbackResource as per request, but still keep the state as owning.

* compositor: ensure commits come in order

if a buffer is waiting any commits after it might be non buffer commits
from the "future" and applying directly. and when the old buffer that
was waiting becomes ready it applies its states and overwrites the
future changes.

move things to scheduleState and add a m_pendingWaiting guard. and
schedule the next pending state from the old buffer commit when done.
and as such it loops itself and keeps thing orderly.
2025-10-07 12:49:38 +01:00
Vaxry
5a20862126
hookSystem: use a full trampo setup for hooks
instead of planting a longjmp at the fn head, make a shortjmp to a launch trampo

this helps with shortjmps that can be in the fn and will break when relocated. They are very unlikely to occur within the first 5 bytes (jmp rel32) but can happen in the first 10 or so (longjmp)

fixes csgo-vk-fix on latest main with release building on gcc / clang
2025-10-07 12:49:36 +01:00
Vaxry
c3747fab56
hookSystem: fix anchoring in seekNewPageAddr()
otherwise we might miss the chance to get an anchor
2025-10-07 01:44:03 +01:00
Vaxry
dc72259a54
core/compositor: revert make wl_surface::frame follow pending states (#11896)
This reverts commit 17e77e0407.

Reverted due to severe performance degradation due to accumulating frame
callbacks
2025-10-06 23:44:47 +01:00
Vaxry
02cda6bebf
systeminfo: log system package versions (#11946) 2025-10-06 23:20:21 +02:00
rfresh2
73f06434a4
keybinds: fix repeat and long press keybinds release (#11863) 2025-10-06 21:10:56 +02:00
Tom Englund
17e77e0407
core/compositor: make wl_surface::frame follow pending states (#11896)
* compositor: make pending states store frame callbacks

move frame callbacks to pending states so they are only committed in the
order they came depending on the buffer wait for readyness.

* buffer: damage is relative to current commit

ensure the damage is only used once, or we are constantly redrawing
things on state commits that isnt a buffer.

thanks PlasmaPower.

* compositor: move callbacks back to compositor

move SSurfaceStateFrameCB back to compositor in the class
CWLCallbackResource as per request, but still keep the state as owning.

* compositor: ensure commits come in order

if a buffer is waiting any commits after it might be non buffer commits
from the "future" and applying directly. and when the old buffer that
was waiting becomes ready it applies its states and overwrites the
future changes.

move things to scheduleState and add a m_pendingWaiting guard. and
schedule the next pending state from the old buffer commit when done.
and as such it loops itself and keeps thing orderly.
2025-10-06 12:20:04 +01:00
Dave Walker
cfac27251a
debug: fix data race in Debug::log() (#11931)
* debug: fix data race in Debug::log()

The templated Debug::log() had mutex protection but the non-template
overload it calls didn't, causing crashes when plugins called log from
background threads (like hypr-dynamic-cursors loading cursor themes).

Fixed by moving the mutex lock from the template version into the
non-template version, so all writes to shared state are protected.

Fixes: hyprwm/Hyprland#11929
Fixes: VirtCode/hypr-dynamic-cursors#99

* debug: apply clang-format to Log.cpp

Fix formatting to satisfy CI clang-format check.

---------

Co-authored-by: Dave Walker <dave@daviey.com>
2025-10-05 16:24:49 +02:00
UjinT34
76d998743a
cm: handle inert cm outputs (#11916) 2025-10-04 00:35:22 +02:00
vaxerski
b7ef892ecf [gha] Nix: update inputs 2025-10-03 19:52:11 +00:00
UjinT34
f0b4164e2e
cm: fix primaries to proto scale (#11914) 2025-10-03 21:50:57 +02:00
UjinT34
3bcfa94ee4
renderer: add render:non_shader_cm and fixes (#11900) 2025-10-02 12:05:54 +02:00
Vaxry
c467bb2640
renderer: fix popup fadeout blur (#11756)
popups dont get no xray
2025-10-02 12:01:16 +02:00
Vaxry
e0c96276df
renderer: optimize border drawcalls (#11891)
calculates the specific border region to avoid sampling on regions where the border cannot be at
2025-10-01 12:38:17 +01:00
vaxerski
378438ffe7 config: increase default anr_missed_pings value
ref https://github.com/hyprwm/Hyprland/discussions/11884
2025-10-01 12:19:16 +01:00
Vaxry
13648d196a
protocols/seat: force down rounding of coords at the surface edge (#11890)
ref https://github.com/hyprwm/Hyprland/discussions/11665
2025-10-01 12:15:23 +01:00
UjinT34
8c54c9b412
protocols/cm: remove unneeded preferred ref (#11877) 2025-10-01 11:04:49 +01:00
ItsOhen
38c1e72c9d
rules: fix some monitor rules (#11873) 2025-09-29 20:10:34 +02:00
UjinT34
0959672591
renderer/cm: add more monitor cm options (#11861)
Adds more cm options for monitors: DCIP3, Apple P3, Adobe
2025-09-29 13:22:42 +01:00
UjinT34
4d82cc5957
internal: fix clang-tidy "errors" (#11862) 2025-09-29 13:10:15 +01:00
Vaxry
43fb4753fc
gestures: fix gesture direction detection (#11852) 2025-09-29 12:29:40 +01:00
Tom Englund
f854b5bffb deco: reduce virtual calls in drop shadow
damageEntire() in CHyprdDropShadow is pretty much called per window per
frame, instead of all the PWINDOW-> virtual calls, store pos and size
once and move the duplicated code to a lambda. reducing it a bit.

shows up in profiling as minor waste.
2025-09-28 23:20:52 +02:00
Tom Englund
eb25dfd399 opengl: move from unordered_set to array
setCapStatus is a a heavy used function in hot rendering paths, it
shows up in profiling as using a bit of cpu just because of
unordered_set hashing etc, move to a enum and array and cache only the
heavily used ones.
2025-09-28 23:20:52 +02:00
Tom Englund
b627885788 decoration: reduce virtual calls
this shows up as top contender in idle cpu usage, because decos in
animations keeps locking weak pointers to shared pointers per window per
frame when its not really needed, use weakpointers all the way and it
drops to a bottom contender. marginal gains in the big picture. but
gains is gains.
2025-09-28 23:20:52 +02:00
Mihai Fufezan
c30036bdac
CI/Arch: build hyprgraphics after hyprutils
Ensure no ABI breaks. Hyprgraphics depends on hyprutils.
2025-09-28 19:19:41 +03:00
usering-around
766acadcf1
seat: release depressed modifiers on leave (#11854) 2025-09-28 00:05:30 +02:00
omar
ef479ff539
viewporter: clamp sub-pixel overflow (#11845)
Clamps the pending wp_viewport source rect back inside the attached buffer when it misses by <= 1 px, so if clients request something that falls within the 256-increment wl_fixed_from_double precision error it’s still treated as valid.
2025-09-27 20:14:43 +02:00
ItsOhen
6f1d2e771d
config: fix rules with no parameters not being counted as invalid (#11849)
Quite a big whoopsie to insert invalid rules.

Also adds special: cases.
2025-09-27 01:04:22 +02:00
ItsOhen
ae445606e2
config: allow negative to be used with tags. (#11779) 2025-09-26 18:19:53 +02:00
Nikolai Nechaev
4f3dd1ddb4
config: fix gesture dispatcher parsing with whitespaces (#11784)
* config: fix gesture dispatcher parsing with whitespaces

Some dispatcher functions (e.g., `moveFocusTo`) expect the given string to be
stripped of whitepsaces.

This fixes `gesture` line parsing: rather than calling dispatcher functions
with the original string, we reuse words parsed by `CConstVarList` and join
them with a comma.

* tests/gestures: Add a test for `movecursortocorner`
2025-09-26 15:49:07 +02:00
ItsOhen
d8f615751a
config: support more than 1 window rule per rule line. (#11689)
Adds support for specifying multiple rules in one line
2025-09-26 00:33:58 +02:00
João V. Farias
7ce451d20c
renderer: disable anti-aliasing on cursor:zoom_factor (#6135) (#11828)
use nearest-neighbor filtering for cursor scaling to avoid blurriness
2025-09-25 21:14:04 +02:00
Tom Englund
5212099b9f
layout: avoid nullptr deref (#11831)
OPENINGON can be a nullptr and that makes FLOATEDINTOTILED to nullptr
deref and segfault.
2025-09-25 15:30:04 +02:00
Tom Englund
8cce3b98ce
shm: refactor to UP and correct m_data check (#11820)
use unique pointers and rvalue references where applicable, buffer is
still a shared pointer because CHLBufferReference uses it to hold it
locked.

in CSHMPool destructor add a check for m_data != MAP_FAILED same in
resize, because mmap returns (void *) -1 on failure and that is not
comparable to nullptr. delete default constructor so we dont end up in
weird states with m_data.
2025-09-25 01:44:33 +02:00
Tom Englund
683fc77f80
hyprctl: nullptr guard --systeminfo (#11822)
running Hyprland --systeminfo from a console/tty calls systemInfoRequest
without us having a g_pCompositor or g_pHyprOpengl, so just if check them
and make --systeminfo not segfault and atleast print what info we can.
2025-09-25 01:44:07 +02:00
Vaxry
ec9a72d9fb
workspaces: fix persistence with no monitor specified (#11807) 2025-09-23 21:08:30 +02:00
omar
31bd9ec417
foreign-toplevel: continue past skipped invalid windows (#11804) 2025-09-23 19:50:57 +02:00
Nikolai Nechaev
29b103c376
exec: Spawn processes as direct children (#11735)
* exec: Spawn processes as direct children

Spawn processes as children rather than grandchildren.
This way, spawned processes may track Hyprland's state
by watching their parent, either directly or indirectly
(e.g., Linux's `PR_SET_PDEATH_SIG`).

Fixes #11728

* tests/exec: Add the test on process spawning

Add a test that ensures that:
- A spawned process remains a direct child of Hyprland;
- Upon termination, the process does not become a zombie.
2025-09-23 19:32:48 +02:00
Vaxry
70a7047ee1
renderer: fix uv scaling detection (#11789) 2025-09-22 13:01:59 +01:00
0xFMD
26f293523a
renderer: add "noscreenshare" layer rule (#11664) 2025-09-22 12:26:14 +01:00
Bahaa Mohamed
45f007d412 ci: remove duplicate cp and redundant mkdir commands 2025-09-22 12:31:36 +03:00
Nikolai Nechaev
22c8bc9b9b CI/Nix: Allow running CI in forks
Rather than hardcoding the repository name in the workflow file,
use a context value. This allows running workflows in forks.
2025-09-22 12:30:39 +03:00
Vaxry
26cbc67385
renderer: fix uv calculations once and for all (#11770)
fixes synchronization of ackd sizes, fixes wrong xdg stuff
2025-09-21 19:27:56 +02:00
Nikolai Nechaev
41dad38177
config: fix multi-argument gesture dispatcher parsing (#11721)
* config: Fix multi-argument gesture dispatchers parsing

The `dispatcher` gesture handler used to only handle
the first argument to the dispatcher, while some dispatchers
(e.g., `sendshortcut`) want multiple arguments.

This fixes `ConfigManager` to handle all the arguments
provided to the dispatcher gesture handler.

Fixes #11684.

* test/gestures: Add a test for a gesture with a multi-argument dispatcher

* test/gestures: Factor out `waitForWindowCount`

Reduce code duplication in the gestures test.
2025-09-20 17:57:49 +02:00
JS Deck
838439080a
vkeyboard: update cached mods before IME; add share_states = 2 config option (#11720) 2025-09-20 17:57:39 +02:00
ItsOhen
6a88f2e880
monitors: auto apply suggested scale and notify the user. (#11753) 2025-09-20 17:42:02 +02:00
vaxerski
8832607574 [gha] Nix: update inputs 2025-09-19 14:59:16 +00:00
usering-around
8fc7b2c171
input: fix virtual keyboard keymaps (#11763) 2025-09-19 16:58:03 +02:00
REVO9
afd1e71761
renderer: fix inconsistent border thickness for roundingPower < 2 (#11752) 2025-09-19 00:34:54 +02:00
Vaxry
4fc95d646d
renderer: asynchronously load background tex (#11749)
Bumps required hyprgraphics to 0.1.6

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-09-18 22:10:30 +02:00
Vaxry
91f592a875
workspace: fix relative workspaces with monitor descs 2025-09-18 20:46:57 +01:00
Vaxry
059ec60e9f
hyprpm: make temp root if not present 2025-09-18 13:25:04 +01:00
nikitax44
5648077978
animation: fix slide/slidefade to accept forced direction (#11725) 2025-09-18 13:53:28 +02:00
Vaxry
1cb8cd3930
solitary: fix check for config error (#11733)
Adds a blocker for solitary optimizations if there is a hyprerror present
2025-09-17 14:03:49 +02:00
Vaxry
7fd6998f7c
core: fix clang-format 2025-09-17 13:02:56 +01:00
Vaxry
5e96fac52f
presentation: fix vrr check for reporting no refresh time
ref #11608
2025-09-16 00:09:30 +01:00
Vaxry
4a9c4dbc04
gestures/fs: fix typo
fixes #11678
2025-09-15 22:30:08 +01:00
Vaxry
9e74d0aea7
renderer: clamp blur:passes 1-8
fixes some UB and dumb things

ref #11707
2025-09-15 12:44:12 +01:00
Vaxry
559024c331
gestures/float: fix typo 2025-09-14 01:52:41 +01:00
ItsOhen
16c18dde24
windows: fix no decorate not disabling borders (#11673) 2025-09-13 16:37:02 +02:00
Stanislav Senotrusov
adbf7c8663
input: handle tablet active area scaling when axes swap due to rotation (#11661)
Some tablet rotation modes (90°, 270°, and flipped variants) swap the X and Y axes.
This change adjusts the effective physical size based on axis orientation
to ensure tablet active area coordinates are normalized correctly.
2025-09-13 01:11:30 +02:00
0xFMD
797bfe905e
dispatchers: fix movecursor not updating client pos (#11672) 2025-09-11 21:52:30 +02:00
usering-around
38169c8fdd
input: support xkb v2 format (#11482) 2025-09-11 19:42:20 +02:00
Florian "sp1rit
c7b9969129
render/OpenGL: fix compilation for 32bit systems (#11667) 2025-09-11 19:41:33 +02:00
Mihai Fufezan
231b800784
flake.lock: update 2025-09-11 18:54:08 +03:00
Mihai Fufezan
8a959b4342
meson: set minimum version 2025-09-11 18:53:13 +03:00
Vaxry
46174f78b3
version: bump to 0.51.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland with Meson (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (Arch) (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
Nix / test (push) Has been cancelled
2025-09-10 13:41:05 +01:00
Maximilian Seidler
b8cff8a434
input: focus when first keyboard is added and m_lastFocus is set (#11645) 2025-09-10 12:22:45 +02:00
Levizor
150d693fe7
hyprctl: add an active layout index field in devices (#11531) 2025-09-09 14:19:51 +01:00
jmanc3
ecc9e4d8cd
window: fix centering calculation for floating windows (#11632) 2025-09-09 12:56:33 +01:00
Vaxry
1e3a06560f
gestures: add unset
ref https://github.com/hyprwm/Hyprland/pull/11490
2025-09-08 20:24:51 +01:00
vaxerski
b619f39555 [gha] Nix: update inputs 2025-09-08 09:08:22 +00:00
Vaxry
02bb350bb3
screencopy: add force 8 bit to fix 10b screensharing (#11623)
ref https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/270
2025-09-08 11:07:04 +02:00
Dominick DiMaggio
bce43f74eb
presentation: handle vrr for v1 clients (#11608) 2025-09-06 19:43:03 +02:00
0xFMD
56dd1124ab
animation: fix slide/slidevert to accept params (#11574) 2025-09-06 19:24:17 +02:00
Vaxry
4e785d12a9
protocols/kde-deco: fix tug of war in deco mode
fixes #11591
2025-09-04 10:16:54 +01:00
Vaxry
127aab8159
input: add per-device scroll-factor (#11241) 2025-09-02 13:16:43 +02:00
Matteo Golinelli
78e86d879f
config: fix crash when monitor position contains non-integer values before/after 'x' (#11573) 2025-09-02 13:16:26 +02:00
jmanc3
00423bb738
plugins: expose csd functionality (#11551) 2025-09-02 11:49:24 +02:00
jmanc3
8a64168a43
window: treat maximize as toggle request (#11564)
Breaks the spec, but fixes a few issues due to how we always communicate to the apps that they are maximized in xdg_shell.
2025-09-01 22:44:41 +02:00
Mihai Fufezan
641d85b14e
CMake: fix tests message 2025-09-01 22:57:25 +03:00
0xFMD
5bb8adbc32
dispatchers: allow window address in swapwindow (#11518) 2025-08-31 18:14:39 +02:00
Ikalco
ea42041f93
protocols: implement pointer-warp-v1 (#11469) 2025-08-29 22:16:40 +02:00
UjinT34
05a1c0aa73
renderer: Fix CM for DS and SDR passthrough (#11503) 2025-08-29 13:31:07 +02:00
Vaxry
790e544689
config: update environment if cfg changes live (#11508) 2025-08-29 11:16:11 +02:00
Vaxry
a209f9911c
window: allow rounding power of 1
supersedes #11510
2025-08-29 11:12:37 +02:00
jmanc3
4b2bfbd85f
xwayland: fix game permanent blackscreen (#11542) 2025-08-28 11:22:00 +02:00
jmanc3
4e8657568c
xwayland: handle minimize and maximize requests (#11536) 2025-08-28 11:21:36 +02:00
Vaxry
81bf4eccba
input: Add fully configurable trackpad gestures (#11490)
Adds configurable trackpad gestures
2025-08-28 11:20:29 +02:00
vaxerski
378e130f14 [gha] Nix: update inputs 2025-08-27 20:18:24 +00:00
Vaxry
d7cf95b515
tablet: remove old comment 2025-08-27 22:16:46 +02:00
Vaxry
0ed880f3f7
protocols/activation: revert send an invalid token when serial isn't valid (#11505)
This reverts commit d9cf1cb78e.

See discussion in #11505
2025-08-24 22:59:41 +02:00
Tom Englund
b329ea8e96
syncobj: use rendernode for timelines (#11087)
* syncobj: use rendernode for timelines

use rendernode for timelines instead of the drmfd, some devices dont
support to use the drmfd for this.

* opengl: use rendernode if available

use rendernode if available for CHyprOpenglImpl

* MesaDRM: use the m_drmRenderNodeFD if it exist

try use the rendernode we got from AQ if it exist.

* linuxdmabuf: use rendernode if available

use the rendernode if available already from AQ

* syncobj: prefer rendernode over displaynode

prefer the rendernode over the displaynode, and log a error if
attempting to use the protocol without explicit sync support on any of
the nodes.

* syncobj: check support on both nodes always

check support on both nodes always so it can be used later for
preferring rendernode if possible in syncobj protocol.

* syncobj: remove old var in non linux if else case

remove old m_bDrmSyncobjTimelineSupported from non linux if else case
that will fail to compile on non linux. the nodes sets support by
default to false, and if non linux it wont check for support and set it
to true.

* build: bump aq requirement

bump to 0.9.3 where rendernode support got added.

* flake.lock: update

* renderer: glfinish on software renderer

software renderers apparently bug out on implicit sync, use glfinish as
with nvidia case on implicit paths.

* flake.lock: update

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-08-24 22:32:13 +02:00
Tom Englund
ced38b1b0f
disable buffer readability checks on intel (#11515)
* dmabuf: disable buffer read check on intel

readability checks directly on buffer fds on some intel laptops is
broken, see https://gitlab.freedesktop.org/drm/intel/-/issues/9415

* sync: use rvalue ref in addwaiter doonreadable

use rvalue reference in addwaiter and doonreadable, because we store the
function in the SReadableWaiter a lot of the time, move it into place
there when that happends or let it go out of scope after function call.
2025-08-24 08:57:37 +01:00
Ross
d9cf1cb78e
protocols/activation: send an invalid token when serial isn't valid (#11505) 2025-08-23 11:45:00 +01:00
UjinT34
0d45b277d6
internal: Solitary clients with single subsurface & verbose solitary/tearing/DS checks (#11228)
Adds more verbose checks for various conditional rendering mechanisms
2025-08-22 18:24:25 +01:00
jmanc3
e95ba5bf59
renderer: add eRenderStage::RENDER_POST_WALLPAPER (#11501)
Comes after the wallpaper is rendered, but before all windows and docks are rendered
2025-08-22 18:19:00 +01:00
UjinT34
4e8875b5e9
hdr: scRGB, HLG and SDR -> HDR fixes (#11499) 2025-08-22 11:13:55 +01:00
Hleb Shauchenka
fdf1612f0f
windowrules: Add novrr dynamic window rule (#11370) 2025-08-22 10:48:42 +01:00
jmanc3
42caff5587
window: fix requestedMinSize crash (#11498)
There are cases where m_isX11 is true but m_xwaylandSurface doesn't exist.
2025-08-22 08:25:27 +01:00
vaxerski
50a242f16a config: add dim_modal
fixes #11486
2025-08-21 14:59:20 +02:00
vaxerski
1ac1ff457a touch: detach from pointer input
this detaches touch from pointer input. Touch should not affect where your cursor is, and it doesn't make much sense for it to move when we use touch
2025-08-20 13:01:31 +02:00
vaxerski
9a20206945 touch: fix popup coordinates for touch down
fixes #10626
2025-08-20 12:22:18 +02:00
Mike Will
10cec2b7e2
dwindle: simplify split_bias logic and set of possible values. (#11448) 2025-08-19 19:32:37 +01:00
Linux User
d0d728c6a6
render: include numbers header (#11475)
Fixes error `no member named 'numbers' in namespace 'std'` on llvm/musl
2025-08-19 19:31:01 +01:00
Aaron Tulino
3370a6a83d
monitor: fix dpms toggling animations when state is unchanged (#11480) 2025-08-19 19:30:26 +01:00
UjinT34
1d67987459
hdr: fix overrides and missing edid hdr metadata (#11476) 2025-08-19 19:28:52 +01:00
Tom Englund
1a0ed00f74
protocols/wayland: use UP and rvalue refs for callbacks (#11471)
use UP and rvalue refs in CWLCallbackResource and m_callbacks.
2025-08-18 16:42:19 +01:00
Luke Barkess
21953ddf3d
hyprctl: add getprop (#11394) 2025-08-18 16:41:17 +01:00
Hato
d890178610
internal: reference command-line arguments instead of copying them (#11422)
Eliminates the need to copy command-line arguments into a std::vector<std::string>, reducing memory usage and improving performance by referencing the original arguments directly.
2025-08-17 20:18:51 +01:00
Kamikadze
bca96a5d3b
protocols: Fix fading out windows with noscreenshare being visible (#11457) 2025-08-17 20:17:22 +01:00
vaxerski
dfe58c4809 compositor: mark createNewWorkspace as nodiscard
discarding this makes the call do nothing but waste cycles
2025-08-17 20:33:04 +02:00
vaxerski
e8731883a5 compositor: fix new workspace being lost in moveWorkspaceToMonitor
with the move to refcounting workspaces, createNewWorkspace would've lost the ref

fixes #11385
2025-08-17 20:33:04 +02:00
Vaxry
0840103ae0
renderer: improve modeset timings (#11461)
some CRTCs will just happily eat frames and we can't do much. Some will eat one.

Adds a 5-frame buffer to DPMS and Added animations. Better than nothing.
2025-08-17 17:14:29 +01:00
Vaxry
251288ec59
renderer: add dpms animations (#11452) 2025-08-17 08:37:13 +01:00
Vaxry
3d4dc19412
renderer: improve zoom in anims (#11453)
Removes `animations:first_launch_animation` as it's useless now
2025-08-16 20:02:15 +01:00
vaxerski
78c9e2080c framescheduler: fix edge case crashes
rare UAFs because renderMonitor can call onDisconnect (ugh, that should be changed...)

fixes #11073
2025-08-16 16:52:40 +02:00
Maaz Ahmed
1cbb62ed6a
masterlayout: add previous mode for focusmaster command (#11361) 2025-08-16 14:42:23 +01:00
Martin
7580a9aaaa
renderer: Add rounding power setting to groupbar and gradient roundness. (#11420) 2025-08-16 14:14:14 +01:00
Aditya Lohuni
edc473e8b0
xwayland: prevent infinite event loop in XWM clipboard transfers (#11427)
Only recreate event source when onWrite() returns 1 (needs continuation).
Prevents infinite loop when no valid transfers are available, fixing high
CPU usage and error spam.
2025-08-15 18:04:39 +01:00
Nihal Jere
aaedce596e
protocols: implement ext-data-control (#11323)
This protocol has superseded wlr-data-control
2025-08-15 15:38:28 +01:00
vaxerski
60d769a899 internal: unify VT getting 2025-08-14 17:13:23 +02:00
Kamikadze
beee22a95e
refactor: Use new hyprutils casts (#11377) 2025-08-14 15:44:56 +01:00
Arnaud
aa6a78f0a4
internal: Ensure unique identifiers for persistent workspaces (#11409) 2025-08-13 08:45:34 +01:00
David Baucum
2b6e2ceb2e
config: Hardened config logic against Time-Of-Check race conditions (#11368) 2025-08-12 20:11:21 +01:00
Martin
449d5e1113
internal: add missing c includes (#11417) 2025-08-12 20:07:19 +01:00
vaxerski
cb6589db98 misc: remove commas from device names
ref #11399
2025-08-11 20:01:33 +02:00
vaxerski
584b844aaf [gha] Nix: update inputs 2025-08-10 16:52:29 +00:00
Maxime Nordier
69c3ab1a49
tablet: do not lock focus when dnd-ing (#11390) 2025-08-10 17:51:14 +01:00
Vaxry
00da4450db
renderer: minor fixups to uv calcs (#11375)
Fixes #11374
2025-08-08 16:14:02 +02:00
Iman Seyed
afbd879685
configWatcher: fix inotify event reading buffer size (#11337)
Read full variable-length inotify_event structure instead of just the
fixed-size header. The previous code only read sizeof(inotify_event)
bytes, missing the trailing name field, which could cause truncated
events and undefined behavior.
2025-08-07 18:15:28 +02:00
Fazzi
6a1baa89b1 nix/lib: add bezier to topCommandsPrefixes
if any custom beziers are defined in animations, hyprland will complain
that the beziers haven't been defined. I think this change makes sense
as its likely most configurations are defining custom beziers anyway.
2025-08-07 11:27:02 +03:00
Vaxry
a4529beb7c
master: avoid crash if openingon null in onWindowCreated 2025-08-06 23:47:47 +02:00
Vaxry
d1c8dc5420
hyprtester: drop gcc flag 2025-08-06 22:46:26 +02:00
Vaxry
ec26b753a2
descriptions: fix bad json output (#11350)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-08-06 16:28:07 +02:00
Sv. Lockal
0c317f2508
internal: Fix compilation with libc++ (#11355)
Build with libc++ (Clang-20, Gentoo LLVM profile) fails due to transitive include with:
```
s_Sys.cpp.o -c ../hyprland-source/hyprpm/src/helpers/Sys.cpp
../hyprland-source/hyprpm/src/helpers/Sys.cpp:24:24: error: implicit instantiation of undefined template 'std::basic_ostringstream<char>'
   24 |     std::ostringstream oss;
      |                        ^
/usr/include/c++/v1/__fwd/sstream.h:28:28: note: template is declared here
   28 | class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
      |                            ^
1 error generated.
```
2025-08-06 14:01:02 +02:00
Moh Oktavi Aziz Nugraha
3c6536d932
config: format animation config as table for readability (#11326) 2025-08-05 19:31:32 +02:00
Vaxry
2859f1b795
keybinds: use the triggering keyboard for repeat timings (#11309) 2025-08-05 15:54:55 +02:00
JS Deck
2be309de1d
virtualkeyboard: Add options to skip releasing pressed keys on close and to skip sharing key states (#11214) 2025-08-04 21:29:39 +02:00
WhySoBad
6491bb4fb7
hyprctl: Include physical monitor size in IPC monitor info (#11276) 2025-08-04 21:28:54 +02:00
Vaxry
1b86d35f7e
popup: remove wlSurface ownership on destroy
fixes #11320
2025-08-03 22:55:02 +02:00
Vaxry
549f5e8dff
popup: fix animation configs 2025-08-03 16:48:12 +02:00
Vaxry
0f1484c2f4
subsurface: check surface size in damageLastArea
akin to CPopup, which already does this
2025-08-03 16:42:54 +02:00
Vaxry
f6d8e86439
popup: imorove logging, use fadeAlpha for opacity 2025-08-03 16:39:54 +02:00
Vaxry
61826dc7ac
renderer: fix snapshot coords 2025-08-03 16:19:36 +02:00
Vaxry
855d103aef
renderer: add popup fade-in-out (#11313)
Adds xdg popup fade-in and fade-out
2025-08-03 13:44:50 +02:00
Vaxry
77068c781d
screencopy: multiply box pos by scale
fixes #11299
2025-08-03 13:28:24 +02:00
Vaxry
bfe7e090bc
hyprctl: fix typo in seterror
fixes #11297
2025-08-03 13:21:29 +02:00
Vaxry
824438949e
renderer: apply default luma for reverting back to srgb
fixes #11315
2025-08-02 16:21:08 +02:00
Rico
f1f1161c17
dwindle: fix single_window_aspect_ratio not updating with config reload (#11305)
* dwindle: fix single_window_aspect_ratio not updating with config reload

* refactor: dereference instead of using ptr method
2025-08-02 15:24:18 +02:00
Vaxry
e1e23eb9bd
screencopy: avoid crash on cm disabled
fixes #11310

closes #11312
2025-08-02 14:35:20 +02:00
vaxerski
c14f792f8f [gha] Nix: update inputs 2025-08-02 11:41:47 +00:00
UjinT34
310fc629b0
protocols: fix presentation time proto version (#11306) 2025-08-02 13:40:28 +02:00
Jerry Tan
314a0ea441
LICENSE: Update year (#11301)
Update license year from 2022-2024 to 2022-2025
2025-08-01 11:17:46 +02:00
Vaxry
9607e3b5a8
screencopy: un-hdr screencopy buffers for cm-unaware clients (#11294) 2025-07-31 18:07:59 +02:00
Vaxry
a907ecd4ff
opengl: improve render fn arg clarity (#11286) 2025-07-31 16:23:09 +02:00
Martin
3e35797b18
fix: add climits includes (#11288) 2025-07-31 01:12:05 +02:00
Maxime Nordier
23be1db1e3
dnd: drop on tablet pen tip up (#11270) 2025-07-30 22:37:36 +02:00
Maximilian Seidler
f309d86003
session-lock: explicitly consider dpms states for sending locked or denied (#11278)
* session-lock: explicitly consider dpms states for sending locked or denied

* session-lock: check for active monitors before locking
2025-07-30 22:36:02 +02:00
ryincler
38e13282cd flake.lock: bump hyprutils 2025-07-30 18:13:28 +03:00
Vaxry
84c5e74459
build: bump hu dep to 0.8.2 2025-07-30 11:55:09 +02:00
Tom Englund
36a8b2226f
renderer: use CRegion foreach over getRects (#10980)
instead of allocating and returning a vector, use forEach to directly
call a function on the rects.
2025-07-30 11:54:09 +02:00
Vaxry
43966cc787
foreign-toplevel: update monitor properly on changed
fixes #11197
2025-07-29 21:59:35 +02:00
JS Deck
f51be7f201
layers: check monitor is not null on animation update (#11267) 2025-07-29 18:02:29 +02:00
Vaxry
66a6ef3859
core: disable esync for non-linux kernels
ref #10437, BSD doesn't support timeline fds
2025-07-29 17:55:56 +02:00
Vaxry
745a671ce6
input: don't reload xkb configs if settings didnt change
fixes #9105
2025-07-29 17:25:27 +02:00
Vaxry
abe29647ae
monitor: fix crash on mutating workspace vec
fixes #11236
2025-07-28 22:08:05 +02:00
Vaxry
c63d0003a1
core: fix workspace persistence tracking (#11239) 2025-07-27 18:46:23 +02:00
Shelby Tucker
5d4b4ecbfb
input: lock focus for tablet when down (#11219) 2025-07-27 15:11:45 +02:00
jmanc3
211199e864
fix: include decorations in visibleOnMonitor calculation (#11232)
Fixes: https://github.com/hyprwm/Hyprland/discussions/11203

The window turned invisible when just outside the monitor bounds, even though it should have stayed visible given its decorations.

The fix was to include the decorations when determining if a window is on a monitor.
2025-07-27 15:11:07 +02:00
Vaxry
e1fff05d0d
layerSurface: check for monitor validity in startAnimation
ref #11168

sometimes on exit monitor might be null
2025-07-26 11:46:07 +02:00
xqso
5c8d675eed
ci: correct tar command for xz compression & fix typos (#11213) 2025-07-25 17:19:23 +02:00
Vaxry
fd0c1f2ab4
keybinds: do not reset scroll timer on not passed
avoids endless lockups
2025-07-25 14:59:00 +02:00
Vaxry
31cc7f3b87
core: move workspace ptrs to weak (#11194)
Fixes some race conditions that come up in tests. We only clean up workspaces when we render a frame. With this, they are always cleared instantly.
2025-07-24 00:36:29 +02:00
mavonarx
ecc04e8ba7
drm: check syncobj timeline support before advertising protocol (#11117)
Prevents crashes on systems where DRM driver lacks syncobj timeline
support (e.g., Apple Silicon with Honeykrisp driver). Applications
like Zed and WezTerm would crash with 'Timeline failed importing'
when trying to use explicit sync.

Fixes #8158 #8803

---------

Co-authored-by: mvonarx <matthias.vonarx@sitrox.com>
2025-07-23 23:11:07 +02:00
Vaxry
c51c6e38ac
tests: add a few more workspace tests 2025-07-23 20:41:38 +02:00
Florent Charpentier
55f2daa21e
swipe: fix workspace swipe not rendering last frame if target ws is on edge (#11184)
Fix for a weird behaviour that happens when swipe is only valid in 1
direction (i.e. from ws 1)

When you start a swipe from the only direction possible, then swipe back
(without releasing), the last frame where the delta is reset to 0 was
not being rendered
2025-07-23 20:06:28 +02:00
Nikolaos Karaolidis
2d2a5bebff
core: fix maxwidth resolution mode (#11183)
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-07-23 12:10:39 +02:00
Tom Englund
6ca7c14b58
CTM: check for finite value aswell (#11185)
checking for < 0.F will not catch NaN or inf values, use std::isfinite
aswell.
2025-07-23 12:09:19 +02:00
Vaxry
fdbbad04bb
core: enter unsafe state on boot if there are no mons 2025-07-22 11:14:12 +02:00
Karun Sandhu
873914a2a6 CI/Nix: also check for qt version in update script 2025-07-22 09:56:43 +03:00
00-KAMIDUKI
50758505d5
example: make screen shader example compatible with glsl 300 (#10846) (#11132) 2025-07-21 21:05:47 +02:00
Vaxry
462729d865
protocols/subcompositor: fix subsurface sorting (#11136) 2025-07-20 19:42:40 +02:00
Thomas Müller
bf1602d9f9
renderer: implement wp-color-management-v1 transfer functions (#11084) 2025-07-20 18:20:27 +02:00
MightyPlaza
d4de69381e
internal: set value and goal for window size and position on setGroupCurrent (#11120) 2025-07-20 17:00:17 +02:00
MirzaSamadAhmedBaig
503fc458d8
internal: replace unsafe strcpy with snprintf (#11128) 2025-07-20 15:31:53 +02:00
Vaxry
a3d59b525b
systeminfo: print more render info 2025-07-20 14:51:17 +02:00
Mozzarella32
b7a91e02e9
renderer: Add cursor:invisible to allow to hide the cursor (#11058) 2025-07-20 12:40:21 +02:00
Vaxry
58b6eceb6d
sessionlock: fix flipped if condition 2025-07-20 12:33:22 +02:00
Vaxry
91d8a629eb
sessionlock: fix timer logic on unsafe state 2025-07-19 16:48:20 +02:00
Vaxry
8b38353012
eventloop: improve timer handling to avoid crashes
ref #11062
2025-07-19 16:47:14 +02:00
Vaxry
3b04131259
eventloop: avoid duplicate timers 2025-07-19 13:31:37 +02:00
Vaxry
d84699d8e5
opengl: detect android fence support and disable explicit if it's missing (#11077)
Checks for explicit sync support via the android fences, and falls back to implicit sync if it isn't
2025-07-19 12:38:41 +02:00
MrFantOlas
ae3cc48f22
protocols/gamma: support pipes (#11076)
Add support for pipes and potentially other valid file descriptors. Add check for more data on the socket than the required amount as per protocol.

---------

Co-authored-by: Alexandre Teixeira <alexandre.teixeira@etu.emse.fr>
2025-07-18 23:20:17 +02:00
Radovenchyk
4adf658907
README: add link to CI from badge (#11085) 2025-07-18 21:13:56 +03:00
Mike Will
260a13a12f
snap: use window extents instead of border size (#11079)
* snap: use window extents instead of border size

`border_overlap` no longer does anything for window snapping, only monitor snapping.
2025-07-18 17:35:43 +02:00
vaxerski
088e8af955 [gha] Nix: update inputs 2025-07-18 10:11:00 +00:00
Vaxry
49abc193f7
framescheduler: check monitor validity in doLater 2025-07-18 12:09:43 +02:00
Vaxry
a05c797e4a
compositor: properly set infinite region on null input
fixes #11065
2025-07-17 22:04:20 +02:00
Tom Englund
b46dc9ee0c
framescheduler: dont if check deleted weakpointer (#11063)
if m_monitor is destroyed the doOnReadable will eventually hit UB on
destruction if checking a destroyed m_monitor. acctually use the
captured mon weak pointer.
2025-07-17 21:59:20 +02:00
aphelei
75c0675e14
config: add better zoomFactor default (#11060) 2025-07-17 18:37:11 +02:00
Vaxry
49d73d1893
config: default drag_lock to 0 2025-07-16 22:39:42 +02:00
boundlessvoid0
409b56f6a3
hyprctl: make animations print details about bezier curves (#10413) (#10871) 2025-07-16 21:35:15 +02:00
Vaxry
148718b3bc
socket2: fixup invalid ws passed to openwindow
fixes #11044
2025-07-16 18:22:54 +02:00
Vaxry
5349667992
master: add ignoremaster to swapwithmaster
fixes #11042
2025-07-16 15:51:11 +02:00
Vaxry
c4a4c34156
version: bump to 0.50.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland with Meson (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (Arch) (push) Has been cancelled
Nix / update-inputs (push) Has been cancelled
Nix / hyprland (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
Nix / xdph (push) Has been cancelled
Nix / test (push) Has been cancelled
2025-07-16 11:33:42 +02:00
Vaxry
d4fbedcd35
core: never use hw cursors when tearing 2025-07-16 11:33:40 +02:00
Vaxry
5bfe6dc703
config: disable hw on mgpu nvidia by default (#11018) 2025-07-16 11:02:20 +02:00
Mike Will
8453fbf4eb
snap: fix border_overlap option for monitor snapping (#10987) 2025-07-15 22:24:40 +02:00
UjinT34
e15014e031
protocols/cm: Fix preferred image description (#11026) 2025-07-15 19:33:14 +02:00
UjinT34
bc764f7065
protocols: Remove incorrect CM proto debug check and fix preferred image description (#11023) 2025-07-14 22:54:43 +02:00
Maximilian Seidler
06fcdbd9c7
renderer: use makeUnique for session-lock render passes (#11019)
Fixup for a merge conflict introduced by #10865.
2025-07-14 15:48:50 +02:00
Maximilian Seidler
01971cb6c7
session-lock: don't render workspaces when locked (#10865)
Avoid rendering the workspace behind if we are locked
2025-07-14 13:13:54 +02:00
Vaxry
d0f58baf29
screencopy: ignore hidden windows in noscreenshare
fixes #11002
2025-07-12 18:22:47 +02:00
Vaxry
8bfff87833
debugOverlay: fix tick measurement 2025-07-12 18:19:59 +02:00
Vaxry
6821723b44
splashes: add zacoons' splash
winner of the 4th ricing comp
2025-07-11 23:47:48 +02:00
Tom Englund
e589adb00d config: remove render_ahead* config options
remove render_ahead* config options and descriptions. they are unusued.
2025-07-11 17:51:04 +02:00
Tom Englund
523eed048e xwl: dont mark the even source as readable
wl_event_source_check makes the event trigger until onx11event returns non
zero. but we arent removing the event source from the event loop so lets
not mark it at all and recieve spurious constant calls.
2025-07-11 17:51:04 +02:00
Tom Englund
e6bb809663 monintor: remove rathandler
is this even used? lets just remove it.
2025-07-11 17:51:04 +02:00
Tom Englund
b5433bb753 singlepixel: move to unique ptrs
less refcounting, move by rvalue.
2025-07-10 14:09:00 +02:00
Tom Englund
bcb96c5532 presentation: move to unique ptrs
less refcounting, move by rvalue.
2025-07-10 14:09:00 +02:00
Tom Englund
f22b5971d1 dmabuf: move to unique ptrs
less refcounting, move by rvalue.
2025-07-10 14:09:00 +02:00
Tom Englund
87653077f8 cursorshape: use unique ptrs
less refcounting.
2025-07-10 14:09:00 +02:00
Tom Englund
a21882be33 ctmcontrol: move to unique ptrs
less refcounting, move by rvalue.
2025-07-10 14:09:00 +02:00
Tom Englund
37be9a8959 alphamodifier: move to unique ptrs
less refcounting, move by rvalue.
2025-07-10 14:09:00 +02:00
Tom Englund
f5af40afce renderpass: use unique ptr instead of shared ptr
lets use unique ptrs instead of refcounting shared ptr when its not
needed, use rvalue reference to construct in vector directly.
2025-07-10 14:09:00 +02:00
Vaxry
6375e471f3
config: disable new_render_scheduling by default 2025-07-09 16:13:57 +02:00
Kamikadze
c6497a7193
internal: Prevent double-free in attemptDirectScanout (#10974) 2025-07-09 14:39:36 +02:00
FrancisTheCat
9517d0eaa4
renderer: Added a pointer position uniform to the screen shader. (#10821) 2025-07-08 19:31:15 +02:00
outfoxxed
78e9eddfb6
core: use new typed signals from hu (#10853) 2025-07-08 18:56:40 +02:00
Tom Englund
2f34ef141b
compositor: fix race to finish on null buffer (#10970)
if a null buffer is commited and a pending state is awaiting, drop the
pending state so we dont end up in race to finish brokeness.
2025-07-08 18:55:46 +02:00
Vaxry
8f948827a6
Renderer: Implement new render scheduling (#10936)
Implements a new render scheduling method, where we triple buffer when necessary.

Enabled by default, improves FPS on underpowered devices.

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-07-08 12:41:10 +02:00
Tom Englund
9856563f89
opengl: avoid reallocations in EGLImage (#10960)
use a std::array instead of vector and avoid reallocations.
it should at most be 49 entries, so make the array 50. and RASSERT check
it incase more entries gets added in the future.
2025-07-07 23:44:35 +02:00
Tom Englund
bb958a9e13 pass: overload TexPass constructor
overload it with a rvalue to allow us to move the data directly avoiding
an extra copy. because SRenderData is not trivially copyable.
2025-07-07 18:09:34 +02:00
Tom Englund
c75f85098c renderer: move render calculation behind if case
the durationUs is not used unless debug overlay is enabled, lets not
calculate it each call to rendermonitor if not enabled. same with
renderStart.
2025-07-07 18:09:34 +02:00
Tom Englund
4a30e2acd9 eventloop: RAII the even source on readable fd
RAII remove the event source and honor rule by 5
2025-07-07 18:09:34 +02:00
Tom Englund
ceec1943ff compositor: dont send around int max values
we know the buffersize use it instead of int max values that can
potentially cause math issues and slowdowns. minor improvement to
glmark2 aswell.
2025-07-07 18:09:34 +02:00
jmanc3
83c453cb82
plugins: made currentWindow available in RENDER_PRE_WINDOW (#10957) 2025-07-07 18:06:42 +02:00
Tom Englund
54369adffa
internal: iso C++ prohibits anonymous structs (#10955)
turn on -Wpedantic and name the anonymous struct.
2025-07-07 16:18:06 +02:00
vaxerski
d23ed852fc [gha] Nix: update inputs 2025-07-07 11:34:38 +00:00
Tom Englund
a16d0c76a6
texture: zero out the cached states in destroy (#10954)
if destroyTexture is called outside of the texture destructor we need to
empty out the cached states.
2025-07-07 13:33:22 +02:00
Mihai Fufezan
6a5f4f5954
Nix: fix overlay application
Should fix hyprwm/hyprland-plugins#412
2025-07-05 14:18:38 +03:00
MightyPlaza
b99c193e46
internal: handle setGroupCurrent properly on fs groups (#10920) 2025-07-05 00:16:25 +02:00
bobrat
9b51d73a1e
hyprpm: print all dependencies that are missing (#10907) 2025-07-04 14:43:46 +02:00
Tiago Dinis
3c9447ca53 nix: update aquamarine 2025-07-04 01:33:31 +03:00
Mihai Fufezan
90c8609cbb
CMake: disable tests by default (#10899) 2025-07-01 23:18:34 +02:00
Vaxry
b246f33ab1
inputmgr: remove unused var 2025-07-01 23:18:01 +02:00
aphelei
e9c5594186
renderer: add mouse zoom animations (#10882)
Adds animations for the mouse zoom effect.
2025-07-01 11:33:48 +02:00
Tom Englund
e827b75e22
opengl: add missing skipcm if case (#10888)
missing skipcm if case so the CM uniforms where never added on the
gradient2 renderBorder case, until the non gradient2 one had run atleast
once. causing it to not render on first launch/delayed.
2025-07-01 11:32:49 +02:00
Tom Englund
9adacef70b
buffer: check if buffer fd already readable (#10894)
check if buffer fd is already readable, to avoid a lot of unnecessery
systemcalls and churn.
2025-07-01 11:32:17 +02:00
Tom Englund
f464dfbefa
shader: replace texture2d with texture (#10893)
* shader: replace texture2d with texture

remove unused v_color and replace deprecated texture2d with texture.

* shader: use the more modern essl3 extension

GL_OES_EGL_image_external_essl3 provides support for samplerExternalOES
in texture function, aquamarine already use it. apply it here too.
2025-07-01 11:32:00 +02:00
Tom Englund
8c37d2ce25
sessionlock: restore cursor if hidden on unlock (#10889)
if session locks have hidden the cursor its gonna be missing unless a
new cursor shape is set, hovering windows makes us get one, moving the
wallpaper/desktop does not. set it again to left_ptr as is default on
compositor start.
2025-07-01 11:31:10 +02:00
Karun Sandhu
ee8978b961 flake.lock: update 2025-06-29 19:29:36 +03:00
Vaxry
ab900d8752
screencopy: fix improper box calculations for transforms (#10870) 2025-06-28 17:01:14 +02:00
Vaxry
0fea173fc8
unbind: add unbind all 2025-06-28 14:55:13 +02:00
Mihai Fufezan
a01d20cfe8
CI/Nix: fix rebase oopsie 2025-06-27 16:56:52 +03:00
Vaxry
e4b6fedfb9
tester: simplify adding test files 2025-06-27 12:18:45 +02:00
Vaxry
1fc7e80bdb
README: update previews 2025-06-27 12:06:21 +02:00
Mike Will
b850b35778
snap: move gapOffset logic outside of for loop (#10861) 2025-06-27 12:01:45 +02:00
Mihai Fufezan
2796ec1cf2 CI/Nix: separate xdph from hl 2025-06-26 23:38:23 +03:00
Vaxry
3d6476c902
Core: Add a test suite (#9297)
Adds a test suite for testing hyprland's features with a runtime tester

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-06-26 19:43:39 +02:00
rafiq
9a67e0421b
renderer: clamp rounding_power (#10816) 2025-06-26 19:26:46 +02:00
outfoxxed
3bbdf9dc5a
protocols: add ext-workspace implementation (#10818) 2025-06-26 18:32:44 +02:00
sam
1f337a7a5e
hyprctl: replace read-only strings with std::string_view (#10851) 2025-06-26 12:28:35 +02:00
UjinT34
452a158107
config: use parseScale for monitorv2 (#10852) 2025-06-26 12:28:21 +02:00
Tom Englund
f4f090e4b2
renderer: reduce a lot of glcalls and cache various states (#10757)
* opengl: cache viewport state

according to nvidia docs calling glViewPort unnecessarily on the same
already set viewport is wasteful and can cause state changes when not
needed. cache it in a struct and only call it when the viewport is
actually changing.

* opengl: cache glenable/gldisable state

avoid making multiple glenable/gldisable calls on already set caps, can
cause state changes and incur driver overhead.

* opengl: cache glscissor box

only call glscissor if the box actually has changed, try to avoid state
changes.

* opengl: cache gluniform calls

cache the gluniform calls, the uniform values are cached in driver per
program only the drawcalls setting the uniform yet again with the same
value on same location is causing more overhead then caching it ourself
and just no oping on it if no changes.

* shader: rewrite handling of uniforms and state

this is way faster as we don't need to mess with maps (hashing, etc) and instead can just use an array

* opengl: stuff and 300 shaders

* opengl: typo

* opengl: get the uniform locations properly

now that the legacy shaders are gone get the uniformlocations for
SKIP_CM etc, so they can be properly set and used depending on if
cm_enabled is set to false or true, before it was falling back to a
legacy shader that didnt even have those uniforms.

* opengl: check epsilon on float and remove extra glcall

seems an extra unset glcall was added, remove it. and check the float
epsilon on the glfloat.

* opengl: remove instanced shader draw

remove the instanced boolean from the vertex shader, might be neglible
differences, needs more benchmark/work to see if its even worth it.

* texture: cache texture paramaters

parameters where occasionally set twice or more on same texture, short
version wrap it and cache it. and move gpu churn to cpu churn.

add a bind/unbind to texture aswell.

* texture: use fast std::array caching

cache the texparameter values in fast array lookups
and incase we dont want it cached, apply it anyways.

* shader: fix typo and hdr typo

actually use Matrix4x2fv in the 4x2fv cache function, and send the
proper float array for hdr.

* texture: make caching not linear lookup

make caching of texture params not linear.

* minor style changes

* opengl: revert drawarrays

revert the mostly code style reduce loc change of drawarrays, and focus
on the caching. its a if else case going wrong here breaking
blur/contrast amongst others drawing.

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2025-06-25 12:42:32 +02:00
Mihai Fufezan
5a348fb7df
Nix: filter src using fileset
Allows reusing already-built derivation when changing files outside the
ones defined in the fileset.
2025-06-24 21:39:42 +03:00
Vaxry
aea8132001
buffer: don't use crazy listener::emit() 2025-06-24 15:23:53 +02:00
UjinT34
cf7e3aa448
renderer/cm: Add automatic hdr (#9785) 2025-06-23 14:33:09 +02:00
Vaxry
c7c8ca475b
config: add missing description for enforce_permissions 2025-06-23 13:56:02 +02:00
Vaxry
24e5f9974d
hyprctl: print no open windows instead of invalid request on empty clients 2025-06-23 13:49:30 +02:00
Vaxry
dd33128c2f
input: fix mouseDown triggering hl ops on locked (#10809) 2025-06-22 12:49:13 +02:00
zacoons
8b1d5560cf
renderer: add wrapping options to renderTextureWithBlur method (#10807) 2025-06-21 19:03:28 +02:00
vaxerski
2388874738 [gha] Nix: update inputs 2025-06-21 14:22:28 +00:00
Vladimir-csp
4be32dbff4
xwayland: Don't leave shell process (#10802) 2025-06-21 16:21:08 +02:00
fufexan
8ebff1948f [gha] build man pages 2025-06-19 22:49:42 +00:00
Mihai Fufezan
a301d54df8
treewide: hyprland.org -> hypr.land 2025-06-20 01:49:20 +03:00
Mihai Fufezan
ff2f85641a CI/Nix: add cache-nix-action
Use nixbuild/nix-quick-install-action which pairs well with
nix-community/cache-nix-action.

Should help with build times by reducing the number of packages needing
to be re-downloaded on each run.

Parameters are taken from https://github.com/nix-community/cache-nix-action
and may be tweaked later.
2025-06-20 01:37:59 +03:00
Jasson
b49d0ca20e
xwayland: Fix crash when copying from wayland to xwayland (#10786) 2025-06-19 19:44:38 +02:00
Vaxry
86b5e3bfbc
config: nuke explicit_sync settings
were not used anymore, explicit is on by default
2025-06-19 14:58:03 +02:00
Vaxry
54ccf9c6b3
renderer: make lock fail textures dynamically loaded
this should reduce idle vram usage by a whopping 16MB, but also might fix the tty unknown issue.
2025-06-19 13:46:42 +02:00
Vaxry
e999ad664d
hookSystem: avoid using manual mem management, fix leak
fixes #10790
2025-06-19 11:58:12 +02:00
7mile
9fb6b5d96b
input: Fix incorrect localcoords with a surface above an XWayland window (#10773) 2025-06-18 22:48:51 +02:00
Vaxry
0fb63c68e9
permissions: properly print config requests for plugins 2025-06-18 22:43:04 +02:00
Vaxry
83a4c61048
plugins: don't update config plugins on state unchanged
fixes #10781
2025-06-18 22:42:57 +02:00
Jasson
bef1321f00
xwayland: fix minor errors in previous refactor (#10763) 2025-06-18 10:16:22 +02:00
Jacob Ilias Komissar
0ece4af36a
grpupbar: Add config options to color inactive and locked groupbar titles (#10667) 2025-06-16 22:40:38 +02:00
Vaxry
aba2cfe7a8
asyncDialogBox: lock box in fdWrite to prevent a uaf (#10759) 2025-06-16 17:02:08 +02:00
Vaxry
d4e8a44087
windowrules/move: clamp max pos in onscreen to avoid assert crash
fixes #10760
2025-06-16 13:43:06 +02:00
Jasson
1905c41c65
xwayland: Use RAII instead or freeing memory manually (#10677)
As suggested by clang-tidy
2025-06-16 13:31:46 +02:00
UjinT34
bd5703d5c6
protocols/cm: fix wp invalid luminance check (#10752) 2025-06-15 23:13:57 +02:00
Vaxry
d037c54260
protocols: support xdg-shell v7
there's nothing special we need to add for this rev
2025-06-15 12:21:16 +02:00
UjinT34
c3894d9288
config/monitor: Add monitor v2 HDR rules (#10623) 2025-06-15 12:15:18 +02:00
Vaxry
3db3baa19e
opengl: use a stack for storing monitor transform enabled
fixes #10487
2025-06-15 12:11:28 +02:00
Vaxry
57d20a1bf6
internal: clean up dead snapshot code 2025-06-15 11:51:27 +02:00
Vaxry
472b52bc06
cursor: reset hc data after theme change
theme change invalidates the cairo surfaces there

fixes #10636
2025-06-15 11:47:10 +02:00
vaxerski
79b9edb85b [gha] Nix: update inputs 2025-06-15 09:46:31 +00:00
may
f08167c877
input: add sticky option for drag_lock (#10702)
* allow configuring the sticky option for `drag_lock`

* enable sticky drag_lock by default as recommended by libinput

recommended here:
https://lists.freedesktop.org/archives/wayland-devel/2024-November/043860.html
2025-06-15 11:45:06 +02:00
Joel-Valenciano
ad85406220
drm-lease: Add Multi-GPU Support (#10099) 2025-06-13 15:17:32 +02:00
Otto Modinos
d14f81e6ac
protocols: whitelist wp_color_manager_v1 for security_context (#10723)
Now that `wine` (and `proton`) supports Wayland it makes sense to allow the `wp_color_manager_v1` in Flatpak for native HDR without the need for `gamescope`!
2025-06-13 00:27:30 +02:00
linfindel
826061d166
README: Update image cdn (#10722) 2025-06-12 23:22:52 +02:00
Vaxry
748419faa5
hyprpm: check version and update automatically on add (#10706)
ideally should let the user know, but jic also checks for header updates
2025-06-12 13:40:55 +02:00
Vaxry
412c7dc7f7
renderer: fixup some missing fadeout cases with special
fixes some fadeout missing cases:

- closing last window
- closing above fs
- closing in general

fixes #10283
2025-06-11 17:52:23 +02:00
Vaxry
8329de1ab5
input: grab the correct active workspace on mouseMove
fixes #10651
2025-06-11 17:09:39 +02:00
Vaxry
144885d89f
anr: make dialog disappear if the app dies
fixes #10514
2025-06-11 17:00:16 +02:00
Vaxry
f7526d6be0
renderer: refuse rendering invalid resolutions
sometimes a driver fails to assign any reasonable mode in which case we might render 0x0 which will make us crash. Don't do that. Part 1 of #10678
2025-06-11 16:57:07 +02:00
Vaxry
6910ca76bd
protocols/subcompositor: fixup place_above and _below
fixes #10716
2025-06-11 16:54:47 +02:00
Viktor
6bdb1f413e
dwindle: add the ability to specify an aspect ratio for a singular window (#10650) 2025-06-10 08:20:31 +01:00
ilusha420
81468253ea
hyprpm: fix typo in help message (#10687) 2025-06-09 14:31:04 +03:00
Luuk Blankenstijn
231e01e39b
hyprctl: don't detect a negative value as a parameter (#10671) 2025-06-08 20:17:38 +01:00
Kamikadze
c6f713fefe
screencopy: fix incorrect noscreenshare positions with monitor scaling (#10674) 2025-06-08 08:19:23 +01:00
Kamikadze
91967f8ec0
renderer: fix incorrect cursor position when screencopy region with monitor scaling (#10675) 2025-06-08 08:18:42 +01:00
Kamikadze
0a47575c7f
internal: Use using instead of #define to alias smart pointers (#10673) 2025-06-08 08:13:56 +01:00
vaxerski
8801770981 [gha] Nix: update inputs 2025-06-07 20:14:08 +00:00
Kamikadze
66b99bd277
monitor: ensure autoDir is applied when changed (#10672) 2025-06-07 21:12:43 +01:00
sam
2794f485cb
hyprctl: Remove exceptions, use modern error handling (#10664) 2025-06-06 20:23:33 +01:00
Ufuk Ustali
0ac3bef724
input: support configuring drag_3fg from libinput (#10631) 2025-06-06 15:47:15 +01:00
vaxerski
456c820d52 assets: update header 2025-06-06 15:14:17 +02:00
UjinT34
c35c2fea40
config: Restore auto-center-* for monitors (#10660) 2025-06-06 08:01:19 +01:00
Friday
d6fbd89336 nix: use gcc15-built dependencies 2025-06-06 08:07:34 +03:00
XPhyro
fb7548cb41
screencopy: fix applying noscreenshare to invisible special workspaces (#10628) 2025-06-05 21:29:01 +01:00
Eric Li
423b69f5d3
config: add group: selector (#10588) 2025-06-05 21:17:04 +01:00
UjinT34
abdfc5ea40
config: add a new monitor v2 config syntax (#9761) 2025-06-05 15:56:46 +01:00
sam
59c886d855
internal: Catch filesystem exceptions while iterating RunTimeDir (#10648) 2025-06-05 15:19:54 +01:00
Jasson
d7a87ce6e2
xwayland: fix xwayland -> wayland clipboard (#10646) 2025-06-04 16:00:55 +01:00
vaxerski
d9f7448d82 xwayland: pad pid with leading zeroes in lockfile
fixes #10652
2025-06-04 16:54:12 +02:00
littleblack111
b5c0d0b8aa
keybinds: add an option to respect gaps out for floating to movewindow (#9360) 2025-06-03 19:48:56 +01:00
sam
b1d0a727cc
internal: Center window on parent if available (#10582)
Fixes #10537
2025-06-02 19:22:51 +01:00
Kamikadze
ef2c73af80
internal: embed example config (#10608) 2025-06-02 18:36:44 +01:00
Kamikadze
16c62a6dbb
internal: Fix HyprError not displaying at startup (#10606) 2025-06-01 21:03:53 +01:00
Jasson
2d1c6f88d2
xwm: Refactored functions in XWM.cpp (#10569)
* Refactored SXSelection::onSelection in XWM.cpp

- Made the function more readable and less redundant
- Extracted repeated conditions into booleans.
- Reduced nested conditionals
- Reused (conn) pointer

* Refectd readProp

* Refactor initSelection
2025-06-01 21:02:17 +01:00
vaxerski
82b8549542 hyprpm: refuse adding a new repo without update 2025-06-01 21:53:30 +02:00
Kamikadze
69c2b2926e
internal: refactor to use empty() (#10599) 2025-05-31 19:49:50 +01:00
Kamikadze
4078e1d17c
refactor: replace all typedef with using (#10594) 2025-05-31 14:02:02 +01:00
mitsuru
af2fdb5d58 nix: use gcc15
resolves Nix build/CI failures introduced in 9190443
bumps flake.lock as gcc15Stdenv wasn't available at the pinned version
of nixpkgs
2025-05-31 01:45:34 +03:00
Kamikadze
9190443d95
refactor: use std::ranges whenever possible (#10584) 2025-05-30 14:25:59 +01:00
littleblack111
9bf1b49144
snap: add option to respect gaps (#10524) 2025-05-28 14:20:03 +01:00
vaxerski
5cc6cb4945 groupbar: force recalc on visibility changes
fixes #10566
2025-05-28 15:18:30 +02:00
vaxerski
9b327ddfd1 monitor: mark 0, 0 presentation timestamps as invalid
fixes #10562
2025-05-27 21:26:47 +02:00
Kamikadze
24915a3a9b
windowrules: Add noscreenshare (#10482) 2025-05-27 16:10:22 +01:00
Nikolaos Karaolidis
90d0b8ecae
core: add auto-center arrangements (#10527)
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-05-27 15:51:59 +01:00
littleblack111
ddb9f8394d
config: fix inconsistant hint of default value (#10556)
similar to https://github.com/hyprwm/hyprland-wiki/pull/1093
2025-05-27 15:50:00 +01:00
littleblack111
a62ccb169a
config: fix crash on misnamed variable (#10549) 2025-05-27 08:33:17 +01:00
Vaxry
be6ee6e55f
cmake: disable gprof by default 2025-05-26 23:33:44 +02:00
Nikolaos Karaolidis
c2805aad92
config: add maxwidth monitor resolution mode (#10528)
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-05-26 19:25:58 +02:00
littleblack111
4c4c9bb324
dwindle: add better automatic window drag and drop direction detection (#9704) 2025-05-26 19:15:11 +02:00
Vaxry
292a7456af
eventLoop: fixup headers 2025-05-26 16:53:35 +02:00
Vaxry
2347050285
pass/surface: make sure popup blurs are marked for require live blur
fixes #10535
2025-05-25 18:48:32 +02:00
Vaxry
a58ab20e8b
debug/pass: show live/precompile blur in debug 2025-05-25 18:45:28 +02:00
Vladimir-csp
cc0792c1dc hyprland-uwsm.desktop: Add TryExec
This should hide this entry when uwsm is missing (at least in DMs that handle TryExec)
2025-05-25 14:55:33 +03:00
vaxerski
28c9122adb [gha] Nix: update inputs 2025-05-24 18:41:03 +00:00
Vaxry
55076edaac
versionkeeper: don't pop up on initial launch 2025-05-24 20:39:36 +02:00
Virt
81cd526f92
cursor: fix screencopy cursor pos and duplicate shape with sw cursors (#10519)
* cursor: account for hotspot with overridePos

* cursor: don't draw cursor on screencopy if using sw anyways
2025-05-23 23:41:35 +02:00
Mihai Fufezan
bd4733a0ff
flake.lock: update
nix/overlays: remove wayland-protocols overlay. PR landed in master a while ago
2025-05-22 18:02:20 +03:00
nezu
4f161da3d6
hyprpm: ignore pins when adding a package with a git rev (#10502)
ref #10436
2025-05-22 13:54:02 +02:00
darkwater
185c96849e
input: unhide cursor on tablet events after touch events (#10484) 2025-05-21 23:44:21 +02:00
zacoons
b90910c0dc
renderer: add wrapping options to renderTexture method (#10497) 2025-05-21 16:41:40 +01:00
Vaxry
eb3b38d40b
eventLoop: fixup event source callbacks 2025-05-19 01:27:30 +02:00
Vaxry
d9c8a37811
input: always allow focus to permission popups 2025-05-18 19:34:20 +02:00
Vaxry
158c0f2911
permissions: add permission management for keyboards (#10367) 2025-05-18 19:13:20 +02:00
zacoons
44cb8f769e
internal: added error log when getEdgeDefinedPoint is impossible (#10462) 2025-05-18 19:10:06 +02:00
Vaxry
705b97c4ac
input: revert #10416 and #10418
fixes #10451
2025-05-17 19:43:12 +02:00
Vaxry
c19f383685
hyprpm: fix crash with enable without an arg 2025-05-17 19:07:18 +02:00
Vaxry
bb5cd5b2dd
screencopy: store a fb before permission popup if the permission is pending (#10455)
stops rendering the permission popup on stuff like grim when it asks
2025-05-17 19:03:35 +02:00
Vaxry
bb9aa79b21
hyprpm: reject remove without a param
ref #10458
2025-05-17 18:10:35 +02:00
Vaxry
dfa4836216
hyprpm: fix execute permission bit on installed dirs (#10435) 2025-05-17 18:08:42 +02:00
vaxerski
18377d221d [gha] Nix: update inputs 2025-05-17 11:08:13 +00:00
outfoxxed
2aa21625bd
input: ensure seat grabs from exclusive layers can be dismissed (#10418) 2025-05-17 13:06:48 +02:00
outfoxxed
2946009006
input: do not send mouse events when outside of a surface (#10416) 2025-05-16 23:39:28 +02:00
outfoxxed
b0cc49218d
protocols: simulate mouse movement after activating a toplevel (#10429) 2025-05-16 23:38:45 +02:00
Zach DeCook
a5c9b3e490
core: Include cstring whenever strncpy is used (#10404)
Fixes ppc64le build in alpine
2025-05-15 10:31:44 +01:00
outfoxxed
dfb841c303
desktop: prevent layers from dismissing their own seat grabs on map (#10417) 2025-05-15 10:16:03 +01:00
Tom Englund
5ceb0ec15d
core: drop the legacy renderer (#10408)
* core: drop the legacy renderer

the legacy renderer is broken and barely used, drop it.

* Nix: drop support for legacyRenderer

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-05-15 10:13:24 +01:00
outfoxxed
f707d86912
protocols/hyprland-surface: account for scaled monitor positions (#10415) 2025-05-15 10:12:55 +01:00
Yukari Chiba
75f2cb5f65
xwayland: do not include xcb.h when xwayland is disabled (#10407)
xcb.h should not be included when xwayland is disabled. 
This allows hyprland to not use X11 libraries at all when xwayland is disabled.
2025-05-14 19:31:19 +01:00
Vaxry
a51e639d81
input: disallow virtual keyboards from changing LED state (#10402) 2025-05-14 17:48:17 +01:00
Tom Englund
59b2340680
opengl: add missing vao for screenshader (#10397)
missed creating vertex array objects in 04124988e8
add it.
2025-05-13 23:46:29 +01:00
outfoxxed
da3583fd5e
opengl: publicize shader creation/usage functions (#10378)
Allows plugins to create and use shaders again
2025-05-12 14:15:47 +02:00
Tom Englund
04124988e8
opengl: optimize shaders and reduce unneeded drawcalls (#10364)
* opengl: remove unnecessery glflush calls

glflushing forces the driver to break batching and issue commands
prematurely and prevents optimisations like command reordering and
merging.

many glFunctions already internally glflushes and eglsync creation still
has a glflush at end render. so lets reduce the overhead of these calls.

* opengl: reduce glUseProgram calls

apitrace shows cases where the same program gets called multiple times,
add a helper function that keeps track of current program and only call
it once on same program. reduces slight overhead.

* opengl: use more efficient vertex array object

use a more modern vertex array object approach with the shaders, makes
it a onetime setup on shader creation instead of once per drawcall, also
should make the driver not have to revalidate the vertex format on each
call.
2025-05-11 18:36:20 +02:00
Vaxry
390a357859
renderer: use alpha for the lockttytext texture
ref #10348
2025-05-11 13:15:03 +01:00
Vaxry
9a87498bb1
renderer: minor damage fixes 2025-05-10 23:53:05 +01:00
Vaxry
f58bb72d3a
renderer: render blur on fade out (#10356) 2025-05-10 19:31:26 +02:00
vaxerski
60cd5b7a48 renderer: always render snapshots as 8bit
fixes issues with transparent windows on 10b
2025-05-09 22:16:21 +01:00
Florian "sp1rit
25cf06f6cf
build: require hyprgraphics>=0.1.3 (#10350)
49974d5 introduced use of types, which were only added in 0.1.3
2025-05-09 14:47:28 +02:00
Jan Beich
e44aae0c20
hyprpm: switch to numeric owner/group after f8bbe5124c (#10345)
On BSDs "root" is in "wheel" group. Instead of enumerating platforms
or probing "wheel" explicitly use numeric value for the superuser.

$ truss hyprpm add <url>
[...]
read(5,"install: unknown group root\n",1023)     = 28 (0x1c)
[...]
[ERR] ✖ Failed to write plugin state
2025-05-09 14:18:15 +02:00
Jan Beich
fcb6f936ea
hyprpm: add missing include for libc++ after 1c530cbc66 (#10344)
hyprpm/src/helpers/Sys.cpp:24:24: error: implicit instantiation of undefined temp
late 'std::basic_ostringstream<char>'
   24 |     std::ostringstream oss;
      |                        ^
/usr/include/c++/v1/__fwd/sstream.h:27:28: note: template is declared here
   27 | class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
      |                            ^
2025-05-09 03:42:19 +02:00
Vaxry
9958d29764
version: bump to 0.49.0
Some checks failed
Build Hyprland / Build Hyprland (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland with Meson (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Has been cancelled
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Has been cancelled
Build Hyprland / Code Style (Arch) (push) Has been cancelled
Nix (CI) / update-inputs (push) Has been cancelled
Nix (CI) / build (push) Has been cancelled
Security Checks / Flawfinder Checks (push) Has been cancelled
2025-05-08 21:15:18 +01:00
Vaxry
239cdd67fd
socket2: fix order of window events on map (#10341) 2025-05-08 22:10:31 +02:00
s1dd
f01e3043b8
desktop: cleanup code and use std::ranges (#10289) 2025-05-08 21:01:49 +02:00
Vaxry
04c98abd1f
layout: properly assign workspace and monitor when moving a child to the parent (#10338) 2025-05-08 21:00:28 +02:00
nyx
53bfb92d65
layout: allow interacting with pinned windows when fullscreened (#10326)
* layout: allow interacting with pinned windows when fullscreened

* IHyprLayout: format code

* e
2025-05-08 20:59:51 +02:00
Mihai Fufezan
2b3cac018e
flake.lock: update 2025-05-08 20:37:36 +03:00
Vaxry
f909b0f114
opengl: fix legacyrenderer 2025-05-08 18:22:44 +01:00
MightyPlaza
fa1e343b04
compositor: set fullscreenstate on movetoworkspace (#10303)
modified:   src/managers/KeybindManager.cpp
2025-05-08 18:29:47 +02:00
davc0n
22b12e3013
refactor: cshader class to sshader struct (#10324) 2025-05-08 00:07:35 +02:00
Mihai Fufezan
7a971735af
flake.lock: update 2025-05-07 21:51:59 +03:00
Tom Englund
6abb5b0c7e
renderer: precompute fullalpha (#10319)
precompute it once instead of calculating it every single call, was showing
up as a lot of time wasted in profiling.
2025-05-07 19:02:07 +02:00
Tom Englund
0dfcba9825
DMABuffer: reserve vector and avoid UB (#10317)
actually reserve the vector instead of initializing it with the
m_attrs.fd.size() adding 4 invalid fd entries, and later emplace_back
the valid ones.

sync_merge_data name is defined as char name[32] a fixed size array, and
c++ technically doesnt allow assigning string literals directly to array
fields in aggregate initializers, it may compile but is technically
undefined behaviour or ill formed. zero initalise it and use
std::ranges::copy_n instead.
2025-05-07 18:15:27 +02:00
davc0n
e5df8cdc62
xwayland: refactor class member vars (#10312)
* xwayland: refactor class member vars

* xwayland: fix pure wayland build
2025-05-07 15:21:44 +02:00
Vaxry
f8bbe5124c
hyprpm: clean up root access and properly check input (#10304)
* manifest: reject bad names from parsing

* sys: restructure root functions
2025-05-06 22:43:08 +02:00
Vaxry
948277895e
popup: damage old size on unmap as well as new (#10306)
fixes #10305

chromium for some reason sets the popup size to like 8x8 at the same time as unmapping
2025-05-06 21:49:20 +02:00
Zebra2711
708a7c24ef
hyprpm: add missing return (#10299)
Add a missing return statement after handling the first superuser binary in the `dropSudo` function

Fixes: 1c530cb

Co-authored-by: Zebra2711 <zebra2711@users.noreply.github.com>
2025-05-06 14:53:28 +02:00
CyrenArkade
1ce614dfc0
animations: Add option for animating workspaces as if the first and last were adjacent (#10277)
* add option for animating workspaces as if the first and last were adjacent

* change wraparound detection to use IDs instead of dispatcher

* move shouldWraparound from MiscFunctions to Monitor
2025-05-06 03:54:27 +02:00
Jack Barnes
930eeac900
window: use stored size for new floating window when persistentsize is set (#10212)
* fix(window): use stored size for new floating window when persistentsize is set. fix hyprwm#9422.

* fix: replace `std::any_of` with `std::ranges:any_of`

* fix: use initialClass and initialTitle when storing sizes on close

* fix: add `xdgTag` as a new indicator

* fix: no {}

* fix: format with clang-format
2025-05-06 03:53:43 +02:00
shane blackthorne
ec93f8a1cd
socket2: add monitorremovedv2 event (#10229) 2025-05-06 03:52:36 +02:00
davc0n
997fefbc11
render: refactor class member vars (#10292)
* render: refactor class member vars

* render: fix clang format
2025-05-05 23:44:49 +02:00
Vaxry
c7eb141098
renderer: always try to apply a mode if pixel size is invalid (#10291) 2025-05-05 23:40:37 +02:00
Vaxry
1f50cdfa8b
hyprpm: wrap sudo cmd in quotes
ref #10288
2025-05-05 13:09:00 +01:00
s1dd
1c530cbc66
hyprpm: Minor optimizations and refactor of helpers and progress bar (#10246)
* hyprpm: optimize sys.cpp

* hyprpm: refine progress bar logic

* chore: fix fetchSuperuserBins

* chore: modify one line if/else statements

* chore: fix if/else statements

* chore: follow naming convention for const vars

* chore: revert shell escape logic
2025-05-05 04:22:22 +02:00
davc0n
9cd5b25745
protocols: refactor class member vars (u-z) (#10282)
* protocols: refactor class member vars (u-z)

* protocols: fix clang format
2025-05-04 23:39:00 +02:00
phonetic112
78ff20ddf0
workspaces: Fix empty flag not selecting active workspace (#10237) 2025-05-04 19:22:41 +02:00
davc0n
2626f89ea6
protocols: refactor class member vars (n-t) (#10273) 2025-05-04 19:21:36 +02:00
davc0n
adbae0f74d
protocols: refactor class member vars (a-m) (#10265) 2025-05-04 00:13:29 +02:00
davc0n
46ac115bd1
protocols: refactor class member vars (types) (#10261) 2025-05-03 18:54:50 +02:00
Honkazel
3465efcdc1
internal: Use vecnotinrect instead of !vecinrect (#10262)
* monitor: use vecnotinrect

* inputmanager: vecnotinrect

* clang format
2025-05-03 18:54:15 +02:00
Virt
cdf5736f1a
layerrules: fix abovelock interactivity for touch input (#10253) 2025-05-03 16:07:02 +02:00
davc0n
2d6ca96e07
plugins: refactor class member vars (#10257) 2025-05-03 16:06:24 +02:00
davc0n
d9cad5e1b6
protocols: refactor class member vars (core) (#10259) 2025-05-03 16:02:49 +02:00
Vaxry
0c736217a7
configmgr: fix CConfigValue<> from plugins 2025-05-02 17:53:55 +01:00
Vaxry
77ecf09506
internal: fix name confusion in SAlphaValue
fixes #10251
2025-05-02 16:29:15 +01:00
vaxerski
f1ac1847ff [gha] Nix: update inputs 2025-05-02 15:08:46 +00:00
davc0n
ce821294e2
managers: refactor class member vars (#10242) 2025-05-02 17:07:20 +02:00
Vaxry
6f174a9e08
renderer: render fading out floating windows over fs 2025-05-02 00:16:17 +01:00
davc0n
5b3e489108
inputs: refactor class member vars (#10230) 2025-05-01 23:57:11 +02:00
Jan Beich
2670b8f772
hyprpm: add missing include for libc++ after 858c0e26d1 (#10234)
hyprpm/src/core/DataState.cpp:80:23: error: implicit instantiation of undefined template 'std::basic_stringstream<char>'
   80 |     std::stringstream ss;
      |                       ^
hyprpm/src/core/DataState.cpp:149:23: error: implicit instantiation of undefined template 'std::basic_stringstream<char>'
  149 |     std::stringstream ss;
      |                       ^
hyprpm/src/core/DataState.cpp:229:31: error: implicit instantiation of undefined template 'std::basic_stringstream<char>'
  229 |             std::stringstream ss;
      |                               ^
/usr/include/c++/v1/__fwd/sstream.h:30:28: note: template is declared here
   30 | class _LIBCPP_TEMPLATE_VIS basic_stringstream;
      |                            ^
2025-05-01 20:48:13 +02:00
Vaxry
858c0e26d1
hyprpm: move to system directories for storing plugins (#10211) 2025-05-01 18:00:26 +02:00
Zetta1 Reid0
b5ef049ea1
master: Change center_master_slaves_on_right to center_master_fallback (#10201)
* Change center_master_slaves_on_right  to center_master_fallback
2025-05-01 13:29:06 +02:00
davc0n
615e0dae46
layouts: refactor class member vars (#10228) 2025-05-01 13:27:07 +02:00
davc0n
ce4766772d
hyprerror: refactor class member vars (#10227) 2025-05-01 13:26:43 +02:00
Vaxry
8d6618104e
cmake: ignore Wclobbered
fails build otherwise
2025-04-30 23:06:40 +01:00
davc0n
50e1bec85f
helpers: refactor class member vars (#10218) 2025-04-30 23:45:20 +02:00
Vaxry
b8a204c21d
ci: minor fixes to glaze 2025-04-30 22:43:37 +01:00
Ikalco
2ee5118d7a
render: properly release rendered buffers (#9807)
* cleanup eglSync

* properly release buffers in renderer

* add renderingDoneCallback and use it in screencopy

* use static constructor for CEGLSync
2025-04-30 18:35:25 +02:00
Vaxry
5d005f11fa
xdg-bell: fix wrong resource cast 2025-04-30 14:07:23 +01:00
Vaxry
54c89104de
DonationNag: ask after each major update (#10213)
This changes how the donation nag timing works.

The donation nag will now appear:

- after a major update (e.g. 48 -> 49)*
- once in late july
- once in december

however, a donation nag will never pop up more than once a month. So, if there is an update on the 26th of November, and you get a popup on the 28th, you will not get one in december.

This is of course still disableable in your config.
2025-04-30 14:47:35 +02:00
Mihai Fufezan
b2ad21a65c
flake.lock: update 2025-04-30 09:26:58 +03:00
Vaxry
72cb5d24b6
permissions: disable automatic reloading of permissions from cfg
security reasons, avoid reading them live. Ideally we'd lock them behind sudo, but we can't do that.
2025-04-30 00:35:32 +01:00
Vaxry
9868b18378
input: don't use pointer hold logic for unmapped surfs
fixes #10215
2025-04-30 00:31:21 +01:00
Sander
208f4c48db
config: use natural increase and decrease of brightness for default cfg (#10210)
* feat(config): hyprland natural brightness

* feat(config): natural increase and decrease of brightness
2025-04-30 01:10:47 +02:00
Vaxry
4506871310
xdg-bell: avoid crashes on null toplevel 2025-04-30 00:10:07 +01:00
Vaxry
6483f4ec22
screencopy: don't render cursor when frame doesn't want it 2025-04-29 22:02:55 +01:00
UjinT34
ae1fe860ff
renderer: add render:send_content_type setting (#9851) 2025-04-29 22:09:14 +02:00
UjinT34
49974d5e34
cm: Use precomputed primaries conversion (#9814) 2025-04-29 21:29:40 +02:00
Vaxry
94bc132084
xdg-bell/xdg-tag: fix moved resource usage 2025-04-29 19:49:13 +01:00
davc0n
e9c3fcbb64
devices: refactor class member vars (#10206) 2025-04-29 19:51:07 +02:00
Vaxry
40147d3a3f
asyncdialogbox: fix missing header 2025-04-29 18:37:21 +01:00
Vaxry
23ecce0e7a
protocols: add support for xdg-system-bell-v1 2025-04-29 18:32:21 +01:00
Vaxry
465e3d979d
window: make AsyncDialogBoxes not closeable
we don't want the user to accidentally close a popup for permissions or ANR. They can dismiss them by clicking an appropriate option.
2025-04-29 18:20:06 +01:00
Vaxry
b10a43dabc
windowrules: add noclosefor
fixes #10027
2025-04-29 18:14:02 +01:00
Vaxry
5bd7ff884d
permissions: add perms for plugin loading (#10184)
Adds permission management for loading plugins

---------

Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
2025-04-29 18:59:43 +02:00
davc0n
2118440488
windows: refactor class member vars (#10168) 2025-04-28 22:25:22 +02:00
Vaxry
c505eb55ff
screencopy: support hw cursors while sharing with cursor 2025-04-28 20:18:02 +01:00
Vaxry
f5c5cfa960
keybindmgr: fixup bindn regression
fixes #10195
2025-04-28 00:18:51 +01:00
Vaxry
0302bfdc22
async: add Promise and use it for AsyncDialogBox 2025-04-27 13:28:06 +01:00
Vaxry
4f868a1f3c
SECURITY: init security policy
fixes #9921
2025-04-27 00:07:00 +02:00
nyx
94c55fe909
helpers: properly support next/prev for workspace switching (#10074) 2025-04-26 23:52:07 +02:00
Vaxry
742bce016c
decorationPositioner: update posinfo on window update
fixes #10175
2025-04-25 16:09:11 +01:00
Virt
4cf62c114e
layerrules: add abovelock to render above lockscreen (#9793) 2025-04-25 16:38:31 +02:00
Jason
41f5f67f6c
window: Fix order of urgency flag and event emission (#10163) 2025-04-25 02:37:49 +02:00
davc0n
02d7badd15
workspaces: refactor class member vars (#10167) 2025-04-25 02:37:12 +02:00
davc0n
0e80ecc534
layers: refactor class member vars (#10149)
* layers: refactor class member vars

* popups: rename m_WLSurface to m_wlSurface
2025-04-24 20:49:49 +02:00
M Matthew Hydock
be6268a7ec
groupbar: Add options for setting group bar title font weight (and indicator gap) (#9617) 2025-04-24 20:48:08 +02:00
WhySoBad
a9549dbca0
protocols: add Hyprland toplevel mapping implementation (#9775) 2025-04-24 18:10:57 +02:00
Vaxry
b06fbdb743
dwindle: use idealIgnoreReserved for moveWindowTo bbs
fixes #10005
2025-04-23 22:31:14 +01:00
davc0n
241a4935a2
compositor: refactor class member vars (#10141) 2025-04-22 15:23:29 +02:00
Mihai Fufezan
3577a6be31
nix/overlays: add w-p 1.43 2025-04-22 11:03:27 +03:00
Mihai Fufezan
2e540e4ec4
flake.lock: update 2025-04-22 11:00:49 +03:00
Vaxry
a4f7d7c594
protocols: add xdg_toplevel_tag_v1 support
Adds a new windowrule to target windows by xdgTag, xdgtag:
2025-04-21 22:30:27 +01:00
nyx
55e953b383
InputManager: add nofollowmouse (#9994)
* InputManager: add nofollowmouse

with this, focus_follows_mouse=1 acts like focus_follows_mouse=2 on the specific windows defined by the user

* e

* e

biggest e of all time
2025-04-21 20:48:27 +02:00
nyx
d29723cb76
keybinds: allow executing binds not bound to a key (#10102) 2025-04-21 20:47:14 +02:00
davc0n
400dd16072
debug: refactor class member vars (#10130) 2025-04-21 20:42:02 +02:00
Andrei V
a3b96961a2
tablet: naive window refocusing (#10110)
Signed-off-by: Andrei V <andrei@ptaxa.net>
2025-04-21 00:32:31 +02:00
Vaxry
a3d32f3b70
hyprpm: fix format 2025-04-20 23:23:17 +01:00
davc0n
4d14bcb02f
config: Refactor class member vars (#10124)
* Refactor config classes vars

* Fix clang format errors
2025-04-20 20:39:33 +02:00
Vaxry
9b4060f09b
hyprpm: extend dep list 2025-04-20 16:54:28 +01:00
syuzuki
867bc86089
compositor: fix getMonitorInDirection skipping active monitor (#10114) 2025-04-20 04:22:21 +02:00
Bruno Krügel
f48ee7a3d1
protocols: ensure PointerConstraints activation occurs only after attched to InputManager (#10096) 2025-04-19 01:16:30 +02:00
fazzi
51afc2c291
ctm: enable fade animation on nvidia driver versions 575 and above (#10095)
* ctm: enable fade animation on nvidia driver versions 575 and above

* format if statement without braces; handle potential throw when checking for nvidia version file
2025-04-18 21:44:54 +02:00
vaxerski
02f7da2bf2 [gha] Nix: update inputs 2025-04-18 15:39:22 +00:00
Lee Bousfield
7631d4c73f
render, helpers: Call OpenGL destroyMonitorResources on disconnect (#10111)
* render, helpers: Call OpenGL destroyMonitorResources on disconnect

* helpers: Add opengl null check
2025-04-18 17:37:51 +02:00
raf
ddae3036ca
ci: close unwanted issues automatically (#10106)
* ci: close unwanted issues automatically

You want it, it's yours my friend.

* ci/close-issues: simplify

* ci/close-issues: try to handle large number of issues

* ci/close-issues: fix 'vaxerski'
2025-04-17 22:33:05 +02:00
nyx
225e13c3cc
InputManager: add config option to disable keybinds per device (#10064) 2025-04-17 02:19:10 +02:00
Lee Bousfield
3fa6320a39
desktop: Damage subsurface when position changes (#10094) 2025-04-16 17:49:01 +02:00
Vaxry
1ae7e2164c xcursormgr: include <variant>
ref #10093
2025-04-16 13:49:41 +01:00
Vaxry
877fb5b93a time: move to stl's clocks and move timer 2025-04-16 01:37:48 +01:00
Ikalco
0e521788bc
core: wait for dmabuf readiness (#9806)
* add doOnReadable to event loop manager

* move syncTimeline addWaiter to doOnReadable

* wait on dmabuf buffers to be readable

* don't over synchronize in scanout, also give present feedback on same buffer commit
2025-04-16 01:02:31 +02:00
MightyPlaza
ffd6cf65e4
windowrules: allow incrementing window props (#9566) 2025-04-16 01:00:40 +02:00
Mihai Fufezan
8b7b169043
flake.lock: update 2025-04-14 18:58:37 +03:00
Nathan Ollerenshaw
533bc5115e
monitors: fix disconnected monitors are reconnected to an empty workspace (#9874)
---------

Co-authored-by: nyx <nnyyxxxx@protonmail.com>
2025-04-14 11:07:53 +02:00
psyvern
99ab3e19d9
framebuffer: Fix framebuffer size check (#10068) 2025-04-13 22:40:15 +02:00
Vaxry
f4e19d3f1e
layerSurface: warp position and size before taking a snapshot (#10054) 2025-04-13 17:56:20 +02:00
nyx
06469b3391
IHyprLayout: center floating window at cursor when picked up from fullscreen (#10063) 2025-04-13 17:32:53 +02:00
nyx
303a10d27c
IHyprLayout: respect minimum window size (#10017)
* IHyprLayout: respect minimum window size

this prevents window warping, before we were not respecting the minimum size which caused the window to move suddenly, even though it would be sized to its minimum size.
2025-04-13 01:03:03 +02:00
rszyma
4d85e7996d
dwindle: ignore fullscreen window for positioning when use_active_for_splits=false (#9838)
* fix(dwindle): ignore fullscreen window for positioning when use_active_for_splits=false

* rename NON_FULLSCREEN -> SKIP_FULLSCREEN_PRIORITY
2025-04-13 00:58:38 +02:00
Ikalco
2da4f427ea
compositor/surface: fix surface opaque and input regions not being updated (#10055) 2025-04-12 18:58:29 +02:00
Vaxry
a17cea8b8c asyncDialogBox: fix missing pid
fixes #10056
2025-04-12 17:47:22 +01:00
alaricljs
6538970087
binds: add drag_threshold for click/drag isolation (#9839)
---------

Co-authored-by: Leeman <lstrout@enlj.com>
2025-04-12 16:43:13 +02:00
Lee Bousfield
0399e64274
screencopy: Handle explicit sync failure (#10050) 2025-04-12 16:38:46 +02:00
Vaxry
382f0f23f1
pass: revert "remove renderer finalDamage since it's unused (#9996)" (#10039)
This reverts commit 0a7e2cb152.
2025-04-11 00:34:50 +02:00
Aaron Blasko
b83c9f5c6f
cmake: do not install version.h.in (#10035) 2025-04-11 00:31:07 +02:00
Virt
d775686380
input: add warp_on_toggle_special (#9945) 2025-04-10 14:54:24 +02:00
Ikalco
0dc531c4a7
core: fix crash in data device on shutdown (#9997) 2025-04-09 18:08:42 +02:00
Ikalco
0a7e2cb152
pass: remove renderer finalDamage since it's unused (#9996) 2025-04-09 17:50:06 +02:00
Vaxry
4f991610d0 watchdog: remove watchdog
it has been unused for a while now
2025-04-09 01:48:21 +01:00
nyx
ea852965ff
xdg-shell: fix some null refs (#9992) 2025-04-08 19:43:15 +02:00
Vaxry
260d8e1f71
Permission Manager: add permission management for screencopy (#9930) 2025-04-08 19:39:53 +02:00
nyx
642f394eb3
xwayland: sync primary selection with wayland (#9952) 2025-04-08 17:36:29 +02:00
Vaxry
b15c2bfff6
CursorManager: Store cursor pixel data retrieved from X/HC as a copy (#9986)
Instead of storing pointers as refs (which could randomly get invalid very easily) copy the data.
2025-04-07 21:08:16 +02:00
Ikalco
da86db43d4
core: refactor and improve surface commit (#9805)
* make CHLBufferReference not a SP anymore

* copy over release and acquire points in CHLBufferReference

* use CHLBufferReference in screencopy and toplevel export

TODO: use CHLBufferReference in direct scanout properly
      the only problem is the scanout buffer release timing,
      specifically the onBackendRelease mechanism

* cleanup SSurfaceState and surface pending commit tracking

* move surface code from DRMSyncobj, and move acquire to SSurfaceState

* use queue for comitted pending surface states like proto says

"The content update is placed in a queue until it becomes active." - wl_surface::commit

* drop, not release, prev buffer if 2nd buffer wl_surface.attach is sent

"A wl_buffer that has been attached and then replaced by another attach instead of committed will not receive a release event, and is not used by the compositor." - wl_surface::attach
2025-04-07 21:03:27 +02:00
Vaxry
70ae99f521
input/layers: Fix exclusive LS focus / refocus after unmap (#9984) 2025-04-07 20:52:11 +02:00
Jan Beich
a8eda7f978
helpers: add missing include for BSDs after 3c128679ee (#9982)
src/helpers/AsyncDialogBox.cpp:47:23: error: use of undeclared identifier 'read'
   47 |         while ((ret = read(m_pipeReadFd.get(), buf.data(), 1023)) > 0) {
      |                       ^
src/helpers/AsyncDialogBox.cpp:83:9: error: use of undeclared identifier 'pipe'
   83 |     if (pipe(outPipe)) {
      |         ^
src/helpers/AsyncDialogBox.cpp:110:5: error: use of undeclared identifier 'close'
  110 |     close(outPipe[1]);
      |     ^
2025-04-07 20:36:01 +02:00
kerty0
8a8f394da7
swipe: fix swiping onto a new workspace bound to another monitor (#8176) (#9927)
The previous code didn't check if the chosen new workspace was bound to another monitor, causing buggy behavior where workspace was simultaneously open and not.

The fix simply uses `r+1` for new workspace selection.

Also, the previous code would select rightmost workspace + 1, creating large gaps in workspace IDs in some scenarios. Example (`()` and `[]` indicate workspaces on different monitors):

`(1), 2, 3, 4, 5, 6, 7, 8, 9, [10]`

Swipe right on `()` monitor would create:

`(1), 2, 3, 4, 5, 6, 7, 8, 9, [10], (11)`

But with this commit:

`(1), (2), 3, 4, 5, 6, 7, 8, 9, [10]`
2025-04-07 14:46:31 +02:00
Virt
51838fb5f5
layout: properly track floating window position (#9937) 2025-04-06 23:41:27 +02:00
Vaxry
85f874d10f swipe: fix prev workspace remembering
fixes #9904
2025-04-06 22:35:26 +01:00
nyx
9b3925009a
DataDevice: position icon at cursor hotspot (#9895)
* DataDevice: position icon at cursor hotspot

ref: https://wayland.app/protocols/wayland#wl_data_device:request:start_drag
2025-04-06 23:24:14 +02:00
Vaxry
3c128679ee
helpers: Add an async dialog box impl (#9919)
Adds an async dialog box, way safer than our previous local solution for ANR
2025-04-06 17:31:58 +02:00
Vaxry
e96b8ce4cc window: send fractional scale on updateScaleTransform
fixes #9889
2025-04-06 00:30:13 +01:00
Maximilian Seidler
433b7881a3
compositor: fix crash when moving a workspace to a monitor with size 0x0 (#9848) 2025-04-06 00:54:29 +02:00
Vaxry
ed05f14300 ci: nuke stalebot 2025-04-05 19:28:42 +01:00
Vaxry
c62fb08da6 github: remove issue templates 2025-04-05 18:45:52 +01:00
Vaxry
8ba20fcae1 compositor: avoid crash on null window monitor move
ref #9809
2025-04-05 00:30:33 +01:00
Mihai Fufezan
ff97d18c4c
flake.lock: update 2025-04-03 18:08:55 +00:00
Maximilian Seidler
5e8bb71785
ctm: fix crash when finishing ctm progress with a destroyed monitor (#9835) 2025-04-03 16:40:59 +02:00
Amadej Kastelic
b496e2c718
nix/module: load plugins using exec-once (#9836) 2025-04-03 10:43:06 +03:00
Arkady Buryakov
a41b8d5e97
groupbar: add text offset and upper gap settings (#9733)
* Groupbar: add keep_upper_gap setting to apply/remove outer gap offset to the upper side of groupbar

* Groupbar: add text_offset setting to adjust text vertical position in a group header
2025-04-02 22:26:46 +02:00
Armin
8654029f86
versionkeeper: create version file if not present (#9829) 2025-04-02 22:21:05 +02:00
nyx
a4e6c5d678
window: don't deactivate unfocused xwayland windows in groups (#9781)
* window: don't deactivate unfocused xwayland windows in groups

we dont want to deactivate unfocused xwayland windows because X is weird, keep the behavior for wayland windows
2025-04-02 00:51:37 +02:00
nyx
3a47c73f34
layout: center floating window at cursor when picked up from fullscreen (#9780)
* layout: center floating window at cursor when picked up from fullscreen

when picking up a floating window after it had been fullscreened before it would return to its previous position which looked ugly because the cursor could be no where near the windows original position, this patch makes it so that the window is returned to the users current cursor position

* E
2025-04-02 00:45:51 +02:00
X2E4VXpZKv
1f0fd79b91
internal: Don't force default cursor on config reload/monitor reconfigure (#9815) 2025-04-01 16:20:38 +02:00
Vaxry
d1a59ec39e renderer: render tiled fading out above other tiled windows
fixes #9717

closes #9796
2025-04-01 00:25:09 +01:00
Vaxry
4c987b20e2 makefile: fix find command in installheaders
fixes #9812
2025-03-31 17:13:27 +01:00
nyx
2309270752
anr: add config for ping number before popup shows up (#9782)
* anr: make pings configurable

makes the pings of the dialog popup configurable
2025-03-31 18:06:17 +02:00
Vaxry
79b526a041 socket2: add minimized event for foreign-wlr
ref #995
2025-03-30 22:38:30 +01:00
nyx
075bbecabd
core: fix artifacts when fullscreening (#9778)
* core: fix artifacts when fullscreening

fixes an issue where fullscreening a floating window that is between two monitors causes artifacts to appear on the monitor where it did not become fullscreened on

* e
2025-03-30 23:28:12 +02:00
nyx
8aaffda969
core: fix null ref when resuming system (#9794)
* core: fix null ref when resuming system

* e
2025-03-30 23:18:04 +02:00
Shockingly Good
10a335631e
solitary: Fix the non-working tearing #9429 (#9772)
Fixes the non-working tearing by removing the incorrect
opaqueness check for the windows.

Fixes #9429
2025-03-30 20:29:39 +02:00
Emad Elsaid
da2d7c3971
config: Fix matching monitor by description to allow space prefix (#9788) 2025-03-30 03:12:15 +02:00
LeviVanDerMaas
05eb0aa43d
workspaces: Add binds:hide_special_on_workspace_change (#9728) 2025-03-30 03:11:39 +02:00
Tom Englund
fc7223edc0
synctimeline: check if fd is readable before wait (#9789)
a lot of the time the fd is already readable, and done. so just call the
waiter directly instead of making a waiter and adding it to the
eventloop.
2025-03-30 01:53:23 +01:00
Lee Bousfield
86c279d7d0
protocols: Don't update hdr metadata if image description is unchanged (#9776) 2025-03-30 01:25:27 +01:00
micha4w
46b00a4a86
makefile: add new shaders to make installheaders (#9783) 2025-03-30 01:25:02 +01:00
Tom Englund
4a79eea6dc
opengl: check for g_pHyprOpengl pointer (#9791)
restore the pointer check to avoid null ptr dereference on compositor
destruction.
2025-03-29 21:52:27 +01:00
UjinT34
7374a023ef
renderer/opengl: Extract shaders from source (#9600)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2025-03-29 01:19:35 +01:00
Lee Bousfield
a46576afc3
xwayland: Cleanup server startup and FDs (#9769) 2025-03-28 17:12:25 +01:00
Lee Bousfield
10035a85cc
core: Don't damage the entire surface every frame (#9763)
* core: Don't damage the entire surface every frame

* core: Damage buffer on dims or transform change

* core: Use guards for scale and tr equality checks
2025-03-28 17:00:39 +01:00
Vaxry
c93140a5f1 surfacestate: reset buffer bit before applying to current
fixes #9759
2025-03-28 12:32:07 +00:00
Vaxry
5380cbcdda workspaces: minor fixes to persistence
fixes #9741
2025-03-27 14:00:29 +00:00
Tom Englund
9ea76428b6
internal: fix minor ubsan errors (#9743)
* opengl: check if g_pHyprOpengl exist

on compositor destruction we can hit a race where a CEGLSync destructs
and tries to call eglDestroySyncKHR on a null g_pHyprOpengl.

/src/render/OpenGL.cpp:3019:32: runtime error: member access within null pointer of type 'struct CHyprOpenGLImpl'
     #0 0x555565eed979 in CEGLSync::~CEGLSync() /src/render/OpenGL.cpp:3019
     #1 0x555565f6271e in std::default_delete<CEGLSync>::operator()(CEGLSync*)
     const /usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/unique_ptr.h:93

* xdgshell: dont apply state on empty states

setsize can be called before a state has been added to pending,
resulting in calling ApplyState with a empty state.

/src/protocols/XDGShell.cpp:323:11: runtime error: null pointer passed as argument 2, which is declared to never be null
     #0 0x5555659bf67e in CXDGToplevelResource::applyState() /src/protocols/XDGShell.cpp:323
     #1 0x5555659bcedc in CXDGToplevelResource::setSize(Hyprutils::Math::Vector2D const&) /src/protocols/XDGShell.cpp:  256
     #2 0x555563eed0ef in Events::listener_commitWindow(void*, void*) /src/events/Windows.cpp:841
2025-03-26 18:22:44 +01:00
Vaxry
0cd04bd666 surfacestate: track and apply updated state
fixes #9729
2025-03-26 17:22:21 +00:00
Vaxry
1c2b9a9ce3 opengl: don't attempt to compile cm on gles3.0
also disable the error for the cm shader

fixes #9738
2025-03-26 14:28:19 +00:00
vaxerski
cec084c178 pass/rect: include clipBox in opaque calculations
ref #9730 ref #9709
2025-03-26 11:47:04 +00:00
vaxerski
c2ef8fcc00 groupbar: round boxes 2025-03-26 11:44:38 +00:00
Tom Englund
3fc3521a97
pass: remove unusued timeline in texpass (#9734)
remove unused timeline and waitpoint in texpass and especially remove
the passing it to renderTextureInternalWithDamage that implicitly
converted it to bool. setting discardActive and allowCustomUV
2025-03-26 02:22:09 +01:00
Arkady Buryakov
9a67354fa2
Groupbar: apply scaling factor to text (#9731) 2025-03-26 02:07:56 +01:00
nyx
f7ba86d1f3
keybinds: add sendkeystate dispatcher (#9599) 2025-03-25 00:59:13 +01:00
Vaxry
f3db1b172c decoration: bring back border_part_of_window
fixes #9683, now under decoration: though
2025-03-24 23:57:50 +00:00
Tom Englund
2a6d070774
xwl: dont close the fd to early (#9715)
dont close the fd until the wl_event_source is removed, so we dont get
another event triggered with an already closed fd.
2025-03-24 19:33:07 +01:00
Vaxry
aec69131cd seat: avoid sending null surfaces in leave/enter events
ref #9699
2025-03-24 14:10:47 +00:00
vaxerski
4b968e5bc1 [gha] Nix: update inputs 2025-03-24 12:57:34 +00:00
UjinT34
a852461c7d
renderer: Simplify and fix hdr metadata setting (#9706)
* simplify and fix hdr metadata setting

* keep incorrect(?) cm skip till #9600
2025-03-24 13:56:07 +01:00
Mihai Fufezan
e4abf26069
Nix: add changes from Nixpkgs derivation 2025-03-23 18:19:34 +02:00
Mihai Fufezan
006bd9eef5
protocols/meson.build: use native wayland-scanner 2025-03-23 18:15:17 +02:00
724 changed files with 68091 additions and 38458 deletions

View file

@ -1,4 +1,111 @@
WarningsAsErrors: '*' WarningsAsErrors: >
-*,
bugprone-*,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-empty-catch,
-bugprone-unused-return-value,
-bugprone-reserved-identifier,
-bugprone-switch-missing-default-case,
-bugprone-unused-local-non-trivial-variable,
-bugprone-easily-swappable-parameters,
-bugprone-forward-declararion-namespace,
-bugprone-forward-declararion-namespace,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-branch-clone,
-bugprone-assignment-in-if-condition,
concurrency-*,
-concurrency-mt-unsafe,
cppcoreguidelines-*,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-explicit-virtual-functions,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-global-names-in-headers,
-google-readability-casting,
google-runtime-operator,
misc-*,
-misc-use-internal-linkage,
-misc-unused-parameters,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
-misc-const-correctness,
modernize-*,
-modernize-use-emplace,
-modernize-redundant-void-arg,
-modernize-use-starts-ends-with,
-modernize-use-designated-initializers,
-modernize-use-std-numbers,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-modernize-use-using,
-modernize-use-override,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-loop-convert,
-modernize-use-nodiscard,
-modernize-pass-by-value,
-modernize-use-auto,
performance-*,
-performance-inefficient-vector-operation,
-performance-inefficient-string-concatenation,
-performance-enum-size,
-performance-move-const-arg,
-performance-avoid-endl,
-performance-unnecessary-value-param,
portability-std-allocator-const,
readability-*,
-readability-identifier-naming,
-readability-use-std-min-max,
-readability-math-missing-parentheses,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
-readability-use-anyofallof,
-readability-enum-initial-value,
-readability-redundant-inline-specifier,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-readability-braces-around-statements,
-readability-redundant-access-specifiers,
-readability-else-after-return,
-readability-container-data-pointer,
-readability-implicit-bool-conversion,
-readability-avoid-nested-conditional-operator,
-readability-redundant-member-init,
-readability-redundant-string-init,
-readability-avoid-const-params-in-decls,
-readability-named-parameter,
-readability-convert-member-functions-to-static,
-readability-qualified-auto,
-readability-make-member-function-const,
-readability-isolate-declaration,
-readability-inconsistent-declaration-parameter-name,
-clang-diagnostic-error,
HeaderFilterRegex: '.*\.hpp' HeaderFilterRegex: '.*\.hpp'
FormatStyle: file FormatStyle: file
Checks: > Checks: >

View file

@ -1,117 +1,15 @@
name: Bug Report name: Do not open issues, go to discussions please!
description: Something is not working right description: Do not open an issue
labels: ["bug"]
body: body:
- type: checkboxes - type: checkboxes
attributes: attributes:
label: Already reported ? * label: Please close this issue.
description: Before opening a new bug report, please take a moment to search through the current open issues. If the same bug is already reported, don't open new issue - instead go upvote/comment on an existing one. description: Users cannot open issues. I want my issue to be closed.
options: options:
- label: I have searched the existing open and closed issues. - label: Yes, I want this issue to be closed.
required: true required: true
- type: dropdown
id: type
attributes:
label: Regression?
description: |
Regression means that something used to work but no longer does.
**BEFORE CONTINUING**, please check if this bug is a regression or not, and if it is, we need you to bisect with the help of the wiki: https://wiki.hyprland.org/Crashes-and-Bugs/#bisecting-an-issue
multiple: true
options:
- "Definitely a regression - something broke after update (requires bisect)"
- "Probably not a regression / I don't remember it happening before"
- "Not a regression - it's bug regarding new feature"
- "Not a regression - it's an old bug"
- "I don't know, I started using Hyprland only recently"
validations:
required: true
- type: textarea - type: textarea
id: ver id: body
attributes: attributes:
label: System Info and Hyprland Version label: Issue body
description: |
Paste the output of `hyprctl systeminfo` here. If you can't
launch Hyprland, paste the output of `Hyprland --systeminfo`.
value: "<details>
<summary>System/Version info</summary>
```
<Paste the output of the command here, without removing any formatting around this>
```
</details>"
validations:
required: true
- type: textarea
id: desc
attributes:
label: Description
description: "What went wrong?"
validations:
required: true
- type: textarea
id: repro
attributes:
label: How to reproduce
description: "How can someone else reproduce the issue?"
placeholder: |
1. ...
2. ...
3. ...
validations:
required: true
- type: markdown
attributes:
value: |
## Additional info section
In the section below you will be asked to upload some files.
When including text files (such as logs or config), please **always ATTACH** them, and not paste them directly.
This is important to avoid clutter, spam, and make the issues more readable.
Thanks for your understanding.
# The main reason to disallow pasting directly or in a dropdown, is to not clutter
# the issue with unnecessary keywords, making the github issue search useless.
- type: checkboxes
attributes:
label: Attach not paste
options:
- label: I understand that all text files must be *attached*, and not pasted directly. If not respected, this issue will likely get closed as spam
required: true
- type: markdown
attributes:
value: >-
Please be sure to upload the following files below if they are relevant to the issue:
- Logs can be found in $XDG_RUNTIME_DIR/hypr (sort by date to grab the latest)
- Crash reports are stored in ~/.cache/hyprland or $XDG_CACHE_HOME/hyprland
- Hyprland config files - `hyprctl systeminfo -c > /tmp/hyprland_config_dump.txt` use this command to dump full configuration to a single file.
- type: checkboxes
attributes:
label: Checklist of files to include below
options:
- label: Hyprland config - `hyprctl systeminfo -c` (always include)
- label: Crash report (always include in case of crash)
- label: Video (always include in case of a visual bug)
- label: Logs (might contain useful info such as errors)
- type: textarea
id: logs
attributes:
label: Additional info & File uploads
description: |
Tip: You can attach files by clicking this area to highlight it and then dragging files in.

View file

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

View file

@ -20,9 +20,11 @@ runs:
clang \ clang \
cmake \ cmake \
git \ git \
glaze \
glm \ glm \
glslang \ glslang \
go \ go \
gtest \
hyprlang \ hyprlang \
hyprcursor \ hyprcursor \
jq \ jq \
@ -44,6 +46,7 @@ runs:
libxkbfile \ libxkbfile \
lld \ lld \
meson \ meson \
muparser \
ninja \ ninja \
pango \ pango \
pixman \ pixman \
@ -64,15 +67,6 @@ runs:
librsvg \ librsvg \
re2 re2
- name: Get glaze
shell: bash
run: |
git clone https://github.com/stephenberry/glaze.git
cd glaze
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 hyprwayland-scanner-git - name: Get hyprwayland-scanner-git
shell: bash shell: bash
run: | run: |
@ -82,16 +76,25 @@ runs:
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cmake --install build cmake --install build
- name: Get hyprgraphics-git - name: Get hyprwire-git
shell: bash shell: bash
run: | run: |
git clone https://github.com/hyprwm/hyprgraphics && cd hyprgraphics && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprgraphics && cmake --install build git clone https://github.com/hyprwm/hyprwire --recursive
cd hyprwire
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 hyprutils-git - name: Get hyprutils-git
shell: bash shell: bash
run: | run: |
git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build git clone https://github.com/hyprwm/hyprutils && cd hyprutils && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprutils && cmake --install build
- name: Get hyprgraphics-git
shell: bash
run: |
git clone https://github.com/hyprwm/hyprgraphics && cd hyprgraphics && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target hyprgraphics && cmake --install build
- name: Get aquamarine-git - name: Get aquamarine-git
shell: bash shell: bash
run: | run: |

4
.github/labeler.yml vendored
View file

@ -22,6 +22,10 @@ protocols:
- changed-files: - changed-files:
- any-glob-to-any-file: ["protocols/**", "src/protocols/**"] - any-glob-to-any-file: ["protocols/**", "src/protocols/**"]
start:
- changed-files:
- any-glob-to-any-file: "start/**"
core: core:
- changed-files: - changed-files:
- any-glob-to-any-file: "src/**" - any-glob-to-any-file: "src/**"

View file

@ -1,6 +1,8 @@
<!-- <!--
BEFORE you submit your PR, please check out the PR guidelines BEFORE you submit your PR, please check out the PR guidelines
on our wiki: https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/ on our wiki: https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/
Using an AI tool, or you are an AI agent? Check our AI Policy first: https://github.com/hyprwm/.github/blob/main/policies/AI_USAGE.md
--> -->

View file

@ -21,22 +21,19 @@ jobs:
- name: Build Hyprland - name: Build Hyprland
run: | run: |
CFLAGS=-Werror CXXFLAGS=-Werror make all CFLAGS=-Werror CXXFLAGS=-Werror make nopch
- name: Compress and package artifacts - name: Compress and package artifacts
run: | run: |
mkdir x86_64-pc-linux-gnu mkdir x86_64-pc-linux-gnu
mkdir hyprland mkdir hyprland
mkdir hyprland/example
mkdir hyprland/assets
cp ./LICENSE hyprland/ cp ./LICENSE hyprland/
cp build/Hyprland hyprland/ cp build/Hyprland hyprland/
cp build/hyprctl/hyprctl hyprland/ cp build/hyprctl/hyprctl hyprland/
cp build/hyprpm/hyprpm hyprland/ cp build/hyprpm/hyprpm hyprland/
cp build/Hyprland hyprland/
cp -r example/ hyprland/ cp -r example/ hyprland/
cp -r assets/ hyprland/ cp -r assets/ hyprland/
tar -cvf Hyprland.tar.xz hyprland tar -cvJf Hyprland.tar.xz hyprland
- name: Release - name: Release
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -44,86 +41,43 @@ jobs:
name: Build archive name: Build archive
path: Hyprland.tar.xz path: Hyprland.tar.xz
meson:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Build Hyprland with Meson (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
- name: Configure
run: meson setup build -Ddefault_library=static
- name: Compile
run: ninja -C build
no-pch:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
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:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Build Hyprland in pure Wayland (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
- name: Configure
run: mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DNO_XWAYLAND:STRING=true -H./ -B./build -G Ninja
- name: Compile
run: make release
clang-format: clang-format:
permissions: read-all permissions: read-all
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Code Style (Arch)" name: "Code Style"
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: archlinux image: archlinux
steps: steps:
- name: Checkout repository actions - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Setup base # - name: clang-format check
uses: ./.github/actions/setup_base # uses: jidicula/clang-format-action@v4.16.0
# with:
# exclude-regex: ^subprojects$
- name: Configure - name: Install clang-format
run: meson setup build -Ddefault_library=static run: |
pacman --noconfirm --noprogressbar -Syyu
pacman --noconfirm --noprogressbar -Sy clang
- name: clang-format check - name: clang-format check
run: ninja -C build clang-format-check run: .github/workflows/clang-format-check.sh "." "llvm" "^subprojects$" ""
- name: Save PR head commit SHA
if: failure() && github.event_name == 'pull_request'
shell: bash
run: |
SHA="${{ github.event.pull_request.head.sha }}"
echo "SHA=$SHA" >> $GITHUB_ENV
- name: Save latest commit SHA if not PR
if: failure() && github.event_name != 'pull_request'
shell: bash
run: echo "SHA=${{ github.sha }}" >> $GITHUB_ENV
- name: Report failure in job summary
if: failure()
run: |
DEEPLINK="${{ github.server_url }}/${{ github.repository }}/commit/${{ env.SHA }}"
echo -e "Format check failed on commit [${GITHUB_SHA:0:8}]($DEEPLINK) with files:\n$(<$GITHUB_WORKSPACE/failing-files.txt)" >> $GITHUB_STEP_SUMMARY

92
.github/workflows/clang-format-check.sh vendored Executable file
View file

@ -0,0 +1,92 @@
#!/usr/bin/env bash
#
# Adapted from https://github.com/jidicula/clang-format-action
###############################################################################
# check.sh #
###############################################################################
# USAGE: ./entrypoint.sh [<path>] [<fallback style>]
#
# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c,
# .C, .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path
# (arg1) for conforming to clang-format. If no path is provided or provided path
# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files
# are incorrectly formatted, the script lists them and exits with 1.
#
# Define your own formatting rules in a .clang-format file at your repository
# root. Otherwise, the provided style guide (arg2) is used as a fallback.
# format_diff function
# Accepts a filepath argument. The filepath passed to this function must point
# to a C/C++/Protobuf/CUDA file.
format_diff() {
local filepath="$1"
# Invoke clang-format with dry run and formatting error output
local_format="$(clang-format \
--dry-run \
--Werror \
--style=file \
--fallback-style="$FALLBACK_STYLE" \
"${filepath}")"
local format_status="$?"
if [[ ${format_status} -ne 0 ]]; then
# Append Markdown-bulleted monospaced filepath of failing file to
# summary file.
echo "* \`$filepath\`" >>failing-files.txt
echo "Failed on file: $filepath" >&2
echo "$local_format" >&2
exit_code=1 # flip the global exit code
return "${format_status}"
fi
return 0
}
CHECK_PATH="$1"
FALLBACK_STYLE="$2"
EXCLUDE_REGEX="$3"
INCLUDE_REGEX="$4"
# Set the regex to an empty string regex if nothing was provided
if [[ -z $EXCLUDE_REGEX ]]; then
EXCLUDE_REGEX="^$"
fi
# Set the filetype regex if nothing was provided.
# Find all C/C++/Protobuf/CUDA files:
# h, H, hpp, hh, h++, hxx
# c, C, cpp, cc, c++, cxx
# ino, pde
# proto
# cu
if [[ -z $INCLUDE_REGEX ]]; then
INCLUDE_REGEX='^.*\.((((c|C)(c|pp|xx|\+\+)?$)|((h|H)h?(pp|xx|\+\+)?$))|(ino|pde|proto|cu))$'
fi
cd "$GITHUB_WORKSPACE" || exit 2
if [[ ! -d $CHECK_PATH ]]; then
echo "Not a directory in the workspace, fallback to all files." >&2
CHECK_PATH="."
fi
# initialize exit code
exit_code=0
# All files improperly formatted will be printed to the output.
src_files=$(find "$CHECK_PATH" -name .git -prune -o -regextype posix-egrep -regex "$INCLUDE_REGEX" -print)
# check formatting in each source file
IFS=$'\n' # Loop below should separate on new lines, not spaces.
for file in $src_files; do
# Only check formatting if the path doesn't match the regex
if ! [[ ${file} =~ $EXCLUDE_REGEX ]]; then
format_diff "${file}"
fi
done
# global exit code is flipped to nonzero if any invocation of `format_diff` has
# a formatting difference.
exit "$exit_code"

View file

@ -4,43 +4,23 @@ jobs:
clang-format: clang-format:
permissions: write-all permissions: write-all
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Code Style (Arch)" name: "Code Style"
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: archlinux
steps: steps:
- name: Checkout repository actions - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: Setup base
uses: ./.github/actions/setup_base
- name: Configure
run: meson setup build -Ddefault_library=static
- name: clang-format check - name: clang-format check
run: ninja -C build clang-format-check uses: jidicula/clang-format-action@v4.16.0
with:
exclude-regex: ^subprojects$
- name: clang-format apply - name: Create comment
if: ${{ failure() && github.event_name == 'pull_request' }}
run: ninja -C build clang-format
- name: Create patch
if: ${{ failure() && github.event_name == 'pull_request' }} if: ${{ failure() && github.event_name == 'pull_request' }}
run: | run: |
echo 'Please fix the formatting issues by running [`clang-format`](https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/#code-style), or directly apply this patch:' > clang-format.patch echo 'Please fix the formatting issues by running [`clang-format`](https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/#code-style).' > clang-format.patch
echo '<details>' >> clang-format.patch
echo '<summary>clang-format.patch</summary>' >> clang-format.patch
echo >> clang-format.patch
echo '```diff' >> clang-format.patch
git diff >> clang-format.patch
echo '```' >> clang-format.patch
echo >> clang-format.patch
echo '</details>' >> clang-format.patch
- name: Comment patch - name: Post comment
if: ${{ failure() && github.event_name == 'pull_request' }} if: ${{ failure() && github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v2 uses: mshick/add-pr-comment@v2
with: with:

101
.github/workflows/close-issues.yml vendored Normal file
View file

@ -0,0 +1,101 @@
name: Close Unauthorized Issues
on:
workflow_dispatch:
issues:
types: [opened]
jobs:
close-unauthorized-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
# XXX: This *could* be done in Bash by abusing GitHub's own tool to interact with its API
# but that's too much of a hack, and we'll be adding a layer of abstraction. github-script
# is a workflow that eases interaction with GitHub API in the workflow run context.
- name: "Close 'unauthorized' issues"
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const ALLOWED_USERS = ['vaxerski', 'fufexan', 'NotAShelf'];
const CLOSING_COMMENT = 'Users are no longer allowed to open issues themselves, please open a discussion instead.\n\nPlease see the [wiki](https://wiki.hyprland.org/Contributing-and-Debugging/Issue-Guidelines/) on why this is the case.\n\nWe are volunteers, and we need your cooperation to make the best software we can. Thank you for understanding! ❤️\n\n[Open a discussion here](https://github.com/hyprwm/Hyprland/discussions)';
async function closeUnauthorizedIssue(issueNumber, userName) {
if (ALLOWED_USERS.includes(userName)) {
console.log(`Issue #${issueNumber} - Created by authorized user ${userName}`);
return;
}
console.log(`Issue #${issueNumber} - Unauthorized, closing`);
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
state: 'closed',
state_reason: 'not_planned'
});
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: CLOSING_COMMENT
});
}
if (context.eventName === 'issues' && context.payload.action === 'opened') {
// Direct access to the issue that triggered the workflow
const issue = context.payload.issue;
// Skip if this is a PR
if (issue.pull_request) {
console.log(`Issue #${issue.number} - Skipping, this is a pull request`);
return;
}
// Process the single issue that triggered the workflow
await closeUnauthorizedIssue(issue.number, issue.user.login);
} else {
// For manual runs, we need to handle pagination
async function* fetchAllOpenIssues() {
let page = 1;
let hasNextPage = true;
while (hasNextPage) {
const response = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
page: page
});
if (response.data.length === 0) {
hasNextPage = false;
} else {
for (const issue of response.data) {
yield issue;
}
page++;
}
}
}
// Process issues one by one
for await (const issue of fetchAllOpenIssues()) {
try {
// Skip pull requests
if (issue.pull_request) {
console.log(`Issue #${issue.number} - Skipping, this is a pull request`);
continue;
}
await closeUnauthorizedIssue(issue.number, issue.user.login);
} catch (error) {
console.error(`Error processing issue #${issue.number}: ${error.message}`);
}
}
}

45
.github/workflows/new-pr-comment.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: "New MR welcome comment"
on:
pull_request_target:
types:
- opened
jobs:
comment:
if: >
github.event.pull_request.user.login != 'vaxerski' &&
github.event.pull_request.user.login != 'fufexan' &&
github.event.pull_request.user.login != 'gulafaran' &&
github.event.pull_request.user.login != 'ujint34' &&
github.event.pull_request.user.login != 'paideiadilemma' &&
github.event.pull_request.user.login != 'notashelf'
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
PR_COMMENT: |
Hello and thank you for making a PR to Hyprland!
Please check the [PR Guidelines](https://wiki.hypr.land/Contributing-and-Debugging/PR-Guidelines/) and make sure your PR follows them.
It will make the entire review process faster. :)
If your code can be tested, please always add tests. See more [here](https://wiki.hypr.land/Contributing-and-Debugging/Tests/).
_beep boop, I'm just a bot. A real human will review your PR soon._
steps:
- name: Add comment to PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: process.env.PR_COMMENT,
});

View file

@ -1,28 +0,0 @@
name: Nix (Build)
on:
workflow_call:
secrets:
CACHIX_AUTH_TOKEN:
required: false
jobs:
build:
strategy:
matrix:
package:
- hyprland
# - hyprland-cross # cross compiling fails due to qt
# failure chain: hyprland-qtutils -> qt6.qtsvg -> qt6.qtbase -> psqlodbc & qt6.qttranslations
- xdg-desktop-portal-hyprland
runs-on: ubuntu-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: cachix/cachix-action@v15
with:
name: hyprland
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- run: nix build 'github:hyprwm/Hyprland?ref=${{ github.ref }}#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"

View file

@ -1,4 +1,4 @@
name: Nix (CI) name: Nix
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
@ -8,7 +8,22 @@ jobs:
uses: ./.github/workflows/nix-update-inputs.yml uses: ./.github/workflows/nix-update-inputs.yml
secrets: inherit secrets: inherit
build: hyprland:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
uses: ./.github/workflows/nix-build.yml uses: ./.github/workflows/nix.yml
secrets: inherit
with:
command: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}' -L --extra-substituters "https://hyprland.cachix.org"
xdph:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
needs: hyprland
uses: ./.github/workflows/nix.yml
secrets: inherit
with:
command: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}#xdg-desktop-portal-hyprland' -L --extra-substituters "https://hyprland.cachix.org"
test:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
uses: ./.github/workflows/nix-test.yml
secrets: inherit secrets: inherit

47
.github/workflows/nix-test.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: Nix (Test)
on:
workflow_call:
secrets:
CACHIX_AUTH_TOKEN:
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v31
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key (per job)
primary-key: nix-${{ runner.os }}-${{ github.job }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 5G
- uses: cachix/cachix-action@v15
with:
name: hyprland
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Run test VM
run: nix build 'github:${{ github.repository }}?ref=${{ github.ref }}#checks.x86_64-linux.tests' -L --extra-substituters "https://hyprland.cachix.org"
- name: Check exit status
run: grep 0 result/exit_status
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: result

View file

@ -17,7 +17,24 @@ jobs:
with: with:
token: ${{ secrets.PAT }} token: ${{ secrets.PAT }}
- uses: DeterminateSystems/nix-installer-action@main - name: Install Nix
uses: nixbuild/nix-quick-install-action@v31
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key (per job)
primary-key: nix-${{ runner.os }}-${{ github.job }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 5G
- name: Update inputs - name: Update inputs
run: nix/update-inputs.sh run: nix/update-inputs.sh

41
.github/workflows/nix.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: Build
on:
workflow_call:
inputs:
command:
required: true
type: string
description: Command to run
secrets:
CACHIX_AUTH_TOKEN:
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v31
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key (per job)
primary-key: nix-${{ runner.os }}-${{ github.job }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
gc-max-store-size-linux: 5G
- uses: cachix/cachix-action@v15
with:
name: hyprland
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- run: ${{ inputs.command }}

View file

@ -9,17 +9,36 @@ jobs:
source-tarball: source-tarball:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Hyprland - name: Checkout repository
id: checkout uses: actions/checkout@v5
uses: actions/checkout@v4
with: with:
fetch-depth: 0
submodules: recursive submodules: recursive
- name: Generate version - name: Populate git info in version.h.in
id: genversion
run: | run: |
git fetch --unshallow || echo "failed unshallowing" git fetch --tags --unshallow || true
bash -c scripts/generateVersion.sh
COMMIT_HASH=$(git rev-parse HEAD)
BRANCH="${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}"
COMMIT_MSG=$(git show -s --format=%s | sed 's/[&/]/\\&/g')
COMMIT_DATE=$(git show -s --format=%cd --date=local)
GIT_DIRTY=$(git diff-index --quiet HEAD -- && echo "clean" || echo "dirty")
GIT_TAG=$(git describe --tags --always || echo "unknown")
GIT_COMMITS=$(git rev-list --count HEAD)
echo "Branch: $BRANCH"
echo "Tag: $GIT_TAG"
sed -i \
-e "s|@GIT_COMMIT_HASH@|$COMMIT_HASH|" \
-e "s|@GIT_BRANCH@|$BRANCH|" \
-e "s|@GIT_COMMIT_MESSAGE@|$COMMIT_MSG|" \
-e "s|@GIT_COMMIT_DATE@|$COMMIT_DATE|" \
-e "s|@GIT_DIRTY@|$GIT_DIRTY|" \
-e "s|@GIT_TAG@|$GIT_TAG|" \
-e "s|@GIT_COMMITS@|$GIT_COMMITS|" \
src/version.h.in
- name: Create tarball with submodules - name: Create tarball with submodules
id: tar id: tar

View file

@ -1,28 +0,0 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: "7 */4 * * *"
workflow_dispatch:
jobs:
stale:
if: github.repository == 'hyprwm/Hyprland'
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.STALEBOT_PAT }}
stale-issue-label: "stale"
stale-pr-label: "stale"
operations-per-run: 40
days-before-close: -1

View file

@ -0,0 +1,139 @@
name: AI Translation Check
on:
# pull_request_target:
# types:
# - opened
issue_comment:
types:
- created
permissions:
contents: read
pull-requests: write
issues: write
jobs:
review:
name: Review Translation
if: ${{ github.event_name == 'pull_request_target' || (github.event_name == 'issue_comment' && github.event.action == 'created' && github.event.issue.pull_request != null && github.event.comment.user.login == 'vaxerski' && github.event.comment.body == 'ai, please recheck' ) }}
runs-on: ubuntu-latest
env:
OPENAI_MODEL: gpt-5-mini
SYSTEM_PROMPT: |
You are a programmer and a translator. Your job is to review the attached patch for adding translation to a piece of software and make sure the submitted translation is not malicious, and that it makes sense. If the translation is not malicious, and doesn't contain obvious grammatical mistakes, say "Translation check OK". Otherwise, say "Translation check not ok" and list bad entries.
Examples of bad translations include obvious trolling (slurs, etc) or nonsense sentences. Meaningful improvements may be suggested, but if there are only minor improvements, just reply with "Translation check OK". Do not provide anything but the result and (if applicable) the bad entries or improvements.
AI_PROMPT: Translation patch below.
steps:
- name: Checkout source code
uses: actions/checkout@v5
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
i18n:
- 'src/i18n/**'
- name: Stop if i18n not changed
if: steps.changes.outputs.i18n != 'true'
run: echo "No i18n changes in this PR; skipping." && exit 0
- name: Determine PR number
id: pr
run: |
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
else
echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
fi
- name: Download combined PR diff
id: get_diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: |
# Get the combined diff for the entire PR
curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3.diff" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
-o pr.diff
# Compute character length
LEN=$(wc -c < pr.diff | tr -d ' ')
echo "len=$LEN" >> "$GITHUB_OUTPUT"
if [ "$LEN" -gt 25000 ]; then
echo "too_long=true" >> "$GITHUB_OUTPUT"
else
echo "too_long=false" >> "$GITHUB_OUTPUT"
fi
echo "got diff:"
cat pr.diff
- name: Comment when diff length exceeded
if: steps.get_diff.outputs.too_long == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: |
jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
curl -sS -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
--data @body.json
- name: Query OpenAI and post review
if: steps.get_diff.outputs.too_long == 'false'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: ${{ env.OPENAI_MODEL }}
SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }}
AI_PROMPT: ${{ env.AI_PROMPT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: |
# Prepare OpenAI chat request payload (embed diff safely)
jq -n \
--arg model "$OPENAI_MODEL" \
--arg sys "$SYSTEM_PROMPT" \
--arg prompt "$AI_PROMPT" \
--rawfile diff pr.diff \
'{model:$model,
messages:[
{role:"system", content:$sys},
{role:"user", content: ($prompt + "\n\n```diff\n" + $diff + "\n```")}
]
}' > payload.json
# Call OpenAI
curl -sS https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d @payload.json > response.json
# Extract response text
COMMENT=$(jq -r '.choices[0].message.content // empty' response.json)
if [ -z "$COMMENT" ]; then
COMMENT="AI did not return a response."
fi
# If failed, add a note
ADDITIONAL_NOTE=""
if [[ "$COMMENT" == *"not ok"* ]]; then
ADDITIONAL_NOTE=$(echo -ne "\n\nPlease note this check is a guideline, not a hard requirement. It is here to help you translate. If you disagree with some points, just state that. Any typos should be fixed.")
fi
# Post the review as a PR comment
jq -n --arg body "$COMMENT" --arg note "$ADDITIONAL_NOTE" '{body: ("AI translation check result:\n\n" + $body + $note)}' > body.json
echo "CURLing https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
curl -sS -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
--data @body.json

5
.gitignore vendored
View file

@ -28,8 +28,12 @@ protocols/*.c*
protocols/*.h* protocols/*.h*
.ccls-cache .ccls-cache
*.so *.so
src/render/shaders/*.inc
src/render/shaders/Shaders.hpp
hyprctl/hyprctl hyprctl/hyprctl
hyprctl/hw-protocols/*.c*
hyprctl/hw-protocols/*.h*
gmon.out gmon.out
*.out *.out
@ -40,6 +44,7 @@ PKGBUILD
src/version.h src/version.h
hyprpm/Makefile hyprpm/Makefile
hyprctl/Makefile hyprctl/Makefile
example/hyprland.desktop
**/.#*.* **/.#*.*
**/#*.*# **/#*.*#

View file

@ -9,6 +9,7 @@ project(
DESCRIPTION "A Modern C++ Wayland Compositor" DESCRIPTION "A Modern C++ Wayland Compositor"
VERSION ${VER}) VERSION ${VER})
include(CTest)
include(CheckIncludeFile) include(CheckIncludeFile)
include(GNUInstallDirs) include(GNUInstallDirs)
@ -16,15 +17,21 @@ set(HYPRLAND_VERSION ${VER})
set(PREFIX ${CMAKE_INSTALL_PREFIX}) set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(BINDIR ${CMAKE_INSTALL_BINDIR}) set(BINDIR ${CMAKE_INSTALL_BINDIR})
configure_file(hyprland.pc.in hyprland.pc @ONLY)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
message(STATUS "Gathering git info") message(STATUS "Gathering git info")
# Get git info hash and branch # Make shader files includable
execute_process(COMMAND ./scripts/generateVersion.sh execute_process(COMMAND ./scripts/generateShaderIncludes.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE HYPR_SHADER_GEN_RESULT)
if(NOT HYPR_SHADER_GEN_RESULT EQUAL 0)
message(
FATAL_ERROR
"Failed to generate shader includes (scripts/generateShaderIncludes.sh), exit code: ${HYPR_SHADER_GEN_RESULT}"
)
endif()
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
@ -32,11 +39,23 @@ find_package(PkgConfig REQUIRED)
# provide a .pc file and won't be detected this way # provide a .pc file and won't be detected this way
pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2) pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2)
# Fallback to subproject # Find non-pkgconfig udis86, otherwise fallback to subproject
if(NOT udis_dep_FOUND) if(NOT udis_dep_FOUND)
add_subdirectory("subprojects/udis86") find_library(udis_nopc udis86)
include_directories("subprojects/udis86") if(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND"))
message(STATUS "udis86 dependency not found, falling back to subproject") message(STATUS "Found udis86 at ${udis_nopc}")
else()
add_subdirectory("subprojects/udis86")
include_directories("subprojects/udis86")
message(STATUS "udis86 dependency not found, falling back to subproject")
endif()
endif()
find_library(librt rt)
if("${librt}" MATCHES "librt-NOTFOUND")
unset(LIBRT)
else()
set(LIBRT rt)
endif() endif()
if(CMAKE_BUILD_TYPE) if(CMAKE_BUILD_TYPE)
@ -67,9 +86,11 @@ message(
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake") message(STATUS "Configuring Hyprland in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG) add_compile_definitions(HYPRLAND_DEBUG)
set(BUILD_TESTING ON)
else() else()
add_compile_options(-O3) add_compile_options(-O3)
message(STATUS "Configuring Hyprland in Release with CMake") message(STATUS "Configuring Hyprland in Release with CMake")
set(BUILD_TESTING OFF)
endif() endif()
add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}") add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
@ -81,13 +102,20 @@ set(CXX_STANDARD_REQUIRED ON)
add_compile_options( add_compile_options(
-Wall -Wall
-Wextra -Wextra
-Wpedantic
-Wno-unused-parameter -Wno-unused-parameter
-Wno-unused-value -Wno-unused-value
-Wno-missing-field-initializers -Wno-missing-field-initializers
-Wno-gnu-zero-variadic-macro-arguments
-Wno-narrowing -Wno-narrowing
-Wno-pointer-arith -Wno-pointer-arith
-Wno-clobbered
-frtti
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=) -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
# disable lto as it may break plugins
add_compile_options(-fno-lto)
set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE) set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
@ -95,55 +123,158 @@ message(STATUS "Checking deps...")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if(LEGACY_RENDERER) set(GLES_VERSION "GLES3")
set(GLES_VERSION "GLES2")
else()
set(GLES_VERSION "GLES3")
endif()
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION}) find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
find_package(glslang CONFIG REQUIRED)
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=0.8.0) set(AQUAMARINE_MINIMUM_VERSION 0.9.3)
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=0.3.2) set(HYPRLANG_MINIMUM_VERSION 0.6.7)
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=0.1.7) set(HYPRCURSOR_MINIMUM_VERSION 0.1.7)
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.5.1) set(HYPRUTILS_MINIMUM_VERSION 0.11.0)
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=0.1.1) set(HYPRGRAPHICS_MINIMUM_VERSION 0.1.6)
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=${AQUAMARINE_MINIMUM_VERSION})
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=${HYPRLANG_MINIMUM_VERSION})
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=${HYPRCURSOR_MINIMUM_VERSION})
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=${HYPRUTILS_MINIMUM_VERSION})
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=${HYPRGRAPHICS_MINIMUM_VERSION})
string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION}) string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION})
list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR) list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR)
list(GET AQ_VERSION_LIST 1 AQ_VERSION_MINOR) list(GET AQ_VERSION_LIST 1 AQ_VERSION_MINOR)
list(GET AQ_VERSION_LIST 2 AQ_VERSION_PATCH) list(GET AQ_VERSION_LIST 2 AQ_VERSION_PATCH)
add_compile_definitions(AQUAMARINE_VERSION="${aquamarine_dep_VERSION}") set(AQUAMARINE_VERSION "${aquamarine_dep_VERSION}")
add_compile_definitions(AQUAMARINE_VERSION_MAJOR=${AQ_VERSION_MAJOR}) set(AQUAMARINE_VERSION_MAJOR "${AQ_VERSION_MAJOR}")
add_compile_definitions(AQUAMARINE_VERSION_MINOR=${AQ_VERSION_MINOR}) set(AQUAMARINE_VERSION_MINOR "${AQ_VERSION_MINOR}")
add_compile_definitions(AQUAMARINE_VERSION_PATCH=${AQ_VERSION_PATCH}) set(AQUAMARINE_VERSION_PATCH "${AQ_VERSION_PATCH}")
add_compile_definitions(HYPRLANG_VERSION="${hyprlang_dep_VERSION}") set(HYPRLANG_VERSION "${hyprlang_dep_VERSION}")
add_compile_definitions(HYPRUTILS_VERSION="${hyprutils_dep_VERSION}") set(HYPRUTILS_VERSION "${hyprutils_dep_VERSION}")
add_compile_definitions(HYPRCURSOR_VERSION="${hyprcursor_dep_VERSION}") set(HYPRCURSOR_VERSION "${hyprcursor_dep_VERSION}")
add_compile_definitions(HYPRGRAPHICS_VERSION="${hyprgraphics_dep_VERSION}") set(HYPRGRAPHICS_VERSION "${hyprgraphics_dep_VERSION}")
find_package(Git QUIET)
# Populate variables with env vars if present
set(GIT_COMMIT_HASH "$ENV{GIT_COMMIT_HASH}")
if(NOT GIT_COMMIT_HASH)
set(GIT_COMMIT_HASH "unknown")
endif()
set(GIT_BRANCH "$ENV{GIT_BRANCH}")
if(NOT GIT_BRANCH)
set(GIT_BRANCH "unknown")
endif()
set(GIT_COMMIT_MESSAGE "$ENV{GIT_COMMIT_MESSAGE}")
if(NOT GIT_COMMIT_MESSAGE)
set(GIT_COMMIT_MESSAGE "unknown")
endif()
set(GIT_COMMIT_DATE "$ENV{GIT_COMMIT_DATE}")
if(NOT GIT_COMMIT_DATE)
set(GIT_COMMIT_DATE "unknown")
endif()
set(GIT_DIRTY "$ENV{GIT_DIRTY}")
if(NOT GIT_DIRTY)
set(GIT_DIRTY "unknown")
endif()
set(GIT_TAG "$ENV{GIT_TAG}")
if(NOT GIT_TAG)
set(GIT_TAG "unknown")
endif()
set(GIT_COMMITS "$ENV{GIT_COMMITS}")
if(NOT GIT_COMMITS)
set(GIT_COMMITS "0")
endif()
if(Git_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TOPLEVEL
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE GIT_TOPLEVEL_RESULT
)
if(GIT_TOPLEVEL_RESULT EQUAL 0)
message(STATUS "Detected git repository root: ${GIT_TOPLEVEL}")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} branch --show-current
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND sh "-c" "${GIT_EXECUTABLE} show -s --format=%s --no-show-signature | sed \"s/\\\"/\'/g\""
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%cd --date=local --no-show-signature
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD --
WORKING_DIRECTORY ${GIT_TOPLEVEL}
RESULT_VARIABLE GIT_DIRTY_RESULT)
if(NOT GIT_DIRTY_RESULT EQUAL 0)
set(GIT_DIRTY "dirty")
else()
set(GIT_DIRTY "clean")
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
WORKING_DIRECTORY ${GIT_TOPLEVEL}
OUTPUT_VARIABLE GIT_COMMITS OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
message(WARNING "No Git repository detected in ${CMAKE_SOURCE_DIR}")
endif()
endif()
configure_file(
${CMAKE_SOURCE_DIR}/src/version.h.in
${CMAKE_SOURCE_DIR}/src/version.h
@ONLY
)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERATED TRUE)
set(XKBCOMMON_MINIMUM_VERSION 1.11.0)
set(WAYLAND_SERVER_MINIMUM_VERSION 1.22.91)
set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.45)
set(LIBINPUT_MINIMUM_VERSION 1.28)
pkg_check_modules( pkg_check_modules(
deps deps
REQUIRED REQUIRED
IMPORTED_TARGET IMPORTED_TARGET GLOBAL
xkbcommon xkbcommon>=${XKBCOMMON_MINIMUM_VERSION}
uuid uuid
wayland-server>=1.22.90 wayland-server>=${WAYLAND_SERVER_MINIMUM_VERSION}
wayland-protocols>=1.41 wayland-protocols>=${WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION}
cairo cairo
pango pango
pangocairo pangocairo
pixman-1 pixman-1
xcursor xcursor
libdrm libdrm
libinput libinput>=${LIBINPUT_MINIMUM_VERSION}
gbm gbm
gio-2.0 gio-2.0
re2) re2
muparser
lcms2)
find_package(hyprwayland-scanner 0.3.10 REQUIRED) find_package(hyprwayland-scanner 0.3.10 REQUIRED)
file(GLOB_RECURSE SRCFILES "src/*.cpp") file(GLOB_RECURSE SRCFILES "src/*.cpp")
get_filename_component(FULL_MAIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE)
list(REMOVE_ITEM SRCFILES "${FULL_MAIN_PATH}")
set(TRACY_CPP_FILES "") set(TRACY_CPP_FILES "")
if(USE_TRACY) if(USE_TRACY)
@ -151,9 +282,14 @@ if(USE_TRACY)
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES}) message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
endif() endif()
add_executable(Hyprland ${SRCFILES} ${TRACY_CPP_FILES}) add_library(hyprland_lib STATIC ${SRCFILES})
add_executable(Hyprland src/main.cpp ${TRACY_CPP_FILES})
target_link_libraries(Hyprland hyprland_lib)
set(USE_GPROF ON) target_include_directories(hyprland_lib PUBLIC ${deps_INCLUDE_DIRS})
target_include_directories(Hyprland PUBLIC ${deps_INCLUDE_DIRS})
set(USE_GPROF OFF)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Setting debug flags") message(STATUS "Setting debug flags")
@ -161,23 +297,8 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
if(WITH_ASAN) if(WITH_ASAN)
message(STATUS "Enabling ASan") message(STATUS "Enabling ASan")
target_link_libraries(Hyprland asan) target_link_libraries(hyprland_lib PUBLIC asan)
target_compile_options(Hyprland PUBLIC -fsanitize=address) target_compile_options(hyprland_lib PUBLIC -fsanitize=address)
endif()
if(USE_TRACY)
message(STATUS "Tracy is turned on")
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON)
add_subdirectory(subprojects/tracy)
target_link_libraries(Hyprland Tracy::TracyClient)
if(USE_TRACY_GPU)
message(STATUS "Tracy GPU Profiling is turned on")
add_compile_definitions(USE_TRACY_GPU)
endif()
endif() endif()
add_compile_options(-fno-pie -fno-builtin) add_compile_options(-fno-pie -fno-builtin)
@ -188,6 +309,27 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
endif() endif()
endif() endif()
if(USE_TRACY)
message(STATUS "Tracy is turned on")
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON)
add_subdirectory(subprojects/tracy)
add_compile_options(-fno-omit-frame-pointer)
target_link_libraries(hyprland_lib PUBLIC Tracy::TracyClient)
if(USE_TRACY_GPU)
message(STATUS "Tracy GPU Profiling is turned on")
add_compile_definitions(USE_TRACY_GPU)
endif()
endif()
if(BUILT_WITH_NIX)
add_compile_definitions(BUILT_WITH_NIX)
endif()
check_include_file("execinfo.h" EXECINFOH) check_include_file("execinfo.h" EXECINFOH)
if(EXECINFOH) if(EXECINFOH)
message(STATUS "Configuration supports execinfo") message(STATUS "Configuration supports execinfo")
@ -197,24 +339,19 @@ endif()
include(CheckLibraryExists) include(CheckLibraryExists)
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
if(HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO)
target_link_libraries(Hyprland execinfo) target_link_libraries(hyprland_lib PUBLIC execinfo)
endif() endif()
check_include_file("sys/timerfd.h" HAS_TIMERFD) check_include_file("sys/timerfd.h" HAS_TIMERFD)
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim) pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
if(NOT HAS_TIMERFD AND epoll_FOUND) if(NOT HAS_TIMERFD AND epoll_FOUND)
target_link_libraries(Hyprland PkgConfig::epoll) target_link_libraries(hyprland_lib PUBLIC PkgConfig::epoll)
endif() endif()
check_include_file("sys/inotify.h" HAS_INOTIFY) check_include_file("sys/inotify.h" HAS_INOTIFY)
pkg_check_modules(inotify IMPORTED_TARGET libinotify) pkg_check_modules(inotify IMPORTED_TARGET libinotify)
if(NOT HAS_INOTIFY AND inotify_FOUND) if(NOT HAS_INOTIFY AND inotify_FOUND)
target_link_libraries(Hyprland PkgConfig::inotify) target_link_libraries(hyprland_lib PUBLIC PkgConfig::inotify)
endif()
if(LEGACY_RENDERER)
message(STATUS "Using the legacy GLES2 renderer!")
add_compile_definitions(LEGACY_RENDERER)
endif() endif()
if(NO_XWAYLAND) if(NO_XWAYLAND)
@ -222,10 +359,7 @@ if(NO_XWAYLAND)
add_compile_definitions(NO_XWAYLAND) add_compile_definitions(NO_XWAYLAND)
else() else()
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...") message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
pkg_check_modules( set(XWAYLAND_DEPENDENCIES
xdeps
REQUIRED
IMPORTED_TARGET
xcb xcb
xcb-render xcb-render
xcb-xfixes xcb-xfixes
@ -233,9 +367,21 @@ else()
xcb-composite xcb-composite
xcb-res xcb-res
xcb-errors) xcb-errors)
target_link_libraries(Hyprland PkgConfig::xdeps)
pkg_check_modules(
xdeps
REQUIRED
IMPORTED_TARGET
${XWAYLAND_DEPENDENCIES})
string(JOIN ", " PKGCONFIG_XWAYLAND_DEPENDENCIES ${XWAYLAND_DEPENDENCIES})
string(PREPEND PKGCONFIG_XWAYLAND_DEPENDENCIES ", ")
target_link_libraries(hyprland_lib PUBLIC PkgConfig::xdeps)
endif() endif()
configure_file(hyprland.pc.in hyprland.pc @ONLY)
if(NO_SYSTEMD) if(NO_SYSTEMD)
message(STATUS "SYSTEMD support is disabled...") message(STATUS "SYSTEMD support is disabled...")
else() else()
@ -256,30 +402,42 @@ set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack) include(CPack)
message(STATUS "Setting precompiled headers") if(CMAKE_DISABLE_PRECOMPILE_HEADERS)
message(STATUS "Not using precompiled headers")
target_precompile_headers(Hyprland PRIVATE else()
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>) message(STATUS "Setting precompiled headers")
target_precompile_headers(hyprland_lib PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
endif()
message(STATUS "Setting link libraries") message(STATUS "Setting link libraries")
target_link_libraries( target_link_libraries(
Hyprland hyprland_lib
rt PUBLIC
PkgConfig::aquamarine_dep PkgConfig::aquamarine_dep
PkgConfig::hyprlang_dep PkgConfig::hyprlang_dep
PkgConfig::hyprutils_dep PkgConfig::hyprutils_dep
PkgConfig::hyprcursor_dep PkgConfig::hyprcursor_dep
PkgConfig::hyprgraphics_dep PkgConfig::hyprgraphics_dep
PkgConfig::deps) PkgConfig::deps
)
target_link_libraries(
Hyprland
${LIBRT}
hyprland_lib)
if(udis_dep_FOUND) if(udis_dep_FOUND)
target_link_libraries(Hyprland PkgConfig::udis_dep) target_link_libraries(hyprland_lib PUBLIC PkgConfig::udis_dep)
elseif(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND"))
target_link_libraries(hyprland_lib PUBLIC ${udis_nopc})
else() else()
target_link_libraries(Hyprland libudis86) target_link_libraries(hyprland_lib PUBLIC libudis86)
endif() endif()
# used by `make installheaders`, to ensure the headers are generated # used by `make installheaders`, to ensure the headers are generated
add_custom_target(generate-protocol-headers) add_custom_target(generate-protocol-headers)
set(PROTOCOL_SOURCES "")
function(protocolnew protoPath protoName external) function(protocolnew protoPath protoName external)
if(external) if(external)
@ -293,10 +451,15 @@ function(protocolnew protoPath protoName external)
COMMAND hyprwayland-scanner ${path}/${protoName}.xml COMMAND hyprwayland-scanner ${path}/${protoName}.xml
${CMAKE_SOURCE_DIR}/protocols/ ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp target_sources(hyprland_lib PRIVATE protocols/${protoName}.cpp
protocols/${protoName}.hpp) protocols/${protoName}.hpp)
target_sources(generate-protocol-headers target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp) PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
endfunction() endfunction()
function(protocolWayland) function(protocolWayland)
add_custom_command( add_custom_command(
@ -306,14 +469,23 @@ function(protocolWayland)
hyprwayland-scanner --wayland-enums hyprwayland-scanner --wayland-enums
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/ ${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp) target_sources(hyprland_lib PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(generate-protocol-headers target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp) PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.hpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.cpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
endfunction() endfunction()
target_link_libraries(Hyprland OpenGL::EGL OpenGL::GL Threads::Threads) if(TARGET OpenGL::GL)
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads)
else()
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GLES3 glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads)
endif()
pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.2) pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4)
if(hyprland_protocols_dep_FOUND) if(hyprland_protocols_dep_FOUND)
pkg_get_variable(HYPRLAND_PROTOCOLS hyprland-protocols pkgdatadir) pkg_get_variable(HYPRLAND_PROTOCOLS hyprland-protocols pkgdatadir)
message(STATUS "hyprland-protocols dependency set to ${HYPRLAND_PROTOCOLS}") message(STATUS "hyprland-protocols dependency set to ${HYPRLAND_PROTOCOLS}")
@ -339,12 +511,12 @@ protocolnew("protocols" "kde-server-decoration" true)
protocolnew("protocols" "wlr-data-control-unstable-v1" true) protocolnew("protocols" "wlr-data-control-unstable-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-focus-grab-v1" true) protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-focus-grab-v1" true)
protocolnew("protocols" "wlr-layer-shell-unstable-v1" true) protocolnew("protocols" "wlr-layer-shell-unstable-v1" true)
protocolnew("protocols" "xx-color-management-v4" true)
protocolnew("protocols" "frog-color-management-v1" true)
protocolnew("protocols" "wayland-drm" true) protocolnew("protocols" "wayland-drm" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-ctm-control-v1" true) protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-ctm-control-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-surface-v1" true) protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-surface-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-lock-notify-v1" true) protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-lock-notify-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-toplevel-mapping-v1"
true)
protocolnew("staging/tearing-control" "tearing-control-v1" false) protocolnew("staging/tearing-control" "tearing-control-v1" false)
protocolnew("staging/fractional-scale" "fractional-scale-v1" false) protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
@ -379,11 +551,21 @@ protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false)
protocolnew("staging/security-context" "security-context-v1" false) protocolnew("staging/security-context" "security-context-v1" false)
protocolnew("staging/content-type" "content-type-v1" false) protocolnew("staging/content-type" "content-type-v1" false)
protocolnew("staging/color-management" "color-management-v1" false) protocolnew("staging/color-management" "color-management-v1" false)
protocolnew("staging/xdg-toplevel-tag" "xdg-toplevel-tag-v1" false)
protocolnew("staging/xdg-system-bell" "xdg-system-bell-v1" false)
protocolnew("staging/ext-workspace" "ext-workspace-v1" false)
protocolnew("staging/ext-data-control" "ext-data-control-v1" false)
protocolnew("staging/pointer-warp" "pointer-warp-v1" false)
protocolnew("staging/fifo" "fifo-v1" false)
protocolnew("staging/commit-timing" "commit-timing-v1" false)
protocolnew("staging/ext-image-capture-source" "ext-image-capture-source-v1" false)
protocolnew("staging/ext-image-copy-capture" "ext-image-copy-capture-v1" false)
protocolwayland() protocolwayland()
# tools # tools
add_subdirectory(hyprctl) add_subdirectory(hyprctl)
add_subdirectory(start)
if(NO_HYPRPM) if(NO_HYPRPM)
message(STATUS "hyprpm is disabled") message(STATUS "hyprpm is disabled")
@ -402,6 +584,11 @@ install(
\"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/hyprland\" \ \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/hyprland\" \
)") )")
# session file # session file
configure_file(
${CMAKE_SOURCE_DIR}/example/hyprland.desktop.in
${CMAKE_SOURCE_DIR}/example/hyprland.desktop
@ONLY
)
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions)
@ -410,7 +597,6 @@ add_compile_definitions(DATAROOTDIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}")
# installable assets # installable assets
file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*") file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*")
list(FILTER INSTALLABLE_ASSETS EXCLUDE REGEX "meson.build")
install(FILES ${INSTALLABLE_ASSETS} install(FILES ${INSTALLABLE_ASSETS}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr) DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
@ -444,5 +630,51 @@ install(
DIRECTORY ${HEADERS_SRC} DIRECTORY ${HEADERS_SRC}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING FILES_MATCHING
PATTERN "*.h*" PATTERN "*.h"
PATTERN "*.frag") PATTERN "*.hpp"
PATTERN "*.inc")
if(BUILD_TESTING OR WITH_TESTS)
message(STATUS "Building tests")
# hyprtester
add_subdirectory(hyprtester)
# GTest
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
file(GLOB_RECURSE TESTFILES "tests/*.cpp")
add_executable(hyprland_gtests ${TESTFILES})
target_compile_options(hyprland_gtests PRIVATE --coverage)
target_link_options(hyprland_gtests PRIVATE --coverage)
target_include_directories(
hyprland_gtests
PUBLIC "./include"
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
target_link_libraries(hyprland_gtests hyprland_lib GTest::gtest_main)
gtest_discover_tests(hyprland_gtests)
# Enable coverage in main hyprland lib
target_compile_options(hyprland_lib PRIVATE --coverage)
target_link_options(hyprland_lib PRIVATE --coverage)
target_link_libraries(hyprland_lib PUBLIC gcov)
# Enable coverage in hyprland exe
target_compile_options(Hyprland PRIVATE --coverage)
target_link_options(Hyprland PRIVATE --coverage)
target_link_libraries(Hyprland gcov)
endif()
if(BUILD_TESTING)
message(STATUS "Testing is enabled")
enable_testing()
add_custom_target(tests)
add_dependencies(tests hyprland_gtests)
else()
message(STATUS "Testing is disabled")
endif()

View file

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

View file

@ -3,20 +3,12 @@ PREFIX = /usr/local
stub: stub:
@echo "Do not run $(MAKE) directly without any arguments. Please refer to the wiki on how to compile Hyprland." @echo "Do not run $(MAKE) directly without any arguments. Please refer to the wiki on how to compile Hyprland."
legacyrenderer:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
legacyrendererdebug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
release: release:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
debug: debug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DTESTS=true -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
nopch: nopch:
@ -26,6 +18,7 @@ nopch:
clear: clear:
rm -rf build rm -rf build
rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp
rm -f ./hyprctl/hw-protocols/*.cpp ./hyprctl/hw-protocols/*.hpp
all: all:
$(MAKE) clear $(MAKE) clear
@ -52,7 +45,7 @@ installheaders:
cmake --build ./build --config Release --target generate-protocol-headers cmake --build ./build --config Release --target generate-protocol-headers
find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland find src -type f \( -name '*.hpp' -o -name '*.h' -o -name '*.inc' \) -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland
cp ./protocols/*.h* ${PREFIX}/include/hyprland/protocols cp ./protocols/*.h* ${PREFIX}/include/hyprland/protocols
cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig 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 if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi
@ -95,8 +88,12 @@ asan:
@echo "Wayland done" @echo "Wayland done"
patch -p1 < ./scripts/hyprlandStaticAsan.diff 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 --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
cmake --build ./build --config Debug --target all cmake --build ./build --config Debug --target all
@echo "Hyprland done" @echo "Hyprland done"
ASAN_OPTIONS="detect_odr_violation=0,log_path=asan.log" HYPRLAND_NO_CRASHREPORTER=1 ./build/Hyprland -c ~/.config/hypr/hyprland.conf ASAN_OPTIONS="detect_odr_violation=0,log_path=asan.log" HYPRLAND_NO_CRASHREPORTER=1 ./build/Hyprland -c ~/.config/hypr/hyprland.conf
test:
$(MAKE) debug
./build/hyprtester/hyprtester -c hyprtester/test.conf -b ./build/Hyprland -p hyprtester/plugin/hyprtestplugin.so

View file

@ -4,7 +4,7 @@
<br> <br>
![Badge Workflow] [![Badge Workflow]][Workflow]
[![Badge License]][License] [![Badge License]][License]
![Badge Language] ![Badge Language]
[![Badge Pull Requests]][Pull Requests] [![Badge Pull Requests]][Pull Requests]
@ -100,7 +100,7 @@ easy IPC, much more QoL stuff than other compositors and more...
<!-----------------------------------------------------------------------------> <!----------------------------------------------------------------------------->
[Configure]: https://wiki.hyprland.org/Configuring/ [Configure]: https://wiki.hypr.land/Configuring/
[Stars]: https://starchart.cc/hyprwm/Hyprland [Stars]: https://starchart.cc/hyprwm/Hyprland
[Hypr]: https://github.com/hyprwm/Hypr [Hypr]: https://github.com/hyprwm/Hypr
@ -108,9 +108,10 @@ easy IPC, much more QoL stuff than other compositors and more...
[Issues]: https://github.com/hyprwm/Hyprland/issues [Issues]: https://github.com/hyprwm/Hyprland/issues
[Todo]: https://github.com/hyprwm/Hyprland/projects?type=beta [Todo]: https://github.com/hyprwm/Hyprland/projects?type=beta
[Contribute]: https://wiki.hyprland.org/Contributing-and-Debugging/ [Contribute]: https://wiki.hypr.land/Contributing-and-Debugging/
[Install]: https://wiki.hyprland.org/Getting-Started/Installation/ [Install]: https://wiki.hypr.land/Getting-Started/Installation/
[Quick Start]: https://wiki.hyprland.org/Getting-Started/Master-Tutorial/ [Quick Start]: https://wiki.hypr.land/Getting-Started/Master-Tutorial/
[Workflow]: https://github.com/hyprwm/Hyprland/actions/workflows/ci.yaml
[License]: LICENSE [License]: LICENSE
@ -125,9 +126,9 @@ easy IPC, much more QoL stuff than other compositors and more...
<!----------------------------------{ Images }---------------------------------> <!----------------------------------{ Images }--------------------------------->
[Preview A]: https://i.ibb.co/C1yTb0r/falf.png [Preview A]: https://i.ibb.co/XxFY75Mk/greerggergerhtrytghjnyhjn.png
[Preview B]: https://linfindel.github.io/cdn/hyprland-preview-b.png [Preview B]: https://i.ibb.co/C1yTb0r/falf.png
[Preview C]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png [Preview C]: https://i.ibb.co/2Yc4q835/hyprland-preview-b.png
<!----------------------------------{ Badges }---------------------------------> <!----------------------------------{ Badges }--------------------------------->

32
SECURITY.md Normal file
View file

@ -0,0 +1,32 @@
# Hyprland Development Security Policy
If you have a bug that affects the security of your system, you may
want to privately disclose it instead of making it immediately public.
## Supported versions
_Only_ the most recent release on Github is supported. There are no LTS releases.
## What is not a security issue
Some examples of issues that should not be reported as security issues:
- An app can execute a command when ran outside of a sandbox
- An app can write / read hyprland sockets when ran outside of a sandbox
- Crashes
- Things that are protected via permissions when the permission system is disabled
## What is a security issue
Some examples of issues that should be reported as security issues:
- Sandboxed application executing arbitrary code via Hyprland
- Application being able to modify Hyprland's code on the fly
- Application being able to keylog / track user's activity beyond what the wayland protocols allow
## How to report security issues
Please report your security issues via either of these channels:
- Mail: `vaxry [at] vaxry [dot] net`
- Matrix: `@vaxry:matrix.vaxry.net`
- Discord: `@vaxry`

View file

@ -1 +1 @@
0.48.0 0.54.0

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 506 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Before After
Before After

View file

@ -1,10 +0,0 @@
globber = run_command('sh', '-c', 'find . -type f -not -name "*.build"', check: true)
files = globber.stdout().strip().split('\n')
foreach file : files
install_data(
file,
install_dir: join_paths(get_option('datadir'), 'hypr'),
install_tag: 'runtime',
)
endforeach

View file

@ -1,7 +0,0 @@
install_data(
'hyprland-portals.conf',
install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal'),
install_tag: 'runtime',
)
subdir('install')

View file

@ -1,5 +1,19 @@
.\" Automatically generated by Pandoc 2.9.2.1 .\" Automatically generated by Pandoc 3.1.3
.\" .\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "Hyprland" "1" "" "" "Hyprland User Manual" .TH "Hyprland" "1" "" "" "Hyprland User Manual"
.hy .hy
.SH NAME .SH NAME

View file

@ -2,15 +2,15 @@
First of all, please remember to: First of all, please remember to:
- Check that your issue is not a duplicate - Check that your issue is not a duplicate
- Read the [FAQ](https://wiki.hyprland.org/FAQ/) - Read the [FAQ](https://wiki.hypr.land/FAQ/)
- Read the [Configuring Page](https://wiki.hyprland.org/Configuring/) - Read the [Configuring Page](https://wiki.hypr.land/Configuring/)
<br/> <br/>
# Reporting suggestions # Reporting suggestions
Suggestions are welcome. Suggestions are welcome.
Many features can be implemented using bash scripts and Hyprland sockets, read up on those [Here](https://wiki.hyprland.org/IPC). Please do not suggest features that can be implemented as such. Many features can be implemented using bash scripts and Hyprland sockets, read up on those [Here](https://wiki.hypr.land/IPC). Please do not suggest features that can be implemented as such.
<br/> <br/>
@ -70,7 +70,7 @@ A debug coredump provides more information for debugging and may speed up the pr
Make sure you're on latest git. Run `git pull --recurse-submodules` to sync everything. Make sure you're on latest git. Run `git pull --recurse-submodules` to sync everything.
1. [Compile Hyprland with debug mode](http://wiki.hyprland.org/Contributing-and-Debugging/#build-in-debug-mode) 1. [Compile Hyprland with debug mode](http://wiki.hypr.land/Contributing-and-Debugging/#build-in-debug-mode)
> Note: The config file used will be `hyprlandd.conf` instead of `hyprland.conf` > Note: The config file used will be `hyprlandd.conf` instead of `hyprland.conf`
2. `cd ~` 2. `cd ~`

View file

@ -1,5 +1,19 @@
.\" Automatically generated by Pandoc 2.9.2.1 .\" Automatically generated by Pandoc 3.1.3
.\" .\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "hyprctl" "1" "" "" "hyprctl User Manual" .TH "hyprctl" "1" "" "" "hyprctl User Manual"
.hy .hy
.SH NAME .SH NAME

View file

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

View file

@ -1,6 +1,6 @@
# This is an example Hyprland config file. # This is an example Hyprland config file.
# Refer to the wiki for more information. # Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/ # https://wiki.hypr.land/Configuring/
# Please note not all available settings / options are set here. # Please note not all available settings / options are set here.
# For a full list, see the wiki # For a full list, see the wiki
@ -14,7 +14,7 @@
### MONITORS ### ### MONITORS ###
################ ################
# See https://wiki.hyprland.org/Configuring/Monitors/ # See https://wiki.hypr.land/Configuring/Monitors/
monitor=,preferred,auto,auto monitor=,preferred,auto,auto
@ -22,12 +22,12 @@ monitor=,preferred,auto,auto
### MY PROGRAMS ### ### MY PROGRAMS ###
################### ###################
# See https://wiki.hyprland.org/Configuring/Keywords/ # See https://wiki.hypr.land/Configuring/Keywords/
# Set programs that you use # Set programs that you use
$terminal = kitty $terminal = kitty
$fileManager = dolphin $fileManager = dolphin
$menu = wofi --show drun $menu = hyprlauncher
################# #################
@ -46,39 +46,56 @@ $menu = wofi --show drun
### ENVIRONMENT VARIABLES ### ### ENVIRONMENT VARIABLES ###
############################# #############################
# See https://wiki.hyprland.org/Configuring/Environment-variables/ # See https://wiki.hypr.land/Configuring/Environment-variables/
env = XCURSOR_SIZE,24 env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24 env = HYPRCURSOR_SIZE,24
###################
### PERMISSIONS ###
###################
# See https://wiki.hypr.land/Configuring/Permissions/
# Please note permission changes here require a Hyprland restart and are not applied on-the-fly
# for security reasons
# ecosystem {
# enforce_permissions = 1
# }
# permission = /usr/(bin|local/bin)/grim, screencopy, allow
# permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
# permission = /usr/(bin|local/bin)/hyprpm, plugin, allow
##################### #####################
### LOOK AND FEEL ### ### LOOK AND FEEL ###
##################### #####################
# Refer to https://wiki.hyprland.org/Configuring/Variables/ # Refer to https://wiki.hypr.land/Configuring/Variables/
# https://wiki.hyprland.org/Configuring/Variables/#general # https://wiki.hypr.land/Configuring/Variables/#general
general { general {
gaps_in = 5 gaps_in = 5
gaps_out = 20 gaps_out = 20
border_size = 2 border_size = 2
# https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors # https://wiki.hypr.land/Configuring/Variables/#variable-types for info about colors
col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border = rgba(595959aa) col.inactive_border = rgba(595959aa)
# Set to true enable resizing windows by clicking and dragging on borders and gaps # Set to true enable resizing windows by clicking and dragging on borders and gaps
resize_on_border = false resize_on_border = false
# Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on # Please see https://wiki.hypr.land/Configuring/Tearing/ before you turn this on
allow_tearing = false allow_tearing = false
layout = dwindle layout = dwindle
} }
# https://wiki.hyprland.org/Configuring/Variables/#decoration # https://wiki.hypr.land/Configuring/Variables/#decoration
decoration { decoration {
rounding = 10 rounding = 10
rounding_power = 2 rounding_power = 2
@ -94,7 +111,7 @@ decoration {
color = rgba(1a1a1aee) color = rgba(1a1a1aee)
} }
# https://wiki.hyprland.org/Configuring/Variables/#blur # https://wiki.hypr.land/Configuring/Variables/#blur
blur { blur {
enabled = true enabled = true
size = 3 size = 3
@ -104,58 +121,74 @@ decoration {
} }
} }
# https://wiki.hyprland.org/Configuring/Variables/#animations # https://wiki.hypr.land/Configuring/Variables/#animations
animations { animations {
enabled = yes, please :) enabled = yes, please :)
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more # Default curves, see https://wiki.hypr.land/Configuring/Animations/#curves
# NAME, X0, Y0, X1, Y1
bezier = easeOutQuint, 0.23, 1, 0.32, 1
bezier = easeInOutCubic, 0.65, 0.05, 0.36, 1
bezier = linear, 0, 0, 1, 1
bezier = almostLinear, 0.5, 0.5, 0.75, 1
bezier = quick, 0.15, 0, 0.1, 1
bezier = easeOutQuint,0.23,1,0.32,1 # Default animations, see https://wiki.hypr.land/Configuring/Animations/
bezier = easeInOutCubic,0.65,0.05,0.36,1 # NAME, ONOFF, SPEED, CURVE, [STYLE]
bezier = linear,0,0,1,1 animation = global, 1, 10, default
bezier = almostLinear,0.5,0.5,0.75,1.0 animation = border, 1, 5.39, easeOutQuint
bezier = quick,0.15,0,0.1,1 animation = windows, 1, 4.79, easeOutQuint
animation = windowsIn, 1, 4.1, easeOutQuint, popin 87%
animation = global, 1, 10, default animation = windowsOut, 1, 1.49, linear, popin 87%
animation = border, 1, 5.39, easeOutQuint animation = fadeIn, 1, 1.73, almostLinear
animation = windows, 1, 4.79, easeOutQuint animation = fadeOut, 1, 1.46, almostLinear
animation = windowsIn, 1, 4.1, easeOutQuint, popin 87% animation = fade, 1, 3.03, quick
animation = windowsOut, 1, 1.49, linear, popin 87% animation = layers, 1, 3.81, easeOutQuint
animation = fadeIn, 1, 1.73, almostLinear animation = layersIn, 1, 4, easeOutQuint, fade
animation = fadeOut, 1, 1.46, almostLinear animation = layersOut, 1, 1.5, linear, fade
animation = fade, 1, 3.03, quick animation = fadeLayersIn, 1, 1.79, almostLinear
animation = layers, 1, 3.81, easeOutQuint animation = fadeLayersOut, 1, 1.39, almostLinear
animation = layersIn, 1, 4, easeOutQuint, fade animation = workspaces, 1, 1.94, almostLinear, fade
animation = layersOut, 1, 1.5, linear, fade animation = workspacesIn, 1, 1.21, almostLinear, fade
animation = fadeLayersIn, 1, 1.79, almostLinear animation = workspacesOut, 1, 1.94, almostLinear, fade
animation = fadeLayersOut, 1, 1.39, almostLinear animation = zoomFactor, 1, 7, quick
animation = workspaces, 1, 1.94, almostLinear, fade
animation = workspacesIn, 1, 1.21, almostLinear, fade
animation = workspacesOut, 1, 1.94, almostLinear, fade
} }
# Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/ # Ref https://wiki.hypr.land/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only" # "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that. # uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0 # workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0 # workspace = f[1], gapsout:0, gapsin:0
# windowrule = bordersize 0, floating:0, onworkspace:w[tv1] # windowrule {
# windowrule = rounding 0, floating:0, onworkspace:w[tv1] # name = no-gaps-wtv1
# windowrule = bordersize 0, floating:0, onworkspace:f[1] # match:float = false
# windowrule = rounding 0, floating:0, onworkspace:f[1] # match:workspace = w[tv1]
#
# border_size = 0
# rounding = 0
# }
#
# windowrule {
# name = no-gaps-f1
# match:float = false
# match:workspace = f[1]
#
# border_size = 0
# rounding = 0
# }
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more # See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more
dwindle { dwindle {
pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # You probably want this preserve_split = true # You probably want this
} }
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more # See https://wiki.hypr.land/Configuring/Master-Layout/ for more
master { master {
new_status = master new_status = master
} }
# https://wiki.hyprland.org/Configuring/Variables/#misc # https://wiki.hypr.land/Configuring/Variables/#misc
misc { misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers 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. :( disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :(
@ -166,7 +199,7 @@ misc {
### INPUT ### ### INPUT ###
############# #############
# https://wiki.hyprland.org/Configuring/Variables/#input # https://wiki.hypr.land/Configuring/Variables/#input
input { input {
kb_layout = us kb_layout = us
kb_variant = kb_variant =
@ -183,13 +216,11 @@ input {
} }
} }
# https://wiki.hyprland.org/Configuring/Variables/#gestures # See https://wiki.hypr.land/Configuring/Gestures
gestures { gesture = 3, horizontal, workspace
workspace_swipe = false
}
# Example per-device config # Example per-device config
# See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more # See https://wiki.hypr.land/Configuring/Keywords/#per-device-input-configs for more
device { device {
name = epic-mouse-v1 name = epic-mouse-v1
sensitivity = -0.5 sensitivity = -0.5
@ -200,18 +231,18 @@ device {
### KEYBINDINGS ### ### KEYBINDINGS ###
################### ###################
# See https://wiki.hyprland.org/Configuring/Keywords/ # See https://wiki.hypr.land/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier $mainMod = SUPER # Sets "Windows" key as main modifier
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more # Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
bind = $mainMod, Q, exec, $terminal bind = $mainMod, Q, exec, $terminal
bind = $mainMod, C, killactive, bind = $mainMod, C, killactive,
bind = $mainMod, M, exit, bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit
bind = $mainMod, E, exec, $fileManager bind = $mainMod, E, exec, $fileManager
bind = $mainMod, V, togglefloating, bind = $mainMod, V, togglefloating,
bind = $mainMod, R, exec, $menu bind = $mainMod, R, exec, $menu
bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle bind = $mainMod, J, layoutmsg, togglesplit # dwindle
# Move focus with mainMod + arrow keys # Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l bind = $mainMod, left, movefocus, l
@ -260,8 +291,8 @@ bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@
bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+ bindel = ,XF86MonBrightnessUp, exec, brightnessctl -e4 -n2 set 5%+
bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%- bindel = ,XF86MonBrightnessDown, exec, brightnessctl -e4 -n2 set 5%-
# Requires playerctl # Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next bindl = , XF86AudioNext, exec, playerctl next
@ -273,14 +304,38 @@ bindl = , XF86AudioPrev, exec, playerctl previous
### WINDOWS AND WORKSPACES ### ### WINDOWS AND WORKSPACES ###
############################## ##############################
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more # See https://wiki.hypr.land/Configuring/Window-Rules/ for more
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules # See https://wiki.hypr.land/Configuring/Workspace-Rules/ for workspace rules
# Example windowrule # Example windowrules that are useful
# windowrule = float,class:^(kitty)$,title:^(kitty)$
# Ignore maximize requests from apps. You'll probably like this. windowrule {
windowrule = suppressevent maximize, class:.* # Ignore maximize requests from all apps. You'll probably like this.
name = suppress-maximize-events
match:class = .*
# Fix some dragging issues with XWayland suppress_event = maximize
windowrule = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0 }
windowrule {
# Fix some dragging issues with XWayland
name = fix-xwayland-drags
match:class = ^$
match:title = ^$
match:xwayland = true
match:float = true
match:fullscreen = false
match:pin = false
no_focus = true
}
# Hyprland-run windowrule
windowrule {
name = move-hyprland-run
match:class = hyprland-run
move = 20 monitor_h-120
float = yes
}

View file

@ -1,7 +1,7 @@
[Desktop Entry] [Desktop Entry]
Name=Hyprland Name=Hyprland
Comment=An intelligent dynamic tiling Wayland compositor Comment=An intelligent dynamic tiling Wayland compositor
Exec=Hyprland Exec=@PREFIX@/@CMAKE_INSTALL_BINDIR@/start-hyprland
Type=Application Type=Application
DesktopNames=Hyprland DesktopNames=Hyprland
Keywords=tiling;wayland;compositor; Keywords=tiling;wayland;compositor;

View file

@ -1,10 +0,0 @@
install_data(
'hyprland.conf',
install_dir: join_paths(get_option('datadir'), 'hypr'),
install_tag: 'runtime',
)
install_data(
'hyprland.desktop',
install_dir: join_paths(get_option('datadir'), 'wayland-sessions'),
install_tag: 'runtime',
)

View file

@ -1,16 +1,19 @@
// //
// Example blue light filter shader. // Example blue light filter shader.
// //
#version 300 es
precision mediump float; precision mediump float;
varying vec2 v_texcoord; in vec2 v_texcoord;
layout(location = 0) out vec4 fragColor;
uniform sampler2D tex; uniform sampler2D tex;
void main() { void main() {
vec4 pixColor = texture2D(tex, v_texcoord); vec4 pixColor = texture(tex, v_texcoord);
pixColor[2] *= 0.8; pixColor[2] *= 0.8;
gl_FragColor = pixColor; fragColor = pixColor;
} }

244
flake.lock generated
View file

@ -16,11 +16,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1742213273, "lastModified": 1772292445,
"narHash": "sha256-0l0vDb4anfsBu1rOs94bC73Hub+xEivgBAo6QXl2MmU=", "narHash": "sha256-4F1Q7U313TKUDDovCC96m/Za4wZcJ3yqtu4eSrj8lk8=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "aquamarine", "repo": "aquamarine",
"rev": "484b732195cc53f4536ce4bd59a5c6402b1e7ccf", "rev": "1dbbba659c1cef0b0202ce92cadfe13bae550e8f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -32,15 +32,15 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1696426674, "lastModified": 1767039857,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "edolstra", "owner": "NixOS",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "edolstra", "owner": "NixOS",
"repo": "flake-compat", "repo": "flake-compat",
"type": "github" "type": "github"
} }
@ -79,11 +79,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1742215578, "lastModified": 1753964049,
"narHash": "sha256-zfs71PXVVPEe56WEyNi2TJQPs0wabU4WAlq0XV7GcdE=", "narHash": "sha256-lIqabfBY7z/OANxHoPeIrDJrFyYy9jAM4GQLzZ2feCM=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprcursor", "repo": "hyprcursor",
"rev": "2fd36421c21aa87e2fe3bee11067540ae612f719", "rev": "44e91d467bdad8dcf8bbd2ac7cf49972540980a5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -105,11 +105,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1739049071, "lastModified": 1770511807,
"narHash": "sha256-3+7TpXMrbsUXSwgr5VAKAnmkzMb6JO+Rvc9XRb5NMg4=", "narHash": "sha256-suKmSbSk34uPOJDTg/GbPrKEJutzK08vj0VoTvAFBCA=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprgraphics", "repo": "hyprgraphics",
"rev": "175c6b29b6ff82100539e7c4363a35a02c74dd73", "rev": "7c75487edd43a71b61adb01cae8326d277aab683",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -118,6 +118,45 @@
"type": "github" "type": "github"
} }
}, },
"hyprland-guiutils": {
"inputs": {
"aquamarine": [
"aquamarine"
],
"hyprgraphics": [
"hyprgraphics"
],
"hyprlang": [
"hyprlang"
],
"hyprtoolkit": "hyprtoolkit",
"hyprutils": [
"hyprutils"
],
"hyprwayland-scanner": [
"hyprwayland-scanner"
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1767023960,
"narHash": "sha256-R2HgtVS1G3KSIKAQ77aOZ+Q0HituOmPgXW9nBNkpp3Q=",
"owner": "hyprwm",
"repo": "hyprland-guiutils",
"rev": "c2e906261142f5dd1ee0bfc44abba23e2754c660",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-guiutils",
"type": "github"
}
},
"hyprland-protocols": { "hyprland-protocols": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -128,11 +167,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1738422629, "lastModified": 1765214753,
"narHash": "sha256-5v+bv75wJWvahyM2xcMTSNNxmV8a7hb01Eey5zYnBJw=", "narHash": "sha256-P9zdGXOzToJJgu5sVjv7oeOGPIIwrd9hAUAP3PsmBBs=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprland-protocols", "repo": "hyprland-protocols",
"rev": "755aef8dab49d0fc4663c715fa4ad221b2aedaed", "rev": "3f3860b869014c00e8b9e0528c7b4ddc335c21ab",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -141,67 +180,6 @@
"type": "github" "type": "github"
} }
}, },
"hyprland-qt-support": {
"inputs": {
"hyprlang": [
"hyprland-qtutils",
"hyprlang"
],
"nixpkgs": [
"hyprland-qtutils",
"nixpkgs"
],
"systems": [
"hyprland-qtutils",
"systems"
]
},
"locked": {
"lastModified": 1737634706,
"narHash": "sha256-nGCibkfsXz7ARx5R+SnisRtMq21IQIhazp6viBU8I/A=",
"owner": "hyprwm",
"repo": "hyprland-qt-support",
"rev": "8810df502cdee755993cb803eba7b23f189db795",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-qt-support",
"type": "github"
}
},
"hyprland-qtutils": {
"inputs": {
"hyprland-qt-support": "hyprland-qt-support",
"hyprlang": [
"hyprlang"
],
"hyprutils": [
"hyprland-qtutils",
"hyprlang",
"hyprutils"
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1739048983,
"narHash": "sha256-REhTcXq4qs3B3cCDtLlYDz0GZvmsBSh947Ub6pQWGTQ=",
"owner": "hyprwm",
"repo": "hyprland-qtutils",
"rev": "3504a293c8f8db4127cb0f7cfc1a318ffb4316f8",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-qtutils",
"type": "github"
}
},
"hyprlang": { "hyprlang": {
"inputs": { "inputs": {
"hyprutils": [ "hyprutils": [
@ -215,11 +193,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741191527, "lastModified": 1771866172,
"narHash": "sha256-kM+11Nch47Xwfgtw2EpRitJuORy4miwoMuRi5tyMBDY=", "narHash": "sha256-fYFoXhQLrm1rD8vSFKQBOEX4OGCuJdLt1amKfHd5GAw=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprlang", "repo": "hyprlang",
"rev": "72df3861f1197e41b078faa3e38eedd60e00018d", "rev": "0b219224910e7642eb0ed49f0db5ec3d008e3e41",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -228,6 +206,51 @@
"type": "github" "type": "github"
} }
}, },
"hyprtoolkit": {
"inputs": {
"aquamarine": [
"hyprland-guiutils",
"aquamarine"
],
"hyprgraphics": [
"hyprland-guiutils",
"hyprgraphics"
],
"hyprlang": [
"hyprland-guiutils",
"hyprlang"
],
"hyprutils": [
"hyprland-guiutils",
"hyprutils"
],
"hyprwayland-scanner": [
"hyprland-guiutils",
"hyprwayland-scanner"
],
"nixpkgs": [
"hyprland-guiutils",
"nixpkgs"
],
"systems": [
"hyprland-guiutils",
"systems"
]
},
"locked": {
"lastModified": 1764592794,
"narHash": "sha256-7CcO+wbTJ1L1NBQHierHzheQGPWwkIQug/w+fhTAVuU=",
"owner": "hyprwm",
"repo": "hyprtoolkit",
"rev": "5cfe0743f0e608e1462972303778d8a0859ee63e",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprtoolkit",
"type": "github"
}
},
"hyprutils": { "hyprutils": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -238,11 +261,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741534688, "lastModified": 1771271487,
"narHash": "sha256-EV3945SnjOCuRVbGRghsWx/9D89FyshnSO1Q6/TuQ14=", "narHash": "sha256-41gEiUS0Pyw3L/ge1l8MXn61cK14VAhgWB/JV8s/oNI=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprutils", "repo": "hyprutils",
"rev": "dd1f720cbc2dbb3c71167c9598045dd3261d27b3", "rev": "340a792e3b3d482c4ae5f66d27a9096bdee6d76d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -261,11 +284,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1739870480, "lastModified": 1770501770,
"narHash": "sha256-SiDN5BGxa/1hAsqhgJsS03C3t2QrLgBT8u+ENJ0Qzwc=", "narHash": "sha256-NWRM6+YxTRv+bT9yvlhhJ2iLae1B1pNH3mAL5wi2rlQ=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprwayland-scanner", "repo": "hyprwayland-scanner",
"rev": "206367a08dc5ac4ba7ad31bdca391d098082e64b", "rev": "0bd8b6cde9ec27d48aad9e5b4deefb3746909d40",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -274,13 +297,39 @@
"type": "github" "type": "github"
} }
}, },
"hyprwire": {
"inputs": {
"hyprutils": [
"hyprutils"
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1771606233,
"narHash": "sha256-F3PLUqQ/TwgR70U+UeOqJnihJZ2EuunzojYC4g5xHr0=",
"owner": "hyprwm",
"repo": "hyprwire",
"rev": "06c7f1f8c4194786c8400653c4efc49dc14c0f3a",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprwire",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1742069588, "lastModified": 1772198003,
"narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", "narHash": "sha256-I45esRSssFtJ8p/gLHUZ1OUaaTaVLluNkABkk6arQwE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", "rev": "dd9b079222d43e1943b6ebd802f04fd959dc8e61",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -299,11 +348,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1742058297, "lastModified": 1772024342,
"narHash": "sha256-b4SZc6TkKw8WQQssbN5O2DaCEzmFfvSTPYHlx/SFW9Y=", "narHash": "sha256-+eXlIc4/7dE6EcPs9a2DaSY3fTA9AE526hGqkNID3Wg=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "59f17850021620cd348ad2e9c0c64f4e6325ce2a", "rev": "6e34e97ed9788b17796ee43ccdbaf871a5c2b476",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -317,11 +366,12 @@
"aquamarine": "aquamarine", "aquamarine": "aquamarine",
"hyprcursor": "hyprcursor", "hyprcursor": "hyprcursor",
"hyprgraphics": "hyprgraphics", "hyprgraphics": "hyprgraphics",
"hyprland-guiutils": "hyprland-guiutils",
"hyprland-protocols": "hyprland-protocols", "hyprland-protocols": "hyprland-protocols",
"hyprland-qtutils": "hyprland-qtutils",
"hyprlang": "hyprlang", "hyprlang": "hyprlang",
"hyprutils": "hyprutils", "hyprutils": "hyprutils",
"hyprwayland-scanner": "hyprwayland-scanner", "hyprwayland-scanner": "hyprwayland-scanner",
"hyprwire": "hyprwire",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks", "pre-commit-hooks": "pre-commit-hooks",
"systems": "systems", "systems": "systems",
@ -365,11 +415,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1741934139, "lastModified": 1761431178,
"narHash": "sha256-ZhTcTH9FoeAtbPfWGrhkH7RjLJZ7GeF18nygLAMR+WE=", "narHash": "sha256-xzjC1CV3+wpUQKNF+GnadnkeGUCJX+vgaWIZsnz9tzI=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland", "repo": "xdg-desktop-portal-hyprland",
"rev": "150b0b6f52bb422a1b232a53698606fe0320dde0", "rev": "4b8801228ff958d028f588f0c2b911dbf32297f9",
"type": "github" "type": "github"
}, },
"original": { "original": {

204
flake.nix
View file

@ -35,11 +35,15 @@
inputs.systems.follows = "systems"; inputs.systems.follows = "systems";
}; };
hyprland-qtutils = { hyprland-guiutils = {
url = "github:hyprwm/hyprland-qtutils"; url = "github:hyprwm/hyprland-guiutils";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems"; inputs.systems.follows = "systems";
inputs.aquamarine.follows = "aquamarine";
inputs.hyprgraphics.follows = "hyprgraphics";
inputs.hyprutils.follows = "hyprutils";
inputs.hyprlang.follows = "hyprlang"; inputs.hyprlang.follows = "hyprlang";
inputs.hyprwayland-scanner.follows = "hyprwayland-scanner";
}; };
hyprlang = { hyprlang = {
@ -61,6 +65,13 @@
inputs.systems.follows = "systems"; inputs.systems.follows = "systems";
}; };
hyprwire = {
url = "github:hyprwm/hyprwire";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};
xdph = { xdph = {
url = "github:hyprwm/xdg-desktop-portal-hyprland"; url = "github:hyprwm/xdg-desktop-portal-hyprland";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -77,91 +88,122 @@
}; };
}; };
outputs = inputs @ { outputs =
self, inputs@{
nixpkgs, self,
systems, nixpkgs,
... systems,
}: let ...
inherit (nixpkgs) lib; }:
eachSystem = lib.genAttrs (import systems); let
pkgsFor = eachSystem (system: inherit (nixpkgs) lib;
import nixpkgs { eachSystem = lib.genAttrs (import systems);
localSystem = system; pkgsFor = eachSystem (
overlays = with self.overlays; [ system:
hyprland-packages import nixpkgs {
hyprland-extras localSystem = system;
]; overlays = with self.overlays; [
}); hyprland-packages
pkgsCrossFor = eachSystem (system: crossSystem: hyprland-extras
import nixpkgs { ];
localSystem = system; }
inherit crossSystem; );
overlays = with self.overlays; [ pkgsCrossFor = eachSystem (
hyprland-packages system: crossSystem:
hyprland-extras import nixpkgs {
]; localSystem = system;
}); inherit crossSystem;
in { overlays = with self.overlays; [
overlays = import ./nix/overlays.nix {inherit self lib inputs;}; hyprland-packages
hyprland-extras
];
}
);
pkgsDebugFor = eachSystem (
system:
import nixpkgs {
localSystem = system;
overlays = with self.overlays; [
hyprland-debug
];
}
);
pkgsDebugCrossFor = eachSystem (
system: crossSystem:
import nixpkgs {
localSystem = system;
inherit crossSystem;
overlays = with self.overlays; [
hyprland-debug
];
}
);
in
{
overlays = import ./nix/overlays.nix { inherit self lib inputs; };
checks = eachSystem (system: checks = eachSystem (
(lib.filterAttrs system:
(n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n)) (lib.filterAttrs (
self.packages.${system}) n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n)
// { ) self.packages.${system})
inherit (self.packages.${system}) xdg-desktop-portal-hyprland; // {
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { inherit (self.packages.${system}) xdg-desktop-portal-hyprland;
src = ./.; pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
hooks = { src = ./.;
hyprland-treewide-formatter = { hooks = {
enable = true; hyprland-treewide-formatter = {
entry = "${self.formatter.${system}}/bin/hyprland-treewide-formatter"; enable = true;
pass_filenames = false; entry = "${self.formatter.${system}}/bin/hyprland-treewide-formatter";
excludes = ["subprojects"]; pass_filenames = false;
always_run = true; excludes = [ "subprojects" ];
always_run = true;
};
}; };
}; };
}; }
// (import ./nix/tests inputs pkgsFor.${system})
);
packages = eachSystem (system: {
default = self.packages.${system}.hyprland;
inherit (pkgsFor.${system})
# hyprland-packages
hyprland
hyprland-unwrapped
hyprland-with-tests
# hyprland-extras
xdg-desktop-portal-hyprland
;
inherit (pkgsDebugFor.${system}) hyprland-debug;
hyprland-cross = (pkgsCrossFor.${system} "aarch64-linux").hyprland;
hyprland-debug-cross = (pkgsDebugCrossFor.${system} "aarch64-linux").hyprland-debug;
}); });
packages = eachSystem (system: { devShells = eachSystem (system: {
default = self.packages.${system}.hyprland; default =
inherit pkgsFor.${system}.mkShell.override
(pkgsFor.${system}) {
# hyprland-packages inherit (self.packages.${system}.default) stdenv;
hyprland }
hyprland-debug {
hyprland-legacy-renderer name = "hyprland-shell";
hyprland-unwrapped hardeningDisable = [ "fortify" ];
# hyprland-extras inputsFrom = [ pkgsFor.${system}.hyprland ];
xdg-desktop-portal-hyprland packages = [ pkgsFor.${system}.clang-tools ];
; inherit (self.checks.${system}.pre-commit-check) shellHook;
hyprland-cross = (pkgsCrossFor.${system} "aarch64-linux").hyprland; };
}); });
devShells = eachSystem (system: { formatter = eachSystem (system: pkgsFor.${system}.callPackage ./nix/formatter.nix { });
default =
pkgsFor.${system}.mkShell.override {
inherit (self.packages.${system}.default) stdenv;
} {
name = "hyprland-shell";
hardeningDisable = ["fortify"];
inputsFrom = [pkgsFor.${system}.hyprland];
packages = [pkgsFor.${system}.clang-tools];
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
formatter = eachSystem (system: pkgsFor.${system}.callPackage ./nix/formatter.nix {}); nixosModules.default = import ./nix/module.nix inputs;
homeManagerModules.default = import ./nix/hm-module.nix self;
nixosModules.default = import ./nix/module.nix inputs; # Hydra build jobs
homeManagerModules.default = import ./nix/hm-module.nix self; # Recent versions of Hydra can aggregate jobsets from 'hydraJobs' instead of a release.nix
# or similar. Remember to filter large or incompatible attributes here. More eval jobs can
# Hydra build jobs # be added by merging, e.g., self.packages // self.devShells.
# Recent versions of Hydra can aggregate jobsets from 'hydraJobs' intead of a release.nix hydraJobs = self.packages;
# or similar. Remember to filter large or incompatible attributes here. More eval jobs can };
# be added by merging, e.g., self.packages // self.devShells.
hydraJobs = self.packages;
};
} }

View file

@ -5,11 +5,32 @@ project(
DESCRIPTION "Control utility for Hyprland" DESCRIPTION "Control utility for Hyprland"
) )
pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 re2) pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 hyprwire re2)
add_executable(hyprctl "main.cpp") file(GLOB_RECURSE HYPRCTL_SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "hw-protocols/*.cpp" "include/*.hpp")
add_executable(hyprctl ${HYPRCTL_SRCFILES})
target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps) target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps)
target_include_directories(hyprctl PRIVATE "hw-protocols")
# Hyprwire
function(hyprprotocol protoPath protoName)
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.hpp
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-spec.hpp
COMMAND hyprwire-scanner --client ${path}/${protoName}.xml
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(hyprctl PRIVATE hw-protocols/${protoName}-client.cpp
hw-protocols/${protoName}-client.hpp
hw-protocols/${protoName}-spec.hpp)
endfunction()
hyprprotocol(hw-protocols hyprpaper_core)
# binary # binary
install(TARGETS hyprctl) install(TARGETS hyprctl)

View file

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="hyprpaper_core" version="2">
<copyright>
BSD 3-Clause License
Copyright (c) 2025, Hypr Development
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright>
<object name="hyprpaper_core_manager" version="2">
<description summary="manager object">
This is the core manager object for hyprpaper operations
</description>
<c2s name="get_wallpaper_object">
<description summary="Get a wallpaper object">
Creates a wallpaper object
</description>
<returns iface="hyprpaper_wallpaper"/>
</c2s>
<s2c name="add_monitor">
<description summary="New monitor added">
Emitted when a new monitor is added.
</description>
<arg name="monitor_name" type="varchar" summary="the monitor's name"/>
</s2c>
<s2c name="remove_monitor">
<description summary="A monitor was removed">
Emitted when a monitor is removed.
</description>
<arg name="monitor_name" type="varchar" summary="the monitor's name"/>
</s2c>
<c2s name="destroy" destructor="true">
<description summary="Destroy this object">
Destroys this object. Children remain alive until destroyed.
</description>
</c2s>
<c2s name="get_status_object" since="2">
<description summary="Get a status object">
Creates a status object
</description>
<returns iface="hyprpaper_status"/>
</c2s>
</object>
<enum name="wallpaper_fit_mode">
<value idx="0" name="stretch"/>
<value idx="1" name="cover"/>
<value idx="2" name="contain"/>
<value idx="3" name="tile"/>
</enum>
<enum name="wallpaper_errors">
<value idx="0" name="inert_wallpaper_object" description="attempted to use an inert wallpaper object"/>
</enum>
<enum name="applying_error">
<value idx="0" name="invalid_path" description="path provided was invalid"/>
<value idx="1" name="invalid_monitor" description="monitor provided was invalid"/>
<value idx="2" name="unknown_error" description="unknown error"/>
</enum>
<object name="hyprpaper_wallpaper" version="1">
<description summary="wallpaper object">
This is an object describing a wallpaper
</description>
<c2s name="path">
<description summary="Set a path">
Set a file path for the wallpaper. This has to be an absolute path from the fs root.
This is required.
</description>
<arg name="wallpaper" type="varchar" summary="path"/>
</c2s>
<c2s name="fit_mode">
<description summary="Set a fit mode">
Set a fit mode for the wallpaper. This is set to cover by default.
</description>
<arg name="fit_mode" type="enum" interface="wallpaper_fit_mode" summary="path"/>
</c2s>
<c2s name="monitor_name">
<description summary="Set the monitor name">
Set a monitor for the wallpaper. Setting this to empty (or not setting at all) will
treat this as a wildcard fallback.
See hyprpaper_core_manager.add_monitor and hyprpaper_core_manager.remove_monitor
for tracking monitor names.
</description>
<arg name="monitor_name" type="varchar" summary="monitor name"/>
</c2s>
<c2s name="apply">
<description summary="Apply this wallpaper">
Applies this object's state to the wallpaper state. Will emit .success on success,
and .failed on failure.
This object becomes inert after .succeess or .failed, the only valid operation
is to destroy it afterwards.
</description>
</c2s>
<s2c name="success">
<description summary="Operation succeeded">
Wallpaper was applied successfully.
</description>
</s2c>
<s2c name="failed">
<description summary="Operation failed">
Wallpaper was not applied. See the error field for more information.
</description>
<arg name="error" type="enum" interface="hyprpaper_wallpaper_application_error" summary="path"/>
</s2c>
<c2s name="destroy" destructor="true">
<description summary="Destroy this object">
Destroys this object.
</description>
</c2s>
</object>
<object name="hyprpaper_status" version="2">
<description summary="status object">
This is an object which will emit various status updates.
</description>
<s2c name="active_wallpaper">
<description summary="Active wallpaper state">
Sends the active wallpaper for a given monitor. This will be emitted
immediately after binding, and then every time the path changes.
</description>
<arg name="monitor" type="varchar" summary="monitor name"/>
<arg name="path" type="varchar" summary="wallpaper path"/>
</s2c>
<c2s name="destroy" destructor="true">
<description summary="Destroy this object">
Destroys this object.
</description>
</c2s>
</object>
</protocol>

View file

@ -23,7 +23,7 @@ _hyprctl () {
local words cword local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword _get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
declare -a literals=(resizeactive 2 changegroupactive -r moveintogroup forceallowsinput 4 ::= systeminfo all layouts setprop animationstyle switchxkblayout create denywindowfromgroup headless activebordercolor exec setcursor wayland focusurgentorlast workspacerules movecurrentworkspacetomonitor movetoworkspacesilent hyprpaper alpha inactivebordercolor movegroupwindow movecursortocorner movewindowpixel prev movewindow globalshortcuts clients dimaround setignoregrouplock splash execr monitors 0 forcenoborder -q animations 1 nomaxsize splitratio moveactive pass swapnext devices layers rounding lockactivegroup 5 moveworkspacetomonitor -f -i --quiet forcenodim pin 0 1 forceopaque forcenoshadow setfloating minsize alphaoverride sendshortcut workspaces cyclenext alterzorder togglegroup lockgroups bordersize dpms focuscurrentorlast -1 --batch notify remove instances 1 3 moveoutofgroup killactive 2 movetoworkspace movecursor configerrors closewindow swapwindow tagwindow forcerendererreload centerwindow auto focuswindow seterror nofocus alphafullscreen binds version -h togglespecialworkspace fullscreen windowdancecompat 0 keyword toggleopaque 3 --instance togglefloating renameworkspace alphafullscreenoverride activeworkspace x11 kill forceopaqueoverriden output global dispatch reload forcenoblur -j event --help disable -1 activewindow keepaspectratio dismissnotify focusmonitor movefocus plugin exit workspace fullscreenstate getoption alphainactiveoverride alphainactive decorations settiled config-only descriptions resizewindowpixel fakefullscreen rollinglog swapactiveworkspaces submap next movewindoworgroup cursorpos forcenoanims focusworkspaceoncurrentmonitor maxsize) declare -a literals=(resizeactive 2 changegroupactive -r moveintogroup forceallowsinput 4 ::= systeminfo all layouts setprop animationstyle switchxkblayout create denywindowfromgroup headless activebordercolor exec setcursor wayland focusurgentorlast workspacerules movecurrentworkspacetomonitor movetoworkspacesilent hyprpaper alpha inactivebordercolor movegroupwindow movecursortocorner movewindowpixel prev movewindow globalshortcuts clients dimaround setignoregrouplock splash execr monitors 0 forcenoborder -q animations 1 nomaxsize splitratio moveactive pass swapnext devices layers rounding lockactivegroup 5 moveworkspacetomonitor -f -i --quiet forcenodim pin 0 1 forceopaque forcenoshadow setfloating minsize alphaoverride sendshortcut workspaces cyclenext alterzorder togglegroup lockgroups bordersize dpms focuscurrentorlast -1 --batch notify remove instances 1 3 moveoutofgroup killactive 2 movetoworkspace movecursor configerrors closewindow swapwindow tagwindow forcerendererreload centerwindow auto focuswindow seterror nofocus alphafullscreen binds version -h togglespecialworkspace fullscreen windowdancecompat 0 keyword toggleopaque 3 --instance togglefloating renameworkspace alphafullscreenoverride activeworkspace x11 kill forceopaqueoverriden output global dispatch reload forcenoblur -j event --help disable -1 activewindow keepaspectratio dismissnotify focusmonitor movefocus plugin exit workspace fullscreenstate getoption alphainactiveoverride alphainactive decorations settiled config-only descriptions resizewindowpixel fakefullscreen rollinglog swapactiveworkspaces submap next movewindoworgroup cursorpos forcenoanims focusworkspaceoncurrentmonitor maxsize sendkeystate)
declare -A literal_transitions declare -A literal_transitions
literal_transitions[0]="([120]=14 [43]=2 [125]=21 [81]=2 [3]=21 [51]=2 [50]=2 [128]=2 [89]=2 [58]=21 [8]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [102]=21 [133]=7 [100]=2 [137]=2 [22]=2 [19]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [78]=21 [114]=2 [37]=2 [151]=2 [116]=2 [121]=13 [123]=21 [39]=11 [42]=21 [79]=15 [118]=12)" literal_transitions[0]="([120]=14 [43]=2 [125]=21 [81]=2 [3]=21 [51]=2 [50]=2 [128]=2 [89]=2 [58]=21 [8]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [102]=21 [133]=7 [100]=2 [137]=2 [22]=2 [19]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [78]=21 [114]=2 [37]=2 [151]=2 [116]=2 [121]=13 [123]=21 [39]=11 [42]=21 [79]=15 [118]=12)"
literal_transitions[1]="([81]=2 [51]=2 [50]=2 [128]=2 [8]=2 [89]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [133]=7 [100]=2 [22]=2 [19]=2 [137]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [114]=2 [37]=2 [151]=2 [116]=2 [39]=11 [118]=12 [121]=13 [120]=14 [79]=15 [43]=2)" literal_transitions[1]="([81]=2 [51]=2 [50]=2 [128]=2 [8]=2 [89]=2 [10]=2 [11]=3 [130]=4 [13]=5 [97]=6 [101]=2 [133]=7 [100]=2 [22]=2 [19]=2 [137]=2 [140]=8 [25]=2 [143]=2 [107]=9 [146]=10 [69]=2 [33]=2 [34]=2 [114]=2 [37]=2 [151]=2 [116]=2 [39]=11 [118]=12 [121]=13 [120]=14 [79]=15 [43]=2)"

View file

@ -29,7 +29,7 @@ function _hyprctl
set COMP_CWORD (count $COMP_WORDS) set COMP_CWORD (count $COMP_WORDS)
end end
set literals "resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize" set literals "resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize" "sendkeystate"
set descriptions set descriptions
set descriptions[1] "Resize the active window" set descriptions[1] "Resize the active window"
@ -48,7 +48,7 @@ function _hyprctl
set descriptions[22] "Focus the urgent window or the last window" set descriptions[22] "Focus the urgent window or the last window"
set descriptions[23] "Get the list of defined workspace rules" set descriptions[23] "Get the list of defined workspace rules"
set descriptions[24] "Move the active workspace to a monitor" set descriptions[24] "Move the active workspace to a monitor"
set descriptions[25] "Move window doesnt switch to the workspace" set descriptions[25] "Move window doesn't switch to the workspace"
set descriptions[26] "Interact with hyprpaper if present" set descriptions[26] "Interact with hyprpaper if present"
set descriptions[29] "Swap the active window with the next or previous in a group" set descriptions[29] "Swap the active window with the next or previous in a group"
set descriptions[30] "Move the cursor to the corner of the active window" set descriptions[30] "Move the cursor to the corner of the active window"

View file

@ -1,4 +1,4 @@
# This is a file feeded to complgen to generate bash/fish/zsh completions # This is a file fed to complgen to generate bash/fish/zsh completions
# Repo: https://github.com/adaszko/complgen # 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" # Generate completion scripts: "complgen aot --bash-script hyprctl.bash --fish-script hyprctl.fish --zsh-script hyprctl.zsh ./hyprctl.usage"
@ -106,11 +106,12 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
| (execr) "Execute a raw shell command" | (execr) "Execute a raw shell command"
| (pass) "Pass the key to a specified window" | (pass) "Pass the key to a specified window"
| (sendshortcut) "On shortcut X sends shortcut Y to a specified window" | (sendshortcut) "On shortcut X sends shortcut Y to a specified window"
| (sendkeystate) "Send a key with specific state (down/repeat/up) to a specified window (window must keep focus for events to continue)"
| (killactive) "Close the active window" | (killactive) "Close the active window"
| (closewindow) "Close a specified window" | (closewindow) "Close a specified window"
| (workspace) "Change the workspace" | (workspace) "Change the workspace"
| (movetoworkspace) "Move the focused window to a workspace" | (movetoworkspace) "Move the focused window to a workspace"
| (movetoworkspacesilent) "Move window doesnt switch to the workspace" | (movetoworkspacesilent) "Move window doesn't switch to the workspace"
| (togglefloating) "Toggle the current window's floating state" | (togglefloating) "Toggle the current window's floating state"
| (setfloating) "Set the current window's floating state to true" | (setfloating) "Set the current window's floating state to true"
| (settiled) "Set the current window's floating state to false" | (settiled) "Set the current window's floating state to false"

View file

@ -17,7 +17,7 @@ _hyprctl_cmd_0 () {
} }
_hyprctl () { _hyprctl () {
local -a literals=("resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize") local -a literals=("resizeactive" "2" "changegroupactive" "-r" "moveintogroup" "forceallowsinput" "4" "::=" "systeminfo" "all" "layouts" "setprop" "animationstyle" "switchxkblayout" "create" "denywindowfromgroup" "headless" "activebordercolor" "exec" "setcursor" "wayland" "focusurgentorlast" "workspacerules" "movecurrentworkspacetomonitor" "movetoworkspacesilent" "hyprpaper" "alpha" "inactivebordercolor" "movegroupwindow" "movecursortocorner" "movewindowpixel" "prev" "movewindow" "globalshortcuts" "clients" "dimaround" "setignoregrouplock" "splash" "execr" "monitors" "0" "forcenoborder" "-q" "animations" "1" "nomaxsize" "splitratio" "moveactive" "pass" "swapnext" "devices" "layers" "rounding" "lockactivegroup" "5" "moveworkspacetomonitor" "-f" "-i" "--quiet" "forcenodim" "pin" "0" "1" "forceopaque" "forcenoshadow" "setfloating" "minsize" "alphaoverride" "sendshortcut" "workspaces" "cyclenext" "alterzorder" "togglegroup" "lockgroups" "bordersize" "dpms" "focuscurrentorlast" "-1" "--batch" "notify" "remove" "instances" "1" "3" "moveoutofgroup" "killactive" "2" "movetoworkspace" "movecursor" "configerrors" "closewindow" "swapwindow" "tagwindow" "forcerendererreload" "centerwindow" "auto" "focuswindow" "seterror" "nofocus" "alphafullscreen" "binds" "version" "-h" "togglespecialworkspace" "fullscreen" "windowdancecompat" "0" "keyword" "toggleopaque" "3" "--instance" "togglefloating" "renameworkspace" "alphafullscreenoverride" "activeworkspace" "x11" "kill" "forceopaqueoverriden" "output" "global" "dispatch" "reload" "forcenoblur" "-j" "event" "--help" "disable" "-1" "activewindow" "keepaspectratio" "dismissnotify" "focusmonitor" "movefocus" "plugin" "exit" "workspace" "fullscreenstate" "getoption" "alphainactiveoverride" "alphainactive" "decorations" "settiled" "config-only" "descriptions" "resizewindowpixel" "fakefullscreen" "rollinglog" "swapactiveworkspaces" "submap" "next" "movewindoworgroup" "cursorpos" "forcenoanims" "focusworkspaceoncurrentmonitor" "maxsize" "sendkeystate")
local -A descriptions local -A descriptions
descriptions[1]="Resize the active window" descriptions[1]="Resize the active window"
@ -36,7 +36,7 @@ _hyprctl () {
descriptions[22]="Focus the urgent window or the last window" descriptions[22]="Focus the urgent window or the last window"
descriptions[23]="Get the list of defined workspace rules" descriptions[23]="Get the list of defined workspace rules"
descriptions[24]="Move the active workspace to a monitor" descriptions[24]="Move the active workspace to a monitor"
descriptions[25]="Move window doesnt switch to the workspace" descriptions[25]="Move window doesn't switch to the workspace"
descriptions[26]="Interact with hyprpaper if present" descriptions[26]="Interact with hyprpaper if present"
descriptions[29]="Swap the active window with the next or previous in a group" descriptions[29]="Swap the active window with the next or previous in a group"
descriptions[30]="Move the cursor to the corner of the active window" descriptions[30]="Move the cursor to the corner of the active window"

View file

@ -1,27 +0,0 @@
executable(
'hyprctl',
'main.cpp',
dependencies: [
dependency('hyprutils', version: '>= 0.1.1'),
dependency('re2', required: true)
],
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

@ -49,6 +49,7 @@ commands:
the same format as in colors in config. Will reset the same format as in colors in config. Will reset
when Hyprland's config is reloaded when Hyprland's config is reloaded
setprop ... Sets a window property setprop ... Sets a window property
getprop ... Gets a window property
splash Get the current splash splash Get the current splash
switchxkblayout ... Sets the xkb layout index for a keyboard switchxkblayout ... Sets the xkb layout index for a keyboard
systeminfo Get system info systeminfo Get system info
@ -73,11 +74,8 @@ flags:
const std::string_view HYPRPAPER_HELP = R"#(usage: hyprctl [flags] hyprpaper <request> const std::string_view HYPRPAPER_HELP = R"#(usage: hyprctl [flags] hyprpaper <request>
requests: requests:
listactive Lists all active images wallpaper Issue a wallpaper to call a config wallpaper dynamically.
listloaded Lists all loaded images Arguments are [mon],[path],[fit_mode]. Fit mode is optional.
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: flags:
See 'hyprctl --help')#"; See 'hyprctl --help')#";
@ -146,7 +144,7 @@ regex:
Regular expression by which a window will be searched Regular expression by which a window will be searched
property: property:
See https://wiki.hyprland.org/Configuring/Using-hyprctl/#setprop for list See https://wiki.hypr.land/Configuring/Using-hyprctl/#setprop for list
of properties of properties
value: value:
@ -159,6 +157,18 @@ lock:
flags: flags:
See 'hyprctl --help')#"; See 'hyprctl --help')#";
const std::string_view GETPROP_HELP = R"#(usage: hyprctl [flags] getprop <regex> <property>
regex:
Regular expression by which a window will be searched
property:
See https://wiki.hypr.land/Configuring/Using-hyprctl/#setprop for list
of properties
flags:
See 'hyprctl --help')#";
const std::string_view SWITCHXKBLAYOUT_HELP = R"#(usage: [flags] switchxkblayout <device> <cmd> const std::string_view SWITCHXKBLAYOUT_HELP = R"#(usage: [flags] switchxkblayout <device> <cmd>
device: device:

View file

@ -0,0 +1,11 @@
#pragma once
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprutils/memory/UniquePtr.hpp>
#include <hyprutils/memory/Atomic.hpp>
using namespace Hyprutils::Memory;
#define SP CSharedPointer
#define WP CWeakPointer
#define UP CUniquePointer

View file

@ -0,0 +1,208 @@
#include "Hyprpaper.hpp"
#include "../helpers/Memory.hpp"
#include <optional>
#include <format>
#include <filesystem>
#include <print>
#include <hyprpaper_core-client.hpp>
#include <hyprutils/string/VarList2.hpp>
using namespace Hyprutils::String;
using namespace std::string_literals;
constexpr const char* SOCKET_NAME = ".hyprpaper.sock";
static SP<CCHyprpaperCoreImpl> g_coreImpl;
constexpr const uint32_t PROTOCOL_VERSION_SUPPORTED = 2;
//
static hyprpaperCoreWallpaperFitMode fitFromString(const std::string_view& sv) {
if (sv == "contain")
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_CONTAIN;
if (sv == "fit" || sv == "stretch")
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_STRETCH;
if (sv == "tile")
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_TILE;
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_COVER;
}
static std::expected<std::string, std::string> resolvePath(const std::string_view& sv) {
std::error_code ec;
auto can = std::filesystem::canonical(sv, ec);
if (ec)
return std::unexpected(std::format("invalid path: {}", ec.message()));
return can;
}
static std::expected<std::string, std::string> getFullPath(const std::string_view& sv) {
if (sv.empty())
return std::unexpected("empty path");
if (sv[0] == '~') {
static auto HOME = getenv("HOME");
if (!HOME || HOME[0] == '\0')
return std::unexpected("home path but no $HOME");
return resolvePath(std::string{HOME} + "/"s + std::string{sv.substr(1)});
}
return resolvePath(sv);
}
static std::expected<void, std::string> doWallpaper(const std::string_view& RHS) {
CVarList2 args(std::string{RHS}, 0, ',');
const std::string MONITOR = std::string{args[0]};
const auto& PATH_RAW = args[1];
const auto& FIT = args[2];
if (PATH_RAW.empty())
return std::unexpected("not enough args");
const auto RTDIR = getenv("XDG_RUNTIME_DIR");
if (!RTDIR || RTDIR[0] == '\0')
return std::unexpected("can't send: no XDG_RUNTIME_DIR");
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!HIS || HIS[0] == '\0')
return std::unexpected("can't send: no HYPRLAND_INSTANCE_SIGNATURE (not running under hyprland)");
const auto PATH = getFullPath(PATH_RAW);
if (!PATH)
return std::unexpected(std::format("bad path: {}", PATH_RAW));
auto socketPath = RTDIR + "/hypr/"s + HIS + "/"s + SOCKET_NAME;
auto socket = Hyprwire::IClientSocket::open(socketPath);
if (!socket)
return std::unexpected("can't send: failed to connect to hyprpaper (is it running?)");
g_coreImpl = makeShared<CCHyprpaperCoreImpl>(PROTOCOL_VERSION_SUPPORTED);
socket->addImplementation(g_coreImpl);
if (!socket->waitForHandshake())
return std::unexpected("can't send: wire handshake failed");
auto spec = socket->getSpec(g_coreImpl->protocol()->specName());
if (!spec)
return std::unexpected("can't send: hyprpaper doesn't have the spec?!");
auto manager = makeShared<CCHyprpaperCoreManagerObject>(socket->bindProtocol(g_coreImpl->protocol(), std::min(PROTOCOL_VERSION_SUPPORTED, spec->specVer())));
if (!manager)
return std::unexpected("wire error: couldn't create manager");
auto wallpaper = makeShared<CCHyprpaperWallpaperObject>(manager->sendGetWallpaperObject());
if (!wallpaper)
return std::unexpected("wire error: couldn't create wallpaper object");
bool canExit = false;
std::optional<std::string> err;
wallpaper->setFailed([&canExit, &err](uint32_t code) {
canExit = true;
switch (code) {
case HYPRPAPER_CORE_APPLYING_ERROR_INVALID_PATH: err = std::format("failed to set wallpaper: Invalid path", code); break;
case HYPRPAPER_CORE_APPLYING_ERROR_INVALID_MONITOR: err = std::format("failed to set wallpaper: Invalid monitor", code); break;
default: err = std::format("failed to set wallpaper: unknown error, code {}", code); break;
}
});
wallpaper->setSuccess([&canExit]() { canExit = true; });
wallpaper->sendPath(PATH->c_str());
wallpaper->sendMonitorName(MONITOR.c_str());
if (!FIT.empty())
wallpaper->sendFitMode(fitFromString(FIT));
wallpaper->sendApply();
while (!canExit) {
socket->dispatchEvents(true);
}
if (err)
return std::unexpected(*err);
return {};
}
static std::expected<void, std::string> doListActive() {
const auto RTDIR = getenv("XDG_RUNTIME_DIR");
if (!RTDIR || RTDIR[0] == '\0')
return std::unexpected("can't send: no XDG_RUNTIME_DIR");
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!HIS || HIS[0] == '\0')
return std::unexpected("can't send: no HYPRLAND_INSTANCE_SIGNATURE (not running under hyprland)");
auto socketPath = RTDIR + "/hypr/"s + HIS + "/"s + SOCKET_NAME;
auto socket = Hyprwire::IClientSocket::open(socketPath);
if (!socket)
return std::unexpected("can't send: failed to connect to hyprpaper (is it running?)");
g_coreImpl = makeShared<CCHyprpaperCoreImpl>(PROTOCOL_VERSION_SUPPORTED);
socket->addImplementation(g_coreImpl);
if (!socket->waitForHandshake())
return std::unexpected("can't send: wire handshake failed");
auto spec = socket->getSpec(g_coreImpl->protocol()->specName());
if (!spec)
return std::unexpected("can't send: hyprpaper doesn't have the spec?!");
if (spec->specVer() < 2)
return std::unexpected("can't send: hyprpaper protocol version too low (hyprpaper too old)");
auto manager = makeShared<CCHyprpaperCoreManagerObject>(socket->bindProtocol(g_coreImpl->protocol(), std::min(PROTOCOL_VERSION_SUPPORTED, spec->specVer())));
if (!manager)
return std::unexpected("wire error: couldn't create manager");
auto status = makeShared<CCHyprpaperStatusObject>(manager->sendGetStatusObject());
status->setActiveWallpaper([](const char* mon, const char* wp) { std::println("{}: {}", mon, wp); });
socket->roundtrip();
return {};
}
std::expected<void, std::string> Hyprpaper::makeHyprpaperRequest(const std::string_view& rq) {
if (!rq.contains(' '))
return std::unexpected("Invalid request");
if (!rq.starts_with("/hyprpaper "))
return std::unexpected("Invalid request");
std::string_view LHS, RHS;
auto spacePos = rq.find(' ', 12);
LHS = rq.substr(11, spacePos - 11);
RHS = rq.substr(spacePos + 1);
if (LHS == "wallpaper")
return doWallpaper(RHS);
else if (LHS == "listactive")
return doListActive();
else
return std::unexpected("invalid hyprpaper request");
return {};
}

View file

@ -0,0 +1,8 @@
#pragma once
#include <expected>
#include <string>
namespace Hyprpaper {
std::expected<void, std::string> makeHyprpaperRequest(const std::string_view& rq);
};

View file

@ -14,6 +14,9 @@
#include <unistd.h> #include <unistd.h>
#include <algorithm> #include <algorithm>
#include <csignal> #include <csignal>
#include <ranges>
#include <optional>
#include <charconv>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -23,11 +26,12 @@
#include <filesystem> #include <filesystem>
#include <cstdarg> #include <cstdarg>
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::String; using namespace Hyprutils::String;
using namespace Hyprutils::Memory;
#include "Strings.hpp" #include "Strings.hpp"
#include "hyprpaper/Hyprpaper.hpp"
#define PAD
std::string instanceSignature; std::string instanceSignature;
bool quiet = false; bool quiet = false;
@ -37,10 +41,9 @@ struct SInstanceData {
uint64_t time; uint64_t time;
uint64_t pid; uint64_t pid;
std::string wlSocket; std::string wlSocket;
bool valid = true;
}; };
void log(const std::string& str) { void log(const std::string_view str) {
if (quiet) if (quiet)
return; return;
@ -64,47 +67,74 @@ std::string getRuntimeDir() {
return std::string{XDG} + "/hypr"; return std::string{XDG} + "/hypr";
} }
static std::optional<uint64_t> toUInt64(const std::string_view str) {
uint64_t value = 0;
const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), value);
if (ec != std::errc() || ptr != str.data() + str.size())
return std::nullopt;
return value;
}
static std::optional<SInstanceData> parseInstance(const std::filesystem::directory_entry& entry) {
if (!entry.is_directory())
return std::nullopt;
const auto lockPath = entry.path() / "hyprland.lock";
std::ifstream ifs(lockPath);
if (!ifs.is_open())
return std::nullopt;
SInstanceData data;
data.id = entry.path().filename().string();
const auto first = std::string_view{data.id}.find_first_of('_');
const auto last = std::string_view{data.id}.find_last_of('_');
if (first == std::string_view::npos || last == std::string_view::npos || last <= first)
return std::nullopt;
auto time = toUInt64(std::string_view{data.id}.substr(first + 1, last - first - 1));
if (!time)
return std::nullopt;
data.time = *time;
std::string line;
if (!std::getline(ifs, line))
return std::nullopt;
auto pid = toUInt64(std::string_view{line});
if (!pid)
return std::nullopt;
data.pid = *pid;
if (!std::getline(ifs, data.wlSocket))
return std::nullopt;
if (std::getline(ifs, line) && !line.empty())
return std::nullopt; // more lines than expected
return data;
}
std::vector<SInstanceData> instances() { std::vector<SInstanceData> instances() {
std::vector<SInstanceData> result; std::vector<SInstanceData> result;
try { std::error_code ec;
if (!std::filesystem::exists(getRuntimeDir())) const auto runtimeDir = getRuntimeDir();
return {}; if (!std::filesystem::exists(runtimeDir, ec) || ec)
} catch (std::exception& e) { return {}; } return result;
for (const auto& el : std::filesystem::directory_iterator(getRuntimeDir())) { std::filesystem::directory_iterator it(runtimeDir, std::filesystem::directory_options::skip_permission_denied, ec);
if (!el.is_directory() || !std::filesystem::exists(el.path().string() + "/hyprland.lock")) if (ec)
continue; return result;
// read lock for (const auto& el : it) {
SInstanceData* data = &result.emplace_back(); if (auto instance = parseInstance(el))
data->id = el.path().filename().string(); result.emplace_back(std::move(*instance));
try {
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() + "/hyprland.lock");
int i = 0;
for (std::string line; std::getline(ifs, line); ++i) {
if (i == 0) {
try {
data->pid = std::stoull(line);
} catch (std::exception& e) { continue; }
} else if (i == 1) {
data->wlSocket = line;
} else
break;
}
ifs.close();
} }
std::erase_if(result, [&](const auto& el) { return kill(el.pid, 0) != 0 && errno == ESRCH; }); std::erase_if(result, [](const auto& el) { return kill(el.pid, 0) != 0 && errno == ESRCH; });
std::sort(result.begin(), result.end(), [&](const auto& a, const auto& b) { return a.time < b.time; }); std::ranges::sort(result, {}, &SInstanceData::time);
return result; return result;
} }
@ -146,7 +176,7 @@ int rollingRead(const int socket) {
return 0; return 0;
} }
int request(std::string arg, int minArgs = 0, bool needRoll = false) { int request(std::string_view arg, int minArgs = 0, bool needRoll = false) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) { if (SERVERSOCKET < 0) {
@ -172,21 +202,19 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
return 3; return 3;
} }
const std::string USERID = std::to_string(getUID()); sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.socket.sock"; std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.socket.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
log("Couldn't connect to " + socketPath + ". (4)"); log("Couldn't connect to " + socketPath + ". (4)");
return 4; return 4;
} }
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length()); auto sizeWritten = write(SERVERSOCKET, arg.data(), arg.size());
if (sizeWritten < 0) { if (sizeWritten < 0) {
log("Couldn't write (5)"); log("Couldn't write (5)");
@ -200,23 +228,23 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
constexpr size_t BUFFER_SIZE = 8192; constexpr size_t BUFFER_SIZE = 8192;
char buffer[BUFFER_SIZE] = {0}; char buffer[BUFFER_SIZE] = {0};
sizeWritten = read(SERVERSOCKET, buffer, BUFFER_SIZE); // read all data until server closes the connection
// this handles partial writes on the server side under high load
if (sizeWritten < 0) { while (true) {
if (errno == EWOULDBLOCK)
log("Hyprland IPC didn't respond in time\n");
log("Couldn't read (6)");
return 6;
}
reply += std::string(buffer, sizeWritten);
while (sizeWritten == BUFFER_SIZE) {
sizeWritten = read(SERVERSOCKET, buffer, BUFFER_SIZE); sizeWritten = read(SERVERSOCKET, buffer, BUFFER_SIZE);
if (sizeWritten < 0) { if (sizeWritten < 0) {
if (errno == EWOULDBLOCK)
log("Hyprland IPC didn't respond in time\n");
log("Couldn't read (6)"); log("Couldn't read (6)");
return 6; return 6;
} }
if (sizeWritten == 0) {
// server closed connection, we're done
break;
}
reply += std::string(buffer, sizeWritten); reply += std::string(buffer, sizeWritten);
} }
@ -227,7 +255,7 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
return 0; return 0;
} }
int requestIPC(std::string filename, std::string arg) { int requestIPC(std::string_view filename, std::string_view arg) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) { if (SERVERSOCKET < 0) {
@ -243,13 +271,11 @@ int requestIPC(std::string filename, std::string arg) {
sockaddr_un serverAddress = {0}; sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX; serverAddress.sun_family = AF_UNIX;
const std::string USERID = std::to_string(getUID()); std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/" + filename;
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/" + filename;
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1); strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
log("Couldn't connect to " + socketPath + ". (3)"); log("Couldn't connect to " + socketPath + ". (3)");
return 3; return 3;
} }
@ -257,7 +283,7 @@ int requestIPC(std::string filename, std::string arg) {
arg = arg.substr(arg.find_first_of('/') + 1); // strip flags arg = arg.substr(arg.find_first_of('/') + 1); // strip flags
arg = arg.substr(arg.find_first_of(' ') + 1); // strip "hyprpaper" arg = arg.substr(arg.find_first_of(' ') + 1); // strip "hyprpaper"
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length()); auto sizeWritten = write(SERVERSOCKET, arg.data(), arg.size());
if (sizeWritten < 0) { if (sizeWritten < 0) {
log("Couldn't write (4)"); log("Couldn't write (4)");
@ -280,16 +306,12 @@ int requestIPC(std::string filename, std::string arg) {
return 0; return 0;
} }
int requestHyprpaper(std::string arg) { int requestHyprsunset(std::string_view arg) {
return requestIPC(".hyprpaper.sock", arg);
}
int requestHyprsunset(std::string arg) {
return requestIPC(".hyprsunset.sock", arg); return requestIPC(".hyprsunset.sock", arg);
} }
void batchRequest(std::string arg, bool json) { void batchRequest(std::string_view arg, bool json) {
std::string commands = arg.substr(arg.find_first_of(' ') + 1); std::string commands(arg.substr(arg.find_first_of(' ') + 1));
if (json) { if (json) {
RE2::GlobalReplace(&commands, ";\\s*", ";j/"); RE2::GlobalReplace(&commands, ";\\s*", ";j/");
@ -360,7 +382,7 @@ int main(int argc, char** argv) {
parseArgs = false; parseArgs = false;
continue; continue;
} }
if (parseArgs && (ARGS[i][0] == '-') && !isNumber(ARGS[i], true) /* For stuff like -2 */) { if (parseArgs && (ARGS[i][0] == '-') && !(isNumber(ARGS[i], true) || isNumber(ARGS[i].substr(0, ARGS[i].length() - 1), true)) /* For stuff like -2 or -2, */) {
// parse // parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) { if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j"; fullArgs += "j";
@ -402,6 +424,8 @@ int main(int argc, char** argv) {
std::println("{}", PLUGIN_HELP); std::println("{}", PLUGIN_HELP);
} else if (cmd == "setprop") { } else if (cmd == "setprop") {
std::println("{}", SETPROP_HELP); std::println("{}", SETPROP_HELP);
} else if (cmd == "getprop") {
std::println("{}", GETPROP_HELP);
} else if (cmd == "switchxkblayout") { } else if (cmd == "switchxkblayout") {
std::println("{}", SWITCHXKBLAYOUT_HELP); std::println("{}", SWITCHXKBLAYOUT_HELP);
} else { } else {
@ -452,7 +476,7 @@ int main(int argc, char** argv) {
const auto INSTANCES = instances(); const auto INSTANCES = instances();
if (INSTANCENO < 0 || static_cast<std::size_t>(INSTANCENO) >= INSTANCES.size()) { if (INSTANCENO < 0 || sc<std::size_t>(INSTANCENO) >= INSTANCES.size()) {
log("no such instance\n"); log("no such instance\n");
return 1; return 1;
} }
@ -473,9 +497,12 @@ int main(int argc, char** argv) {
if (fullRequest.contains("/--batch")) if (fullRequest.contains("/--batch"))
batchRequest(fullRequest, json); batchRequest(fullRequest, json);
else if (fullRequest.contains("/hyprpaper")) else if (fullRequest.contains("/hyprpaper")) {
exitStatus = requestHyprpaper(fullRequest); auto result = Hyprpaper::makeHyprpaperRequest(fullRequest);
else if (fullRequest.contains("/hyprsunset")) if (!result)
log(std::format("error: {}", result.error()));
exitStatus = !result;
} else if (fullRequest.contains("/hyprsunset"))
exitStatus = requestHyprsunset(fullRequest); exitStatus = requestHyprsunset(fullRequest);
else if (fullRequest.contains("/switchxkblayout")) else if (fullRequest.contains("/switchxkblayout"))
exitStatus = request(fullRequest, 2); exitStatus = request(fullRequest, 2);

View file

@ -4,4 +4,5 @@ Name: Hyprland
URL: https://github.com/hyprwm/Hyprland URL: https://github.com/hyprwm/Hyprland
Description: Hyprland header files Description: Hyprland header files
Version: @HYPRLAND_VERSION@ Version: @HYPRLAND_VERSION@
Requires: aquamarine >= @AQUAMARINE_MINIMUM_VERSION@, hyprcursor >= @HYPRCURSOR_MINIMUM_VERSION@, hyprgraphics >= @HYPRGRAPHICS_MINIMUM_VERSION@, hyprlang >= @HYPRLANG_MINIMUM_VERSION@, hyprutils >= @HYPRUTILS_MINIMUM_VERSION@, libdrm, egl, cairo, xkbcommon >= @XKBCOMMON_MINIMUM_VERSION@, libinput >= @LIBINPUT_MINIMUM_VERSION@, wayland-server >= @WAYLAND_SERVER_MINIMUM_VERSION@@PKGCONFIG_XWAYLAND_DEPENDENCIES@
Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland

View file

@ -9,11 +9,11 @@ file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.2.4) pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.7.0)
find_package(glaze QUIET) find_package(glaze 6.0.1 QUIET)
if (NOT glaze_FOUND) if (NOT glaze_FOUND)
set(GLAZE_VERSION v4.2.3) set(GLAZE_VERSION v6.0.1)
message(STATUS "glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent") message(STATUS "glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent")
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
@ -21,6 +21,7 @@ if (NOT glaze_FOUND)
GIT_REPOSITORY https://github.com/stephenberry/glaze.git GIT_REPOSITORY https://github.com/stephenberry/glaze.git
GIT_TAG ${GLAZE_VERSION} GIT_TAG ${GLAZE_VERSION}
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL
) )
FetchContent_MakeAvailable(glaze) FetchContent_MakeAvailable(glaze)
endif() endif()

View file

@ -29,8 +29,8 @@ function _hyprpm
set descriptions[6] "Show help menu" set descriptions[6] "Show help menu"
set descriptions[7] "Check and update all plugins if needed" set descriptions[7] "Check and update all plugins if needed"
set descriptions[8] "Install a new plugin repository from git" set descriptions[8] "Install a new plugin repository from git"
set descriptions[9] "Enable too much loggin" set descriptions[9] "Enable too much logging"
set descriptions[10] "Enable too much loggin" set descriptions[10] "Enable too much logging"
set descriptions[11] "Force an operation ignoring checks (e.g. update -f)" set descriptions[11] "Force an operation ignoring checks (e.g. update -f)"
set descriptions[12] "Disable shallow cloning of Hyprland sources" set descriptions[12] "Disable shallow cloning of Hyprland sources"
set descriptions[13] "Remove a plugin repository" set descriptions[13] "Remove a plugin repository"

View file

@ -3,7 +3,7 @@ hyprpm [<FLAGS>]... <ARGUMENT>
<FLAGS> ::= (--notify | -n) "Send a hyprland notification for important events (e.g. load fail)" <FLAGS> ::= (--notify | -n) "Send a hyprland notification for important events (e.g. load fail)"
| (--help | -h) "Show help menu" | (--help | -h) "Show help menu"
| (--verbose | -v) "Enable too much loggin" | (--verbose | -v) "Enable too much logging"
| (--force | -f) "Force an operation ignoring checks (e.g. update -f)" | (--force | -f) "Force an operation ignoring checks (e.g. update -f)"
| (--no-shallow | -s) "Disable shallow cloning of Hyprland sources" | (--no-shallow | -s) "Disable shallow cloning of Hyprland sources"
; ;

View file

@ -19,8 +19,8 @@ _hyprpm () {
descriptions[6]="Show help menu" descriptions[6]="Show help menu"
descriptions[7]="Check and update all plugins if needed" descriptions[7]="Check and update all plugins if needed"
descriptions[8]="Install a new plugin repository from git" descriptions[8]="Install a new plugin repository from git"
descriptions[9]="Enable too much loggin" descriptions[9]="Enable too much logging"
descriptions[10]="Enable too much loggin" descriptions[10]="Enable too much logging"
descriptions[11]="Force an operation ignoring checks (e.g. update -f)" descriptions[11]="Force an operation ignoring checks (e.g. update -f)"
descriptions[12]="Disable shallow cloning of Hyprland sources" descriptions[12]="Disable shallow cloning of Hyprland sources"
descriptions[13]="Remove a plugin repository" descriptions[13]="Remove a plugin repository"

View file

@ -1,22 +1,44 @@
#include "DataState.hpp" #include "DataState.hpp"
#include <sys/stat.h>
#include <toml++/toml.hpp> #include <toml++/toml.hpp>
#include <print> #include <print>
#include <sstream>
#include <fstream> #include <fstream>
#include "PluginManager.hpp" #include "PluginManager.hpp"
#include "../helpers/Die.hpp"
#include "../helpers/Sys.hpp"
#include "../helpers/StringUtils.hpp"
std::filesystem::path DataState::getDataStatePath() { static std::string getTempRoot() {
const auto HOME = getenv("HOME"); static auto ENV = getenv("XDG_RUNTIME_DIR");
if (!HOME) { if (!ENV) {
std::println(stderr, "DataState: no $HOME"); std::cerr << "\nERROR: XDG_RUNTIME_DIR not set!\n";
throw std::runtime_error("no $HOME"); exit(1);
return "";
} }
const auto XDG_DATA_HOME = getenv("XDG_DATA_HOME"); const auto STR = ENV + std::string{"/hyprpm/"};
if (XDG_DATA_HOME) if (!std::filesystem::exists(STR))
return std::filesystem::path{XDG_DATA_HOME} / "hyprpm"; mkdir(STR.c_str(), S_IRWXU);
return std::filesystem::path{HOME} / ".local/share/hyprpm";
return STR;
}
// write the state to a file
static bool writeState(const std::string& str, const std::string& to) {
// create temp file in a safe temp root
std::ofstream of(getTempRoot() + ".temp-state", std::ios::trunc);
if (!of.good())
return false;
of << str;
of.close();
return NSys::root::install(getTempRoot() + ".temp-state", to, "644");
}
std::filesystem::path DataState::getDataStatePath() {
return std::filesystem::path("/var/cache/hyprpm/" + g_pPluginManager->m_szUsername);
} }
std::string DataState::getHeadersPath() { std::string DataState::getHeadersPath() {
@ -41,25 +63,37 @@ std::vector<std::filesystem::path> DataState::getPluginStates() {
} }
void DataState::ensureStateStoreExists() { void DataState::ensureStateStoreExists() {
const auto PATH = getDataStatePath(); std::error_code ec;
if (!std::filesystem::exists(getHeadersPath(), ec) || ec) {
if (!std::filesystem::exists(PATH)) std::println("{}", infoString("The hyprpm state store doesn't exist. Creating now..."));
std::filesystem::create_directories(PATH); if (!std::filesystem::exists("/var/cache/hyprpm/", ec) || ec) {
if (!NSys::root::createDirectory("/var/cache/hyprpm", "755"))
if (!std::filesystem::exists(getHeadersPath())) Debug::die("ensureStateStoreExists: Failed to run a superuser cmd");
std::filesystem::create_directories(getHeadersPath()); }
if (!std::filesystem::exists(getDataStatePath(), ec) || ec) {
if (!NSys::root::createDirectory(getDataStatePath().string(), "755"))
Debug::die("ensureStateStoreExists: Failed to run a superuser cmd");
}
if (!NSys::root::createDirectory(getHeadersPath(), "755"))
Debug::die("ensureStateStoreExists: Failed to run a superuser cmd");
}
} }
void DataState::addNewPluginRepo(const SPluginRepository& repo) { void DataState::addNewPluginRepo(const SPluginRepository& repo) {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath() / repo.name; const auto PATH = getDataStatePath() / repo.name;
std::filesystem::create_directories(PATH); std::error_code ec;
if (!std::filesystem::exists(PATH, ec) || ec) {
if (!NSys::root::createDirectory(PATH.string(), "755"))
Debug::die("addNewPluginRepo: failed to create cache dir");
}
// clang-format off // clang-format off
auto DATA = toml::table{ auto DATA = toml::table{
{"repository", toml::table{ {"repository", toml::table{
{"name", repo.name}, {"name", repo.name},
{"author", repo.author},
{"hash", repo.hash}, {"hash", repo.hash},
{"url", repo.url}, {"url", repo.url},
{"rev", repo.rev} {"rev", repo.rev}
@ -68,9 +102,11 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
for (auto const& p : repo.plugins) { for (auto const& p : repo.plugins) {
const auto filename = p.name + ".so"; const auto filename = p.name + ".so";
// copy .so to the good place // copy .so to the good place and chmod 755
if (std::filesystem::exists(p.filename)) if (std::filesystem::exists(p.filename)) {
std::filesystem::copy_file(p.filename, PATH / filename); if (!NSys::root::install(p.filename, (PATH / filename).string(), "0755"))
Debug::die("addNewPluginRepo: failed to install so file");
}
DATA.emplace(p.name, toml::table{ DATA.emplace(p.name, toml::table{
{"filename", filename}, {"filename", filename},
@ -80,40 +116,39 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
} }
// clang-format on // clang-format on
std::ofstream ofs(PATH / "state.toml", std::ios::trunc); std::stringstream ss;
ofs << DATA; ss << DATA;
ofs.close();
if (!writeState(ss.str(), (PATH / "state.toml").string()))
Debug::die("{}", failureString("Failed to write plugin state"));
} }
bool DataState::pluginRepoExists(const std::string& urlOrName) { bool DataState::pluginRepoExists(const SPluginRepoIdentifier identifier) {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath();
for (const auto& stateFile : getPluginStates()) { for (const auto& stateFile : getPluginStates()) {
const auto STATE = toml::parse_file(stateFile.c_str()); const auto STATE = toml::parse_file(stateFile.c_str());
const auto NAME = STATE["repository"]["name"].value_or(""); const auto NAME = STATE["repository"]["name"].value_or("");
const auto URL = STATE["repository"]["url"].value_or(""); const auto AUTHOR = STATE["repository"]["author"].value_or("");
const auto URL = STATE["repository"]["url"].value_or("");
if (URL == urlOrName || NAME == urlOrName) if (identifier.matches(URL, NAME, AUTHOR))
return true; return true;
} }
return false; return false;
} }
void DataState::removePluginRepo(const std::string& urlOrName) { void DataState::removePluginRepo(const SPluginRepoIdentifier identifier) {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath();
for (const auto& stateFile : getPluginStates()) { for (const auto& stateFile : getPluginStates()) {
const auto STATE = toml::parse_file(stateFile.c_str()); const auto STATE = toml::parse_file(stateFile.c_str());
const auto NAME = STATE["repository"]["name"].value_or(""); const auto NAME = STATE["repository"]["name"].value_or("");
const auto URL = STATE["repository"]["url"].value_or(""); const auto AUTHOR = STATE["repository"]["author"].value_or("");
const auto URL = STATE["repository"]["url"].value_or("");
if (URL == urlOrName || NAME == urlOrName) {
if (identifier.matches(URL, NAME, AUTHOR)) {
// unload the plugins!! // unload the plugins!!
for (const auto& file : std::filesystem::directory_iterator(stateFile.parent_path())) { for (const auto& file : std::filesystem::directory_iterator(stateFile.parent_path())) {
if (!file.path().string().ends_with(".so")) if (!file.path().string().ends_with(".so"))
@ -122,7 +157,14 @@ void DataState::removePluginRepo(const std::string& urlOrName) {
g_pPluginManager->loadUnloadPlugin(std::filesystem::absolute(file.path()), false); g_pPluginManager->loadUnloadPlugin(std::filesystem::absolute(file.path()), false);
} }
std::filesystem::remove_all(stateFile.parent_path()); const auto PATH = stateFile.parent_path().string();
if (!PATH.starts_with("/var/cache/hyprpm") || PATH.contains('\''))
return; // WTF?
// scary!
if (!NSys::root::removeRecursive(PATH))
Debug::die("removePluginRepo: failed to remove dir");
return; return;
} }
} }
@ -131,36 +173,43 @@ void DataState::removePluginRepo(const std::string& urlOrName) {
void DataState::updateGlobalState(const SGlobalState& state) { void DataState::updateGlobalState(const SGlobalState& state) {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath(); const auto PATH = getDataStatePath();
std::filesystem::create_directories(PATH); std::error_code ec;
if (!std::filesystem::exists(PATH, ec) || ec) {
if (!NSys::root::createDirectory(PATH.string(), "755"))
Debug::die("updateGlobalState: failed to create dir");
}
// clang-format off // clang-format off
auto DATA = toml::table{ auto DATA = toml::table{
{"state", toml::table{ {"state", toml::table{
{"hash", state.headersHashCompiled}, {"hash", state.headersAbiCompiled},
{"dont_warn_install", state.dontWarnInstall} {"dont_warn_install", state.dontWarnInstall}
}} }}
}; };
// clang-format on // clang-format on
std::ofstream ofs(PATH / "state.toml", std::ios::trunc); std::stringstream ss;
ofs << DATA; ss << DATA;
ofs.close();
if (!writeState(ss.str(), (PATH / "state.toml").string()))
Debug::die("{}", failureString("Failed to write plugin state"));
} }
SGlobalState DataState::getGlobalState() { SGlobalState DataState::getGlobalState() {
ensureStateStoreExists(); ensureStateStoreExists();
const auto stateFile = getDataStatePath() / "state.toml"; const auto stateFile = getDataStatePath() / "state.toml";
if (!std::filesystem::exists(stateFile)) std::error_code ec;
if (!std::filesystem::exists(stateFile, ec) || ec)
return SGlobalState{}; return SGlobalState{};
auto DATA = toml::parse_file(stateFile.c_str()); auto DATA = toml::parse_file(stateFile.c_str());
SGlobalState state; SGlobalState state;
state.headersHashCompiled = DATA["state"]["hash"].value_or(""); state.headersAbiCompiled = DATA["state"]["hash"].value_or("");
state.dontWarnInstall = DATA["state"]["dont_warn_install"].value_or(false); state.dontWarnInstall = DATA["state"]["dont_warn_install"].value_or(false);
return state; return state;
} }
@ -168,22 +217,22 @@ SGlobalState DataState::getGlobalState() {
std::vector<SPluginRepository> DataState::getAllRepositories() { std::vector<SPluginRepository> DataState::getAllRepositories() {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath();
std::vector<SPluginRepository> repos; std::vector<SPluginRepository> repos;
for (const auto& stateFile : getPluginStates()) { for (const auto& stateFile : getPluginStates()) {
const auto STATE = toml::parse_file(stateFile.c_str()); const auto STATE = toml::parse_file(stateFile.c_str());
const auto NAME = STATE["repository"]["name"].value_or(""); const auto NAME = STATE["repository"]["name"].value_or("");
const auto URL = STATE["repository"]["url"].value_or(""); const auto AUTHOR = STATE["repository"]["author"].value_or("");
const auto REV = STATE["repository"]["rev"].value_or(""); const auto URL = STATE["repository"]["url"].value_or("");
const auto HASH = STATE["repository"]["hash"].value_or(""); const auto REV = STATE["repository"]["rev"].value_or("");
const auto HASH = STATE["repository"]["hash"].value_or("");
SPluginRepository repo; SPluginRepository repo;
repo.hash = HASH; repo.hash = HASH;
repo.name = NAME; repo.name = NAME;
repo.url = URL; repo.author = AUTHOR;
repo.rev = REV; repo.url = URL;
repo.rev = REV;
for (const auto& [key, val] : STATE) { for (const auto& [key, val] : STATE) {
if (key == "repository") if (key == "repository")
@ -202,19 +251,26 @@ std::vector<SPluginRepository> DataState::getAllRepositories() {
return repos; return repos;
} }
bool DataState::setPluginEnabled(const std::string& name, bool enabled) { bool DataState::setPluginEnabled(const SPluginRepoIdentifier identifier, bool enabled) {
ensureStateStoreExists(); ensureStateStoreExists();
const auto PATH = getDataStatePath();
for (const auto& stateFile : getPluginStates()) { for (const auto& stateFile : getPluginStates()) {
const auto STATE = toml::parse_file(stateFile.c_str()); const auto STATE = toml::parse_file(stateFile.c_str());
for (const auto& [key, val] : STATE) { for (const auto& [key, val] : STATE) {
if (key == "repository") if (key == "repository")
continue; continue;
if (key.str() != name) switch (identifier.type) {
continue; case IDENTIFIER_NAME:
if (key.str() != identifier.name)
continue;
break;
case IDENTIFIER_AUTHOR_NAME:
if (STATE["repository"]["author"] != identifier.author || key.str() != identifier.name)
continue;
break;
default: return false;
}
const auto FAILED = STATE[key]["failed"].value_or(false); const auto FAILED = STATE[key]["failed"].value_or(false);
@ -224,9 +280,11 @@ bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
auto modifiedState = STATE; auto modifiedState = STATE;
(*modifiedState[key].as_table()).insert_or_assign("enabled", enabled); (*modifiedState[key].as_table()).insert_or_assign("enabled", enabled);
std::ofstream state(stateFile, std::ios::trunc); std::stringstream ss;
state << modifiedState; ss << modifiedState;
state.close();
if (!writeState(ss.str(), stateFile.string()))
Debug::die("{}", failureString("Failed to write plugin state"));
return true; return true;
} }
@ -234,3 +292,18 @@ bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
return false; return false;
} }
void DataState::purgeAllCache() {
std::error_code ec;
if (!std::filesystem::exists(getDataStatePath()) && !ec) {
std::println("{}", infoString("Nothing to do"));
return;
}
const auto PATH = getDataStatePath().string();
if (PATH.contains('\''))
return;
// scary!
if (!NSys::root::removeRecursive(PATH))
Debug::die("Failed to run a superuser cmd");
}

View file

@ -5,8 +5,8 @@
#include "Plugin.hpp" #include "Plugin.hpp"
struct SGlobalState { struct SGlobalState {
std::string headersHashCompiled = ""; std::string headersAbiCompiled = "";
bool dontWarnInstall = false; bool dontWarnInstall = false;
}; };
namespace DataState { namespace DataState {
@ -15,10 +15,11 @@ namespace DataState {
std::vector<std::filesystem::path> getPluginStates(); std::vector<std::filesystem::path> getPluginStates();
void ensureStateStoreExists(); void ensureStateStoreExists();
void addNewPluginRepo(const SPluginRepository& repo); void addNewPluginRepo(const SPluginRepository& repo);
void removePluginRepo(const std::string& urlOrName); void removePluginRepo(const SPluginRepoIdentifier identifier);
bool pluginRepoExists(const std::string& urlOrName); bool pluginRepoExists(const SPluginRepoIdentifier identifier);
void updateGlobalState(const SGlobalState& state); void updateGlobalState(const SGlobalState& state);
void purgeAllCache();
SGlobalState getGlobalState(); SGlobalState getGlobalState();
bool setPluginEnabled(const std::string& name, bool enabled); bool setPluginEnabled(const SPluginRepoIdentifier identifier, bool enabled);
std::vector<SPluginRepository> getAllRepositories(); std::vector<SPluginRepository> getAllRepositories();
}; };

View file

@ -0,0 +1,89 @@
#include "HyprlandSocket.hpp"
#include <pwd.h>
#include <sys/socket.h>
#include "../helpers/StringUtils.hpp"
#include <print>
#include <sys/un.h>
#include <unistd.h>
#include <cstring>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::Memory;
static int getUID() {
const auto UID = getuid();
const auto PWUID = getpwuid(UID);
return PWUID ? PWUID->pw_uid : UID;
}
static std::string getRuntimeDir() {
const auto XDG = getenv("XDG_RUNTIME_DIR");
if (!XDG) {
const std::string USERID = std::to_string(getUID());
return "/run/user/" + USERID + "/hypr";
}
return std::string{XDG} + "/hypr";
}
std::string NHyprlandSocket::send(const std::string& cmd) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) {
std::println("{}", failureString("Couldn't open a socket (1)"));
return "";
}
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!HIS) {
std::println("{}", failureString("HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?) (3)"));
return "";
}
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = getRuntimeDir() + "/" + HIS + "/.socket.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
std::println("{}", failureString("Couldn't connect to " + socketPath + ". (4)"));
return "";
}
auto sizeWritten = write(SERVERSOCKET, cmd.c_str(), cmd.length());
if (sizeWritten < 0) {
std::println("{}", failureString("Couldn't write (5)"));
return "";
}
std::string reply = "";
constexpr size_t BUFFER_SIZE = 8192;
char buffer[BUFFER_SIZE] = {0};
sizeWritten = read(SERVERSOCKET, buffer, BUFFER_SIZE);
if (sizeWritten < 0) {
std::println("{}", failureString("Couldn't read (6)"));
return "";
}
reply += std::string(buffer, sizeWritten);
while (sizeWritten == BUFFER_SIZE) {
sizeWritten = read(SERVERSOCKET, buffer, BUFFER_SIZE);
if (sizeWritten < 0) {
std::println("{}", failureString("Couldn't read (7)"));
return "";
}
reply += std::string(buffer, sizeWritten);
}
close(SERVERSOCKET);
return reply;
}

View file

@ -0,0 +1,7 @@
#pragma once
#include <string>
namespace NHyprlandSocket {
std::string send(const std::string& cmd);
};

View file

@ -1,6 +1,12 @@
#include "Manifest.hpp" #include "Manifest.hpp"
#include <toml++/toml.hpp> #include <toml++/toml.hpp>
#include <iostream> #include <algorithm>
// Alphanumerics and -_ allowed for plugin names. No magic names.
// [A-Za-z0-9\-_]*
static bool validManifestName(const std::string_view& n) {
return std::ranges::all_of(n, [](const char& c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-' || c == '_' || c == '=' || (c >= '0' && c <= '9'); });
}
CManifest::CManifest(const eManifestType type, const std::string& path) { CManifest::CManifest(const eManifestType type, const std::string& path) {
auto manifest = toml::parse_file(path); auto manifest = toml::parse_file(path);
@ -11,11 +17,17 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
continue; continue;
CManifest::SManifestPlugin plugin; CManifest::SManifestPlugin plugin;
if (!validManifestName(key.str())) {
m_good = false;
return;
}
plugin.name = key; plugin.name = key;
m_vPlugins.push_back(plugin); m_plugins.push_back(plugin);
} }
for (auto& plugin : m_vPlugins) { for (auto& plugin : m_plugins) {
plugin.description = manifest[plugin.name]["description"].value_or("?"); plugin.description = manifest[plugin.name]["description"].value_or("?");
plugin.version = manifest[plugin.name]["version"].value_or("?"); plugin.version = manifest[plugin.name]["version"].value_or("?");
plugin.output = manifest[plugin.name]["build"]["output"].value_or("?"); plugin.output = manifest[plugin.name]["build"]["output"].value_or("?");
@ -37,21 +49,21 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
} }
if (plugin.output.empty() || plugin.buildSteps.empty()) { if (plugin.output.empty() || plugin.buildSteps.empty()) {
m_bGood = false; m_good = false;
return; return;
} }
} }
} else if (type == MANIFEST_HYPRPM) { } else if (type == MANIFEST_HYPRPM) {
m_sRepository.name = manifest["repository"]["name"].value_or(""); m_repository.name = manifest["repository"]["name"].value_or("");
auto authors = manifest["repository"]["authors"].as_array(); auto authors = manifest["repository"]["authors"].as_array();
if (authors) { if (authors) {
for (auto&& a : *authors) { for (auto&& a : *authors) {
m_sRepository.authors.push_back(a.as_string()->value_or("?")); m_repository.authors.push_back(a.as_string()->value_or("?"));
} }
} else { } else {
auto author = manifest["repository"]["author"].value_or(""); auto author = manifest["repository"]["author"].value_or("");
if (!std::string{author}.empty()) if (!std::string{author}.empty())
m_sRepository.authors.push_back(author); m_repository.authors.push_back(author);
} }
auto pins = manifest["repository"]["commit_pins"].as_array(); auto pins = manifest["repository"]["commit_pins"].as_array();
@ -59,7 +71,7 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
for (auto&& pin : *pins) { for (auto&& pin : *pins) {
auto pinArr = pin.as_array(); auto pinArr = pin.as_array();
if (pinArr && pinArr->get(1)) if (pinArr && pinArr->get(1))
m_sRepository.commitPins.push_back(std::make_pair<>(pinArr->get(0)->as_string()->get(), pinArr->get(1)->as_string()->get())); m_repository.commitPins.push_back(std::make_pair<>(pinArr->get(0)->as_string()->get(), pinArr->get(1)->as_string()->get()));
} }
} }
@ -68,11 +80,17 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
continue; continue;
CManifest::SManifestPlugin plugin; CManifest::SManifestPlugin plugin;
if (!validManifestName(key.str())) {
m_good = false;
return;
}
plugin.name = key; plugin.name = key;
m_vPlugins.push_back(plugin); m_plugins.push_back(plugin);
} }
for (auto& plugin : m_vPlugins) { for (auto& plugin : m_plugins) {
plugin.description = manifest[plugin.name]["description"].value_or("?"); plugin.description = manifest[plugin.name]["description"].value_or("?");
plugin.output = manifest[plugin.name]["output"].value_or("?"); plugin.output = manifest[plugin.name]["output"].value_or("?");
plugin.since = manifest[plugin.name]["since_hyprland"].value_or(0); plugin.since = manifest[plugin.name]["since_hyprland"].value_or(0);
@ -94,12 +112,12 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
} }
if (plugin.output.empty() || plugin.buildSteps.empty()) { if (plugin.output.empty() || plugin.buildSteps.empty()) {
m_bGood = false; m_good = false;
return; return;
} }
} }
} else { } else {
// ??? // ???
m_bGood = false; m_good = false;
} }
} }

View file

@ -27,8 +27,8 @@ class CManifest {
std::string name; std::string name;
std::vector<std::string> authors; std::vector<std::string> authors;
std::vector<std::pair<std::string, std::string>> commitPins; std::vector<std::pair<std::string, std::string>> commitPins;
} m_sRepository; } m_repository;
std::vector<SManifestPlugin> m_vPlugins; std::vector<SManifestPlugin> m_plugins;
bool m_bGood = true; bool m_good = true;
}; };

View file

@ -0,0 +1,48 @@
#include "Plugin.hpp"
SPluginRepoIdentifier SPluginRepoIdentifier::fromUrl(const std::string& url) {
return SPluginRepoIdentifier{.type = IDENTIFIER_URL, .url = url};
}
SPluginRepoIdentifier SPluginRepoIdentifier::fromName(const std::string& name) {
return SPluginRepoIdentifier{.type = IDENTIFIER_NAME, .name = name};
}
SPluginRepoIdentifier SPluginRepoIdentifier::fromAuthorName(const std::string& author, const std::string& name) {
return SPluginRepoIdentifier{.type = IDENTIFIER_AUTHOR_NAME, .name = name, .author = author};
}
SPluginRepoIdentifier SPluginRepoIdentifier::fromString(const std::string& string) {
if (string.find(':') != std::string::npos) {
return SPluginRepoIdentifier{.type = IDENTIFIER_URL, .url = string};
} else {
auto slashPos = string.find('/');
if (slashPos != std::string::npos) {
std::string author = string.substr(0, slashPos);
std::string name = string.substr(slashPos + 1, string.size() - slashPos - 1);
return SPluginRepoIdentifier{.type = IDENTIFIER_AUTHOR_NAME, .name = name, .author = author};
} else {
return SPluginRepoIdentifier{.type = IDENTIFIER_NAME, .name = string};
}
}
}
std::string SPluginRepoIdentifier::toString() const {
switch (type) {
case IDENTIFIER_NAME: return name;
case IDENTIFIER_AUTHOR_NAME: return author + '/' + name;
case IDENTIFIER_URL: return url;
}
return "";
}
bool SPluginRepoIdentifier::matches(const std::string& url, const std::string& name, const std::string& author) const {
switch (type) {
case IDENTIFIER_URL: return this->url == url;
case IDENTIFIER_NAME: return this->name == name;
case IDENTIFIER_AUTHOR_NAME: return this->author == author && this->name == name;
}
return false;
}

View file

@ -14,6 +14,27 @@ struct SPluginRepository {
std::string url; std::string url;
std::string rev; std::string rev;
std::string name; std::string name;
std::string author;
std::vector<SPlugin> plugins; std::vector<SPlugin> plugins;
std::string hash; std::string hash;
}; };
enum ePluginRepoIdentifierType {
IDENTIFIER_URL,
IDENTIFIER_NAME,
IDENTIFIER_AUTHOR_NAME
};
struct SPluginRepoIdentifier {
ePluginRepoIdentifierType type;
std::string url = "";
std::string name = "";
std::string author = "";
static SPluginRepoIdentifier fromString(const std::string& string);
static SPluginRepoIdentifier fromUrl(const std::string& Url);
static SPluginRepoIdentifier fromName(const std::string& name);
static SPluginRepoIdentifier fromAuthorName(const std::string& author, const std::string& name);
std::string toString() const;
bool matches(const std::string& url, const std::string& name, const std::string& author) const;
};

View file

@ -4,10 +4,14 @@
#include "../progress/CProgressBar.hpp" #include "../progress/CProgressBar.hpp"
#include "Manifest.hpp" #include "Manifest.hpp"
#include "DataState.hpp" #include "DataState.hpp"
#include "HyprlandSocket.hpp"
#include "../helpers/Sys.hpp"
#include "../helpers/Die.hpp"
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
#include <string>
#include <print> #include <print>
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>
@ -23,8 +27,10 @@
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>
#include <hyprutils/os/Process.hpp> #include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::String; using namespace Hyprutils::String;
using namespace Hyprutils::OS; using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
static std::string execAndGet(std::string cmd) { static std::string execAndGet(std::string cmd) {
cmd += " 2>&1"; cmd += " 2>&1";
@ -49,6 +55,13 @@ static std::string getTempRoot() {
return STR; return STR;
} }
CPluginManager::CPluginManager() {
if (NSys::isSuperuser())
Debug::die("Don't run hyprpm as a superuser.");
m_szUsername = getpwuid(NSys::getUID())->pw_name;
}
SHyprlandVersion CPluginManager::getHyprlandVersion(bool running) { SHyprlandVersion CPluginManager::getHyprlandVersion(bool running) {
static bool onceRunning = false; static bool onceRunning = false;
static bool onceInstalled = false; static bool onceInstalled = false;
@ -66,40 +79,33 @@ SHyprlandVersion CPluginManager::getHyprlandVersion(bool running) {
else else
onceInstalled = true; onceInstalled = true;
const auto HLVERCALL = running ? execAndGet("hyprctl version") : execAndGet("Hyprland --version"); const auto HLVERCALL = running ? NHyprlandSocket::send("j/version") : execAndGet("Hyprland --version-json");
if (m_bVerbose)
std::println("{}", verboseString("{} version returned: {}", running ? "running" : "installed", HLVERCALL));
if (!HLVERCALL.contains("Tag:")) { auto jsonQuery = glz::read_json<glz::generic>(HLVERCALL);
std::println(stderr, "\n{}", failureString("You don't seem to be running Hyprland."));
if (!jsonQuery) {
std::println("{}", failureString("failed to get the current hyprland version. Are you running hyprland?"));
return SHyprlandVersion{}; return SHyprlandVersion{};
} }
std::string hlcommit = HLVERCALL.substr(HLVERCALL.find("at commit") + 10); auto hlbranch = (*jsonQuery)["branch"].get_string();
hlcommit = hlcommit.substr(0, hlcommit.find_first_of(' ')); auto hlcommit = (*jsonQuery)["commit"].get_string();
auto abiHash = (*jsonQuery)["abiHash"].get_string();
auto hldate = (*jsonQuery)["commit_date"].get_string();
auto hlcommits = (*jsonQuery)["commits"].get_string();
std::string hlbranch = HLVERCALL.substr(HLVERCALL.find("from branch") + 12); auto flags = (*jsonQuery)["flags"].get_array();
hlbranch = hlbranch.substr(0, hlbranch.find(" at commit ")); bool isNix = std::ranges::any_of(flags, [](const auto& f) { return f.is_string() && f.get_string() == std::string_view{"nix"}; });
std::string hldate = HLVERCALL.substr(HLVERCALL.find("Date: ") + 6); size_t commits = 0;
hldate = hldate.substr(0, hldate.find('\n'));
std::string hlcommits;
if (HLVERCALL.contains("commits:")) {
hlcommits = HLVERCALL.substr(HLVERCALL.find("commits:") + 9);
hlcommits = hlcommits.substr(0, hlcommits.find(' '));
}
int commits = 0;
try { try {
commits = std::stoi(hlcommits); commits = std::stoull(hlcommits);
} catch (...) { ; } } catch (...) { ; }
if (m_bVerbose) if (m_bVerbose)
std::println("{}", verboseString("parsed commit {} at branch {} on {}, commits {}", hlcommit, hlbranch, hldate, commits)); std::println("{}", verboseString("parsed commit {} at branch {} on {}, commits {}, nix: {}", hlcommit, hlbranch, hldate, commits, isNix));
auto ver = SHyprlandVersion{hlbranch, hlcommit, hldate, commits}; auto ver = SHyprlandVersion{hlbranch, hlcommit, hldate, abiHash, commits, isNix};
if (running) if (running)
verRunning = ver; verRunning = ver;
@ -125,15 +131,24 @@ bool CPluginManager::createSafeDirectory(const std::string& path) {
return true; return true;
} }
bool CPluginManager::validArg(const std::string& s) {
return !s.contains("'") && !s.ends_with("\\") && !s.starts_with("\\");
}
bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& rev) { bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& rev) {
const auto HLVER = getHyprlandVersion(); const auto HLVER = getHyprlandVersion();
if (!hasDeps()) { if (!validArg(url) || !validArg(rev)) {
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio, pkg-config")); std::println(stderr, "\n{}", failureString("url or rev invalid"));
return false; return false;
} }
if (DataState::pluginRepoExists(url)) { if (!hasDeps()) {
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, cpio, pkg-config, git, g++, gcc"));
return false;
}
if (DataState::pluginRepoExists(SPluginRepoIdentifier::fromUrl(url))) {
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Repository already installed.")); std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Repository already installed."));
return false; return false;
} }
@ -141,13 +156,18 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
auto GLOBALSTATE = DataState::getGlobalState(); auto GLOBALSTATE = DataState::getGlobalState();
if (!GLOBALSTATE.dontWarnInstall) { if (!GLOBALSTATE.dontWarnInstall) {
std::println("{}!{} Disclaimer: {}", Colors::YELLOW, Colors::RED, Colors::RESET); std::println("{}!{} Disclaimer: {}", Colors::YELLOW, Colors::RED, Colors::RESET);
std::println("plugins, especially not official, have no guarantee of stability, availablity or security.\n" std::println("plugins, especially not official, have no guarantee of stability, availability or security.\n"
"Run them at your own risk.\n" "Run them at your own risk.\n"
"This message will not appear again."); "This message will not appear again.");
GLOBALSTATE.dontWarnInstall = true; GLOBALSTATE.dontWarnInstall = true;
DataState::updateGlobalState(GLOBALSTATE); DataState::updateGlobalState(GLOBALSTATE);
} }
if (GLOBALSTATE.headersAbiCompiled.empty()) {
std::println("\n{}", failureString("Cannot find headers in the global state. Try running hyprpm update first."));
return false;
}
std::cout << Colors::GREEN << "" << Colors::RESET << Colors::RED << " adding a new plugin repository " << Colors::RESET << "from " << url << "\n " << Colors::RED std::cout << Colors::GREEN << "" << Colors::RESET << Colors::RED << " adding a new plugin repository " << Colors::RESET << "from " << url << "\n " << Colors::RED
<< "MAKE SURE" << Colors::RESET << " that you trust the authors. " << Colors::RED << "DO NOT" << Colors::RESET << "MAKE SURE" << Colors::RESET << " that you trust the authors. " << Colors::RED << "DO NOT" << Colors::RESET
<< " install random plugins without verifying the code and author.\n " << " install random plugins without verifying the code and author.\n "
@ -187,7 +207,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
progress.printMessageAbove(infoString("Cloning {}", url)); progress.printMessageAbove(infoString("Cloning {}", url));
std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), url, USERNAME)); std::string ret = execAndGet(std::format("cd {} && git clone --recursive '{}' {}", getTempRoot(), url, USERNAME));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) { if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. shell returned:\n{}", ret)); std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. shell returned:\n{}", ret));
@ -225,14 +245,14 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
return false; return false;
} }
if (!pManifest->m_bGood) { if (!pManifest->m_good) {
std::println(stderr, "\n{}", failureString("The provided plugin repository has a corrupted manifest")); std::println(stderr, "\n{}", failureString("The provided plugin repository has a corrupted manifest"));
return false; return false;
} }
progress.m_iSteps = 2; progress.m_iSteps = 2;
progress.printMessageAbove(successString("parsed manifest, found " + std::to_string(pManifest->m_vPlugins.size()) + " plugins:")); progress.printMessageAbove(successString("parsed manifest, found " + std::to_string(pManifest->m_plugins.size()) + " plugins:"));
for (auto const& pl : pManifest->m_vPlugins) { for (auto const& pl : pManifest->m_plugins) {
std::string message = "" + pl.name + " by "; std::string message = "" + pl.name + " by ";
for (auto const& a : pl.authors) { for (auto const& a : pl.authors) {
message += a + ", "; message += a + ", ";
@ -245,12 +265,12 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
progress.printMessageAbove(message); progress.printMessageAbove(message);
} }
if (!pManifest->m_sRepository.commitPins.empty()) { if (rev.empty() && !pManifest->m_repository.commitPins.empty()) {
// check commit pins // check commit pins
progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_sRepository.commitPins.size())); progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_repository.commitPins.size()));
for (auto const& [hl, plugin] : pManifest->m_sRepository.commitPins) { for (auto const& [hl, plugin] : pManifest->m_repository.commitPins) {
if (hl != HLVER.hash) if (hl != HLVER.hash)
continue; continue;
@ -273,6 +293,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
if (HEADERSSTATUS != HEADERS_OK) { if (HEADERSSTATUS != HEADERS_OK) {
std::println("\n{}", headerError(HEADERSSTATUS)); std::println("\n{}", headerError(HEADERSSTATUS));
std::println("\n{}", infoString("if the problem persists, try running hyprpm purge-cache."));
return false; return false;
} }
@ -281,7 +302,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
progress.m_szCurrentMessage = "Building plugin(s)"; progress.m_szCurrentMessage = "Building plugin(s)";
progress.print(); progress.print();
for (auto& p : pManifest->m_vPlugins) { for (auto& p : pManifest->m_plugins) {
std::string out; std::string out;
if (p.since > HLVER.commits && HLVER.commits >= 1 /* for --depth 1 clones, we can't check this. */) { if (p.since > HLVER.commits && HLVER.commits >= 1 /* for --depth 1 clones, we can't check this. */) {
@ -293,8 +314,14 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
progress.printMessageAbove(infoString("Building {}", p.name)); progress.printMessageAbove(infoString("Building {}", p.name));
for (auto const& bs : p.buildSteps) { for (auto const& bs : p.buildSteps) {
const std::string& cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs); const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && PKG_CONFIG_PATH=\"{}\" {}", m_szWorkingPluginDirectory, getPkgConfigPath(), bs), HLVER);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
if (!CMD_RAW) {
progress.printMessageAbove(failureString("Failed to build {}: {}", p.name, CMD_RAW.error()));
break;
}
out += " -> " + *CMD_RAW + "\n" + execAndGet(*CMD_RAW) + "\n";
} }
if (m_bVerbose) if (m_bVerbose)
@ -324,11 +351,14 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD"); std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
if (repohash.length() > 0) if (repohash.length() > 0)
repohash.pop_back(); repohash.pop_back();
repo.name = pManifest->m_sRepository.name.empty() ? url.substr(url.find_last_of('/') + 1) : pManifest->m_sRepository.name; auto lastSlash = url.find_last_of('/');
repo.url = url; auto secondLastSlash = url.find_last_of('/', lastSlash - 1);
repo.rev = rev; repo.name = pManifest->m_repository.name.empty() ? url.substr(lastSlash + 1) : pManifest->m_repository.name;
repo.hash = repohash; repo.author = url.substr(secondLastSlash + 1, lastSlash - secondLastSlash - 1);
for (auto const& p : pManifest->m_vPlugins) { repo.url = url;
repo.rev = rev;
repo.hash = repohash;
for (auto const& p : pManifest->m_plugins) {
repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed}); repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed});
} }
DataState::addNewPluginRepo(repo); DataState::addNewPluginRepo(repo);
@ -347,13 +377,13 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
return true; return true;
} }
bool CPluginManager::removePluginRepo(const std::string& urlOrName) { bool CPluginManager::removePluginRepo(const SPluginRepoIdentifier identifier) {
if (!DataState::pluginRepoExists(urlOrName)) { if (!DataState::pluginRepoExists(identifier)) {
std::println(stderr, "\n{}", failureString("Could not remove the repository. Repository is not installed.")); std::println(stderr, "\n{}", failureString("Could not remove the repository. Repository is not installed."));
return false; return false;
} }
std::cout << Colors::YELLOW << "!" << Colors::RESET << Colors::RED << " removing a plugin repository: " << Colors::RESET << urlOrName << "\n " std::cout << Colors::YELLOW << "!" << Colors::RESET << Colors::RED << " removing a plugin repository: " << Colors::RESET << identifier.toString() << "\n "
<< "Are you sure? [Y/n] "; << "Are you sure? [Y/n] ";
std::fflush(stdout); std::fflush(stdout);
std::string input; std::string input;
@ -364,7 +394,7 @@ bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
return false; return false;
} }
DataState::removePluginRepo(urlOrName); DataState::removePluginRepo(identifier);
return true; return true;
} }
@ -376,7 +406,7 @@ eHeadersErrors CPluginManager::headersValid() {
return HEADERS_MISSING; return HEADERS_MISSING;
// find headers commit // find headers commit
const std::string& cmd = std::format("PKG_CONFIG_PATH=\"{}/share/pkgconfig\" pkgconf --cflags --keep-system-cflags hyprland", DataState::getHeadersPath()); const std::string& cmd = std::format("PKG_CONFIG_PATH=\"{}\" pkgconf --cflags --keep-system-cflags hyprland", getPkgConfigPath());
auto headers = execAndGet(cmd); auto headers = execAndGet(cmd);
if (!headers.contains("-I/")) if (!headers.contains("-I/"))
@ -425,17 +455,22 @@ eHeadersErrors CPluginManager::headersValid() {
if (hash != HLVER.hash) if (hash != HLVER.hash)
return HEADERS_MISMATCHED; return HEADERS_MISMATCHED;
// check ABI hash too
const auto GLOBALSTATE = DataState::getGlobalState();
if (GLOBALSTATE.headersAbiCompiled != HLVER.abiHash)
return HEADERS_ABI_MISMATCH;
return HEADERS_OK; return HEADERS_OK;
} }
bool CPluginManager::updateHeaders(bool force) { bool CPluginManager::updateHeaders(bool force) {
DataState::ensureStateStoreExists(); DataState::ensureStateStoreExists();
const auto HLVER = getHyprlandVersion(false); const auto HLVER = getHyprlandVersion(false);
if (!hasDeps()) { if (!hasDeps()) {
std::println("\n{}", failureString("Could not update. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio, pkg-config")); std::println("\n{}", failureString("Could not update. Dependencies not satisfied. Hyprpm requires: cmake, cpio, pkg-config, git, g++, gcc"));
return false; return false;
} }
@ -477,11 +512,11 @@ bool CPluginManager::updateHeaders(bool force) {
progress.printMessageAbove(verboseString("will shallow since: {}", SHALLOW_DATE)); progress.printMessageAbove(verboseString("will shallow since: {}", SHALLOW_DATE));
std::string ret = std::string ret =
execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}{}", getTempRoot(), HL_URL, USERNAME, (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""))); execAndGet(std::format("cd {} && git clone --recursive '{}' hyprland-{}{}", getTempRoot(), HL_URL, USERNAME, (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : "")));
if (!std::filesystem::exists(WORKINGDIR)) { if (!std::filesystem::exists(WORKINGDIR)) {
progress.printMessageAbove(failureString("Clone failed. Retrying without shallow.")); progress.printMessageAbove(failureString("Clone failed. Retrying without shallow."));
ret = execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}", getTempRoot(), HL_URL, USERNAME)); ret = execAndGet(std::format("cd {} && git clone --recursive '{}' hyprland-{}", getTempRoot(), HL_URL, USERNAME));
} }
if (!std::filesystem::exists(WORKINGDIR + "/.git")) { if (!std::filesystem::exists(WORKINGDIR + "/.git")) {
@ -524,8 +559,17 @@ bool CPluginManager::updateHeaders(bool force) {
if (m_bVerbose) if (m_bVerbose)
progress.printMessageAbove(verboseString("setting PREFIX for cmake to {}", DataState::getHeadersPath())); progress.printMessageAbove(verboseString("setting PREFIX for cmake to {}", 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, const auto CONFIGURE_CMD =
DataState::getHeadersPath())); nixDevelopIfNeeded(std::format("cd {} && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=\"{}\" -S . -B ./build", WORKINGDIR,
DataState::getHeadersPath()),
HLVER);
if (!CONFIGURE_CMD) {
std::println(stderr, "\n{}", failureString("Could not configure hyprland: {}", CONFIGURE_CMD.error()));
return false;
}
ret = execAndGet(*CONFIGURE_CMD);
if (m_bVerbose) if (m_bVerbose)
progress.printMessageAbove(verboseString("cmake returned: {}", ret)); progress.printMessageAbove(verboseString("cmake returned: {}", ret));
@ -548,13 +592,21 @@ bool CPluginManager::updateHeaders(bool force) {
progress.m_szCurrentMessage = "Installing sources"; progress.m_szCurrentMessage = "Installing sources";
progress.print(); progress.print();
const std::string& cmd = std::string cmd = std::format("sed -i -e \"s#PREFIX = /usr/local#PREFIX = {}#\" {}/Makefile", DataState::getHeadersPath(), WORKINGDIR);
std::format("sed -i -e \"s#PREFIX = /usr/local#PREFIX = {}#\" {}/Makefile && cd {} && make installheaders", DataState::getHeadersPath(), WORKINGDIR, WORKINGDIR);
if (m_bVerbose) if (m_bVerbose)
progress.printMessageAbove(verboseString("installation will run: {}", cmd)); progress.printMessageAbove(verboseString("prepare install will run: {}", cmd));
ret = execAndGet(cmd); ret = execAndGet(cmd);
cmd = std::format("make -C '{}' installheaders && chmod -R 644 '{}' && find '{}' -type d -exec chmod a+x {{}} \\;", WORKINGDIR, DataState::getHeadersPath(),
DataState::getHeadersPath());
if (m_bVerbose)
progress.printMessageAbove(verboseString("install will run as sudo: {}", cmd));
// WORKINGDIR and headersPath should not contain anything unsafe. Usernames can't contain cmd exec parts.
ret = NSys::root::runAsSuperuserUnsafe(cmd);
if (m_bVerbose) if (m_bVerbose)
std::println("{}", verboseString("installer returned: {}", ret)); std::println("{}", verboseString("installer returned: {}", ret));
@ -562,15 +614,21 @@ bool CPluginManager::updateHeaders(bool force) {
std::filesystem::remove_all(WORKINGDIR); std::filesystem::remove_all(WORKINGDIR);
auto HEADERSVALID = headersValid(); auto HEADERSVALID = headersValid();
if (HEADERSVALID == HEADERS_OK) {
if (HEADERSVALID == HEADERS_OK || HEADERSVALID == HEADERS_MISMATCHED || HEADERSVALID == HEADERS_ABI_MISMATCH) {
progress.printMessageAbove(successString("installed headers")); progress.printMessageAbove(successString("installed headers"));
progress.m_iSteps = 5; progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Done!"; progress.m_szCurrentMessage = "Done!";
progress.print(); progress.print();
auto GLOBALSTATE = DataState::getGlobalState();
GLOBALSTATE.headersAbiCompiled = HLVER.abiHash;
DataState::updateGlobalState(GLOBALSTATE);
std::print("\n"); std::print("\n");
} else { } else {
progress.printMessageAbove(failureString("failed to install headers with error code {} ({})", (int)HEADERSVALID, headerErrorShort(HEADERSVALID))); progress.printMessageAbove(failureString("failed to install headers with error code {} ({})", sc<int>(HEADERSVALID), headerErrorShort(HEADERSVALID)));
progress.printMessageAbove(infoString("if the problem persists, try running hyprpm purge-cache."));
progress.m_iSteps = 5; progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Failed"; progress.m_szCurrentMessage = "Failed";
progress.print(); progress.print();
@ -599,7 +657,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
const auto HLVER = getHyprlandVersion(false); const auto HLVER = getHyprlandVersion(false);
CProgressBar progress; CProgressBar progress;
progress.m_iMaxSteps = REPOS.size() * 2 + 2; progress.m_iMaxSteps = (REPOS.size() * 2) + 2;
progress.m_iSteps = 0; progress.m_iSteps = 0;
progress.m_szCurrentMessage = "Updating repositories"; progress.m_szCurrentMessage = "Updating repositories";
progress.print(); progress.print();
@ -620,7 +678,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.printMessageAbove(infoString("Cloning {}", repo.url)); progress.printMessageAbove(infoString("Cloning {}", repo.url));
std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), repo.url, USERNAME)); std::string ret = execAndGet(std::format("cd {} && git clone --recursive '{}' {}", getTempRoot(), repo.url, USERNAME));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) { if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::println("{}", failureString("could not clone repo: shell returned: {}", ret)); std::println("{}", failureString("could not clone repo: shell returned: {}", ret));
@ -630,7 +688,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
if (!repo.rev.empty()) { if (!repo.rev.empty()) {
progress.printMessageAbove(infoString("Plugin has revision set, resetting: {}", repo.rev)); progress.printMessageAbove(infoString("Plugin has revision set, resetting: {}", repo.rev));
std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules " + repo.rev); std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules \'" + repo.rev + "\'");
if (ret.compare(0, 6, "fatal:") == 0) { if (ret.compare(0, 6, "fatal:") == 0) {
std::println(stderr, "\n{}", failureString("could not check out revision {}: shell returned:\n{}", repo.rev, ret)); std::println(stderr, "\n{}", failureString("could not check out revision {}: shell returned:\n{}", repo.rev, ret));
@ -677,17 +735,17 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
continue; continue;
} }
if (!pManifest->m_bGood) { if (!pManifest->m_good) {
std::println(stderr, "\n{}", failureString("The provided plugin repository has a corrupted manifest")); std::println(stderr, "\n{}", failureString("The provided plugin repository has a bad manifest"));
continue; continue;
} }
if (repo.rev.empty() && !pManifest->m_sRepository.commitPins.empty()) { if (repo.rev.empty() && !pManifest->m_repository.commitPins.empty()) {
// check commit pins unless a revision is specified // check commit pins unless a revision is specified
progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_sRepository.commitPins.size())); progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_repository.commitPins.size()));
for (auto const& [hl, plugin] : pManifest->m_sRepository.commitPins) { for (auto const& [hl, plugin] : pManifest->m_repository.commitPins) {
if (hl != HLVER.hash) if (hl != HLVER.hash)
continue; continue;
@ -697,7 +755,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
} }
} }
for (auto& p : pManifest->m_vPlugins) { for (auto& p : pManifest->m_plugins) {
std::string out; 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. */) { if (p.since > HLVER.commits && HLVER.commits >= 1000 /* for shallow clones, we can't check this. 1000 is an arbitrary number I chose. */) {
@ -709,8 +767,14 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.printMessageAbove(infoString("Building {}", p.name)); progress.printMessageAbove(infoString("Building {}", p.name));
for (auto const& bs : p.buildSteps) { for (auto const& bs : p.buildSteps) {
const std::string& cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs); const auto CMD_RAW = nixDevelopIfNeeded(std::format("cd {} && PKG_CONFIG_PATH=\"{}\" {}", m_szWorkingPluginDirectory, getPkgConfigPath(), bs), HLVER);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
if (!CMD_RAW) {
progress.printMessageAbove(failureString("Failed to build {}: {}", p.name, CMD_RAW.error()));
break;
}
out += " -> " + *CMD_RAW + "\n" + execAndGet(*CMD_RAW) + "\n";
} }
if (m_bVerbose) if (m_bVerbose)
@ -739,11 +803,11 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
if (repohash.length() > 0) if (repohash.length() > 0)
repohash.pop_back(); repohash.pop_back();
newrepo.hash = repohash; newrepo.hash = repohash;
for (auto const& p : pManifest->m_vPlugins) { for (auto const& p : pManifest->m_plugins) {
const auto OLDPLUGINIT = std::find_if(repo.plugins.begin(), repo.plugins.end(), [&](const auto& other) { return other.name == p.name; }); const auto OLDPLUGINIT = std::ranges::find_if(repo.plugins, [&](const auto& other) { return other.name == p.name; });
newrepo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false}); newrepo.plugins.emplace_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
} }
DataState::removePluginRepo(newrepo.name); DataState::removePluginRepo(SPluginRepoIdentifier::fromName(newrepo.name));
DataState::addNewPluginRepo(newrepo); DataState::addNewPluginRepo(newrepo);
std::filesystem::remove_all(m_szWorkingPluginDirectory); std::filesystem::remove_all(m_szWorkingPluginDirectory);
@ -755,8 +819,8 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.m_szCurrentMessage = "Updating global state..."; progress.m_szCurrentMessage = "Updating global state...";
progress.print(); progress.print();
auto GLOBALSTATE = DataState::getGlobalState(); auto GLOBALSTATE = DataState::getGlobalState();
GLOBALSTATE.headersHashCompiled = HLVER.hash; GLOBALSTATE.headersAbiCompiled = HLVER.abiHash;
DataState::updateGlobalState(GLOBALSTATE); DataState::updateGlobalState(GLOBALSTATE);
progress.m_iSteps++; progress.m_iSteps++;
@ -768,17 +832,23 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
return true; return true;
} }
bool CPluginManager::enablePlugin(const std::string& name) { bool CPluginManager::enablePlugin(const SPluginRepoIdentifier identifier) {
bool ret = DataState::setPluginEnabled(name, true); bool ret = false;
switch (identifier.type) {
case IDENTIFIER_NAME:
case IDENTIFIER_AUTHOR_NAME: ret = DataState::setPluginEnabled(identifier, true); break;
default: return false;
}
if (ret) if (ret)
std::println("{}", successString("Enabled {}", name)); std::println("{}", successString("Enabled {}", identifier.name));
return ret; return ret;
} }
bool CPluginManager::disablePlugin(const std::string& name) { bool CPluginManager::disablePlugin(const SPluginRepoIdentifier identifier) {
bool ret = DataState::setPluginEnabled(name, false); bool ret = DataState::setPluginEnabled(identifier, false);
if (ret) if (ret)
std::println("{}", successString("Disabled {}", name)); std::println("{}", successString("Disabled {}", identifier.name));
return ret; return ret;
} }
@ -796,9 +866,9 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState(bool forceReload)
} }
const auto HYPRPMPATH = DataState::getDataStatePath(); const auto HYPRPMPATH = DataState::getDataStatePath();
const auto json = glz::read_json<glz::json_t::array_t>(execAndGet("hyprctl plugins list -j")); const auto json = glz::read_json<glz::generic::array_t>(NHyprlandSocket::send("j/plugins list"));
if (!json) { if (!json) {
std::println(stderr, "PluginManager: couldn't parse hyprctl output"); std::println(stderr, "PluginManager: couldn't parse plugin list output");
return LOADSTATE_FAIL; return LOADSTATE_FAIL;
} }
@ -861,7 +931,7 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState(bool forceReload)
if (!p.enabled) if (!p.enabled)
continue; continue;
if (!forceReload && std::find_if(loadedPlugins.begin(), loadedPlugins.end(), [&](const auto& other) { return other == p.name; }) != loadedPlugins.end()) if (!forceReload && std::ranges::find_if(loadedPlugins, [&](const auto& other) { return other == p.name; }) != loadedPlugins.end())
continue; continue;
if (!loadUnloadPlugin(HYPRPMPATH / repoForName(p.name) / p.filename, true)) { if (!loadUnloadPlugin(HYPRPMPATH / repoForName(p.name) / p.filename, true)) {
@ -881,15 +951,16 @@ bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) {
auto state = DataState::getGlobalState(); auto state = DataState::getGlobalState();
auto HLVER = getHyprlandVersion(true); auto HLVER = getHyprlandVersion(true);
if (state.headersHashCompiled != HLVER.hash) { if (state.headersAbiCompiled != HLVER.abiHash) {
std::println("{}", infoString("Running Hyprland version differs from plugin state, please restart Hyprland.")); if (load)
std::println("{}", infoString("Running Hyprland version ({}) differs from plugin state ({}), please restart Hyprland.", HLVER.hash, state.headersAbiCompiled));
return false; return false;
} }
if (load) if (load)
execAndGet("hyprctl plugin load " + path); NHyprlandSocket::send("/plugin load " + path);
else else
execAndGet("hyprctl plugin unload " + path); NHyprlandSocket::send("/plugin unload " + path);
return true; return true;
} }
@ -898,7 +969,7 @@ void CPluginManager::listAllPlugins() {
const auto REPOS = DataState::getAllRepositories(); const auto REPOS = DataState::getAllRepositories();
for (auto const& r : REPOS) { for (auto const& r : REPOS) {
std::println("{}", infoString("Repository {}:", r.name)); std::println("{}", infoString("Repository {} (by {}):", r.name, r.author));
for (auto const& p : r.plugins) { for (auto const& p : r.plugins) {
std::println(" │ Plugin {}", p.name); std::println(" │ Plugin {}", p.name);
@ -914,7 +985,7 @@ void CPluginManager::listAllPlugins() {
} }
void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message) { void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message) {
execAndGet("hyprctl notify " + std::to_string((int)icon) + " " + std::to_string(durationMs) + " " + std::to_string(color) + " " + message); NHyprlandSocket::send("/notify " + std::to_string(icon) + " " + std::to_string(durationMs) + " " + std::to_string(color) + " " + message);
} }
std::string CPluginManager::headerError(const eHeadersErrors err) { std::string CPluginManager::headerError(const eHeadersErrors err) {
@ -923,6 +994,7 @@ std::string CPluginManager::headerError(const eHeadersErrors err) {
case HEADERS_MISMATCHED: return failureString("Headers version mismatch. Please run hyprpm update to fix those.\n"); case HEADERS_MISMATCHED: return failureString("Headers version mismatch. Please run hyprpm update to fix those.\n");
case HEADERS_NOT_HYPRLAND: return failureString("It doesn't seem you are running on hyprland.\n"); case HEADERS_NOT_HYPRLAND: return failureString("It doesn't seem you are running on hyprland.\n");
case HEADERS_MISSING: return failureString("Headers missing. Please run hyprpm update to fix those.\n"); case HEADERS_MISSING: return failureString("Headers missing. Please run hyprpm update to fix those.\n");
case HEADERS_ABI_MISMATCH: return failureString("ABI is mismatched. Please run hyprpm update to fix that.\n");
case HEADERS_DUPLICATED: { case HEADERS_DUPLICATED: {
return failureString("Headers duplicated!!! This is a very bad sign.\n" return failureString("Headers duplicated!!! This is a very bad sign.\n"
"This could be due to e.g. installing hyprland manually while a system package of hyprland is also installed.\n" "This could be due to e.g. installing hyprland manually while a system package of hyprland is also installed.\n"
@ -947,11 +1019,107 @@ std::string CPluginManager::headerErrorShort(const eHeadersErrors err) {
} }
bool CPluginManager::hasDeps() { bool CPluginManager::hasDeps() {
std::vector<std::string> deps = {"meson", "cpio", "cmake", "pkg-config"}; if (!m_bNoNix && getHyprlandVersion().isNix)
return true; // dep check not needed if we are on nix
bool hasAllDeps = true;
std::vector<std::string> deps = {"cpio", "cmake", "pkg-config", "g++", "gcc", "git"};
for (auto const& d : deps) { for (auto const& d : deps) {
if (!execAndGet("command -v " + d).contains("/")) if (!execAndGet("command -v " + d).contains("/")) {
return false; std::println(stderr, "{}", failureString("Missing dependency: {}", d));
hasAllDeps = false;
}
} }
return true; return hasAllDeps;
}
const std::string& CPluginManager::getPkgConfigPath() {
static const auto str = std::format("{}/share/pkgconfig:$PKG_CONFIG_PATH", DataState::getHeadersPath());
return str;
}
static std::expected<std::string, std::string> getNixDevelopFromPath(const std::string& argv0) {
std::string fullStorePath;
if (argv0.starts_with("/")) {
// we can use this directly
fullStorePath = argv0;
} else {
// use hyprpm, find in path
auto exe = NSys::findInPath("hyprpm");
if (!exe)
return std::unexpected("hyprpm not found in PATH");
fullStorePath = *exe;
}
if (fullStorePath.empty() || !fullStorePath.ends_with("/bin/hyprpm"))
return std::unexpected("couldn't get a real path for hyprpm (1)");
// canonicalize to get the real nix-store path
std::error_code ec;
fullStorePath = std::filesystem::canonical(fullStorePath, ec);
if (ec || fullStorePath.empty() || !fullStorePath.starts_with("/nix"))
return std::unexpected("couldn't get a real path for hyprpm");
fullStorePath = fullStorePath.substr(0, fullStorePath.length() - std::string_view{"/bin/hyprpm"}.length());
auto deriver = trim(execAndGet(std::format("echo \"$(nix-store --query --deriver '{}')\"", fullStorePath)));
if (deriver.starts_with("unknown"))
return std::unexpected("couldn't nix deriver");
return deriver;
}
static std::expected<std::string, std::string> getNixDevelopFromProfile() {
const auto NIX_PROFILE_STR = execAndGet("nix profile list --json");
auto rawJson = glz::read_json<glz::generic>(NIX_PROFILE_STR);
if (!rawJson)
return std::unexpected("failed to parse nix profile list --json");
auto& json = *rawJson;
if (!json.contains("elements") || !json["elements"].is_object())
return std::unexpected("nix profile list --json returned a wonky json");
if (!json["elements"].contains("hyprland") && !json["elements"].contains("Hyprland"))
return std::unexpected("nix profile list --json doesn't contain Hyprland (did you uninstall?)");
auto& hyprlandJson = json["elements"].contains("hyprland") ? json["elements"]["hyprland"] : json["elements"]["Hyprland"];
if (!hyprlandJson.contains("originalUrl"))
return std::unexpected("nix profile list --json's hyprland doesn't contain originalUrl?");
return hyprlandJson["originalUrl"].get_string();
}
std::expected<std::string, std::string> CPluginManager::nixDevelopIfNeeded(const std::string& cmd, const SHyprlandVersion& ver) {
if (m_bNoNix || !ver.isNix)
return cmd;
// Escape single quotes
std::string newCmd = cmd;
replaceInString(newCmd, "'", "\\'");
auto NIX_DEVELOP = getNixDevelopFromPath(m_szArgv0);
if (NIX_DEVELOP)
return std::format("nix develop '{}' --command bash -c $'{}'", *NIX_DEVELOP, newCmd);
else if (m_bVerbose)
std::println("{}", verboseString("Failed nix from path: {}", NIX_DEVELOP.error()));
NIX_DEVELOP = getNixDevelopFromProfile();
if (NIX_DEVELOP)
return std::format("nix develop '{}' --command bash -c $'{}'", *NIX_DEVELOP, newCmd);
else if (m_bVerbose)
std::println("{}", verboseString("Failed nix from profile: {}", NIX_DEVELOP.error()));
return std::unexpected("hyprland is nix, but hyprpm failed to obtain a nix develop shell for build cmd");
} }

View file

@ -1,8 +1,11 @@
#pragma once #pragma once
#include <cstdint>
#include <memory> #include <memory>
#include <optional>
#include <string> #include <string>
#include <utility> #include <expected>
#include "Plugin.hpp"
enum eHeadersErrors { enum eHeadersErrors {
HEADERS_OK = 0, HEADERS_OK = 0,
@ -10,6 +13,7 @@ enum eHeadersErrors {
HEADERS_MISSING, HEADERS_MISSING,
HEADERS_CORRUPTED, HEADERS_CORRUPTED,
HEADERS_MISMATCHED, HEADERS_MISMATCHED,
HEADERS_ABI_MISMATCH,
HEADERS_DUPLICATED HEADERS_DUPLICATED
}; };
@ -35,13 +39,17 @@ struct SHyprlandVersion {
std::string branch; std::string branch;
std::string hash; std::string hash;
std::string date; std::string date;
std::string abiHash;
int commits = 0; int commits = 0;
bool isNix = false;
}; };
class CPluginManager { class CPluginManager {
public: public:
CPluginManager();
bool addNewPluginRepo(const std::string& url, const std::string& rev); bool addNewPluginRepo(const std::string& url, const std::string& rev);
bool removePluginRepo(const std::string& urlOrName); bool removePluginRepo(const SPluginRepoIdentifier identifier);
eHeadersErrors headersValid(); eHeadersErrors headersValid();
bool updateHeaders(bool force = false); bool updateHeaders(bool force = false);
@ -49,8 +57,8 @@ class CPluginManager {
void listAllPlugins(); void listAllPlugins();
bool enablePlugin(const std::string& name); bool enablePlugin(const SPluginRepoIdentifier identifier);
bool disablePlugin(const std::string& name); bool disablePlugin(const SPluginRepoIdentifier identifier);
ePluginLoadStateReturn ensurePluginsLoadState(bool forceReload = false); ePluginLoadStateReturn ensurePluginsLoadState(bool forceReload = false);
bool loadUnloadPlugin(const std::string& path, bool load); bool loadUnloadPlugin(const std::string& path, bool load);
@ -58,20 +66,26 @@ class CPluginManager {
void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message); void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message);
const std::string& getPkgConfigPath();
bool hasDeps(); bool hasDeps();
bool m_bVerbose = false; bool m_bVerbose = false;
bool m_bNoShallow = false; bool m_bNoShallow = false;
std::string m_szCustomHlUrl; bool m_bNoNix = false;
std::string m_szCustomHlUrl, m_szUsername, m_szArgv0;
// will delete recursively if exists!! // will delete recursively if exists!!
bool createSafeDirectory(const std::string& path); bool createSafeDirectory(const std::string& path);
private: private:
std::string headerError(const eHeadersErrors err); std::string headerError(const eHeadersErrors err);
std::string headerErrorShort(const eHeadersErrors err); std::string headerErrorShort(const eHeadersErrors err);
bool validArg(const std::string& s);
std::string m_szWorkingPluginDirectory; std::expected<std::string, std::string> nixDevelopIfNeeded(const std::string& cmd, const SHyprlandVersion& ver);
std::string m_szWorkingPluginDirectory;
}; };
inline std::unique_ptr<CPluginManager> g_pPluginManager; inline std::unique_ptr<CPluginManager> g_pPluginManager;

View file

@ -0,0 +1,15 @@
#pragma once
#include <format>
#include <iostream>
// NOLINTNEXTLINE
namespace Debug {
template <typename... Args>
void die(std::format_string<Args...> fmt, Args&&... args) {
const std::string logMsg = std::vformat(fmt.get(), std::make_format_args(args...));
std::cout << "\n[ERR] " << logMsg << "\n";
exit(1);
}
};

173
hyprpm/src/helpers/Sys.cpp Normal file
View file

@ -0,0 +1,173 @@
#include "Sys.hpp"
#include "Die.hpp"
#include "StringUtils.hpp"
#include <pwd.h>
#include <unistd.h>
#include <sstream>
#include <print>
#include <filesystem>
#include <algorithm>
#include <sstream>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/string/VarList.hpp>
using namespace Hyprutils::OS;
using namespace Hyprutils::String;
inline constexpr std::array<std::string_view, 3> SUPERUSER_BINARIES = {
"sudo",
"doas",
"run0",
};
static std::string validSubinsAsStr() {
std::ostringstream oss;
auto it = SUPERUSER_BINARIES.begin();
if (it != SUPERUSER_BINARIES.end()) {
oss << *it++;
for (; it != SUPERUSER_BINARIES.end(); ++it)
oss << ", " << *it;
}
return oss.str();
}
static bool executableExistsInPath(const std::string& exe) {
return NSys::findInPath(exe).has_value();
}
std::optional<std::string> NSys::findInPath(const std::string& exe) {
const char* PATHENV = std::getenv("PATH");
if (!PATHENV)
return std::nullopt;
CVarList paths(PATHENV, 0, ':', true);
std::error_code ec;
for (const auto& PATH : paths) {
std::filesystem::path candidate = std::filesystem::path(PATH) / exe;
if (!std::filesystem::exists(candidate, ec) || ec)
continue;
if (!std::filesystem::is_regular_file(candidate, ec) || ec)
continue;
auto perms = std::filesystem::status(candidate, ec).permissions();
if (ec)
continue;
if ((perms & std::filesystem::perms::others_exec) != std::filesystem::perms::none)
return candidate.string();
}
return std::nullopt;
}
static std::string subin() {
static std::string bin;
static bool once = true;
if (!once)
return bin;
for (const auto& BIN : SUPERUSER_BINARIES) {
if (!executableExistsInPath(std::string{BIN}))
continue;
bin = BIN;
break;
}
once = false;
if (bin.empty())
Debug::die("{}", failureString("No valid superuser binary present. Supported: {}", validSubinsAsStr()));
return bin;
}
static bool verifyStringValid(const std::string& s) {
return std::ranges::none_of(s, [](const char& c) { return c == '`' || c == '$' || c == '(' || c == ')' || c == '\'' || c == '"'; });
}
int NSys::getUID() {
const auto UID = getuid();
const auto PWUID = getpwuid(UID);
return PWUID ? PWUID->pw_uid : UID;
}
int NSys::getEUID() {
const auto UID = geteuid();
const auto PWUID = getpwuid(UID);
return PWUID ? PWUID->pw_uid : UID;
}
bool NSys::isSuperuser() {
return getuid() != geteuid() || geteuid() == 0;
}
void NSys::root::cacheSudo() {
// "caches" the sudo so that the prompt later doesn't pop up in a weird spot
// sudo will not ask us again for a moment
CProcess proc(subin(), {"echo", "hyprland"});
proc.runSync();
}
void NSys::root::dropSudo() {
if (subin() != "sudo") {
std::println("{}", infoString("Don't know how to drop timestamp for '{}', ignoring.", subin()));
return;
}
CProcess proc(subin(), {"-k"});
proc.runSync();
}
bool NSys::root::createDirectory(const std::string& path, const std::string& mode) {
if (!verifyStringValid(path))
return false;
if (!std::ranges::all_of(mode, [](const char& c) { return c >= '0' && c <= '9'; }))
return false;
CProcess proc(subin(), {"mkdir", "-p", "-m", mode, path});
return proc.runSync() && proc.exitCode() == 0;
}
bool NSys::root::removeRecursive(const std::string& path) {
if (!verifyStringValid(path))
return false;
std::error_code ec;
const std::string PATH_ABSOLUTE = std::filesystem::canonical(path, ec);
if (ec)
return false;
if (!PATH_ABSOLUTE.starts_with("/var/cache/hyprpm"))
return false;
CProcess proc(subin(), {"rm", "-fr", PATH_ABSOLUTE});
return proc.runSync() && proc.exitCode() == 0;
}
bool NSys::root::install(const std::string& what, const std::string& where, const std::string& mode) {
if (!verifyStringValid(what) || !verifyStringValid(where))
return false;
if (!std::ranges::all_of(mode, [](const char& c) { return c >= '0' && c <= '9'; }))
return false;
CProcess proc(subin(), {"install", "-m" + mode, "-o", "0", "-g", "0", what, where});
return proc.runSync() && proc.exitCode() == 0;
}
std::string NSys::root::runAsSuperuserUnsafe(const std::string& cmd) {
CProcess proc(subin(), {"/bin/sh", "-c", cmd});
if (!proc.runSync())
return "";
return proc.stdOut();
}

View file

@ -0,0 +1,25 @@
#pragma once
#include <string>
#include <optional>
namespace NSys {
bool isSuperuser();
int getUID();
int getEUID();
std::optional<std::string> findInPath(const std::string& exe);
// NOLINTNEXTLINE
namespace root {
void cacheSudo();
void dropSudo();
//
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool createDirectory(const std::string& path, const std::string& mode);
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool removeRecursive(const std::string& path);
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool install(const std::string& what, const std::string& where, const std::string& mode);
// Do not use this unless absolutely necessary!
std::string runAsSuperuserUnsafe(const std::string& cmd);
};
};

View file

@ -2,34 +2,37 @@
#include "helpers/StringUtils.hpp" #include "helpers/StringUtils.hpp"
#include "core/PluginManager.hpp" #include "core/PluginManager.hpp"
#include "core/DataState.hpp" #include "core/DataState.hpp"
#include "helpers/Sys.hpp"
#include <cstdio>
#include <vector> #include <vector>
#include <string> #include <string>
#include <print> #include <print>
#include <chrono>
#include <thread> #include <hyprutils/utils/ScopeGuard.hpp>
using namespace Hyprutils::Utils;
constexpr std::string_view HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager constexpr std::string_view HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
add [url] [git rev] Install a new plugin repository from git. Git revision add <url> [git rev] Install a new plugin repository from git. Git revision
is optional, when set, commit locks are ignored. is optional, when set, commit locks are ignored.
remove [url/name] Remove an installed plugin repository remove <url|name|author/name> Remove an installed plugin repository.
enable [name] Enable a plugin enable <name|author/name> Enable a plugin.
disable [name] Disable a plugin disable <name|author/name> Disable a plugin.
update Check and update all plugins if needed update Check and update all plugins if needed.
reload Reload hyprpm state. Ensure all enabled plugins are loaded. reload Reload hyprpm state. Ensure all enabled plugins are loaded.
list List all installed plugins list List all installed plugins.
purge-cache Remove the entire hyprpm cache, built plugins, hyprpm settings and headers.
Flags: Flags:
--notify | -n Send a hyprland notification for important events (including both successes and fail events) --no-nix | Disable `nix develop` for build commands, even if Hyprland is nix.
--notify-fail | -nn Send a hyprland notification for fail events only --notify | -n Send a hyprland notification confirming successful plugin load.
--help | -h Show this menu Warnings/Errors trigger notifications regardless of this flag.
--verbose | -v Enable too much logging --help | -h Show this menu.
--force | -f Force an operation ignoring checks (e.g. update -f) --verbose | -v Enable too much logging.
--no-shallow | -s Disable shallow cloning of Hyprland sources --force | -f Force an operation ignoring checks (e.g. update -f).
--hl-url | Pass a custom hyprland source url --no-shallow | -s Disable shallow cloning of Hyprland sources.
--hl-url | Pass a custom hyprland source url.
)#"; )#";
@ -45,7 +48,7 @@ int main(int argc, char** argv, char** envp) {
} }
std::vector<std::string> command; std::vector<std::string> command;
bool notify = false, notifyFail = false, verbose = false, force = false, noShallow = false; bool notify = false, verbose = false, force = false, noShallow = false, noNix = false;
std::string customHlUrl; std::string customHlUrl;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
@ -56,9 +59,13 @@ int main(int argc, char** argv, char** envp) {
} else if (ARGS[i] == "--notify" || ARGS[i] == "-n") { } else if (ARGS[i] == "--notify" || ARGS[i] == "-n") {
notify = true; notify = true;
} else if (ARGS[i] == "--notify-fail" || ARGS[i] == "-nn") { } else if (ARGS[i] == "--notify-fail" || ARGS[i] == "-nn") {
notifyFail = notify = true; // TODO: Deprecated since v.053.0. Remove in version>0.56.0
std::println(stderr, "{}", failureString("Deprececated flag."));
g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] -n flag is deprecated, see hyprpm --help.");
} else if (ARGS[i] == "--verbose" || ARGS[i] == "-v") { } else if (ARGS[i] == "--verbose" || ARGS[i] == "-v") {
verbose = true; verbose = true;
} else if (ARGS[i] == "--no-nix") {
noNix = true;
} else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") { } else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") {
noShallow = true; noShallow = true;
} else if (ARGS[i] == "--hl-url") { } else if (ARGS[i] == "--hl-url") {
@ -87,7 +94,9 @@ int main(int argc, char** argv, char** envp) {
g_pPluginManager = std::make_unique<CPluginManager>(); g_pPluginManager = std::make_unique<CPluginManager>();
g_pPluginManager->m_bVerbose = verbose; g_pPluginManager->m_bVerbose = verbose;
g_pPluginManager->m_bNoShallow = noShallow; g_pPluginManager->m_bNoShallow = noShallow;
g_pPluginManager->m_bNoNix = noNix;
g_pPluginManager->m_szCustomHlUrl = customHlUrl; g_pPluginManager->m_szCustomHlUrl = customHlUrl;
g_pPluginManager->m_szArgv0 = argv[0];
if (command[0] == "add") { if (command[0] == "add") {
if (command.size() < 2) { if (command.size() < 2) {
@ -96,25 +105,44 @@ int main(int argc, char** argv, char** envp) {
} }
std::string rev = ""; std::string rev = "";
if (command.size() >= 3) { if (command.size() >= 3)
rev = command[2]; rev = command[2];
const auto HLVER = g_pPluginManager->getHyprlandVersion();
auto GLOBALSTATE = DataState::getGlobalState();
if (GLOBALSTATE.headersAbiCompiled != HLVER.abiHash) {
std::println(stderr, "{}", failureString("Headers outdated, please run hyprpm update."));
return 1;
} }
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
g_pPluginManager->updateHeaders(false);
return g_pPluginManager->addNewPluginRepo(command[1], rev) ? 0 : 1; return g_pPluginManager->addNewPluginRepo(command[1], rev) ? 0 : 1;
} else if (command[0] == "remove") { } else if (command[0] == "remove") {
if (ARGS.size() < 2) { if (command.size() < 2) {
std::println(stderr, "{}", failureString("Not enough args for remove.")); std::println(stderr, "{}", failureString("Not enough args for remove."));
return 1; return 1;
} }
return g_pPluginManager->removePluginRepo(command[1]) ? 0 : 1; NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
return g_pPluginManager->removePluginRepo(SPluginRepoIdentifier::fromString(command[1])) ? 0 : 1;
} else if (command[0] == "update") { } else if (command[0] == "update") {
bool headersValid = g_pPluginManager->headersValid() == HEADERS_OK; NSys::root::cacheSudo();
bool headers = g_pPluginManager->updateHeaders(force); CScopeGuard x([] { NSys::root::dropSudo(); });
bool headersValid = g_pPluginManager->headersValid() == HEADERS_OK;
bool headers = g_pPluginManager->updateHeaders(force);
if (headers) { if (headers) {
const auto HLVER = g_pPluginManager->getHyprlandVersion(false); const auto HLVER = g_pPluginManager->getHyprlandVersion(false);
auto GLOBALSTATE = DataState::getGlobalState(); auto GLOBALSTATE = DataState::getGlobalState();
const auto COMPILEDOUTDATED = HLVER.hash != GLOBALSTATE.headersHashCompiled; const auto COMPILEDOUTDATED = HLVER.abiHash != GLOBALSTATE.headersAbiCompiled;
bool ret1 = g_pPluginManager->updatePlugins(!headersValid || force || COMPILEDOUTDATED); bool ret1 = g_pPluginManager->updatePlugins(!headersValid || force || COMPILEDOUTDATED);
@ -128,20 +156,24 @@ int main(int argc, char** argv, char** envp) {
if (ret2 != LOADSTATE_OK) if (ret2 != LOADSTATE_OK)
return 1; return 1;
} else if (notify) } else {
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Couldn't update headers"); g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Couldn't update headers");
}
} else if (command[0] == "enable") { } else if (command[0] == "enable") {
if (ARGS.size() < 2) { if (command.size() < 2) {
std::println(stderr, "{}", failureString("Not enough args for enable.")); std::println(stderr, "{}", failureString("Not enough args for enable."));
return 1; return 1;
} }
if (!g_pPluginManager->enablePlugin(command[1])) { if (!g_pPluginManager->enablePlugin(SPluginRepoIdentifier::fromString(command[1]))) {
std::println(stderr, "{}", failureString("Couldn't enable plugin (missing?)")); std::println(stderr, "{}", failureString("Couldn't enable plugin (missing?)"));
return 1; return 1;
} }
auto ret = g_pPluginManager->ensurePluginsLoadState(); NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
auto ret = g_pPluginManager->ensurePluginsLoadState();
if (ret == LOADSTATE_HYPRLAND_UPDATED) if (ret == LOADSTATE_HYPRLAND_UPDATED)
g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] Enabled plugin, but Hyprland was updated. Please restart Hyprland."); g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] Enabled plugin, but Hyprland was updated. Please restart Hyprland.");
@ -154,33 +186,39 @@ int main(int argc, char** argv, char** envp) {
return 1; return 1;
} }
if (!g_pPluginManager->disablePlugin(command[1])) { if (!g_pPluginManager->disablePlugin(SPluginRepoIdentifier::fromString(command[1]))) {
std::println(stderr, "{}", failureString("Couldn't disable plugin (missing?)")); std::println(stderr, "{}", failureString("Couldn't disable plugin (missing?)"));
return 1; return 1;
} }
auto ret = g_pPluginManager->ensurePluginsLoadState(); NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
auto ret = g_pPluginManager->ensurePluginsLoadState();
if (ret != LOADSTATE_OK) if (ret != LOADSTATE_OK)
return 1; return 1;
} else if (command[0] == "reload") { } else if (command[0] == "reload") {
auto ret = g_pPluginManager->ensurePluginsLoadState(force); auto ret = g_pPluginManager->ensurePluginsLoadState(force);
if (ret != LOADSTATE_OK) { if (ret != LOADSTATE_OK) {
if (notify) { switch (ret) {
switch (ret) { case LOADSTATE_FAIL:
case LOADSTATE_FAIL: case LOADSTATE_PARTIAL_FAIL: g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins"); break;
case LOADSTATE_PARTIAL_FAIL: g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins"); break; case LOADSTATE_HEADERS_OUTDATED:
case LOADSTATE_HEADERS_OUTDATED: g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins: Outdated headers. Please run hyprpm update manually.");
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins: Outdated headers. Please run hyprpm update manually."); break;
break; default: break;
default: break;
}
} }
return 1; return 1;
} else if (notify && !notifyFail) { } else if (notify) {
g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins"); g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins");
} }
} else if (command[0] == "purge-cache") {
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
DataState::purgeAllCache();
} else if (command[0] == "list") { } else if (command[0] == "list") {
g_pPluginManager->listAllPlugins(); g_pPluginManager->listAllPlugins();
} else { } else {

View file

@ -1,32 +0,0 @@
globber = run_command('sh', '-c', 'find . -name "*.cpp" | sort', check: true)
src = globber.stdout().strip().split('\n')
executable(
'hyprpm',
src,
dependencies: [
dependency('hyprutils', version: '>= 0.1.1'),
dependency('threads'),
dependency('tomlplusplus'),
dependency('glaze', method: 'cmake'),
],
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

@ -1,82 +1,80 @@
#include "CProgressBar.hpp" #include "CProgressBar.hpp"
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <algorithm> #include <unistd.h>
#include <cmath> #include <cmath>
#include <format> #include <format>
#include <print> #include <print>
#include <stdio.h> #include <cstdio>
#include <unistd.h>
#include <algorithm>
#include <sstream>
#include <hyprutils/memory/Casts.hpp>
#include "../helpers/Colors.hpp" #include "../helpers/Colors.hpp"
void CProgressBar::printMessageAbove(const std::string& msg) { using namespace Hyprutils::Memory;
struct winsize w;
static winsize getTerminalSize() {
winsize w{};
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
return w;
}
std::string spaces; static void clearCurrentLine() {
spaces.reserve(w.ws_col); std::print("\r\33[2K"); // ansi escape sequence to clear entire line
for (size_t i = 0; i < w.ws_col; ++i) { }
spaces += ' ';
}
std::println("\r{}\r{}", spaces, msg); void CProgressBar::printMessageAbove(const std::string& msg) {
print(); clearCurrentLine();
std::print("\r{}\n", msg);
print(); // reprint bar underneath
} }
void CProgressBar::print() { void CProgressBar::print() {
struct winsize w; const auto w = getTerminalSize();
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
if (m_bFirstPrint) if (m_bFirstPrint) {
std::print("\n"); std::print("\n");
m_bFirstPrint = false; m_bFirstPrint = false;
std::string spaces;
spaces.reserve(w.ws_col);
for (size_t i = 0; i < w.ws_col; ++i) {
spaces += ' ';
} }
std::print("\r{}\r", spaces); clearCurrentLine();
std::string message = ""; float percentDone = 0.0f;
if (m_fPercentage >= 0.0f)
float percentDone = 0;
if (m_fPercentage >= 0)
percentDone = m_fPercentage; percentDone = m_fPercentage;
else else {
percentDone = (float)m_iSteps / (float)m_iMaxSteps; // check for divide-by-zero
percentDone = m_iMaxSteps > 0 ? sc<float>(m_iSteps) / m_iMaxSteps : 0.0f;
const auto BARWIDTH = std::clamp(w.ws_col - static_cast<unsigned long>(m_szCurrentMessage.length()) - 2, 0UL, 50UL);
// draw bar
message += std::string{" "} + Colors::GREEN;
size_t i = 0;
for (; i < std::floor(percentDone * BARWIDTH); ++i) {
message += "";
} }
// clamp to ensure no overflows (sanity check)
percentDone = std::clamp(percentDone, 0.0f, 1.0f);
const size_t BARWIDTH = std::clamp<size_t>(w.ws_col - m_szCurrentMessage.length() - 2, 0, 50);
std::ostringstream oss;
oss << ' ' << Colors::GREEN;
size_t filled = std::floor(percentDone * BARWIDTH);
size_t i = 0;
for (; i < filled; ++i)
oss << "";
if (i < BARWIDTH) { if (i < BARWIDTH) {
i++; oss << "" << Colors::RESET;
++i;
message += std::string{""} + Colors::RESET; for (; i < BARWIDTH; ++i)
oss << "";
for (; i < BARWIDTH; ++i) {
message += "";
}
} else } else
message += Colors::RESET; oss << Colors::RESET;
// draw progress if (m_fPercentage >= 0.0f)
if (m_fPercentage >= 0) oss << " " << std::format("{}%", sc<int>(percentDone * 100.0)) << ' ';
message += " " + std::format("{}%", static_cast<int>(percentDone * 100.0)) + " ";
else else
message += " " + std::format("{} / {}", m_iSteps, m_iMaxSteps) + " "; oss << " " << std::format("{} / {}", m_iSteps, m_iMaxSteps) << ' ';
// draw message
std::print("{} {}", message, m_szCurrentMessage);
std::print("{} {}", oss.str(), m_szCurrentMessage);
std::fflush(stdout); std::fflush(stdout);
} }

104
hyprtester/CMakeLists.txt Normal file
View file

@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 3.19)
project(hyprtester DESCRIPTION "Hyprland test suite")
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(hyprtester_deps REQUIRED IMPORTED_TARGET hyprutils>=0.5.0)
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(hyprtester ${SRCFILES})
add_custom_command(
TARGET hyprtester
POST_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/plugin/build.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/plugin)
target_link_libraries(hyprtester PUBLIC PkgConfig::hyprtester_deps)
install(TARGETS hyprtester)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test.conf
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/plugin/hyprtestplugin.so
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/clients/build.hpp
"#include <string>\n"
"static const std::string binaryDir = \"${CMAKE_CURRENT_BINARY_DIR}\";"
)
######## wayland protocols testing stuff
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE)
endif()
find_package(hyprwayland-scanner 0.4.0 REQUIRED)
pkg_check_modules(
protocols_deps
REQUIRED
IMPORTED_TARGET
hyprutils>=0.8.0
wayland-client
wayland-protocols
)
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
message(STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}")
# gen core wayland stuff
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.hpp
COMMAND hyprwayland-scanner --wayland-enums --client
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
function(protocolNew protoPath protoName external)
if(external)
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner --client ${path}/${protoName}.xml
${CMAKE_CURRENT_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()
function(clientNew sourceName)
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "PROTOS")
add_executable(${sourceName} clients/${sourceName}.cpp)
target_include_directories(${sourceName} BEFORE PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/protocols")
target_link_libraries(${sourceName} PUBLIC PkgConfig::protocols_deps)
target_sources(${sourceName} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.cpp ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.hpp)
foreach(protoName IN LISTS ARG_PROTOS)
target_sources(${sourceName} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.hpp)
endforeach()
endfunction()
protocolnew("staging/pointer-warp" "pointer-warp-v1" false)
protocolnew("stable/xdg-shell" "xdg-shell" false)
protocolnew("unstable/keyboard-shortcuts-inhibit" "keyboard-shortcuts-inhibit-unstable-v1" false)
clientNew("pointer-warp" PROTOS "pointer-warp-v1" "xdg-shell")
clientNew("pointer-scroll" PROTOS "xdg-shell")
clientNew("child-window" PROTOS "xdg-shell")
clientNew("shortcut-inhibitor" PROTOS "xdg-shell" "keyboard-shortcuts-inhibit-unstable-v1")

View file

@ -0,0 +1,336 @@
#include <print>
#include <poll.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <wayland-client.h>
#include <wayland.hpp>
#include <xdg-shell.hpp>
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprutils/math/Vector2D.hpp>
using Hyprutils::Math::Vector2D;
using namespace Hyprutils::Memory;
struct SWlState {
wl_display* display;
CSharedPointer<CCWlRegistry> registry;
// protocols
CSharedPointer<CCWlCompositor> wlCompositor;
CSharedPointer<CCWlSeat> wlSeat;
CSharedPointer<CCWlShm> wlShm;
CSharedPointer<CCXdgWmBase> xdgShell;
// shm/buffer stuff
CSharedPointer<CCWlShmPool> shmPool;
CSharedPointer<CCWlBuffer> shmBuf;
CSharedPointer<CCWlBuffer> shmBuf2;
int shmFd = 0;
size_t shmBufSize = 0;
bool xrgb8888_support = false;
// surface/toplevel stuff
CSharedPointer<CCWlSurface> surf;
CSharedPointer<CCXdgSurface> xdgSurf;
CSharedPointer<CCXdgToplevel> xdgToplevel;
Vector2D geom;
// pointer
CSharedPointer<CCWlPointer> pointer;
uint32_t enterSerial = 0;
};
bool debug, shouldExit, started;
template <typename... Args>
//NOLINTNEXTLINE
static void clientLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
std::println("{}", text);
std::fflush(stdout);
}
template <typename... Args>
//NOLINTNEXTLINE
static void debugLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
if (!debug)
return;
std::println("{}", text);
std::fflush(stdout);
}
static bool bindRegistry(SWlState& state) {
state.registry = makeShared<CCWlRegistry>((wl_proxy*)wl_display_get_registry(state.display));
state.registry->setGlobal([&](CCWlRegistry* r, uint32_t id, const char* name, uint32_t version) {
const std::string NAME = name;
if (NAME == "wl_compositor") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlCompositor = makeShared<CCWlCompositor>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_compositor_interface, 6));
} else if (NAME == "wl_shm") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlShm = makeShared<CCWlShm>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_shm_interface, 1));
} else if (NAME == "wl_seat") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlSeat = makeShared<CCWlSeat>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_seat_interface, 9));
} else if (NAME == "xdg_wm_base") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.xdgShell = makeShared<CCXdgWmBase>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &xdg_wm_base_interface, 1));
}
});
state.registry->setGlobalRemove([](CCWlRegistry* r, uint32_t id) { debugLog("Global {} removed", id); });
wl_display_roundtrip(state.display);
if (!state.wlCompositor || !state.wlShm || !state.wlSeat || !state.xdgShell) {
clientLog("Failed to get protocols from Hyprland");
return false;
}
return true;
}
static bool createShm(SWlState& state, Vector2D geom) {
if (!state.xrgb8888_support)
return false;
size_t stride = geom.x * 4;
size_t size = geom.y * stride;
if (!state.shmPool) {
const char* name = "/wl-shm-pointer-warp";
state.shmFd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (state.shmFd < 0)
return false;
if (shm_unlink(name) < 0 || ftruncate(state.shmFd, size * 2) < 0) {
close(state.shmFd);
return false;
}
state.shmPool = makeShared<CCWlShmPool>(state.wlShm->sendCreatePool(state.shmFd, size * 2));
if (!state.shmPool->resource()) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmBufSize = size;
} else if (size > state.shmBufSize) {
if (ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmPool->sendResize(size * 2);
state.shmBufSize = size;
}
auto buf = makeShared<CCWlBuffer>(state.shmPool->sendCreateBuffer(0, geom.x, geom.y, stride, WL_SHM_FORMAT_XRGB8888));
if (!buf->resource())
return false;
if (state.shmBuf) {
state.shmBuf->sendDestroy();
state.shmBuf.reset();
}
state.shmBuf = buf;
return true;
}
static bool setupToplevel(SWlState& state) {
state.wlShm->setFormat([&](CCWlShm* p, uint32_t format) {
if (format == WL_SHM_FORMAT_XRGB8888)
state.xrgb8888_support = true;
});
state.xdgShell->setPing([&](CCXdgWmBase* p, uint32_t serial) { state.xdgShell->sendPong(serial); });
state.surf = makeShared<CCWlSurface>(state.wlCompositor->sendCreateSurface());
if (!state.surf->resource())
return false;
state.xdgSurf = makeShared<CCXdgSurface>(state.xdgShell->sendGetXdgSurface(state.surf->resource()));
if (!state.xdgSurf->resource())
return false;
state.xdgToplevel = makeShared<CCXdgToplevel>(state.xdgSurf->sendGetToplevel());
if (!state.xdgToplevel->resource())
return false;
state.xdgToplevel->setClose([&](CCXdgToplevel* p) { exit(0); });
state.xdgToplevel->setConfigure([&](CCXdgToplevel* p, int32_t w, int32_t h, wl_array* arr) {
state.geom = {1280, 720};
if (!createShm(state, state.geom))
exit(-1);
});
state.xdgSurf->setConfigure([&](CCXdgSurface* p, uint32_t serial) {
if (!state.shmBuf)
debugLog("xdgSurf configure but no buf made yet?");
state.xdgSurf->sendSetWindowGeometry(0, 0, state.geom.x, state.geom.y);
state.surf->sendAttach(state.shmBuf.get(), 0, 0);
state.surf->sendCommit();
state.xdgSurf->sendAckConfigure(serial);
if (!started) {
started = true;
clientLog("started");
}
});
state.xdgToplevel->sendSetTitle("child-test parent");
state.xdgToplevel->sendSetAppId("child-test-parent");
state.surf->sendAttach(nullptr, 0, 0);
state.surf->sendCommit();
return true;
}
static bool setupSeat(SWlState& state) {
state.pointer = makeShared<CCWlPointer>(state.wlSeat->sendGetPointer());
if (!state.pointer->resource())
return false;
state.pointer->setEnter([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf, wl_fixed_t x, wl_fixed_t y) {
debugLog("Got pointer enter event, serial {}, x {}, y {}", serial, x, y);
state.enterSerial = serial;
});
state.pointer->setLeave([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf) { debugLog("Got pointer leave event, serial {}", serial); });
state.pointer->setMotion([&](CCWlPointer* p, uint32_t serial, wl_fixed_t x, wl_fixed_t y) { debugLog("Got pointer motion event, serial {}, x {}, y {}", serial, x, y); });
return true;
}
struct SChildWindow {
CSharedPointer<CCWlSurface> surface;
CSharedPointer<CCXdgSurface> xSurface;
CSharedPointer<CCXdgToplevel> toplevel;
};
static void parseRequest(SWlState& state, std::string str, SChildWindow& window) {
if (str.starts_with("exit")) {
shouldExit = true;
return;
}
size_t index = str.find_first_of('\n');
str = str.substr(0, index);
if (str == "toplevel") {
window.surface = makeShared<CCWlSurface>(state.wlCompositor->sendCreateSurface());
window.xSurface = makeShared<CCXdgSurface>(state.xdgShell->sendGetXdgSurface(window.surface->resource()));
window.xSurface->setConfigure([&](CCXdgSurface* p, uint32_t serial) {
if (!state.shmBuf)
debugLog("xdgSurf configure but no buf made yet?");
window.xSurface->sendSetWindowGeometry(0, 0, state.geom.x, state.geom.y);
window.surface->sendAttach(state.shmBuf2.get(), 0, 0);
window.surface->sendCommit();
window.xSurface->sendAckConfigure(serial);
});
window.toplevel = makeShared<CCXdgToplevel>(window.xSurface->sendGetToplevel());
window.toplevel->setConfigure([&](CCXdgToplevel* p, int32_t w, int32_t h, wl_array* arr) {
size_t stride = 1280 * 4;
size_t size = 720 * stride;
auto buf = makeShared<CCWlBuffer>(state.shmPool->sendCreateBuffer(size, state.geom.x, state.geom.y, stride, WL_SHM_FORMAT_XRGB8888));
if (!buf->resource())
clientLog("Failed to create child buffer");
if (state.shmBuf2) {
state.shmBuf2->sendDestroy();
state.shmBuf2.reset();
}
state.shmBuf2 = buf;
});
window.toplevel->sendSetTitle("child-test child");
window.toplevel->sendSetAppId("child-test-child");
window.toplevel->sendSetParent(state.xdgToplevel.get());
window.surface->sendAttach(nullptr, 0, 0);
window.surface->sendCommit();
clientLog("child started");
return;
}
}
int main(int argc, char** argv) {
if (argc != 1 && argc != 2)
clientLog("Only the \"--debug\" switch is allowed, it turns on debug logs.");
if (argc == 2 && std::string{argv[1]} == "--debug")
debug = true;
SWlState state;
SChildWindow window;
// WAYLAND_DISPLAY env should be set to the correct one
state.display = wl_display_connect(nullptr);
if (!state.display) {
clientLog("Failed to connect to wayland display");
return -1;
}
if (!bindRegistry(state) || !setupSeat(state) || !setupToplevel(state))
return -1;
std::array<char, 1024> readBuf;
readBuf.fill(0);
wl_display_flush(state.display);
struct pollfd fds[2] = {{.fd = wl_display_get_fd(state.display), .events = POLLIN | POLLOUT}, {.fd = STDIN_FILENO, .events = POLLIN}};
while (!shouldExit && poll(fds, 2, 0) != -1) {
if (fds[0].revents & POLLIN) {
wl_display_flush(state.display);
if (wl_display_prepare_read(state.display) == 0) {
wl_display_read_events(state.display);
wl_display_dispatch_pending(state.display);
} else
wl_display_dispatch(state.display);
int ret = 0;
do {
ret = wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
} while (ret > 0);
}
if (fds[1].revents & POLLIN) {
ssize_t bytesRead = read(fds[1].fd, readBuf.data(), 1023);
if (bytesRead == -1)
continue;
readBuf[bytesRead] = 0;
parseRequest(state, std::string{readBuf.data()}, window);
}
}
wl_display* display = state.display;
state = {};
window = {};
wl_display_disconnect(display);
return 0;
}

View file

@ -0,0 +1,319 @@
#include <cstring>
#include <sys/poll.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <print>
#include <format>
#include <string>
#include <fstream>
#include <wayland-client.h>
#include <wayland.hpp>
#include <xdg-shell.hpp>
#include <pointer-warp-v1.hpp>
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprutils/math/Vector2D.hpp>
#include <hyprutils/os/FileDescriptor.hpp>
using Hyprutils::Math::Vector2D;
using namespace Hyprutils::Memory;
struct SWlState {
wl_display* display;
CSharedPointer<CCWlRegistry> registry;
// protocols
CSharedPointer<CCWlCompositor> wlCompositor;
CSharedPointer<CCWlSeat> wlSeat;
CSharedPointer<CCWlShm> wlShm;
CSharedPointer<CCXdgWmBase> xdgShell;
// shm/buffer stuff
CSharedPointer<CCWlShmPool> shmPool;
CSharedPointer<CCWlBuffer> shmBuf;
int shmFd;
size_t shmBufSize;
bool xrgb8888_support = false;
// surface/toplevel stuff
CSharedPointer<CCWlSurface> surf;
CSharedPointer<CCXdgSurface> xdgSurf;
CSharedPointer<CCXdgToplevel> xdgToplevel;
Vector2D geom;
// pointer
CSharedPointer<CCWlPointer> pointer;
uint32_t enterSerial;
// last delta
float lastScrollDelta = -1.F;
bool writeDelta = false;
};
static std::ofstream logfile;
static bool debug, started, shouldExit;
template <typename... Args>
//NOLINTNEXTLINE
static void clientLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
std::println("{}", text);
logfile << text << std::endl;
std::fflush(stdout);
}
template <typename... Args>
//NOLINTNEXTLINE
static void debugLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
logfile << text << std::endl;
if (!debug)
return;
std::println("{}", text);
std::fflush(stdout);
}
static bool bindRegistry(SWlState& state) {
state.registry = makeShared<CCWlRegistry>((wl_proxy*)wl_display_get_registry(state.display));
state.registry->setGlobal([&](CCWlRegistry* r, uint32_t id, const char* name, uint32_t version) {
const std::string NAME = name;
if (NAME == "wl_compositor") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlCompositor = makeShared<CCWlCompositor>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_compositor_interface, 6));
} else if (NAME == "wl_shm") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlShm = makeShared<CCWlShm>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_shm_interface, 1));
} else if (NAME == "wl_seat") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlSeat = makeShared<CCWlSeat>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_seat_interface, 9));
} else if (NAME == "xdg_wm_base") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.xdgShell = makeShared<CCXdgWmBase>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &xdg_wm_base_interface, 1));
}
});
state.registry->setGlobalRemove([](CCWlRegistry* r, uint32_t id) { debugLog("Global {} removed", id); });
wl_display_roundtrip(state.display);
if (!state.wlCompositor || !state.wlShm || !state.wlSeat || !state.xdgShell) {
clientLog("Failed to get protocols from Hyprland");
return false;
}
return true;
}
static bool createShm(SWlState& state, Vector2D geom) {
if (!state.xrgb8888_support)
return false;
size_t stride = geom.x * 4;
size_t size = geom.y * stride;
if (!state.shmPool) {
const char* name = "/wl-shm-pointer-scroll";
state.shmFd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (state.shmFd < 0)
return false;
if (shm_unlink(name) < 0 || ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
return false;
}
state.shmPool = makeShared<CCWlShmPool>(state.wlShm->sendCreatePool(state.shmFd, size));
if (!state.shmPool->resource()) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmBufSize = size;
} else if (size > state.shmBufSize) {
if (ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmPool->sendResize(size);
state.shmBufSize = size;
}
auto buf = makeShared<CCWlBuffer>(state.shmPool->sendCreateBuffer(0, geom.x, geom.y, stride, WL_SHM_FORMAT_XRGB8888));
if (!buf->resource())
return false;
if (state.shmBuf) {
state.shmBuf->sendDestroy();
state.shmBuf.reset();
}
state.shmBuf = buf;
return true;
}
static bool setupToplevel(SWlState& state) {
state.wlShm->setFormat([&](CCWlShm* p, uint32_t format) {
if (format == WL_SHM_FORMAT_XRGB8888)
state.xrgb8888_support = true;
});
state.xdgShell->setPing([&](CCXdgWmBase* p, uint32_t serial) { state.xdgShell->sendPong(serial); });
state.surf = makeShared<CCWlSurface>(state.wlCompositor->sendCreateSurface());
if (!state.surf->resource())
return false;
state.xdgSurf = makeShared<CCXdgSurface>(state.xdgShell->sendGetXdgSurface(state.surf->resource()));
if (!state.xdgSurf->resource())
return false;
state.xdgToplevel = makeShared<CCXdgToplevel>(state.xdgSurf->sendGetToplevel());
if (!state.xdgToplevel->resource())
return false;
state.xdgToplevel->setClose([&](CCXdgToplevel* p) { exit(0); });
state.xdgToplevel->setConfigure([&](CCXdgToplevel* p, int32_t w, int32_t h, wl_array* arr) {
state.geom = {1280, 720};
if (!createShm(state, state.geom))
exit(-1);
});
state.xdgSurf->setConfigure([&](CCXdgSurface* p, uint32_t serial) {
if (!state.shmBuf)
debugLog("xdgSurf configure but no buf made yet?");
state.xdgSurf->sendSetWindowGeometry(0, 0, state.geom.x, state.geom.y);
state.surf->sendAttach(state.shmBuf.get(), 0, 0);
state.surf->sendCommit();
state.xdgSurf->sendAckConfigure(serial);
if (!started) {
started = true;
clientLog("started");
}
});
state.xdgToplevel->sendSetTitle("pointer-scroll test client");
state.xdgToplevel->sendSetAppId("pointer-scroll");
state.surf->sendAttach(nullptr, 0, 0);
state.surf->sendCommit();
return true;
}
static bool setupSeat(SWlState& state) {
state.pointer = makeShared<CCWlPointer>(state.wlSeat->sendGetPointer());
if (!state.pointer->resource())
return false;
state.pointer->setEnter([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf, wl_fixed_t x, wl_fixed_t y) {
debugLog("Got pointer enter event, serial {}, x {}, y {}", serial, x, y);
state.enterSerial = serial;
});
state.pointer->setAxis([&](CCWlPointer* p, uint32_t time, wl_pointer_axis axis, wl_fixed_t delta) {
debugLog("axis: ax {} delta {}", (int)axis, wl_fixed_to_double(delta));
if (state.writeDelta) {
clientLog("{:.2f}", wl_fixed_to_double(delta));
state.writeDelta = false;
state.lastScrollDelta = -1;
return;
}
state.lastScrollDelta = wl_fixed_to_double(delta);
state.writeDelta = true;
});
state.pointer->setLeave([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf) { debugLog("Got pointer leave event, serial {}", serial); });
state.pointer->setMotion([&](CCWlPointer* p, uint32_t serial, wl_fixed_t x, wl_fixed_t y) { debugLog("Got pointer motion event, serial {}, x {}, y {}", serial, x, y); });
return true;
}
// return last delta after axis
static void parseRequest(SWlState& state, std::string req) {
if (!state.writeDelta) {
state.writeDelta = true;
return;
}
clientLog("{:.2f}", state.lastScrollDelta);
state.writeDelta = false;
state.lastScrollDelta = -1;
}
int main(int argc, char** argv) {
logfile.open("pointer-scroll.txt", std::ios::trunc);
if (argc != 1 && argc != 2)
clientLog("Only the \"--debug\" switch is allowed, it turns on debug logs.");
if (argc == 2 && std::string{argv[1]} == "--debug")
debug = true;
SWlState state;
// WAYLAND_DISPLAY env should be set to the correct one
state.display = wl_display_connect(nullptr);
if (!state.display) {
clientLog("Failed to connect to wayland display");
return -1;
}
if (!bindRegistry(state) || !setupSeat(state) || !setupToplevel(state))
return -1;
std::array<char, 1024> readBuf;
readBuf.fill(0);
wl_display_flush(state.display);
struct pollfd fds[2] = {{.fd = wl_display_get_fd(state.display), .events = POLLIN | POLLOUT}, {.fd = STDIN_FILENO, .events = POLLIN}};
while (!shouldExit && poll(fds, 2, 0) != -1) {
if (fds[0].revents & POLLIN) {
wl_display_flush(state.display);
if (wl_display_prepare_read(state.display) == 0) {
wl_display_read_events(state.display);
wl_display_dispatch_pending(state.display);
} else
wl_display_dispatch(state.display);
int ret = 0;
do {
ret = wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
} while (ret > 0);
}
if (fds[1].revents & POLLIN) {
ssize_t bytesRead = read(fds[1].fd, readBuf.data(), 1023);
if (bytesRead == -1)
continue;
readBuf[bytesRead] = 0;
parseRequest(state, std::string{readBuf.data()});
}
}
wl_display* display = state.display;
state = {};
wl_display_disconnect(display);
logfile.flush();
logfile.close();
return 0;
}

View file

@ -0,0 +1,318 @@
#include <cstring>
#include <sys/poll.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <print>
#include <format>
#include <string>
#include <wayland-client.h>
#include <wayland.hpp>
#include <xdg-shell.hpp>
#include <pointer-warp-v1.hpp>
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprutils/math/Vector2D.hpp>
#include <hyprutils/os/FileDescriptor.hpp>
using Hyprutils::Math::Vector2D;
using namespace Hyprutils::Memory;
struct SWlState {
wl_display* display;
CSharedPointer<CCWlRegistry> registry;
// protocols
CSharedPointer<CCWlCompositor> wlCompositor;
CSharedPointer<CCWlSeat> wlSeat;
CSharedPointer<CCWlShm> wlShm;
CSharedPointer<CCXdgWmBase> xdgShell;
CSharedPointer<CCWpPointerWarpV1> pointerWarp;
// shm/buffer stuff
CSharedPointer<CCWlShmPool> shmPool;
CSharedPointer<CCWlBuffer> shmBuf;
int shmFd;
size_t shmBufSize;
bool xrgb8888_support = false;
// surface/toplevel stuff
CSharedPointer<CCWlSurface> surf;
CSharedPointer<CCXdgSurface> xdgSurf;
CSharedPointer<CCXdgToplevel> xdgToplevel;
Vector2D geom;
// pointer
CSharedPointer<CCWlPointer> pointer;
uint32_t enterSerial;
};
static bool debug, started, shouldExit;
template <typename... Args>
//NOLINTNEXTLINE
static void clientLog(std::format_string<Args...> fmt, Args&&... args) {
std::println("{}", std::vformat(fmt.get(), std::make_format_args(args...)));
std::fflush(stdout);
}
template <typename... Args>
//NOLINTNEXTLINE
static void debugLog(std::format_string<Args...> fmt, Args&&... args) {
if (!debug)
return;
std::println("{}", std::vformat(fmt.get(), std::make_format_args(args...)));
std::fflush(stdout);
}
static bool bindRegistry(SWlState& state) {
state.registry = makeShared<CCWlRegistry>((wl_proxy*)wl_display_get_registry(state.display));
state.registry->setGlobal([&](CCWlRegistry* r, uint32_t id, const char* name, uint32_t version) {
const std::string NAME = name;
if (NAME == "wl_compositor") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlCompositor = makeShared<CCWlCompositor>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_compositor_interface, 6));
} else if (NAME == "wl_shm") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlShm = makeShared<CCWlShm>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_shm_interface, 1));
} else if (NAME == "wl_seat") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlSeat = makeShared<CCWlSeat>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_seat_interface, 9));
} else if (NAME == "xdg_wm_base") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.xdgShell = makeShared<CCXdgWmBase>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &xdg_wm_base_interface, 1));
} else if (NAME == "wp_pointer_warp_v1") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.pointerWarp = makeShared<CCWpPointerWarpV1>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wp_pointer_warp_v1_interface, 1));
}
});
state.registry->setGlobalRemove([](CCWlRegistry* r, uint32_t id) { debugLog("Global {} removed", id); });
wl_display_roundtrip(state.display);
if (!state.wlCompositor || !state.wlShm || !state.wlSeat || !state.xdgShell || !state.pointerWarp) {
clientLog("Failed to get protocols from Hyprland");
return false;
}
return true;
}
static bool createShm(SWlState& state, Vector2D geom) {
if (!state.xrgb8888_support)
return false;
size_t stride = geom.x * 4;
size_t size = geom.y * stride;
if (!state.shmPool) {
const char* name = "/wl-shm-pointer-warp";
state.shmFd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (state.shmFd < 0)
return false;
if (shm_unlink(name) < 0 || ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
return false;
}
state.shmPool = makeShared<CCWlShmPool>(state.wlShm->sendCreatePool(state.shmFd, size));
if (!state.shmPool->resource()) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmBufSize = size;
} else if (size > state.shmBufSize) {
if (ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmPool->sendResize(size);
state.shmBufSize = size;
}
auto buf = makeShared<CCWlBuffer>(state.shmPool->sendCreateBuffer(0, geom.x, geom.y, stride, WL_SHM_FORMAT_XRGB8888));
if (!buf->resource())
return false;
if (state.shmBuf) {
state.shmBuf->sendDestroy();
state.shmBuf.reset();
}
state.shmBuf = buf;
return true;
}
static bool setupToplevel(SWlState& state) {
state.wlShm->setFormat([&](CCWlShm* p, uint32_t format) {
if (format == WL_SHM_FORMAT_XRGB8888)
state.xrgb8888_support = true;
});
state.xdgShell->setPing([&](CCXdgWmBase* p, uint32_t serial) { state.xdgShell->sendPong(serial); });
state.surf = makeShared<CCWlSurface>(state.wlCompositor->sendCreateSurface());
if (!state.surf->resource())
return false;
state.xdgSurf = makeShared<CCXdgSurface>(state.xdgShell->sendGetXdgSurface(state.surf->resource()));
if (!state.xdgSurf->resource())
return false;
state.xdgToplevel = makeShared<CCXdgToplevel>(state.xdgSurf->sendGetToplevel());
if (!state.xdgToplevel->resource())
return false;
state.xdgToplevel->setClose([&](CCXdgToplevel* p) { exit(0); });
state.xdgToplevel->setConfigure([&](CCXdgToplevel* p, int32_t w, int32_t h, wl_array* arr) {
state.geom = {1280, 720};
if (!createShm(state, state.geom))
exit(-1);
});
state.xdgSurf->setConfigure([&](CCXdgSurface* p, uint32_t serial) {
if (!state.shmBuf)
debugLog("xdgSurf configure but no buf made yet?");
state.xdgSurf->sendSetWindowGeometry(0, 0, state.geom.x, state.geom.y);
state.surf->sendAttach(state.shmBuf.get(), 0, 0);
state.surf->sendCommit();
state.xdgSurf->sendAckConfigure(serial);
if (!started) {
started = true;
clientLog("started");
}
});
state.xdgToplevel->sendSetTitle("pointer-warp test client");
state.xdgToplevel->sendSetAppId("pointer-warp");
state.surf->sendAttach(nullptr, 0, 0);
state.surf->sendCommit();
return true;
}
static bool setupSeat(SWlState& state) {
state.pointer = makeShared<CCWlPointer>(state.wlSeat->sendGetPointer());
if (!state.pointer->resource())
return false;
state.pointer->setEnter([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf, wl_fixed_t x, wl_fixed_t y) {
debugLog("Got pointer enter event, serial {}, x {}, y {}", serial, x, y);
state.enterSerial = serial;
});
state.pointer->setLeave([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf) { debugLog("Got pointer leave event, serial {}", serial); });
state.pointer->setMotion([&](CCWlPointer* p, uint32_t serial, wl_fixed_t x, wl_fixed_t y) { debugLog("Got pointer motion event, serial {}, x {}, y {}", serial, x, y); });
return true;
}
// format is like below
// "warp 20 20\n" would ask to warp cursor to x=20,y=20 in surface local coords
static void parseRequest(SWlState& state, std::string req) {
if (req.contains("exit")) {
shouldExit = true;
return;
}
if (!req.starts_with("warp "))
return;
auto it = req.find_first_of('\n');
if (it == std::string::npos)
return;
req = req.substr(0, it);
it = req.find_first_of(' ');
if (it == std::string::npos)
return;
req = req.substr(it + 1);
it = req.find_first_of(' ');
int x = std::stoi(req.substr(0, it));
int y = std::stoi(req.substr(it + 1));
state.pointerWarp->sendWarpPointer(state.surf->resource(), state.pointer->resource(), wl_fixed_from_int(x), wl_fixed_from_int(y), state.enterSerial);
// sync the request then reply
wl_display_roundtrip(state.display);
clientLog("parsed request to move to x:{}, y:{}", x, y);
}
int main(int argc, char** argv) {
if (argc != 1 && argc != 2)
clientLog("Only the \"--debug\" switch is allowed, it turns on debug logs.");
if (argc == 2 && std::string{argv[1]} == "--debug")
debug = true;
SWlState state;
// WAYLAND_DISPLAY env should be set to the correct one
state.display = wl_display_connect(nullptr);
if (!state.display) {
clientLog("Failed to connect to wayland display");
return -1;
}
if (!bindRegistry(state) || !setupSeat(state) || !setupToplevel(state))
return -1;
std::array<char, 1024> readBuf;
readBuf.fill(0);
wl_display_flush(state.display);
struct pollfd fds[2] = {{.fd = wl_display_get_fd(state.display), .events = POLLIN | POLLOUT}, {.fd = STDIN_FILENO, .events = POLLIN}};
while (!shouldExit && poll(fds, 2, 0) != -1) {
if (fds[0].revents & POLLIN) {
wl_display_flush(state.display);
if (wl_display_prepare_read(state.display) == 0) {
wl_display_read_events(state.display);
wl_display_dispatch_pending(state.display);
} else
wl_display_dispatch(state.display);
int ret = 0;
do {
ret = wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
} while (ret > 0);
}
if (fds[1].revents & POLLIN) {
ssize_t bytesRead = read(fds[1].fd, readBuf.data(), 1023);
if (bytesRead == -1)
continue;
readBuf[bytesRead] = 0;
parseRequest(state, std::string{readBuf.data()});
}
}
wl_display* display = state.display;
state = {};
wl_display_disconnect(display);
return 0;
}

View file

@ -0,0 +1,297 @@
#include <sys/poll.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <print>
#include <wayland-client.h>
#include <wayland.hpp>
#include <xdg-shell.hpp>
#include <keyboard-shortcuts-inhibit-unstable-v1.hpp>
#include <hyprutils/memory/SharedPtr.hpp>
#include <hyprutils/math/Vector2D.hpp>
using Hyprutils::Math::Vector2D;
using namespace Hyprutils::Memory;
struct SWlState {
wl_display* display;
CSharedPointer<CCWlRegistry> registry;
// protocols
CSharedPointer<CCWlCompositor> wlCompositor;
CSharedPointer<CCWlSeat> wlSeat;
CSharedPointer<CCWlShm> wlShm;
CSharedPointer<CCXdgWmBase> xdgShell;
CSharedPointer<CCZwpKeyboardShortcutsInhibitManagerV1> inhibitManager;
// shm/buffer stuff
CSharedPointer<CCWlShmPool> shmPool;
CSharedPointer<CCWlBuffer> shmBuf;
int shmFd;
size_t shmBufSize;
bool xrgb8888_support = false;
// surface/toplevel stuff
CSharedPointer<CCWlSurface> surf;
CSharedPointer<CCXdgSurface> xdgSurf;
CSharedPointer<CCXdgToplevel> xdgToplevel;
Vector2D geom;
// pointer
CSharedPointer<CCWlPointer> pointer;
uint32_t enterSerial;
// shortcut inhibiting
CSharedPointer<CCZwpKeyboardShortcutsInhibitorV1> inhibitor;
};
static bool debug, started, shouldExit;
template <typename... Args>
//NOLINTNEXTLINE
static void clientLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
std::println("{}", text);
std::fflush(stdout);
}
template <typename... Args>
//NOLINTNEXTLINE
static void debugLog(std::format_string<Args...> fmt, Args&&... args) {
std::string text = std::vformat(fmt.get(), std::make_format_args(args...));
if (!debug)
return;
std::println("{}", text);
std::fflush(stdout);
}
static bool bindRegistry(SWlState& state) {
state.registry = makeShared<CCWlRegistry>((wl_proxy*)wl_display_get_registry(state.display));
state.registry->setGlobal([&](CCWlRegistry* r, uint32_t id, const char* name, uint32_t version) {
const std::string NAME = name;
if (NAME == "wl_compositor") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlCompositor = makeShared<CCWlCompositor>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_compositor_interface, 6));
} else if (NAME == "wl_shm") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlShm = makeShared<CCWlShm>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_shm_interface, 1));
} else if (NAME == "wl_seat") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.wlSeat = makeShared<CCWlSeat>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &wl_seat_interface, 9));
} else if (NAME == "xdg_wm_base") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.xdgShell = makeShared<CCXdgWmBase>((wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &xdg_wm_base_interface, 1));
} else if (NAME == "zwp_keyboard_shortcuts_inhibit_manager_v1") {
debugLog(" > binding to global: {} (version {}) with id {}", name, version, id);
state.inhibitManager = makeShared<CCZwpKeyboardShortcutsInhibitManagerV1>(
(wl_proxy*)wl_registry_bind((wl_registry*)state.registry->resource(), id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1));
}
});
state.registry->setGlobalRemove([](CCWlRegistry* r, uint32_t id) { debugLog("Global {} removed", id); });
wl_display_roundtrip(state.display);
if (!state.wlCompositor || !state.wlShm || !state.wlSeat || !state.xdgShell || !state.inhibitManager) {
clientLog("Failed to get protocols from Hyprland");
return false;
}
return true;
}
static bool createShm(SWlState& state, Vector2D geom) {
if (!state.xrgb8888_support)
return false;
size_t stride = geom.x * 4;
size_t size = geom.y * stride;
if (!state.shmPool) {
const char* name = "/wl-shm-shortcut-inhibitor";
state.shmFd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (state.shmFd < 0)
return false;
if (shm_unlink(name) < 0 || ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
return false;
}
state.shmPool = makeShared<CCWlShmPool>(state.wlShm->sendCreatePool(state.shmFd, size));
if (!state.shmPool->resource()) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmBufSize = size;
} else if (size > state.shmBufSize) {
if (ftruncate(state.shmFd, size) < 0) {
close(state.shmFd);
state.shmFd = -1;
state.shmPool.reset();
return false;
}
state.shmPool->sendResize(size);
state.shmBufSize = size;
}
auto buf = makeShared<CCWlBuffer>(state.shmPool->sendCreateBuffer(0, geom.x, geom.y, stride, WL_SHM_FORMAT_XRGB8888));
if (!buf->resource())
return false;
if (state.shmBuf) {
state.shmBuf->sendDestroy();
state.shmBuf.reset();
}
state.shmBuf = buf;
return true;
}
static bool setupToplevel(SWlState& state) {
state.wlShm->setFormat([&](CCWlShm* p, uint32_t format) {
if (format == WL_SHM_FORMAT_XRGB8888)
state.xrgb8888_support = true;
});
state.xdgShell->setPing([&](CCXdgWmBase* p, uint32_t serial) { state.xdgShell->sendPong(serial); });
state.surf = makeShared<CCWlSurface>(state.wlCompositor->sendCreateSurface());
if (!state.surf->resource())
return false;
state.xdgSurf = makeShared<CCXdgSurface>(state.xdgShell->sendGetXdgSurface(state.surf->resource()));
if (!state.xdgSurf->resource())
return false;
state.xdgToplevel = makeShared<CCXdgToplevel>(state.xdgSurf->sendGetToplevel());
if (!state.xdgToplevel->resource())
return false;
state.xdgToplevel->setClose([&](CCXdgToplevel* p) { exit(0); });
state.xdgToplevel->setConfigure([&](CCXdgToplevel* p, int32_t w, int32_t h, wl_array* arr) {
state.geom = {1280, 720};
if (!createShm(state, state.geom))
exit(-1);
});
state.xdgSurf->setConfigure([&](CCXdgSurface* p, uint32_t serial) {
if (!state.shmBuf)
debugLog("xdgSurf configure but no buf made yet?");
state.xdgSurf->sendSetWindowGeometry(0, 0, state.geom.x, state.geom.y);
state.surf->sendAttach(state.shmBuf.get(), 0, 0);
state.surf->sendCommit();
state.xdgSurf->sendAckConfigure(serial);
if (!started) {
started = true;
clientLog("started");
}
});
state.xdgToplevel->sendSetTitle("shortcut-inhibitor test client");
state.xdgToplevel->sendSetAppId("shortcut-inhibitor");
state.surf->sendAttach(nullptr, 0, 0);
state.surf->sendCommit();
return true;
}
static bool setupSeat(SWlState& state) {
state.pointer = makeShared<CCWlPointer>(state.wlSeat->sendGetPointer());
if (!state.pointer->resource())
return false;
state.pointer->setEnter([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf, wl_fixed_t x, wl_fixed_t y) {
debugLog("Got pointer enter event, serial {}, x {}, y {}", serial, x, y);
state.enterSerial = serial;
});
state.pointer->setLeave([&](CCWlPointer* p, uint32_t serial, wl_proxy* surf) { debugLog("Got pointer leave event, serial {}", serial); });
state.pointer->setMotion([&](CCWlPointer* p, uint32_t serial, wl_fixed_t x, wl_fixed_t y) { debugLog("Got pointer motion event, serial {}, x {}, y {}", serial, x, y); });
return true;
}
static void parseRequest(SWlState& state, std::string req) {
if (req.starts_with("on")) {
state.inhibitor = makeShared<CCZwpKeyboardShortcutsInhibitorV1>(state.inhibitManager->sendInhibitShortcuts(state.surf->resource(), state.wlSeat->resource()));
state.inhibitor->setActive([&](CCZwpKeyboardShortcutsInhibitorV1* inhibitorV1) { clientLog("inhibiting"); });
state.inhibitor->setInactive([&](CCZwpKeyboardShortcutsInhibitorV1* inhibitorV1) { clientLog("inhibit disabled by compositor"); });
} else if (req.starts_with("off")) {
state.inhibitor->sendDestroy();
state.inhibitor.reset();
shouldExit = true;
clientLog("inhibit disabled by request");
}
}
int main(int argc, char** argv) {
if (argc != 1 && argc != 2)
clientLog("Only the \"--debug\" switch is allowed, it turns on debug logs.");
if (argc == 2 && std::string{argv[1]} == "--debug")
debug = true;
SWlState state;
// WAYLAND_DISPLAY env should be set to the correct one
state.display = wl_display_connect(nullptr);
if (!state.display) {
clientLog("Failed to connect to wayland display");
return -1;
}
if (!bindRegistry(state) || !setupSeat(state) || !setupToplevel(state))
return -1;
std::array<char, 1024> readBuf;
readBuf.fill(0);
wl_display_flush(state.display);
struct pollfd fds[2] = {{.fd = wl_display_get_fd(state.display), .events = POLLIN | POLLOUT}, {.fd = STDIN_FILENO, .events = POLLIN}};
while (!shouldExit && poll(fds, 2, 0) != -1) {
if (fds[0].revents & POLLIN) {
wl_display_flush(state.display);
if (wl_display_prepare_read(state.display) == 0) {
wl_display_read_events(state.display);
wl_display_dispatch_pending(state.display);
} else
wl_display_dispatch(state.display);
int ret = 0;
do {
ret = wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
} while (ret > 0);
}
if (fds[1].revents & POLLIN) {
ssize_t bytesRead = read(fds[1].fd, readBuf.data(), 1023);
if (bytesRead == -1)
continue;
readBuf[bytesRead] = 0;
parseRequest(state, std::string{readBuf.data()});
}
}
wl_display* display = state.display;
state = {};
wl_display_disconnect(display);
return 0;
}

View file

@ -0,0 +1,16 @@
CXXFLAGS = -shared -fPIC -g -std=c++2b -Wno-c++11-narrowing
INCLUDES = `pkg-config --cflags pixman-1 libdrm pangocairo libinput libudev wayland-server xkbcommon`
LIBS = `pkg-config --libs pangocairo`
SRC = src/main.cpp
TARGET = hyprtestplugin.so
all: $(TARGET)
$(TARGET): $(SRC)
$(CXX) $(CXXFLAGS) -I../.. -I../../protocols $(INCLUDES) $^ $> -o $@ $(LIBS) -O2
clean:
rm -f ./$(TARGET)
.PHONY: all clean

4
hyprtester/plugin/build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
make clean
make all

View file

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

View file

@ -0,0 +1,387 @@
#include <unistd.h>
#include <src/includes.hpp>
#include <sstream>
#include <any>
#define private public
#include <src/config/ConfigManager.hpp>
#include <src/config/ConfigDescriptions.hpp>
#include <src/managers/input/InputManager.hpp>
#include <src/managers/PointerManager.hpp>
#include <src/managers/input/trackpad/TrackpadGestures.hpp>
#include <src/desktop/rule/windowRule/WindowRuleEffectContainer.hpp>
#include <src/desktop/rule/layerRule/LayerRuleEffectContainer.hpp>
#include <src/desktop/rule/windowRule/WindowRuleApplicator.hpp>
#include <src/desktop/view/LayerSurface.hpp>
#include <src/Compositor.hpp>
#include <src/desktop/state/FocusState.hpp>
#include <src/layout/LayoutManager.hpp>
#undef private
#include <hyprutils/utils/ScopeGuard.hpp>
#include <hyprutils/string/VarList.hpp>
using namespace Hyprutils::Utils;
using namespace Hyprutils::String;
#include "globals.hpp"
// Do NOT change this function.
APICALL EXPORT std::string PLUGIN_API_VERSION() {
return HYPRLAND_API_VERSION;
}
static SDispatchResult test(std::string in) {
bool success = true;
std::string errors = "";
if (g_pConfigManager->m_configValueNumber != CONFIG_OPTIONS.size() + 1 /* autogenerated is special */) {
errors += "config value number mismatches descriptions size\n";
success = false;
}
return SDispatchResult{
.success = success,
.error = errors,
};
}
// Trigger a snap move event for the active window
static SDispatchResult snapMove(std::string in) {
const auto PLASTWINDOW = Desktop::focusState()->window();
if (!PLASTWINDOW->m_isFloating)
return {.success = false, .error = "Window must be floating"};
Vector2D pos = PLASTWINDOW->m_realPosition->goal();
Vector2D size = PLASTWINDOW->m_realSize->goal();
g_layoutManager->performSnap(pos, size, PLASTWINDOW->layoutTarget(), MBIND_MOVE, -1, size);
PLASTWINDOW->layoutTarget()->setPositionGlobal(CBox{pos, size});
return {};
}
class CTestKeyboard : public IKeyboard {
public:
static SP<CTestKeyboard> create(bool isVirtual) {
auto keeb = SP<CTestKeyboard>(new CTestKeyboard());
keeb->m_self = keeb;
keeb->m_isVirtual = isVirtual;
keeb->m_shareStates = !isVirtual;
return keeb;
}
virtual bool isVirtual() {
return m_isVirtual;
}
virtual SP<Aquamarine::IKeyboard> aq() {
return nullptr;
}
void sendKey(uint32_t key, bool pressed) {
auto event = IKeyboard::SKeyEvent{
.timeMs = sc<uint32_t>(Time::millis(Time::steadyNow())),
.keycode = key,
.state = pressed ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED,
};
updatePressed(event.keycode, pressed);
m_keyboardEvents.key.emit(event);
}
void destroy() {
m_events.destroy.emit();
}
private:
bool m_isVirtual = false;
};
class CTestMouse : public IPointer {
public:
static SP<CTestMouse> create(bool isVirtual) {
auto maus = SP<CTestMouse>(new CTestMouse());
maus->m_self = maus;
maus->m_isVirtual = isVirtual;
maus->m_deviceName = "test-mouse";
maus->m_hlName = "test-mouse";
return maus;
}
virtual bool isVirtual() {
return m_isVirtual;
}
virtual SP<Aquamarine::IPointer> aq() {
return nullptr;
}
void destroy() {
m_events.destroy.emit();
}
private:
bool m_isVirtual = false;
};
SP<CTestMouse> g_mouse;
SP<CTestKeyboard> g_keyboard;
static SDispatchResult pressAlt(std::string in) {
g_pInputManager->m_lastMods = in == "1" ? HL_MODIFIER_ALT : 0;
return {.success = true};
}
static SDispatchResult simulateGesture(std::string in) {
CVarList data(in);
uint32_t fingers = 3;
try {
fingers = std::stoul(data[1]);
} catch (...) { return {.success = false}; }
if (data[0] == "down") {
g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{});
g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {0, 300}});
g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{});
} else if (data[0] == "up") {
g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{});
g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {0, -300}});
g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{});
} else if (data[0] == "left") {
g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{});
g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {-300, 0}});
g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{});
} else {
g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{});
g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {300, 0}});
g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{});
}
return {.success = true};
}
static SDispatchResult vkb(std::string in) {
auto tkb0 = CTestKeyboard::create(false);
auto tkb1 = CTestKeyboard::create(false);
auto vkb0 = CTestKeyboard::create(true);
g_pInputManager->newKeyboard(tkb0);
g_pInputManager->newKeyboard(tkb1);
g_pInputManager->newKeyboard(vkb0);
CScopeGuard x([&] {
tkb0->destroy();
tkb1->destroy();
vkb0->destroy();
});
const auto& PRESSED = g_pInputManager->getKeysFromAllKBs();
const uint32_t TESTKEY = 1;
tkb0->sendKey(TESTKEY, true);
if (!std::ranges::contains(PRESSED, TESTKEY)) {
return {
.success = false,
.error = "Expected pressed key not found",
};
}
tkb1->sendKey(TESTKEY, true);
tkb0->sendKey(TESTKEY, false);
if (!std::ranges::contains(PRESSED, TESTKEY)) {
return {
.success = false,
.error = "Expected pressed key not found (kb share state)",
};
}
vkb0->sendKey(TESTKEY, true);
tkb1->sendKey(TESTKEY, false);
if (std::ranges::contains(PRESSED, TESTKEY)) {
return {
.success = false,
.error = "Expected released key found in pressed (vkb no share state)",
};
}
return {};
}
static SDispatchResult scroll(std::string in) {
double by;
try {
by = std::stod(in);
} catch (...) { return SDispatchResult{.success = false, .error = "invalid input"}; }
Log::logger->log(Log::DEBUG, "tester: scrolling by {}", by);
g_mouse->m_pointerEvents.axis.emit(IPointer::SAxisEvent{
.delta = by,
.deltaDiscrete = 120,
.mouse = true,
});
return {};
}
static SDispatchResult click(std::string in) {
CVarList2 data(std::move(in));
uint32_t button;
bool pressed;
try {
button = std::stoul(std::string{data[0]});
pressed = std::stoul(std::string{data[1]}) == 1;
} catch (...) { return {.success = false, .error = "invalid input"}; }
Log::logger->log(Log::DEBUG, "tester: mouse button {} state {}", button, pressed);
g_mouse->m_pointerEvents.button.emit(IPointer::SButtonEvent{
.timeMs = sc<uint32_t>(Time::millis(Time::steadyNow())),
.button = button,
.state = pressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED,
.mouse = true,
});
return {};
}
static SDispatchResult keybind(std::string in) {
CVarList2 data(std::move(in));
// 0 = release, 1 = press
bool press;
// See src/devices/IKeyboard.hpp : eKeyboardModifiers for modifier bitmasks
// 0 = none, eKeyboardModifiers is shifted to start at 1
uint32_t modifier;
// keycode
uint32_t key;
try {
press = std::stoul(std::string{data[0]}) == 1;
modifier = std::stoul(std::string{data[1]});
key = std::stoul(std::string{data[2]}) - 8; // xkb offset
} catch (...) { return {.success = false, .error = "invalid input"}; }
uint32_t modifierMask = 0;
if (modifier > 0)
modifierMask = 1 << (modifier - 1);
g_pInputManager->m_lastMods = modifierMask;
g_keyboard->sendKey(key, press);
return {};
}
static Desktop::Rule::CWindowRuleEffectContainer::storageType windowRuleIDX = 0;
//
static SDispatchResult addWindowRule(std::string in) {
windowRuleIDX = Desktop::Rule::windowEffects()->registerEffect("plugin_rule");
if (Desktop::Rule::windowEffects()->registerEffect("plugin_rule") != windowRuleIDX)
return {.success = false, .error = "re-registering returned a different id?"};
return {};
}
static SDispatchResult checkWindowRule(std::string in) {
const auto PLASTWINDOW = Desktop::focusState()->window();
if (!PLASTWINDOW)
return {.success = false, .error = "No window"};
if (!PLASTWINDOW->m_ruleApplicator->m_otherProps.props.contains(windowRuleIDX))
return {.success = false, .error = "No rule"};
if (PLASTWINDOW->m_ruleApplicator->m_otherProps.props[windowRuleIDX]->effect != "effect")
return {.success = false, .error = "Effect isn't \"effect\""};
return {};
}
static Desktop::Rule::CLayerRuleEffectContainer::storageType layerRuleIDX = 0;
static SDispatchResult addLayerRule(std::string in) {
layerRuleIDX = Desktop::Rule::layerEffects()->registerEffect("plugin_rule");
if (Desktop::Rule::layerEffects()->registerEffect("plugin_rule") != layerRuleIDX)
return {.success = false, .error = "re-registering returned a different id?"};
return {};
}
static SDispatchResult checkLayerRule(std::string in) {
if (g_pCompositor->m_layers.size() != 3)
return {.success = false, .error = "Layers under test not here"};
for (const auto& layer : g_pCompositor->m_layers) {
if (layer->m_namespace == "rule-layer") {
if (!layer->m_ruleApplicator->m_otherProps.props.contains(layerRuleIDX))
return {.success = false, .error = "No rule"};
if (layer->m_ruleApplicator->m_otherProps.props[layerRuleIDX]->effect != "effect")
return {.success = false, .error = "Effect isn't \"effect\""};
} else if (layer->m_namespace == "norule-layer") {
if (layer->m_ruleApplicator->m_otherProps.props.contains(layerRuleIDX))
return {.success = false, .error = "Rule even though it shouldn't"};
} else
return {.success = false, .error = "Unrecognized layer"};
}
return {};
}
static SDispatchResult floatingFocusOnFullscreen(std::string in) {
const auto PLASTWINDOW = Desktop::focusState()->window();
if (!PLASTWINDOW)
return {.success = false, .error = "No window"};
if (!PLASTWINDOW->m_isFloating)
return {.success = false, .error = "Window must be floating"};
if (PLASTWINDOW->m_alpha != 1.f)
return {.success = false, .error = "floating window doesnt restore it opacity when focused on fullscreen workspace"};
if (!PLASTWINDOW->m_createdOverFullscreen)
return {.success = false, .error = "floating window doesnt get flagged as createdOverFullscreen"};
return {};
}
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
PHANDLE = handle;
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:test", ::test);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:snapmove", ::snapMove);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:vkb", ::vkb);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:alt", ::pressAlt);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:scroll", ::scroll);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:click", ::click);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_window_rule", ::addWindowRule);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_window_rule", ::checkWindowRule);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_layer_rule", ::addLayerRule);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_layer_rule", ::checkLayerRule);
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:floating_focus_on_fullscreen", ::floatingFocusOnFullscreen);
// init mouse
g_mouse = CTestMouse::create(false);
g_pInputManager->newMouse(g_mouse);
// init keyboard
g_keyboard = CTestKeyboard::create(false);
g_pInputManager->newKeyboard(g_keyboard);
return {"hyprtestplugin", "hyprtestplugin", "Vaxry", "1.0"};
}
APICALL EXPORT void PLUGIN_EXIT() {
g_mouse->destroy();
g_mouse.reset();
g_keyboard->destroy();
g_keyboard.reset();
}

2
hyprtester/protocols/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

17
hyprtester/src/Log.hpp Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include <string>
#include <format>
#include <print>
namespace NLog {
template <typename... Args>
//NOLINTNEXTLINE
void log(std::format_string<Args...> fmt, Args&&... args) {
std::string logMsg = "";
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
std::println("{}", logMsg);
std::fflush(stdout);
}
}

View file

@ -0,0 +1,138 @@
#include "hyprctlCompat.hpp"
#include "shared.hpp"
#include <pwd.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <filesystem>
#include <fstream>
#include <algorithm>
#include <csignal>
#include <cerrno>
#include <print>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::Memory;
static int getUID() {
const auto UID = getuid();
const auto PWUID = getpwuid(UID);
return PWUID ? PWUID->pw_uid : UID;
}
static std::string getRuntimeDir() {
const auto XDG = getenv("XDG_RUNTIME_DIR");
if (!XDG) {
const std::string USERID = std::to_string(getUID());
return "/run/user/" + USERID + "/hypr";
}
return std::string{XDG} + "/hypr";
}
std::vector<SInstanceData> instances() {
std::vector<SInstanceData> result;
try {
if (!std::filesystem::exists(getRuntimeDir()))
return {};
} catch (std::exception& e) { return {}; }
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().filename().string();
try {
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() + "/hyprland.lock");
int i = 0;
for (std::string line; std::getline(ifs, line); ++i) {
if (i == 0) {
try {
data->pid = std::stoull(line);
} catch (std::exception& e) { continue; }
} else if (i == 1) {
data->wlSocket = line;
} else
break;
}
ifs.close();
}
std::erase_if(result, [&](const auto& el) { return kill(el.pid, 0) != 0 && errno == ESRCH; });
std::sort(result.begin(), result.end(), [&](const auto& a, const auto& b) { return a.time < b.time; });
return result;
}
std::string getFromSocket(const std::string& cmd) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
auto t = timeval{.tv_sec = 5, .tv_usec = 0};
setsockopt(SERVERSOCKET, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(struct timeval));
if (SERVERSOCKET < 0) {
std::println("socket: Couldn't open a socket (1)");
return "";
}
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
std::string socketPath = getRuntimeDir() + "/" + HIS + "/.socket.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
if (connect(SERVERSOCKET, rc<sockaddr*>(&serverAddress), SUN_LEN(&serverAddress)) < 0) {
std::println("Couldn't connect to {}. (3)", socketPath);
return "";
}
auto sizeWritten = write(SERVERSOCKET, cmd.c_str(), cmd.length());
if (sizeWritten < 0) {
std::println("Couldn't write (4)");
return "";
}
std::string reply = "";
char buffer[8192] = {0};
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
if (errno == EWOULDBLOCK)
std::println("Hyprland IPC didn't respond in time");
std::println("Couldn't read (5)");
return "";
}
reply += std::string(buffer, sizeWritten);
while (sizeWritten == 8192) {
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
std::println("Couldn't read (5)");
return "";
}
reply += std::string(buffer, sizeWritten);
}
close(SERVERSOCKET);
return reply;
}

View file

@ -0,0 +1,16 @@
#pragma once
#include <vector>
#include <string>
#include <cstdint>
struct SInstanceData {
std::string id;
uint64_t time;
uint64_t pid;
std::string wlSocket;
bool valid = true;
};
std::vector<SInstanceData> instances();
std::string getFromSocket(const std::string& cmd);

261
hyprtester/src/main.cpp Normal file
View file

@ -0,0 +1,261 @@
// This is a tester for Hyprland. It will launch the built binary in ./build/Hyprland
// in headless mode and test various things.
// for now it's quite basic and limited, but will be expanded in the future.
// NOTE: This tester has to be ran from its directory!!
// Some TODO:
// - Add a plugin built alongside so that we can do more detailed tests (e.g. simulating keystrokes)
// - test coverage
// - maybe figure out a way to do some visual tests too?
// Required runtime deps for checks:
// - kitty
// - xeyes
#include "shared.hpp"
#include "hyprctlCompat.hpp"
#include "tests/main/tests.hpp"
#include "tests/clients/tests.hpp"
#include "tests/plugin/plugin.hpp"
#include <filesystem>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include <hyprutils/memory/Casts.hpp>
using namespace Hyprutils::Memory;
#include <csignal>
#include <cerrno>
#include <chrono>
#include <thread>
#include <print>
#include <string_view>
#include <span>
#include "Log.hpp"
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define SP CSharedPointer
static int ret = 0;
static SP<CProcess> hyprlandProc;
static const std::string cwd = std::filesystem::current_path().string();
//
static bool launchHyprland(std::string configPath, std::string binaryPath) {
if (binaryPath == "") {
std::error_code ec;
if (!std::filesystem::exists(cwd + "/../build/Hyprland", ec) || ec) {
NLog::log("{}No Hyprland binary", Colors::RED);
return false;
}
binaryPath = cwd + "/../build/Hyprland";
}
if (configPath == "") {
std::error_code ec;
if (!std::filesystem::exists(cwd + "/test.conf", ec) || ec) {
NLog::log("{}No test config", Colors::RED);
return false;
}
configPath = cwd + "/test.conf";
}
NLog::log("{}Launching Hyprland", Colors::YELLOW);
hyprlandProc = makeShared<CProcess>(binaryPath, std::vector<std::string>{"--config", configPath});
hyprlandProc->addEnv("HYPRLAND_HEADLESS_ONLY", "1");
NLog::log("{}Launched async process", Colors::YELLOW);
return hyprlandProc->runAsync();
}
static bool hyprlandAlive() {
NLog::log("{}hyprlandAlive", Colors::YELLOW);
kill(hyprlandProc->pid(), 0);
return errno != ESRCH;
}
static void help() {
NLog::log("usage: hyprtester [arg [...]].\n");
NLog::log(R"(Arguments:
--help -h - Show this message again
--config FILE -c FILE - Specify config file to use
--binary FILE -b FILE - Specify Hyprland binary to use
--plugin FILE -p FILE - Specify the location of the test plugin)");
}
int main(int argc, char** argv, char** envp) {
std::string configPath = "";
std::string binaryPath = "";
std::string pluginPath = std::filesystem::current_path().string();
if (argc > 1) {
std::span<char*> args{argv + 1, sc<std::size_t>(argc - 1)};
for (auto it = args.begin(); it != args.end(); it++) {
std::string_view value = *it;
if (value == "--config" || value == "-c") {
if (std::next(it) == args.end()) {
help();
return 1;
}
configPath = *std::next(it);
try {
configPath = std::filesystem::canonical(configPath);
if (!std::filesystem::is_regular_file(configPath)) {
throw std::exception();
}
} catch (...) {
std::println(stderr, "[ ERROR ] Config file '{}' doesn't exist!", configPath);
help();
return 1;
}
it++;
continue;
} else if (value == "--binary" || value == "-b") {
if (std::next(it) == args.end()) {
help();
return 1;
}
binaryPath = *std::next(it);
try {
binaryPath = std::filesystem::canonical(binaryPath);
if (!std::filesystem::is_regular_file(binaryPath)) {
throw std::exception();
}
} catch (...) {
std::println(stderr, "[ ERROR ] Binary '{}' doesn't exist!", binaryPath);
help();
return 1;
}
it++;
continue;
} else if (value == "--plugin" || value == "-p") {
if (std::next(it) == args.end()) {
help();
return 1;
}
pluginPath = *std::next(it);
try {
pluginPath = std::filesystem::canonical(pluginPath);
if (!std::filesystem::is_regular_file(pluginPath)) {
throw std::exception();
}
} catch (...) {
std::println(stderr, "[ ERROR ] plugin '{}' doesn't exist!", pluginPath);
help();
return 1;
}
it++;
continue;
} else if (value == "--help" || value == "-h") {
help();
return 0;
} else {
std::println(stderr, "[ ERROR ] Unknown option '{}' !", *it);
help();
return 1;
}
}
}
NLog::log("{}launching hl", Colors::YELLOW);
if (!launchHyprland(configPath, binaryPath)) {
NLog::log("{}well it failed", Colors::RED);
return 1;
}
// hyprland has launched, let's check if it's alive after 10s
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
NLog::log("{}slept for 10s", Colors::YELLOW);
if (!hyprlandAlive()) {
NLog::log("{}Hyprland failed to launch", Colors::RED);
return 1;
}
// wonderful, we are in. Let's get the instance signature.
NLog::log("{}trying to get INSTANCES", Colors::YELLOW);
const auto INSTANCES = instances();
if (INSTANCES.empty()) {
NLog::log("{}Hyprland failed to launch (2)", Colors::RED);
return 1;
}
HIS = INSTANCES.back().id;
WLDISPLAY = INSTANCES.back().wlSocket;
NLog::log("{}trying to get create headless output", Colors::YELLOW);
getFromSocket("/output create headless");
NLog::log("{}trying to load plugin", Colors::YELLOW);
if (const auto R = getFromSocket(std::format("/plugin load {}", pluginPath)); R != "ok") {
NLog::log("{}Failed to load the test plugin: {}", Colors::RED, R);
getFromSocket("/dispatch exit 1");
return 1;
}
NLog::log("{}Loaded plugin", Colors::YELLOW);
NLog::log("{}Running main tests", Colors::YELLOW);
for (const auto& fn : testFns) {
EXPECT(fn(), true);
}
NLog::log("{}Running protocol client tests", Colors::YELLOW);
for (const auto& fn : clientTestFns) {
EXPECT(fn(), true);
}
NLog::log("{}running plugin test", Colors::YELLOW);
EXPECT(testPlugin(), true);
NLog::log("{}running vkb test from plugin", Colors::YELLOW);
EXPECT(testVkb(), true);
// kill hyprland
NLog::log("{}dispatching exit", Colors::YELLOW);
getFromSocket("/dispatch exit");
NLog::log("\n{}Summary:\n\tPASSED: {}{}{}/{}\n\tFAILED: {}{}{}/{}\n{}", Colors::RESET, Colors::GREEN, TESTS_PASSED, Colors::RESET, TESTS_PASSED + TESTS_FAILED, Colors::RED,
TESTS_FAILED, Colors::RESET, TESTS_PASSED + TESTS_FAILED, (TESTS_FAILED > 0 ? std::string{Colors::RED} + "\nSome tests failed.\n" : ""));
kill(hyprlandProc->pid(), SIGKILL);
hyprlandProc.reset();
return ret || TESTS_FAILED;
}

111
hyprtester/src/shared.hpp Normal file
View file

@ -0,0 +1,111 @@
// Stolen from hyprutils
#pragma once
#include <iostream>
inline std::string HIS = "";
inline std::string WLDISPLAY = "";
inline int TESTS_PASSED = 0;
inline int TESTS_FAILED = 0;
namespace Colors {
constexpr const char* RED = "\x1b[31m";
constexpr const char* GREEN = "\x1b[32m";
constexpr const char* YELLOW = "\x1b[33m";
constexpr const char* BLUE = "\x1b[34m";
constexpr const char* MAGENTA = "\x1b[35m";
constexpr const char* CYAN = "\x1b[36m";
constexpr const char* RESET = "\x1b[0m";
};
#define EXPECT_MAX_DELTA(expr, desired, delta) \
if (const auto RESULT = expr; std::abs(RESULT - (desired)) > delta) { \
NLog::log("{}Failed: {}{}, expected max delta of {}, got delta {} ({} - {}). Source: {}@{}.", Colors::RED, Colors::RESET, #expr, delta, (RESULT - (desired)), RESULT, \
desired, __FILE__, __LINE__); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{}. Got {}", Colors::GREEN, Colors::RESET, #expr, (RESULT - (desired))); \
TESTS_PASSED++; \
}
#define EXPECT(expr, val) \
if (const auto RESULT = expr; RESULT != (val)) { \
NLog::log("{}Failed: {}{}, expected {}, got {}. Source: {}@{}.", Colors::RED, Colors::RESET, #expr, val, RESULT, __FILE__, __LINE__); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{}. Got {}", Colors::GREEN, Colors::RESET, #expr, val); \
TESTS_PASSED++; \
}
#define EXPECT_NOT(expr, val) \
if (const auto RESULT = expr; RESULT == (val)) { \
NLog::log("{}Failed: {}{}, expected not {}, got {}. Source: {}@{}.", Colors::RED, Colors::RESET, #expr, val, RESULT, __FILE__, __LINE__); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{}. Got {}", Colors::GREEN, Colors::RESET, #expr, val); \
TESTS_PASSED++; \
}
#define EXPECT_VECTOR2D(expr, val) \
do { \
const auto& RESULT = expr; \
const auto& EXPECTED = val; \
if (!(std::abs(RESULT.x - EXPECTED.x) < 1e-6 && std::abs(RESULT.y - EXPECTED.y) < 1e-6)) { \
NLog::log("{}Failed: {}{}, expected [{}, {}], got [{}, {}]. Source: {}@{}.", Colors::RED, Colors::RESET, #expr, EXPECTED.x, EXPECTED.y, RESULT.x, RESULT.y, __FILE__, \
__LINE__); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{}. Got [{}, {}].", Colors::GREEN, Colors::RESET, #expr, RESULT.x, RESULT.y); \
TESTS_PASSED++; \
} \
} while (0)
#define EXPECT_CONTAINS(haystack, needle) \
if (const auto EXPECTED = needle; !std::string{haystack}.contains(EXPECTED)) { \
NLog::log("{}Failed: {}{} should contain {} but doesn't. Source: {}@{}. Haystack is:\n{}", Colors::RED, Colors::RESET, #haystack, #needle, __FILE__, __LINE__, \
std::string{haystack}); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{} contains {}.", Colors::GREEN, Colors::RESET, #haystack, EXPECTED); \
TESTS_PASSED++; \
}
#define EXPECT_NOT_CONTAINS(haystack, needle) \
if (std::string{haystack}.contains(needle)) { \
NLog::log("{}Failed: {}{} shouldn't contain {} but does. Source: {}@{}. Haystack is:\n{}", Colors::RED, Colors::RESET, #haystack, #needle, __FILE__, __LINE__, \
std::string{haystack}); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{} doesn't contain {}.", Colors::GREEN, Colors::RESET, #haystack, #needle); \
TESTS_PASSED++; \
}
#define EXPECT_STARTS_WITH(str, what) \
if (!std::string{str}.starts_with(what)) { \
NLog::log("{}Failed: {}{} should start with {} but doesn't. Source: {}@{}. String is:\n{}", Colors::RED, Colors::RESET, #str, #what, __FILE__, __LINE__, \
std::string{str}); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{} starts with {}.", Colors::GREEN, Colors::RESET, #str, #what); \
TESTS_PASSED++; \
}
#define EXPECT_COUNT_STRING(str, what, no) \
if (Tests::countOccurrences(str, what) != no) { \
NLog::log("{}Failed: {}{} should contain {} {} times, but doesn't. Source: {}@{}. String is:\n{}", Colors::RED, Colors::RESET, #str, #what, no, __FILE__, __LINE__, \
std::string{str}); \
ret = 1; \
TESTS_FAILED++; \
} else { \
NLog::log("{}Passed: {}{} contains {} {} times.", Colors::GREEN, Colors::RESET, #str, #what, no); \
TESTS_PASSED++; \
}
#define OK(x) EXPECT(x, "ok")

View file

@ -0,0 +1 @@
build.hpp

View file

@ -0,0 +1,151 @@
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "../shared.hpp"
#include "tests.hpp"
#include "build.hpp"
#include <hyprutils/os/FileDescriptor.hpp>
#include <hyprutils/os/Process.hpp>
#include <sys/poll.h>
#include <unistd.h>
#include <csignal>
#include <thread>
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define SP CSharedPointer
struct SClient {
SP<CProcess> proc;
std::array<char, 1024> readBuf;
CFileDescriptor readFd, writeFd;
struct pollfd fds;
};
static int ret = 0;
static bool waitForWindow(SP<CProcess> proc, int windowsBefore) {
int counter = 0;
while (Tests::processAlive(proc->pid()) && Tests::windowCount() == windowsBefore) {
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (counter > 50)
return false;
}
NLog::log("{}Waited {} milliseconds for window to open", Colors::YELLOW, counter * 100);
return Tests::processAlive(proc->pid());
}
static bool startClient(SClient& client) {
NLog::log("{}Attempting to start child-window client", Colors::YELLOW);
client.proc = makeShared<CProcess>(binaryDir + "/child-window", std::vector<std::string>{});
client.proc->addEnv("WAYLAND_DISPLAY", WLDISPLAY);
int procInPipeFd[2], procOutPipeFd[2];
if (pipe(procInPipeFd) != 0 || pipe(procOutPipeFd) != 0) {
NLog::log("{}Unable to open pipe to client", Colors::RED);
return false;
}
client.writeFd = CFileDescriptor(procInPipeFd[1]);
client.proc->setStdinFD(procInPipeFd[0]);
client.readFd = CFileDescriptor(procOutPipeFd[0]);
client.proc->setStdoutFD(procOutPipeFd[1]);
if (!client.proc->runAsync()) {
NLog::log("{}Failed to run client", Colors::RED);
return false;
}
close(procInPipeFd[0]);
close(procOutPipeFd[1]);
if (!waitForWindow(client.proc, Tests::windowCount())) {
NLog::log("{}Window took too long to open", Colors::RED);
return false;
}
NLog::log("{}Started child-window client", Colors::YELLOW);
return true;
}
static void stopClient(SClient& client) {
std::string cmd = "exit\n";
write(client.writeFd.get(), cmd.c_str(), cmd.length());
kill(client.proc->pid(), SIGKILL);
client.proc.reset();
}
static bool createChild(SClient& client) {
std::string cmd = "toplevel\n";
if ((size_t)write(client.writeFd.get(), cmd.c_str(), cmd.length()) != cmd.length())
return false;
if (!waitForWindow(client.proc, Tests::windowCount()))
NLog::log("{}Child window took too long to open", Colors::RED);
if (getFromSocket("/dispatch focuswindow class:child-test-child") != "ok") {
NLog::log("{}Failed to focus child window", Colors::RED);
return false;
}
return true;
}
static bool test() {
SClient client;
if (!startClient(client))
return false;
OK(getFromSocket("/dispatch setfloating class:child-test-parent"));
OK(getFromSocket("/dispatch pin class:child-test-parent"));
createChild(client);
EXPECT(Tests::windowCount(), 2)
EXPECT_COUNT_STRING(getFromSocket("/clients"), "pinned: 1", 2);
stopClient(client);
NLog::log("{}Reloading config", Colors::YELLOW);
OK(getFromSocket("/reload"));
Tests::killAllWindows();
EXPECT(Tests::windowCount(), 0);
// test that child windows (shouldBeFloated) are not auto-grouped
NLog::log("{}Test child windows are not auto-grouped", Colors::GREEN);
auto kitty = Tests::spawnKitty();
if (!kitty) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
// create group and enable auto-grouping
OK(getFromSocket("/dispatch togglegroup"));
OK(getFromSocket("/keyword group:auto_group true"));
SClient client2;
if (!startClient(client2))
return false;
EXPECT(Tests::windowCount(), 2);
createChild(client2);
EXPECT(Tests::windowCount(), 3);
// child has set_parent so shouldBeFloated returns true, it should not be auto-grouped
EXPECT_COUNT_STRING(getFromSocket("/clients"), "grouped: 0", 1);
stopClient(client2);
Tests::killAllWindows();
EXPECT(Tests::windowCount(), 0);
return !ret;
}
REGISTER_CLIENT_TEST_FN(test);

View file

@ -0,0 +1,156 @@
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "../shared.hpp"
#include "tests.hpp"
#include "build.hpp"
#include <hyprutils/os/FileDescriptor.hpp>
#include <hyprutils/os/Process.hpp>
#include <sys/poll.h>
#include <unistd.h>
#include <csignal>
#include <thread>
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define SP CSharedPointer
struct SClient {
SP<CProcess> proc;
std::array<char, 1024> readBuf;
CFileDescriptor readFd, writeFd;
struct pollfd fds;
};
static int ret = 0;
static bool startClient(SClient& client) {
client.proc = makeShared<CProcess>(binaryDir + "/pointer-scroll", std::vector<std::string>{});
client.proc->addEnv("WAYLAND_DISPLAY", WLDISPLAY);
int pipeFds1[2], pipeFds2[2];
if (pipe(pipeFds1) != 0 || pipe(pipeFds2) != 0) {
NLog::log("{}Unable to open pipe to client", Colors::RED);
return false;
}
client.writeFd = CFileDescriptor(pipeFds1[1]);
client.proc->setStdinFD(pipeFds1[0]);
client.readFd = CFileDescriptor(pipeFds2[0]);
client.proc->setStdoutFD(pipeFds2[1]);
const int COUNT_BEFORE = Tests::windowCount();
client.proc->runAsync();
close(pipeFds1[0]);
close(pipeFds2[1]);
client.fds = {.fd = client.readFd.get(), .events = POLLIN};
if (poll(&client.fds, 1, 1000) != 1 || !(client.fds.revents & POLLIN))
return false;
client.readBuf.fill(0);
if (read(client.readFd.get(), client.readBuf.data(), client.readBuf.size() - 1) == -1)
return false;
std::string ret = std::string{client.readBuf.data()};
if (ret.find("started") == std::string::npos) {
NLog::log("{}Failed to start pointer-scroll client, read {}", Colors::RED, ret);
return false;
}
// wait for window to appear
int counter = 0;
while (Tests::processAlive(client.proc->pid()) && Tests::windowCount() == COUNT_BEFORE) {
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (counter > 50) {
NLog::log("{}pointer-scroll client took too long to open", Colors::RED);
return false;
}
}
if (getFromSocket(std::format("/dispatch setprop pid:{} no_anim 1", client.proc->pid())) != "ok") {
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
return false;
}
if (getFromSocket(std::format("/dispatch focuswindow pid:{}", client.proc->pid())) != "ok") {
NLog::log("{}Failed to focus pointer-scroll client", Colors::RED, ret);
return false;
}
NLog::log("{}Started pointer-scroll client", Colors::YELLOW);
return true;
}
static void stopClient(SClient& client) {
std::string cmd = "exit\n";
write(client.writeFd.get(), cmd.c_str(), cmd.length());
kill(client.proc->pid(), SIGKILL);
client.proc.reset();
}
static int getLastDelta(SClient& client) {
std::string cmd = "hypr";
if ((size_t)write(client.writeFd.get(), cmd.c_str(), cmd.length()) != cmd.length())
return false;
if (poll(&client.fds, 1, 1500) != 1 || !(client.fds.revents & POLLIN))
return false;
ssize_t bytesRead = read(client.fds.fd, client.readBuf.data(), 1023);
if (bytesRead == -1)
return false;
client.readBuf[bytesRead] = 0;
std::string received = std::string{client.readBuf.data()};
received.pop_back();
try {
return std::stoi(received);
} catch (...) { return -1; }
}
static bool sendScroll(int delta) {
return getFromSocket(std::format("/dispatch plugin:test:scroll {}", delta)) == "ok";
}
static bool test() {
SClient client;
if (!startClient(client))
return false;
EXPECT(getFromSocket("/keyword input:emulate_discrete_scroll 0"), "ok");
EXPECT(sendScroll(10), true);
EXPECT(getLastDelta(client), 10);
EXPECT(getFromSocket("/keyword input:scroll_factor 2"), "ok");
EXPECT(sendScroll(10), true);
EXPECT(getLastDelta(client), 20);
EXPECT(getFromSocket("r/keyword device[test-mouse-1]:scroll_factor 3"), "ok");
EXPECT(sendScroll(10), true);
EXPECT(getLastDelta(client), 30);
EXPECT(getFromSocket("r/dispatch setprop active scroll_mouse 4"), "ok");
EXPECT(sendScroll(10), true);
EXPECT(getLastDelta(client), 40);
stopClient(client);
NLog::log("{}Reloading the config", Colors::YELLOW);
OK(getFromSocket("/reload"));
return !ret;
}
REGISTER_CLIENT_TEST_FN(test);

View file

@ -0,0 +1,194 @@
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "../shared.hpp"
#include "tests.hpp"
#include "build.hpp"
#include <hyprutils/os/FileDescriptor.hpp>
#include <hyprutils/os/Process.hpp>
#include <sys/poll.h>
#include <unistd.h>
#include <csignal>
#include <thread>
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define SP CSharedPointer
struct SClient {
SP<CProcess> proc;
std::array<char, 1024> readBuf;
CFileDescriptor readFd, writeFd;
struct pollfd fds;
};
static int ret = 0;
static bool startClient(SClient& client) {
client.proc = makeShared<CProcess>(binaryDir + "/pointer-warp", std::vector<std::string>{});
client.proc->addEnv("WAYLAND_DISPLAY", WLDISPLAY);
int pipeFds1[2], pipeFds2[2];
if (pipe(pipeFds1) != 0 || pipe(pipeFds2) != 0) {
NLog::log("{}Unable to open pipe to client", Colors::RED);
return false;
}
client.writeFd = CFileDescriptor(pipeFds1[1]);
client.proc->setStdinFD(pipeFds1[0]);
client.readFd = CFileDescriptor(pipeFds2[0]);
client.proc->setStdoutFD(pipeFds2[1]);
const int COUNT_BEFORE = Tests::windowCount();
client.proc->runAsync();
close(pipeFds1[0]);
close(pipeFds2[1]);
client.fds = {.fd = client.readFd.get(), .events = POLLIN};
if (poll(&client.fds, 1, 1000) != 1 || !(client.fds.revents & POLLIN))
return false;
client.readBuf.fill(0);
if (read(client.readFd.get(), client.readBuf.data(), client.readBuf.size() - 1) == -1)
return false;
std::string ret = std::string{client.readBuf.data()};
if (ret.find("started") == std::string::npos) {
NLog::log("{}Failed to start pointer-warp client, read {}", Colors::RED, ret);
return false;
}
// wait for window to appear
int counter = 0;
while (Tests::processAlive(client.proc->pid()) && Tests::windowCount() == COUNT_BEFORE) {
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (counter > 50) {
NLog::log("{}pointer-warp client took too long to open", Colors::RED);
return false;
}
}
if (getFromSocket(std::format("/dispatch setprop pid:{} no_anim 1", client.proc->pid())) != "ok") {
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
return false;
}
if (getFromSocket(std::format("/dispatch focuswindow pid:{}", client.proc->pid())) != "ok") {
NLog::log("{}Failed to focus pointer-warp client", Colors::RED, ret);
return false;
}
NLog::log("{}Started pointer-warp client", Colors::YELLOW);
return true;
}
static void stopClient(SClient& client) {
std::string cmd = "exit\n";
write(client.writeFd.get(), cmd.c_str(), cmd.length());
kill(client.proc->pid(), SIGKILL);
client.proc.reset();
}
// format is like below
// "warp 20 20\n" would ask to warp cursor to x=20,y=20 in surface local coords
static bool sendWarp(SClient& client, int x, int y) {
std::string cmd = std::format("warp {} {}\n", x, y);
if ((size_t)write(client.writeFd.get(), cmd.c_str(), cmd.length()) != cmd.length())
return false;
if (poll(&client.fds, 1, 1500) != 1 || !(client.fds.revents & POLLIN))
return false;
ssize_t bytesRead = read(client.fds.fd, client.readBuf.data(), 1023);
if (bytesRead == -1)
return false;
client.readBuf[bytesRead] = 0;
std::string recieved = std::string{client.readBuf.data()};
recieved.pop_back();
return true;
}
static bool isCursorPos(int x, int y) {
// TODO: add a better way to do this using test plugin?
std::string res = getFromSocket("/cursorpos");
if (res == "error") {
NLog::log("{}Cursorpos err'd: {}", Colors::RED, res);
return false;
}
auto it = res.find_first_of(' ');
if (res.at(it - 1) != ',') {
NLog::log("{}Cursorpos err'd: {}", Colors::RED, res);
return false;
}
int cursorX = std::stoi(res.substr(0, it - 1));
int cursorY = std::stoi(res.substr(it + 1));
// somehow this is always gives 1 less than surfbox->pos()??
res = getFromSocket("/activewindow");
it = res.find("at: ") + 4;
res = res.substr(it, res.find_first_of('\n', it) - it);
it = res.find_first_of(',');
int clientX = cursorX - std::stoi(res.substr(0, it)) + 1;
int clientY = cursorY - std::stoi(res.substr(it + 1)) + 1;
return clientX == x && clientY == y;
}
static bool test() {
SClient client;
if (!startClient(client))
return false;
EXPECT(sendWarp(client, 100, 100), true);
EXPECT(isCursorPos(100, 100), true);
EXPECT(sendWarp(client, 0, 0), true);
EXPECT(isCursorPos(0, 0), true);
EXPECT(sendWarp(client, 200, 200), true);
EXPECT(isCursorPos(200, 200), true);
EXPECT(sendWarp(client, 100, -100), true);
EXPECT(isCursorPos(200, 200), true);
EXPECT(sendWarp(client, 234, 345), true);
EXPECT(isCursorPos(234, 345), true);
EXPECT(sendWarp(client, -1, -1), true);
EXPECT(isCursorPos(234, 345), true);
EXPECT(sendWarp(client, 1, -1), true);
EXPECT(isCursorPos(234, 345), true);
EXPECT(sendWarp(client, 13, 37), true);
EXPECT(isCursorPos(13, 37), true);
EXPECT(sendWarp(client, -100, 100), true);
EXPECT(isCursorPos(13, 37), true);
EXPECT(sendWarp(client, -1, 1), true);
EXPECT(isCursorPos(13, 37), true);
stopClient(client);
NLog::log("{}Reloading the config", Colors::YELLOW);
OK(getFromSocket("/reload"));
return !ret;
}
REGISTER_CLIENT_TEST_FN(test);

View file

@ -0,0 +1,180 @@
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "../shared.hpp"
#include "tests.hpp"
#include "build.hpp"
#include <hyprutils/os/FileDescriptor.hpp>
#include <hyprutils/os/Process.hpp>
#include <sys/poll.h>
#include <csignal>
#include <thread>
#include <filesystem>
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define SP CSharedPointer
struct SClient {
SP<CProcess> proc;
std::array<char, 1024> readBuf;
CFileDescriptor readFd, writeFd;
struct pollfd fds;
};
static int ret = 0;
static bool startClient(SClient& client) {
Tests::killAllWindows();
client.proc = makeShared<CProcess>(binaryDir + "/shortcut-inhibitor", std::vector<std::string>{});
client.proc->addEnv("WAYLAND_DISPLAY", WLDISPLAY);
int pipeFds1[2], pipeFds2[2];
if (pipe(pipeFds1) != 0 || pipe(pipeFds2) != 0) {
NLog::log("{}Unable to open pipe to client", Colors::RED);
return false;
}
client.writeFd = CFileDescriptor(pipeFds1[1]);
client.proc->setStdinFD(pipeFds1[0]);
client.readFd = CFileDescriptor(pipeFds2[0]);
client.proc->setStdoutFD(pipeFds2[1]);
const int COUNT_BEFORE = Tests::windowCount();
client.proc->runAsync();
close(pipeFds1[0]);
close(pipeFds2[1]);
client.fds = {.fd = client.readFd.get(), .events = POLLIN};
if (poll(&client.fds, 1, 1000) != 1 || !(client.fds.revents & POLLIN)) {
NLog::log("{}shortcut-inhibitor client failed poll", Colors::RED);
return false;
}
client.readBuf.fill(0);
if (read(client.readFd.get(), client.readBuf.data(), client.readBuf.size() - 1) == -1) {
NLog::log("{}shortcut-inhibitor client read failed", Colors::RED);
return false;
}
std::string ret = std::string{client.readBuf.data()};
if (ret.find("started") == std::string::npos) {
NLog::log("{}Failed to start shortcut-inhibitor client, read {}", Colors::RED, ret);
return false;
}
// wait for window to appear
int counter = 0;
while (Tests::processAlive(client.proc->pid()) && Tests::windowCount() == COUNT_BEFORE) {
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (counter > 50) {
NLog::log("{}shortcut-inhibitor client took too long to open", Colors::RED);
return false;
}
}
if (!Tests::processAlive(client.proc->pid())) {
NLog::log("{}shortcut-inhibitor client not alive", Colors::RED);
return false;
}
if (getFromSocket(std::format("/dispatch focuswindow pid:{}", client.proc->pid())) != "ok") {
NLog::log("{}Failed to focus shortcut-inhibitor client", Colors::RED, ret);
return false;
}
std::string command = "on\n";
if (write(client.writeFd.get(), command.c_str(), command.length()) == -1) {
NLog::log("{}shortcut-inhibitor client write failed", Colors::RED);
return false;
}
client.readBuf.fill(0);
if (read(client.readFd.get(), client.readBuf.data(), client.readBuf.size() - 1) == -1)
return false;
ret = std::string{client.readBuf.data()};
if (ret.find("inhibiting") == std::string::npos) {
NLog::log("{}shortcut-inhibitor client didn't return inhibiting", Colors::RED);
return false;
}
NLog::log("{}Started shortcut-inhibitor client", Colors::YELLOW);
return true;
}
static void stopClient(SClient& client) {
std::string cmd = "off\n";
write(client.writeFd.get(), cmd.c_str(), cmd.length());
kill(client.proc->pid(), SIGKILL);
client.proc.reset();
}
static std::string flagFile = "/tmp/hyprtester-keybinds.txt";
static bool checkFlag() {
bool exists = std::filesystem::exists(flagFile);
std::filesystem::remove(flagFile);
return exists;
}
static bool attemptCheckFlag(int attempts, int intervalMs) {
for (int i = 0; i < attempts; i++) {
if (checkFlag())
return true;
std::this_thread::sleep_for(std::chrono::milliseconds(intervalMs));
}
return false;
}
static bool test() {
SClient client;
if (!startClient(client))
return false;
NLog::log("{}Testing keybinds", Colors::GREEN);
//basic keybind test
EXPECT(checkFlag(), false);
EXPECT(getFromSocket("/keyword bind SUPER,Y,exec,touch " + flagFile), "ok");
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
EXPECT(attemptCheckFlag(20, 50), false);
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
//keybind bypass flag test
EXPECT(checkFlag(), false);
EXPECT(getFromSocket("/keyword bindp SUPER,Y,exec,touch " + flagFile), "ok");
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
EXPECT(attemptCheckFlag(20, 50), true);
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
NLog::log("{}Testing gestures", Colors::GREEN);
//basic gesture test
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
EXPECT_NOT_CONTAINS(getFromSocket("/activewindow"), "floating: 1");
//gesture bypass flag test
OK(getFromSocket("/dispatch plugin:test:gesture right,2"));
EXPECT_CONTAINS(getFromSocket("/activewindow"), "floating: 1");
stopClient(client);
NLog::log("{}Reloading the config", Colors::YELLOW);
OK(getFromSocket("/reload"));
return !ret;
}
REGISTER_CLIENT_TEST_FN(test);

View file

@ -0,0 +1,12 @@
#pragma once
#include <vector>
#include <functional>
inline std::vector<std::function<bool()>> clientTestFns;
#define REGISTER_CLIENT_TEST_FN(fn) \
static auto _register_fn = [] { \
clientTestFns.emplace_back(fn); \
return 1; \
}();

View file

@ -0,0 +1,22 @@
#include "../../Log.hpp"
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
static bool test() {
NLog::log("{}Testing animations", Colors::GREEN);
auto str = getFromSocket("/animations");
NLog::log("{}Testing bezier curve output from `hyprctl animations`", Colors::YELLOW);
{EXPECT_CONTAINS(str, std::format("beziers:\n\n\tname: quick\n\t\tX0: 0.15\n\t\tY0: 0.00\n\t\tX1: 0.10\n\t\tY1: 1.00"))};
return !ret;
}
REGISTER_TEST_FN(test)

View file

@ -0,0 +1,27 @@
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "../shared.hpp"
static int ret = 0;
static bool test() {
NLog::log("{}Testing hyprctl monitors", Colors::GREEN);
std::string monitorsSpec = getFromSocket("j/monitors");
EXPECT_CONTAINS(monitorsSpec, R"("colorManagementPreset": "srgb")");
EXPECT_CONTAINS(getFromSocket("/keyword monitor HEADLESS-2,1920x1080x60.00000,0x0,1.0,bitdepth,10,cm,wide"), "ok")
monitorsSpec = getFromSocket("j/monitors");
EXPECT_CONTAINS(monitorsSpec, R"("colorManagementPreset": "wide")");
EXPECT_CONTAINS(getFromSocket("/keyword monitor HEADLESS-2,1920x1080x60.00000,0x0,1.0,bitdepth,10,cm,srgb,sdrbrightness,1.2,sdrsaturation,0.98"), "ok")
monitorsSpec = getFromSocket("j/monitors");
EXPECT_CONTAINS(monitorsSpec, R"("colorManagementPreset": "srgb")");
EXPECT_CONTAINS(monitorsSpec, R"("sdrBrightness": 1.20)");
EXPECT_CONTAINS(monitorsSpec, R"("sdrSaturation": 0.98)");
return !ret;
}
REGISTER_TEST_FN(test)

View file

@ -0,0 +1,254 @@
#include "../shared.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include "tests.hpp"
static int ret = 0;
static void testFloatClamp() {
for (auto const& win : {"a", "b", "c"}) {
if (!Tests::spawnKitty(win)) {
NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
++TESTS_FAILED;
ret = 1;
return;
}
}
OK(getFromSocket("/keyword dwindle:force_split 2"));
OK(getFromSocket("/keyword monitor HEADLESS-2, addreserved, 0, 20, 0, 20"));
OK(getFromSocket("/dispatch focuswindow class:c"));
OK(getFromSocket("/dispatch setfloating class:c"));
OK(getFromSocket("/dispatch resizewindowpixel exact 1200 900,class:c"));
OK(getFromSocket("/dispatch settiled class:c"));
OK(getFromSocket("/dispatch setfloating class:c"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 698,158");
EXPECT_CONTAINS(str, "size: 1200,900");
}
OK(getFromSocket("/keyword dwindle:force_split 0"));
// clean up
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
OK(getFromSocket("/reload"));
}
static void test13349() {
// Test if dwindle properly uses a focal point to place a new window.
// exposed by #13349 as a regression from #12890
for (auto const& win : {"a", "b", "c"}) {
if (!Tests::spawnKitty(win)) {
NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
++TESTS_FAILED;
ret = 1;
return;
}
}
OK(getFromSocket("/dispatch focuswindow class:c"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 967,547");
EXPECT_CONTAINS(str, "size: 931,511");
}
OK(getFromSocket("/dispatch movewindow l"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 497,22");
EXPECT_CONTAINS(str, "size: 456,1036");
}
OK(getFromSocket("/dispatch movewindow r"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 967,22");
EXPECT_CONTAINS(str, "size: 456,1036");
}
// clean up
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
}
static void testSplit() {
// Test various split methods
Tests::spawnKitty("a");
// these must not crash
EXPECT_NOT(getFromSocket("/dispatch layoutmsg swapsplit"), "ok");
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio 1 exact"), "ok");
Tests::spawnKitty("b");
OK(getFromSocket("/dispatch focuswindow class:a"));
OK(getFromSocket("/dispatch layoutmsg splitratio -0.2"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 22,22");
EXPECT_CONTAINS(str, "size: 743,1036");
}
OK(getFromSocket("/dispatch layoutmsg splitratio 1.6 exact"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 22,22");
EXPECT_CONTAINS(str, "size: 1495,1036");
}
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio fhne exact"), "ok");
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio exact"), "ok");
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio -....9"), "ok");
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio ..9"), "ok");
EXPECT_NOT(getFromSocket("/dispatch layoutmsg splitratio"), "ok");
OK(getFromSocket("/dispatch layoutmsg togglesplit"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 22,22");
EXPECT_CONTAINS(str, "size: 1876,823");
}
OK(getFromSocket("/dispatch layoutmsg swapsplit"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, "at: 22,859");
EXPECT_CONTAINS(str, "size: 1876,199");
}
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
}
static void testRotatesplit() {
OK(getFromSocket("r/keyword general:gaps_in 0"));
OK(getFromSocket("r/keyword general:gaps_out 0"));
OK(getFromSocket("r/keyword general:border_size 0"));
for (auto const& win : {"a", "b"}) {
if (!Tests::spawnKitty(win)) {
NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
++TESTS_FAILED;
ret = 1;
return;
}
}
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
// test 4 repeated rotations by 90 degrees
OK(getFromSocket("/dispatch layoutmsg rotatesplit"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,0");
EXPECT_CONTAINS(str, "size: 1920,540");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 960,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,540");
EXPECT_CONTAINS(str, "size: 1920,540");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
// test different angles
OK(getFromSocket("/dispatch layoutmsg rotatesplit 180"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 960,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit 270"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,540");
EXPECT_CONTAINS(str, "size: 1920,540");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit 360"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,0");
EXPECT_CONTAINS(str, "size: 1920,540");
}
// test negative angles
OK(getFromSocket("/dispatch layoutmsg rotatesplit -90"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 0,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
OK(getFromSocket("/dispatch layoutmsg rotatesplit -180"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 960,0");
EXPECT_CONTAINS(str, "size: 960,1080");
}
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
OK(getFromSocket("/reload"));
}
static bool test() {
NLog::log("{}Testing Dwindle layout", Colors::GREEN);
// test
NLog::log("{}Testing float clamp", Colors::GREEN);
testFloatClamp();
NLog::log("{}Testing #13349", Colors::GREEN);
test13349();
NLog::log("{}Testing splits", Colors::GREEN);
testSplit();
NLog::log("{}Testing rotatesplit", Colors::GREEN);
testRotatesplit();
// clean up
NLog::log("Cleaning up", Colors::YELLOW);
getFromSocket("/dispatch workspace 1");
OK(getFromSocket("/reload"));
return !ret;
}
REGISTER_TEST_FN(test);

View file

@ -0,0 +1,61 @@
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <chrono>
#include <format>
#include <thread>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include "../shared.hpp"
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define UP CUniquePointer
#define SP CSharedPointer
const static auto SLEEP_DURATIONS = std::array{1, 10};
static bool test() {
NLog::log("{}Testing process spawning", Colors::GREEN);
for (const auto duration : SLEEP_DURATIONS) {
// Note: POSIX sleep does not support fractional seconds, so
// can't sleep for less than 1 second.
OK(getFromSocket(std::format("/dispatch exec sleep {}", duration)));
// Ensure that sleep is our child
const std::string sleepPidS = Tests::execAndGet("pgrep sleep");
pid_t sleepPid;
try {
sleepPid = std::stoull(sleepPidS);
} catch (...) {
NLog::log("{}Sleep was not spawned or several sleeps are running: pgrep returned '{}'", Colors::RED, sleepPidS);
continue;
}
const std::string sleepParentComm = Tests::execAndGet("cat \"/proc/$(ps -o ppid:1= -p " + sleepPidS + ")/comm\"");
NLog::log("{}Expecting that sleep's parent is Hyprland", Colors::YELLOW);
EXPECT_CONTAINS(sleepParentComm, "Hyprland");
std::this_thread::sleep_for(std::chrono::seconds(duration));
// Ensure that sleep did not become a zombie
EXPECT(Tests::processAlive(sleepPid), false);
// kill all
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 0);
return !ret;
}
return false;
}
REGISTER_TEST_FN(test)

View file

@ -0,0 +1,203 @@
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <print>
#include <thread>
#include <chrono>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include <csignal>
#include <cerrno>
#include "../shared.hpp"
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define UP CUniquePointer
#define SP CSharedPointer
static bool waitForWindowCount(int expectedWindowCnt, std::string_view expectation, int waitMillis = 100, int maxWaitCnt = 50) {
int counter = 0;
while (Tests::windowCount() != expectedWindowCnt) {
counter++;
std::this_thread::sleep_for(std::chrono::milliseconds(waitMillis));
if (counter > maxWaitCnt) {
NLog::log("{}Unmet expectation: {}", Colors::RED, expectation);
return false;
}
}
return true;
}
static bool test() {
NLog::log("{}Testing gestures", Colors::GREEN);
EXPECT(Tests::windowCount(), 0);
// test on workspace "window"
NLog::log("{}Switching to workspace 1", Colors::YELLOW);
getFromSocket("/dispatch workspace 1"); // no OK: we might be on 1 already
Tests::spawnKitty();
EXPECT(Tests::windowCount(), 1);
// Give the shell a moment to initialize
std::this_thread::sleep_for(std::chrono::milliseconds(500));
OK(getFromSocket("/dispatch plugin:test:gesture up,5"));
OK(getFromSocket("/dispatch plugin:test:gesture down,5"));
OK(getFromSocket("/dispatch plugin:test:gesture left,5"));
OK(getFromSocket("/dispatch plugin:test:gesture right,5"));
OK(getFromSocket("/dispatch plugin:test:gesture right,4"));
EXPECT(waitForWindowCount(0, "Gesture sent paste exit + enter to kitty"), true);
EXPECT(Tests::windowCount(), 0);
OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
EXPECT(waitForWindowCount(1, "Gesture spawned kitty"), true);
EXPECT(Tests::windowCount(), 1);
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "floating: 1");
}
OK(getFromSocket("/dispatch plugin:test:gesture down,3"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "fullscreen: 2");
}
OK(getFromSocket("/dispatch plugin:test:gesture down,3"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "fullscreen: 0");
}
OK(getFromSocket("/dispatch plugin:test:alt 1"));
OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_CONTAINS(str, "ID 2 (2)");
}
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_NOT_CONTAINS(str, "ID 2 (2)");
}
// check for crashes
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_NOT_CONTAINS(str, "ID 2 (2)");
}
OK(getFromSocket("/keyword gestures:workspace_swipe_invert 0"));
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_CONTAINS(str, "ID 2 (2)");
}
OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_NOT_CONTAINS(str, "ID 2 (2)");
}
OK(getFromSocket("/keyword gestures:workspace_swipe_invert 1"));
OK(getFromSocket("/keyword gestures:workspace_swipe_create_new 0"));
OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
{
auto str = getFromSocket("/workspaces");
EXPECT_NOT_CONTAINS(str, "ID 2 (2)");
EXPECT_CONTAINS(str, "ID 1 (1)");
}
OK(getFromSocket("/dispatch plugin:test:gesture down,3"));
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "floating: 0");
}
OK(getFromSocket("/dispatch plugin:test:alt 0"));
OK(getFromSocket("/dispatch plugin:test:gesture up,3"));
EXPECT(waitForWindowCount(0, "Gesture closed kitty"), true);
EXPECT(Tests::windowCount(), 0);
// This test ensures that `movecursortocorner`, which expects
// a single-character direction argument, is parsed correctly.
Tests::spawnKitty();
OK(getFromSocket("/dispatch movecursortocorner 0"));
const std::string cursorPos1 = getFromSocket("/cursorpos");
OK(getFromSocket("/dispatch plugin:test:gesture left,4"));
const std::string cursorPos2 = getFromSocket("/cursorpos");
// The cursor should have moved because of the gesture
EXPECT(cursorPos1 != cursorPos2, true);
// Test that `workspace previous` works correctly after a workspace gesture.
{
OK(getFromSocket("/keyword gestures:workspace_swipe_invert 0"));
OK(getFromSocket("/keyword gestures:workspace_swipe_create_new 1"));
OK(getFromSocket("/dispatch workspace 3"));
// Come to workspace 5 from workspace 3: 5 will remember that.
OK(getFromSocket("/dispatch workspace 5"));
Tests::spawnKitty(); // Keep workspace 5 open
// Swipe from 1 to 5: 5 shall remember that.
OK(getFromSocket("/dispatch workspace 1"));
OK(getFromSocket("/dispatch plugin:test:alt 1"));
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
OK(getFromSocket("/dispatch plugin:test:alt 0"));
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
// Must return to 1 rather than 3
OK(getFromSocket("/dispatch workspace previous"));
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 1 (1)");
OK(getFromSocket("/dispatch workspace previous"));
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
OK(getFromSocket("/dispatch workspace 1"));
}
// kill all
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 0);
// reload cfg
OK(getFromSocket("/reload"));
return !ret;
}
REGISTER_TEST_FN(test)

View file

@ -0,0 +1,300 @@
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <print>
#include <thread>
#include <chrono>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include <csignal>
#include <cerrno>
#include "../shared.hpp"
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define UP CUniquePointer
#define SP CSharedPointer
static bool test() {
NLog::log("{}Testing groups", Colors::GREEN);
// test on workspace "window"
NLog::log("{}Dispatching workspace `groups`", Colors::YELLOW);
getFromSocket("/dispatch workspace name:groups");
NLog::log("{}Spawning kittyProcA", Colors::YELLOW);
auto kittyProcA = Tests::spawnKitty();
if (!kittyProcA) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
NLog::log("{}Expecting 1 window", Colors::YELLOW);
EXPECT(Tests::windowCount(), 1);
// check kitty properties. One kitty should take the entire screen, minus the gaps.
NLog::log("{}Check kitty dimensions", Colors::YELLOW);
{
auto str = getFromSocket("/clients");
EXPECT_COUNT_STRING(str, "at: 22,22", 1);
EXPECT_COUNT_STRING(str, "size: 1876,1036", 1);
EXPECT_COUNT_STRING(str, "fullscreen: 0", 1);
}
// group the kitty
NLog::log("{}Enable group and groupbar", Colors::YELLOW);
OK(getFromSocket("/dispatch togglegroup"));
OK(getFromSocket("/keyword group:groupbar:enabled 1"));
// check the height of the window now
NLog::log("{}Recheck kitty dimensions", Colors::YELLOW);
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 22,43");
EXPECT_CONTAINS(str, "size: 1876,1015");
}
// disable the groupbar for ease of testing for now
NLog::log("{}Disable groupbar", Colors::YELLOW);
OK(getFromSocket("r/keyword group:groupbar:enabled 0"));
// kill all
NLog::log("{}Kill windows", Colors::YELLOW);
Tests::killAllWindows();
NLog::log("{}Spawn kitty again", Colors::YELLOW);
kittyProcA = Tests::spawnKitty();
if (!kittyProcA) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
NLog::log("{}Group kitty", Colors::YELLOW);
OK(getFromSocket("/dispatch togglegroup"));
// check the height of the window now
NLog::log("{}Check kitty dimensions 2", Colors::YELLOW);
{
auto str = getFromSocket("/clients");
EXPECT_CONTAINS(str, "at: 22,22");
EXPECT_CONTAINS(str, "size: 1876,1036");
}
NLog::log("{}Spawn kittyProcB", Colors::YELLOW);
auto kittyProcB = Tests::spawnKitty();
if (!kittyProcB) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
NLog::log("{}Expecting 2 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 2);
size_t lastActiveKittyIdx = 0;
NLog::log("{}Get last active kitty id", Colors::YELLOW);
try {
auto str = getFromSocket("/activewindow");
lastActiveKittyIdx = std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16);
} catch (...) {
NLog::log("{}Fail at getting prop", Colors::RED);
ret = 1;
}
// test cycling through
NLog::log("{}Test cycling through grouped windows", Colors::YELLOW);
OK(getFromSocket("/dispatch changegroupactive f"));
try {
auto str = getFromSocket("/activewindow");
EXPECT(lastActiveKittyIdx != std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16), true);
} catch (...) {
NLog::log("{}Fail at getting prop", Colors::RED);
ret = 1;
}
getFromSocket("/dispatch changegroupactive f");
try {
auto str = getFromSocket("/activewindow");
EXPECT(lastActiveKittyIdx, std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16));
} catch (...) {
NLog::log("{}Fail at getting prop", Colors::RED);
ret = 1;
}
// test movegroupwindow: focus should follow the moved window
NLog::log("{}Test movegroupwindow focus follows window", Colors::YELLOW);
try {
auto str = getFromSocket("/activewindow");
auto activeBeforeMove = std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16);
OK(getFromSocket("/dispatch movegroupwindow f"));
str = getFromSocket("/activewindow");
auto activeAfterMove = std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16);
EXPECT(activeAfterMove, activeBeforeMove);
} catch (...) {
NLog::log("{}Fail at getting prop", Colors::RED);
ret = 1;
}
// and backwards
NLog::log("{}Test movegroupwindow backwards", Colors::YELLOW);
try {
auto str = getFromSocket("/activewindow");
auto activeBeforeMove = std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16);
OK(getFromSocket("/dispatch movegroupwindow b"));
str = getFromSocket("/activewindow");
auto activeAfterMove = std::stoull(str.substr(7, str.find(" -> ") - 7), nullptr, 16);
EXPECT(activeAfterMove, activeBeforeMove);
} catch (...) {
NLog::log("{}Fail at getting prop", Colors::RED);
ret = 1;
}
NLog::log("{}Disable autogrouping", Colors::YELLOW);
OK(getFromSocket("/keyword group:auto_group false"));
NLog::log("{}Spawn kittyProcC", Colors::YELLOW);
auto kittyProcC = Tests::spawnKitty();
if (!kittyProcC) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
NLog::log("{}Expecting 3 windows 2", Colors::YELLOW);
EXPECT(Tests::windowCount(), 3);
{
auto str = getFromSocket("/clients");
EXPECT_COUNT_STRING(str, "at: 22,22", 2);
}
OK(getFromSocket("/dispatch movefocus l"));
OK(getFromSocket("/dispatch changegroupactive 1"));
OK(getFromSocket("/keyword group:auto_group true"));
OK(getFromSocket("/keyword group:insert_after_current false"));
NLog::log("{}Spawn kittyProcD", Colors::YELLOW);
auto kittyProcD = Tests::spawnKitty();
if (!kittyProcD) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
NLog::log("{}Expecting 4 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 4);
OK(getFromSocket("/dispatch changegroupactive 3"));
{
auto str = getFromSocket("/activewindow");
EXPECT_CONTAINS(str, std::format("pid: {}", kittyProcD->pid()));
}
// kill all
NLog::log("{}Kill windows", Colors::YELLOW);
Tests::killAllWindows();
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 0);
// test movewindoworgroup: direction should be respected when extracting from group
NLog::log("{}Test movewindoworgroup respects direction out of group", Colors::YELLOW);
OK(getFromSocket("/keyword group:groupbar:enabled 0"));
{
auto kittyE = Tests::spawnKitty();
if (!kittyE) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
// group kitty, and new windows should be auto-grouped
OK(getFromSocket("/dispatch togglegroup"));
auto kittyF = Tests::spawnKitty();
if (!kittyF) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
EXPECT(Tests::windowCount(), 2);
// both windows should be grouped at the same position
{
auto str = getFromSocket("/clients");
EXPECT_COUNT_STRING(str, "at: 22,22", 2);
}
// move active window out of group to the right
NLog::log("{}Test movewindoworgroup r", Colors::YELLOW);
OK(getFromSocket("/dispatch movewindoworgroup r"));
// the group should stay at x=22, the extracted window should be to the right
{
auto str = getFromSocket("/clients");
EXPECT_COUNT_STRING(str, "at: 22,22", 1);
}
// move it back into the group
OK(getFromSocket("/dispatch moveintogroup l"));
// move active window out of group downward
NLog::log("{}Test movewindoworgroup d", Colors::YELLOW);
OK(getFromSocket("/dispatch movewindoworgroup d"));
// the group should stay at y=22, the extracted window should be below
{
auto str = getFromSocket("/clients");
EXPECT_COUNT_STRING(str, "at: 22,22", 1);
}
Tests::killAllWindows();
EXPECT(Tests::windowCount(), 0);
}
// test that we deny a floated window getting auto-grouped into a tiled group.
NLog::log("{}Test that we deny a floated window getting auto-grouped into a tiled group.", Colors::GREEN);
OK(getFromSocket("/keyword windowrule[kitty-tiled]:match:class kitty_tiled"));
OK(getFromSocket("/keyword windowrule[kitty-tiled]:tile yes"));
auto kittyProcE = Tests::spawnKitty("kitty_tiled");
if (!kittyProcE) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
OK(getFromSocket("/dispatch togglegroup"));
OK(getFromSocket("/keyword windowrule[kitty-floated]:match:class kitty_floated"));
OK(getFromSocket("/keyword windowrule[kitty-floated]:float yes"));
auto kittyProcF = Tests::spawnKitty("kitty_floated");
if (!kittyProcF) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
EXPECT(Tests::windowCount(), 2);
{
auto clients = getFromSocket("/clients");
auto classPos = clients.find("class: kitty_floated");
if (classPos == std::string::npos) {
NLog::log("{}Could not find kitty_floated in clients output", Colors::RED);
ret = 1;
} else {
auto entryStart = clients.rfind("Window ", classPos);
auto entryEnd = clients.find("\n\n", classPos);
auto windowEntry = clients.substr(entryStart, entryEnd - entryStart);
EXPECT_CONTAINS(windowEntry, "floating: 1");
EXPECT_CONTAINS(windowEntry, "grouped: 0");
}
}
Tests::killAllWindows();
EXPECT(Tests::windowCount(), 0);
return !ret;
}
REGISTER_TEST_FN(test)

View file

@ -0,0 +1,194 @@
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <cstdint>
#include <print>
#include <string>
#include <thread>
#include <chrono>
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include <csignal>
#include <cerrno>
#include "../shared.hpp"
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
#define UP CUniquePointer
#define SP CSharedPointer
static std::string getCommandStdOut(std::string command) {
CProcess process("bash", {"-c", command});
process.addEnv("HYPRLAND_INSTANCE_SIGNATURE", HIS);
process.runSync();
const std::string& stdOut = process.stdOut();
// Remove trailing new line
return stdOut.substr(0, stdOut.length() - 1);
}
static bool testDevicesActiveLayoutIndex() {
NLog::log("{}Testing hyprctl devices active_layout_index", Colors::GREEN);
// configure layouts
getFromSocket("/keyword input:kb_layout us,pl,ua");
for (uint8_t i = 0; i < 3; i++) {
// set layout
getFromSocket("/switchxkblayout all " + std::to_string(i));
std::string devicesJson = getFromSocket("j/devices");
std::string expected = R"("active_layout_index": )" + std::to_string(i);
// check layout index
EXPECT_CONTAINS(devicesJson, expected);
}
return true;
}
static bool testGetprop() {
NLog::log("{}Testing hyprctl getprop", Colors::GREEN);
if (!Tests::spawnKitty()) {
NLog::log("{}Error: kitty did not spawn", Colors::RED);
return false;
}
// animation
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation"), "(unset)");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation -j"), R"({"animation": ""})");
getFromSocket("/dispatch setprop class:kitty animation teststyle");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation"), "teststyle");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation -j"), R"({"animation": "teststyle"})");
// max_size
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size"), "inf inf");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size -j"), R"({"max_size": [null,null]})");
getFromSocket("/dispatch setprop class:kitty max_size 200 150");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size"), "200 150");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size -j"), R"({"max_size": [200,150]})");
// min_size
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size"), "20 20");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size -j"), R"({"min_size": [20,20]})");
getFromSocket("/dispatch setprop class:kitty min_size 100 50");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size"), "100 50");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size -j"), R"({"min_size": [100,50]})");
// expr-based min/max _size
getFromSocket("/dispatch setfloating class:kitty"); // need to set floating for tests below
getFromSocket("/dispatch setprop class:kitty max_size 90+10 25*2"); // set max to the same as min above, forcing window to 100*50
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size"), "100 50");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size -j"), R"({"max_size": [100,50]})");
getFromSocket("/dispatch setprop class:kitty min_size window_w*0.5 window_h-10");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size"), "50 40");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size -j"), R"({"min_size": [50,40]})");
getFromSocket("/dispatch settiled class:kitty"); // go back to tiled for consistency
// opacity
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity"), "1");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity -j"), R"({"opacity": 1})");
getFromSocket("/dispatch setprop class:kitty opacity 0.3");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity"), "0.3");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity -j"), R"({"opacity": 0.3})");
// opacity_inactive
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive"), "1");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive -j"), R"({"opacity_inactive": 1})");
getFromSocket("/dispatch setprop class:kitty opacity_inactive 0.5");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive"), "0.5");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive -j"), R"({"opacity_inactive": 0.5})");
// opacity_fullscreen
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen"), "1");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen -j"), R"({"opacity_fullscreen": 1})");
getFromSocket("/dispatch setprop class:kitty opacity_fullscreen 0.75");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen"), "0.75");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen -j"), R"({"opacity_fullscreen": 0.75})");
// opacity_override
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override"), "false");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override -j"), R"({"opacity_override": false})");
getFromSocket("/dispatch setprop class:kitty opacity_override true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override"), "true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override -j"), R"({"opacity_override": true})");
// opacity_inactive_override
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override"), "false");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override -j"), R"({"opacity_inactive_override": false})");
getFromSocket("/dispatch setprop class:kitty opacity_inactive_override true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override"), "true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override -j"), R"({"opacity_inactive_override": true})");
// opacity_fullscreen_override
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override"), "false");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override -j"), R"({"opacity_fullscreen_override": false})");
getFromSocket("/dispatch setprop class:kitty opacity_fullscreen_override true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override"), "true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override -j"), R"({"opacity_fullscreen_override": true})");
// active_border_color
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color"), "ee33ccff ee00ff99 45deg");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color -j"), R"({"active_border_color": "ee33ccff ee00ff99 45deg"})");
getFromSocket("/dispatch setprop class:kitty active_border_color rgb(abcdef)");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color"), "ffabcdef 0deg");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color -j"), R"({"active_border_color": "ffabcdef 0deg"})");
// bool window properties
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input"), "false");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input -j"), R"({"allows_input": false})");
getFromSocket("/dispatch setprop class:kitty allows_input true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input"), "true");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input -j"), R"({"allows_input": true})");
// int window properties
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding"), "10");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding -j"), R"({"rounding": 10})");
getFromSocket("/dispatch setprop class:kitty rounding 4");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding"), "4");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding -j"), R"({"rounding": 4})");
// float window properties
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power"), "2");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power -j"), R"({"rounding_power": 2})");
getFromSocket("/dispatch setprop class:kitty rounding_power 1.25");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power"), "1.25");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power -j"), R"({"rounding_power": 1.25})");
// errors
EXPECT(getCommandStdOut("hyprctl getprop"), "not enough args");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty"), "not enough args");
EXPECT(getCommandStdOut("hyprctl getprop class:nonexistantclass animation"), "window not found");
EXPECT(getCommandStdOut("hyprctl getprop class:kitty nonexistantprop"), "prop not found");
// kill all
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
EXPECT(Tests::windowCount(), 0);
return true;
}
static bool test() {
NLog::log("{}Testing hyprctl", Colors::GREEN);
{
NLog::log("{}Testing hyprctl descriptions for any json errors", Colors::GREEN);
CProcess jqProc("bash", {"-c", "hyprctl descriptions | jq"});
jqProc.addEnv("HYPRLAND_INSTANCE_SIGNATURE", HIS);
jqProc.runSync();
EXPECT(jqProc.exitCode(), 0);
}
testGetprop();
testDevicesActiveLayoutIndex();
getFromSocket("/reload");
return !ret;
}
REGISTER_TEST_FN(test);

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