Compare commits

...

680 Commits

Author SHA1 Message Date
Vaxry
0bd541f2fd version: bump to 0.46.2 2024-12-19 19:26:47 +00:00
Aqa-Ib
23d00cdd0d layout: apply group rules after window creation (#8779)
* apply group rules after window creation

* clang-format
2024-12-19 19:26:40 +00:00
Vaxry
061241d3a2 core: fix possible crash on null active workspace
fixes #7822
2024-12-19 19:26:40 +00:00
Aaron Blasko
b9df70be22 hyprpm: fix hyrpm sometimes returning 0 despite errors occuring (#8761)
* hyprpm: fix hyrpm sometimes returning 0 despite errors occuring

* there u go
2024-12-19 19:26:40 +00:00
Jan Beich
9583429eae core: Unbreak build on FreeBSD (#8762)
* CrashReporter: restore explicit environ(7) after 8bbeee1173

BSD systems don't declare environ(7) in any header like POSIX suggests.

src/signal-safe.cpp:12:23: error: use of undeclared identifier 'environ'
   12 |     for (char** var = environ; *var != nullptr; var++) {
      |                       ^

* fix

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-12-19 19:26:40 +00:00
Vaxry
747c38112b xwayland: fix compile with no xwayland 2024-12-19 19:26:40 +00:00
Vaxry
508e82341f xwm: fixup targets in selection requests
fixes #8719
2024-12-19 19:26:40 +00:00
Vaxry
ec0a38303b xwayland: fix dnd including xwayland
ref #8759
2024-12-19 19:26:40 +00:00
Vaxry
d0bffc4fa9 core: avoid activating toplevel-less surfaces
ref #8609
2024-12-19 19:26:40 +00:00
Khalid
07a19e2c95 hyprctl: Fix hyprctl batch JSON command (#8749) 2024-12-19 19:26:40 +00:00
Vaxry
46d5b363fa windowrules: fixup duplicate rule enum tags
fixes #8746
2024-12-19 19:26:40 +00:00
Vaxry
788ae58897 version: bump to 0.46.0 2024-12-16 23:38:56 +00:00
Vaxry
bba2d9a197 versionkeeper: init version to 0.0.0 if no file is present 2024-12-16 23:37:13 +00:00
Austin Horstman
e340e9f431 nix/meson: add re2 dependency (#8738)
* nix/default: add re2 dependency

* meson: add re2
2024-12-16 20:22:36 +01:00
Vaxry
c2d14a2013 opengl: fixup missed /4 in oklab parsing 2024-12-16 18:53:21 +00:00
Vaxry
95cdedee04 windowrules: fix prop rules with boolean values 2024-12-16 18:44:19 +00:00
Vaxry
0706c1a1f7 layerrules: fix ignorezero not working
fixes #8737
2024-12-16 18:37:34 +00:00
Vaxry
aecf1abddd opengl: fixup invalid ogl uniform reads 2024-12-16 18:34:19 +00:00
Vaxry
b9f82e9968 animationmgr: fixup stack-use-after-return 2024-12-16 18:31:07 +00:00
Vaxry
e06b520427 core: Move regex from stdlib to re2 (#8736)
Moves the regex handling from stdlib to re2
2024-12-16 19:21:44 +01:00
Vaxry
dab50b3ef3 core: Optimize window/layer rule application and scanning (#8735)
Optimizes window and layer rule parsing and later usage.
2024-12-16 19:05:24 +01:00
Mihai Fufezan
eaac5c7cbd flake.lock: update 2024-12-16 18:06:00 +02:00
Vaxry
a5234f26e4 core: drop using deques in favor of vectors
No point in most of these.
2024-12-16 15:58:19 +00:00
Vaxry
de3ad245dc input: add warp_back_after_non_mouse_input
adds cursor:warp_back_after_non_mouse_input

fixes #8675
2024-12-15 23:54:14 +00:00
Vaxry
db24964877 xwayland: Support cross DnD from Wayland (#8708)
Adds support for drag-and-drop from Wayland clients to XWayland ones
2024-12-15 00:37:17 +01:00
Vaxry
9f7a96b997 core/data: Use pointer focus for DnD operations (#8707)
fixes #7737
2024-12-14 16:19:56 +01:00
Vaxry
3cba4ba44e hyprctl: avoid crash on null pwuid
fixes #8693
2024-12-13 22:36:42 +00:00
Vaxry
8237627f3a compositor: fix monitor arrangement with mixed auto directions
fixes #8518
2024-12-13 22:31:30 +00:00
Vaxry
35e134e570 hyprctl: add an inhibitingIdle field to windows
fixes #4322
2024-12-13 21:30:24 +00:00
normaltaro
452a7e6905 dispatchers: Add an option to prioritize focus change within groups with movefocus (#8601)
* modified movefocus dispatcher to prioritize focus change within groups

* pass clang-format check

* `movefocus` cycling groups set optional to config bool `movefocus_cycles_groupfirst`

* Update ConfigDescriptions.hpp
2024-12-13 21:28:57 +01:00
Mike Will
61a51bb4ef snap: bias reserved area when its size is greater than zero (#8694) 2024-12-13 17:34:04 +01:00
Vaxry
aefaeedf5e data-device: fixup wrong box expansion
oopsie 7c03e9d376 was wrong
2024-12-12 12:16:59 +00:00
Vaxry
cef5e6dd7c layersurface: use lastMonitor and not monitor from cursor for new ls
fixes #8622
2024-12-11 22:31:38 +00:00
Vaxry
7c03e9d376 core/data-device: expand damage region to fix minor px errors
fixes #7656
2024-12-11 22:30:17 +00:00
Mike Will
df956a0f6f windowrules: add rules for mouse and touchpad scroll factors (#8655) 2024-12-11 17:27:49 +00:00
rooot
33f271c29a hyprpm: target installed instead of running version (#8634)
---------

Signed-off-by: rooot <hey@rooot.gay>
2024-12-11 17:49:09 +01:00
Vaxry
e892310953 workspace: update hasFullscreenWindow in updateWindows 2024-12-11 16:03:04 +00:00
Pavel Belyavsky
4d05677e8d config: add 'force' option for 'cursor:warp_on_change_workspace' (#8681)
* config: add 'force' option for 'cursor:warp_on_change_workspace'

* manager: throw the expression into the function arguments

* config: fix description of `cursor:warp_on_change_workspace`
2024-12-10 21:55:05 +01:00
Alexander Iliev
c16044a5c8 core: Fix workspace selector parsing (#8687)
Search for the closing bracket when parsing a workspace selector.
This is needed when the `m[desc:<monitor description>]` selector
is used, as the monitor description always contains spaces.
2024-12-10 21:54:51 +01:00
littleblack111
d94d8b4ab2 windows: allow replacing existing fullscreen (#8566)
* feat: `binds:allow_replace_fullscreen`

this allows replacement of fullscreen window(i.e. fullscreening another
window when one is already fullscreened on the workspace)

this is used when a floating window that is spawned on top of a
fullscreen wanted to be fullscreened

* clang-format

* remove: config for `allow_replace_fullscreen`
2024-12-10 21:09:47 +01:00
Vaxry
bb5c3f2702 core/output: don't send enter too aggresively
sometimes this might be like 1px and send enter to the wrong output

fixes #8654
2024-12-10 01:40:35 +00:00
Vaxry
0a27af8cd1 crashreporter: avoid clang warning 2024-12-08 18:52:39 +00:00
Mihai Fufezan
c106f454c1 CI/Nix: temporarily disable cross build 2024-12-07 22:01:32 +02:00
Vaxry
875b598a33 github: mention PR guidelines in the template 2024-12-07 18:01:19 +00:00
Vaxry
8bbeee1173 core: Add clang-tidy (#8664)
This adds a .clang-tidy file for us.

It's not a strict requirement to be compliant, but I tuned it to be alright.
2024-12-07 18:51:18 +01:00
Vaxry
b1e5cc66bd core: Add support for hyprqtutils' update screen (#8651)
* Nix: add hyprland-qtutils to PATH

* flake.lock: update

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-12-06 15:45:02 +01:00
Mike Will
5ff02902ee snap: use the bit mask to check if snapping occurred (#8659) 2024-12-06 15:25:14 +01:00
Vaxry
cccca7c02e renderer: drop requesting OUT_FENCE_PTR 2024-12-06 14:15:46 +00:00
Mihai Fufezan
10a4365f7d Nix: create TAG info from version 2024-12-06 10:16:18 +02:00
Vaxry
a7a6eedc21 core: move version include to hyprctl 2024-12-05 19:35:50 +00:00
Vaxry
888bdf4e23 hyprctl: add directScanout to hyprctl monitors 2024-12-05 19:33:54 +00:00
Vaxry
ceef4fb3a5 core: feeling a bit quirky today. 2024-12-05 03:36:50 +00:00
Vaxry
22f7d6f142 core: add a few festive splashes
adds two new 'special' splash types for xmas and new years. Activated based on local time.
2024-12-05 01:59:36 +00:00
Mike Will
f9e4998a6d snap: check which corner is being grabbed for monitor snapping (#8637) 2024-12-04 19:12:04 +01:00
Vaxry
3c617ce33c internal: fixup some missed updateColorsOk() calls 2024-12-03 22:58:30 +00:00
vaxerski
f6ac755cf7 cleanup: Revert use doLater instead of adding idle event handlers (#8624)
This reverts commit 6d7544458d.
2024-12-03 21:15:25 +00:00
Vaxry
320144ae72 core: move colorspace handling to oklab (#8635)
* Meson: add hyprgraphics

* Nix: add hyprgraphics

* CI/setup_base: get hyprgraphics-git

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-12-03 18:58:24 +00:00
Vaxry
92186898c0 version: add link versions for other utils (#8619)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-12-02 16:31:22 +00:00
UjinT34
10a9fec7fc master: make center ignore reserved areas (#8625) 2024-12-02 15:32:32 +00:00
Ikalco
6d7544458d cleanup: use doLater instead of adding idle event handlers (#8624) 2024-12-01 17:14:35 +00:00
Vaxry
d26439a0fe nix: update flake 2024-11-30 17:42:40 +00:00
littleblack111
ef6b0c81c9 cleanup: remove leftover var in ThreadManager.cpp (#8611) 2024-11-30 16:40:23 +00:00
Vaxry
8f83d29f00 renderer: restore discard mode after IME render pass
ref #8555
2024-11-28 23:51:59 +00:00
Daringcuteseal
22bf2853e6 hyprpm: fix incomplete unmet dependencies message 2024-11-28 17:48:46 +02:00
nyx
5963970be5 descriptions: change allow_pin_fullscreen value to false (#8592) 2024-11-28 15:25:24 +00:00
Vaxry
8b51eeb7ae core: fix compilation outside stdlibc++
fixes #8603
2024-11-28 14:31:43 +00:00
Andre Toerien
5329298b52 sessionLock: don't send motion events on every surface commit (#8584) 2024-11-27 19:59:00 +00:00
Agent00Ming
e9a7fb8f91 renderer: fix incorrect early return (#8590)
Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-11-27 14:17:45 +00:00
Ikalco
1fb720b62a seat: fix double scrolling in some applications (#8583) 2024-11-26 13:52:43 +00:00
Vaxry
2687788236 hyprctl: verify runtime dir exists in instances()
ref #8579
2024-11-25 14:42:11 +00:00
Vladimir-csp
0ddb952d7a hyprland-uwsm.desktop: Just reference plain entry (#8553) 2024-11-25 16:18:50 +02:00
Nabil Otsmane
1930a95000 shm: fix shm fd size check before creating or resizing shm_pool (#8572)
* protocols: fix shm fd size check before creating or resizing shm_pool

* added static to function
2024-11-25 00:50:35 +00:00
Vaxry
cc38e7e18f config: don't overwrite errors in gradients 2024-11-24 14:53:36 +00:00
Vaxry
55ec8bd512 config: throw an error explicitly when parsing colors in gradients
ref #8552
2024-11-24 02:46:28 +00:00
Mike Will
54f57797e9 snap: account for position of multiple monitors (#8543) 2024-11-23 14:36:28 +00:00
littleblack111
65f66dcf0d binds: add option to allow fullscreening a pinned window (#8526) 2024-11-23 14:32:13 +00:00
Ryan
451d7a41fc renderer: add option to blur IME popups (#8521) 2024-11-23 14:29:29 +00:00
Vaxry
00d6261cc0 hyprpm: move temp files to XDG_RUNTIME_DIR
avoid /tmp, it's cringe
2024-11-23 14:18:13 +00:00
Vaxry
745a82ce8a core: workspace-related function cleanup / refactor
CCompositor is massive, and has a lot of functions that could be better optimized if in CWorkspace
2024-11-22 16:01:02 +00:00
Vaxry
a847bc67b1 monitor: fix default focus when switching to a fs workspace 2024-11-22 15:22:35 +00:00
may
b100344595 keybinds: actually suppress internal keybinds instead of passing them along (#8538) 2024-11-22 02:31:42 +00:00
Tom Englund
943b3d467b bezier: optimize setup of bezier curves (#8528)
avoid reallocations by resizing and copy the pVec into the resized
m_dPoints, reduce the amount of calculations in baking to only do it
once per iteration instead of twice. precompute in getYforT and getXforT
return early in getYForPoint if x is equal or below 0. and use const
references where we can.

these changes we are now down to an average of "time to bake: 2.50µs."
on my machine compared to before average of "time to bake: 11.15µs"
2024-11-22 01:47:51 +00:00
vaxerski
940f7aa990 renderer: fixup blur optimization considitons
fixes #8531
2024-11-20 11:02:21 +00:00
Vaxry
e5fa017172 internal: fix some misused configStringToInt conversions
fixes #8523
2024-11-20 10:32:50 +00:00
Vaxry
c4eda46d0e xdg-shell: even more robust layout min/max size
although I don't think any apps use this, but better safe than sorry
2024-11-19 22:07:25 +00:00
Vaxry
aa067a4cf1 xdg-shell: don't report invalid min/max sizes on unset
fixes #8522
2024-11-19 21:40:16 +00:00
Vaxry
67cee43006 internal: minor cleanups for color results 2024-11-19 01:16:11 +00:00
Vaxry
47a1650c48 miscfunctions: move configStringToInt to std::expected 2024-11-18 23:53:38 +00:00
Vaxry
936dfedbad keybinds: move to managed pointers 2024-11-18 19:56:26 +00:00
MightyPlaza
6113f4da7f keybinds: allow repeating multiple binds (#8290) 2024-11-18 19:48:13 +00:00
Maximilian Seidler
cc923ad031 config: update the configStringToInt implementation (#8476)
Copied from hyprlang and removed std::expected.
2024-11-18 19:45:22 +00:00
🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко)
df9ff44899 Fix example config name in auto-generated cfg header (#8509)
Previously, it was suggesting to find `hypr.conf` in the `examples/` folder which doesn't exist. This patch fixed that to point to the existing file.

Additionally, the change updates `HYPR` to `HYPRLAND` in the same header.
2024-11-18 17:54:18 +02:00
Aqa-Ib
97493511f9 internal: fix changeWindowZOrder reordering incorrectly (#8494) 2024-11-18 14:44:15 +00:00
Vaxry
505c1f8f4a miscfunctions: fix cross build 2024-11-18 14:35:09 +00:00
johannes hanika
6744bb57c6 constraints: don't warp pointer position on release (#8491)
this was annoying for nuklear properties/ui slider elements that grab
the pointer via GLFW_CURSOR_DISABLE to allow more range and finer control.
upon mouse release, the pointer is reset to the middle of the window
without this patch, making long mouse movements necessary to go back
to the original position for readjustments. fwiw the new behaviour
is consistent with x11 and weston.
2024-11-18 14:02:34 +00:00
Vaxry
2259a88551 miscfunctions: add missing include 2024-11-18 13:59:57 +00:00
Vaxry
1ba050d603 shell: propagate new machanism from hyprctl to miscfunctions 2024-11-17 21:58:00 +00:00
Vaxry
e8717a4fce shell: don't use fgrep, prefer grep -F 2024-11-17 21:57:04 +00:00
Alessio Molinari
9b03307653 hooks: add pre connected/disconnected monitor events (#8503) 2024-11-17 19:34:03 +00:00
Vaxry
b735295d2b windows/xdg: minor cleanup of min/max size calculations
fixes #8495
2024-11-17 19:31:54 +00:00
Vaxry
8d5cdedbd3 hyprpm: fix format crash
ref #8487
2024-11-17 16:46:49 +00:00
Vaxry
4f591e807a renderer: simplify blur enabling logic 2024-11-17 16:42:30 +00:00
Vaxry
fb91c2550f renderer: don't render unmapped popups
fixes #8485
2024-11-17 16:16:54 +00:00
Alexandre Acebedo
0ddbd1c3a4 renderer: add lockdead_screen_delay (#8467) 2024-11-17 15:58:18 +00:00
Ruslan
af83c82513 hyprctl: add json output on hyprctl -j plugins list (#8480)
---------

Co-authored-by: Руслан Новокшонов <r.novokshonov@vk.team>
2024-11-16 23:18:30 +00:00
staz
9d37b1b073 workspacerules: Do not check 'on-created-empty' if using a workspace windowrule (#8486) 2024-11-16 23:07:33 +00:00
vaxerski
cf18eca86d [gha] Nix: update inputs 2024-11-16 23:06:35 +00:00
Vaxry
ec1e6be003 core: guard pmonitor in focuswindow
may be null

fixes #8483
2024-11-16 23:05:02 +00:00
sslater11
83be2480c4 workspace: fix missing name via focusworkspaceoncurrentmonitor (#8484) 2024-11-16 16:39:58 +00:00
littleblack111
7affc34ab4 bind: new long press option (#8302)
---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-11-15 23:21:59 +00:00
Vaxry
098e491a43 protocols: mark primarySelection as not privileged
fixes #8479
2024-11-15 00:47:34 +00:00
UjinT34
967fe76a60 drm: enable explit out fence in AQ (#8431) 2024-11-15 00:45:13 +00:00
Tom Englund
940ed3d525 xcursors: store themes in a std:set to order it (#8474)
using a unordered_set means its store based on a hash_value meaning
currently it can end up loading inherited themes before the actual theme
itself depending on the hash of the theme name used, reason for using
set at all over vector is to keep unique members and not foreverever
looping broken inherit themeing.
2024-11-14 20:38:16 +00:00
Vaxry
6f7280a690 descriptions: add use_cpu_buffer 2024-11-14 20:20:51 +00:00
Vaxry
20031cea92 pointer: add drm dumb buffers for cursors (#8399)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-11-14 20:15:51 +00:00
Mihai Fufezan
3fb47372b7 flake.lock: update 2024-11-13 21:34:52 +02:00
Vaxry
bb160cfe37 makefile: add stub to discourage direct make 2024-11-12 15:26:25 +00:00
SoSeDiK
a29cfa7843 logging: Add some context to config error logs (#8326) 2024-11-12 00:53:55 +00:00
nnra
f5fa84554f config: Changed the default value of decoration:blur:ignore_opacity to true (#8418)
This change is made in order to deliver the blur look majority of people
expect by default.
2024-11-11 15:49:35 +00:00
Mihai Fufezan
b88e4a1a9a Nix: disable uwsm desktop file installation
Will be enabled in the NixOS module.
2024-11-11 16:52:42 +02:00
Mihai Fufezan
ff411658e8 Lock uwsm desktop file behind feature flag
The file in the repo cannot be used in NixOS due to missing full paths,
and the fact that `uwsm` does not have access to `PATH` to find the
listed binaries. Might be useful in other situations as well.
2024-11-11 16:52:42 +02:00
Mihai Fufezan
943c7d18cc meson: autodetect systemd 2024-11-11 16:52:42 +02:00
Izmyname
ccfae82ad1 rename hyprland-systemd.desktop and remove hyprland-session.service 2024-11-11 16:52:42 +02:00
izmyname
430b5c302a systemd: hyprland-systemd.desktop -> hyprland-uwsm.desktop
Remove hyprland-session.service.
2024-11-11 16:52:42 +02:00
Vaxry
8fa4cfb7df keybinds: don't animate fullscreen size/pos changes coming in
when fullscreen, don't animate the pos/size when switching to another fullscreen window, as they can look weird and distracting.

Ideally we would do it differently but it's not really possible to do well without reading minds
2024-11-11 13:55:37 +00:00
dawsers
a551f85b91 renderer: scaled surfaces could have zero area (#8423) 2024-11-11 13:48:50 +00:00
JManch
07052a515b pointer: map devices across all outputs by default (#8352) 2024-11-11 13:45:33 +00:00
WavyEbuilder
1fa0cd7a75 debug: clean up fetching of the contents of /proc/device-tree (#8413) 2024-11-11 13:44:41 +00:00
Vaxry
c10739e6e3 core: fixup execAndGet
fixes #8410
2024-11-10 22:53:11 +00:00
WavyEbuilder
9e628067fc debug: clean up opening of files in HyprCtl (#8401)
`std::ifstream` is more suited than `execAndGet` here.
2024-11-10 15:54:15 +00:00
Vaxry
99b01c5d12 hyprpm: fix format 2024-11-10 15:54:00 +00:00
Vaxry
a8ff3a452c core: move to os/Process from hyprutils
nix bump too
2024-11-09 17:14:25 +00:00
Vaxry
dca75db127 defaultConfig: fixup smart gaps rules 2024-11-09 16:56:43 +00:00
Vaxry
a425fbebe4 version: bump to 0.45.0 2024-11-09 14:27:47 +00:00
Vaxry
cca227a53e tablet: use inputMgr unified naming scheme
ref #8301
2024-11-09 02:34:04 +00:00
Vaxry
b9c439a55e compositor: make sure we don't ret early on no surface
if there is no implicit surface passed, make sure the current focus is not null, otherwise we nope early without focusing the window

fixes #8293
2024-11-09 02:27:01 +00:00
Vaxry
726d697821 popup: minor cleanups
don't iterate over unmapped popups in breadthfirst, don't refocus if it wasnt in focus

ref #8293
2024-11-09 02:26:24 +00:00
Vaxry
0ccc0ace88 input: ignore non-kb ls-es in refocusLastWindow
ref #8293
2024-11-09 02:25:54 +00:00
Vaxry
f43d4a8638 layershell: minor cleanups and improvements to focus
ref #8293
2024-11-09 02:25:34 +00:00
Vaxry
4c7a2faf85 input: cleanup device naming logic
ref #8301
2024-11-09 01:53:05 +00:00
nickodei
3b66351eeb input: Refocus window on scrolling if follows mouse (#8361) 2024-11-08 17:25:37 +00:00
Mihai Fufezan
e58e97b0a3 Nix: build aquamarine and hyprutils in debug when using hyprland-debug 2024-11-07 10:54:52 +02:00
Mihai Fufezan
2dd0b2af71 flake.lock: update 2024-11-07 10:54:52 +02:00
dawsers
2ec2b3bfb3 renderer: minor fixup to window rendering logic (#8359)
Don't render animating windows out of their monitor when they are not moving workspaces
2024-11-06 23:30:17 +00:00
Vaxry
0ec128e5ed renderer: don't rely on datarootdir for local share 2024-11-06 22:11:46 +00:00
Mihai Fufezan
083a5cf3c1 CI: update actions 2024-11-06 19:50:01 +02:00
Aqa-Ib
8f42401aa8 groups: add merge_groups_on_groupbar (#8362) 2024-11-06 16:52:10 +00:00
Vaxry
97a309b784 layershell: check if workspace is valid in onMap
ref #8296
2024-11-06 14:02:44 +00:00
izmyname
3bf6f78dad hyprland-systemd.desktop: change name back to Hyprland (#8351) 2024-11-05 20:14:48 +02:00
Kamikadze
e4ab28b1fb defaultConfig: update default config values for shadows (#8360) 2024-11-05 18:03:37 +00:00
Vaxry
81ad218b8b shadow: fix double premultiplication
shader takes straight alpha aaaa
2024-11-05 16:28:55 +00:00
Vaxry
64c46db087 hyprctl: add mirrorOf to hyprctl monitors
fixes #8026
2024-11-05 16:20:04 +00:00
Vaxry
0920572e70 shaders: improve corner AA in borders shader 2024-11-05 16:11:05 +00:00
Vaxry
55ccb1a8cf shaders: fixup jagged edges in texture rounded corners 2024-11-05 16:00:39 +00:00
Vaxry
d1638a09ba shadow: add sharp and refactor options
options moved to decoration:shadow:
2024-11-05 15:44:40 +00:00
Vaxry
e3882b23d0 screencopy: fix build with legacyrenderer
fixes #8355
2024-11-05 09:59:03 +00:00
Vaxry
88e9e03945 renderer: add expand_undersized_textures
adds an option to disable the texture expansion for textures that are smaller while resizing up
2024-11-04 19:45:23 +00:00
Mihai Fufezan
0fb9a04526 flake.lock: update xdph 2024-11-04 20:01:40 +02:00
Mihai Fufezan
44899cd548 nix/overlays: fix xdph overlay
Partial fix for https://github.com/hyprwm/Hyprland/issues/8343
2024-11-04 19:43:25 +02:00
Gliczy
cd0d049126 flake.lock: update xdph 2024-11-03 18:43:08 +02:00
Vaxry
180c26ada6 renderer: safeguard against non-sampleable currentFB in blurMainFb
fixes #8325
2024-11-03 15:16:13 +00:00
trianta
5833abbbd1 xwayland: minor fixups for stability (#8323)
* xwayland: add inline safe closing of fds and fix LOCK_FILE_MODE permissions

* xwayland: auto recreate xwayland instance if it crashes

* xwayland: delay auto-restart until later
2024-11-03 14:59:46 +00:00
diniamo
514e0ff509 flake: update nixpkgs 2024-11-03 12:14:49 +02:00
Vaxry
40081cb330 renderer: improve api around new framebuffer changes
ref #8325
2024-11-02 15:26:45 +00:00
Mihai Fufezan
32b18179dd CMake: systemd fixes 2024-11-02 00:20:52 +02:00
Pavel Solovev
29e7dc6428 Systemd fixes
Fix installation path, install the service only if the systemd option is enabled
2024-11-02 00:20:52 +02:00
izmyname
3c0605c68e hyprland-systemd.desktop improvements (#8318) 2024-11-01 19:21:36 +02:00
Vaxry
d8b865366a renderer: Add a missing texture asset and a user check
When an asset is missing, instead of a black screen, render an obnoxious, yet standard, missing texture.

Additionally, warn the user assets failed to load.

Shoutout to Arch for having their assets broken for months. Fix your shit. I am tired of it, and it's negatively impacting users.
2024-11-01 15:52:09 +00:00
vaxerski
3852418d24 hyprctl: reload windowrules on reloadAll 2024-11-01 13:03:12 +00:00
Ikalco
c4d214c42d monitors: fix vrr breaking monitor disconnect (#8314) 2024-11-01 12:30:26 +00:00
Mike Will
93b4478e70 snap: add option border_overlap and other improvements (#8289)
* snap: add option `border_overlap` and other improvements

I really liked the way borders used to overlap when snapping and how
only the window's main surface would snap to the monitor, so I would
like to bring that behavior back, but in the form of a config option.

Other improvements include:

- reduced the number of snap functions from 4 down to 2, and only
one ever gets called at any given time.

- border size should not be added to gap size. It seemed like the
right thing to do at the time, but it makes snapping feel way
stronger than it actually should.

- all const variables have been given the all-caps naming convention.

- to avoid excessive casting, border size is declared as a double.

- to avoid excessive x + w, y + h calculations. I'm using a struct
called Range and working only with start and end values until the
very end of the function.

- check for both monitor snapping as well as reserved monitor space
snapping in a relatively efficient way.

* snap: always border-align for corners and reserved monitor space

We probably don't want to treat reserved monitor space as if it were just
a smaller monitor. Instead, it should be treated more like a borderless
window, which means our window's border should never encroach upon it.
2024-10-31 11:21:08 +00:00
Tom Englund
7c7a84ff60 internal: more profiling less calls and local copies (#8300)
* compositor: reduce amount of window box copies

mousemoveunified can call this very frequently, the cbox copying
actually shows up as an impact in such cases, move it down in the scope
and only do it when necessery.

* core: constify and reference frequent calls

profiling shows these as frequent called functions try to reduce the
amount of copies with references and const the variables.

* pointermgr: remove not used local copy, const ref

remove unneded local copies and const ref cursorsize.

* inputmgr: reduce amount of calls to vectortowindow

the amount of calls to g_pCompositor->vectorToWindowUnified fast ramps
up in cpu usage with enough windows existing and moving the mouse, move
the PWINDOWIDEAL up and reuse it if its already the same.

* protocol: compositor remove unused local copy

remove unused local copy of accumulateCurrentBufferDamage and const
previousBuffer.

* renderer: reduce scope of variables and refactor

move a few variables down in their scopes to reduce the amount of calls
and copies when not needed, also add one more for loop in
renderWorkspaceWindows and store the windows in a vector with
weakpointers that should be rendered, this adds a loop but reduces the
amount of repeated calls to shouldRenderWindow and also makes the rest
of the loops go over way smaller vector when many windows exist.
2024-10-30 23:20:32 +00:00
Vaxry
a0b2169ed6 input: revert #8279 2024-10-30 22:14:43 +00:00
nickodei
ee91df62f0 input: simulate mouse movement after scroll to refocus window (#8279) 2024-10-30 19:12:16 +00:00
MightyPlaza
12c1bb936d internal: check size limit in layouts (#8298)
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/helpers/MiscFunctions.cpp
modified:   src/helpers/MiscFunctions.hpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/MasterLayout.cpp
modified:   src/macros.hpp
2024-10-30 18:58:36 +00:00
Aqa-Ib
5f721dce36 group: fix moveWindowIntoGroup (#8297) 2024-10-30 10:00:58 +00:00
staticssleever668
d679d20029 seat: avoid sending pointless 'keymap' and 'repeat_info' events (#8276)
#### Describe your PR, what does it fix/add?

Fix lag spikes when pressing more than 6 keys at the same time.

 #### Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Debugging process:
<details>
This is triggered by typing some applications, like CopyQ or XWayland.
Typing in Firefox doesn't lead to lag, however it itself does lag
handling these events.

Profiling CopyQ shows that paths leading to
`QtWaylandClient::QWaylandInputDevice::Keyboard::keyboard` take over
80% of processing time of an otherwise idle program.

Looking at output of 'wev' even when it's not focused shows same events
received over and over again.

```
[14:     wl_keyboard] repeat_info: rate: 25 keys/sec; delay: 300 ms
[14:     wl_keyboard] keymap: format: 1 (xkb v1), size: 64754
```

Looking at what passes through CInputManager::onKeyboardKey() ->
CSeatManager::setKeyboard() shows Hyprland 'switching' between endpoints
of the same keyboard, one of them being named like the other but with
'-1' suffix.
</details>

Tested changing layouts in Fcitx5 and with following config.

```
input:kb_layout = us,cz
input:kb_variant = ,qwerty
input:kb_options = grp:alt_shift_toggle
```

Also tested changing 'input:repeat_delay' while running.

Curiously, now these events appear in the output of 'wev' only once.
Changing layouts still seems to work fine though.

 #### Is it ready for merging, or does it need work?

Ready for merging.
2024-10-28 19:25:27 +00:00
MightyPlaza
7188ee4f99 hyprctl: move setprop into dispatchers (#8275)
* move setprop into dispatchers
modified:   src/debug/HyprCtl.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/KeybindManager.hpp

* add deprecated
modified:   src/debug/HyprCtl.cpp
2024-10-28 18:18:58 +00:00
Tom Englund
c7315617eb internal: few more marginal optimisations from profiling (#8271)
* deco: reduce local temporars and function calls

profiling shows this is a high used function, reduce the amount of
function calls and local temporar copies and also check if we even need
to add extents at all in the loop.

* popup: optimize bfhelper in popups

pass nodes as const reference and reserve the size of the children node
vector help reduce the reallocations.

* procotol: make compositor bfhelper use const ref

use const ref for nodes and reserve second nodes vector size to reduce
amount of reallocation needed.
2024-10-28 18:02:52 +00:00
Aqa-Ib
d49a1334a8 swallow: check if swallow_regex doesn't exist (#8265)
Avoid to run CWindow::getSwallower() when `swallow_regex` doesn't exist in the user's config file.
2024-10-28 16:52:14 +00:00
Mike Will
2c481202ef layout: slight adjustments to snapping logic (#8273)
fixes some bugs with resizing and corner snapping
2024-10-28 13:39:05 +00:00
Vaxry
6cf193e166 layout: don't snap to self and allow same-pid snaps
fixes #8255
2024-10-27 23:41:22 +00:00
Vaxry
b1120ec433 layout: window snapping cleanup + fixes
way better now heh

fixes #8259 fixes #8267
2024-10-27 23:39:57 +00:00
Vaxry
5d4b54b012 core: move internal structures to monitor pointers (#8266) 2024-10-27 18:45:38 +00:00
Ryan
b6e226c320 groupbar: set locked color when groups are globally locked (#8257) 2024-10-27 18:26:42 +00:00
Tom Englund
f9b52203f5 internal: optimize cursor move a bit (#8264)
* window: inline and const getWindowMainSurfaceBox

getWindowMainSurfaceBox gets called a lot of times from deep down from
mousemoveunified, profiling mousemoveunified it spends quite a lot of
cpu time in here, let the compiler optimize the call to
getWindowMainSurfaceBox by inlining and making it const. reducing the
overhead.

* inputmgr: return early and use std::any_of

return early in mousemoveunified to reduce the amount of unnecessery
calls to various pointers when not needed, also make isconstrained use
std::any_of instead of for loop to use the STL optimized paths with
hopes and dreams marginally faster.

* decoration: return early, reduce temporar copy

return earlier and reduce the temp copies by using one .lock instead of
two
2024-10-27 17:51:26 +00:00
Aqa-Ib
a3d3b4fd64 groups: fix swallowing (#8223)
* fix swallowing for groups

* remove unnecessary check

* clang-format

* clarify comment

* make variables consistent

* make aditional variables consistent
2024-10-27 01:44:55 +01:00
izmyname
f3f7d3629a Build with hyprland-session.service (#8251)
Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-10-26 22:49:00 +03:00
Damianu
c356e42500 misc: Fix bad links to wiki (#8240)
Same as in https://github.com/hyprwm/hyprland-wiki/pull/828
2024-10-26 16:50:31 +01:00
Aqa-Ib
0b29caf9ab core: fix group members disappearing when you move the group to another monitor (#8237)
* fix group members disappearance when you move the group to another monitor

* remove repeated action
2024-10-26 02:22:37 +01:00
Vaxry
3dd8db83f1 pointer: add default auto for no_hw_cursors
auto defaults to off on nvidia, on for everyone else. Gotta wait until we do fucking drm_dumb and it fucking works
2024-10-26 02:12:43 +01:00
Vaxry
d5689bb539 internal: cleanup CMonitor usage and fix a few ref hogs
ref #8221
2024-10-26 02:06:13 +01:00
izmyname
e5384774a8 example/hyprland-session.service: add support for xdg autostart (#8230) 2024-10-25 23:38:59 +03:00
Tom Englund
f0e023bff2 security-context: avoid UB in C macro (#8229)
to safely use wl_container_of with a class the class has to be no
virtual functions, no inheritance, and uniform access control (e.g all
public)

work around this by putting this into a destroywrapper struct.
2024-10-25 11:26:48 +01:00
izmyname
3cec45d821 Improve hyprland-session.service (#8225) 2024-10-24 17:50:53 +03:00
czlabinger
7f46680ab1 hyprctl: add caps/num lock state for keyboards (#8145)
---------

Co-authored-by: Behzad <behzadasbahi@gmail.com>
2024-10-24 14:01:08 +01:00
Honkazel
f603a22af0 internal: Remove some unused lambda captures (#8218) 2024-10-24 13:12:41 +01:00
Honkazel
cdac64970e Makefile: fix legacyrendererdebug typo (#8214) 2024-10-23 23:32:39 +03:00
chitoroagad
6e0aadc585 updated flake.lock 2024-10-23 07:19:55 +03:00
Aqa-Ib
2b6ff6837e groups: add group_on_movetoworkspace (#8159) 2024-10-23 00:51:25 +01:00
Vaxry
29997ef4ba default/config: improve default animations
objectively better
2024-10-22 21:34:21 +01:00
KAGEYAM4
5e96d738e6 hyprpm: Add option to notify on fail and keep original notify (#8167)
* Only generate notification on fail

Hyprpm fail/pass notification are mutually exclusive.

* Add option to notify on fail and keep original notify (#1)

* Add option to notify on fail and keep original notify
---------

Co-authored-by: KAGEYAM4 <75798544+KAGEYAM4@users.noreply.github.com>

---------

Co-authored-by: littleblack111 <littleblack11111@gmail.com>
2024-10-22 00:28:42 +01:00
Ikalco
9df0f0b66c renderer: fix floating window damage (#8182) 2024-10-21 16:09:14 +01:00
Mike Will
4093b993a2 input: add snapping to floating windows (#8088)
* add snapping to floating windows

Works for both moving and resizing of windows.
It comes with 3 options:

`general:snap:enabled` - whether it's enabled, off by default

`general:snap:window_gap` - minimum gap in pixels between windows before
snapping. Setting to 0 effectively turns off this method of snapping.

`general:snap:monitor_gap` - minimum gap in pixels between window and
monitor edges before snapping. Again, setting it to 0 effectively turns
it off.

* snap: add more ignore criteria and change if clause into a guard

* snap: refactor code

* snap: new refactoring approach and account for border size

* snap: do corner snapping after all edge snapping is done

The approach of performing corner snaps after each individual edge snap
results in far fewer scenarios where snapping can occur.

After trying it out for a while, I found that I prefer an approach
that's more prone to snapping.

* snap: combine snapWindows and snapMonitor into a single function

* snap: add forced aspect ratio functionality

* snap: avoid directly referring to border_size config value

* snap: address vaxerski feedback

- add new line between functions
- use std::function typedef for SnapFn and make snap functions static
- avoid uninitialized variable declarations.
- change ignore condition m_bIsX11 to isX11OverrideRedirect()
- use braces for CBox and Vector2D declarations.
- add SNAP_INVALID to eSnapEdge enum
- use bitshift notation for eSnapEdge and eRectCorner
- make performSnap a non-member function.

* snap: add corner-snapping to forced aspect ratio mode
2024-10-21 16:08:25 +01:00
Vaxry
08cc063e17 monitor: avoid crash on released buffer in surf 2024-10-19 23:48:25 +01:00
Vaxry
a17850e41c layersurface: fixup brace style 2024-10-19 23:47:28 +01:00
Vaxry
6a5c342063 layersurface: round geom in arrangeLayerArray
fixes #8171
2024-10-19 23:45:51 +01:00
Vaxry
f044e4c951 internal: Move CMonitor to SP (#8178)
* move monitors to sp

* XD
2024-10-19 23:03:29 +01:00
Vaxry
ce3ba798df defaultConfig: improve smart gaps 2024-10-19 17:03:22 +01:00
Vaxry
0eaf3581a3 window: guard PMONITOR in commit listener
ref #8170
2024-10-19 16:24:03 +01:00
Vaxry
62ee5cc273 monitor: modernize/refactor last legacy-handled events 2024-10-19 16:21:47 +01:00
Vaxry
48bf32c5de foreign-toplevel-wlr: don't send updates to X11 OR windows 2024-10-19 16:09:53 +01:00
Vaxry
904f9b6aee foreign-toplevel: don't send updates to X11 OR windows 2024-10-19 16:09:53 +01:00
Maximilian Seidler
e5d3a71263 config: fix generateConfig loop (#8164)
* config: fix generateConfig loop

* config: cleanup getMainConfigPath
2024-10-19 15:49:56 +01:00
Maximilian Seidler
0e630e9e74 session-lock: reset seat grab on a new session lock (#8147) 2024-10-17 21:05:55 +01:00
MightyPlaza
5f30cb7753 windowrules: allow specifying max size in size window rule (#8021)
* allow specifying max size in size window rule
modified:   src/events/Windows.cpp

* clean up
modified:   src/events/Windows.cpp
2024-10-17 21:03:17 +01:00
Behzad
495b92fb53 makefile: fix typo (#8127) 2024-10-17 15:20:18 +01:00
Vaxry
b57086aa43 window: properly break cycles in X11TransientFor
ref #8045
2024-10-16 22:23:15 +01:00
zakk4223
09581d32fd hyprpm: Fix crashes due to misplaced fmt argument(s) (#8140) 2024-10-16 22:13:59 +01:00
Aqa-Ib
86e9f69a69 layout: move applyGroupRules() to onWindowCreated() (#8139) 2024-10-16 22:13:35 +01:00
Vaxry
781828a56e output: send enter events on late wl_output binds
fixes #6560
2024-10-16 21:59:33 +01:00
vaxerski
0baf166d39 [gha] Nix: update inputs 2024-10-16 10:01:31 +00:00
Aqa-Ib
ace803948a layout: enable group rules for new floating windows (#8122)
* layout: enable group rules for new floating windows

* fix comment

* do not apply group rules to a new floating window if it shouldBeFloated.
fixes child windows

* comment
2024-10-16 10:59:47 +01:00
Aqa-Ib
01c2ff34dd layout: simplify the conditions to autogroup (#8120) 2024-10-14 19:31:17 +01:00
fanlumaster(Fany Full)
22b1370ae5 IME: Fixup IME popup candidate windows position when scale is not 1.0 (#8117) 2024-10-14 18:03:16 +01:00
deadacute
f309681d4a example: update desktop file to include DesktopNames 2024-10-14 18:26:07 +03:00
Ikalco
ce62521883 drm-lease: fix crashes and implementation (#8116) 2024-10-14 11:37:42 +01:00
Aqa-Ib
e7fd0f5aec layout: deny auto-grouping a new floating window into a tiled group (#8108) 2024-10-14 00:25:19 +01:00
Vaxry
abfd550ee2 xwm: avoid infinite parent lookup loop in lookupParentExists
ref #8045
2024-10-14 00:24:32 +01:00
Vaxry
8e51a36c7f config/example: add optional smart gaps to the default config
ref #8106 #8114
2024-10-14 00:19:10 +01:00
Vaxry
5c3bd8e93d notif-overlay: add a bit of padding for icons 2024-10-13 17:26:44 +01:00
Toni500git
05a5e0b4f1 hyprland: convert std::cout and std::cerr to std::println() 2024-10-13 14:13:56 +01:00
Toni500git
b61d4c3636 hyprctl: convert std::cout and std::cerr to std::println() 2024-10-13 14:13:56 +01:00
Toni500git
e79d3cd2ef hyprpm: convert std::cout and std::cerr to std::println() 2024-10-13 14:13:56 +01:00
Vaxry
1822707c7e drm-syncobj: fix crash on missing timelines
fixes #8092
2024-10-12 17:56:46 +01:00
Vaxry
c3f7c9bbb5 xcursor: don't crash on broken permissions in X themes
ref #8079
2024-10-12 15:18:39 +01:00
UjinT34
ee8116ac5d input: Fix VRR for constrained cursors (#6877) 2024-10-12 01:29:51 +01:00
Edgars Cīrulis
f5db483973 drm-timeline: Add check for conflicting acquire and release points (#8083)
Signed-off-by: Edgars Cirulis <edgarsciruliss@gmail.com>
2024-10-12 01:12:07 +01:00
Toni500github
7564b26b7d internal: improve version query and define HYPRLAND_VERSION (#8034) 2024-10-11 12:19:16 +01:00
Jasson
178a300eea xwayland: minor cleanups and fixes (#8076) 2024-10-11 12:07:25 +01:00
Vaxry
d655a10381 config/layout: nuke no_gaps_when_only (#8072) 2024-10-11 10:56:19 +01:00
Vaxry
b65773bea9 hyprpm: disallow shallow on unknown branch 2024-10-10 11:01:13 +01:00
Vaxry
c4eb194033 gammactrl: guard pMonitor in setGamma 2024-10-09 22:00:06 +01:00
Aqa-Ib
6ae89940c7 layout: add merge_floated_into_tiled_on_groupbar (#8042) 2024-10-09 10:58:49 +01:00
JManch
3d28879c26 hyprerror: fix height calc with bottom bar (#8043) 2024-10-09 10:24:35 +01:00
trianta
223dcc8bac output: update state even if no owner exists (#8044) 2024-10-09 10:24:05 +01:00
Mihai Fufezan
6ce07ee864 CI/release: remove script backup line 2024-10-09 12:00:43 +03:00
Vaxry
bc299928ad output/xdg-output: avoid sending events to released globals
ref #6835
2024-10-09 00:26:40 +01:00
Vaxry
ac658500fb keyboard: update group state on change for the sym resolve state
fixes #8038
2024-10-08 23:33:10 +01:00
Vaxry
8cced091f5 renderer: reserve space for error at the bottom if that's set
ref #8040
2024-10-08 21:58:40 +01:00
Vaxry
91299f7039 hyprerror: make hyprerror reserve space (#8040) 2024-10-08 21:20:25 +01:00
Vaxry
60308a2bb5 defaultConfig: add a nofocus rule for weird X windows
ref #6543
2024-10-08 20:28:34 +01:00
Aqa-Ib
613eac4603 layout: remove unnecessary check after 45e8219 (#8037) 2024-10-08 19:31:15 +01:00
JManch
e4a26f4f1d dispatchers: allow leading whitespace in window parameter (#8016) 2024-10-08 17:50:06 +01:00
Vaxry
57b632ead8 pointer: expand sw cursor damage box
fixes #8031

just a bit, rounding errors I guess
2024-10-08 17:03:19 +01:00
Vaxry
1bf63dfdcd protocols: Add support for hyprland-ctm-control-v1 (#8023)
* initial ctm support

* flake.lock: update

* Meson: bump required versions and add ctm proto

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-10-08 16:59:15 +01:00
vaxerski
e0cfbec66b keybinds: fixup xkb_states for resolve_by_sym
fixes #7750
2024-10-08 13:15:58 +01:00
davc0n
b3a7e3109b misc: refactor version command (#8027)
Fixes a minor spacing issue if git status is not dirty.
Additionally now should be easier to extend it eventually.
2024-10-08 11:42:51 +01:00
Aqa-Ib
45e82199fb layout: add drag_into_group to control merging dragging windows (#8004) 2024-10-08 11:20:41 +01:00
Vaxry
4711796d38 config: give simple help for super+q not working
only on default config :P
2024-10-08 09:54:25 +01:00
Ikalco
0d70c44253 screencopy: fix screencopy frames not being cleaned up (#8017)
---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-10-08 01:23:48 +01:00
MightyPlaza
a364df4c9e internal: use clampWindowSize to unify min/maxsize handling (#8014)
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
2024-10-07 19:52:49 +01:00
Artur Manuel
46d990f1b6 feat: add a custom made treewide formatter (#7992) 2024-10-07 21:49:19 +03:00
Timon Schelling
5bf7b1e1fa flake.nix: add xdph follows
fixes a duplicate  hyprland-protocols instance sometimes being created due to xdph not following hyprlands instance
2024-10-07 21:43:35 +03:00
Aqa-Ib
97444ed7a8 layout: fix auto group when opening a new window in a non-focused workspace using window rules (#8006) 2024-10-07 13:22:55 +01:00
Vaxry
4e41cda27e security-context: close client fds after disconnect 2024-10-06 15:08:26 +01:00
Vaxry
da86aac0f5 security-context: implement protocol
fixes #7318
2024-10-06 14:07:07 +01:00
Vaxry
0c7a7e2d56 version: bump to 0.44.0 2024-10-06 12:04:13 +01:00
Vaxry
0ec6072a29 single-pixel: set buffer size to 1,1 2024-10-05 16:36:57 +01:00
Vaxry
3ca699debf opengl: use GL_CLAMP_TO_EDGE instead of GL_CLAMP
avoid error spam on select hw
2024-10-05 14:57:18 +01:00
Vaxry
52c0919621 monitor: arrange monitors on connect and disconnect 2024-10-05 14:41:44 +01:00
Vaxry
6fbfeefc71 protocolmgr: don't expose the fallback output 2024-10-05 14:40:03 +01:00
Vaxry
46bf87c8d1 monitor: use a scope guard for disconnect events 2024-10-05 14:37:12 +01:00
Vaxry
595eb89f6e renderer: Fix resize artifacts (stretching, bumps) (#7499) 2024-10-05 01:01:21 +01:00
Vaxry
a815b14bf1 monitor: cleanup and modernize scheduleDone 2024-10-05 01:01:21 +01:00
Vaxry
3a5052a714 compositor: update all xdg outputs on arrange 2024-10-05 01:01:21 +01:00
Vaxry
8e237b006f xdg-output: minor cleanups 2024-10-05 01:01:20 +01:00
Theo Paris
1ed925b69c internal: fix missing include directive (#7984)
This should fix building with clang.
2024-10-04 09:41:27 +01:00
Maximilian Seidler
aed529f695 renderer: fix uvBR calculation (#7975) 2024-10-03 23:00:44 +01:00
Aqa-Ib
de68e065fe layout: fix dragging a window into a group after e242694 (#7976) 2024-10-02 21:25:25 +01:00
Aqa-Ib
e2426942e5 layout: add auto_group to control default grouping (#7883) 2024-10-02 10:22:19 +01:00
Vaxry
5c6c300abf wayland/output: send geometry in updateState 2024-09-30 17:42:36 +01:00
Vaxry
6bd3397141 wlr-output-management: accept 0 refresh rates
fixes #7879
2024-09-30 17:40:38 +01:00
Vaxry
68fd32c810 byteoperations: add missing header 2024-09-30 17:27:10 +01:00
Vaxry
3ddb16bd5b compositor/wayland: up the max buffer size to avoid disconnects when app hangs 2024-09-30 17:25:57 +01:00
Trianta
f6387536f6 protocol: fix missing include 2024-09-30 10:06:39 +03:00
Trianta
968f6a6013 meson: fix arch build with new protocol 2024-09-30 10:06:39 +03:00
Vaxry
488efab636 single-pixel-buffer: new protocol impl
fixes #6624
2024-09-30 00:58:16 +01:00
Gliczy
6649255d54 flake.lock: update 2024-09-29 17:56:27 +03:00
Luke Chen
4b00cba319 dwindle: add movetoroot method to layout messages (#7903) 2024-09-29 14:47:59 +01:00
Mike Will
9e418671e1 config: add descriptions for dwindle and master layout options (#7933) 2024-09-29 14:42:10 +01:00
Mihai Fufezan
d73c14751a CI/Nix: git+https -> github 2024-09-28 21:53:18 +03:00
bivsk
6f313de952 core: Fix Musl builds (#7934)
Musl does not include the internal type `__time_t`.
Use `time_t` instead.
2024-09-28 13:46:31 +01:00
Mike Will
2cf6e7862a dwindle: add config option split_bias (#7920)
If `default_split_ratio` is greater than 1.0, `split_bias` will give the
bigger half to a specific window:

0 - positional (default)
1 - current window
2 - opening window
2024-09-28 01:49:40 +01:00
Mihai Fufezan
58669fef77 flake.lock: update 2024-09-27 18:35:29 +03:00
Vaxry
e20aef7d53 opengl: remove debug log 2024-09-26 22:34:33 +01:00
Mihai Fufezan
b2143a98e2 CI/Nix: no longer build with submodules 2024-09-27 00:07:52 +03:00
Mihai Fufezan
f75f8efb1b Meson: add tracy dependency 2024-09-27 00:07:52 +03:00
Mihai Fufezan
be96787ed0 CMake: use udis86 from pkg-config, fallback to subproject
Only canihavesomecoffee's fork (the one the subproject uses) provides
a .pc file, so we either find the correct version or we use the
subproject.
2024-09-27 00:07:52 +03:00
Mihai Fufezan
89d945aabe CMake: use hyprland-protocols from pkg-config, fallback to subproject
protocolnew: fix external path, which may not be in $CMAKE_SOURCE_DIR
2024-09-27 00:07:52 +03:00
Mihai Fufezan
27211c71e9 Meson: try to find udis86 through pkgconfig, fallback to subproject
Only the fork provides a .pc file, so there's no risk of linking the wrong
lib version. If pkg-config can't find it (most cases), fall back to using
the subproject through the wrap file.
2024-09-27 00:07:52 +03:00
Mihai Fufezan
14942bca60 Nix: re-add hyprland-protocols 2024-09-27 00:07:52 +03:00
Mihai Fufezan
77f2a01304 flake.lock: update nixpkgs 2024-09-26 21:17:07 +03:00
Mihai Fufezan
7b56ce6521 CI/Nix: add cross build 2024-09-26 21:17:07 +03:00
Jörg Thalheim
32a8caf7e7 Nix: also test cross build 2024-09-26 21:17:07 +03:00
Vaxry
caaa9b11e4 wlr-output-configuration: Improve output configuration (#7571) 2024-09-26 11:10:53 +01:00
Kamikadze
b1ad2d8066 dispatchers: fixup dpms toggle (#7875)
now toggles every monitor individually
2024-09-26 00:08:50 +01:00
Vaxry
22746b3046 hyprctl: use the getMonitorData helper everywhere 2024-09-25 23:38:11 +01:00
Vaxry
49713fab04 pointermgr: avoid hogging CMonitor refs 2024-09-25 23:15:41 +01:00
vaxerski
8b86ee8bf0 github: encourage usage of --systeminfo if Hyprland won't launch 2024-09-25 10:39:33 +01:00
vaxerski
2a052c69f3 core: add a --systeminfo parameter to gather systeminfo without running 2024-09-25 10:36:51 +01:00
Vaxry
2320b2241c Internal: move to Mat3x3 from hyprutils (#7902)
* Meson: require hyprutils >= 0.2.3

* flake.lock: update hyprutils

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-09-25 10:01:13 +01:00
vaxerski
8f5188269b hyprctl: add solitary field to hyprctl monitors 2024-09-25 09:59:18 +01:00
vaxerski
00c8626863 hyprctl: add submap request
fixes #7898
2024-09-24 11:25:05 +01:00
Vaxry
0a211f29f5 hyprctl: add defaultName to workspacerules
fixes #7886
2024-09-24 01:19:05 +01:00
Vaxry
d279d7c4c6 eventloop: dispatch pending in session on start
fixes #7855 #7391
2024-09-24 00:49:29 +01:00
diniamo
6c78b03bb7 flake: update xdph 2024-09-24 00:47:34 +01:00
Vaxry
f79497087b internal: nuke wlsignal and related
old semi-wrappers for wl_signal, they are no longer used
2024-09-24 00:47:34 +01:00
Artur Manuel
508bde1f61 core: add HYPRLAND_CONFIG environment variable (#7851) 2024-09-23 16:40:19 +01:00
diniamo
e5ff19ac0f flake: update xdph 2024-09-22 11:55:13 +03:00
Mihai Fufezan
8579066c7a Nix: clean up derivation 2024-09-21 14:27:13 +03:00
Vaxry
9232bc2c00 internal: move to hyprutils' scopeguard
bumps hyprutils dep to 0.2.2
2024-09-21 00:37:17 +01:00
Vaxry
db0b764a5a shm: send a static list of shm formats
fixes #7733
2024-09-20 22:56:15 +01:00
Mihai Fufezan
278583b8a1 flake.lock: update 2024-09-20 20:16:13 +03:00
Jasson
4414cd07e2 xwm: Minor cleanup, add wrappers for basic types (#7856) 2024-09-20 12:32:04 +01:00
Vaxry
9e98fb0167 dmabuffer: attempt importing failed dmabufs as implicit
don't ask me why, vulkan doesn't like this.

funny note, broken on wlroots :P

fixes #7037
2024-09-20 10:47:41 +01:00
Mihai Fufezan
9856378384 Nix: use mold linker 2024-09-19 18:53:34 +03:00
Mihai Fufezan
dfa1bd0cd4 Meson: pass AQUAMARINE_VERSION argument 2024-09-19 13:48:31 +00:00
vaxerski
92df6b0dce version: log build aquamarine version
log the built against aq version, might be useful when it's mismatched to identify the problem
2024-09-19 11:40:00 +01:00
vaxerski
71963972bf args: add --version to binary args 2024-09-19 11:40:00 +01:00
Arisa Snowbell
1bc05b1f9f xwayland: use proper path for the XWayland sockets (#7852)
fixes #7849
2024-09-19 11:08:02 +01:00
Vaxry
e6cf643f5a pointermgr: Hide hardware cursor on leave (#7806) 2024-09-18 18:47:53 +01:00
Jasson
94140e886e xwayland: Some readability improvements (#7807)
* Readability improvements xwayland server

* Made requested changes

* removed braces

* fix

* Ok this time is fixed

* Formatting
2024-09-18 18:12:26 +01:00
Mihai Fufezan
b248d59713 Nix: fix meson PCH flag 2024-09-18 19:43:56 +03:00
Mihai Fufezan
cbc0ff6ec0 Nix: disable PCH 2024-09-18 18:54:00 +03:00
Mihai Fufezan
6b6554adb8 flake.nix: inherit stdenv from package
Means we no longer have to change the base stdenv in two places.
2024-09-18 18:43:39 +03:00
Mihai Fufezan
d936eb437b flake.lock: update aquamarine 2024-09-18 17:26:51 +03:00
vaxerski
883d01084c userchecks: add an xdg_current_desktop check
ref https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/251

if the XDG_CURRENT_DESKTOP is externally managed (e.g. DE, DM, etc) Hyprland will not overwrite it. In those cases, if that's undesired, portals and other apps depending on it might break.
2024-09-18 11:22:12 +01:00
Aqa-Ib
0564b46a5e dispatchers: allow moveintogroup when floating (#7818)
This allows to use the moveintogroup dispatcher when windows are floating. I don't know why was this disabled in the first place though.

Cheers!
2024-09-18 11:05:17 +01:00
André Silva
3c9716acfd gammactrl: fix potential crash on monitor removed (#7828) 2024-09-17 14:37:20 +01:00
vaxerski
581f6659f8 data-device: conform to reported source actions
fixes #7815
2024-09-17 12:55:48 +01:00
vaxerski
e72ae6b25f hyprctl: allow parsing empty value
fixes #7821
2024-09-17 11:24:54 +01:00
Leiser Fernández Gallo
9e35656244 internal: Delay monitor events/hooks (#7797)
* Delay monitor messages

* Format
2024-09-15 21:03:42 +01:00
AlvinaNancy
e87758529e internal: Fix change group current fullscreen state query (#7802) 2024-09-15 18:25:06 +01:00
Sungyoon Cho
eb97d949aa textinput: don't reset if ti isn't enabled (#7798) 2024-09-15 17:31:38 +01:00
Ikalco
e74efd87e5 internal: fix initial cursor warping (#7793) 2024-09-14 23:37:18 +01:00
Vaxry
4dbdb556fe data-device: don't send default action of move
gtk doesn't like it?
2024-09-14 23:36:06 +01:00
Vaxry
5ee4b19691 data-device: send clock time in motion events
remove hack
2024-09-14 23:35:45 +01:00
Vaxry
d35e70a8c6 cmake: drop ninja dep 2024-09-13 17:56:44 +01:00
diniamo
c35ed8363f nix: adapt cmake options 2024-09-13 19:44:38 +03:00
diniamo
d505b33665 nix: use meson 2024-09-13 17:54:49 +03:00
Sungyoon Cho
118be4dea0 textinput: fix tiv3 leave (#7761) 2024-09-12 17:41:24 +01:00
trianta
73b9756b8d xwayland: remove extra x11 deactivation (#7755) 2024-09-12 10:15:01 +01:00
fufexan
8b9e385943 [gha] Nix: update inputs 2024-09-11 16:10:51 +00:00
Mihai Fufezan
e01da1fd7a Meson: format 2024-09-11 19:09:17 +03:00
Mihai Fufezan
7a8c013edc Meson: fix protocols, clean up 2024-09-11 19:09:16 +03:00
Vaxry
518399a95b pointermgr: avoid derefing null outputs 2024-09-11 09:30:21 +01:00
Sungyoon Cho
155d44016d textinput: handle IME resetting (#7731) 2024-09-10 14:49:10 +01:00
Alexandre Acebedo
13f90bb87a update xdph commit in flake.lock 2024-09-10 16:38:47 +03:00
davc0n
c67b257e51 build: Set cmake_minimum_required to version 3.30 (#7709)
* build: Set cmake_minimum_required to version 3.30

* Nix: add patch for CMake min ver

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-09-10 11:06:37 +01:00
Maximilian Seidler
8237d7e1a4 input: move dmps activation to input listeners (#7721) 2024-09-09 21:29:00 +01:00
vaxerski
85da1a17d8 [gha] build man pages 2024-09-09 15:19:44 +00:00
justmessingaround
9609b04ff9 man: Fixed the man page to show the new information (#7713)
* Update Hyprland.1.rst

* Update Hyprland.1
2024-09-09 16:19:17 +01:00
darkwater
04421063af config: add order rule for layers (#7697) 2024-09-09 10:10:08 +01:00
davc0n
43e1415e71 assets: Remove execute permission from lockdead.png (#7715) 2024-09-09 10:01:26 +01:00
Sungyoon Cho
e1448732b3 tiv1: fix deleting first character (#7716) 2024-09-09 09:58:44 +01:00
Richard Ayotte
7c4c402bd7 config: include XF86Audio* key bindings to default cfg (#7695) 2024-09-08 22:04:07 +01:00
Aqa-Ib
6179b17903 github: improve issue template (#7699)
* github: improve issue template

Require to check that you have searched through open and closed issues before committing.

* fix yaml syntax

* clarify text

* validation

* revert validation

* markdown

* done
2024-09-08 21:12:01 +01:00
Davide Conti
05b48d48d9 config: Limit max volume to 100% 2024-09-08 22:53:28 +03:00
diniamo
07a21fdfa9 github(nix-build): switch to better nix installer, attempt at fixing hash mismatch (#7701)
* github(nix-build): switch to DeterminateSystems/nix-installer-action

* github(nix-build): switch to a direct git reference instead of cloning

* github(nix-ci): attempt to fix CI for pull requests
2024-09-08 21:20:45 +03:00
Vaxry
0f594732b0 props: bump version to 0.43.0 2024-09-08 17:48:21 +01:00
Vaxry
312411fc70 windows: support size with pseudo tiled
fixes #7690
2024-09-08 00:46:46 +01:00
trianta
70add904c4 config: add exec-shutdown for running commands on shutdown (#7683)
* config: add exec-shutdown for running commands on shutdown

* compositor: delay stopping until after exec-shutdown
2024-09-07 20:54:33 +01:00
Darth ŠČ!
5ca4823128 config: Added default button mapping for xf86 keys (#7672)
* Added default button mapping for laptop multimedia keys for volume and brightness

* Added default button mapping for laptop multimedia keys for volume and brightness into example config
2024-09-07 16:14:23 +01:00
outfoxxed
0500213086 input: try to refocus a focusable window when seat grabs are reset (#7669) 2024-09-07 01:06:55 +01:00
outfoxxed
b0fca6eaf0 input: kb focus mouse focused window if unset (#7666)
Normally it shouldn't be possible to have mouse focus with no kb
focus, but it does happen, and when it does this makes it considerably
less annoying.
2024-09-06 01:03:12 +01:00
Maximilian Seidler
4988e00b1d input: move idle notify to input handlers (#7659)
* Revert "input: don't emit idle activity when calling simulateMouseMovement (#7649)"

This reverts commit ea10592ad3.

* input: move idle notify calls to input event listeners

* input: don't post idle activity when keyboard is not enabled
2024-09-06 00:58:57 +01:00
Sungyoon Cho
0fad7a0bb0 workspacerules: fix on-created-empty window focus (#7657) 2024-09-06 00:54:01 +01:00
Sungyoon Cho
727f1b54cd textinput: fix ime activation in some edge cases (#7660)
* textinput: clear ti3 state when focused surface gets destroyed

* textinput: send enter to newly created ti in focus
2024-09-05 20:04:23 +01:00
Mihai Fufezan
c80457be02 nix: add COMMITS var 2024-09-05 21:26:12 +03:00
Parola Marco
4a42c5ed20 config: Add a variable to prevent groups from merging after being dragged (#7650)
* config: Add a variable to prevent groups from merging after being dragged

* Fixed code style for [f777f028]
2024-09-05 17:29:33 +01:00
trianta
bd6d6e7f33 xwayland: add option to enable/disable xwayland (#7633)
* config: add xwayland enabled option to config

* xwayland: use DISPLAY env variable for enable/disable of new launches

* xwayland: close X11 windows when turning of XWayland

* clang: format fix

* config: add better description for xwayland:enabled

* xwayland: close X11 windows on disable without crashes

* xwayland: better method of informing CXWayland if xwayland enabled

* xwayland: prevent closing non-xwayland windows on disable

* misc: loop formatting
2024-09-05 17:26:46 +01:00
Maximilian Seidler
027140b731 sessionLock: ensure sls focus in some edge cases (#7647)
* input: return early in mouseMoveUnified when the session is locked

* sessionLock: make make a commit an opportunity to focus session lock surfaces

* compositor: allow resetting focus when session is locked

* input: remove redundant PMONITOR checks

PMONITOR is checked above

* input: check isSessionLocked earlier in mouseMoveUnified

A bit of reordering, so that we don't call some stuff that is irrelevant
when the session is locked
2024-09-04 16:59:00 +01:00
Maximilian Seidler
ea10592ad3 input: don't emit idle activity when calling simulateMouseMovement (#7649) 2024-09-04 11:23:29 +01:00
vaxerski
9b54342baa Revert "syncobj: wait for deadline instead of available"
This reverts commit cf6a1716ae.

Fixes #7628
2024-09-03 14:47:34 +02:00
Mihai Fufezan
8f9887b0c9 Nix: remove unused dependencies 2024-09-02 23:48:58 +03:00
Jan Beich
fa39df4731 CMake: drop unused deps after 016da234d0
Found via LDFLAGS += -Wl,--as-needed (default in Meson).
Some dependencies are only used by aquamarine.
2024-09-02 23:48:58 +03:00
Jan Beich
f7249bd331 CMake: drop duplicate -luuid after 5262292abc 2024-09-02 23:48:58 +03:00
Sungyoon Cho
6934e7aa2b textinput: don't deactivate ime if another ti is focused (#7617) 2024-09-01 21:33:31 +02:00
Sungyoon Cho
8bbeee2041 textinput: send deactivate to ime on destory ti (#7614) 2024-09-01 18:44:33 +02:00
Mihai Fufezan
7a24e564f4 flake.lock: update xdph again 2024-09-01 19:37:25 +03:00
Mihai Fufezan
4b5b8a7630 flake.lock: update xdph 2024-09-01 18:14:14 +03:00
Mihai Fufezan
5b1375141b flake.lock: update 2024-09-01 17:18:57 +03:00
Tom Englund
4af9410dc2 xwm: read atom name from xcb (#7546)
expand the debug trace logging by actually reading the atom name from
xcb if not found in HYPRATOMS, will also print the proper atom for xcb
internal ones and not just the HYPRATOMS ones.
2024-09-01 12:04:28 +02:00
Ikalco
a6315b0af4 core: fix crash on monitor removed with gammaControl (#7601)
* fix crash on monitor removed with gammaControl

* Update GammaControl.cpp
2024-08-31 21:55:08 +02:00
TheMical
cac59fefec data-device: Fix selection mismatch when wlr resets primary selection (#7598) 2024-08-31 21:43:02 +02:00
Ikalco
1ac2fc3f7e protocols: destroy new xdgDialog protocol at right time (#7600) 2024-08-31 21:07:23 +02:00
Vaxry
cf6a1716ae syncobj: wait for deadline instead of available
avoids slow apps from lagging the desktop
2024-08-31 18:33:04 +02:00
NotAShelf
10d7219807 CI: clarify Nix CI jobs; disable on forked repositories 2024-08-31 17:17:36 +03:00
Ikalco
838ed87d6f renderer: minor direct scanout fixes (#7594) 2024-08-31 15:07:52 +02:00
Jan Beich
76b82fdde7 meson: explicitly specify path for find(1) (#7590)
assets/install/meson.build:1:10: ERROR: Command `/bin/sh -c 'find -type f -not -name "*.build"'` failed with status 1.
2024-08-31 11:01:02 +02:00
Vaxry
c5fd577181 config: Add a window rule to render while unfocused (#7582) 2024-08-30 17:37:52 +02:00
Vaxry
fbd6354393 presentation-feedback: minor fixups 2024-08-30 15:53:45 +02:00
Vaxry
fd8d8e122e keybinds: fixup misused kb state
fixes #7369
2024-08-30 15:53:45 +02:00
Vaxry
1c9d56998d xdg-dialog: implement new protocol 2024-08-30 15:53:44 +02:00
darkwater
242e06b242 keybinds: release mods after sendshortcut (#7581) 2024-08-30 15:06:49 +02:00
Vaxry
25e72949a1 window/xwayland: minor property cleanup
fixes #6921
2024-08-30 14:12:23 +02:00
trianta
259dcd838e xwayland: update overrideRedirect on map and configure (#7575) 2024-08-30 14:04:09 +02:00
Mihai Fufezan
ef33198e8f flake.lock: update aquamarine and hyprutils 2024-08-30 14:10:46 +03:00
Vaxry
604eb21a7e renderer: better lockscreen dead behavior (#7574)
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-08-29 23:30:12 +02:00
Mihai Fufezan
92a0dd164e flake.lock: update 2024-08-29 13:41:03 +00:00
Vaxry
b9b8e6220f renderer: fade out windows on silent moves 2024-08-28 21:54:49 +02:00
Vaxry
a95df6b57e xwm: don't mark selection events as succeeded
fixes #7401
2024-08-28 20:37:07 +02:00
Vaxry
9642311ac2 window: don't focus on activate if window isn't mapped yet
ref #7089
2024-08-28 20:33:38 +02:00
Ikalco
98e99cd03d renderer: ensure buffer format on commit (#7556) 2024-08-28 15:07:13 +02:00
diniamo
8210a1d7ac nix(flake): update aquamarine 2024-08-28 15:28:01 +03:00
Vaxry
d105c7403c hyprctl: add next and all to switchxkblayout
fixes #7555
2024-08-28 14:05:31 +02:00
Vaxry
00ee1cf98e data-device: send dndFinished when dnd offer is destroyed while unfinished
fixes #7496

see 711c5bb43f

see https://bugs.kde.org/show_bug.cgi\?id\=482142
2024-08-28 13:45:13 +02:00
Ikalco
7dd0f76e5a logs: don't get timezone every time logging (#7550)
its expensive cause cpp dum
2024-08-28 13:19:06 +02:00
Tom Englund
17ed4fc04c hyprctl: avoid parsing string::npos on invalid cmd (#7544)
* hyprctl: avoid parsing string::npos on invalid cmd

invalid lines passed to hyprctl keyword made the string parsing try to
parse std::string::npos, avoid that and return an error text instead.

* style

---------

Co-authored-by: Vaxry <vaxry@vaxry.net>
2024-08-27 20:42:30 +02:00
Nick H
6a8824253c build: Fix NO_XWAYLAND compilation (#7538) 2024-08-27 20:41:46 +02:00
Serenity Braesch
eb42adc4c0 Fix missing include needed by clang 2024-08-26 22:36:43 +03:00
raf
09dbcabcc7 CI: disable stale workflow on forks (#7535)
The stale workflow will run unconditionally, but will fail on forks due to
`STALEBOT_PAT` not being set. Trigger the workflow *only* if we are on the
main repo, where we can guarantee the PAT. Also formats the YML syntax to be
slightly more readable.
2024-08-26 20:24:57 +02:00
Tom Englund
72c7818ae6 misc: constify the remaining for loops (#7534)
now we roll loops at blazing constified speed.
2024-08-26 20:24:30 +02:00
Tom Englund
1ea47950f4 misc: fix some minor typos (#7530)
* keybindmgr: fix typo in swap prev

seems a suspicious extra ) got added, remove it.

* configmgr: dont dereference invalid iterator

i think the idea here was to print the key and not the iterator at or
past .end()
2024-08-26 18:02:44 +02:00
Tom Englund
8d6c18076f core: make most for loops use const references (#7527)
why not let the compiler optimise things for us at hyprspeeds when we
can.
2024-08-26 17:25:39 +02:00
Tom Englund
9c5a37a797 build: fix 32bit builds (#7510)
ensure the correct type is passed to std::clamp and std::max int64_t is
different on 64bit compared to 32bit, also in presentationtime
tv_sec is __time_t and on 32bit its a 32bit type so right shift count >= width
of type. so only bit shift on 64bit. and avoid potential nullptr deref
in the for loops, check for .end() before *it <= endID.
2024-08-26 14:08:30 +02:00
Adithya Ajith
ca85455a8e misc: Rename all instances of "emtpy" to "empty" (#7522) 2024-08-26 12:25:52 +02:00
Maximilian Seidler
28f6c2df59 sessionLock: fix misc:allow_session_lock_restore (#7511)
* Revert "sessionLock: fix the check for locking a locked session (#6843)"

This reverts commit 9ff83f4aa9.

* sessionLock: remove early check for session beeing locked

It is checked in the `onNewSessionLock` handler, which also respects the
`misc:allow_session_lock_restore` option.
2024-08-26 10:27:34 +02:00
Vaxry
83ab3ae0af xwaylandmgr: minor refactor to activateSurface
Make it more efficient now that we can + fix possible nullptr deref

fixes #7514
2024-08-26 10:24:45 +02:00
trianta
b672118f92 xwayland: deactivate xwayland focus if wayland is focused (#7458)
* xwayland: deactivate xwayland focus if wayland is focused

* xwayland: deactivate last xwayland surface after focusing wayland
2024-08-25 16:37:03 +02:00
Nelo-T. Wallus
aac90d9279 hyprpm: Fix checking dependencies (#7504)
* hyprpm: Fix checking dependencies

* hyprpm: Check for dependency "pkg-config"

---------

Co-authored-by: Nelo-T. Wallus <nelo@wallus.de>
2024-08-25 13:13:48 +02:00
Ikalco
66586c38f5 keybinds: refactor dispatchers to be better (#7331) 2024-08-24 18:45:53 +02:00
Vaxry
82c67e61a9 config: fix uninitialized values with mode parsing 2024-08-24 15:24:55 +02:00
Vaxry
e45e606fbd layersurface: don't unref from monitor until dtor
reee
2024-08-24 15:22:10 +02:00
Sungyoon Cho
688fe5c147 windowrules: add fullscreenstate field (#7466)
* windowrules: add fullscreenstate field

* fix typo
2024-08-23 20:42:14 +01:00
MahouShoujoMivutilde
a3b75559b3 input: Fix modifier keys getting stuck if depressed during config reload (#7486)
The problem:
    If `input:numlock_by_default = true`, depressed mods will get stuck
    on config reload; this takes effect after some other mod is pressed.

This restores 0.41.2 behavior, with the exception that selected keyboard
layout is preserved.

918d8340af/src/managers/input/InputManager.cpp (L993-L1002)
2024-08-23 20:35:52 +01:00
Tom Englund
df4f222482 layersurface: remove layer on destroy from monitor (#7457)
remove destroyed layer weakptrs on destroy, we can hit multiple
null ptr derefs in renderering on mirroring and unmirroring displays
otherwise.
2024-08-23 14:06:52 +01:00
vaxerski
3b663f4afc screencopy: fixup 10-bit sharing via shm on nvidia 2024-08-23 14:13:49 +02:00
Red
f634b9e61a Fix crash reports having execute permission 2024-08-22 15:28:01 +03:00
Mihai Fufezan
bdb296a83c flake.lock: update 2024-08-22 14:30:17 +03:00
Mihai Fufezan
4fa63104c9 Nix: exclude wayland-scanner until next staging merge 2024-08-22 14:30:10 +03:00
Florian Klink
a437e44a6a CMakeLists: wayland.xml is in wayland-scanner pkgdatadir
See 6c4a695045/meson.build (L129-136)

Similar fix as https://github.com/hyprwm/aquamarine/pull/55.
2024-08-22 13:50:00 +03:00
Tom Englund
cae937c51b layersurface: dont rollover on size_t (#7451)
unneded rollover on size_t if force equals -1
2024-08-21 22:05:03 +01:00
James R Larrowe
8162fae377 Fix Makefile too
... did this ever work?
2024-08-21 23:09:13 +03:00
James R Larrowe
c5786be695 Fix static asan patch 2024-08-21 23:09:13 +03:00
Mihai Fufezan
1b1ecf77e0 Nix: include xcursor regardless of xwayland 2024-08-21 22:37:28 +03:00
vaxerski
883463f9dd animations: add workspace in/out configs 2024-08-21 14:38:07 +02:00
Tom Englund
3e7325af57 output: dont cast enum out of range (#7448)
avoid casting non typed enum out of range, looks like
WL_OUTPUT_MODE_CURRENT was the intention here.
2024-08-21 11:52:40 +01:00
ParaN3xus
946ed1f32a core: add option to control which window to focus on close (#7368) 2024-08-21 11:24:42 +01:00
Ali Atashrooz
4eff224a7f example/config: fix typo in default config (#7446)
* Update hyprland.conf

* Update defaultConfig.hpp
2024-08-21 11:24:02 +01:00
vaxerski
c86db7bbb0 monitor: avoid dangling references to old monitors being undestroyed
ref #7414
2024-08-19 18:44:22 +02:00
vaxerski
272d904870 monitors: avoid crash on wayland output removal 2024-08-19 18:36:14 +02:00
JL2210
01e3da4d51 examples: more systemd examples (#7409)
These allow launching hyprland with a systemd service. They provide
graphical-session.target which allows enabling services such as the
ones for Waybar and Mako.
2024-08-19 14:02:09 +01:00
Jan Beich
33015546c6 config: add missing header for libc++ after 92744b5b9a (#7403)
In file included from src/pch/pch.hpp:1:
In file included from src/Compositor.hpp:11:
src/config/ConfigManager.hpp:147:10: error: no template named 'variant' in namespace 'std'
  147 |     std::variant<SBoolData, SRangeData, SFloatData, SStringData, SColorData, SChoiceData, SGradientData, SVectorData> data;
      |     ~~~~~^
2024-08-19 13:46:36 +01:00
loseardes77
83d88fa564 hyprpm, hyprctl: update shell completions 2024-08-19 00:21:59 +03:00
diniamo
11dfb8397b flake: update aquamarine 2024-08-19 00:18:26 +03:00
vaxerski
f4045ab8d0 screencopy: fix 10b format r/b flip 2024-08-18 22:57:21 +02:00
vaxerski
fa12efdd2a protocol: fix logm template checks 2024-08-18 22:54:47 +02:00
vaxerski
bf611fbbf3 screencopy: nuke unused stuff 2024-08-18 22:40:21 +02:00
Tom Englund
5afc4dc42e compositor: update suspendstate on window move (#7396)
hyprctl dispatch -- movetoworkspacesilent x,"^kitty$" where X is the
current workspace makes kitty stops updating until current workspace is
changed while it is on the screen. update the suspend state after it has
been moved.
2024-08-18 20:02:46 +01:00
vaxerski
50348a3ddb renderer: pass custom modelines to aq
ref #7390
2024-08-18 20:19:13 +02:00
vaxerski
279ec1c291 linux-dmabuf: allow on split-node systems
ref #7364
2024-08-18 19:52:01 +02:00
Tom Englund
1006663b6e shm: align size to stride (#7383)
calculate the size to the stride we got to better align it.
2024-08-18 09:23:27 +01:00
Sami Liedes
b2a18aa80a input: Fix disabling tap-to-click (#7304)
* Allow disabling tap-to-click

* Style fix
2024-08-18 08:14:42 +01:00
leiserfg
d21a6b12b8 Update aquamarine input in flake 2024-08-18 09:47:39 +03:00
vaxerski
912e7ba82d render: fixup format mismatch after leaving DS
fixes #7373
2024-08-17 19:27:20 +02:00
Vaxry
92744b5b9a IPC: Add config descriptions (#7377)
Thanks @gulafaran for the work

---

Co-authored-by: @gulafaran
2024-08-17 17:33:16 +01:00
Tom Englund
c5feee1e35 xcursormgr: dont apply scale on gsettings (#7316)
gtk scales the cursor size itself since its CSD so if we scale the size
its gonna get double scaled. incorporate the scale into xcursormanager
to keep track of it.
2024-08-16 17:00:59 +01:00
Tom Englund
1840a907a8 renderbuffer: ensure framebuffer gets deleted (#7363)
after commit 4b4971c it uses m_iFbAllocated and deletes if upon calling
release() but Renderbuffer generates directly on m_iFb without calling
alloc() meaning it wont be deleted on release(), set m_iFbAllocated to
true after generating the buffer.
2024-08-16 10:09:01 +01:00
Vladimir-csp
682b30fba8 env: Add HYPRLAND_NO_SD_VARS env condition (#7358)
* Add HYPRLAND_NO_SD_VARS env condition

wip #7083

* Formatting shuffle

* Formatting
2024-08-16 08:19:08 +01:00
Tom Englund
12d9901472 protocols: refactor protocol logging to a macro (#7324)
this avoids the usage of the unique_ptr PROTO::protocol before it has
been constructed incase one wants to log something inside the
constructor itself, move the logging to macros and print file:linenumber
on ERR,CRIT,WARN and classname on the rest of the levels.
2024-08-15 17:16:18 +01:00
Vladimir-csp
15f942000e core: Preserve existing XDG_CURRENT_DESKTOP (#7347)
* Preserve existing XDG_CURRENT_DESKTOP

* fix

---------

Co-authored-by: vaxerski <vaxry@vaxry.net>
2024-08-15 17:14:48 +01:00
Maximilian Seidler
520e91238f gamma-control: fix crash on monitor disconnect (#7353) 2024-08-15 17:08:54 +01:00
Kyle
0c56be74a3 keybinds: Fix syncFullscreen inconsistent with state when set by fullscreenState (#7343)
* Set syncFullscreen to true on synced non -1 states

* Fix syncFullscreen value in fullscreenState
2024-08-15 17:04:24 +01:00
Mirkwood
069faa4027 helpers: fix: revert to signed arithmetic for cycling through workspaces (#7339)
The code clearly expects signed types there.
Fixes #7329
2024-08-15 13:03:23 +01:00
vaxerski
c30dfe92ee [gha] Nix: update inputs 2024-08-15 11:39:29 +00:00
Ikalco
d85ae306c5 xcursor: handle file errors when loading xcursor themes (#7326) 2024-08-15 12:37:56 +01:00
davc0n
197f880790 logs: Add file path to asset ERR log (#7336) 2024-08-14 18:35:07 +01:00
MightyPlaza
3b4aabe04c decorations: fix manual resize not recalculating decos (#7323)
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/MasterLayout.cpp
2024-08-13 21:00:31 +01:00
Mihai Fufezan
c5ec079c6f hyprpm, hyprctl: remove Makefiles 2024-08-13 22:14:58 +03:00
Patrick Ulbricht
4aec237ec0 README: Change image sources from vaxerski/Hyprland to hyprwm/Hyprland (#7315)
* readme: Change image sources from vaxerski/Hyprland to hyprwm/Hyprland

* readme: Remove unused image
2024-08-13 19:14:52 +01:00
Ikalco
39df1f4dbf cursormgr: fix cursor gsettings on session change (#7295) 2024-08-13 18:27:00 +01:00
Tom Englund
77cf651825 protocols: avoid crashing in drmlease (#7290)
instead of potentially causing wonky behaviour from destructing in the
constructor add the unique_ptr reset to doLater and dont use the not
done constructed protolog in the constructor, call Debug::log directly.

see issue #7240
2024-08-12 19:49:52 +01:00
Kyle
c7b72790bd keybinds: Fix fullscreenState toggling behaviour (#7288)
* Update fullscreen state dispatcher behaviour

* Change syncFullscreen default to false

* Revert all changes

* Modify fullscreenstate dispatcher toggle behaviour

* Update syncFullscreen according to state

* Update syncFullscreen before setting fullscreen state
2024-08-12 18:41:26 +01:00
Tom Englund
3fa6db1e7a core: fix data race and a unsigned int rollover (#7278)
* keybindmgr: avoid uint rollover on mouse keycode

mouse keycode is 0, and the switch case checks for 0 - 8 and rolls over,
just return early if keycode is 0.

* watchdog: avoid data races in watchdog

asan thread sanitizer reported data races in the watchdog from reading
and setting the bool variables make them std::atomic bools. also add a
atomic bool for the main thread to wait for to avoid data race when
reading the config values.

* hyprdebug: change non unicode character to name

asan created false positives and didnt like this bit, so for the sake of
easier debugging rename it to something unicode.
2024-08-12 18:19:03 +01:00
Ikalco
d361fcbd85 config: fix explicit sync option warning (#7293) 2024-08-12 17:16:00 +01:00
Mihai Fufezan
df9d830117 flake.lock: update 2024-08-12 18:18:03 +03:00
Yang, Ying-chao
118d4e1001 install: Prepend ${DESTDIR} when creating hyprland symbolic link (fixes #7280). (#7281) 2024-08-11 20:38:16 +01:00
Tom Englund
511eea71c6 pointermgr: fix initial cursorwarp (#7286)
change the hook to monitorAdded instead of newMonitor so its finalized
in the compositor and added to vMonitors, move the
checkDefaultCursorWarp to PointerManager and check for it upon mode
change. and also ensure it doesnt go out of bounds by replacing it in
the middle again on resolution changes.
2024-08-11 19:42:18 +01:00
Walt Bringenberg
01ff5fdf6a cursor: make inactive_timeout setting a float (#7268) 2024-08-10 21:42:45 +01:00
Zach DeCook
0bf9ceb53b core: Include cstring whenever strncpy is used (#7267)
Fixes ppc64le build in alpine
2024-08-10 21:09:12 +01:00
Vaxry
4fdc0d55e4 eventloop: don't dispatch in enterLoop
ref #6842, BSD blocks in udev on no event apparently
2024-08-10 00:04:26 +02:00
Tom Englund
8b37e81374 cursormgr: add a new setting to sync gsettings (#7253)
cursor:sync_gsettings_theme is set to default true and if enabled it
will now sync xcursor theme loading with gsettings if it can, meaning
CSD clients will now also change to the appropiate theme upon start and
hyprctl setcursor THEME SIZE .
2024-08-09 19:33:20 +02:00
Mathis H.
fd1d4e288e headers: set correct paths to header files (#7245) 2024-08-09 16:51:21 +02:00
Tom Englund
4b4971c06f internal: introduce new types to avoid unsigned int rollover and signed int overflow (#7216)
* framebuffer: avoid gluint overflow

GLuint was being initialized to -1 and rolling over to unsigned int max,
its defined behaviour but very unnecessery. add a bool and use it for
checking if allocated or not.

* opengl: avoid gluint rollover

-1 rolls over to unsigned int max, use 0xFF instead.

* core: big uint64_t to int type conversion

there were a few uint64_t to int implicit conversions overflowing int
and causing UB, make all monitor/workspaces/windows use the new
typedefs. also fix the various related 64 to 32 implicit conversions
going around found with -Wshorten-64-to-32
2024-08-08 21:01:50 +02:00
Vaxry
83a334f97d core: Move to C++26 and use native_handle to CLOEXEC the debug fd (#7219)
Requires GCC >= 14 / Clang >= 18

---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
2024-08-08 11:54:41 +02:00
Vaxry
9a09eac79b props: bump version to 0.42.0 2024-08-07 21:17:10 +02:00
Vaxry
2d552fbaa2 renderer: fixup nvidia driver version checks 2024-08-07 18:54:45 +02:00
Vaxry
ea72831541 wayland/compositor: introduce client commit events 2024-08-07 17:04:49 +02:00
Tom Englund
a399f98c68 cursormgr: avoid scanning ill formed inherit (#7211)
avoid adding ill formed Inherit lines to inherit vector and later
scanning them, it wont change anything in practice but makes the inherit
theme parsing more in line with what its supposed todo. also check for
return values of the various string functions so we dont end up erasing
the wrong thing.
2024-08-07 16:37:09 +02:00
Agent00Ming
3e00d7dde7 compositor: fix general:extend_border_grab_area (#7214)
Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-08-07 16:36:20 +02:00
Sami Liedes
d5bc3eb1fa hyprctl: link to much less libraries (#7212)
This makes hyprctl start significantly faster.

$ time for ((i=0; i<1000; i++)); do hyprctl/hyprctl -j activewindow >/dev/null; done

Before: 12.269 s (about 12.3 ms/execution)
After: 2.142 s (about 2.1 ms/execution)
2024-08-07 16:28:02 +02:00
Vaxry
99e9cb5107 drm-syncobj: fixup fd leak with timelines 2024-08-07 16:08:50 +02:00
Vaxry
f36c625e37 compositor: minor cleanups for fading out layers 2024-08-07 13:35:02 +02:00
Vaxry
2e3dc17a7e renderer: guard layer in renderLayer
ref #7181
2024-08-07 13:31:32 +02:00
outfoxxed
b2717cf7fd xdg-shell: make xdg-positioner flip target greatest available space (#7209)
When both flip directions use more space than is available, pick the
direction that has more space available instead of just the opposite
of what was initially requested.
2024-08-07 13:26:09 +02:00
Tom Englund
3d82d199f0 cursormgr: implement inheriting themes for xcursor (#7197)
* cursormgr: reduce duplicated code

add a few functions such as setCursorBuffer and setAnimationTimer to
reduce duplicated code and also avoid future mishaps of forgetting to
clear buffer or disarm timer. and generally reduce spaghetti even tho
pasta can be delicious.

* xcursormgr: implent inherited themes

implent index.theme parsing and inherited themes.

* cursormgr: ensure a fallback xcursor exist

ensure a xcursor fallback exist otherwise it wont load the proper theme
if we at launch have hyprcursor enabled and then set it to false in
config and reload. also use the env var when using hyprctl setcursor
incase its empty.
2024-08-07 13:23:00 +02:00
Ikalco
a05da63d85 keybinds: fix NoSymbol keybinds (#7199) 2024-08-07 13:22:19 +02:00
Tom Englund
5b736a4a66 debug: dont manually unlock the lock_guard (#7210)
when lock_guard goes out of scope it RAII itself and calls unlock.
causes crashes on freebsd/libc++ and double unlocking a mutex is UB.
2024-08-07 13:22:01 +02:00
Ikalco
fa6ee51367 input: fix leds on kb creation (#7206) 2024-08-07 08:44:20 +01:00
Vaxry
b0a70f63e3 wayland/compositor: drop pending buffer ref if synchronous
fixes https://github.com/hyprwm/hyprpicker/issues/85
2024-08-06 17:08:22 +02:00
Vaxry
d597ae41b9 renderer: fixup crashes on inaccessible files for bg 2024-08-06 16:57:15 +02:00
Vaxry
640d161851 renderer: Explicit sync fixes (#7151)
Enables explicit sync by default for most platforms

`misc:no_direct_scanout` -> `render:direct_scanout`
2024-08-06 15:52:19 +02:00
Tom Englund
0e86808e59 cursor: Better xcursor implementation (#7178)
* xcursor: bootleg xcursors into its own manager

implent XCursorManager and load themes based on librarypath and its
dir, now we catch all supplied theme files. and also implent animated
cursors. also refactor a bit of spaghetti regarding xcursors in
CursorManager.

* hyprcursor: fix buffer leak

animated cursors are creating a new buffer for each image, ensure we
drop the buffers so it continously doesnt build up in infinity.

* cursormgr: use eventloopmgr for animation

use EvenloopManager for timers instead of adding it directly to
m_sWLEventLoop and using its related wl_* functions.
2024-08-05 19:58:21 +02:00
MightyPlaza
2b520571e8 keybinds: improve fullscreenstate toggling (#7174)
modified:   src/managers/KeybindManager.cpp
2024-08-04 21:40:34 +02:00
Mihai Fufezan
5dd2c27b63 CMake, Meson: install config and wallpapers to DATADIR/hypr
OpenGL: get wallpapers dir from DATAROOTDIR
2024-08-04 15:19:37 +03:00
MaroonSkull
4ae89e1f22 CMake: Suppress CMake warning about GNUInstallDirs 2024-08-04 12:10:50 +03:00
MightyPlaza
51ffd7fa6f decorations: fix infinite recursion on no_gaps when only (#7169)
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/MasterLayout.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
2024-08-03 19:50:08 +02:00
Vaxry
ae50f8614d wayland/surface: fixup self-owning surface roles
fixes #7133
2024-08-03 17:58:06 +02:00
Jan Beich
9f5a57ff45 core: Add missing header for libc++ after e989a0bcff (#7158)
src/Compositor.cpp:2295:74: error: no member named 'bit_floor' in namespace 'std'
 2295 |     const eFullscreenMode CURRENT_EFFECTIVE_MODE = (eFullscreenMode)std::bit_floor((uint8_t)PWINDOW->m_sFullscreenState.internal);
      |                                                                     ~~~~~^
src/Compositor.cpp:2296:74: error: no member named 'bit_floor' in namespace 'std'
 2296 |     const eFullscreenMode EFFECTIVE_MODE         = (eFullscreenMode)std::bit_floor((uint8_t)state.internal);
      |                                                                     ~~~~~^
src/desktop/Window.cpp:1242:34: error: no member named 'bit_floor' in namespace 'std'
 1242 |     return (eFullscreenMode)std::bit_floor((uint8_t)m_sFullscreenState.internal) == MODE;
      |                             ~~~~~^
2024-08-03 13:02:10 +01:00
Tom Englund
4141e67550 xcursor: rework bootleg xcursor (#7140)
there were a bunch of missing cursors, rework the shape loading add a
function to get legacyname from new wayland names. also bootleg add a
cursor if no theme can be found and no shape. to atleast show
something.
2024-08-02 23:16:20 +02:00
Tuur Vanhoutte
be2dfa36ef hyprctl: increase hyprctl timeout to 5s to fix #6801 (#7152) 2024-08-02 21:49:47 +02:00
Vaxry
1fa4b7d79b hyprerror: minor stylistic changes 2024-08-02 18:42:10 +02:00
Maximilian Seidler
592b4a709c sessionLock: don't sendLocked when session lock has already been destoyed (#7150)
* sessionLock: reset m_pSessionLock on destroy

* sessionLock: only send locked when resource is good
2024-08-02 15:25:51 +02:00
Vaxry
09bb5658b7 window/ls: reset core signals after destroy
fixes #7137
2024-08-02 00:31:44 +02:00
Vaxry
ab0a3268e0 xdg-shell: fixup unassigned wl surfaces to xdg surfaces
fixes #7133
2024-08-01 15:43:19 +02:00
MightyPlaza
c8873b958d internal: fix fullscreen typos (#7134)
modified:   src/events/Windows.cpp
modified:   src/layout/DwindleLayout.cpp
2024-08-01 14:59:52 +02:00
Vaxry
60571cd5cc border: fixup infinite recursion
ref #7127
2024-08-01 12:36:15 +02:00
Vaxry
5edfa627b4 layershell: don't throw misaligned error on exclusive edge 0
ref #7108
2024-08-01 11:46:04 +02:00
MightyPlaza
95959789b7 keybinds: allow toggling fullscreenstate (#7128)
modified:   src/managers/KeybindManager.cpp
2024-08-01 11:43:32 +02:00
Sungyoon Cho
8c02b3c267 layout: fix dynamic rules not updating after setting fullscreen (#7129) 2024-08-01 11:43:02 +02:00
Tom Englund
5b7057c479 pointer: fix buffer crash (#7131)
current buffer->buffer can turn out to be null actually check for its
existence or use the lastbuffer when calling updateCursorShm()
2024-08-01 11:42:22 +02:00
Vaxry
37e1411e8d core/surface/buffer: Buffer lock/release fixes (#7110) 2024-07-31 21:47:26 +02:00
Tom Englund
5489682799 internal: some minor fd/socket cleanups and make logging thread safe (#7123)
* bezier: dont loop on float values

Using a floating-point loop variable with a fixed increment can cause precision
errors over time due to the nature of floating-point arithmetic.
and cause undesired effects.

ex
iteration 1 = 0.10000000149011611938
iteration 2 = 0.20000000298023223877

eventually..

iteration 8 = 0.80000001192092895508
iteration 9 = 0.89999997615814208984

* hyprctl: close sockets on destruction

store socketpath and close the fd and unlink the socket path on exit.

* eventloopmgr: close the timerfd

close the timerfd on exit.

* debug: make logging thread safe

instead of opening and closing the logfile on each write open it on init
and close it on compositor exit. also add a mutex so accidently using
logging from a thread like the watchdog or similiar doesnt cause issues.

* xwl: clean up fd logic

check if the fd is actually opened before closing, and close the
pipesource FD on exit.
2024-07-31 21:00:14 +02:00
MightyPlaza
e989a0bcff internal: refactor fullscreen states (#7104)
* refactor fullscreen
modified:   src/Compositor.cpp
modified:   src/Compositor.hpp
modified:   src/config/ConfigManager.cpp
modified:   src/config/ConfigManager.hpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/LayerSurface.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/desktop/Workspace.cpp
modified:   src/desktop/Workspace.hpp
modified:   src/events/Windows.cpp
modified:   src/helpers/Monitor.cpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/DwindleLayout.hpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/IHyprLayout.hpp
modified:   src/layout/MasterLayout.cpp
modified:   src/layout/MasterLayout.hpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/KeybindManager.hpp
modified:   src/managers/input/IdleInhibitor.cpp
modified:   src/managers/input/InputManager.cpp
modified:   src/managers/input/Swipe.cpp
modified:   src/protocols/ForeignToplevelWlr.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp

* clean up
modified:   src/config/ConfigManager.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.hpp
modified:   src/desktop/Workspace.cpp
modified:   src/events/Windows.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/input/Swipe.cpp

* fix mapWindow fullscreen
modified:   src/events/Windows.cpp

* fix typo
modified:   src/desktop/Workspace.cpp

* add fullscreenstate
modified:   src/config/ConfigManager.cpp
modified:   src/events/Windows.cpp

* change syncFullscreen to lower
modified:   src/config/ConfigManager.hpp

* initialize fs state
modified:   src/desktop/Window.hpp
2024-07-31 19:55:52 +02:00
André Silva
8a5f9bbb39 keybinds: handle null monitor in pinActive (#7122) 2024-07-31 17:54:07 +02:00
Ikalco
3b9b5346b8 protocols: Move globalshortcuts impl (#7102)
* move global shortcuts to hyprwayland-scanner

* remove wayland-scanner from deps

* fix the thing
2024-07-30 23:33:56 +02:00
Mihai Fufezan
8ec3dc4c09 CI: update actions
flake.lock: update aquamarine and xdph
2024-07-30 22:13:48 +03:00
Vaxry
cc7c117fe7 output: minor tearing fixes 2024-07-30 15:50:14 +02:00
Vaxry
1c221240d0 output: submit damage to kms 2024-07-30 15:46:41 +02:00
vaxerski
c1afc82a4c [gha] Nix: update inputs 2024-07-30 13:34:22 +00:00
Vaxry
f3a9f9ec45 pointer: use preMonitorCommit for resetting render state
in DS preRender is not called
2024-07-30 15:32:42 +02:00
jim3692
10e631053a compositor: fix log typos (#7111) 2024-07-30 13:50:13 +02:00
Vaxry
46c6efeab3 hyprpm: execute all git commands regardless of fails 2024-07-30 12:11:38 +02:00
Vaxry
68ee4dda5e hyprpm: warn about uncheckoutable commits 2024-07-30 12:05:23 +02:00
Vaxry
743e98f0c0 hyprpm: add short error code explanations 2024-07-30 11:54:28 +02:00
Vaxry
e673220340 core/surface: fixup a few pointer handling edge cases 2024-07-29 19:29:08 +02:00
Tom Englund
9c38b0fdbe core: add a destructor to CHyprOpenglImpl and avoid wl_container_of undefined behaviour (#7101)
* protocols: avoid undefined behaviour in C macro

to safely use wl_container_of with a class the class has to be no
virtual functions, no inheritance, and uniform access control (e.g all
public)

work around this by putting this into a destroywrapper struct.

* opengl: clean memory on destruction

add a destructor and free the allocated memory and close the fd
2024-07-29 19:29:08 +02:00
Ikalco
60b663e276 protocols: move text-input-v1 to hyprwayland-scanner (#7096)
* move text-input-v1 to hyprwayland-scanner

* vro
2024-07-29 18:14:19 +02:00
Vaxry
01560c9d7c virtualptr: map to entire screen if no output is provided
fixes #6749
2024-07-29 18:13:23 +02:00
atikiNBTW
3a1afb53fd pluginapi: Add force reload of config at the end of plugin initialization (#7099)
* Add force reload of config at the end of plugin load

* Remove unnecessary include
2024-07-29 16:56:50 +02:00
Vaxry
23a8f06594 virtualptr: allow binding to output 2024-07-29 16:27:09 +02:00
Vaxry
70468857da egl: attempt a 3.2 egl context first 2024-07-29 14:27:05 +02:00
Vaxry
87699575e1 egl: require gles 3.0 only
No clue what could break, hopefully nothing

ref #6973
2024-07-29 14:23:19 +02:00
outfoxxed
33e513d489 xdg-shell: fix xdg-positioner y-flip (#7094) 2024-07-29 09:48:27 +01:00
Virt
6e6c61b9e8 layer-shell: avoid crashes on unmap (#7092) 2024-07-29 09:47:25 +01:00
vaxerski
a9d87bd666 surface: emit unmap before unmapping and releasing the buffers 2024-07-28 23:56:35 +02:00
vaxerski
7df9b01d48 core: emit unmap event after unmap in surface destroy 2024-07-28 23:47:17 +02:00
vaxerski
256db08aed layersurface: null check for surface validity before unmap() 2024-07-28 23:41:41 +02:00
vaxerski
73d09953e8 core/surface: drop map/unmap events in member funcs
causes loops
2024-07-28 23:41:41 +02:00
Mihai Fufezan
fcff2dcac2 flake.lock: update xdph 2024-07-28 18:42:05 +03:00
Mihai Fufezan
3cc2028def hyprpm: checkout commit instead of branch
Fixes #6948
2024-07-28 14:03:46 +03:00
Sungyoon Cho
9b6ae4f77b input: fix keyboard leds with multiple keyboards (#7079) 2024-07-28 11:46:38 +01:00
outfoxxed
bc86afea7e xdg-shell: completely rewrite xdg-positioner (#7067)
This implementation actually works.
2024-07-27 21:43:01 +01:00
vaxerski
6edfdd63a1 surface: avoid crashes on fading out layers 2024-07-27 22:15:36 +02:00
Mihai Fufezan
04b40ea2ec CI: only run once for PRs with branches from original repo (#7075) 2024-07-27 22:17:05 +03:00
Mihai Fufezan
55ceca4cdd flake.lock: update aquamarine 2024-07-27 20:32:11 +03:00
Mihai Fufezan
10e8af00d6 flake.lock: update hyprutils 2024-07-27 19:51:43 +03:00
MightyPlaza
ad711ef421 input: unify removing currentlyDraggedWindow (#7071)
modified:   src/desktop/Window.cpp
modified:   src/events/Windows.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/KeybindManager.hpp
modified:   src/managers/input/InputManager.cpp
2024-07-27 17:46:19 +01:00
vaxerski
ae638d997d configmgr: fix warning 2024-07-27 18:15:47 +02:00
vaxerski
141cd09bd3 renderer: use session lock alpha for rendering lacking locks 2024-07-27 18:13:41 +02:00
vaxerski
0243271544 layer-shell: properly map and unmap surface and propagate unmap events 2024-07-27 18:08:22 +02:00
vaxerski
729b47d46d input: refocus last window on keyboard unfocusable surfaces
fixes #4460
2024-07-27 17:49:35 +02:00
MahouShoujoMivutilde
84227eb587 input: Fix hyprctl switchxkblayout not actually changing layout (#7070)
Emits `SModifiersEvent` in `updateModifiers()`

Before the patch:

Changing layout with `hyprctl switchxkblayout ...` results in:
    * active keymap in `hyprctl devices` is changed
    * no event
    * no layout is actually changed UNTIL you press one of the mod keys
      (Alt | Shift | Super | Ctrl)

After:
    * active keymap in `hyprctl devices` changed
    * activelayout IPC event emitted
    * layout is changed

This fixes https://github.com/hyprwm/Hyprland/issues/7044
2024-07-27 16:43:45 +01:00
vaxerski
daed75219f wayland/compositor: fixup double buffer releases
fixes #7043
2024-07-27 17:04:03 +02:00
Ikalco
ec672b1ab9 protocols: move screencopy and toplevel export to hyprwayland-scanner (#7065)
* move screencopy and toplevel export to hyprwayland-scanner

* oops
2024-07-27 16:02:02 +01:00
vaxerski
963816b9a6 layersurface: fixup focus issues in onUnmap
fixes #6929
2024-07-27 15:04:03 +02:00
Mihai Fufezan
534fdb5a37 flake.lock: update 2024-07-27 15:57:52 +03:00
vaxerski
682865632f xwayland: fix high cpu idle usage
fixes #7051
2024-07-27 13:58:30 +02:00
vaxerski
76610d9fb0 opengl: destroy cairo image surface after use 2024-07-27 13:03:43 +02:00
vaxerski
57371b93a0 renderer: drastically optimize bg texture creation
stop loading 20MB images every time, dumbass
2024-07-26 19:53:24 +02:00
Vaxry
33a5c8ce32 config: avoid using initial ws tracking for exec-once 2024-07-25 15:29:39 +02:00
Vaxry
a0d15a0b7b wayland/compositor: release buffers on unmap
XWayland does not use the regular commit(null) method to unmap, which results in buffers never being released.

release the buffers if present and un-released in the unmap() handler

ref #6584
2024-07-25 14:12:08 +02:00
Vaxry
cd942ad12d keyboard: update xkb state after key event
fixes #6946
2024-07-25 13:10:53 +02:00
Vaxry
daf5fad190 keyboard: properly update keymap state and fd on keymap changes
needed for virtual keyboards that impose their own layouts.

fixes #6991
2024-07-25 13:02:10 +02:00
MightyPlaza
4beac91cbd keybinds: add safeguard to mousebinds (#7034)
modified:   src/managers/KeybindManager.cpp
2024-07-25 00:19:15 +02:00
Anton Lazarev
391f1ae838 input: don't simulate mouse movement on focus change in follow_mouse = 2/3 if no_warps is false (#7015) 2024-07-25 00:16:47 +02:00
Mihai Fufezan
381cb2d833 flake.lock: update aquamarine 2024-07-24 23:51:23 +03:00
MightyPlaza
a0be3de0e8 keybinds: handle monitor change in moveWindowIntoGroup (#7030)
modified:   src/managers/KeybindManager.cpp
2024-07-24 20:00:25 +02:00
Ikalco
3e543d2ce8 core: Properly shutdown wl display (#7018)
* correctly destroy wayland globals

* properly shutdown and cleanup hyprland

* appease the nitpick gods and some comments
2024-07-24 19:07:36 +02:00
MightyPlaza
735e3c6c56 crashreporter: add date and flags to crash report (#7028)
modified:   src/debug/CrashReporter.cpp
2024-07-24 19:05:54 +02:00
Vaxry
b16fb9770c egl: support getting the device via platform_device
a neat EXT
2024-07-24 18:53:51 +02:00
MightyPlaza
f2b6ebbf54 keybinds: remove toggleopaque (#7024)
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/KeybindManager.hpp
2024-07-24 18:53:51 +02:00
Vaxry
fe19754887 shortcutsInhibit: fix crash 2024-07-24 16:26:44 +02:00
MightyPlaza
72bce7efd5 keybinds: add bindp and noshortcutsinhibit (#7017) 2024-07-24 14:10:36 +02:00
Vaxry
99088eaed8 compositor: simplify getWindowFromSurface 2024-07-24 11:07:28 +02:00
Leon
2da3cfb422 touch: fix touch swipe invert config (#7014) 2024-07-24 10:59:50 +02:00
Leon
e2efecc24e flake: update aquamarine 2024-07-24 01:42:15 +03:00
Vaxry
8a4548e430 window: drop ack requirement for applying pending reported size
fixes #6533
2024-07-23 23:38:58 +02:00
Ikalco
a5f58a3126 layer-shell: validate exclusiveEdge and don't set it as top by default (#7006)
* validate exclusiveEdge and don't set it as top by default

* make sure exclusive edge anchor is within bounds
2024-07-23 20:03:15 +02:00
Vaxry
077494ee85 surface: fix zero_scaling xwayland damage 2024-07-23 19:56:47 +02:00
Mihai Fufezan
752604cfe9 Nix: remove meson (used by wlroots) 2024-07-23 20:40:33 +03:00
Sam Lakerveld
3c758db95c renderer/layer-shell: use explicitly set exclusiveEdge (#6984) 2024-07-22 23:36:58 +02:00
Vaxry
7c68236a51 egl: avoid setting debug mode and handle legacyrenderer
ref #6973
2024-07-22 23:05:22 +02:00
Vaxry
4c3b035162 pointer/hw: rollback the swapchain on multiple renders without a commit
fixes the hack
2024-07-22 19:19:37 +02:00
Vaxry
f17f8b219c pointer/hw: extend cursor swapchain to 3
otherwise on some commits we draw twice and we draw over the front buffer
2024-07-22 19:05:45 +02:00
Ikalco
e8374e0792 debug: get rid of useless 1s in logs (#6969)
* get rid of 1s in logs lol

* replace WLR with AQ in logs
2024-07-22 18:06:11 +02:00
Vaxry
77b134e23b virtual-pointer: fixup virtual pointer warp events
fixes #6976
2024-07-22 17:24:30 +02:00
Vaxry
87db950189 wl_seat: avoid sending events to objects without caps
ref #6835
2024-07-22 16:57:35 +02:00
Vaxry
5bae7f150b wayland/output: avoid sending events to dead outputs
ref #6835
2024-07-22 16:56:51 +02:00
diniamo
83a5395eaa flake: update xdph 2024-07-22 14:47:06 +03:00
diniamo
d03fa94c2c core: avoid locking 2 wayland sockets (#6971)
* fix: avoid locking 2 wayland sockets

* format

* fix formatting
2024-07-22 13:16:25 +02:00
UjinT34
511e9ccdd1 xwm: Fix xwayland black window bug after losing focus (#6966)
* fix xwayland black window bug

* resend normal state
2024-07-22 13:15:40 +02:00
Vaxry
3132f0275e touch: set lastInputTouch on every event 2024-07-22 13:05:06 +02:00
Vaxry
1797319a07 renderer: untransform textures matching display transform
fixes #6754

This will break if the client uses a transform that is not equal to the display, reverting to old behavior. Combining transforms is left as a todo for the future.
2024-07-22 13:01:55 +02:00
Vaxry
5979ceb56b surface: fixup logical damage size calculations
fixes #6618
2024-07-22 12:38:05 +02:00
Vaxry
672bf1f867 compositor: ignore setting surface scanout if DS is disabled 2024-07-21 23:52:16 +02:00
Vaxry
33e933e2a0 renderer: drop redundant spammy trace log 2024-07-21 22:09:29 +02:00
Vaxry
341fb4497f wayland/compositor: fixup buffer damage tracking for wl_shm buffers
remove qt hack, fixup conditions

fixes #6844
2024-07-21 22:05:53 +02:00
Vaxry
cbaac6deaf xwm: drop invalid case for clearing X focus
fixes #6955
2024-07-21 20:02:48 +02:00
Vaxry
3b6bcd6ddc presentation-feedback: fix invalid values sent after aq merge 2024-07-21 19:25:07 +02:00
Mihai Fufezan
e6fc9873b5 flake.lock: update 2024-07-21 19:31:36 +03:00
Mihai Fufezan
db1f5cd137 CMake: fmt 2024-07-21 19:25:42 +03:00
Mihai Fufezan
928d1dd38a CMake, Meson, Nix: replace props.json with VERSION 2024-07-21 19:24:17 +03:00
Mihai Fufezan
faa157e162 gitignore: add CMake residual files 2024-07-21 19:24:17 +03:00
Vaxry
7f624d2236 xwayland: fixup WM_SIZE_HINTS handling according to ICCCM 2024-07-21 17:41:26 +02:00
Vaxry
f7fb7e7e49 xwayland: avoid unfocusing on OR child focuses
fixes #6698
2024-07-21 17:27:36 +02:00
Vaxry
efcbcd7297 input: fix invalid usage of dev in setTouchDeviceConfigs
ref #6943
2024-07-21 16:45:46 +02:00
Vaxry
043b859ea2 hyprpm: init submodules after resets
ref #6948
2024-07-21 16:42:49 +02:00
khachbe
cf373d315e touch: add touch swipe invert config (#6940) 2024-07-21 13:59:09 +02:00
Vaxry
016da234d0 Core: Move to aquamarine (#6608)
Moves Hyprland from wlroots to aquamarine for the backend.

---------

Signed-off-by: Vaxry <vaxry@vaxry.net>
Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
Co-authored-by: vaxerski <vaxerski@users.noreply.github.com>
Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com>
Co-authored-by: Tom Englund <tomenglund26@gmail.com>
Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com>
Co-authored-by: diniamo <diniamo53@gmail.com>
2024-07-21 13:09:54 +02:00
phonetic112
f642fb97df core: Fix crash on opening chromium (#6932) 2024-07-20 10:11:32 +02:00
vaxerski
9b0993cc49 [gha] build man pages 2024-07-19 22:37:42 +00:00
Ferdinand Bachmann
efccf25fcc compositor: implement wayland socket handover (#6930)
* compositor: implement wayland socket handover

This commit implements the compositor side of the Wayland socket
handover protocol as described in the [KDE Wiki]. The CLI options are
chosen so that they are compatible with Kwin.

[KDE Wiki]: https://invent.kde.org/plasma/kwin/-/wikis/Restarting

* main: verify that --wayland-fd is a valid file descriptor

* main: fail if only one of --socket and --wayland-fd is passed
2024-07-20 00:37:20 +02:00
Agent00Ming
8e15f91c24 input: Emulate discrete scrolling from v120 events (#6881)
* seat: avoid sending axis_stop() when source is wheel

 * fix rounding for absolute discrete values greater than 1

Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-07-18 21:57:08 +02:00
VESSE Léo
300228b503 flake: add clang-tools to devShell (#6916) 2024-07-17 23:30:02 +03:00
Party Wumpus
293e687389 renderer: Make shader time always count from zero (#6903)
* testing out an initialtime variable

* Make time universally start at zero instead of exposing an initial time

* Appease the CI
2024-07-16 22:03:10 +02:00
Mihai Fufezan
da956c8a97 config: use hyprutils helper (#6891)
* flake.lock: update

nix/overlays: remove xwayland overlay (merged upstream)

* config: use hyprutils helper

* flake.lock: update

* CMake & Meson: update required versions
2024-07-16 21:23:37 +02:00
Khiet Tam Nguyen
bd526822de config: add option to exit window while retaining fullscreen (#516) (#6880)
* feat: saving fullscreen mode and state for restoring later

* style: no p-prefix, capitalised constants
2024-07-15 13:48:04 +02:00
MightyPlaza
f442f435d3 layout: update workspace rules on layout change (#6878)
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/MasterLayout.cpp
2024-07-15 11:57:52 +02:00
Khiet Tam Nguyen
bc6b0880dd window: override noMaximize if new window takes over fullscreen (#6812) (#6870) 2024-07-13 20:44:32 +02:00
MightyPlaza
ed6c701144 renderer: partially revert previous xray fix (#6868)
modified:   src/render/OpenGL.cpp
2024-07-13 20:29:07 +02:00
Tim Waterhouse
45c4898423 socket2: Add windowtitlev2 event which includes the window address (#6856)
Fixes #5393
2024-07-13 16:21:32 +02:00
David De Sousa
a770a88e09 toplevelexport: fix flipped r/b channels when sharing windows (#6861)
fixes #6823
2024-07-13 12:53:53 +02:00
Tim Waterhouse
1f64668953 ext-foreign-toplevel: Send done after title and class (#6857)
According to the spec (https://wayland.app/protocols/ext-foreign-toplevel-list-v1#ext_foreign_toplevel_handle_v1:event:title), clients should wait for the done signal before applying updates
2024-07-13 12:53:23 +02:00
Vaxry
13bc7e1e14 style: fix clang-format 2024-07-13 12:36:35 +02:00
Junxuan Liao
7486576fa7 session-lock: send locked after the lock screen is properly rendered (#6850)
The protocol says:
> The locked event "must not be sent until a new "locked" frame (either from a
> session lock surface or the compositor blanking the output) has been presented
> on all outputs and no security sensitive normal/unlocked content is possibly
> visible".

This helps users ensure the screen is properly locked before suspending
the machine. (e.g. with swaylock --ready-fd)
2024-07-13 12:32:08 +02:00
MightyPlaza
f85c6416c6 renderer: fix a few xray regressions (#6855)
* fix xray unset
modified:   src/render/OpenGL.cpp

* fix xwray unset
modified:   src/render/OpenGL.cpp
2024-07-12 23:05:19 +02:00
Virt
e728e56cbc meson: install wayland.hpp header 2024-07-11 23:58:23 +03:00
Maximilian Seidler
9ff83f4aa9 sessionLock: fix the check for locking a locked session (#6843) 2024-07-11 16:40:43 +02:00
vaxerski
3247d18a7c [gha] Nix: update inputs 2024-07-11 14:12:19 +00:00
MightyPlaza
a443902abc core: Improve handling of window properties (#6776)
* add mWindowProperties

modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp

* support int values
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp

* create m_sWindowData

modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/MasterLayout.cpp
modified:   src/managers/AnimationManager.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/XWaylandManager.cpp
modified:   src/render/OpenGL.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp

* simplify some properties
modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/managers/KeybindManager.cpp

* store multiple values in CWindowOverridableVar
modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/managers/AnimationManager.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/XWaylandManager.cpp
modified:   src/render/OpenGL.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp

* clean up
modified:   src/Compositor.cpp
modified:   src/Compositor.hpp
modified:   src/config/ConfigManager.cpp
modified:   src/config/ConfigManager.hpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/IHyprLayout.hpp
modified:   src/layout/MasterLayout.cpp
modified:   src/managers/KeybindManager.cpp

* use SET_PROP priority for exec rules
modified:   src/config/ConfigManager.hpp
modified:   src/desktop/Window.cpp

* add default value
modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/XWaylandManager.cpp
modified:   src/render/OpenGL.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp

* add setprop toggle
modified:   src/config/ConfigManager.hpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp

* add setprop toggle
modified:   src/debug/HyprCtl.cpp

* make window rules functional
modified:   src/config/ConfigManager.cpp
modified:   src/desktop/Window.cpp

* minor fixes
modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.hpp

* properly clean layout data
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/layout/IHyprLayout.hpp
modified:   src/layout/MasterLayout.cpp

* remove newline
modified:   src/events/Windows.cpp

* fixes
modified:   src/config/ConfigManager.hpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp

* use CamelCase
modified:   src/Compositor.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/desktop/Window.cpp
modified:   src/desktop/Window.hpp
modified:   src/events/Windows.cpp
modified:   src/layout/IHyprLayout.cpp
modified:   src/managers/AnimationManager.cpp
modified:   src/managers/KeybindManager.cpp
modified:   src/managers/XWaylandManager.cpp
modified:   src/render/OpenGL.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
2024-07-11 16:10:42 +02:00
Ikalco
b03f41efec xwayland: fix setting title prop (#6809)
* fix setting xwayland title prop

* add window title types
2024-07-08 17:46:42 +02:00
André Silva
648f824b9e flake.lock: update 2024-07-08 18:24:54 +03:00
Virt
22138ac259 workspaces: don't try to reopen special workspaces (#6802) 2024-07-07 21:27:18 +02:00
Yusuf
19fb13e6cf internal: Add functions to hyprctl header (#6745)
* add functions to hyprctl header

* refactor monitor json into own function and add it to header

* format hyprctl.hpp

* move functions to namespace

* move helper functions to class
2024-07-07 17:52:56 +02:00
Maximilian Seidler
ede1e63f69 config: don't crash when getenv HOME returns null 2024-07-07 16:59:03 +03:00
Vaxry
cc98594c3a pointer: update geometry after unplug events
fixes #6700

fixes #6740
2024-07-05 23:05:09 +02:00
MightyPlaza
0502c3f62b keybinds: fix movewindow float to 0 (#6777)
modified:   src/managers/KeybindManager.cpp
2024-07-05 22:46:38 +02:00
Lincoln Yuji de Oliveira
0a6e83005f Completions: use only awk (#6763) 2024-07-04 14:21:07 +03:00
Agent00Ming
e894d5e964 tablet: Send .frame() on .proximity_out() (#6761)
Co-authored-by: Agent_00Ming <agent00ming9366@gmail.com>
2024-07-03 21:40:18 +02:00
Lincoln Yuji
8bb75a223d hyprctl completions: Use only awk rather than grep + awk
Using "awk '/<exp>/{ print $n }'" is more minimal and slightly faster
than using "grep '<exp>' | awk '{ print $n }'".

Signed-off-by: Lincoln Yuji <lincolnyuji@hotmail.com>
2024-07-02 22:46:20 +03:00
Vaxry
6247a6b537 renderer: don't skip back background on preBlurQueued
fixes #6332
2024-07-02 18:40:27 +02:00
drendog
2fa57f2dc4 pointer: change min cursor padding to 0 (#6027)
* fix: change min cursor padding to 0

* chore: set default hotspot padding to 0

* fix: adjusting clamp after getting closest point to fix getting off limit point

* fix: deal with floating point to clamp to prev value

* refactor: max coords to vector

* fix: remove box closestPoint adjustment due its fix on hyprutils
2024-07-02 12:17:48 +02:00
Ikalco
e58fd3bfb0 meson: fix wlroots-hyprland dep checks (for libliftoff patch to work) (#6736) 2024-07-02 12:14:27 +02:00
Tom Englund
d7ea1b7785 xwayland: break cyclic loop of parents (#6722)
in X11 some surfaces is a parent of itself and creates a cyclic loop
when trying to find its parent. check for old parent and break if its
beginning to roll over.
2024-07-01 00:26:08 +02:00
UjinT34
4d6f96f74f debug: add Nvidia driver info (#6715)
* add nvidia driver info to systeminfo

* check file exists
2024-06-30 13:16:41 +02:00
Tom Englund
8ff9410d2c inputmgr: ensure we dont divide by zero (#6713)
some weird combination of scrolling/nesting hyprland and closing a
window i managed to divide by zero here, reported by ubsan. add a check
to ensure we dont hit UB.
2024-06-30 13:15:59 +02:00
はれなよ
718afe271e seat: don't send keyboard data without a keyboard cap (#6697)
* Fix #6279: prevent sending keymap or repeat info events by keyboards without keyboard capability

* Remove brackets
2024-06-29 20:05:07 +02:00
はれなよ
1f43a5c859 session: fix activate events being always treated as on (#6696)
* Fix listener_sessionActive to handle an event correctly when the session get inactivated

* Remove log
2024-06-29 20:04:48 +02:00
Vaxry
9c5dd59d4b input: fix capabilities enum types passed
hyprland down to the seat protocol impl expects IHID capabilities, not WL_ ones

ref #6702 #6196
2024-06-29 00:23:02 +02:00
Vaxry
d16c6aa1db pointer-constraint: set lifetime correctly
ref #6679
2024-06-29 00:18:24 +02:00
Tom Englund
ac11771348 core: fix a few ubsan issues reported at exit of hyprland (#6699)
* watchdog: dont detach and cause race condition

instead of detaching and causing a race condition on destruction where
the thread is alive and watchdog has been destroyed, check if its
joinable and join it on destruction.

causes heap use after free on exit of compositor.

* render: add checks for compositor shutting down

avoid member call on null pointer, if the g_pHyprRenderer is destroyed
we can call the member makeEGLCurrent on it, causes undefined behaviour
on destruction of the compositor/hyprrenderer.

found with ubsan.
2024-06-28 22:24:32 +02:00
Alexander
f2dc48d92f keybinds: never switch to another monitor with per_monitor (#6665)
Co-authored-by: Крылов Александр <aleksandr.krylov@hyperus.team>
2024-06-27 15:07:56 +02:00
outfoxxed
e4d09aa3a9 sessionLock: focus lock on creation based on mouse position (#6658)
* sessionLock: focus lock on creation based on mouse position

* sessionLock: immediately unfocus any focused surfaces on lock
2024-06-25 23:22:38 +02:00
Vaxry
c338acbb7d ime-relay: fix crash on nullptr surface focus 2024-06-25 22:46:36 +02:00
Vaxry
95782de966 renderer: don't use the surface counter in popup iterations
fixes #6663
2024-06-25 20:04:02 +02:00
Vaxry
3ba3d20ad3 pointer: round position when rendering software cursors
otherwise the image gets resampled and gets blurry
2024-06-25 18:44:54 +02:00
Vaxry
1d70962892 core: move to steady_clock where applicable
avoid issues when system clock gets desynchronized or changed
2024-06-25 16:05:47 +02:00
367 changed files with 22940 additions and 13228 deletions

101
.clang-tidy Normal file
View File

@@ -0,0 +1,101 @@
WarningsAsErrors: '*'
HeaderFilterRegex: '.*\.hpp'
FormatStyle: file
Checks: >
-*,
bugprone-*,
-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-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-unused-parameters,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
-misc-const-correctness,
modernize-*,
-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-avoid-endl,
-performance-unnecessary-value-param,
portability-std-allocator-const,
readability-*,
-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,
CheckOptions:
performance-for-range-copy.WarnOnAllAutoCopies: true
performance-inefficient-string-concatenation.StrictMode: true
readability-braces-around-statements.ShortStatementLines: 0
readability-identifier-naming.ClassCase: CamelCase
readability-identifier-naming.ClassIgnoredRegexp: I.*
readability-identifier-naming.ClassPrefix: C # We can't use regex here?!?!?!?
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumPrefix: e
readability-identifier-naming.EnumConstantCase: UPPER_CASE
readability-identifier-naming.FunctionCase: camelBack
readability-identifier-naming.NamespaceCase: CamelCase
readability-identifier-naming.NamespacePrefix: N
readability-identifier-naming.StructPrefix: S
readability-identifier-naming.StructCase: CamelCase

View File

@@ -2,12 +2,13 @@ name: Bug Report
description: Something is not working right
labels: ["bug"]
body:
- type: markdown
- type: checkboxes
attributes:
value: |
## Before opening a new issue, please take a moment to search through the current open and closed issues to check if it already exists.
---
label: Already reported ? *
description: Before opening a new bug report, please take a moment to search through the current open and closed issues to check if it already exists.
options:
- label: I have searched the existing open and closed issues.
required: true
- type: dropdown
id: type
@@ -28,10 +29,10 @@ body:
attributes:
label: System Info and Version
description: |
Paste the output of `hyprctl systeminfo -c` here (If you are on a
version that shows you help menu, omit the `-c` and attach config files
to the issue). If you have configs outside of the main config shown
here, please attach.
Paste the output of `hyprctl systeminfo -c` here. If you can't
launch Hyprland, paste the output of `Hyprland --systeminfo`.
If `Hyprland --systeminfo` errors out (added in 0.44.0), find
and paste the Hyprland version manually.
value: "<details>
<summary>System/Version info</summary>

View File

@@ -33,7 +33,10 @@ runs:
libfontenc \
libglvnd \
libinput \
libjxl \
libliftoff \
libwebp \
libxcursor \
libxcvt \
libxfont2 \
libxkbcommon \
@@ -57,7 +60,8 @@ runs:
xcb-util \
xcb-util-image \
libzip \
librsvg
librsvg \
re2
- name: Get hyprwayland-scanner-git
shell: bash
@@ -68,11 +72,21 @@ runs:
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
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 hyprutils-git
shell: bash
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
- name: Get aquamarine-git
shell: bash
run: |
git clone https://github.com/hyprwm/aquamarine && cd aquamarine && cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -B build && cmake --build build --target aquamarine && cmake --install build
- name: Get Xorg pacman pkgs
shell: bash
if: inputs.INSTALL_XORG_PKGS == 'true'

View File

@@ -1,3 +1,9 @@
<!--
BEFORE you submit your PR, please check out the PR guidelines
on our wiki: https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/
-->
#### Describe your PR, what does it fix/add?

View File

@@ -3,6 +3,7 @@ name: Build Hyprland
on: [push, pull_request, workflow_dispatch]
jobs:
gcc:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Build Hyprland (Arch)"
runs-on: ubuntu-latest
container:
@@ -38,12 +39,13 @@ jobs:
tar -cvf Hyprland.tar.xz hyprland
- name: Release
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Build archive
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:
@@ -64,6 +66,7 @@ jobs:
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:
@@ -83,6 +86,7 @@ jobs:
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:
@@ -103,6 +107,7 @@ jobs:
run: make release
clang-format:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: "Code Style (Arch)"
runs-on: ubuntu-latest
container:

View File

@@ -17,14 +17,14 @@ jobs:
run: sudo apt install pandoc
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Build man pages
run: make man
- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
name: Commit
with:
commit_message: "[gha] build man pages"

View File

@@ -1,3 +1,5 @@
name: Nix (Build)
on:
workflow_call:
secrets:
@@ -10,21 +12,18 @@ jobs:
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:
- name: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
submodules: recursive
- uses: cachix/install-nix-action@v26
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v12
- uses: cachix/cachix-action@v15
with:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- run: nix build '.?submodules=1#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"
- run: nix build 'github:hyprwm/Hyprland?ref=${{ github.ref }}#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"

View File

@@ -1,15 +1,14 @@
name: Nix
name: Nix (CI)
on: [push, pull_request, workflow_dispatch]
jobs:
update-inputs:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/nix-update-inputs.yml
secrets: inherit
build:
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
needs: update-inputs
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
uses: ./.github/workflows/nix-build.yml
secrets: inherit

View File

@@ -1,4 +1,4 @@
name: Nix
name: Nix (Update Inputs)
on:
workflow_call:
@@ -8,11 +8,12 @@ on:
jobs:
update:
if: github.repository == 'hyprwm/Hyprland'
name: inputs
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
@@ -21,6 +22,6 @@ jobs:
run: nix/update-inputs.sh
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[gha] Nix: update inputs"

View File

@@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout Hyprland
id: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
@@ -20,7 +20,6 @@ jobs:
run: |
git fetch --unshallow || echo "failed unshallowing"
bash -c scripts/generateVersion.sh
mv scripts/generateVersion.sh scripts/generateVersion.sh.bak
- name: Create tarball with submodules
id: tar

View File

@@ -4,6 +4,7 @@ on: [push, pull_request]
jobs:
flawfinder:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
name: Flawfinder Checks
runs-on: ubuntu-latest
permissions:
@@ -12,7 +13,7 @@ jobs:
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Scan with Flawfinder
uses: david-a-wheeler/flawfinder@8e4a779ad59dbfaee5da586aa9210853b701959c

View File

@@ -7,22 +7,22 @@ name: Mark stale issues and pull requests
on:
schedule:
- cron: '7 */4 * * *'
- 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@v5
with:
repo-token: ${{ secrets.STALEBOT_PAT }}
stale-issue-label: 'stale'
stale-pr-label: 'stale'
operations-per-run: 40
days-before-close: -1
- 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

12
.gitignore vendored
View File

@@ -7,14 +7,21 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
hyprland.pc
_deps
build/
result*
/.pre-commit-config.yaml
/.vscode/
/.idea/
.envrc
.cache
.direnv
/.cmake/
/.worktree/
*.o
protocols/*.c*
@@ -31,5 +38,8 @@ gmon.out
PKGBUILD
src/version.h
hyprpm/Makefile
hyprctl/Makefile
.direnv
**/.#*.*
**/#*.*#

4
.gitmodules vendored
View File

@@ -7,7 +7,3 @@
[submodule "subprojects/tracy"]
path = subprojects/tracy
url = https://github.com/wolfpld/tracy
[submodule "subprojects/wlroots-hyprland"]
path = subprojects/wlroots-hyprland
url = https://github.com/hyprwm/wlroots-hyprland
ignore = dirty

View File

@@ -1,98 +1,91 @@
cmake_minimum_required(VERSION 3.27)
include(CheckIncludeFile)
include(ExternalProject)
include(GNUInstallDirs)
cmake_minimum_required(VERSION 3.30)
# Get version
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS)
string(JSON VER GET ${PROPS} version)
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
string(STRIP ${VER_RAW} VER)
project(Hyprland
DESCRIPTION "A Modern C++ Wayland Compositor"
VERSION ${VER}
)
project(
Hyprland
DESCRIPTION "A Modern C++ Wayland Compositor"
VERSION ${VER})
include(CheckIncludeFile)
include(GNUInstallDirs)
set(HYPRLAND_VERSION ${VER})
set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(BINDIR ${CMAKE_INSTALL_BINDIR})
configure_file(hyprland.pc.in hyprland.pc @ONLY)
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
message(STATUS "Gathering git info")
# Get git info
# hash and branch
execute_process(
COMMAND ./scripts/generateVersion.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# udis
add_subdirectory("subprojects/udis86")
# wlroots
message(STATUS "Setting up wlroots")
if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILDTYPE_LOWER)
if(BUILDTYPE_LOWER STREQUAL "release")
# Pass.
elseif(BUILDTYPE_LOWER STREQUAL "debug")
# Pass.
elseif(BUILDTYPE_LOWER STREQUAL "relwithdebinfo")
set(BUILDTYPE_LOWER "debugoptimized")
elseif(BUILDTYPE_LOWER STREQUAL "minsizerel")
set(BUILDTYPE_LOWER "minsize")
elseif(BUILDTYPE_LOWER STREQUAL "none")
set(BUILDTYPE_LOWER "plain")
else()
set(BUILDTYPE_LOWER "release")
endif()
else()
set(BUILDTYPE_LOWER "release")
endif()
ExternalProject_Add(
wlroots-hyprland
PREFIX ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland
SOURCE_DIR ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland
CONFIGURE_COMMAND meson setup --reconfigure build --buildtype=${BUILDTYPE_LOWER} -Dwerror=false -Dxwayland=$<IF:$<BOOL:${NO_XWAYLAND}>,disabled,enabled> -Dexamples=false -Drenderers=gles2 -Dbackends=drm,libinput $<IF:$<BOOL:${WITH_ASAN}>,-Db_sanitize=address,-Db_sanitize=none>
BUILD_COMMAND ninja -C build
BUILD_ALWAYS true
BUILD_IN_SOURCE true
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
INSTALL_COMMAND echo "wlroots-hyprland: install not needed"
)
# Get git info hash and branch
execute_process(COMMAND ./scripts/generateVersion.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
find_package(PkgConfig REQUIRED)
pkg_get_variable(WaylandScanner wayland-scanner wayland_scanner)
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
pkg_get_variable(WAYLAND_SERVER_DIR wayland-server pkgdatadir)
# Try to find canihavesomecoffee's udis86 using pkgconfig vmd/udis86 does not
# provide a .pc file and won't be detected this way
pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG)
else()
add_compile_options(-O3)
message(STATUS "Configuring Hyprland in Release with CMake")
# Fallback to subproject
if(NOT udis_dep_FOUND)
add_subdirectory("subprojects/udis86")
include_directories("subprojects/udis86")
message(STATUS "udis86 dependency not found, falling back to subproject")
endif()
include_directories(
.
"src/"
"subprojects/wlroots-hyprland/include/"
"subprojects/wlroots-hyprland/build/include/"
"subprojects/udis86/"
"protocols/")
set(CMAKE_CXX_STANDARD 23)
add_compile_definitions(WLR_USE_UNSTABLE)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
-Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
if(CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILDTYPE_LOWER)
if(BUILDTYPE_LOWER STREQUAL "release")
# Pass.
elseif(BUILDTYPE_LOWER STREQUAL "debug")
# Pass.
elseif(BUILDTYPE_LOWER STREQUAL "relwithdebinfo")
set(BUILDTYPE_LOWER "debugoptimized")
elseif(BUILDTYPE_LOWER STREQUAL "minsizerel")
set(BUILDTYPE_LOWER "minsize")
elseif(BUILDTYPE_LOWER STREQUAL "none")
set(BUILDTYPE_LOWER "plain")
else()
set(BUILDTYPE_LOWER "release")
endif()
else()
set(BUILDTYPE_LOWER "release")
endif()
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}")
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG)
else()
add_compile_options(-O3)
message(STATUS "Configuring Hyprland in Release with CMake")
endif()
add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
include_directories(. "src/" "protocols/")
set(CMAKE_CXX_STANDARD 26)
add_compile_options(
-Wall
-Wextra
-Wno-unused-parameter
-Wno-unused-value
-Wno-missing-field-initializers
-Wno-narrowing
-Wno-pointer-arith
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
@@ -102,19 +95,42 @@ message(STATUS "Checking deps...")
find_package(Threads REQUIRED)
if(LEGACY_RENDERER)
set(GLES_VERSION "GLES2")
set(GLES_VERSION "GLES2")
else()
set(GLES_VERSION "GLES3")
set(GLES_VERSION "GLES3")
endif()
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
pkg_check_modules(deps REQUIRED IMPORTED_TARGET
xkbcommon uuid
wayland-server wayland-client wayland-cursor wayland-protocols
cairo pango pangocairo pixman-1
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
hyprlang>=0.3.2 hyprcursor>=0.1.7 hyprutils>=0.1.5
)
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=0.4.5)
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=0.3.2)
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=0.1.7)
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.2.3)
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=0.1.1)
add_compile_definitions(AQUAMARINE_VERSION="${aquamarine_dep_VERSION}")
add_compile_definitions(HYPRLANG_VERSION="${hyprlang_dep_VERSION}")
add_compile_definitions(HYPRUTILS_VERSION="${hyprutils_dep_VERSION}")
add_compile_definitions(HYPRCURSOR_VERSION="${hyprcursor_dep_VERSION}")
add_compile_definitions(HYPRGRAPHICS_VERSION="${hyprgraphics_dep_VERSION}")
pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
xkbcommon
uuid
wayland-server>=1.22.90
wayland-protocols
cairo
pango
pangocairo
pixman-1
xcursor
libdrm
libinput
gbm
gio-2.0
re2)
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
@@ -122,85 +138,103 @@ file(GLOB_RECURSE SRCFILES "src/*.cpp")
set(TRACY_CPP_FILES "")
if(USE_TRACY)
set(TRACY_CPP_FILES "subprojects/tracy/public/TracyClient.cpp")
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
set(TRACY_CPP_FILES "subprojects/tracy/public/TracyClient.cpp")
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
endif()
add_executable(Hyprland ${SRCFILES} ${TRACY_CPP_FILES})
add_dependencies(Hyprland wlroots-hyprland)
set(USE_GPROF ON)
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Setting debug flags")
message(STATUS "Setting debug flags")
if (WITH_ASAN)
message(STATUS "Enabling ASan")
if(WITH_ASAN)
message(STATUS "Enabling ASan")
target_link_libraries(Hyprland asan)
target_compile_options(Hyprland PUBLIC -fsanitize=address)
target_link_libraries(Hyprland asan)
target_compile_options(Hyprland 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()
if(USE_TRACY)
message(STATUS "Tracy is turned on")
option( TRACY_ENABLE "" ON)
option( TRACY_ON_DEMAND "" ON)
add_subdirectory (subprojects/tracy)
target_link_libraries(Hyprland Tracy::TracyClient)
if(USE_TRACY_GPU)
message(STATUS "Tracy GPU Profiling is turned on")
add_compile_definitions(USE_TRACY_GPU)
endif()
endif()
add_compile_options(-fno-pie -fno-builtin)
add_link_options(-no-pie -fno-builtin)
if(USE_GPROF)
add_compile_options(-pg)
add_link_options(-pg)
endif()
add_compile_options(-fno-pie -fno-builtin)
add_link_options(-no-pie -fno-builtin)
if(USE_GPROF)
add_compile_options(-pg)
add_link_options(-pg)
endif()
endif()
check_include_file("execinfo.h" EXECINFOH)
if(EXECINFOH)
message(STATUS "Configuration supports execinfo")
add_compile_definitions(HAS_EXECINFO)
message(STATUS "Configuration supports execinfo")
add_compile_definitions(HAS_EXECINFO)
endif()
include(CheckLibraryExists)
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
if(HAVE_LIBEXECINFO)
target_link_libraries(Hyprland execinfo)
target_link_libraries(Hyprland execinfo)
endif()
check_include_file("sys/timerfd.h" HAS_TIMERFD)
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
if(NOT HAS_TIMERFD AND epoll_FOUND)
target_link_libraries(Hyprland PkgConfig::epoll)
target_link_libraries(Hyprland PkgConfig::epoll)
endif()
if(LEGACY_RENDERER)
message(STATUS "Using the legacy GLES2 renderer!")
add_compile_definitions(LEGACY_RENDERER)
message(STATUS "Using the legacy GLES2 renderer!")
add_compile_definitions(LEGACY_RENDERER)
endif()
if(NO_XWAYLAND)
message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!")
add_compile_definitions(NO_XWAYLAND)
message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!")
add_compile_definitions(NO_XWAYLAND)
else()
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
pkg_check_modules(xdeps REQUIRED IMPORTED_TARGET xcb xwayland xcb-util xcb-render xcb-xfixes xcb-icccm xcb-composite xcb-res xcb-ewmh xcb-errors)
target_link_libraries(Hyprland PkgConfig::xdeps)
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
pkg_check_modules(
xdeps
REQUIRED
IMPORTED_TARGET
xcb
xcb-render
xcb-xfixes
xcb-icccm
xcb-composite
xcb-res
xcb-errors)
target_link_libraries(Hyprland PkgConfig::xdeps)
endif()
if(NO_SYSTEMD)
message(STATUS "SYSTEMD support is disabled...")
message(STATUS "SYSTEMD support is disabled...")
else()
message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...")
add_compile_definitions(USES_SYSTEMD)
message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...")
add_compile_definitions(USES_SYSTEMD)
# session file -uwsm
if(NO_UWSM)
message(STATUS "UWSM support is disabled...")
else()
message(STATUS "UWSM support is enabled (NO_UWSM not defined)...")
install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-uwsm.desktop
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions)
endif()
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
@@ -209,113 +243,115 @@ include(CPack)
message(STATUS "Setting precompiled headers")
target_precompile_headers(Hyprland PRIVATE $<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
target_precompile_headers(Hyprland PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
message(STATUS "Setting link libraries")
target_link_libraries(Hyprland rt PkgConfig::deps)
target_link_libraries(Hyprland rt PkgConfig::aquamarine_dep PkgConfig::hyprlang_dep PkgConfig::hyprutils_dep PkgConfig::hyprcursor_dep PkgConfig::hyprgraphics_dep PkgConfig::deps)
if(udis_dep_FOUND)
target_link_libraries(Hyprland PkgConfig::udis_dep)
else()
target_link_libraries(Hyprland libudis86)
endif()
# used by `make installheaders`, to ensure the headers are generated
add_custom_target(generate-protocol-headers)
function(protocol protoPath protoName external)
if (external)
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h
COMMAND ${WaylandScanner} server-header ${path} protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c
COMMAND ${WaylandScanner} private-code ${path} protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.c)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}-protocol.h)
endfunction()
function(protocolNew protoPath protoName external)
if (external)
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner ${path}/${protoName}.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp protocols/${protoName}.hpp)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
function(protocolnew protoPath protoName external)
if(external)
set(path ${protoPath})
else()
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner ${path}/${protoName}.xml
${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp
protocols/${protoName}.hpp)
target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
endfunction()
function(protocolWayland)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
COMMAND hyprwayland-scanner --wayland-enums ${WAYLAND_SERVER_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(generate-protocol-headers PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
COMMAND
hyprwayland-scanner --wayland-enums
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
endfunction()
target_link_libraries(Hyprland
${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
OpenGL::EGL
OpenGL::GL
Threads::Threads
libudis86
uuid
)
target_link_libraries(Hyprland OpenGL::EGL OpenGL::GL Threads::Threads)
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
protocol("subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.xml" "hyprland-global-shortcuts-v1" true)
protocol("subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml" "hyprland-toplevel-export-v1" true)
protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false)
pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.4.0)
if(hyprland_protocols_dep_FOUND)
pkg_get_variable(HYPRLAND_PROTOCOLS hyprland-protocols pkgdatadir)
message(STATUS "hyprland-protocols dependency set to ${HYPRLAND_PROTOCOLS}")
else()
set(HYPRLAND_PROTOCOLS "subprojects/hyprland-protocols")
message(STATUS "hyprland-protocols subproject set to ${HYPRLAND_PROTOCOLS}")
endif()
protocolNew("protocols" "wlr-gamma-control-unstable-v1" true)
protocolNew("protocols" "wlr-foreign-toplevel-management-unstable-v1" true)
protocolNew("protocols" "wlr-output-power-management-unstable-v1" true)
protocolNew("protocols" "virtual-keyboard-unstable-v1" true)
protocolNew("protocols" "wlr-virtual-pointer-unstable-v1" true)
protocolNew("protocols" "input-method-unstable-v2" true)
protocolNew("protocols" "wlr-output-management-unstable-v1" true)
protocolNew("protocols" "kde-server-decoration" true)
protocolNew("protocols" "wlr-data-control-unstable-v1" true)
protocolNew("subprojects/hyprland-protocols/protocols" "hyprland-focus-grab-v1" true)
protocolNew("protocols" "wlr-layer-shell-unstable-v1" true)
protocolNew("protocols" "wayland-drm" true)
protocolNew("staging/tearing-control" "tearing-control-v1" false)
protocolNew("staging/fractional-scale" "fractional-scale-v1" false)
protocolNew("unstable/xdg-output" "xdg-output-unstable-v1" false)
protocolNew("staging/cursor-shape" "cursor-shape-v1" false)
protocolNew("unstable/idle-inhibit" "idle-inhibit-unstable-v1" false)
protocolNew("unstable/relative-pointer" "relative-pointer-unstable-v1" false)
protocolNew("unstable/xdg-decoration" "xdg-decoration-unstable-v1" false)
protocolNew("staging/alpha-modifier" "alpha-modifier-v1" false)
protocolNew("staging/ext-foreign-toplevel-list" "ext-foreign-toplevel-list-v1" false)
protocolNew("unstable/pointer-gestures" "pointer-gestures-unstable-v1" false)
protocolNew("unstable/keyboard-shortcuts-inhibit" "keyboard-shortcuts-inhibit-unstable-v1" false)
protocolNew("unstable/text-input" "text-input-unstable-v3" false)
protocolNew("unstable/pointer-constraints" "pointer-constraints-unstable-v1" false)
protocolNew("staging/xdg-activation" "xdg-activation-v1" false)
protocolNew("staging/ext-idle-notify" "ext-idle-notify-v1" false)
protocolNew("staging/ext-session-lock" "ext-session-lock-v1" false)
protocolNew("stable/tablet" "tablet-v2" false)
protocolNew("stable/presentation-time" "presentation-time" false)
protocolNew("stable/xdg-shell" "xdg-shell" false)
protocolNew("unstable/primary-selection" "primary-selection-unstable-v1" false)
protocolNew("staging/xwayland-shell" "xwayland-shell-v1" false)
protocolNew("stable/viewporter" "viewporter" false)
protocolNew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-global-shortcuts-v1"
true)
protocolnew("unstable/text-input" "text-input-unstable-v1" false)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-toplevel-export-v1"
true)
protocolnew("protocols" "wlr-screencopy-unstable-v1" true)
protocolnew("protocols" "wlr-gamma-control-unstable-v1" true)
protocolnew("protocols" "wlr-foreign-toplevel-management-unstable-v1" true)
protocolnew("protocols" "wlr-output-power-management-unstable-v1" true)
protocolnew("protocols" "virtual-keyboard-unstable-v1" true)
protocolnew("protocols" "wlr-virtual-pointer-unstable-v1" true)
protocolnew("protocols" "input-method-unstable-v2" true)
protocolnew("protocols" "wlr-output-management-unstable-v1" true)
protocolnew("protocols" "kde-server-decoration" true)
protocolnew("protocols" "wlr-data-control-unstable-v1" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-focus-grab-v1" true)
protocolnew("protocols" "wlr-layer-shell-unstable-v1" true)
protocolnew("protocols" "wayland-drm" true)
protocolnew("${HYPRLAND_PROTOCOLS}/protocols" "hyprland-ctm-control-v1" true)
protocolWayland()
protocolnew("staging/tearing-control" "tearing-control-v1" false)
protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
protocolnew("unstable/xdg-output" "xdg-output-unstable-v1" false)
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
protocolnew("unstable/idle-inhibit" "idle-inhibit-unstable-v1" false)
protocolnew("unstable/relative-pointer" "relative-pointer-unstable-v1" false)
protocolnew("unstable/xdg-decoration" "xdg-decoration-unstable-v1" false)
protocolnew("staging/alpha-modifier" "alpha-modifier-v1" false)
protocolnew("staging/ext-foreign-toplevel-list" "ext-foreign-toplevel-list-v1"
false)
protocolnew("unstable/pointer-gestures" "pointer-gestures-unstable-v1" false)
protocolnew("unstable/keyboard-shortcuts-inhibit"
"keyboard-shortcuts-inhibit-unstable-v1" false)
protocolnew("unstable/text-input" "text-input-unstable-v3" false)
protocolnew("unstable/pointer-constraints" "pointer-constraints-unstable-v1"
false)
protocolnew("staging/xdg-activation" "xdg-activation-v1" false)
protocolnew("staging/ext-idle-notify" "ext-idle-notify-v1" false)
protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false)
protocolnew("stable/tablet" "tablet-v2" false)
protocolnew("stable/presentation-time" "presentation-time" false)
protocolnew("stable/xdg-shell" "xdg-shell" false)
protocolnew("unstable/primary-selection" "primary-selection-unstable-v1" false)
protocolnew("staging/xwayland-shell" "xwayland-shell-v1" false)
protocolnew("stable/viewporter" "viewporter" false)
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
protocolnew("staging/drm-lease" "drm-lease-v1" false)
protocolnew("staging/linux-drm-syncobj" "linux-drm-syncobj-v1" false)
protocolnew("staging/xdg-dialog" "xdg-dialog-v1" false)
protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false)
protocolnew("staging/security-context" "security-context-v1" false)
protocolwayland()
# tools
add_subdirectory(hyprctl)
@@ -324,60 +360,54 @@ add_subdirectory(hyprpm)
# binary and symlink
install(TARGETS Hyprland)
install(CODE "execute_process( \
install(
CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_BINDIR}/Hyprland \
${CMAKE_INSTALL_BINDIR}/hyprland
)"
)
${CMAKE_INSTALL_FULL_BINDIR}/Hyprland \
\"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/hyprland\" \
)")
# session file
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/wayland-sessions)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions)
# wallpapers
file(GLOB_RECURSE WALLPAPERS "assets/wall*")
install(FILES ${WALLPAPERS}
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)
# allow Hyprland to find assets
add_compile_definitions(DATAROOTDIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}")
# installable assets
file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*")
list(FILTER INSTALLABLE_ASSETS EXCLUDE REGEX "meson.build")
install(FILES ${INSTALLABLE_ASSETS}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
# default config
install(FILES ${CMAKE_SOURCE_DIR}/example/hyprland.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/hyprland)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
# portal config
install(FILES ${CMAKE_SOURCE_DIR}/assets/hyprland-portals.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/xdg-desktop-portal)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xdg-desktop-portal)
# man pages
file(GLOB_RECURSE MANPAGES "docs/*.1")
install(FILES ${MANPAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${MANPAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
# pkgconfig entry
install(FILES ${CMAKE_BINARY_DIR}/hyprland.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
# wlroots headers
set(HEADERS_WLR "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/include/wlr")
install(DIRECTORY ${HEADERS_WLR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h")
# config.h and version.h
set(HEADERS_WLR_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/wlroots-hyprland/build/include/wlr")
install(DIRECTORY ${HEADERS_WLR_ROOT}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland/wlr
FILES_MATCHING PATTERN "*.h")
# protocol headers
set(HEADERS_PROTO "${CMAKE_CURRENT_SOURCE_DIR}/protocols")
install(DIRECTORY ${HEADERS_PROTO}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")
install(
DIRECTORY ${HEADERS_PROTO}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING
PATTERN "*.h*")
# hyprland headers
set(HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src")
install(DIRECTORY ${HEADERS_SRC}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING PATTERN "*.h*")
install(
DIRECTORY ${HEADERS_SRC}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hyprland
FILES_MATCHING
PATTERN "*.h*")

View File

@@ -1,33 +1,31 @@
PREFIX = /usr/local
stub:
@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 -G Ninja
cmake --build ./build --config Release --target all
chmod -R 777 ./build
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 -G Ninja
cmake --build ./build --config Release --target all
chmod -R 777 ./build
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:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all
chmod -R 777 ./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`
debug:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build -G Ninja
cmake --build ./build --config Debug --target all
chmod -R 777 ./build
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -S . -B ./build
cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
nopch:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -S . -B ./build -G Ninja
cmake --build ./build --config Release --target all
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -S . -B ./build
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
clear:
rm -rf build
rm -f ./protocols/*.h ./protocols/*.c ./protocols/*.cpp ./protocols/*.hpp
rm -rf ./subprojects/wlroots-hyprland/build
all:
$(MAKE) clear
@@ -50,14 +48,11 @@ installheaders:
rm -fr ${PREFIX}/include/hyprland
mkdir -p ${PREFIX}/include/hyprland
mkdir -p ${PREFIX}/include/hyprland/protocols
mkdir -p ${PREFIX}/include/hyprland/wlr
mkdir -p ${PREFIX}/share/pkgconfig
cmake --build ./build --config Release --target generate-protocol-headers
find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland
cd subprojects/wlroots-hyprland/include/wlr && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../..
cd subprojects/wlroots-hyprland/build/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlr && cd ../../../..
cp ./protocols/*.h* ${PREFIX}/include/hyprland/protocols
cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig
if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi
@@ -88,11 +83,11 @@ asan:
@pidof Hyprland > /dev/null && exit 1 || echo ""
rm -rf ./wayland
git reset --hard
#git reset --hard
@echo -en "If you want to apply a patch, input its path (leave empty for none):\n"
@read patchvar
@if [-n "$patchvar"]; then patch -p1 < $patchvar || echo ""; else echo "No patch specified"; fi
@read patchvar; \
if [ -n "$$patchvar" ]; then patch -p1 < "$$patchvar" || echo ""; else echo "No patch specified"; fi
git clone --recursive https://gitlab.freedesktop.org/wayland/wayland
cd wayland && patch -p1 < ../scripts/waylandStatic.diff && meson setup build --buildtype=debug -Db_sanitize=address -Ddocumentation=false && ninja -C build && cd ..

View File

@@ -1,6 +1,6 @@
<div align = center>
<img src="https://raw.githubusercontent.com/vaxerski/Hyprland/main/assets/header.svg" width="750" height="300" alt="banner">
<img src="https://raw.githubusercontent.com/hyprwm/Hyprland/main/assets/header.svg" width="750" height="300" alt="banner">
<br>
@@ -13,10 +13,10 @@
<br>
Hyprland is a dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks.
Hyprland is a 100% independent, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
It provides the latest Wayland features, is highly customizable, has all the eyecandy, the most powerful plugins,
easy IPC, much more QoL stuff than other wlr-based compositors and more...
easy IPC, much more QoL stuff than other compositors and more...
<br>
<br>
@@ -37,7 +37,7 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
- All of the eyecandy: gradient borders, blur, animations, shadows and much more
- A lot of customization
- Much more QoL stuff than other wlr-based compositors
- 100% independent, no wlroots, no libweston, no kwin, no mutter.
- Custom bezier curves for the best animations
- Powerful plugin support
- Built-in plugin manager
@@ -48,7 +48,6 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
- Config reloaded instantly upon saving
- Fully dynamic workspaces
- Two built-in layouts and more available as plugins
- Uses forked wlroots with QoL patches
- Global keybinds passed to your apps of choice
- Tiling/pseudotiling/floating/fullscreen windows
- Special workspaces (scratchpads)
@@ -86,7 +85,7 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
<br>
**[wlroots]** - *For their amazing library*
**[wlroots]** - *For powering Hyprland in the past*
**[tinywl]** - *For showing how 2 do stuff*
@@ -101,7 +100,7 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
<!----------------------------------------------------------------------------->
[Configure]: https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
[Configure]: https://wiki.hyprland.org/Configuring/
[Stars]: https://starchart.cc/hyprwm/Hyprland
[Hypr]: https://github.com/hyprwm/Hypr
@@ -126,7 +125,6 @@ easy IPC, much more QoL stuff than other wlr-based compositors and more...
<!----------------------------------{ Images }--------------------------------->
[Stars Preview]: https://starchart.cc/vaxerski/Hyprland.svg
[Preview A]: https://i.ibb.co/C1yTb0r/falf.png
[Preview B]: https://linfindel.github.io/cdn/hyprland-preview-b.png
[Preview C]: https://i.ibb.co/B3GJg28/20221126-20h53m26s-grim.png

1
VERSION Normal file
View File

@@ -0,0 +1 @@
0.46.2

BIN
assets/install/lockdead.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -0,0 +1,10 @@
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

Before

Width:  |  Height:  |  Size: 14 MiB

After

Width:  |  Height:  |  Size: 14 MiB

View File

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 5.9 MiB

View File

Before

Width:  |  Height:  |  Size: 27 MiB

After

Width:  |  Height:  |  Size: 27 MiB

View File

@@ -1,7 +1,7 @@
wallpapers = ['0', '1', '2']
install_data(
'hyprland-portals.conf',
install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal'),
install_tag: 'runtime',
)
foreach type : wallpapers
install_data(f'wall@type@.png', install_dir: join_paths(get_option('datadir'), 'hyprland'), install_tag: 'runtime')
endforeach
install_data('hyprland-portals.conf', install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal'), install_tag: 'runtime')
subdir('install')

View File

@@ -10,8 +10,8 @@ Hyprland - Dynamic tiling Wayland compositor
\f[B]Hyprland\f[R] [\f[I]arg [...]\f[R]].
.SH DESCRIPTION
.PP
\f[B]Hyprland\f[R] is a dynamic tiling Wayland compositor based on
wlroots that doesn\[aq]t sacrifice on its looks.
\f[B]Hyprland\f[R] is an independent, highly customizable, dynamic
tiling Wayland compositor that doesn\[aq]t sacrifice on its looks.
.PP
You can launch Hyprland by either going into a TTY and executing
\f[B]Hyprland\f[R], or with a login manager.
@@ -32,6 +32,12 @@ Show command usage.
.TP
\f[B]-c\f[R], \f[B]--config\f[R]
Specify config file to use.
.TP
\f[B]--socket\f[R]
Sets the Wayland socket name (for Wayland socket handover)
.TP
\f[B]--wayland-fd\f[R]
Sets the Wayland socket file descriptor (for Wayland socket handover)
.SH BUGS
.TP
Submit bug reports and request features online at:

View File

@@ -14,8 +14,8 @@ SYNOPSIS
DESCRIPTION
===========
**Hyprland** is a dynamic tiling Wayland compositor based on
wlroots that doesn't sacrifice on its looks.
**Hyprland** is an independent, highly customizable,
dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
You can launch Hyprland by either going into a TTY and
executing **Hyprland**, or with a login manager.
@@ -41,6 +41,12 @@ OPTIONS
**-c**, **--config**
Specify config file to use.
**--socket**
Sets the Wayland socket name (for Wayland socket handover)
**--wayland-fd**
Sets the Wayland socket file descriptor (for Wayland socket handover)
BUGS
====

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
# This is an example Hyprland config file.
# Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
# https://wiki.hyprland.org/Configuring/
# Please note not all available settings / options are set here.
# For a full list, see the wiki
@@ -59,7 +59,7 @@ env = HYPRCURSOR_SIZE,24
# Refer to https://wiki.hyprland.org/Configuring/Variables/
# https://wiki.hyprland.org/Configuring/Variables/#general
general {
general {
gaps_in = 5
gaps_out = 20
@@ -70,7 +70,7 @@ general {
col.inactive_border = rgba(595959aa)
# 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
allow_tearing = false
@@ -86,37 +86,63 @@ decoration {
active_opacity = 1.0
inactive_opacity = 1.0
drop_shadow = true
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
shadow {
enabled = true
range = 4
render_power = 3
color = rgba(1a1a1aee)
}
# https://wiki.hyprland.org/Configuring/Variables/#blur
blur {
enabled = true
size = 3
passes = 1
vibrancy = 0.1696
}
}
# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
enabled = true
enabled = yes, please :)
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
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.0
bezier = quick,0.15,0,0.1,1
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
animation = global, 1, 10, default
animation = border, 1, 5.39, easeOutQuint
animation = windows, 1, 4.79, easeOutQuint
animation = windowsIn, 1, 4.1, easeOutQuint, popin 87%
animation = windowsOut, 1, 1.49, linear, popin 87%
animation = fadeIn, 1, 1.73, almostLinear
animation = fadeOut, 1, 1.46, almostLinear
animation = fade, 1, 3.03, quick
animation = layers, 1, 3.81, easeOutQuint
animation = layersIn, 1, 4, easeOutQuint, fade
animation = layersOut, 1, 1.5, linear, fade
animation = fadeLayersIn, 1, 1.79, almostLinear
animation = fadeLayersOut, 1, 1.39, almostLinear
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/
# "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle {
pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
@@ -129,7 +155,7 @@ master {
}
# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :(
}
@@ -169,9 +195,9 @@ device {
}
####################
### KEYBINDINGSS ###
####################
###################
### KEYBINDINGS ###
###################
# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
@@ -228,6 +254,19 @@ bind = $mainMod, mouse_up, workspace, e-1
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Laptop multimedia keys for volume and LCD brightness
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @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 = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+
bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%-
# Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous
##############################
### WINDOWS AND WORKSPACES ###
@@ -242,4 +281,8 @@ bindm = $mainMod, mouse:273, resizewindow
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.
# Ignore maximize requests from apps. You'll probably like this.
windowrulev2 = suppressevent maximize, class:.*
# Fix some dragging issues with XWayland
windowrulev2 = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0

View File

@@ -2,4 +2,6 @@
Name=Hyprland
Comment=An intelligent dynamic tiling Wayland compositor
Exec=Hyprland
Type=Application
Type=Application
DesktopNames=Hyprland
Keywords=tiling;wayland;compositor;

View File

@@ -1,2 +1,10 @@
install_data('hyprland.conf', install_dir: join_paths(get_option('datadir'), 'hyprland'), install_tag: 'runtime')
install_data('hyprland.desktop', install_dir: join_paths(get_option('datadir'), 'wayland-sessions'), install_tag: 'runtime')
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',
)

218
flake.lock generated
View File

@@ -1,5 +1,71 @@
{
"nodes": {
"aquamarine": {
"inputs": {
"hyprutils": [
"hyprutils"
],
"hyprwayland-scanner": [
"hyprwayland-scanner"
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1734364797,
"narHash": "sha256-2h1c+P0v3l0Z/ypUSsAPhU/yiSRgFwjVFODWp0S3d/w=",
"owner": "hyprwm",
"repo": "aquamarine",
"rev": "8e77618b403a82fde2105a8e3cd7cabe7ef00952",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "aquamarine",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"hyprcursor": {
"inputs": {
"hyprlang": [
@@ -13,11 +79,11 @@
]
},
"locked": {
"lastModified": 1718450675,
"narHash": "sha256-jpsns6buS4bK+1sF8sL8AaixAiCRjA+nldTKvcwmvUs=",
"lastModified": 1734364709,
"narHash": "sha256-+2bZJL2u5hva7rSp65OfKJBK+k03T6GB/NCvpoS1OOo=",
"owner": "hyprwm",
"repo": "hyprcursor",
"rev": "66d5b46ff94efbfa6fa3d1d1b66735f1779c34a6",
"rev": "f388aacd22be4a6e4d634fbaf6f75eb0713d239a",
"type": "github"
},
"original": {
@@ -26,23 +92,47 @@
"type": "github"
}
},
"hyprland-protocols": {
"hyprgraphics": {
"inputs": {
"hyprutils": [
"hyprutils"
],
"nixpkgs": [
"xdph",
"nixpkgs"
],
"systems": [
"xdph",
"systems"
]
},
"locked": {
"lastModified": 1714869498,
"narHash": "sha256-vbLVOWvQqo4n1yvkg/Q70VTlPbMmTiCQfNTgcWDCfJM=",
"lastModified": 1733684019,
"narHash": "sha256-2kYREgmSmbLsmDpLEq96hxVAU3qz8aCvVhF65yCFZHY=",
"owner": "hyprwm",
"repo": "hyprgraphics",
"rev": "fb2c0268645a77403af3b8a4ce8fa7ba5917f15d",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprgraphics",
"type": "github"
}
},
"hyprland-protocols": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1728345020,
"narHash": "sha256-xGbkc7U/Roe0/Cv3iKlzijIaFBNguasI31ynL2IlEoM=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "e06482e0e611130cd1929f75e8c1cf679e57d161",
"rev": "a7c183800e74f337753de186522b9017a07a8cee",
"type": "github"
},
"original": {
@@ -51,6 +141,32 @@
"type": "github"
}
},
"hyprland-qtutils": {
"inputs": {
"hyprutils": [
"hyprutils"
],
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1733940128,
"narHash": "sha256-hmfXWj2GA9cj1QUkPFYtAAeohhs615zL4E3APy3FnvQ=",
"owner": "hyprwm",
"repo": "hyprland-qtutils",
"rev": "3833097e50473a152dd614d4b468886840b4ea78",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-qtutils",
"type": "github"
}
},
"hyprlang": {
"inputs": {
"hyprutils": [
@@ -64,11 +180,11 @@
]
},
"locked": {
"lastModified": 1717881852,
"narHash": "sha256-XeeVoKHQgfKuXoP6q90sUqKyl7EYy3ol2dVZGM+Jj94=",
"lastModified": 1734364628,
"narHash": "sha256-ii8fzJfI953n/EmIxVvq64ZAwhvwuuPHWfGd61/mJG8=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "ec6938c66253429192274d612912649a0cfe4d28",
"rev": "16e59c1eb13d9fb6de066f54e7555eb5e8a4aba5",
"type": "github"
},
"original": {
@@ -87,11 +203,11 @@
]
},
"locked": {
"lastModified": 1719316102,
"narHash": "sha256-dmRz128j/lJmMuTYeCYPfSBRHHQO3VeH4PbmoyAhHzw=",
"lastModified": 1733502241,
"narHash": "sha256-KAUNC4Dgq8WQjYov5auBw/usaHixhacvb7cRDd0AG/k=",
"owner": "hyprwm",
"repo": "hyprutils",
"rev": "1f6bbec5954f623ff8d68e567bddcce97cd2f085",
"rev": "104117aed6dd68561be38b50f218190aa47f2cd8",
"type": "github"
},
"original": {
@@ -110,11 +226,11 @@
]
},
"locked": {
"lastModified": 1719067853,
"narHash": "sha256-mAnZG/eQy72Fp1ImGtqCgUrDumnR1rMZv2E/zgP4U74=",
"lastModified": 1726874836,
"narHash": "sha256-VKR0sf0PSNCB0wPHVKSAn41mCNVCnegWmgkrneKDhHM=",
"owner": "hyprwm",
"repo": "hyprwayland-scanner",
"rev": "914f083741e694092ee60a39d31f693d0a6dc734",
"rev": "500c81a9e1a76760371049a8d99e008ea77aa59e",
"type": "github"
},
"original": {
@@ -125,11 +241,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1719075281,
"narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=",
"lastModified": 1734119587,
"narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af",
"rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
"type": "github"
},
"original": {
@@ -139,13 +255,57 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1730741070,
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1734279981,
"narHash": "sha256-NdaCraHPp8iYMWzdXAt5Nv6sA3MUzlCiGiR586TCwo0=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "aa9f40c906904ebd83da78e7f328cd8aeaeae785",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"aquamarine": "aquamarine",
"hyprcursor": "hyprcursor",
"hyprgraphics": "hyprgraphics",
"hyprland-protocols": "hyprland-protocols",
"hyprland-qtutils": "hyprland-qtutils",
"hyprlang": "hyprlang",
"hyprutils": "hyprutils",
"hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"systems": "systems",
"xdph": "xdph"
}
@@ -167,10 +327,18 @@
},
"xdph": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"hyprland-protocols": [
"hyprland-protocols"
],
"hyprlang": [
"hyprlang"
],
"hyprutils": [
"hyprutils"
],
"hyprwayland-scanner": [
"hyprwayland-scanner"
],
"nixpkgs": [
"nixpkgs"
],
@@ -179,11 +347,11 @@
]
},
"locked": {
"lastModified": 1718619174,
"narHash": "sha256-FWW68AVYmB91ZDQnhLMBNCUUTCjb1ZpO2k2KIytHtkA=",
"lastModified": 1734124279,
"narHash": "sha256-YNpFfiQjYt2o6LGcMN9NkjVvprC8ELrIpLHlbZbclRM=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "c7894aa54f9a7dbd16df5cd24d420c8af22d5623",
"rev": "0c6861f819f6d31f6195c9864709b2556f00b5cf",
"type": "github"
},
"original": {

View File

@@ -7,6 +7,14 @@
# <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux";
aquamarine = {
url = "github:hyprwm/aquamarine";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
inputs.hyprwayland-scanner.follows = "hyprwayland-scanner";
};
hyprcursor = {
url = "github:hyprwm/hyprcursor";
inputs.nixpkgs.follows = "nixpkgs";
@@ -14,6 +22,26 @@
inputs.hyprlang.follows = "hyprlang";
};
hyprgraphics = {
url = "github:hyprwm/hyprgraphics";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};
hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
hyprland-qtutils = {
url = "github:hyprwm/hyprland-qtutils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};
hyprlang = {
url = "github:hyprwm/hyprlang";
inputs.nixpkgs.follows = "nixpkgs";
@@ -37,7 +65,15 @@
url = "github:hyprwm/xdg-desktop-portal-hyprland";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprland-protocols.follows = "hyprland-protocols";
inputs.hyprlang.follows = "hyprlang";
inputs.hyprutils.follows = "hyprutils";
inputs.hyprwayland-scanner.follows = "hyprwayland-scanner";
};
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
@@ -57,6 +93,15 @@
hyprland-extras
];
});
pkgsCrossFor = eachSystem (system: crossSystem:
import nixpkgs {
localSystem = system;
inherit crossSystem;
overlays = with self.overlays; [
hyprland-packages
hyprland-extras
];
});
in {
overlays = import ./nix/overlays.nix {inherit self lib inputs;};
@@ -66,6 +111,18 @@
self.packages.${system})
// {
inherit (self.packages.${system}) xdg-desktop-portal-hyprland;
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
hyprland-treewide-formatter = {
enable = true;
entry = "${self.formatter.${system}}/bin/hyprland-treewide-formatter";
pass_filenames = false;
excludes = ["subprojects"];
always_run = true;
};
};
};
});
packages = eachSystem (system: {
@@ -73,30 +130,30 @@
inherit
(pkgsFor.${system})
# hyprland-packages
hyprland
hyprland-debug
hyprland-legacy-renderer
hyprland-unwrapped
# hyprland-extras
xdg-desktop-portal-hyprland
;
hyprland-cross = (pkgsCrossFor.${system} "aarch64-linux").hyprland;
});
devShells = eachSystem (system: {
default =
pkgsFor.${system}.mkShell.override {
stdenv = pkgsFor.${system}.gcc13Stdenv;
inherit (self.packages.${system}.default) stdenv;
} {
name = "hyprland-shell";
nativeBuildInputs = with pkgsFor.${system}; [expat libxml2];
hardeningDisable = ["fortify"];
inputsFrom = [pkgsFor.${system}.hyprland];
packages = [pkgsFor.${system}.clang-tools];
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
formatter = eachSystem (system: pkgsFor.${system}.callPackage ./nix/formatter.nix {});
nixosModules.default = import ./nix/module.nix inputs;
homeManagerModules.default = import ./nix/hm-module.nix self;

View File

@@ -5,11 +5,11 @@ project(
DESCRIPTION "Control utility for Hyprland"
)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprutils>=0.1.1)
pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 re2)
add_executable(hyprctl "main.cpp")
target_link_libraries(hyprctl PUBLIC PkgConfig::deps)
target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps)
# binary
install(TARGETS hyprctl)

View File

@@ -1,4 +0,0 @@
all:
$(CXX) $(CXXFLAGS) -std=c++2b ./main.cpp -o ./hyprctl
clean:
rm ./hyprctl

View File

@@ -1,5 +1,7 @@
#pragma once
#include <string_view>
const std::string_view USAGE = R"#(usage: hyprctl [flags] <command> [args...|--help]
commands:

View File

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

View File

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

View File

@@ -2,20 +2,21 @@
# Repo: https://github.com/adaszko/complgen
# Generate completion scripts: "complgen aot --bash-script hyprctl.bash --fish-script hyprctl.fish --zsh-script hyprctl.zsh ./hyprctl.usage"
hyprctl [<OPTIONS>]... <ARGUMENTS>
hyprctl [<OPTIONS>]... <ARGUMENTS>
<OPTIONS> ::= (-i | --instance) "Specify the Hyprland instance"
| (-j) "Output in JSON format"
| (-r) "Refresh state after issuing the command"
| (--batch) "Execute a batch of commands separated by ;"
| (-q | --quiet) "Disable output"
| (-h | --help) "Prints the help message"
;
<WINDOWS> ::= {{{ hyprctl clients | grep class | awk '{print $2}' }}};
<WINDOWS> ::= {{{ hyprctl clients | awk '/class/{print $2}' }}};
<AVAILABLE_PLUGINS> ::= {{{ hyprpm list | grep "Plugin" | awk '{print $4}' }}};
<AVAILABLE_PLUGINS> ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}};
<MONITORS> ::= {{{ hyprctl monitors | grep Monitor | awk '{ print $2 }' }}};
<MONITORS> ::= {{{ hyprctl monitors | awk '/Monitor/{ print $2 }' }}};
<KEYBOARDS> ::= {{{ hyprctl devices | sed -n '/Keyboard at/{n; s/^\s\+//; p}' }}};
@@ -59,16 +60,18 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
<ARGUMENTS> ::= (activewindow) "Get the active window name and its properties"
| (activeworkspace) "Get the active workspace name and its properties"
| (animations) "Gets the current config info about animations and beziers"
| (binds) "List all registered binds"
| (clients) "List all windows with their properties"
| (configerrors) "List all current config parsing errors"
| (cursorpos) "Get the current cursor pos in global layout coordinates"
| (decorations <WINDOWS>) "List all decorations and their info"
| (descriptions) "Return a parsable JSON with all the config options, descriptions, value types and ranges"
| (devices) "List all connected keyboards and mice"
| (dismissnotify <NUM>) "Dismiss all or up to amount of notifications"
| (dispatch <DISPATCHERS>) "Issue a dispatch to call a keybind dispatcher with an arg"
| (getoption) "Get the config option status (values)"
| (globalshortcuts) ""
| (globalshortcuts) "Lists all global shortcuts"
| (hyprpaper) "Interact with hyprpaper if present"
| (instances) "List all running Hyprland instances and their info"
| (keyword <KEYWORDS>) "Issue a keyword to call a config keyword dynamically"
@@ -79,8 +82,8 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
| (notify <NOTIFICATION_TYPES> <NUM>) "Send a notification using the built-in Hyprland notification system"
| (output (create (wayland | x11 | headless | auto) | remove <MONITORS>)) "Allows adding/removing fake outputs to a specific backend"
| (plugin <AVAILABLE_PLUGINS>) "Interact with a plugin"
| (reload) "Force reload the config"
| (rollinglog) "Print tail of the log"
| (reload [config-only]) "Force reload the config"
| (rollinglog [-f]) "Print tail of the log"
| (setcursor) "Set the cursor theme and reloads the cursor manager"
| (seterror [disable]) "Set the hyprctl error string"
| (setprop <PROPS>) "Set a property of a window"
@@ -92,6 +95,13 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
| (workspaces) "List all workspaces with their properties"
;
<WINDOW_STATE> ::= (-1) "Current"
| (0) "None"
| (1) "Maximize no fullscreen"
| (2) "Fullscreen"
| (3) "Maximize and fullscreen"
;
<DISPATCHERS> ::= (exec) "Execute a shell command"
| (execr) "Execute a raw shell command"
| (pass) "Pass the key to a specified window"
@@ -106,6 +116,7 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
| (settiled) "Set the current window's floating state to false"
| (fullscreen) "Toggle the focused window's fullscreen state"
| (fakefullscreen) "Toggle the focused window's internal fullscreen state"
| (fullscreenstate <WINDOW_STATE>) "Sets the focused windows fullscreen mode and the one sent to the client"
| (dpms) "Set all monitors' DPMS status"
| (pin) "Pin a window"
| (movefocus) "Move the focus in a direction"
@@ -148,4 +159,5 @@ hyprctl [<OPTIONS>]... <ARGUMENTS>
| (setignoregrouplock) "Temporarily enable or disable binds:ignore_group_lock"
| (global) "Execute a Global Shortcut using the GlobalShortcuts portal"
| (submap) "Change the current mapping group"
| (event) "Emits a custom event to socket2"
;

View File

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

View File

@@ -1,3 +1,5 @@
#include <re2/re2.h>
#include <cctype>
#include <netdb.h>
#include <netinet/in.h>
@@ -17,15 +19,15 @@
#include <iostream>
#include <string>
#include <print>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <filesystem>
#include <cstdarg>
#include <regex>
#include <sys/socket.h>
#include <hyprutils/string/String.hpp>
#include <cstring>
using namespace Hyprutils::String;
#include "Strings.hpp"
@@ -43,18 +45,24 @@ struct SInstanceData {
bool valid = true;
};
void log(std::string str) {
void log(const std::string& str) {
if (quiet)
return;
std::cout << str << "\n";
std::println("{}", str);
}
static int getUID() {
const auto UID = getuid();
const auto PWUID = getpwuid(UID);
return PWUID ? PWUID->pw_uid : UID;
}
std::string getRuntimeDir() {
const auto XDG = getenv("XDG_RUNTIME_DIR");
if (!XDG) {
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
const std::string USERID = std::to_string(getUID());
return "/run/user/" + USERID + "/hypr";
}
@@ -64,6 +72,11 @@ std::string getRuntimeDir() {
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;
@@ -104,7 +117,7 @@ std::vector<SInstanceData> instances() {
static volatile bool sigintReceived = false;
void intHandler(int sig) {
sigintReceived = true;
std::cout << "[hyprctl] SIGINT received, closing connection" << std::endl;
std::println("[hyprctl] SIGINT received, closing connection");
}
int rollingRead(const int socket) {
@@ -113,13 +126,13 @@ int rollingRead(const int socket) {
constexpr size_t BUFFER_SIZE = 8192;
std::array<char, BUFFER_SIZE> buffer = {0};
int sizeWritten = 0;
std::cout << "[hyprctl] reading from socket following up log:" << std::endl;
long sizeWritten = 0;
std::println("[hyprctl] reading from socket following up log:");
while (!sigintReceived) {
sizeWritten = read(socket, buffer.data(), BUFFER_SIZE);
if (sizeWritten < 0 && errno != EAGAIN) {
if (errno != EINTR)
std::cout << "Couldn't read (5) " << strerror(errno) << ":" << errno << std::endl;
std::println("Couldn't read (5): {}: {}", strerror(errno), errno);
close(socket);
return 5;
}
@@ -128,7 +141,7 @@ int rollingRead(const int socket) {
break;
if (sizeWritten > 0) {
std::cout << std::string(buffer.data(), sizeWritten);
std::println("{}", std::string(buffer.data(), sizeWritten));
buffer.fill('\0');
}
@@ -141,7 +154,7 @@ int rollingRead(const int socket) {
int request(std::string arg, int minArgs = 0, bool needRoll = false) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
auto t = timeval{.tv_sec = 1, .tv_usec = 0};
auto t = timeval{.tv_sec = 5, .tv_usec = 0};
setsockopt(SERVERSOCKET, SOL_SOCKET, SO_RCVTIMEO, &t, sizeof(struct timeval));
const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
@@ -161,7 +174,7 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
return 2;
}
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
const std::string USERID = std::to_string(getUID());
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
@@ -231,7 +244,7 @@ int requestHyprpaper(std::string arg) {
sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
const std::string USERID = std::to_string(getpwuid(getuid())->pw_uid);
const std::string USERID = std::to_string(getUID());
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.hyprpaper.sock";
@@ -269,10 +282,11 @@ int requestHyprpaper(std::string arg) {
}
void batchRequest(std::string 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) {
commands = "j/" + std::regex_replace(commands, std::regex(";\\s*"), ";j/");
RE2::GlobalReplace(&commands, ";\\s*", ";j/");
commands.insert(0, "j/");
}
std::string rq = "[[BATCH]]" + commands;
@@ -286,12 +300,12 @@ void instancesRequest(bool json) {
std::vector<SInstanceData> inst = instances();
if (!json) {
for (auto& el : inst) {
for (auto const& el : inst) {
result += std::format("instance {}:\n\ttime: {}\n\tpid: {}\n\twl socket: {}\n\n", el.id, el.time, el.pid, el.wlSocket);
}
} else {
result += '[';
for (auto& el : inst) {
for (auto const& el : inst) {
result += std::format(R"#(
{{
"instance": "{}",
@@ -309,11 +323,11 @@ void instancesRequest(bool json) {
log(result + "\n");
}
std::deque<std::string> splitArgs(int argc, char** argv) {
std::deque<std::string> result;
std::vector<std::string> splitArgs(int argc, char** argv) {
std::vector<std::string> result;
for (auto i = 1 /* skip the executable */; i < argc; ++i)
result.push_back(std::string(argv[i]));
result.emplace_back(argv[i]);
return result;
}
@@ -322,7 +336,7 @@ int main(int argc, char** argv) {
bool parseArgs = true;
if (argc < 2) {
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
return 1;
}
@@ -359,7 +373,7 @@ int main(int argc, char** argv) {
++i;
if (i >= ARGS.size()) {
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
return 1;
}
@@ -370,24 +384,24 @@ int main(int argc, char** argv) {
const std::string& cmd = ARGS[0];
if (cmd == "hyprpaper") {
std::cout << HYPRPAPER_HELP << std::endl;
std::println("{}", HYPRPAPER_HELP);
} else if (cmd == "notify") {
std::cout << NOTIFY_HELP << std::endl;
std::println("{}", NOTIFY_HELP);
} else if (cmd == "output") {
std::cout << OUTPUT_HELP << std::endl;
std::println("{}", OUTPUT_HELP);
} else if (cmd == "plugin") {
std::cout << PLUGIN_HELP << std::endl;
std::println("{}", PLUGIN_HELP);
} else if (cmd == "setprop") {
std::cout << SETPROP_HELP << std::endl;
std::println("{}", SETPROP_HELP);
} else if (cmd == "switchxkblayout") {
std::cout << SWITCHXKBLAYOUT_HELP << std::endl;
std::println("{}", SWITCHXKBLAYOUT_HELP);
} else {
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
}
return 1;
} else {
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
return 1;
}
@@ -398,7 +412,7 @@ int main(int argc, char** argv) {
}
if (fullRequest.empty()) {
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
return 1;
}
@@ -475,7 +489,7 @@ int main(int argc, char** argv) {
else if (fullRequest.contains("/decorations"))
exitStatus = request(fullRequest, 1);
else if (fullRequest.contains("/--help"))
std::cout << USAGE << std::endl;
std::println("{}", USAGE);
else if (fullRequest.contains("/rollinglog") && needRoll)
exitStatus = request(fullRequest, 0, true);
else {

View File

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

@@ -4,4 +4,4 @@ Name: Hyprland
URL: https://github.com/hyprwm/Hyprland
Description: Hyprland header files
Version: @HYPRLAND_VERSION@
Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland -I${prefix}/hyprland/wlr
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)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.1.1)
pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.2.4)
add_executable(hyprpm ${SRCFILES})
target_link_libraries(hyprpm PUBLIC PkgConfig::deps)
target_link_libraries(hyprpm PUBLIC PkgConfig::hyprpm_deps)
# binary
install(TARGETS hyprpm)

View File

@@ -1,5 +1,9 @@
_hyprpm_cmd_0 () {
hyprpm list | grep Plugin | awk '{print $4}'
hyprpm list | awk '/Plugin/{print $4}'
}
_hyprpm_cmd_1 () {
hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
}
_hyprpm () {
@@ -11,16 +15,13 @@ _hyprpm () {
local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
declare -a literals=(--no-shallow -n ::= disable list --help update add --verbose -v --force -s remove enable --notify -h reload -f)
declare -A literal_transitions
literal_transitions[0]="([9]=6 [2]=2 [7]=6 [8]=6 [4]=6 [10]=2 [11]=3 [5]=2 [13]=6 [3]=3 [14]=2 [15]=6 [6]=2)"
literal_transitions[1]="([10]=2 [11]=3 [3]=3 [2]=2 [14]=2 [5]=2 [6]=2)"
literal_transitions[4]="([1]=5)"
literal_transitions[5]="([0]=6 [12]=6)"
declare -A match_anything_transitions
match_anything_transitions=([3]=2 [2]=4 [0]=1 [1]=1)
literal_transitions[0]="([0]=7 [3]=3 [4]=4 [8]=7 [9]=7 [6]=4 [7]=4 [11]=7 [5]=7 [10]=7 [12]=2 [13]=3 [15]=7 [16]=4 [17]=7)"
literal_transitions[1]="([12]=2 [13]=3 [3]=3 [4]=4 [16]=4 [6]=4 [7]=4)"
literal_transitions[5]="([2]=6)"
literal_transitions[6]="([1]=7 [14]=7)"
declare -A match_anything_transitions=([1]=1 [4]=5 [3]=4 [2]=4 [0]=1)
declare -A subword_transitions
local state=0
@@ -58,21 +59,9 @@ _hyprpm () {
done
local -a matches=()
local prefix="${words[$cword]}"
local shortest_suffix="$word"
for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
local char="${COMP_WORDBREAKS:$i:1}"
local candidate="${word##*$char}"
if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
shortest_suffix=$candidate
fi
done
local superfluous_prefix=""
if [[ "$shortest_suffix" != "$word" ]]; then
local superfluous_prefix=${word%$shortest_suffix}
fi
if [[ -v "literal_transitions[$state]" ]]; then
local state_transitions_initializer=${literal_transitions[$state]}
declare -A state_transitions
@@ -81,25 +70,38 @@ _hyprpm () {
for literal_id in "${!state_transitions[@]}"; do
local literal="${literals[$literal_id]}"
if [[ $literal = "${prefix}"* ]]; then
local completion=${literal#"$superfluous_prefix"}
COMPREPLY+=("$completion ")
matches+=("$literal ")
fi
done
fi
declare -A commands
commands=([3]=0)
commands=([3]=0 [2]=1)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local completions=()
mapfile -t completions < <(_hyprpm_cmd_${command_id} "$prefix" | cut -f1)
readarray -t completions < <(_hyprpm_cmd_${command_id} "$prefix" | cut -f1)
for item in "${completions[@]}"; do
if [[ $item = "${prefix}"* ]]; then
COMPREPLY+=("$item")
matches+=("$item")
fi
done
fi
local shortest_suffix="$prefix"
for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
local char="${COMP_WORDBREAKS:$i:1}"
local candidate=${prefix##*$char}
if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
shortest_suffix=$candidate
fi
done
local superfluous_prefix=""
if [[ "$shortest_suffix" != "$prefix" ]]; then
local superfluous_prefix=${prefix%$shortest_suffix}
fi
COMPREPLY=("${matches[@]#$superfluous_prefix}")
return 0
}

View File

@@ -1,6 +1,11 @@
function _hyprpm_1
set 1 $argv[1]
hyprpm list | grep Plugin | awk '{print $4}'
hyprpm list | awk '/Plugin/{print $4}'
end
function _hyprpm_2
set 1 $argv[1]
hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
end
function _hyprpm
@@ -14,49 +19,51 @@ function _hyprpm
set COMP_CWORD (count $COMP_WORDS)
end
set --local literals "-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f"
set literals "--no-shallow" "-n" "::=" "disable" "list" "--help" "update" "add" "--verbose" "-v" "--force" "-s" "remove" "enable" "--notify" "-h" "reload" "-f"
set --local descriptions
set descriptions[1] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[3] "List all installed plugins"
set descriptions
set descriptions[1] "Disable shallow cloning of Hyprland sources"
set descriptions[2] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[4] "Unload a plugin"
set descriptions[5] "Show help menu"
set descriptions[6] "Check and update all plugins if needed"
set descriptions[7] "Install a new plugin repository from git"
set descriptions[8] "Enable too much loggin"
set descriptions[5] "List all installed plugins"
set descriptions[6] "Show help menu"
set descriptions[7] "Check and update all plugins if needed"
set descriptions[8] "Install a new plugin repository from git"
set descriptions[9] "Enable too much loggin"
set descriptions[10] "Force an operation ignoring checks (e.g. update -f)"
set descriptions[11] "Remove a plugin repository"
set descriptions[12] "Load a plugin"
set descriptions[13] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[14] "Show help menu"
set descriptions[15] "Reload all plugins"
set descriptions[16] "Force an operation ignoring checks (e.g. update -f)"
set descriptions[10] "Enable too much loggin"
set descriptions[11] "Force an operation ignoring checks (e.g. update -f)"
set descriptions[12] "Disable shallow cloning of Hyprland sources"
set descriptions[13] "Remove a plugin repository"
set descriptions[14] "Load a plugin"
set descriptions[15] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[16] "Show help menu"
set descriptions[17] "Reload all plugins"
set descriptions[18] "Force an operation ignoring checks (e.g. update -f)"
set --local literal_transitions
set literal_transitions[1] "set inputs 10 3 8 9 5 11 12 6 14 4 15 16 7; set tos 7 3 7 7 7 3 4 3 7 4 3 7 3"
set literal_transitions[2] "set inputs 11 12 4 3 15 6 7; set tos 3 4 4 3 3 3 3"
set literal_transitions[5] "set inputs 2; set tos 6"
set literal_transitions[6] "set inputs 1 13; set tos 7 7"
set literal_transitions
set literal_transitions[1] "set inputs 1 4 5 9 10 7 8 12 6 11 13 14 16 17 18; set tos 8 4 5 8 8 5 5 8 8 8 3 4 8 5 8"
set literal_transitions[2] "set inputs 13 14 4 5 17 7 8; set tos 3 4 4 5 5 5 5"
set literal_transitions[6] "set inputs 3; set tos 7"
set literal_transitions[7] "set inputs 2 15; set tos 8 8"
set --local match_anything_transitions_from 4 3 1 2
set --local match_anything_transitions_to 3 5 2 2
set match_anything_transitions_from 2 5 4 3 1
set match_anything_transitions_to 2 6 5 5 2
set --local state 1
set --local word_index 2
set state 1
set word_index 2
while test $word_index -lt $COMP_CWORD
set --local -- word $COMP_WORDS[$word_index]
set -- word $COMP_WORDS[$word_index]
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
set --erase inputs
set --erase tos
eval $literal_transitions[$state]
if contains -- $word $literals
set --local literal_matched 0
set literal_matched 0
for literal_id in (seq 1 (count $literals))
if test $literals[$literal_id] = $word
set --local index (contains --index -- $literal_id $inputs)
set index (contains --index -- $literal_id $inputs)
set state $tos[$index]
set word_index (math $word_index + 1)
set literal_matched 1
@@ -70,7 +77,7 @@ function _hyprpm
end
if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state]
set --local index (contains --index -- $state $match_anything_transitions_from)
set index (contains --index -- $state $match_anything_transitions_from)
set state $match_anything_transitions_to[$index]
set word_index (math $word_index + 1)
continue
@@ -80,8 +87,8 @@ function _hyprpm
end
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
set --local --erase inputs
set --local --erase tos
set --erase inputs
set --erase tos
eval $literal_transitions[$state]
for literal_id in $inputs
if test -n $descriptions[$literal_id]
@@ -92,14 +99,14 @@ function _hyprpm
end
end
set command_states 4
set command_ids 1
set command_states 4 3
set command_ids 1 2
if contains $state $command_states
set --local index (contains --index $state $command_states)
set --local function_id $command_ids[$index]
set --local function_name _hyprpm_$function_id
set --local --erase inputs
set --local --erase tos
set index (contains --index $state $command_states)
set function_id $command_ids[$index]
set function_name _hyprpm_$function_id
set --erase inputs
set --erase tos
$function_name "$COMP_WORDS[$COMP_CWORD]"
end

View File

@@ -5,10 +5,11 @@ hyprpm [<FLAGS>]... <ARGUMENT>
| (--help | -h) "Show help menu"
| (--verbose | -v) "Enable too much loggin"
| (--force | -f) "Force an operation ignoring checks (e.g. update -f)"
| (--no-shallow | -s) "Disable shallow cloning of Hyprland sources"
;
<ARGUMENT> ::= (add) "Install a new plugin repository from git"
| (remove) "Remove a plugin repository"
| (remove <PLUGIN_REPOS>) "Remove a plugin repository"
| (update) "Check and update all plugins if needed"
| (list) "List all installed plugins"
| (enable <PLUGINS>) "Load a plugin"
@@ -16,4 +17,5 @@ hyprpm [<FLAGS>]... <ARGUMENT>
| (reload) "Reload all plugins"
;
<PLUGINS> ::= {{{ hyprpm list | grep Plugin | awk '{print $4}' }}};
<PLUGINS> ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}};
<PLUGIN_REPOS> ::= {{{ hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//' }}};

View File

@@ -1,37 +1,43 @@
#compdef hyprpm
_hyprpm_cmd_0 () {
hyprpm list | grep Plugin | awk '{print $4}'
hyprpm list | awk '/Plugin/{print $4}'
}
_hyprpm_cmd_1 () {
hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
}
_hyprpm () {
local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
local -a literals=("--no-shallow" "-n" "::=" "disable" "list" "--help" "update" "add" "--verbose" "-v" "--force" "-s" "remove" "enable" "--notify" "-h" "reload" "-f")
local -A descriptions
descriptions[1]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[3]="List all installed plugins"
descriptions[1]="Disable shallow cloning of Hyprland sources"
descriptions[2]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[4]="Unload a plugin"
descriptions[5]="Show help menu"
descriptions[6]="Check and update all plugins if needed"
descriptions[7]="Install a new plugin repository from git"
descriptions[8]="Enable too much loggin"
descriptions[5]="List all installed plugins"
descriptions[6]="Show help menu"
descriptions[7]="Check and update all plugins if needed"
descriptions[8]="Install a new plugin repository from git"
descriptions[9]="Enable too much loggin"
descriptions[10]="Force an operation ignoring checks (e.g. update -f)"
descriptions[11]="Remove a plugin repository"
descriptions[12]="Load a plugin"
descriptions[13]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[14]="Show help menu"
descriptions[15]="Reload all plugins"
descriptions[16]="Force an operation ignoring checks (e.g. update -f)"
descriptions[10]="Enable too much loggin"
descriptions[11]="Force an operation ignoring checks (e.g. update -f)"
descriptions[12]="Disable shallow cloning of Hyprland sources"
descriptions[13]="Remove a plugin repository"
descriptions[14]="Load a plugin"
descriptions[15]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[16]="Show help menu"
descriptions[17]="Reload all plugins"
descriptions[18]="Force an operation ignoring checks (e.g. update -f)"
local -A literal_transitions
literal_transitions[1]="([10]=7 [3]=3 [8]=7 [9]=7 [5]=7 [11]=3 [12]=4 [6]=3 [14]=7 [4]=4 [15]=3 [16]=7 [7]=3)"
literal_transitions[2]="([11]=3 [12]=4 [4]=4 [3]=3 [15]=3 [6]=3 [7]=3)"
literal_transitions[5]="([2]=6)"
literal_transitions[6]="([1]=7 [13]=7)"
literal_transitions[1]="([1]=8 [4]=4 [5]=5 [9]=8 [10]=8 [7]=5 [8]=5 [12]=8 [6]=8 [11]=8 [13]=3 [14]=4 [16]=8 [17]=5 [18]=8)"
literal_transitions[2]="([13]=3 [14]=4 [4]=4 [5]=5 [17]=5 [7]=5 [8]=5)"
literal_transitions[6]="([3]=7)"
literal_transitions[7]="([2]=8 [15]=8)"
local -A match_anything_transitions
match_anything_transitions=([4]=3 [3]=5 [1]=2 [2]=2)
match_anything_transitions=([2]=2 [5]=6 [4]=5 [3]=5 [1]=2)
declare -A subword_transitions
@@ -91,7 +97,7 @@ _hyprpm () {
fi
done
fi
local -A commands=([4]=0)
local -A commands=([4]=0 [3]=1)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}

View File

@@ -1,6 +1,6 @@
#include "DataState.hpp"
#include <toml++/toml.hpp>
#include <iostream>
#include <print>
#include <filesystem>
#include <fstream>
#include "PluginManager.hpp"
@@ -8,7 +8,7 @@
std::string DataState::getDataStatePath() {
const auto HOME = getenv("HOME");
if (!HOME) {
std::cerr << "DataState: no $HOME\n";
std::println(stderr, "DataState: no $HOME");
throw std::runtime_error("no $HOME");
return "";
}
@@ -49,7 +49,7 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
{"rev", repo.rev}
}}
};
for (auto& p : repo.plugins) {
for (auto const& p : repo.plugins) {
// copy .so to the good place
if (std::filesystem::exists(p.filename))
std::filesystem::copy_file(p.filename, PATH + "/" + p.name + ".so");
@@ -242,4 +242,4 @@ bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
}
return false;
}
}

View File

@@ -6,7 +6,7 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
auto manifest = toml::parse_file(path);
if (type == MANIFEST_HYPRLOAD) {
for (auto& [key, val] : manifest) {
for (auto const& [key, val] : manifest) {
if (key.str().ends_with(".build"))
continue;
@@ -63,7 +63,7 @@ CManifest::CManifest(const eManifestType type, const std::string& path) {
}
}
for (auto& [key, val] : manifest) {
for (auto const& [key, val] : manifest) {
if (key.str() == "repository")
continue;

View File

@@ -1,12 +1,15 @@
#include "PluginManager.hpp"
#include "../helpers/Colors.hpp"
#include "../helpers/StringUtils.hpp"
#include "../progress/CProgressBar.hpp"
#include "Manifest.hpp"
#include "DataState.hpp"
#include <cstdio>
#include <iostream>
#include <array>
#include <filesystem>
#include <print>
#include <thread>
#include <fstream>
#include <algorithm>
@@ -20,37 +23,56 @@
#include <toml++/toml.hpp>
#include <hyprutils/string/String.hpp>
#include <hyprutils/os/Process.hpp>
using namespace Hyprutils::String;
using namespace Hyprutils::OS;
static std::string execAndGet(std::string cmd) {
cmd += " 2>&1";
std::array<char, 128> buffer;
std::string result;
using PcloseType = int (*)(FILE*);
const std::unique_ptr<FILE, PcloseType> pipe(popen(cmd.c_str(), "r"), static_cast<PcloseType>(pclose));
if (!pipe)
return "";
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
CProcess proc("/bin/sh", {"-c", cmd});
if (!proc.runSync())
return "error";
return proc.stdOut();
}
SHyprlandVersion CPluginManager::getHyprlandVersion() {
static SHyprlandVersion ver;
static bool once = false;
static std::string getTempRoot() {
static auto ENV = getenv("XDG_RUNTIME_DIR");
if (!ENV) {
std::cerr << "\nERROR: XDG_RUNTIME_DIR not set!\n";
exit(1);
}
if (once)
return ver;
const auto STR = ENV + std::string{"/hyprpm/"};
once = true;
const auto HLVERCALL = execAndGet("hyprctl version");
return STR;
}
SHyprlandVersion CPluginManager::getHyprlandVersion(bool running) {
static bool onceRunning = false;
static bool onceInstalled = false;
static SHyprlandVersion verRunning;
static SHyprlandVersion verInstalled;
if (onceRunning && running)
return verRunning;
if (onceInstalled && !running)
return verInstalled;
if (running)
onceRunning = true;
else
onceInstalled = true;
const auto HLVERCALL = running ? execAndGet("hyprctl version") : execAndGet("Hyprland --version");
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "version returned: " << HLVERCALL << "\n";
std::println("{}", verboseString("{} version returned: {}", running ? "running" : "installed", HLVERCALL));
if (!HLVERCALL.contains("Tag:")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " You don't seem to be running Hyprland.";
std::println(stderr, "\n{}", failureString("You don't seem to be running Hyprland."));
return SHyprlandVersion{};
}
@@ -76,14 +98,20 @@ SHyprlandVersion CPluginManager::getHyprlandVersion() {
} catch (...) { ; }
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "parsed commit " << hlcommit << " at branch " << hlbranch << " on " << hldate << ", commits " << commits << "\n";
std::println("{}", verboseString("parsed commit {} at branch {} on {}, commits {}", hlcommit, hlbranch, hldate, commits));
auto ver = SHyprlandVersion{hlbranch, hlcommit, hldate, commits};
if (running)
verRunning = ver;
else
verInstalled = ver;
ver = SHyprlandVersion{hlbranch, hlcommit, hldate, commits};
return ver;
}
bool CPluginManager::createSafeDirectory(const std::string& path) {
if (path.empty() || !path.starts_with("/tmp"))
if (path.empty() || !path.starts_with(getTempRoot()))
return false;
if (std::filesystem::exists(path))
@@ -102,20 +130,21 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
const auto HLVER = getHyprlandVersion();
if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio, pkg-config"));
return false;
}
if (DataState::pluginRepoExists(url)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Repository already installed.\n";
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Repository already installed."));
return false;
}
auto GLOBALSTATE = DataState::getGlobalState();
if (!GLOBALSTATE.dontWarnInstall) {
std::cout << Colors::YELLOW << "!" << Colors::RED << " Disclaimer:\n " << Colors::RESET
<< "plugins, especially not official, have no guarantee of stability, availablity or security.\n Run them at your own risk.\n "
<< "This message will not appear again.\n";
std::println("{}!{} Disclaimer: {}", Colors::YELLOW, Colors::RED, Colors::RESET);
std::println("plugins, especially not official, have no guarantee of stability, availablity or security.\n"
"Run them at your own risk.\n"
"This message will not appear again.");
GLOBALSTATE.dontWarnInstall = true;
DataState::updateGlobalState(GLOBALSTATE);
}
@@ -129,7 +158,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
std::getline(std::cin, input);
if (input.size() > 0 && input[0] != 'Y' && input[0] != 'y') {
std::cout << "Aborting.\n";
std::println(stderr, "Aborting.");
return false;
}
@@ -140,70 +169,73 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
progress.print();
if (!std::filesystem::exists("/tmp/hyprpm")) {
std::filesystem::create_directory("/tmp/hyprpm");
std::filesystem::permissions("/tmp/hyprpm", std::filesystem::perms::all, std::filesystem::perm_options::replace);
} else if (!std::filesystem::is_directory("/tmp/hyprpm")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for hyprpm\n";
if (!std::filesystem::exists(getTempRoot())) {
std::filesystem::create_directory(getTempRoot());
std::filesystem::permissions(getTempRoot(), std::filesystem::perms::owner_all, std::filesystem::perm_options::replace);
} else if (!std::filesystem::is_directory(getTempRoot())) {
std::println(stderr, "\n{}", failureString("Could not prepare working dir for hyprpm"));
return false;
}
const std::string USERNAME = getpwuid(getuid())->pw_name;
m_szWorkingPluginDirectory = "/tmp/hyprpm/" + USERNAME;
m_szWorkingPluginDirectory = getTempRoot() + USERNAME;
if (!createSafeDirectory(m_szWorkingPluginDirectory)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for repo\n";
std::println(stderr, "\n{}", failureString("Could not prepare working dir for repo"));
return false;
}
progress.printMessageAbove(std::string{Colors::RESET} + "Cloning " + url);
progress.printMessageAbove(infoString("Cloning {}", url));
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + url + " " + USERNAME);
std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), url, USERNAME));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. shell returned:\n" << ret << "\n";
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. shell returned:\n{}", ret));
return false;
}
if (!rev.empty()) {
std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules " + rev);
if (ret.compare(0, 6, "fatal:") == 0) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not check out revision " << rev << ". shell returned:\n" << ret << "\n";
std::println(stderr, "\n{}", failureString("Could not check out revision {}. shell returned:\n{}", rev, ret));
return false;
}
ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " submodule update --init");
if (m_bVerbose)
std::println("{}", verboseString("git submodule update --init returned: {}", ret));
}
progress.m_iSteps = 1;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " cloned");
progress.printMessageAbove(successString("cloned"));
progress.m_szCurrentMessage = "Reading the manifest";
progress.print();
std::unique_ptr<CManifest> pManifest;
if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprpm.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprpm manifest");
progress.printMessageAbove(successString("found hyprpm manifest"));
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, m_szWorkingPluginDirectory + "/hyprpm.toml");
} else if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprload.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprload manifest");
progress.printMessageAbove(successString("found hyprload manifest"));
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, m_szWorkingPluginDirectory + "/hyprload.toml");
}
if (!pManifest) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " The provided plugin repository does not have a valid manifest\n";
std::println(stderr, "\n{}", failureString("The provided plugin repository does not have a valid manifest"));
return false;
}
if (!pManifest->m_bGood) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " The provided plugin repository has a corrupted manifest\n";
std::println(stderr, "\n{}", failureString("The provided plugin repository has a corrupted manifest"));
return false;
}
progress.m_iSteps = 2;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " parsed manifest, found " + std::to_string(pManifest->m_vPlugins.size()) + " plugins:");
for (auto& pl : pManifest->m_vPlugins) {
std::string message = std::string{Colors::RESET} + " " + pl.name + " by ";
for (auto& a : pl.authors) {
progress.printMessageAbove(successString("parsed manifest, found " + std::to_string(pManifest->m_vPlugins.size()) + " plugins:"));
for (auto const& pl : pManifest->m_vPlugins) {
std::string message = "" + pl.name + " by ";
for (auto const& a : pl.authors) {
message += a + ", ";
}
if (pl.authors.size() > 0) {
@@ -217,15 +249,21 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
if (!pManifest->m_sRepository.commitPins.empty()) {
// check commit pins
progress.printMessageAbove(std::string{Colors::RESET} + "Manifest has " + std::to_string(pManifest->m_sRepository.commitPins.size()) + " pins, checking");
progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_sRepository.commitPins.size()));
for (auto& [hl, plugin] : pManifest->m_sRepository.commitPins) {
for (auto const& [hl, plugin] : pManifest->m_sRepository.commitPins) {
if (hl != HLVER.hash)
continue;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " commit pin " + plugin + " matched hl, resetting");
progress.printMessageAbove(successString("commit pin {} matched hl, resetting", plugin));
execAndGet("cd " + m_szWorkingPluginDirectory + " && git reset --hard --recurse-submodules " + plugin);
ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " submodule update --init");
if (m_bVerbose)
std::println("{}", verboseString("git submodule update --init returned: {}", ret));
break;
}
}
@@ -235,12 +273,12 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
const auto HEADERSSTATUS = headersValid();
if (HEADERSSTATUS != HEADERS_OK) {
std::cerr << "\n" << headerError(HEADERSSTATUS);
std::println("\n{}", headerError(HEADERSSTATUS));
return false;
}
progress.m_iSteps = 3;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " Hyprland headers OK");
progress.printMessageAbove(successString("Hyprland headers OK"));
progress.m_szCurrentMessage = "Building plugin(s)";
progress.print();
@@ -248,35 +286,36 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
std::string out;
if (p.since > HLVER.commits && HLVER.commits >= 1 /* for --depth 1 clones, we can't check this. */) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n");
progress.printMessageAbove(failureString("Not building {}: your Hyprland version is too old.\n", p.name));
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::RESET} + "Building " + p.name);
progress.printMessageAbove(infoString("Building {}", p.name));
for (auto& bs : p.buildSteps) {
std::string cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
for (auto const& bs : p.buildSteps) {
const std::string& cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
}
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
std::println("{}", verboseString("shell returned: {}", out));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/" + p.output)) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Plugin " + p.name + " failed to build.\n" +
" This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update "
"first.\n Try re-running with -v to see "
"more verbose output.\n");
progress.printMessageAbove(failureString("Plugin {} failed to build.\n"
" This likely means that the plugin is either outdated, not yet available for your version, or broken.\n"
" If you are on -git, update first\n"
" Try re-running with -v to see more verbose output.\n",
p.name));
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " built " + p.name + " into " + p.output);
progress.printMessageAbove(successString("built {} into {}", p.name, p.output));
}
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " all plugins built");
progress.printMessageAbove(successString("all plugins built"));
progress.m_iSteps = 4;
progress.m_szCurrentMessage = "Installing repository";
progress.print();
@@ -290,18 +329,18 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
repo.url = url;
repo.rev = rev;
repo.hash = repohash;
for (auto& p : pManifest->m_vPlugins) {
for (auto const& p : pManifest->m_vPlugins) {
repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed});
}
DataState::addNewPluginRepo(repo);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " installed repository");
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " you can now enable the plugin(s) with hyprpm enable");
progress.printMessageAbove(successString("installed repository"));
progress.printMessageAbove(successString("you can now enable the plugin(s) with hyprpm enable"));
progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Done!";
progress.print();
std::cout << "\n";
std::print("\n");
// remove build files
std::filesystem::remove_all(m_szWorkingPluginDirectory);
@@ -311,7 +350,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
if (!DataState::pluginRepoExists(urlOrName)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not remove the repository. Repository is not installed.\n";
std::println(stderr, "\n{}", failureString("Could not remove the repository. Repository is not installed."));
return false;
}
@@ -322,7 +361,7 @@ bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
std::getline(std::cin, input);
if (input.size() > 0 && input[0] != 'Y' && input[0] != 'y') {
std::cout << "Aborting.\n";
std::println("Aborting.");
return false;
}
@@ -332,21 +371,21 @@ bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
}
eHeadersErrors CPluginManager::headersValid() {
const auto HLVER = getHyprlandVersion();
const auto HLVER = getHyprlandVersion(false);
if (!std::filesystem::exists(DataState::getHeadersPath() + "/share/pkgconfig/hyprland.pc"))
return HEADERS_MISSING;
// find headers commit
std::string cmd = std::format("PKG_CONFIG_PATH=\"{}/share/pkgconfig\" pkgconf --cflags --keep-system-cflags hyprland", DataState::getHeadersPath());
auto headers = execAndGet(cmd.c_str());
const std::string& cmd = std::format("PKG_CONFIG_PATH=\"{}/share/pkgconfig\" pkgconf --cflags --keep-system-cflags hyprland", DataState::getHeadersPath());
auto headers = execAndGet(cmd.c_str());
if (!headers.contains("-I/"))
return HEADERS_MISSING;
headers.pop_back(); // pop newline
std::string verHeader = "";
std::string verHeader;
while (!headers.empty()) {
const auto PATH = headers.substr(0, headers.find(" -I/", 3));
@@ -356,7 +395,7 @@ eHeadersErrors CPluginManager::headersValid() {
else
headers = "";
if (PATH.ends_with("protocols") || PATH.ends_with("wlroots-hyprland"))
if (PATH.ends_with("protocols"))
continue;
verHeader = trim(PATH.substr(2)) + "/hyprland/src/version.h";
@@ -394,20 +433,20 @@ bool CPluginManager::updateHeaders(bool force) {
DataState::ensureStateStoreExists();
const auto HLVER = getHyprlandVersion();
const auto HLVER = getHyprlandVersion(false);
if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not update. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
std::println("\n{}", failureString("Could not update. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio, pkg-config"));
return false;
}
if (!std::filesystem::exists("/tmp/hyprpm")) {
std::filesystem::create_directory("/tmp/hyprpm");
std::filesystem::permissions("/tmp/hyprpm", std::filesystem::perms::all, std::filesystem::perm_options::replace);
if (!std::filesystem::exists(getTempRoot())) {
std::filesystem::create_directory(getTempRoot());
std::filesystem::permissions(getTempRoot(), std::filesystem::perms::owner_all, std::filesystem::perm_options::replace);
}
if (!force && headersValid() == HEADERS_OK) {
std::cout << "\n" << std::string{Colors::GREEN} + "" + Colors::RESET + " Headers up to date.\n";
std::println("\n{}", successString("Headers up to date."));
return true;
}
@@ -418,67 +457,76 @@ bool CPluginManager::updateHeaders(bool force) {
progress.print();
const std::string USERNAME = getpwuid(getuid())->pw_name;
const auto WORKINGDIR = "/tmp/hyprpm/hyprland-" + USERNAME;
const auto WORKINGDIR = getTempRoot() + "hyprland-" + USERNAME;
if (!createSafeDirectory(WORKINGDIR)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not prepare working dir for hl\n";
std::println("\n{}", failureString("Could not prepare working dir for hl"));
return false;
}
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " Cloning https://github.com/hyprwm/hyprland, this might take a moment.");
progress.printMessageAbove(statusString("!", Colors::YELLOW, "Cloning https://github.com/hyprwm/Hyprland, this might take a moment."));
const bool bShallow = (HLVER.branch == "main" || HLVER.branch == "") && !m_bNoShallow;
const bool bShallow = (HLVER.branch == "main") && !m_bNoShallow;
// let us give a bit of leg-room for shallowing
// due to timezones, etc.
const std::string SHALLOW_DATE =
trim(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+\%a \%b \%d \%H:\%M:\%S \%Y'");
const std::string SHALLOW_DATE = trim(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+%a %b %d %H:%M:%S %Y'");
if (m_bVerbose && bShallow)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "will shallow since: " + SHALLOW_DATE);
progress.printMessageAbove(verboseString("will shallow since: {}", SHALLOW_DATE));
std::string ret =
execAndGet("cd /tmp/hyprpm && git clone --recursive https://github.com/hyprwm/hyprland hyprland-" + USERNAME + (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""));
std::string ret = execAndGet(std::format("cd {} && git clone --recursive https://github.com/hyprwm/Hyprland hyprland-{}{}", getTempRoot(), USERNAME,
(bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : "")));
if (!std::filesystem::exists(WORKINGDIR)) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Clone failed. Retrying without shallow.");
ret = execAndGet("cd /tmp/hyprpm && git clone --recursive https://github.com/hyprwm/hyprland hyprland-" + USERNAME);
progress.printMessageAbove(failureString("Clone failed. Retrying without shallow."));
ret = execAndGet(std::format("cd {} && git clone --recursive https://github.com/hyprwm/hyprland hyprland-{}", getTempRoot(), USERNAME));
}
if (!std::filesystem::exists(WORKINGDIR + "/.git")) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the hyprland repository. shell returned:\n" << ret << "\n";
std::println(stderr, "\n{}", failureString("Could not clone the Hyprland repository. shell returned:\n{}", ret));
return false;
}
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " cloned");
progress.printMessageAbove(successString("Hyprland cloned"));
progress.m_iSteps = 2;
progress.m_szCurrentMessage = "Checking out sources";
progress.print();
ret = execAndGet("cd " + WORKINGDIR + " && git checkout " + HLVER.branch + " 2>&1");
if (m_bVerbose)
progress.printMessageAbove(verboseString("will run: cd {} && git checkout {} 2>&1", WORKINGDIR, HLVER.hash));
ret = execAndGet("cd " + WORKINGDIR + " && git checkout " + HLVER.hash + " 2>&1");
if (ret.contains("fatal: unable to read tree")) {
std::println(stderr, "\n{}",
failureString("Could not checkout the running Hyprland commit. If you are on -git, try updating.\n"
"You can also try re-running hyprpm update with --no-shallow."));
return false;
}
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "git returned (co): " + ret);
progress.printMessageAbove(verboseString("git returned (co): {}", ret));
ret = execAndGet("cd " + WORKINGDIR + " && git rm subprojects/tracy && git submodule update --init 2>&1 && git reset --hard --recurse-submodules " + HLVER.hash);
ret = execAndGet("cd " + WORKINGDIR + " ; git rm subprojects/tracy ; git submodule update --init 2>&1 ; git reset --hard --recurse-submodules " + HLVER.hash);
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "git returned (rs): " + ret);
progress.printMessageAbove(verboseString("git returned (rs): {}", ret));
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " checked out to running ver");
progress.printMessageAbove(successString("checked out to running ver"));
progress.m_iSteps = 3;
progress.m_szCurrentMessage = "Building Hyprland";
progress.print();
progress.printMessageAbove(std::string{Colors::YELLOW} + "!" + Colors::RESET + " configuring Hyprland");
progress.printMessageAbove(statusString("!", Colors::YELLOW, "configuring Hyprland"));
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "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,
DataState::getHeadersPath()));
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "cmake returned: " + ret);
progress.printMessageAbove(verboseString("cmake returned: {}", ret));
if (ret.contains("CMake Error at")) {
// missing deps, let the user know.
@@ -487,52 +535,46 @@ bool CPluginManager::updateHeaders(bool force) {
missing = missing.substr(0, missing.find("-- Configuring incomplete"));
missing = missing.substr(0, missing.find_last_of('\n'));
std::cerr << "\n"
<< Colors::RED << "" << Colors::RESET << " Could not configure the hyprland source, cmake complained:\n"
<< missing << "\n\nThis likely means that you are missing the above dependencies or they are out of date.\n";
std::println(stderr, "\n{}",
failureString("Could not configure the hyprland source, cmake complained:\n{}\n\n"
"This likely means that you are missing the above dependencies or they are out of date.",
missing));
return false;
}
// le hack. Wlroots has to generate its build/include
ret = execAndGet("cd " + WORKINGDIR + "/subprojects/wlroots-hyprland && meson setup -Drenderers=gles2 -Dexamples=false build");
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "meson returned: " + ret);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " configured Hyprland");
progress.printMessageAbove(successString("configured Hyprland"));
progress.m_iSteps = 4;
progress.m_szCurrentMessage = "Installing sources";
progress.print();
std::string cmd =
const std::string& cmd =
std::format("sed -i -e \"s#PREFIX = /usr/local#PREFIX = {}#\" {}/Makefile && cd {} && make installheaders", DataState::getHeadersPath(), WORKINGDIR, WORKINGDIR);
if (m_bVerbose)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "installation will run: " + cmd);
progress.printMessageAbove(verboseString("installation will run: {}", cmd));
ret = execAndGet(cmd);
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "installer returned: " << ret << "\n";
std::println("{}", verboseString("installer returned: {}", ret));
// remove build files
std::filesystem::remove_all(WORKINGDIR);
auto HEADERSVALID = headersValid();
if (HEADERSVALID == HEADERS_OK) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " installed headers");
progress.printMessageAbove(successString("installed headers"));
progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Done!";
progress.print();
std::cout << "\n";
std::print("\n");
} else {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " failed to install headers with error code " + std::to_string((int)HEADERSVALID));
progress.printMessageAbove(failureString("failed to install headers with error code {} ({})", (int)HEADERSVALID, headerErrorShort(HEADERSVALID)));
progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Failed";
progress.print();
std::cout << "\n";
std::cerr << "\n" << headerError(HEADERSVALID);
std::print(stderr, "\n\n{}", headerError(HEADERSVALID));
return false;
}
@@ -542,18 +584,18 @@ bool CPluginManager::updateHeaders(bool force) {
bool CPluginManager::updatePlugins(bool forceUpdateAll) {
if (headersValid() != HEADERS_OK) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " headers are not up-to-date, please run hyprpm update.\n";
std::println("{}", failureString("headers are not up-to-date, please run hyprpm update."));
return false;
}
const auto REPOS = DataState::getAllRepositories();
if (REPOS.size() < 1) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " No repos to update.\n";
std::println("{}", failureString("No repos to update."));
return true;
}
const auto HLVER = getHyprlandVersion();
const auto HLVER = getHyprlandVersion(false);
CProgressBar progress;
progress.m_iMaxSteps = REPOS.size() * 2 + 2;
@@ -562,34 +604,35 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.print();
const std::string USERNAME = getpwuid(getuid())->pw_name;
m_szWorkingPluginDirectory = "/tmp/hyprpm/" + USERNAME;
m_szWorkingPluginDirectory = getTempRoot() + USERNAME;
for (auto& repo : REPOS) {
for (auto const& repo : REPOS) {
bool update = forceUpdateAll;
progress.m_iSteps++;
progress.m_szCurrentMessage = "Updating " + repo.name;
progress.print();
progress.printMessageAbove(std::string{Colors::RESET} + "checking for updates for " + repo.name);
progress.printMessageAbove(infoString("checking for updates for {}", repo.name));
createSafeDirectory(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::RESET} + "Cloning " + repo.url);
progress.printMessageAbove(infoString("Cloning {}", repo.url));
std::string ret = execAndGet("cd /tmp/hyprpm && git clone --recursive " + repo.url + " " + USERNAME);
std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), repo.url, USERNAME));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " could not clone repo: shell returned:\n" + ret;
std::println("{}", failureString("could not clone repo: shell returned: {}", ret));
return false;
}
if (!repo.rev.empty()) {
progress.printMessageAbove(std::string{Colors::RESET} + "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);
if (ret.compare(0, 6, "fatal:") == 0) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " could not check out revision " + repo.rev + ": shell returned:\n" + ret;
std::println(stderr, "\n{}", failureString("could not check out revision {}: shell returned:\n{}", repo.rev, ret));
return false;
}
}
@@ -605,7 +648,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
if (!update) {
std::filesystem::remove_all(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " repository " + repo.name + " is up-to-date.");
progress.printMessageAbove(successString("repository {} is up-to-date.", repo.name));
progress.m_iSteps++;
progress.print();
continue;
@@ -613,41 +656,41 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
// we need to update
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " repository " + repo.name + " has updates.");
progress.printMessageAbove(std::string{Colors::RESET} + "Building " + repo.name);
progress.printMessageAbove(successString("repository {} has updates.", repo.name));
progress.printMessageAbove(infoString("Building {}", repo.name));
progress.m_iSteps++;
progress.print();
std::unique_ptr<CManifest> pManifest;
if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprpm.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprpm manifest");
progress.printMessageAbove(successString("found hyprpm manifest"));
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRPM, m_szWorkingPluginDirectory + "/hyprpm.toml");
} else if (std::filesystem::exists(m_szWorkingPluginDirectory + "/hyprload.toml")) {
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " found hyprload manifest");
progress.printMessageAbove(successString("found hyprload manifest"));
pManifest = std::make_unique<CManifest>(MANIFEST_HYPRLOAD, m_szWorkingPluginDirectory + "/hyprload.toml");
}
if (!pManifest) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " The provided plugin repository does not have a valid manifest\n";
std::println(stderr, "\n{}", failureString("The provided plugin repository does not have a valid manifest"));
continue;
}
if (!pManifest->m_bGood) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " The provided plugin repository has a corrupted manifest\n";
std::println(stderr, "\n{}", failureString("The provided plugin repository has a corrupted manifest"));
continue;
}
if (repo.rev.empty() && !pManifest->m_sRepository.commitPins.empty()) {
// check commit pins unless a revision is specified
progress.printMessageAbove(std::string{Colors::RESET} + "Manifest has " + std::to_string(pManifest->m_sRepository.commitPins.size()) + " pins, checking");
progress.printMessageAbove(infoString("Manifest has {} pins, checking", pManifest->m_sRepository.commitPins.size()));
for (auto& [hl, plugin] : pManifest->m_sRepository.commitPins) {
for (auto const& [hl, plugin] : pManifest->m_sRepository.commitPins) {
if (hl != HLVER.hash)
continue;
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " commit pin " + plugin + " matched hl, resetting");
progress.printMessageAbove(successString("commit pin {} matched hl, resetting", plugin));
execAndGet("cd " + m_szWorkingPluginDirectory + " && git reset --hard --recurse-submodules " + plugin);
}
@@ -657,32 +700,33 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
std::string out;
if (p.since > HLVER.commits && HLVER.commits >= 1000 /* for shallow clones, we can't check this. 1000 is an arbitrary number I chose. */) {
progress.printMessageAbove(std::string{Colors::RED} + "" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n");
progress.printMessageAbove(failureString("Not building {}: your Hyprland version is too old.\n", p.name));
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::RESET} + "Building " + p.name);
progress.printMessageAbove(infoString("Building {}", p.name));
for (auto& bs : p.buildSteps) {
std::string cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
for (auto const& bs : p.buildSteps) {
const std::string& cmd = std::format("cd {} && PKG_CONFIG_PATH=\"{}/share/pkgconfig\" {}", m_szWorkingPluginDirectory, DataState::getHeadersPath(), bs);
out += " -> " + cmd + "\n" + execAndGet(cmd) + "\n";
}
if (m_bVerbose)
std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n";
std::println("{}", verboseString("shell returned: {}", out));
if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/" + p.output)) {
std::cerr << "\n"
<< Colors::RED << "" << Colors::RESET << " Plugin " << p.name << " failed to build.\n"
<< " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update first.\n Try "
"re-running with -v to see more verbose "
"output.\n";
std::println(stderr,
"\n{}\n"
" This likely means that the plugin is either outdated, not yet available for your version, or broken.\n"
"If you are on -git, update first.\n"
"Try re-running with -v to see more verbose output.",
failureString("Plugin {} failed to build.", p.name));
p.failed = true;
continue;
}
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " built " + p.name + " into " + p.output);
progress.printMessageAbove(successString("built {} into {}", p.name, p.output));
}
// add repo toml to DataState
@@ -694,7 +738,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
if (repohash.length() > 0)
repohash.pop_back();
newrepo.hash = repohash;
for (auto& p : pManifest->m_vPlugins) {
for (auto const& p : pManifest->m_vPlugins) {
const auto OLDPLUGINIT = std::find_if(repo.plugins.begin(), repo.plugins.end(), [&](const auto& other) { return other.name == p.name; });
newrepo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
}
@@ -703,7 +747,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
std::filesystem::remove_all(m_szWorkingPluginDirectory);
progress.printMessageAbove(std::string{Colors::GREEN} + "" + Colors::RESET + " updated " + repo.name);
progress.printMessageAbove(successString("updated {}", repo.name));
}
progress.m_iSteps++;
@@ -718,7 +762,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
progress.m_szCurrentMessage = "Done!";
progress.print();
std::cout << "\n";
std::print("\n");
return true;
}
@@ -726,27 +770,27 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
bool CPluginManager::enablePlugin(const std::string& name) {
bool ret = DataState::setPluginEnabled(name, true);
if (ret)
std::cout << Colors::GREEN << "" << Colors::RESET << " Enabled " << name << "\n";
std::println("{}", successString("Enabled {}", name));
return ret;
}
bool CPluginManager::disablePlugin(const std::string& name) {
bool ret = DataState::setPluginEnabled(name, false);
if (ret)
std::cout << Colors::GREEN << "" << Colors::RESET << " Disabled " << name << "\n";
std::println("{}", successString("Disabled {}", name));
return ret;
}
ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() {
if (headersValid() != HEADERS_OK) {
std::cerr << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " headers are not up-to-date, please run hyprpm update.\n";
std::println(stderr, "\n{}", failureString("headers are not up-to-date, please run hyprpm update."));
return LOADSTATE_HEADERS_OUTDATED;
}
const auto HOME = getenv("HOME");
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!HOME || !HIS) {
std::cerr << "PluginManager: no $HOME or HIS\n";
std::println(stderr, "PluginManager: no $HOME or HIS");
return LOADSTATE_FAIL;
}
const auto HYPRPMPATH = DataState::getDataStatePath() + "/";
@@ -755,14 +799,14 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() {
std::vector<std::string> loadedPlugins;
std::cout << Colors::GREEN << "" << Colors::RESET << " Ensuring plugin load state\n";
std::println("{}", successString("Ensuring plugin load state"));
// iterate line by line
while (!pluginLines.empty()) {
auto plLine = pluginLines.substr(0, pluginLines.find("\n"));
auto plLine = pluginLines.substr(0, pluginLines.find('\n'));
if (pluginLines.find("\n") != std::string::npos)
pluginLines = pluginLines.substr(pluginLines.find("\n") + 1);
if (pluginLines.find('\n') != std::string::npos)
pluginLines = pluginLines.substr(pluginLines.find('\n') + 1);
else
pluginLines = "";
@@ -779,8 +823,8 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() {
const auto REPOS = DataState::getAllRepositories();
auto enabled = [REPOS](const std::string& plugin) -> bool {
for (auto& r : REPOS) {
for (auto& p : r.plugins) {
for (auto const& r : REPOS) {
for (auto const& p : r.plugins) {
if (p.name == plugin && p.enabled)
return true;
}
@@ -790,8 +834,8 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() {
};
auto repoForName = [REPOS](const std::string& name) -> std::string {
for (auto& r : REPOS) {
for (auto& p : r.plugins) {
for (auto const& r : REPOS) {
for (auto const& p : r.plugins) {
if (p.name == name)
return r.name;
}
@@ -800,35 +844,54 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() {
return "";
};
// if any of the loadUnloadPlugin calls return false, this is true
// bcs that means the header version doesn't match the running version
// (and Hyprland needs to restart)
bool hyprlandVersionMismatch = false;
// unload disabled plugins
for (auto& p : loadedPlugins) {
for (auto const& p : loadedPlugins) {
if (!enabled(p)) {
// unload
loadUnloadPlugin(HYPRPMPATH + repoForName(p) + "/" + p + ".so", false);
std::cout << Colors::GREEN << "" << Colors::RESET << " Unloaded " << p << "\n";
if (!loadUnloadPlugin(HYPRPMPATH + repoForName(p) + "/" + p + ".so", false)) {
std::println("{}", infoString("{} will be unloaded after restarting Hyprland", p));
hyprlandVersionMismatch = true;
} else
std::println("{}", successString("Unloaded {}", p));
}
}
// load enabled plugins
for (auto& r : REPOS) {
for (auto& p : r.plugins) {
for (auto const& r : REPOS) {
for (auto const& p : r.plugins) {
if (!p.enabled)
continue;
if (std::find_if(loadedPlugins.begin(), loadedPlugins.end(), [&](const auto& other) { return other == p.name; }) != loadedPlugins.end())
continue;
loadUnloadPlugin(HYPRPMPATH + repoForName(p.name) + "/" + p.filename, true);
std::cout << Colors::GREEN << "" << Colors::RESET << " Loaded " << p.name << "\n";
if (!loadUnloadPlugin(HYPRPMPATH + repoForName(p.name) + "/" + p.filename, true)) {
std::println("{}", infoString("{} will be loaded after restarting Hyprland", p.name));
hyprlandVersionMismatch = true;
} else
std::println("{}", successString("Loaded {}", p.name));
}
}
std::cout << Colors::GREEN << "" << Colors::RESET << " Plugin load state ensured\n";
std::println("{}", successString("Plugin load state ensured"));
return LOADSTATE_OK;
return hyprlandVersionMismatch ? LOADSTATE_HYPRLAND_UPDATED : LOADSTATE_OK;
}
bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) {
auto state = DataState::getGlobalState();
auto HLVER = getHyprlandVersion(true);
if (state.headersHashCompiled != HLVER.hash) {
std::println("{}", infoString("Running Hyprland version differs from plugin state, please restart Hyprland."));
return false;
}
if (load)
execAndGet("hyprctl plugin load " + path);
else
@@ -840,17 +903,18 @@ bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) {
void CPluginManager::listAllPlugins() {
const auto REPOS = DataState::getAllRepositories();
for (auto& r : REPOS) {
std::cout << std::string{Colors::RESET} + "Repository " + r.name + ":\n";
for (auto const& r : REPOS) {
std::println("{}", infoString("Repository {}:", r.name));
for (auto& p : r.plugins) {
std::cout << std::string{Colors::RESET} + " │ Plugin " + p.name;
for (auto const& p : r.plugins) {
std::println(" │ Plugin {}", p.name);
if (!p.failed)
std::cout << "\n └─ enabled: " << (p.enabled ? Colors::GREEN : Colors::RED) << (p.enabled ? "true" : "false") << Colors::RESET << "\n";
std::println(" └─ enabled: {}", (p.enabled ? std::string{Colors::GREEN} + "true" : std::string{Colors::RED} + "false"));
else
std::cout << "\n └─ enabled: " << Colors::RED << "Plugin failed to build" << Colors::RESET << "\n";
std::println(" └─ enabled: {}Plugin failed to build", Colors::RED);
std::println("{}", Colors::RESET);
}
}
}
@@ -861,25 +925,37 @@ void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int duratio
std::string CPluginManager::headerError(const eHeadersErrors err) {
switch (err) {
case HEADERS_CORRUPTED: return std::string{Colors::RED} + "" + Colors::RESET + " Headers corrupted. Please run hyprpm update to fix those.\n";
case HEADERS_MISMATCHED: return std::string{Colors::RED} + "" + Colors::RESET + " Headers version mismatch. Please run hyprpm update to fix those.\n";
case HEADERS_NOT_HYPRLAND: return std::string{Colors::RED} + "" + Colors::RESET + " It doesn't seem you are running on hyprland.\n";
case HEADERS_MISSING: return std::string{Colors::RED} + "" + Colors::RESET + " Headers missing. Please run hyprpm update to fix those.\n";
case HEADERS_CORRUPTED: return failureString("Headers corrupted. 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_MISSING: return failureString("Headers missing. Please run hyprpm update to fix those.\n");
case HEADERS_DUPLICATED: {
return std::string{Colors::RED} + "" + Colors::RESET + " 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" +
" If the above doesn't apply, check your /usr/include and /usr/local/include directories\n and remove all the hyprland headers.\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"
"If the above doesn't apply, check your /usr/include and /usr/local/include directories\n and remove all the hyprland headers.\n");
}
default: break;
}
return std::string{Colors::RED} + "" + Colors::RESET + " Unknown header error. Please run hyprpm update to fix those.\n";
return failureString("Unknown header error. Please run hyprpm update to fix those.\n");
}
std::string CPluginManager::headerErrorShort(const eHeadersErrors err) {
switch (err) {
case HEADERS_CORRUPTED: return "Headers corrupted";
case HEADERS_MISMATCHED: return "Headers version mismatched";
case HEADERS_NOT_HYPRLAND: return "Not running on Hyprland";
case HEADERS_MISSING: return "Headers missing";
case HEADERS_DUPLICATED: return "Headers duplicated";
default: break;
}
return "?";
}
bool CPluginManager::hasDeps() {
std::vector<std::string> deps = {"meson", "cpio", "cmake"};
for (auto& d : deps) {
if (!execAndGet("which " + d + " 2>&1").contains("/"))
std::vector<std::string> deps = {"meson", "cpio", "cmake", "pkg-config"};
for (auto const& d : deps) {
if (!execAndGet("command -v " + d).contains("/"))
return false;
}

View File

@@ -2,6 +2,7 @@
#include <memory>
#include <string>
#include <utility>
enum eHeadersErrors {
HEADERS_OK = 0,
@@ -26,7 +27,8 @@ enum ePluginLoadStateReturn {
LOADSTATE_OK = 0,
LOADSTATE_FAIL,
LOADSTATE_PARTIAL_FAIL,
LOADSTATE_HEADERS_OUTDATED
LOADSTATE_HEADERS_OUTDATED,
LOADSTATE_HYPRLAND_UPDATED
};
struct SHyprlandVersion {
@@ -52,7 +54,7 @@ class CPluginManager {
ePluginLoadStateReturn ensurePluginsLoadState();
bool loadUnloadPlugin(const std::string& path, bool load);
SHyprlandVersion getHyprlandVersion();
SHyprlandVersion getHyprlandVersion(bool running = true);
void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message);
@@ -66,8 +68,9 @@ class CPluginManager {
private:
std::string headerError(const eHeadersErrors err);
std::string headerErrorShort(const eHeadersErrors err);
std::string m_szWorkingPluginDirectory = "";
std::string m_szWorkingPluginDirectory;
};
inline std::unique_ptr<CPluginManager> g_pPluginManager;

View File

@@ -0,0 +1,32 @@
#pragma once
#include <format>
#include <string>
#include "Colors.hpp"
template <typename... Args>
std::string statusString(const std::string_view emoji, const std::string_view color, const std::string_view fmt, Args&&... args) {
std::string ret = std::format("{}{}{} ", color, emoji, Colors::RESET);
ret += std::vformat(fmt, std::make_format_args(args...));
return ret;
}
template <typename... Args>
std::string successString(const std::string_view fmt, Args&&... args) {
return statusString("", Colors::GREEN, fmt, args...);
}
template <typename... Args>
std::string failureString(const std::string_view fmt, Args&&... args) {
return statusString("", Colors::RED, fmt, args...);
}
template <typename... Args>
std::string verboseString(const std::string_view fmt, Args&&... args) {
return statusString("[v]", Colors::BLUE, fmt, args...);
}
template <typename... Args>
std::string infoString(const std::string_view fmt, Args&&... args) {
return statusString("", Colors::RESET, fmt, args...);
}

View File

@@ -1,15 +1,16 @@
#include "progress/CProgressBar.hpp"
#include "helpers/Colors.hpp"
#include "helpers/StringUtils.hpp"
#include "core/PluginManager.hpp"
#include "core/DataState.hpp"
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <print>
#include <chrono>
#include <thread>
const std::string 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
is optional, when set, commit locks are ignored.
@@ -22,7 +23,8 @@ const std::string HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
Flags:
--notify | -n Send a hyprland notification for important events (e.g. load fail)
--notify | -n Send a hyprland notification for important events (including both successes and fail events)
--notify-fail | -nn Send a hyprland notification for fail events only
--help | -h Show this menu
--verbose | -v Enable too much logging
--force | -f Force an operation ignoring checks (e.g. update -f)
@@ -30,36 +32,38 @@ const std::string HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
)#";
int main(int argc, char** argv, char** envp) {
int main(int argc, char** argv, char** envp) {
std::vector<std::string> ARGS{argc};
for (int i = 0; i < argc; ++i) {
ARGS[i] = std::string{argv[i]};
}
if (ARGS.size() < 2) {
std::cout << HELP;
std::println(stderr, "{}", HELP);
return 1;
}
std::vector<std::string> command;
bool notify = false, verbose = false, force = false, noShallow = false;
bool notify = false, notifyFail = false, verbose = false, force = false, noShallow = false;
for (int i = 1; i < argc; ++i) {
if (ARGS[i].starts_with("-")) {
if (ARGS[i] == "--help" || ARGS[i] == "-h") {
std::cout << HELP;
std::println("{}", HELP);
return 0;
} else if (ARGS[i] == "--notify" || ARGS[i] == "-n") {
notify = true;
} else if (ARGS[i] == "--notify-fail" || ARGS[i] == "-nn") {
notifyFail = notify = true;
} else if (ARGS[i] == "--verbose" || ARGS[i] == "-v") {
verbose = true;
} else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") {
noShallow = true;
} else if (ARGS[i] == "--force" || ARGS[i] == "-f") {
force = true;
std::cout << Colors::RED << "!" << Colors::RESET << " Using --force, I hope you know what you are doing.\n";
std::println("{}", statusString("!", Colors::RED, "Using --force, I hope you know what you are doing."));
} else {
std::cerr << "Unrecognized option " << ARGS[i] << "\n";
std::println(stderr, "Unrecognized option {}", ARGS[i]);
return 1;
}
} else {
@@ -68,8 +72,8 @@ int main(int argc, char** argv, char** envp) {
}
if (command.empty()) {
std::cout << HELP;
return 0;
std::println(stderr, "{}", HELP);
return 1;
}
g_pPluginManager = std::make_unique<CPluginManager>();
@@ -78,7 +82,7 @@ int main(int argc, char** argv, char** envp) {
if (command[0] == "add") {
if (command.size() < 2) {
std::cerr << Colors::RED << "" << Colors::RESET << " Not enough args for add.\n";
std::println(stderr, "{}", failureString("Not enough args for add."));
return 1;
}
@@ -90,7 +94,7 @@ int main(int argc, char** argv, char** envp) {
return g_pPluginManager->addNewPluginRepo(command[1], rev) ? 0 : 1;
} else if (command[0] == "remove") {
if (ARGS.size() < 2) {
std::cerr << Colors::RED << "" << Colors::RESET << " Not enough args for remove.\n";
std::println(stderr, "{}", failureString("Not enough args for remove."));
return 1;
}
@@ -99,7 +103,7 @@ int main(int argc, char** argv, char** envp) {
bool headersValid = g_pPluginManager->headersValid() == HEADERS_OK;
bool headers = g_pPluginManager->updateHeaders(force);
if (headers) {
const auto HLVER = g_pPluginManager->getHyprlandVersion();
const auto HLVER = g_pPluginManager->getHyprlandVersion(false);
auto GLOBALSTATE = DataState::getGlobalState();
const auto COMPILEDOUTDATED = HLVER.hash != GLOBALSTATE.headersHashCompiled;
@@ -110,32 +114,39 @@ int main(int argc, char** argv, char** envp) {
auto ret2 = g_pPluginManager->ensurePluginsLoadState();
if (ret2 == LOADSTATE_HYPRLAND_UPDATED)
g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] Updated plugins, but Hyprland was updated. Please restart Hyprland.");
if (ret2 != LOADSTATE_OK)
return 1;
} else if (notify)
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Couldn't update headers");
} else if (command[0] == "enable") {
if (ARGS.size() < 2) {
std::cerr << Colors::RED << "" << Colors::RESET << " Not enough args for enable.\n";
std::println(stderr, "{}", failureString("Not enough args for enable."));
return 1;
}
if (!g_pPluginManager->enablePlugin(command[1])) {
std::cerr << Colors::RED << "" << Colors::RESET << " Couldn't enable plugin (missing?)\n";
std::println(stderr, "{}", failureString("Couldn't enable plugin (missing?)"));
return 1;
}
auto ret = g_pPluginManager->ensurePluginsLoadState();
if (ret == LOADSTATE_HYPRLAND_UPDATED)
g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] Enabled plugin, but Hyprland was updated. Please restart Hyprland.");
if (ret != LOADSTATE_OK)
return 1;
} else if (command[0] == "disable") {
if (command.size() < 2) {
std::cerr << Colors::RED << "" << Colors::RESET << " Not enough args for disable.\n";
std::println(stderr, "{}", failureString("Not enough args for disable."));
return 1;
}
if (!g_pPluginManager->disablePlugin(command[1])) {
std::cerr << Colors::RED << "" << Colors::RESET << " Couldn't disable plugin (missing?)\n";
std::println(stderr, "{}", failureString("Couldn't disable plugin (missing?)"));
return 1;
}
@@ -154,15 +165,16 @@ int main(int argc, char** argv, char** envp) {
break;
default: break;
}
} else if (notify) {
return 1;
} else if (notify && !notifyFail) {
g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins");
}
} else if (command[0] == "list") {
g_pPluginManager->listAllPlugins();
} else {
std::cout << HELP;
std::println(stderr, "{}", HELP);
return 1;
}
return 0;
}
}

View File

@@ -1,15 +1,31 @@
globber = run_command('sh', '-c', 'find . -name "*.cpp" | sort', check: true)
src = globber.stdout().strip().split('\n')
executable('hyprpm', src,
executable(
'hyprpm',
src,
dependencies: [
dependency('hyprutils', version: '>= 0.1.1'),
dependency('threads'),
dependency('tomlplusplus')
dependency('tomlplusplus'),
],
install : true
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')
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,11 +1,11 @@
#include "CProgressBar.hpp"
#include <iostream>
#include <sys/ioctl.h>
#include <algorithm>
#include <cmath>
#include <format>
#include <sys/ioctl.h>
#include <print>
#include <stdio.h>
#include <unistd.h>
@@ -16,11 +16,12 @@ void CProgressBar::printMessageAbove(const std::string& msg) {
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
std::string spaces;
spaces.reserve(w.ws_col);
for (size_t i = 0; i < w.ws_col; ++i) {
spaces += ' ';
}
std::cout << "\r" << spaces << "\r" << msg << "\n";
std::println("\r{}\r{}", spaces, msg);
print();
}
@@ -29,15 +30,16 @@ void CProgressBar::print() {
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
if (m_bFirstPrint)
std::cout << "\n";
std::print("\n");
m_bFirstPrint = false;
std::string spaces;
spaces.reserve(w.ws_col);
for (size_t i = 0; i < w.ws_col; ++i) {
spaces += ' ';
}
std::cout << "\r" << spaces << "\r";
std::print("\r{}\r", spaces);
std::string message = "";
@@ -74,7 +76,7 @@ void CProgressBar::print() {
message += " " + std::format("{} / {}", m_iSteps, m_iMaxSteps) + " ";
// draw message
std::cout << message + " " + m_szCurrentMessage;
std::print("{} {}", message, m_szCurrentMessage);
std::fflush(stdout);
}
}

View File

@@ -14,4 +14,4 @@ class CProgressBar {
private:
bool m_bFirstPrint = true;
};
};

View File

@@ -1,31 +1,47 @@
project('Hyprland', 'cpp', 'c',
version : run_command('jq', '-r', '.version', join_paths(meson.source_root(), 'props.json'), check: true).stdout().strip(),
default_options : [
project(
'Hyprland',
'cpp',
'c',
version: run_command('cat', join_paths(meson.project_source_root(), 'VERSION'), check: true).stdout().strip(),
default_options: [
'warning_level=2',
'default_library=static',
'optimization=3',
'buildtype=release',
'debug=false',
'cpp_std=c++23',
])
'cpp_std=c++26',
],
)
datarootdir = '-DDATAROOTDIR="' + get_option('prefix') / get_option('datadir') + '"'
add_project_arguments(
[
'-Wno-unused-parameter',
'-Wno-unused-value',
'-Wno-missing-field-initializers',
'-Wno-narrowing',
'-Wno-pointer-arith',
'-Wno-pointer-arith', datarootdir,
'-DHYPRLAND_VERSION="' + meson.project_version() + '"',
],
language: 'cpp')
language: 'cpp',
)
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.check_header('execinfo.h')
add_project_arguments('-DHAS_EXECINFO', language: 'cpp')
endif
wlroots = subproject('wlroots-hyprland', default_options: ['examples=false', 'renderers=gles2'])
have_xwlr = wlroots.get_variable('features').get('xwayland')
aquamarine = dependency('aquamarine', version: '>=0.4.5')
hyprcursor = dependency('hyprcursor', version: '>=0.1.7')
hyprgraphics = dependency('hyprgraphics', version: '>= 0.1.1')
hyprlang = dependency('hyprlang', version: '>= 0.3.2')
hyprutils = dependency('hyprutils', version: '>= 0.2.3')
add_project_arguments(['-DAQUAMARINE_VERSION="@0@"'.format(aquamarine.version())], language: 'cpp')
add_project_arguments(['-DHYPRCURSOR_VERSION="@0@"'.format(hyprcursor.version())], language: 'cpp')
add_project_arguments(['-DHYPRGRAPHICS_VERSION="@0@"'.format(hyprgraphics.version())], language: 'cpp')
add_project_arguments(['-DHYPRLANG_VERSION="@0@"'.format(hyprlang.version())], language: 'cpp')
add_project_arguments(['-DHYPRUTILS_VERSION="@0@"'.format(hyprutils.version())], language: 'cpp')
xcb_dep = dependency('xcb', required: get_option('xwayland'))
xcb_composite_dep = dependency('xcb-composite', required: get_option('xwayland'))
xcb_errors_dep = dependency('xcb-errors', required: get_option('xwayland'))
@@ -34,24 +50,26 @@ xcb_render_dep = dependency('xcb-render', required: get_option('xwayland'))
xcb_res_dep = dependency('xcb-res', required: get_option('xwayland'))
xcb_xfixes_dep = dependency('xcb-xfixes', required: get_option('xwayland'))
cmake = import('cmake')
udis = cmake.subproject('udis86')
udis86 = udis.dependency('libudis86')
gio_dep = dependency('gio-2.0', required: true)
if get_option('xwayland').enabled() and not have_xwlr
error('Cannot enable Xwayland in Hyprland: wlroots has been built without Xwayland support')
endif
have_xwayland = xcb_dep.found() and have_xwlr
if not have_xwayland
if not xcb_dep.found()
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
endif
backtrace_dep = cpp_compiler.find_library('execinfo', required: false)
epoll_dep = dependency('epoll-shim', required: false) # timerfd on BSDs
if get_option('systemd').enabled()
re2 = dependency('re2', required: true)
# Handle options
systemd_option = get_option('systemd')
systemd = dependency('systemd', required: systemd_option)
systemd_option.enable_auto_if(systemd.found())
if (systemd_option.enabled())
message('Enabling systemd integration')
add_project_arguments('-DUSES_SYSTEMD', language: 'cpp')
subdir('systemd')
endif
if get_option('legacy_renderer').enabled()
@@ -62,14 +80,24 @@ if get_option('buildtype') == 'debug'
add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp')
endif
version_h = run_command('sh', '-c', 'scripts/generateVersion.sh', check: true)
# Generate hyprland version and populate version.h
run_command('sh', '-c', 'scripts/generateVersion.sh', check: true)
# Install headers
globber = run_command('find', 'src', '-name', '*.h*', check: true)
headers = globber.stdout().strip().split('\n')
foreach file : headers
install_headers(file, subdir: 'hyprland', preserve_path: true)
endforeach
tracy = dependency('tracy', static: true, required: get_option('tracy_enable'))
if get_option('tracy_enable') and get_option('buildtype') != 'debugoptimized'
warning('Profiling builds should set -- buildtype = debugoptimized')
endif
subdir('protocols')
subdir('src')
subdir('hyprctl')
@@ -78,6 +106,7 @@ subdir('assets')
subdir('example')
subdir('docs')
# Generate hyprland.pc
pkg_install_dir = join_paths(get_option('datadir'), 'pkgconfig')
import('pkgconfig').generate(
@@ -86,5 +115,5 @@ import('pkgconfig').generate(
url: 'https://github.com/hyprwm/Hyprland',
description: 'Hyprland header files',
install_dir: pkg_install_dir,
subdirs: ['', 'hyprland/protocols', 'hyprland', 'hyprland/wlr'],
subdirs: ['', 'hyprland/protocols', 'hyprland'],
)

View File

@@ -1,3 +1,5 @@
option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
option('systemd', type: 'feature', value: 'auto', description: 'Enable systemd integration')
option('uwsm', type: 'feature', value: 'enabled', description: 'Enable uwsm integration (only if systemd is enabled)')
option('legacy_renderer', type: 'feature', value: 'disabled', description: 'Enable legacy renderer')
option('tracy_enable', type: 'boolean', value: false , description: 'Enable profiling')

View File

@@ -1,43 +1,36 @@
{
lib,
stdenv,
stdenvAdapters,
pkg-config,
pkgconf,
makeWrapper,
cmake,
meson,
ninja,
aquamarine,
binutils,
cairo,
expat,
fribidi,
git,
hwdata,
hyprcursor,
hyprgraphics,
hyprland-protocols,
hyprland-qtutils,
hyprlang,
hyprutils,
hyprwayland-scanner,
jq,
libGL,
libdatrie,
libdisplay-info,
libdrm,
libexecinfo,
libinput,
libliftoff,
libselinux,
libsepol,
libthai,
libuuid,
libxkbcommon,
libuuid,
mesa,
meson,
pango,
pciutils,
pcre2,
python3,
seatd,
re2,
systemd,
tomlplusplus,
udis86-hyprland,
wayland,
wayland-protocols,
wayland-scanner,
@@ -50,134 +43,148 @@
wrapRuntimeDeps ? true,
version ? "git",
commit,
revCount,
date,
# deprecated flags
enableNvidiaPatches ? false,
nvidiaPatches ? false,
hidpiXWayland ? false,
}:
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
stdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}";
inherit version;
}: let
inherit (builtins) baseNameOf foldl';
inherit (lib.asserts) assertMsg;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten concatLists optional optionals;
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix makeBinPath optionalString mesonBool mesonEnable;
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (lib.hasSuffix ".nix" baseName);
src = lib.cleanSource ../.;
};
adapters = flatten [
stdenvAdapters.useMoldLinker
(lib.optional debug stdenvAdapters.keepDebugInfo)
];
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
in
assert assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
customStdenv.mkDerivation (finalAttrs: {
pname = "hyprland${optionalString debug "-debug"}";
inherit version;
# Remove extra @PREFIX@ to fix pkg-config paths
sed -i "s#@PREFIX@/##g" hyprland.pc.in
'';
src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};
COMMITS = commit;
DATE = date;
DIRTY = lib.optionalString (commit == "") "dirty";
HASH = commit;
postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
nativeBuildInputs = [
hyprwayland-scanner
jq
makeWrapper
cmake
meson # for wlroots
ninja
pkg-config
python3 # for udis86
wayland-scanner
];
# Remove extra @PREFIX@ to fix pkg-config paths
sed -i "s#@PREFIX@/##g" hyprland.pc.in
'';
outputs = [
"out"
"man"
"dev"
];
COMMITS = revCount;
DATE = date;
DIRTY = optionalString (commit == "") "dirty";
HASH = commit;
TAG = "v${builtins.readFile "${finalAttrs.src}/VERSION"}";
buildInputs = lib.concatLists [
[
cairo
expat
fribidi
git
hwdata
hyprcursor
hyprlang
hyprutils
libGL
libdrm
libdatrie
libinput
libselinux
libsepol
libthai
libuuid
libxkbcommon
mesa
pango
pciutils
pcre2
tomlplusplus
wayland
wayland-protocols
# for wlroots
seatd
libdisplay-info
libliftoff
]
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutil
xorg.xcbutilerrors
xorg.xcbutilrenderutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
];
depsBuildBuild = [
pkg-config
];
cmakeBuildType =
if debug
then "Debug"
else "RelWithDebInfo";
nativeBuildInputs = [
hyprwayland-scanner
makeWrapper
meson
ninja
pkg-config
];
# we want as much debug info as possible
dontStrip = debug;
outputs = [
"out"
"man"
"dev"
];
cmakeFlags = [
(lib.cmakeBool "NO_XWAYLAND" (!enableXWayland))
(lib.cmakeBool "LEGACY_RENDERER" legacyRenderer)
(lib.cmakeBool "NO_SYSTEMD" (!withSystemd))
];
postInstall = ''
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [
binutils
buildInputs = concatLists [
[
aquamarine
cairo
git
hyprcursor
hyprgraphics
hyprland-protocols
hyprlang
hyprutils
libdrm
libGL
libinput
libuuid
libxkbcommon
mesa
pango
pciutils
pkgconf
]}
''}
'';
re2
tomlplusplus
udis86-hyprland
wayland
wayland-protocols
wayland-scanner
xorg.libXcursor
]
(optionals customStdenv.hostPlatform.isMusl [libexecinfo])
(optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutilerrors
xorg.xcbutilrenderutil
xorg.xcbutilwm
xwayland
])
(optional withSystemd systemd)
];
passthru.providedSessions = ["hyprland"];
mesonBuildType =
if debug
then "debugoptimized"
else "release";
meta = {
homepage = "https://github.com/hyprwm/Hyprland";
description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "Hyprland";
};
}
mesonFlags = flatten [
(mapAttrsToList mesonEnable {
"xwayland" = enableXWayland;
"legacy_renderer" = legacyRenderer;
"uwsm" = false;
})
(mapAttrsToList mesonBool {
"b_pch" = false;
"tracy_enable" = false;
})
];
postInstall = ''
${optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${makeBinPath [
binutils
hyprland-qtutils
pciutils
pkgconf
]}
''}
'';
passthru.providedSessions = ["hyprland"];
meta = {
homepage = "https://github.com/hyprwm/Hyprland";
description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "Hyprland";
};
})

64
nix/formatter.nix Normal file
View File

@@ -0,0 +1,64 @@
{
writeShellApplication,
deadnix,
statix,
alejandra,
llvmPackages_19,
fd,
}:
writeShellApplication {
name = "hyprland-treewide-formatter";
runtimeInputs = [
deadnix
statix
alejandra
llvmPackages_19.clang-tools
fd
];
text = ''
# shellcheck disable=SC2148
# common excludes
excludes="subprojects"
nix_format() {
if [ "$*" = 0 ]; then
fd '.*\.nix' . -E "$excludes" -x statix fix -- {} \;
fd '.*\.nix' . -E "$excludes" -X deadnix -e -- {} \; -X alejandra {} \;
elif [ -d "$1" ]; then
fd '.*\.nix' "$1" -E "$excludes" -i -x statix fix -- {} \;
fd '.*\.nix' "$1" -E "$excludes" -i -X deadnix -e -- {} \; -X alejandra {} \;
else
statix fix -- "$1"
deadnix -e "$1"
alejandra "$1"
fi
}
cpp_format() {
if [ "$*" = 0 ] || [ "$1" = "." ]; then
fd '.*\.cpp' . -E "$excludes" | xargs clang-format --verbose -i
elif [ -d "$1" ]; then
fd '.*\.cpp' "$1" -E "$excludes" | xargs clang-format --verbose -i
else
clang-format --verbose -i "$1"
fi
}
for i in "$@"; do
case ''${i##*.} in
"nix")
nix_format "$i"
;;
"cpp")
cpp_format "$i"
;;
*)
nix_format "$i"
cpp_format "$i"
;;
esac
done
'';
}

View File

@@ -3,13 +3,12 @@
lib,
inputs,
}: let
props = builtins.fromJSON (builtins.readFile ../props.json);
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
version = lib.removeSuffix "\n" (builtins.readFile ../VERSION);
in {
# Contains what a user is most likely to care about:
# Hyprland itself, XDPH and the Share Picker.
@@ -21,24 +20,35 @@ in {
# Packages for variations of Hyprland, dependencies included.
hyprland-packages = lib.composeManyExtensions [
# Dependencies
inputs.aquamarine.overlays.default
inputs.hyprcursor.overlays.default
inputs.hyprgraphics.overlays.default
inputs.hyprland-protocols.overlays.default
inputs.hyprland-qtutils.overlays.default
inputs.hyprlang.overlays.default
inputs.hyprutils.overlays.default
inputs.hyprwayland-scanner.overlays.default
self.overlays.xwayland
self.overlays.udis86
# Hyprland packages themselves
(final: prev: let
(final: _prev: let
date = mkDate (self.lastModifiedDate or "19700101");
in {
hyprland = final.callPackage ./default.nix {
stdenv = final.gcc13Stdenv;
version = "${props.version}+date=${date}_${self.shortRev or "dirty"}";
stdenv = final.gcc14Stdenv;
version = "${version}+date=${date}_${self.shortRev or "dirty"}";
commit = self.rev or "";
revCount = self.sourceInfo.revCount or "";
inherit date;
};
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprland-debug = final.hyprland.override {debug = true;};
# Build major libs with debug to get as much info as possible in a stacktrace
hyprland-debug = final.hyprland.override {
aquamarine = final.aquamarine.override {debug = true;};
hyprutils = final.hyprutils.override {debug = true;};
debug = true;
};
hyprland-legacy-renderer = final.hyprland.override {legacyRenderer = true;};
# deprecated packages
@@ -61,16 +71,22 @@ in {
# Packages for extra software recommended for usage with Hyprland,
# including forked or patched packages for compatibility.
hyprland-extras = lib.composeManyExtensions [
inputs.xdph.overlays.xdg-desktop-portal-hyprland
inputs.xdph.overlays.default
];
# Patches XWayland's pkgconfig file to not include Cflags or includedir
# The above two variables trip up CMake and the build fails
xwayland = final: prev: {
xwayland = prev.xwayland.overrideAttrs (old: {
postInstall = ''
sed -i '/includedir/d' $out/lib/pkgconfig/xwayland.pc
'';
# udis86 from nixpkgs is too old, and also does not provide a .pc file
# this version is the one used in the git submodule, and allows us to
# fetch the source without '?submodules=1'
udis86 = final: prev: {
udis86-hyprland = prev.udis86.overrideAttrs (_self: _super: {
src = final.fetchFromGitHub {
owner = "canihavesomecoffee";
repo = "udis86";
rev = "5336633af70f3917760a6d441ff02d93477b0c86";
hash = "sha256-HifdUQPGsKQKQprByeIznvRLONdOXeolOsU5nkwIv3g=";
};
patches = [];
});
};
}

View File

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

View File

@@ -1,3 +0,0 @@
{
"version": "0.41.2"
}

View File

@@ -1,100 +1,78 @@
wayland_protos = dependency('wayland-protocols',
wayland_protos = dependency(
'wayland-protocols',
version: '>=1.32',
fallback: 'wayland-protocols',
default_options: ['tests=false'],
)
hyprland_protos = dependency('hyprland-protocols',
version: '>=0.2',
fallback: 'hyprland-protocols',
hyprland_protos = dependency(
'hyprland-protocols',
version: '>=0.4',
fallback: 'hyprland-protocols',
)
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
hl_protocol_dir = hyprland_protos.get_variable('pkgdatadir')
wayland_protocol_dir = wayland_protos.get_variable('pkgdatadir')
hyprland_protocol_dir = hyprland_protos.get_variable('pkgdatadir')
wayland_scanner_dep = dependency('wayland-scanner', native: true)
wayland_scanner = find_program(
wayland_scanner_dep.get_variable('wayland_scanner'),
native: true,
)
hyprwayland_scanner_dep = dependency('hyprwayland-scanner', version: '>=0.3.8', native: true)
hyprwayland_scanner_dep = dependency('hyprwayland-scanner', version: '>=0.3.10', native: true)
hyprwayland_scanner = find_program(
hyprwayland_scanner_dep.get_variable('hyprwayland_scanner'),
native: true,
)
protocols = [
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v1.xml'],
['wlr-screencopy-unstable-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
'wlr-gamma-control-unstable-v1.xml',
'wlr-foreign-toplevel-management-unstable-v1.xml',
'wlr-output-power-management-unstable-v1.xml',
'input-method-unstable-v2.xml',
'virtual-keyboard-unstable-v1.xml',
'wlr-virtual-pointer-unstable-v1.xml',
'wlr-output-management-unstable-v1.xml',
'kde-server-decoration.xml',
'wlr-layer-shell-unstable-v1.xml',
'wayland-drm.xml',
'wlr-data-control-unstable-v1.xml',
'wlr-screencopy-unstable-v1.xml',
hyprland_protocol_dir / 'protocols/hyprland-global-shortcuts-v1.xml',
hyprland_protocol_dir / 'protocols/hyprland-toplevel-export-v1.xml',
hyprland_protocol_dir / 'protocols/hyprland-focus-grab-v1.xml',
hyprland_protocol_dir / 'protocols/hyprland-ctm-control-v1.xml',
wayland_protocol_dir / 'staging/tearing-control/tearing-control-v1.xml',
wayland_protocol_dir / 'staging/fractional-scale/fractional-scale-v1.xml',
wayland_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml',
wayland_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
wayland_protocol_dir / 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml',
wayland_protocol_dir / 'unstable/relative-pointer/relative-pointer-unstable-v1.xml',
wayland_protocol_dir / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml',
wayland_protocol_dir / 'staging/alpha-modifier/alpha-modifier-v1.xml',
wayland_protocol_dir / 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
wayland_protocol_dir / 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml',
wayland_protocol_dir / 'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml',
wayland_protocol_dir / 'unstable/text-input/text-input-unstable-v3.xml',
wayland_protocol_dir / 'unstable/text-input/text-input-unstable-v1.xml',
wayland_protocol_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml',
wayland_protocol_dir / 'staging/xdg-activation/xdg-activation-v1.xml',
wayland_protocol_dir / 'staging/ext-idle-notify/ext-idle-notify-v1.xml',
wayland_protocol_dir / 'staging/ext-session-lock/ext-session-lock-v1.xml',
wayland_protocol_dir / 'stable/tablet/tablet-v2.xml',
wayland_protocol_dir / 'stable/presentation-time/presentation-time.xml',
wayland_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
wayland_protocol_dir / 'unstable/primary-selection/primary-selection-unstable-v1.xml',
wayland_protocol_dir / 'staging/xwayland-shell/xwayland-shell-v1.xml',
wayland_protocol_dir / 'stable/viewporter/viewporter.xml',
wayland_protocol_dir / 'stable/linux-dmabuf/linux-dmabuf-v1.xml',
wayland_protocol_dir / 'staging/drm-lease/drm-lease-v1.xml',
wayland_protocol_dir / 'staging/linux-drm-syncobj/linux-drm-syncobj-v1.xml',
wayland_protocol_dir / 'staging/xdg-dialog/xdg-dialog-v1.xml',
wayland_protocol_dir / 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml',
wayland_protocol_dir / 'staging/security-context/security-context-v1.xml',
]
new_protocols = [
['wlr-gamma-control-unstable-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],
['input-method-unstable-v2.xml'],
['virtual-keyboard-unstable-v1.xml'],
['wlr-virtual-pointer-unstable-v1.xml'],
['wlr-output-management-unstable-v1.xml'],
['kde-server-decoration.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wayland-drm.xml'],
['wlr-data-control-unstable-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-focus-grab-v1.xml'],
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/relative-pointer/relative-pointer-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'],
[wl_protocol_dir, 'staging/alpha-modifier/alpha-modifier-v1.xml'],
[wl_protocol_dir, 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml'],
[wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v3.xml'],
[wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'],
[wl_protocol_dir, 'staging/xdg-activation/xdg-activation-v1.xml'],
[wl_protocol_dir, 'staging/ext-idle-notify/ext-idle-notify-v1.xml'],
[wl_protocol_dir, 'staging/ext-session-lock/ext-session-lock-v1.xml'],
[wl_protocol_dir, 'stable/tablet/tablet-v2.xml'],
[wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'],
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/primary-selection/primary-selection-unstable-v1.xml'],
[wl_protocol_dir, 'staging/xwayland-shell/xwayland-shell-v1.xml'],
[wl_protocol_dir, 'stable/viewporter/viewporter.xml'],
[wl_protocol_dir, 'stable/linux-dmabuf/linux-dmabuf-v1.xml'],
]
wl_protos_src = []
wl_protos_headers = []
foreach p : protocols
xml = join_paths(p)
wl_protos_src += custom_target(
xml.underscorify() + '_server_c',
input: xml,
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
wl_protos_headers += custom_target(
xml.underscorify() + '_server_h',
input: xml,
install: true,
install_dir: join_paths(get_option('includedir'), 'hyprland/protocols'),
output: '@BASENAME@-protocol.h',
command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'],
)
endforeach
new_wl_protos = []
foreach p : new_protocols
xml = join_paths(p)
new_wl_protos += custom_target(
xml.underscorify(),
input: xml,
wl_protocols = []
foreach protocol : protocols
wl_protocols += custom_target(
protocol.underscorify(),
input: protocol,
install: true,
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
@@ -102,30 +80,26 @@ foreach p : new_protocols
)
endforeach
wayland_server_dep = dependency('wayland-server', version: '>=1.20.0')
wayland_server_dir = wayland_server_dep.get_variable('pkgdatadir')
# wayland.xml generation
wayland_scanner = dependency('wayland-scanner')
wayland_scanner_datadir = wayland_scanner.get_variable('pkgdatadir')
wl_server_protos = [
wayland_server_dir / 'wayland.xml'
]
wl_server_protos_gen = []
foreach p : wl_server_protos
wl_server_protos_gen += custom_target(
p.underscorify(),
input: p,
install: false,
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
command: [hyprwayland_scanner, '--wayland-enums', '@INPUT@', '@OUTDIR@'],
)
endforeach
wayland_xml = wayland_scanner_datadir / 'wayland.xml'
wayland_protocol = custom_target(
wayland_xml.underscorify(),
input: wayland_xml,
install: true,
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
command: [hyprwayland_scanner, '--wayland-enums', '@INPUT@', '@OUTDIR@'],
)
lib_server_protos = static_library(
'server_protos',
wl_protos_src + wl_protos_headers + new_wl_protos + wl_server_protos_gen,
dependencies: wayland_server_dep.partial_dependency(compile_args: true),
wl_protocols + wayland_protocol,
)
server_protos = declare_dependency(
link_with: lib_server_protos,
sources: wl_protos_headers + new_wl_protos,
sources: wl_protocols + wayland_protocol,
)

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
#pragma once
#include <memory>
#include <deque>
#include <list>
#include <sys/resource.h>
@@ -30,9 +29,12 @@
#include "plugins/PluginSystem.hpp"
#include "helpers/Watchdog.hpp"
#include <aquamarine/backend/Backend.hpp>
#include <aquamarine/output/Output.hpp>
class CWLSurfaceResource;
enum eManagersInitStage {
enum eManagersInitStage : uint8_t {
STAGE_PRIORITY = 0,
STAGE_BASICINIT,
STAGE_LATE
@@ -43,121 +45,106 @@ class CCompositor {
CCompositor();
~CCompositor();
// ------------------ WLR BASICS ------------------ //
wl_display* m_sWLDisplay;
wl_event_loop* m_sWLEventLoop;
wlr_backend* m_sWLRBackend;
wlr_session* m_sWLRSession;
wlr_renderer* m_sWLRRenderer;
wlr_allocator* m_sWLRAllocator;
wlr_compositor* m_sWLRCompositor;
wlr_subcompositor* m_sWLRSubCompositor;
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_egl* m_sWLREGL;
int m_iDRMFD;
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
wlr_backend* m_sWLRHeadlessBackend;
// ------------------------------------------------- //
wl_display* m_sWLDisplay;
wl_event_loop* m_sWLEventLoop;
int m_iDRMFD = -1;
bool m_bInitialized = false;
SP<Aquamarine::CBackend> m_pAqBackend;
std::string m_szHyprTempDataRoot = "";
std::string m_szHyprTempDataRoot = "";
std::string m_szWLDisplaySocket = "";
std::string m_szInstanceSignature = "";
std::string m_szInstancePath = "";
std::string m_szCurrentSplash = "error";
std::string m_szWLDisplaySocket = "";
std::string m_szInstanceSignature = "";
std::string m_szInstancePath = "";
std::string m_szCurrentSplash = "error";
std::vector<SP<CMonitor>> m_vMonitors;
std::vector<SP<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
std::vector<PHLWINDOW> m_vWindows;
std::vector<PHLLS> m_vLayers;
std::vector<PHLWORKSPACE> m_vWorkspaces;
std::vector<PHLWINDOWREF> m_vWindowsFadingOut;
std::vector<PHLLSREF> m_vSurfacesFadingOut;
std::vector<PHLMONITOR> m_vMonitors;
std::vector<PHLMONITOR> m_vRealMonitors; // for all monitors, even those turned off
std::vector<PHLWINDOW> m_vWindows;
std::vector<PHLLS> m_vLayers;
std::vector<PHLWORKSPACE> m_vWorkspaces;
std::vector<PHLWINDOWREF> m_vWindowsFadingOut;
std::vector<PHLLSREF> m_vSurfacesFadingOut;
std::unordered_map<std::string, uint64_t> m_mMonitorIDMap;
std::unordered_map<std::string, MONITORID> m_mMonitorIDMap;
void initServer();
void startCompositor();
void cleanup();
void createLockFile();
void removeLockFile();
void bumpNofile();
void restoreNofile();
void initServer(std::string socketName, int socketFd);
void startCompositor();
void stopCompositor();
void cleanup();
void createLockFile();
void removeLockFile();
void bumpNofile();
void restoreNofile();
WP<CWLSurfaceResource> m_pLastFocus;
PHLWINDOWREF m_pLastWindow;
WP<CMonitor> m_pLastMonitor;
WP<CWLSurfaceResource> m_pLastFocus;
PHLWINDOWREF m_pLastWindow;
PHLMONITORREF m_pLastMonitor;
std::vector<PHLWINDOWREF> m_vWindowFocusHistory; // first element is the most recently focused.
std::vector<PHLWINDOWREF> m_vWindowFocusHistory; // first element is the most recently focused.
bool m_bReadyToProcess = false;
bool m_bSessionActive = true;
bool m_bDPMSStateON = true;
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bNextIsUnsafe = false; // because wlroots
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state
bool m_bExitTriggered = false; // For exit dispatcher
bool m_bIsShuttingDown = false;
bool m_bReadyToProcess = false;
bool m_bSessionActive = true;
bool m_bDPMSStateON = true;
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bNextIsUnsafe = false;
PHLMONITORREF m_pUnsafeOutput; // fallback output for the unsafe state
bool m_bIsShuttingDown = false;
bool m_bFinalRequests = false;
bool m_bDesktopEnvSet = false;
bool m_bEnableXwayland = true;
// ------------------------------------------------- //
CMonitor* getMonitorFromID(const int&);
CMonitor* getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&);
PHLMONITOR getMonitorFromID(const MONITORID&);
PHLMONITOR getMonitorFromName(const std::string&);
PHLMONITOR getMonitorFromDesc(const std::string&);
PHLMONITOR getMonitorFromCursor();
PHLMONITOR getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(PHLWINDOW);
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
bool monitorExists(CMonitor*);
bool monitorExists(PHLMONITOR);
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, CMonitor* monitor, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, PHLMONITOR monitor, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);
CMonitor* getMonitorFromOutput(wlr_output*);
CMonitor* getRealMonitorFromOutput(wlr_output*);
PHLMONITOR getMonitorFromOutput(SP<Aquamarine::IOutput>);
PHLMONITOR getRealMonitorFromOutput(SP<Aquamarine::IOutput>);
PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>);
PHLWINDOW getWindowFromHandle(uint32_t);
bool isWorkspaceVisible(PHLWORKSPACE);
bool isWorkspaceVisibleNotCovered(PHLWORKSPACE);
PHLWORKSPACE getWorkspaceByID(const int&);
PHLWORKSPACE getWorkspaceByID(const WORKSPACEID&);
PHLWORKSPACE getWorkspaceByName(const std::string&);
PHLWORKSPACE getWorkspaceByString(const std::string&);
void sanityCheckWorkspaces();
void updateWorkspaceWindowDecos(const int&);
void updateWorkspaceSpecialRenderData(const int&);
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
int getGroupsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
PHLWINDOW getUrgentWindow();
bool hasUrgentWindowOnWorkspace(const int&);
PHLWINDOW getFirstWindowOnWorkspace(const int&);
PHLWINDOW getTopLeftWindowOnWorkspace(const int&);
PHLWINDOW getFullscreenWindowOnWorkspace(const int&);
bool isWindowActive(PHLWINDOW);
void changeWindowZOrder(PHLWINDOW, bool);
void cleanupFadingOut(const int& monid);
void cleanupFadingOut(const MONITORID& monid);
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
int getNextAvailableNamedWorkspace();
WORKSPACEID getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&);
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
CMonitor* getMonitorInDirection(const char&);
CMonitor* getMonitorInDirection(CMonitor*, const char&);
bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
PHLMONITOR getMonitorInDirection(const char&);
PHLMONITOR getMonitorInDirection(PHLMONITOR, const char&);
void updateAllWindowsAnimatedDecorationValues();
void updateWorkspaceWindows(const int64_t& id);
void updateWindowAnimatedDecorationValues(PHLWINDOW);
int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false);
void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const int64_t&);
void setWindowFullscreen(PHLWINDOW, bool, eFullscreenMode mode = FULLSCREEN_INVALID);
MONITORID getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(PHLWORKSPACE, PHLMONITOR, bool noWarpCursor = false);
void swapActiveWorkspaces(PHLMONITOR, PHLMONITOR);
PHLMONITOR getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const WORKSPACEID&);
void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
void setWindowFullscreenState(const PHLWINDOW PWINDOW, const SFullscreenState state);
void changeWindowFullscreenModeInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
PHLWINDOW getX11Parent(PHLWINDOW);
void scheduleFrameForMonitor(CMonitor*);
void scheduleFrameForMonitor(PHLMONITOR, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN);
void addToFadingOutSafe(PHLLS);
void removeFromFadingOutSafe(PHLLS);
void addToFadingOutSafe(PHLWINDOW);
@@ -166,12 +153,11 @@ class CCompositor {
PHLLS getLayerSurfaceFromSurface(SP<CWLSurfaceResource>);
void closeWindow(PHLWINDOW);
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
void forceReportSizesToWindowsOnWorkspace(const int&);
PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = "", bool isEmtpy = true); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const int&, const std::string& name = "");
void setActiveMonitor(CMonitor*);
bool isWorkspaceSpecial(const int&);
int getNewSpecialID();
PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "",
bool isEmpty = true); // will be deleted next frame if left empty and unfocused!
void setActiveMonitor(PHLMONITOR);
bool isWorkspaceSpecial(const WORKSPACEID&);
WORKSPACEID getNewSpecialID();
void performUserChecks();
void moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWorkspace);
PHLWINDOW getForceFocus();
@@ -182,6 +168,7 @@ class CCompositor {
void setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform);
void updateSuspendedStates();
PHLWINDOW windowForCPointer(CWindow*);
void onNewMonitor(SP<Aquamarine::IOutput> output);
std::string explicitConfigPath;

View File

@@ -5,9 +5,7 @@
#include <any>
#include <hyprutils/math/Box.hpp>
using namespace Hyprutils::Math;
enum eIcons {
enum eIcons : uint8_t {
ICON_WARNING = 0,
ICON_INFO,
ICON_HINT,
@@ -17,7 +15,7 @@ enum eIcons {
ICON_NONE
};
enum eRenderStage {
enum eRenderStage : uint8_t {
RENDER_PRE = 0, /* Before binding the gl context */
RENDER_BEGIN, /* Just when the rendering begins, nothing has been rendered yet. Damage, current render data in opengl valid. */
RENDER_PRE_WINDOWS, /* Pre windows, post bottom and overlay layers */
@@ -29,7 +27,7 @@ enum eRenderStage {
RENDER_POST_WINDOW, /* After rendering a window (any pass) */
};
enum eInputType {
enum eInputType : uint8_t {
INPUT_TYPE_AXIS = 0,
INPUT_TYPE_BUTTON,
INPUT_TYPE_DRAG_START,
@@ -41,7 +39,7 @@ struct SCallbackInfo {
bool cancelled = false; /* on cancellable events, will cancel the event. */
};
enum eHyprCtlOutputFormat {
enum eHyprCtlOutputFormat : uint8_t {
FORMAT_NORMAL = 0,
FORMAT_JSON
};
@@ -52,4 +50,8 @@ struct SHyprCtlCommand {
std::function<std::string(eHyprCtlOutputFormat, std::string)> fn;
};
typedef int64_t WINDOWID;
typedef int64_t MONITORID;
typedef int64_t WORKSPACEID;
typedef std::function<void(void*, SCallbackInfo&, std::any)> HOOK_CALLBACK_FN;

View File

@@ -3,7 +3,7 @@
#include "../helpers/varlist/VarList.hpp"
#include <vector>
enum eConfigValueDataTypes {
enum eConfigValueDataTypes : int8_t {
CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0,
CVD_TYPE_CSS_VALUE = 1
@@ -20,24 +20,40 @@ class ICustomConfigValueData {
class CGradientValueData : public ICustomConfigValueData {
public:
CGradientValueData(){};
CGradientValueData(CColor col) {
CGradientValueData() = default;
CGradientValueData(CHyprColor col) {
m_vColors.push_back(col);
updateColorsOk();
};
virtual ~CGradientValueData(){};
virtual ~CGradientValueData() = default;
virtual eConfigValueDataTypes getDataType() {
return CVD_TYPE_GRADIENT;
}
void reset(CColor col) {
void reset(CHyprColor col) {
m_vColors.clear();
m_vColors.emplace_back(col);
m_fAngle = 0;
updateColorsOk();
}
void updateColorsOk() {
m_vColorsOkLabA.clear();
for (auto& c : m_vColors) {
const auto OKLAB = c.asOkLab();
m_vColorsOkLabA.emplace_back(OKLAB.l);
m_vColorsOkLabA.emplace_back(OKLAB.a);
m_vColorsOkLabA.emplace_back(OKLAB.b);
m_vColorsOkLabA.emplace_back(c.a);
}
}
/* Vector containing the colors */
std::vector<CColor> m_vColors;
std::vector<CHyprColor> m_vColors;
/* Vector containing pure colors for shoving into opengl */
std::vector<float> m_vColorsOkLabA;
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;
@@ -67,11 +83,11 @@ class CGradientValueData : public ICustomConfigValueData {
class CCssGapData : public ICustomConfigValueData {
public:
CCssGapData() : top(0), right(0), bottom(0), left(0){};
CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global){};
CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal){};
CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal){};
CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left){};
CCssGapData() : top(0), right(0), bottom(0), left(0) {};
CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global) {};
CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal) {};
CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal) {};
CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left) {};
/* Css like directions */
int64_t top;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -6,10 +6,9 @@
#include "../debug/Log.hpp"
#include <unordered_map>
#include "../defines.hpp"
#include <variant>
#include <vector>
#include <deque>
#include <algorithm>
#include <regex>
#include <optional>
#include <functional>
#include <xf86drmMode.h>
@@ -33,16 +32,16 @@ struct SWorkspaceRule {
std::string monitor = "";
std::string workspaceString = "";
std::string workspaceName = "";
int workspaceId = -1;
WORKSPACEID workspaceId = -1;
bool isDefault = false;
bool isPersistent = false;
std::optional<CCssGapData> gapsIn;
std::optional<CCssGapData> gapsOut;
std::optional<int64_t> borderSize;
std::optional<int> border;
std::optional<int> rounding;
std::optional<int> decorate;
std::optional<int> shadow;
std::optional<bool> decorate;
std::optional<bool> noRounding;
std::optional<bool> noBorder;
std::optional<bool> noShadow;
std::optional<std::string> onCreatedEmptyRunCmd;
std::optional<std::string> defaultName;
std::map<std::string, std::string> layoutopts;
@@ -68,13 +67,13 @@ struct SAnimationPropertyConfig {
};
struct SPluginKeyword {
HANDLE handle = 0;
HANDLE handle = nullptr;
std::string name = "";
Hyprlang::PCONFIGHANDLERFUNC fn = nullptr;
};
struct SPluginVariable {
HANDLE handle = 0;
HANDLE handle = nullptr;
std::string name = "";
};
@@ -83,6 +82,70 @@ struct SExecRequestedRule {
uint64_t iPid = 0;
};
enum eConfigOptionType : uint8_t {
CONFIG_OPTION_BOOL = 0,
CONFIG_OPTION_INT = 1, /* e.g. 0/1/2*/
CONFIG_OPTION_FLOAT = 2,
CONFIG_OPTION_STRING_SHORT = 3, /* e.g. "auto" */
CONFIG_OPTION_STRING_LONG = 4, /* e.g. a command */
CONFIG_OPTION_COLOR = 5,
CONFIG_OPTION_CHOICE = 6, /* e.g. "one", "two", "three" */
CONFIG_OPTION_GRADIENT = 7,
CONFIG_OPTION_VECTOR = 8,
};
enum eConfigOptionFlags : uint8_t {
CONFIG_OPTION_FLAG_PERCENTAGE = (1 << 0),
};
struct SConfigOptionDescription {
struct SBoolData {
bool value = false;
};
struct SRangeData {
int value = 0, min = 0, max = 2;
};
struct SFloatData {
float value = 0, min = 0, max = 100;
};
struct SStringData {
std::string value;
};
struct SColorData {
CHyprColor color;
};
struct SChoiceData {
int firstIndex = 0;
std::string choices; // comma-separated
};
struct SGradientData {
std::string gradient;
};
struct SVectorData {
Vector2D vec, min, max;
};
std::string value; // e.g. general:gaps_in
std::string description;
std::string specialCategory; // if value is special (e.g. device:abc) value will be abc and special device
bool specialKey = false;
eConfigOptionType type = CONFIG_OPTION_BOOL;
uint32_t flags = 0; // eConfigOptionFlags
std::string jsonify() const;
//
std::variant<SBoolData, SRangeData, SFloatData, SStringData, SColorData, SChoiceData, SGradientData, SVectorData> data;
};
class CConfigManager {
public:
CConfigManager();
@@ -101,20 +164,21 @@ class CConfigManager {
void* const* getConfigValuePtr(const std::string&);
Hyprlang::CConfigValue* getHyprlangConfigValuePtr(const std::string& name, const std::string& specialCat = "");
void onPluginLoadUnload(const std::string& name, bool load);
static std::string getConfigDir();
static std::string getMainConfigPath();
const std::string getConfigString();
std::string getConfigString();
SMonitorRule getMonitorRuleFor(const CMonitor&);
SMonitorRule getMonitorRuleFor(const PHLMONITOR);
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&);
PHLMONITOR getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&);
const std::deque<SWorkspaceRule>& getAllWorkspaceRules();
const std::vector<SWorkspaceRule>& getAllWorkspaceRules();
std::vector<SWindowRule> getMatchingRules(PHLWINDOW, bool dynamic = true, bool shadowExec = false);
std::vector<SLayerRule> getMatchingRules(PHLLS);
std::vector<SP<CWindowRule>> getMatchingRules(PHLWINDOW, bool dynamic = true, bool shadowExec = false);
std::vector<SP<CLayerRule>> getMatchingRules(PHLLS);
const std::vector<SConfigOptionDescription>& getAllDescriptions();
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@@ -126,15 +190,15 @@ class CConfigManager {
// no-op when done.
void dispatchExecOnce();
void dispatchExecShutdown();
void performMonitorReload();
void appendMonitorRule(const SMonitorRule&);
bool replaceMonitorRule(const SMonitorRule&);
bool m_bWantsMonitorReload = false;
bool m_bForceReload = false;
bool m_bNoMonitorReload = false;
void ensureMonitorStatus();
void ensureVRR(CMonitor* pMonitor = nullptr);
void ensureVRR(PHLMONITOR pMonitor = nullptr);
bool shouldUseSoftwareCursors();
std::string parseKeyword(const std::string&, const std::string&);
@@ -148,30 +212,68 @@ class CConfigManager {
std::string getErrors();
// keywords
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
std::optional<std::string> handleMonitor(const std::string&, const std::string&);
std::optional<std::string> handleBind(const std::string&, const std::string&);
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
std::optional<std::string> handleWindowRule(const std::string&, const std::string&);
std::optional<std::string> handleLayerRule(const std::string&, const std::string&);
std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&);
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
std::optional<std::string> handleBezier(const std::string&, const std::string&);
std::optional<std::string> handleAnimation(const std::string&, const std::string&);
std::optional<std::string> handleSource(const std::string&, const std::string&);
std::optional<std::string> handleSubmap(const std::string&, const std::string&);
std::optional<std::string> handleBlurLS(const std::string&, const std::string&);
std::optional<std::string> handleBindWS(const std::string&, const std::string&);
std::optional<std::string> handleEnv(const std::string&, const std::string&);
std::optional<std::string> handlePlugin(const std::string&, const std::string&);
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
std::optional<std::string> handleExecShutdown(const std::string&, const std::string&);
std::optional<std::string> handleMonitor(const std::string&, const std::string&);
std::optional<std::string> handleBind(const std::string&, const std::string&);
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
std::optional<std::string> handleWindowRule(const std::string&, const std::string&);
std::optional<std::string> handleLayerRule(const std::string&, const std::string&);
std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&);
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
std::optional<std::string> handleBezier(const std::string&, const std::string&);
std::optional<std::string> handleAnimation(const std::string&, const std::string&);
std::optional<std::string> handleSource(const std::string&, const std::string&);
std::optional<std::string> handleSubmap(const std::string&, const std::string&);
std::optional<std::string> handleBlurLS(const std::string&, const std::string&);
std::optional<std::string> handleBindWS(const std::string&, const std::string&);
std::optional<std::string> handleEnv(const std::string&, const std::string&);
std::optional<std::string> handlePlugin(const std::string&, const std::string&);
std::string configCurrentPath;
std::string configCurrentPath;
std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> mbWindowProperties = {
{"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.allowsInput; }},
{"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.dimAround; }},
{"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.decorate; }},
{"focusonactivate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.focusOnActivate; }},
{"keepaspectratio", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.keepAspectRatio; }},
{"nearestneighbor", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.nearestNeighbor; }},
{"noanim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noAnim; }},
{"noblur", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBlur; }},
{"noborder", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBorder; }},
{"nodim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noDim; }},
{"nofocus", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noFocus; }},
{"nomaxsize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noMaxSize; }},
{"norounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noRounding; }},
{"noshadow", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShadow; }},
{"noshortcutsinhibit", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShortcutsInhibit; }},
{"opaque", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.opaque; }},
{"forcergbx", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.RGBX; }},
{"syncfullscreen", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.syncFullscreen; }},
{"immediate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.tearing; }},
{"xray", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.xray; }},
};
std::unordered_map<std::string, std::function<CWindowOverridableVar<int>*(const PHLWINDOW&)>> miWindowProperties = {
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.rounding; }},
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.borderSize; }},
};
std::unordered_map<std::string, std::function<CWindowOverridableVar<float>*(PHLWINDOW)>> mfWindowProperties = {
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollMouse; }},
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollTouchpad; }}};
bool m_bWantsMonitorReload = false;
bool m_bForceReload = false;
bool m_bNoMonitorReload = false;
bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
private:
std::unique_ptr<Hyprlang::CConfig> m_pConfig;
std::deque<std::string> configPaths; // stores all the config paths
std::vector<std::string> configPaths; // stores all the config paths
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
@@ -186,28 +288,30 @@ class CConfigManager {
bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules;
std::deque<SWorkspaceRule> m_dWorkspaceRules;
std::deque<SWindowRule> m_dWindowRules;
std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
std::vector<SMonitorRule> m_vMonitorRules;
std::vector<SWorkspaceRule> m_vWorkspaceRules;
std::vector<SP<CWindowRule>> m_vWindowRules;
std::vector<SP<CLayerRule>> m_vLayerRules;
std::vector<std::string> m_dBlurLSNamespaces;
bool firstExecDispatched = false;
bool m_bManualCrashInitiated = false;
std::deque<std::string> firstExecRequests;
std::vector<std::string> firstExecRequests;
std::vector<std::string> finalExecRequests;
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
std::string m_szConfigErrors = "";
// internal methods
void setAnimForChildren(SAnimationPropertyConfig* const);
void updateBlurredLS(const std::string&, const bool);
void setDefaultAnimationVars();
std::optional<std::string> resetHLConfig();
std::optional<std::string> verifyConfigExists();
void postConfigReload(const Hyprlang::CParseResult& result);
void reload();
SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&);
void setAnimForChildren(SAnimationPropertyConfig* const);
void updateBlurredLS(const std::string&, const bool);
void setDefaultAnimationVars();
std::optional<std::string> resetHLConfig();
static std::optional<std::string> generateConfig(std::string configPath);
static std::optional<std::string> verifyConfigExists();
void postConfigReload(const Hyprlang::CParseResult& result);
void reload();
SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&);
};
inline std::unique_ptr<CConfigManager> g_pConfigManager;

View File

@@ -13,6 +13,7 @@ class CConfigValue {
CConfigValue(const std::string& val) {
const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val);
// NOLINTNEXTLINE
p_ = PVHYPRLANG->getDataStaticPtr();
#ifdef HYPRLAND_DEBUG

View File

@@ -4,8 +4,8 @@
inline const std::string AUTOCONFIG = R"#(
# #######################################################################################
# AUTOGENERATED HYPR CONFIG.
# PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT,
# AUTOGENERATED HYPRLAND CONFIG.
# PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hyprland.conf AND EDIT IT,
# OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS.
# #######################################################################################
@@ -13,7 +13,7 @@ autogenerated = 1 # remove this line to remove the warning
# This is an example Hyprland config file.
# Refer to the wiki for more information.
# https://wiki.hyprland.org/Configuring/Configuring-Hyprland/
# https://wiki.hyprland.org/Configuring/
# Please note not all available settings / options are set here.
# For a full list, see the wiki
@@ -72,7 +72,7 @@ env = HYPRCURSOR_SIZE,24
# Refer to https://wiki.hyprland.org/Configuring/Variables/
# https://wiki.hyprland.org/Configuring/Variables/#general
general {
general {
gaps_in = 5
gaps_out = 20
@@ -83,7 +83,7 @@ general {
col.inactive_border = rgba(595959aa)
# 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
allow_tearing = false
@@ -99,37 +99,63 @@ decoration {
active_opacity = 1.0
inactive_opacity = 1.0
drop_shadow = true
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
shadow {
enabled = true
range = 4
render_power = 3
color = rgba(1a1a1aee)
}
# https://wiki.hyprland.org/Configuring/Variables/#blur
blur {
enabled = true
size = 3
passes = 1
vibrancy = 0.1696
}
}
# https://wiki.hyprland.org/Configuring/Variables/#animations
animations {
enabled = true
enabled = yes, please :)
# Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
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.0
bezier = quick,0.15,0,0.1,1
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
animation = global, 1, 10, default
animation = border, 1, 5.39, easeOutQuint
animation = windows, 1, 4.79, easeOutQuint
animation = windowsIn, 1, 4.1, easeOutQuint, popin 87%
animation = windowsOut, 1, 1.49, linear, popin 87%
animation = fadeIn, 1, 1.73, almostLinear
animation = fadeOut, 1, 1.46, almostLinear
animation = fade, 1, 3.03, quick
animation = layers, 1, 3.81, easeOutQuint
animation = layersIn, 1, 4, easeOutQuint, fade
animation = layersOut, 1, 1.5, linear, fade
animation = fadeLayersIn, 1, 1.79, almostLinear
animation = fadeLayersOut, 1, 1.39, almostLinear
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/
# "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[tv1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle {
pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
@@ -142,7 +168,7 @@ master {
}
# https://wiki.hyprland.org/Configuring/Variables/#misc
misc {
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = false # If true disables the random hyprland logo / anime girl background. :(
}
@@ -182,9 +208,9 @@ device {
}
####################
### KEYBINDINGSS ###
####################
###################
### KEYBINDINGS ###
###################
# See https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
@@ -241,6 +267,19 @@ bind = $mainMod, mouse_up, workspace, e-1
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Laptop multimedia keys for volume and LCD brightness
bindel = ,XF86AudioRaiseVolume, 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 = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+
bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%-
# Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous
##############################
### WINDOWS AND WORKSPACES ###
@@ -255,5 +294,9 @@ bindm = $mainMod, mouse:273, resizewindow
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
windowrulev2 = suppressevent maximize, class:.* # You'll probably like this.
# Ignore maximize requests from apps. You'll probably like this.
windowrulev2 = suppressevent maximize, class:.*
# Fix some dragging issues with XWayland
windowrulev2 = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0
)#";

View File

@@ -2,9 +2,10 @@
#include <fcntl.h>
#include <sys/utsname.h>
#include <link.h>
#include <time.h>
#include <errno.h>
#include <ctime>
#include <cerrno>
#include <sys/stat.h>
#include <filesystem>
#include "../plugins/PluginSystem.hpp"
#include "../signal-safe.hpp"
@@ -30,10 +31,10 @@ static char const* const MESSAGES[] = {"Sorry, didn't mean to...",
// <random> is not async-signal-safe, fake it with time(NULL) instead
char const* getRandomMessage() {
return MESSAGES[time(NULL) % (sizeof(MESSAGES) / sizeof(MESSAGES[0]))];
return MESSAGES[time(nullptr) % (sizeof(MESSAGES) / sizeof(MESSAGES[0]))];
}
[[noreturn]] inline void exit_with_error(char const* err) {
[[noreturn]] inline void exitWithError(char const* err) {
write(STDERR_FILENO, err, strlen(err));
// perror() is not signal-safe, but we use it here
// because if the crash-handler already crashed, it can't get any worse.
@@ -41,17 +42,17 @@ char const* getRandomMessage() {
abort();
}
void CrashReporter::createAndSaveCrash(int sig) {
int reportFd;
void NCrashReporter::createAndSaveCrash(int sig) {
int reportFd = -1;
// We're in the signal handler, so we *only* have stack memory.
// To save as much stack memory as possible,
// destroy things as soon as possible.
{
MaxLengthCString<255> reportPath;
CMaxLengthCString<255> reportPath;
const auto HOME = sig_getenv("HOME");
const auto CACHE_HOME = sig_getenv("XDG_CACHE_HOME");
const auto HOME = sigGetenv("HOME");
const auto CACHE_HOME = sigGetenv("XDG_CACHE_HOME");
if (CACHE_HOME && CACHE_HOME[0] != '\0') {
reportPath += CACHE_HOME;
@@ -60,24 +61,24 @@ void CrashReporter::createAndSaveCrash(int sig) {
reportPath += HOME;
reportPath += "/.cache/hyprland";
} else {
exit_with_error("$CACHE_HOME and $HOME not set, nowhere to report crash\n");
exitWithError("$CACHE_HOME and $HOME not set, nowhere to report crash\n");
return;
}
int ret = mkdir(reportPath.get_str(), S_IRWXU);
int ret = mkdir(reportPath.getStr(), S_IRWXU);
//__asm__("int $3");
if (ret < 0 && errno != EEXIST) {
exit_with_error("failed to mkdir() crash report directory\n");
exitWithError("failed to mkdir() crash report directory\n");
}
reportPath += "/hyprlandCrashReport";
reportPath.write_num(getpid());
reportPath.writeNum(getpid());
reportPath += ".txt";
{
BufFileWriter<64> stderr(2);
CBufFileWriter<64> stderr(2);
stderr += "Hyprland has crashed :( Consult the crash report at ";
if (!reportPath.boundsExceeded()) {
stderr += reportPath.get_str();
stderr += reportPath.getStr();
} else {
stderr += "[ERROR: Crash report path does not fit into memory! Check if your $CACHE_HOME/$HOME is too deeply nested. Max 255 characters.]";
}
@@ -85,12 +86,12 @@ void CrashReporter::createAndSaveCrash(int sig) {
stderr.flush();
}
reportFd = open(reportPath.get_str(), O_WRONLY | O_CREAT, S_IRWXU);
reportFd = open(reportPath.getStr(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (reportFd < 0) {
exit_with_error("Failed to open crash report path for writing");
exitWithError("Failed to open crash report path for writing");
}
}
BufFileWriter<512> finalCrashReport(reportFd);
CBufFileWriter<512> finalCrashReport(reportFd);
finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n";
finalCrashReport += getRandomMessage();
@@ -99,19 +100,31 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "Hyprland received signal ";
finalCrashReport.writeNum(sig);
finalCrashReport += '(';
finalCrashReport += sig_strsignal(sig);
finalCrashReport += sigStrsignal(sig);
finalCrashReport += ")\nVersion: ";
finalCrashReport += GIT_COMMIT_HASH;
finalCrashReport += "\nTag: ";
finalCrashReport += GIT_TAG;
finalCrashReport += "\n\n";
finalCrashReport += "\nDate: ";
finalCrashReport += GIT_COMMIT_DATE;
finalCrashReport += "\nFlags:\n";
#ifdef LEGACY_RENDERER
finalCrashReport += "legacyrenderer\n";
#endif
#ifndef ISDEBUG
finalCrashReport += "debug\n";
#endif
#ifdef NO_XWAYLAND
finalCrashReport += "no xwayland\n";
#endif
finalCrashReport += "\n";
if (g_pPluginSystem && g_pPluginSystem->pluginCount() > 0) {
finalCrashReport += "Hyprland seems to be running with plugins. This crash might not be Hyprland's fault.\nPlugins:\n";
size_t count = g_pPluginSystem->pluginCount();
CPlugin* plugins[count];
g_pPluginSystem->sig_getPlugins(plugins, count);
const size_t count = g_pPluginSystem->pluginCount();
std::vector<CPlugin*> plugins(count);
g_pPluginSystem->sigGetPlugins(plugins.data(), count);
for (size_t i = 0; i < count; i++) {
auto p = plugins[i];
@@ -146,7 +159,7 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "GPU:\n\t";
#if defined(__DragonFly__) || defined(__FreeBSD__)
finalCrashReport.writeCmdOutput("pciconf -lv | fgrep -A4 vga");
finalCrashReport.writeCmdOutput("pciconf -lv | grep -F -A4 vga");
#else
finalCrashReport.writeCmdOutput("lspci -vnn | grep VGA");
#endif
@@ -228,5 +241,5 @@ void CrashReporter::createAndSaveCrash(int sig) {
finalCrashReport += "\n\nLog tail:\n";
finalCrashReport += std::string_view(Debug::rollingLog).substr(Debug::rollingLog.find("\n") + 1);
finalCrashReport += std::string_view(Debug::rollingLog).substr(Debug::rollingLog.find('\n') + 1);
}

View File

@@ -2,6 +2,6 @@
#include "../defines.hpp"
namespace CrashReporter {
namespace NCrashReporter {
void createAndSaveCrash(int sig);
};

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,10 @@
#include "../helpers/MiscFunctions.hpp"
#include <functional>
// exposed for main.cpp
std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request);
std::string versionRequest(eHyprCtlOutputFormat format, std::string request);
class CHyprCtl {
public:
CHyprCtl();
@@ -22,11 +26,16 @@ class CHyprCtl {
bool sysInfoConfig = false;
} m_sCurrentRequestParams;
static std::string getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format);
static std::string getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat format);
static std::string getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor> m, eHyprCtlOutputFormat format);
private:
void startHyprCtlSocket();
std::vector<SP<SHyprCtlCommand>> m_vCommands;
wl_event_source* m_eventSource = nullptr;
std::string m_socketPath;
};
inline std::unique_ptr<CHyprCtl> g_pHyprCtl;

View File

@@ -7,8 +7,13 @@ CHyprDebugOverlay::CHyprDebugOverlay() {
m_pTexture = makeShared<CTexture>();
}
void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_dLastRenderTimes.push_back(µs / 1000.f);
void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_dLastRenderTimes.emplace_back(durationUs / 1000.f);
if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastRenderTimes.pop_front();
@@ -17,8 +22,13 @@ void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_pMonitor = pMonitor;
}
void CHyprMonitorDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float µs) {
m_dLastRenderTimesNoOverlay.push_back(µs / 1000.f);
void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_dLastRenderTimesNoOverlay.emplace_back(durationUs / 1000.f);
if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastRenderTimesNoOverlay.pop_front();
@@ -27,8 +37,13 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float µs
m_pMonitor = pMonitor;
}
void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_dLastFrametimes.emplace_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate)
m_dLastFrametimes.pop_front();
@@ -39,7 +54,7 @@ void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
m_pMonitor = pMonitor;
// anim data too
const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor : g_pCompositor->m_pLastMonitor.get();
const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor.lock() : g_pCompositor->m_pLastMonitor.lock();
if (PMONITORFORTICKS) {
if (m_dLastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->refreshRate)
m_dLastAnimationTicks.pop_front();
@@ -57,7 +72,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
float avgFrametime = 0;
float maxFrametime = 0;
float minFrametime = 9999;
for (auto& ft : m_dLastFrametimes) {
for (auto const& ft : m_dLastFrametimes) {
if (ft > maxFrametime)
maxFrametime = ft;
if (ft < minFrametime)
@@ -70,7 +85,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
float avgRenderTime = 0;
float maxRenderTime = 0;
float minRenderTime = 9999;
for (auto& rt : m_dLastRenderTimes) {
for (auto const& rt : m_dLastRenderTimes) {
if (rt > maxRenderTime)
maxRenderTime = rt;
if (rt < minRenderTime)
@@ -83,7 +98,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
float avgRenderTimeNoOverlay = 0;
float maxRenderTimeNoOverlay = 0;
float minRenderTimeNoOverlay = 9999;
for (auto& rt : m_dLastRenderTimesNoOverlay) {
for (auto const& rt : m_dLastRenderTimesNoOverlay) {
if (rt > maxRenderTimeNoOverlay)
maxRenderTimeNoOverlay = rt;
if (rt < minRenderTimeNoOverlay)
@@ -96,7 +111,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
float avgAnimMgrTick = 0;
float maxAnimMgrTick = 0;
float minAnimMgrTick = 9999;
for (auto& at : m_dLastAnimationTicks) {
for (auto const& at : m_dLastAnimationTicks) {
if (at > maxAnimMgrTick)
maxAnimMgrTick = at;
if (at < minAnimMgrTick)
@@ -188,21 +203,36 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
return posY - offset;
}
void CHyprDebugOverlay::renderData(CMonitor* pMonitor, float µs) {
m_mMonitorOverlays[pMonitor].renderData(pMonitor, µs);
void CHyprDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_mMonitorOverlays[pMonitor].renderData(pMonitor, durationUs);
}
void CHyprDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float µs) {
m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, µs);
void CHyprDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, durationUs);
}
void CHyprDebugOverlay::frameData(CMonitor* pMonitor) {
void CHyprDebugOverlay::frameData(PHLMONITOR pMonitor) {
static auto PDEBUGOVERLAY = CConfigValue<Hyprlang::INT>("debug:overlay");
if (!*PDEBUGOVERLAY)
return;
m_mMonitorOverlays[pMonitor].frameData(pMonitor);
}
void CHyprDebugOverlay::draw() {
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
const auto PMONITOR = g_pCompositor->m_vMonitors.front();
if (!m_pCairoSurface || !m_pCairo) {
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
@@ -217,8 +247,8 @@ void CHyprDebugOverlay::draw() {
// draw the things
int offsetY = 0;
for (auto& m : g_pCompositor->m_vMonitors) {
offsetY += m_mMonitorOverlays[m.get()].draw(offsetY);
for (auto const& m : g_pCompositor->m_vMonitors) {
offsetY += m_mMonitorOverlays[m].draw(offsetY);
offsetY += 5; // for padding between mons
}

View File

@@ -3,9 +3,9 @@
#include "../defines.hpp"
#include "../helpers/Monitor.hpp"
#include "../render/Texture.hpp"
#include <deque>
#include <cairo/cairo.h>
#include <unordered_map>
#include <map>
#include <deque>
class CHyprRenderer;
@@ -13,9 +13,9 @@ class CHyprMonitorDebugOverlay {
public:
int draw(int offset);
void renderData(CMonitor* pMonitor, float µs);
void renderDataNoOverlay(CMonitor* pMonitor, float µs);
void frameData(CMonitor* pMonitor);
void renderData(PHLMONITOR pMonitor, float durationUs);
void renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs);
void frameData(PHLMONITOR pMonitor);
private:
std::deque<float> m_dLastFrametimes;
@@ -23,7 +23,7 @@ class CHyprMonitorDebugOverlay {
std::deque<float> m_dLastRenderTimesNoOverlay;
std::deque<float> m_dLastAnimationTicks;
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
CMonitor* m_pMonitor = nullptr;
PHLMONITORREF m_pMonitor;
CBox m_wbLastDrawnBox;
friend class CHyprRenderer;
@@ -33,17 +33,17 @@ class CHyprDebugOverlay {
public:
CHyprDebugOverlay();
void draw();
void renderData(CMonitor*, float µs);
void renderDataNoOverlay(CMonitor*, float µs);
void frameData(CMonitor*);
void renderData(PHLMONITOR, float durationUs);
void renderDataNoOverlay(PHLMONITOR, float durationUs);
void frameData(PHLMONITOR);
private:
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
std::map<PHLMONITORREF, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;
SP<CTexture> m_pTexture;
SP<CTexture> m_pTexture;
friend class CHyprMonitorDebugOverlay;
friend class CHyprRenderer;

View File

@@ -18,7 +18,7 @@ inline auto iconBackendFromLayout(PangoLayout* layout) {
CHyprNotificationOverlay::CHyprNotificationOverlay() {
static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) {
if (m_dNotifications.size() == 0)
if (m_vNotifications.size() == 0)
return;
g_pHyprRenderer->damageBox(&m_bLastDamage);
@@ -34,34 +34,34 @@ CHyprNotificationOverlay::~CHyprNotificationOverlay() {
cairo_surface_destroy(m_pCairoSurface);
}
void CHyprNotificationOverlay::addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon, const float fontSize) {
const auto PNOTIF = m_dNotifications.emplace_back(std::make_unique<SNotification>()).get();
void CHyprNotificationOverlay::addNotification(const std::string& text, const CHyprColor& color, const float timeMs, const eIcons icon, const float fontSize) {
const auto PNOTIF = m_vNotifications.emplace_back(std::make_unique<SNotification>()).get();
PNOTIF->text = text;
PNOTIF->color = color == CColor(0) ? ICONS_COLORS[icon] : color;
PNOTIF->text = icon != eIcons::ICON_NONE ? " " + text /* tiny bit of padding otherwise icon touches text */ : text;
PNOTIF->color = color == CHyprColor(0) ? ICONS_COLORS[icon] : color;
PNOTIF->started.reset();
PNOTIF->timeMs = timeMs;
PNOTIF->icon = icon;
PNOTIF->fontSize = fontSize;
for (auto& m : g_pCompositor->m_vMonitors) {
g_pCompositor->scheduleFrameForMonitor(m.get());
for (auto const& m : g_pCompositor->m_vMonitors) {
g_pCompositor->scheduleFrameForMonitor(m);
}
}
void CHyprNotificationOverlay::dismissNotifications(const int amount) {
if (amount == -1)
m_dNotifications.clear();
m_vNotifications.clear();
else {
const int AMT = std::min(amount, static_cast<int>(m_dNotifications.size()));
const int AMT = std::min(amount, static_cast<int>(m_vNotifications.size()));
for (int i = 0; i < AMT; ++i) {
m_dNotifications.pop_front();
m_vNotifications.erase(m_vNotifications.begin());
}
}
}
CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
static constexpr auto ANIM_DURATION_MS = 600.0;
static constexpr auto ANIM_LAG_MS = 100.0;
static constexpr auto NOTIF_LEFTBAR_SIZE = 5.0;
@@ -87,7 +87,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
const auto iconBackendID = iconBackendFromLayout(layout);
const auto PBEZIER = g_pAnimationManager->getBezier("default");
for (auto& notif : m_dNotifications) {
for (auto const& notif : m_vNotifications) {
const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD;
const auto FONTSIZE = std::clamp((int)(notif->fontSize * ((pMonitor->vecPixelSize.x * SCALE) / 1920.f)), 8, 40);
@@ -182,12 +182,12 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
g_object_unref(layout);
// cleanup notifs
std::erase_if(m_dNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
std::erase_if(m_vNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; });
return CBox{(int)(pMonitor->vecPosition.x + pMonitor->vecSize.x - maxWidth - 20), (int)pMonitor->vecPosition.y, (int)maxWidth + 20, (int)offsetY + 10};
}
void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) {
const auto MONSIZE = pMonitor->vecTransformedSize;
@@ -205,7 +205,7 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
}
// Draw the notifications
if (m_dNotifications.size() == 0)
if (m_vNotifications.size() == 0)
return;
// Render to the monitor
@@ -246,5 +246,5 @@ void CHyprNotificationOverlay::draw(CMonitor* pMonitor) {
}
bool CHyprNotificationOverlay::hasAny() {
return !m_dNotifications.empty();
return !m_vNotifications.empty();
}

View File

@@ -6,11 +6,11 @@
#include "../render/Texture.hpp"
#include "../SharedDefs.hpp"
#include <deque>
#include <vector>
#include <cairo/cairo.h>
enum eIconBackend {
enum eIconBackend : uint8_t {
ICONS_BACKEND_NONE = 0,
ICONS_BACKEND_NF,
ICONS_BACKEND_FA
@@ -19,17 +19,17 @@ enum eIconBackend {
static const std::array<std::array<std::string, ICON_NONE + 1>, 3 /* backends */> ICONS_ARRAY = {
std::array<std::string, ICON_NONE + 1>{"[!]", "[i]", "[Hint]", "[Err]", "[?]", "[ok]", ""},
std::array<std::string, ICON_NONE + 1>{"", "", "", "", "", "󰸞", ""}, std::array<std::string, ICON_NONE + 1>{"", "", "", "", "", ""}};
static const std::array<CColor, ICON_NONE + 1> ICONS_COLORS = {CColor{255.0 / 255.0, 204 / 255.0, 102 / 255.0, 1.0},
CColor{128 / 255.0, 255 / 255.0, 255 / 255.0, 1.0},
CColor{179 / 255.0, 255 / 255.0, 204 / 255.0, 1.0},
CColor{255 / 255.0, 77 / 255.0, 77 / 255.0, 1.0},
CColor{255 / 255.0, 204 / 255.0, 153 / 255.0, 1.0},
CColor{128 / 255.0, 255 / 255.0, 128 / 255.0, 1.0},
CColor{0, 0, 0, 1.0}};
static const std::array<CHyprColor, ICON_NONE + 1> ICONS_COLORS = {CHyprColor{255.0 / 255.0, 204 / 255.0, 102 / 255.0, 1.0},
CHyprColor{128 / 255.0, 255 / 255.0, 255 / 255.0, 1.0},
CHyprColor{179 / 255.0, 255 / 255.0, 204 / 255.0, 1.0},
CHyprColor{255 / 255.0, 77 / 255.0, 77 / 255.0, 1.0},
CHyprColor{255 / 255.0, 204 / 255.0, 153 / 255.0, 1.0},
CHyprColor{128 / 255.0, 255 / 255.0, 128 / 255.0, 1.0},
CHyprColor{0, 0, 0, 1.0}};
struct SNotification {
std::string text = "";
CColor color;
CHyprColor color;
CTimer started;
float timeMs = 0;
eIcons icon = ICON_NONE;
@@ -41,24 +41,24 @@ class CHyprNotificationOverlay {
CHyprNotificationOverlay();
~CHyprNotificationOverlay();
void draw(CMonitor* pMonitor);
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f);
void draw(PHLMONITOR pMonitor);
void addNotification(const std::string& text, const CHyprColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f);
void dismissNotifications(const int amount);
bool hasAny();
private:
CBox drawNotifications(CMonitor* pMonitor);
CBox m_bLastDamage;
CBox drawNotifications(PHLMONITOR pMonitor);
CBox m_bLastDamage;
std::deque<std::unique_ptr<SNotification>> m_dNotifications;
std::vector<std::unique_ptr<SNotification>> m_vNotifications;
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;
cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr;
CMonitor* m_pLastMonitor = nullptr;
Vector2D m_vecLastSize = Vector2D(-1, -1);
PHLMONITORREF m_pLastMonitor;
Vector2D m_vecLastSize = Vector2D(-1, -1);
SP<CTexture> m_pTexture;
SP<CTexture> m_pTexture;
};
inline std::unique_ptr<CHyprNotificationOverlay> g_pHyprNotificationOverlay;

View File

@@ -4,37 +4,21 @@
#include "RollingLogFollow.hpp"
#include <fstream>
#include <iostream>
#include <print>
#include <fcntl.h>
void Debug::init(const std::string& IS) {
logFile = IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
logOfs.open(logFile, std::ios::out | std::ios::app);
auto handle = logOfs.native_handle();
fcntl(handle, F_SETFD, FD_CLOEXEC);
}
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
if (level > wlr_log_get_verbosity())
return;
char* outputStr = nullptr;
vasprintf(&outputStr, fmt, args);
std::string output = std::string(outputStr);
free(outputStr);
rollingLog += output + "\n";
if (!disableLogs || !**disableLogs) {
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
ofs << "[wlr] " << output << "\n";
ofs.close();
}
if (!disableStdout)
std::cout << output << "\n";
void Debug::close() {
logOfs.close();
}
void Debug::log(LogLevel level, std::string str) {
void Debug::log(eLogLevel level, std::string str) {
if (level == TRACE && !trace)
return;
@@ -42,6 +26,7 @@ void Debug::log(LogLevel level, std::string str) {
return;
std::string coloredStr = str;
//NOLINTBEGIN
switch (level) {
case LOG:
str = "[LOG] " + str;
@@ -69,24 +54,22 @@ void Debug::log(LogLevel level, std::string str) {
break;
default: break;
}
//NOLINTEND
rollingLog += str + "\n";
if (rollingLog.size() > ROLLING_LOG_SIZE)
rollingLog = rollingLog.substr(rollingLog.size() - ROLLING_LOG_SIZE);
if (RollingLogFollow::Get().IsRunning())
RollingLogFollow::Get().AddLog(str);
if (SRollingLogFollow::get().isRunning())
SRollingLogFollow::get().addLog(str);
if (!disableLogs || !**disableLogs) {
// log to a file
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
ofs << str << "\n";
ofs.close();
logOfs << str << "\n";
logOfs.flush();
}
// log it to the stdout too.
if (!disableStdout)
std::cout << ((coloredLogs && !**coloredLogs) ? str : coloredStr) << "\n";
std::println("{}", ((coloredLogs && !**coloredLogs) ? str : coloredStr));
}

View File

@@ -4,13 +4,14 @@
#include <iostream>
#include <fstream>
#include <chrono>
#include <mutex>
#include "../includes.hpp"
#include "../helpers/MiscFunctions.hpp"
#define LOGMESSAGESIZE 1024
#define ROLLING_LOG_SIZE 4096
enum LogLevel {
enum eLogLevel : int8_t {
NONE = -1,
LOG = 0,
WARN,
@@ -20,8 +21,10 @@ enum LogLevel {
TRACE
};
// NOLINTNEXTLINE(readability-identifier-naming)
namespace Debug {
inline std::string logFile;
inline std::ofstream logOfs;
inline int64_t* const* disableLogs = nullptr;
inline int64_t* const* disableTime = nullptr;
inline bool disableStdout = false;
@@ -30,14 +33,19 @@ namespace Debug {
inline int64_t* const* coloredLogs = nullptr;
inline std::string rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
inline std::mutex logMutex;
void init(const std::string& IS);
void close();
//
void log(LogLevel level, std::string str);
void log(eLogLevel level, std::string str);
template <typename... Args>
void log(LogLevel level, std::format_string<Args...> fmt, Args&&... args) {
//NOLINTNEXTLINE
void log(eLogLevel level, std::format_string<Args...> fmt, Args&&... args) {
std::lock_guard<std::mutex> guard(logMutex);
if (level == TRACE && !trace)
return;
@@ -49,8 +57,9 @@ namespace Debug {
// print date and time to the ofs
if (disableTime && !**disableTime) {
#ifndef _LIBCPP_VERSION
const auto zt = std::chrono::zoned_time{std::chrono::current_zone(), std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
static auto current_zone = std::chrono::current_zone();
const auto zt = std::chrono::zoned_time{current_zone, std::chrono::system_clock::now()};
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
#else
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
@@ -67,6 +76,4 @@ namespace Debug {
log(level, logMsg);
}
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
};

View File

@@ -2,8 +2,9 @@
#include <shared_mutex>
// NOLINTNEXTLINE(readability-identifier-naming)
namespace Debug {
struct RollingLogFollow {
struct SRollingLogFollow {
std::unordered_map<int, std::string> socketToRollingLogFollowQueue;
std::shared_mutex m;
bool running = false;
@@ -15,12 +16,12 @@ namespace Debug {
return socketToRollingLogFollowQueue[socket].empty();
}
std::string DebugInfo() {
std::string debugInfo() {
std::shared_lock<std::shared_mutex> r(m);
return std::format("RollingLogFollow, got {} connections", socketToRollingLogFollowQueue.size());
}
std::string GetLog(int socket) {
std::string getLog(int socket) {
std::unique_lock<std::shared_mutex> w(m);
const std::string ret = socketToRollingLogFollowQueue[socket];
@@ -29,7 +30,7 @@ namespace Debug {
return ret;
};
void AddLog(std::string log) {
void addLog(const std::string& log) {
std::unique_lock<std::shared_mutex> w(m);
running = true;
std::vector<int> to_erase;
@@ -37,26 +38,26 @@ namespace Debug {
socketToRollingLogFollowQueue[p.first] += log + "\n";
}
bool IsRunning() {
bool isRunning() {
std::shared_lock<std::shared_mutex> r(m);
return running;
}
void StopFor(int socket) {
void stopFor(int socket) {
std::unique_lock<std::shared_mutex> w(m);
socketToRollingLogFollowQueue.erase(socket);
if (socketToRollingLogFollowQueue.empty())
running = false;
}
void StartFor(int socket) {
void startFor(int socket) {
std::unique_lock<std::shared_mutex> w(m);
socketToRollingLogFollowQueue[socket] = std::format("[LOG] Following log to socket: {} started\n", socket);
running = true;
}
static RollingLogFollow& Get() {
static RollingLogFollow instance;
static SRollingLogFollow& get() {
static SRollingLogFollow instance;
static std::mutex gm;
std::lock_guard<std::mutex> lock(gm);
return instance;

View File

@@ -1,6 +1,5 @@
#include "includes.hpp"
#include "debug/Log.hpp"
#include "helpers/WLListener.hpp"
#include "helpers/Color.hpp"
#include "macros.hpp"
#include "desktop/DesktopTypes.hpp"

View File

@@ -3,6 +3,7 @@
class CWorkspace;
class CWindow;
class CLayerSurface;
class CMonitor;
/* Shared pointer to a workspace */
typedef SP<CWorkspace> PHLWORKSPACE;
@@ -18,3 +19,8 @@ typedef WP<CWindow> PHLWINDOWREF;
typedef SP<CLayerSurface> PHLLS;
/* Weak pointer to a layer surface */
typedef WP<CLayerSurface> PHLLSREF;
/* Shared pointer to a monitor */
typedef SP<CMonitor> PHLMONITOR;
/* Weak pointer to a monitor */
typedef WP<CMonitor> PHLMONITORREF;

37
src/desktop/LayerRule.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include "LayerRule.hpp"
#include <unordered_set>
#include <algorithm>
#include "../debug/Log.hpp"
static const auto RULES = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order"};
CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : targetNamespace(ns_), rule(rule_) {
const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });
if (!VALID)
return;
if (rule == "noanim")
ruleType = RULE_NOANIM;
else if (rule == "blur")
ruleType = RULE_BLUR;
else if (rule == "blurpopups")
ruleType = RULE_BLURPOPUPS;
else if (rule == "dimaround")
ruleType = RULE_DIMAROUND;
else if (rule.starts_with("ignorealpha"))
ruleType = RULE_IGNOREALPHA;
else if (rule.starts_with("ignorezero"))
ruleType = RULE_IGNOREZERO;
else if (rule.starts_with("xray"))
ruleType = RULE_XRAY;
else if (rule.starts_with("animation"))
ruleType = RULE_ANIMATION;
else if (rule.starts_with("order"))
ruleType = RULE_ORDER;
else {
Debug::log(ERR, "CLayerRule: didn't match a rule that was found valid?!");
ruleType = RULE_INVALID;
}
}

28
src/desktop/LayerRule.hpp Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include <string>
#include <cstdint>
class CLayerRule {
public:
CLayerRule(const std::string& rule, const std::string& targetNS);
enum eRuleType : uint8_t {
RULE_INVALID = 0,
RULE_NOANIM,
RULE_BLUR,
RULE_BLURPOPUPS,
RULE_DIMAROUND,
RULE_IGNOREALPHA,
RULE_IGNOREZERO,
RULE_XRAY,
RULE_ANIMATION,
RULE_ORDER,
RULE_ZUMBA,
};
eRuleType ruleType = RULE_INVALID;
const std::string targetNamespace;
const std::string rule;
};

View File

@@ -6,9 +6,9 @@
#include "../managers/SeatManager.hpp"
PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource));
PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource));
CMonitor* pMonitor = resource->monitor.empty() ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->getMonitorFromName(resource->monitor);
auto pMonitor = resource->monitor.empty() ? g_pCompositor->m_pLastMonitor.lock() : g_pCompositor->getMonitorFromName(resource->monitor);
pLS->surface->assign(resource->surface.lock(), pLS);
@@ -18,7 +18,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
}
if (pMonitor->pMirrorOf)
pMonitor = g_pCompositor->m_vMonitors.front().get();
pMonitor = g_pCompositor->m_vMonitors.front();
pLS->self = pLS;
@@ -26,7 +26,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->layer = resource->current.layer;
pLS->popupHead = std::make_unique<CPopup>(pLS);
pLS->monitorID = pMonitor->ID;
pLS->monitor = pMonitor;
pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS);
pLS->forceBlur = g_pConfigManager->shouldBlurLS(pLS->szNamespace);
@@ -50,7 +50,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
void CLayerSurface::registerCallbacks() {
alpha.setUpdateCallback([this](void*) {
if (dimAround)
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(monitorID));
g_pHyprRenderer->damageMonitor(monitor.lock());
});
}
@@ -71,14 +71,20 @@ CLayerSurface::~CLayerSurface() {
surface->unassign();
g_pHyprRenderer->makeEGLCurrent();
std::erase_if(g_pHyprOpenGL->m_mLayerFramebuffers, [&](const auto& other) { return other.first.expired() || other.first.lock() == self.lock(); });
for (auto const& mon : g_pCompositor->m_vRealMonitors) {
for (auto& lsl : mon->m_aLayerSurfaceLayers) {
std::erase_if(lsl, [this](auto& ls) { return ls.expired() || ls.get() == this; });
}
}
}
void CLayerSurface::onDestroy() {
Debug::log(LOG, "LayerSurface {:x} destroyed", (uintptr_t)layerSurface);
Debug::log(LOG, "LayerSurface {:x} destroyed", (uintptr_t)layerSurface.get());
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
const auto PMONITOR = monitor.lock();
if (!g_pCompositor->getMonitorFromID(monitorID))
if (!PMONITOR)
Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)");
if (!fadingOut) {
@@ -111,20 +117,27 @@ void CLayerSurface::onDestroy() {
layerSurface.reset();
if (surface)
surface->unassign();
listeners.unmap.reset();
listeners.destroy.reset();
listeners.map.reset();
listeners.commit.reset();
}
void CLayerSurface::onMap() {
Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)layerSurface);
Debug::log(LOG, "LayerSurface {:x} mapped", (uintptr_t)layerSurface.get());
mapped = true;
interactivity = layerSurface->current.interactivity;
layerSurface->surface->map();
// this layer might be re-mapped.
fadingOut = false;
g_pCompositor->removeFromFadingOutSafe(self.lock());
// fix if it changed its mon
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
const auto PMONITOR = monitor.lock();
if (!PMONITOR)
return;
@@ -162,8 +175,7 @@ void CLayerSurface::onMap() {
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
const auto WORKSPACE = PMONITOR->activeWorkspace;
const bool FULLSCREEN = WORKSPACE->m_bHasFullscreenWindow && WORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL;
const bool FULLSCREEN = PMONITOR->activeWorkspace && PMONITOR->activeWorkspace->m_bHasFullscreenWindow && PMONITOR->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN;
startAnimation(!(layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP && FULLSCREEN && !GRABSFOCUS));
readyToDelete = false;
@@ -177,19 +189,21 @@ void CLayerSurface::onMap() {
}
void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)layerSurface);
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)layerSurface.get());
g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", layerSurface->layerNamespace});
EMIT_HOOK_EVENT("closeLayer", self.lock());
std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });
if (!g_pCompositor->getMonitorFromID(monitorID) || g_pCompositor->m_bUnsafeState) {
if (!monitor || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(self.lock());
mapped = false;
if (layerSurface && layerSurface->surface)
layerSurface->surface->unmap();
startAnimation(false);
return;
@@ -201,19 +215,24 @@ void CLayerSurface::onUnmap() {
startAnimation(false);
mapped = false;
if (layerSurface && layerSurface->surface)
layerSurface->surface->unmap();
g_pCompositor->addToFadingOutSafe(self.lock());
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
const auto PMONITOR = monitor.lock();
const bool WASLASTFOCUS = g_pCompositor->m_pLastFocus == surface->resource();
const bool WASLASTFOCUS = g_pSeatManager->state.keyboardFocus == surface->resource() || g_pSeatManager->state.pointerFocus == surface->resource();
if (!PMONITOR)
return;
// refocus if needed
if (WASLASTFOCUS)
// vvvvvvvvvvvvv if there is a last focus and the last focus is not keyboard focusable, fallback to window
if (WASLASTFOCUS || (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus->hlSurface && !g_pCompositor->m_pLastFocus->hlSurface->keyboardFocusable()))
g_pInputManager->refocusLastWindow(PMONITOR);
else if (g_pCompositor->m_pLastFocus && g_pCompositor->m_pLastFocus != surface->resource())
g_pSeatManager->setKeyboardFocus(g_pCompositor->m_pLastFocus.lock());
CBox geomFixed = {geometry.x + PMONITOR->vecPosition.x, geometry.y + PMONITOR->vecPosition.y, geometry.width, geometry.height};
g_pHyprRenderer->damageBox(&geomFixed);
@@ -233,16 +252,16 @@ void CLayerSurface::onCommit() {
if (!mapped) {
// we're re-mapping if this is the case
if (layerSurface->surface && !layerSurface->surface->current.buffer) {
if (layerSurface->surface && !layerSurface->surface->current.texture) {
fadingOut = false;
geometry = {};
g_pHyprRenderer->arrangeLayersForMonitor(monitorID);
g_pHyprRenderer->arrangeLayersForMonitor(monitorID());
}
return;
}
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
const auto PMONITOR = monitor.lock();
if (!PMONITOR)
return;
@@ -301,8 +320,18 @@ void CLayerSurface::onCommit() {
realSize.setValueAndWarp(geometry.size());
}
if (mapped) {
const bool WASLASTFOCUS = g_pCompositor->m_pLastFocus == surface->resource();
if (mapped && (layerSurface->current.committed & CLayerShellResource::eCommittedState::STATE_INTERACTIVITY)) {
bool WASLASTFOCUS = false;
layerSurface->surface->breadthfirst(
[&WASLASTFOCUS](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { WASLASTFOCUS = WASLASTFOCUS || g_pSeatManager->state.keyboardFocus == surf; },
nullptr);
if (!WASLASTFOCUS && popupHead) {
popupHead->breadthfirst(
[&WASLASTFOCUS](CPopup* popup, void* data) {
WASLASTFOCUS = WASLASTFOCUS || (popup->m_pWLSurface && g_pSeatManager->state.keyboardFocus == popup->m_pWLSurface->resource());
},
nullptr);
}
const bool WASEXCLUSIVE = interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
const bool ISEXCLUSIVE = layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;
@@ -312,11 +341,13 @@ void CLayerSurface::onCommit() {
std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });
// if the surface was focused and interactive but now isn't, refocus
if (WASLASTFOCUS && !layerSurface->current.interactivity) {
if (WASLASTFOCUS && layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) {
// moveMouseUnified won't focus non interactive layers but it won't unfocus them either,
// so unfocus the surface here.
g_pCompositor->focusSurface(nullptr);
g_pInputManager->refocusLastWindow(g_pCompositor->getMonitorFromID(monitorID));
g_pInputManager->refocusLastWindow(monitor.lock());
} else if (WASLASTFOCUS && WASEXCLUSIVE && layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
g_pInputManager->simulateMouseMovement();
} else if (!WASEXCLUSIVE && ISEXCLUSIVE) {
// if now exclusive and not previously
g_pSeatManager->setGrab(nullptr);
@@ -346,34 +377,58 @@ void CLayerSurface::applyRules() {
xray = -1;
animationStyle.reset();
for (auto& rule : g_pConfigManager->getMatchingRules(self.lock())) {
if (rule.rule == "noanim")
noAnimations = true;
else if (rule.rule == "blur")
forceBlur = true;
else if (rule.rule == "blurpopups")
forceBlurPopups = true;
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
std::string alphaValue = "";
if (FIRST_SPACE_POS != std::string::npos)
alphaValue = rule.rule.substr(FIRST_SPACE_POS + 1);
for (auto const& rule : g_pConfigManager->getMatchingRules(self.lock())) {
switch (rule->ruleType) {
case CLayerRule::RULE_NOANIM: {
noAnimations = true;
break;
}
case CLayerRule::RULE_BLUR: {
forceBlur = true;
break;
}
case CLayerRule::RULE_BLURPOPUPS: {
forceBlurPopups = true;
break;
}
case CLayerRule::RULE_IGNOREALPHA:
case CLayerRule::RULE_IGNOREZERO: {
const auto FIRST_SPACE_POS = rule->rule.find_first_of(' ');
std::string alphaValue = "";
if (FIRST_SPACE_POS != std::string::npos)
alphaValue = rule->rule.substr(FIRST_SPACE_POS + 1);
try {
ignoreAlpha = true;
if (!alphaValue.empty())
ignoreAlphaValue = std::stof(alphaValue);
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
} else if (rule.rule == "dimaround") {
dimAround = true;
} else if (rule.rule.starts_with("xray")) {
CVarList vars{rule.rule, 0, ' '};
try {
xray = configStringToInt(vars[1]);
} catch (...) {}
} else if (rule.rule.starts_with("animation")) {
CVarList vars{rule.rule, 2, 's'};
animationStyle = vars[1];
try {
ignoreAlpha = true;
if (!alphaValue.empty())
ignoreAlphaValue = std::stof(alphaValue);
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
break;
}
case CLayerRule::RULE_DIMAROUND: {
dimAround = true;
break;
}
case CLayerRule::RULE_XRAY: {
CVarList vars{rule->rule, 0, ' '};
try {
xray = configStringToInt(vars[1]).value_or(false);
} catch (...) {}
break;
}
case CLayerRule::RULE_ANIMATION: {
CVarList vars{rule->rule, 2, 's'};
animationStyle = vars[1];
break;
}
case CLayerRule::RULE_ORDER: {
CVarList vars{rule->rule, 2, 's'};
try {
order = std::stoi(vars[1]);
} catch (...) { Debug::log(ERR, "Invalid value passed to order"); }
break;
}
default: break;
}
}
}
@@ -520,3 +575,7 @@ int CLayerSurface::popupsCount() {
popupHead->breadthfirst([](CPopup* p, void* data) { *(int*)data += 1; }, &no);
return no;
}
MONITORID CLayerSurface::monitorID() {
return monitor ? monitor->ID : MONITOR_INVALID;
}

View File

@@ -4,11 +4,7 @@
#include "../defines.hpp"
#include "WLSurface.hpp"
#include "../helpers/AnimatedVariable.hpp"
struct SLayerRule {
std::string targetNamespace = "";
std::string rule = "";
};
#include "LayerRule.hpp"
class CLayerShellResource;
@@ -42,7 +38,7 @@ class CLayerSurface {
bool mapped = false;
uint32_t layer = 0;
int monitorID = -1;
PHLMONITORREF monitor;
bool fadingOut = false;
bool readyToDelete = false;
@@ -51,10 +47,11 @@ class CLayerSurface {
bool forceBlur = false;
bool forceBlurPopups = false;
int xray = -1;
int64_t xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
bool dimAround = false;
int64_t order = 0;
std::optional<std::string> animationStyle;
@@ -69,6 +66,7 @@ class CLayerSurface {
void onMap();
void onUnmap();
void onCommit();
MONITORID monitorID();
private:
struct {
@@ -82,6 +80,6 @@ class CLayerSurface {
// For the list lookup
bool operator==(const CLayerSurface& rhs) const {
return layerSurface == rhs.layerSurface && monitorID == rhs.monitorID;
return layerSurface == rhs.layerSurface && monitor == rhs.monitor;
}
};

View File

@@ -4,6 +4,8 @@
#include "../protocols/LayerShell.hpp"
#include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../managers/SeatManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include <ranges>
CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) {
@@ -14,15 +16,12 @@ CPopup::CPopup(PHLLS pOwner) : m_pLayerOwner(pOwner) {
initAllSignals();
}
CPopup::CPopup(SP<CXDGPopupResource> popup, CPopup* pOwner) : m_pParent(pOwner), m_pResource(popup) {
CPopup::CPopup(SP<CXDGPopupResource> popup, CPopup* pOwner) : m_pWindowOwner(pOwner->m_pWindowOwner), m_pLayerOwner(pOwner->m_pLayerOwner), m_pParent(pOwner), m_pResource(popup) {
m_pWLSurface = CWLSurface::create();
m_pWLSurface->assign(popup->surface->surface.lock(), this);
m_pLayerOwner = pOwner->m_pLayerOwner;
m_pWindowOwner = pOwner->m_pWindowOwner;
m_vLastSize = popup->surface->current.geometry.size();
unconstrain();
reposition();
initAllSignals();
}
@@ -55,7 +54,7 @@ void CPopup::initAllSignals() {
}
void CPopup::onNewPopup(SP<CXDGPopupResource> popup) {
const auto POPUP = m_vChildren.emplace_back(std::make_unique<CPopup>(popup, this)).get();
const auto POPUP = m_vChildren.emplace_back(makeShared<CPopup>(popup, this)).get();
Debug::log(LOG, "New popup at {:x}", (uintptr_t)POPUP);
}
@@ -106,6 +105,8 @@ void CPopup::onUnmap() {
return;
}
m_bMapped = false;
m_vLastSize = m_pResource->surface->surface->current.size;
const auto COORDS = coordsGlobal();
@@ -116,8 +117,6 @@ void CPopup::onUnmap() {
m_pSubsurfaceHead.reset();
g_pInputManager->simulateMouseMovement();
if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
@@ -131,6 +130,11 @@ void CPopup::onUnmap() {
g_pHyprRenderer->damageBox(&box);
},
nullptr);
const bool WASLASTFOCUS = g_pSeatManager->state.keyboardFocus == m_pWLSurface->resource() || g_pSeatManager->state.pointerFocus == m_pWLSurface->resource();
if (WASLASTFOCUS)
g_pInputManager->simulateMouseMovement();
}
void CPopup::onCommit(bool ignoreSiblings) {
@@ -188,18 +192,25 @@ void CPopup::onReposition() {
m_vLastPos = coordsRelativeToParent();
unconstrain();
reposition();
}
void CPopup::unconstrain() {
void CPopup::reposition() {
const auto COORDS = t1ParentCoords();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
if (!PMONITOR)
return;
CBox box = {PMONITOR->vecPosition.x - COORDS.x, PMONITOR->vecPosition.y - COORDS.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
m_pResource->applyPositioning(box, COORDS - PMONITOR->vecPosition);
CBox box = {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
m_pResource->applyPositioning(box, COORDS);
}
SP<CWLSurface> CPopup::getT1Owner() {
if (m_pWindowOwner)
return m_pWindowOwner->m_pWLSurface;
else
return m_pLayerOwner->surface;
}
Vector2D CPopup::coordsRelativeToParent() {
@@ -250,7 +261,8 @@ void CPopup::recheckTree() {
}
void CPopup::recheckChildrenRecursive() {
for (auto& c : m_vChildren) {
auto cpy = m_vChildren;
for (auto const& c : cpy) {
c->onCommit(true);
c->recheckChildrenRecursive();
}
@@ -280,15 +292,16 @@ bool CPopup::visible() {
return false;
}
void CPopup::bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data) {
for (auto& n : nodes) {
void CPopup::bfHelper(std::vector<CPopup*> const& nodes, std::function<void(CPopup*, void*)> fn, void* data) {
for (auto const& n : nodes) {
fn(n, data);
}
std::vector<CPopup*> nodes2;
nodes2.reserve(nodes.size() * 2);
for (auto& n : nodes) {
for (auto& c : n->m_vChildren) {
for (auto const& n : nodes) {
for (auto const& c : n->m_vChildren) {
nodes2.push_back(c.get());
}
}
@@ -307,8 +320,8 @@ CPopup* CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
std::vector<CPopup*> popups;
breadthfirst([](CPopup* popup, void* data) { ((std::vector<CPopup*>*)data)->push_back(popup); }, &popups);
for (auto& p : popups | std::views::reverse) {
if (!p->m_pResource)
for (auto const& p : popups | std::views::reverse) {
if (!p->m_pResource || !p->m_bMapped)
continue;
if (!allowsInput) {

View File

@@ -18,21 +18,22 @@ class CPopup {
~CPopup();
Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();
SP<CWLSurface> getT1Owner();
Vector2D coordsRelativeToParent();
Vector2D coordsGlobal();
Vector2D size();
Vector2D size();
void onNewPopup(SP<CXDGPopupResource> popup);
void onDestroy();
void onMap();
void onUnmap();
void onCommit(bool ignoreSiblings = false);
void onReposition();
void onNewPopup(SP<CXDGPopupResource> popup);
void onDestroy();
void onMap();
void onUnmap();
void onCommit(bool ignoreSiblings = false);
void onReposition();
void recheckTree();
void recheckTree();
bool visible();
bool visible();
// will also loop over this node
void breadthfirst(std::function<void(CPopup*, void*)> fn, void* data);
@@ -40,6 +41,7 @@ class CPopup {
//
SP<CWLSurface> m_pWLSurface;
bool m_bMapped = false;
private:
// T1 owners, each popup has to have one of these
@@ -56,12 +58,11 @@ class CPopup {
bool m_bRequestedReposition = false;
bool m_bInert = false;
bool m_bMapped = false;
bool m_bInert = false;
//
std::vector<std::unique_ptr<CPopup>> m_vChildren;
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
std::vector<SP<CPopup>> m_vChildren;
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
struct {
CHyprSignalListener newPopup;
@@ -74,11 +75,11 @@ class CPopup {
} listeners;
void initAllSignals();
void unconstrain();
void reposition();
void recheckChildrenRecursive();
void sendScale();
Vector2D localToGlobal(const Vector2D& rel);
Vector2D t1ParentCoords();
static void bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data);
};
static void bfHelper(std::vector<CPopup*> const& nodes, std::function<void(CPopup*, void*)> fn, void* data);
};

View File

@@ -30,13 +30,7 @@ CSubsurface::CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, CPopup* pOwner)
}
CSubsurface::~CSubsurface() {
hyprListener_newSubsurface.removeCallback();
if (!m_pSubsurface)
return;
hyprListener_commitSubsurface.removeCallback();
hyprListener_destroySubsurface.removeCallback();
;
}
void CSubsurface::initSignals() {
@@ -65,7 +59,7 @@ void CSubsurface::checkSiblingDamage() {
const double SCALE = m_pWindowParent.lock() && m_pWindowParent->m_bIsX11 ? 1.0 / m_pWindowParent->m_fX11SurfaceScaledBy : 1.0;
for (auto& n : m_pParent->m_vChildren) {
for (auto const& n : m_pParent->m_vChildren) {
if (n.get() == this)
continue;
@@ -75,7 +69,7 @@ void CSubsurface::checkSiblingDamage() {
}
void CSubsurface::recheckDamageForSubsurfaces() {
for (auto& n : m_vChildren) {
for (auto const& n : m_vChildren) {
const auto COORDS = n->coordsGlobal();
g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y);
}
@@ -183,7 +177,7 @@ Vector2D CSubsurface::coordsGlobal() {
}
void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) {
for (auto& s : pSurface->subsurfaces) {
for (auto const& s : pSurface->subsurfaces) {
if (!s || s->surface->hlSurface /* already assigned */)
continue;
onNewSubsurface(s.lock());

View File

@@ -35,10 +35,6 @@ class CSubsurface {
void recheckDamageForSubsurfaces();
private:
DYNLISTENER(destroySubsurface);
DYNLISTENER(commitSubsurface);
DYNLISTENER(newSubsurface);
struct {
CHyprSignalListener destroySubsurface;
CHyprSignalListener commitSubsurface;

View File

@@ -1,6 +1,7 @@
#include "WLSurface.hpp"
#include "../Compositor.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../protocols/LayerShell.hpp"
void CWLSurface::assign(SP<CWLSurfaceResource> pSurface) {
m_pResource = pSurface;
@@ -56,12 +57,12 @@ bool CWLSurface::small() const {
if (!validMapped(m_pWindowOwner) || !exists())
return false;
if (!m_pResource->current.buffer)
if (!m_pResource->current.texture)
return false;
const auto O = m_pWindowOwner.lock();
return O->m_vReportedSize.x > m_pResource->current.buffer->size.x + 1 || O->m_vReportedSize.y > m_pResource->current.buffer->size.y + 1;
return O->m_vReportedSize.x > m_pResource->current.size.x + 1 || O->m_vReportedSize.y > m_pResource->current.size.y + 1;
}
Vector2D CWLSurface::correctSmallVec() const {
@@ -74,33 +75,52 @@ Vector2D CWLSurface::correctSmallVec() const {
return Vector2D{(O->m_vReportedSize.x - SIZE.x) / 2, (O->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_vRealSize.value() / O->m_vReportedSize);
}
Vector2D CWLSurface::getViewporterCorrectedSize() const {
if (!exists() || !m_pResource->current.buffer)
Vector2D CWLSurface::correctSmallVecBuf() const {
if (!exists() || !small() || m_bFillIgnoreSmall || !m_pResource->current.texture)
return {};
return m_pResource->current.viewport.hasDestination ? m_pResource->current.viewport.destination : m_pResource->current.buffer->size;
const auto SIZE = getViewporterCorrectedSize();
const auto BS = m_pResource->current.bufferSize;
return Vector2D{(BS.x - SIZE.x) / 2, (BS.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY});
}
CRegion CWLSurface::logicalDamage() const {
if (!m_pResource->current.buffer)
Vector2D CWLSurface::getViewporterCorrectedSize() const {
if (!exists() || !m_pResource->current.texture)
return {};
return m_pResource->current.viewport.hasDestination ? m_pResource->current.viewport.destination : m_pResource->current.bufferSize;
}
CRegion CWLSurface::computeDamage() const {
if (!m_pResource->current.texture)
return {};
CRegion damage = m_pResource->accumulateCurrentBufferDamage();
damage.transform(wlTransformToHyprutils(m_pResource->current.transform), m_pResource->current.buffer->size.x, m_pResource->current.buffer->size.y);
damage.scale(1.0 / m_pResource->current.scale);
damage.transform(wlTransformToHyprutils(m_pResource->current.transform), m_pResource->current.bufferSize.x, m_pResource->current.bufferSize.y);
const auto VPSIZE = getViewporterCorrectedSize();
const auto CORRECTVEC = correctSmallVec();
const auto BUFSIZE = m_pResource->current.bufferSize;
const auto CORRECTVEC = correctSmallVecBuf();
if (m_pResource->current.viewport.hasSource)
damage.intersect(m_pResource->current.viewport.source);
const auto SCALEDSRCSIZE =
m_pResource->current.viewport.hasSource ? m_pResource->current.viewport.source.size() * m_pResource->current.scale : m_pResource->current.buffer->size;
const auto SCALEDSRCSIZE = m_pResource->current.viewport.hasSource ? m_pResource->current.viewport.source.size() * m_pResource->current.scale : m_pResource->current.bufferSize;
damage.scale({VPSIZE.x / SCALEDSRCSIZE.x, VPSIZE.y / SCALEDSRCSIZE.y});
damage.scale({BUFSIZE.x / SCALEDSRCSIZE.x, BUFSIZE.y / SCALEDSRCSIZE.y});
damage.translate(CORRECTVEC);
// go from buffer coords in the damage to hl logical
const auto BOX = getSurfaceBoxGlobal();
const Vector2D SCALE = BOX.has_value() ? BOX->size() / m_pResource->current.bufferSize :
Vector2D{1.0 / m_pResource->current.scale, 1.0 / m_pResource->current.scale /* Wrong... but we can't really do better */};
damage.scale(SCALE);
if (m_pWindowOwner)
damage.scale(m_pWindowOwner->m_fX11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
return damage;
}
@@ -141,27 +161,27 @@ void CWLSurface::init() {
Debug::log(LOG, "CWLSurface {:x} called init()", (uintptr_t)this);
}
PHLWINDOW CWLSurface::getWindow() {
PHLWINDOW CWLSurface::getWindow() const {
return m_pWindowOwner.lock();
}
PHLLS CWLSurface::getLayer() {
PHLLS CWLSurface::getLayer() const {
return m_pLayerOwner.lock();
}
CPopup* CWLSurface::getPopup() {
CPopup* CWLSurface::getPopup() const {
return m_pPopupOwner;
}
CSubsurface* CWLSurface::getSubsurface() {
CSubsurface* CWLSurface::getSubsurface() const {
return m_pSubsurfaceOwner;
}
bool CWLSurface::desktopComponent() {
bool CWLSurface::desktopComponent() const {
return !m_pLayerOwner.expired() || !m_pWindowOwner.expired() || m_pSubsurfaceOwner || m_pPopupOwner;
}
std::optional<CBox> CWLSurface::getSurfaceBoxGlobal() {
std::optional<CBox> CWLSurface::getSurfaceBoxGlobal() const {
if (!desktopComponent())
return {};
@@ -181,7 +201,7 @@ void CWLSurface::appendConstraint(WP<CPointerConstraint> constraint) {
m_pConstraint = constraint;
}
SP<CPointerConstraint> CWLSurface::constraint() {
SP<CPointerConstraint> CWLSurface::constraint() const {
return m_pConstraint.lock();
}
@@ -202,3 +222,11 @@ SP<CWLSurface> CWLSurface::fromResource(SP<CWLSurfaceResource> pSurface) {
return nullptr;
return pSurface->hlSurface.lock();
}
bool CWLSurface::keyboardFocusable() const {
if (m_pWindowOwner || m_pPopupOwner || m_pSubsurfaceOwner)
return true;
if (m_pLayerOwner && m_pLayerOwner->layerSurface)
return m_pLayerOwner->layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
return false;
}

View File

@@ -33,22 +33,24 @@ class CWLSurface {
SP<CWLSurfaceResource> resource() const;
bool exists() const;
bool small() const; // means surface is smaller than the requested size
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
bool small() const; // means surface is smaller than the requested size
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
Vector2D correctSmallVecBuf() const; // returns a corrective vector for small() surfaces, in BL coords
Vector2D getViewporterCorrectedSize() const;
CRegion logicalDamage() const;
CRegion computeDamage() const; // logical coordinates. May be wrong if the surface is unassigned
bool visible();
bool keyboardFocusable() const;
// getters for owners.
PHLWINDOW getWindow();
PHLLS getLayer();
CPopup* getPopup();
CSubsurface* getSubsurface();
PHLWINDOW getWindow() const;
PHLLS getLayer() const;
CPopup* getPopup() const;
CSubsurface* getSubsurface() const;
// desktop components misc utils
std::optional<CBox> getSurfaceBoxGlobal();
std::optional<CBox> getSurfaceBoxGlobal() const;
void appendConstraint(WP<CPointerConstraint> constraint);
SP<CPointerConstraint> constraint();
SP<CPointerConstraint> constraint() const;
// allow stretching. Useful for plugins.
bool m_bFillIgnoreSmall = false;
@@ -107,7 +109,7 @@ class CWLSurface {
void destroy();
void init();
bool desktopComponent();
bool desktopComponent() const;
struct {
CHyprSignalListener destroy;

File diff suppressed because it is too large Load Diff

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