Compare commits

..

135 commits

Author SHA1 Message Date
outfoxxed
d4c92973b5
i3/ipc: ensure monitor/workspace pointers are nulled on destroy 2026-04-09 00:34:57 -07:00
outfoxxed
7f7ab6bc8a
launch: use dup2 to reset daemon stdio over close+open 2026-04-09 00:10:49 -07:00
outfoxxed
7208f68bb7
core: add QS_DROP_EXPENSIVE_FONTS env var 2026-04-08 01:35:15 -07:00
outfoxxed
f0d0216b3d
core: add DropExpensiveFonts pragma disabling woff and woff2 fonts 2026-04-08 00:48:58 -07:00
outfoxxed
7c5a6c4bd4
core/log: crash if Quickshell's log filter is installed twice
Crashes from recursion inside filterCategories through the old filter
have been observed. Presumably this means the log filter is getting
installed twice somehow. This should catch it.
2026-04-06 00:45:26 -07:00
outfoxxed
5bf6a412b0
core: correctly construct runtime path when XDG_RUNTIME_DIR missing
Fixes a typo of % as $, which broke string substitution.
2026-04-06 00:43:02 -07:00
outfoxxed
13fe9b0d98
services/pipewire: avoid blanket disconnect for default nodes
The same nodes can be both default and default configured nodes. When
the default and default configured node are not changed in unison, a
blanket disconnect will also disconnect the other's destroy handler,
causing a crash if the other is accessed after the node is destroyed.
2026-04-06 00:42:29 -07:00
outfoxxed
ad5fd9116e
wm: add nullptr guard to WindowManager::screenProjection 2026-04-04 13:51:32 -07:00
outfoxxed
49d4f46cf1
io/fileview: handle deserialization to list<T> properties 2026-04-04 13:05:33 -07:00
outfoxxed
9b98d10178
io/fileview: try to convert values to json before handling sequences
The previous code was interpreting a string as a list of characters
and therefore a sequence.
2026-04-04 12:28:40 -07:00
outfoxxed
854088c48c
io/fileview: convert containers to QVariantList/Map before serialize
QJsonValue::fromVariant doesn't do this automatically for some reason.
2026-04-04 02:06:22 -07:00
bbedward
b4e71cb2c0
core/window: add parentWindow property to FloatingWindow 2026-04-03 21:36:18 -07:00
outfoxxed
ceac3c6cfa
io/fileview: use QVariant when QJSValue cast fails in adapter prop read
A QVariant(QVariantMap) does not convert implicitly to a
QVaraint(QJSValue), causing extra signals to be emitted if the old
value was not updated by js (replaced by a QJSValue) before
deserializing again.
2026-04-03 21:36:02 -07:00
outfoxxed
aaff22f4b0
io/fileview: write values into correct JsonObjects in deserialize
Property writes were being done on the JsonAdapter and not the child
JsonObject, resulting in the data of children being set on the
adapter's props, and occasional crashes.
2026-04-03 21:35:11 -07:00
HigherOrderLogic
50cdf98868
core/colorquant: add imageRect option for cropping image 2026-04-03 00:30:27 -07:00
outfoxxed
4b751ccb0d
wayland/screencopy: use linear texture filtering over nearest
Fixes pixelated views at scaled resolutions.
2026-04-03 00:03:27 -07:00
Carson Powers
20c691cdf1
networking: add PSK, settings and connection status support 2026-04-02 20:26:08 -07:00
outfoxxed
92b336c80c
tooling: ensure intercepts do not overwrite symlinks to cfg files
Intercept-file writes could end up opening an existing vfs symlink
back to the user's actual config instead of creating a new file in the
vfs.
2026-04-02 03:25:42 -07:00
2 * r + 2 * t
d612227740
core/qmlglobal: add shellId, instanceId, appId and launchTime props 2026-03-31 02:49:24 -07:00
outfoxxed
b83c39c8af
services/pipewire: add -fno-strict-overflow to fix PCH with pipewire
Unclear how this should be handled long term.
2026-03-30 21:42:08 -07:00
Mia Herkt
ee1100eb98
wayland/buffer: drop unused GLESv3 include
That one is often in a separate Mesa package and contrary to GLESv2
doesn’t come with a pkg-config file. Mildly annoying…
2026-03-29 09:31:28 +02:00
outfoxxed
9bf752ac33
crash: add std::terminate handler 2026-03-28 23:07:37 -07:00
outfoxxed
313f4e47f6
core: track XDG_CURRENT_DESKTOP in debuginfo 2026-03-28 20:28:03 -07:00
outfoxxed
6ef86dd5aa
crash: run platform compat hooks in crash reporter init
For some reason, QtWayland crashes we work around trigger in this
path. This was previously masked when the crash reporter didn't unmask
signals, as long as the original process crashed with SIGSEGV.
2026-03-28 20:27:57 -07:00
outfoxxed
308f1e249b
crash: unmask signals before reexec
Signals were previously left masked before reexec, causing UB if a
child were to crash again, instead of triggering the reporter.

This might've been responsible for a number of unexplainable bugs.
2026-03-28 20:27:48 -07:00
outfoxxed
08058326f0
core: reuse global pragma parsing js engine during scanning
QJSEngine cleanup is not fast or clean and results in speed
degradation over time if too many are destroyed.
2026-03-25 00:16:36 -07:00
bbedward
6a244c3c56
core/region: add per-corner radius support 2026-03-19 23:42:32 -07:00
bbedward
d745184823
wayland/background-effect: add ext-background-effect-v1 support 2026-03-19 23:39:21 -07:00
bbedward
77c04a9447
launch: add ability to override AppId via pragma or QS_APP_ID 2026-03-19 22:33:32 -07:00
Dan Aloni
eb6eaf59c7
core/log: add a mutex to protect stdoutStream
QTextStream is not thread safe.
2026-03-19 03:36:12 -07:00
Mia Herkt
7511545ee2
build: add missing wayland-client CFLAGS
Fixes #276
2026-03-19 03:30:11 -07:00
outfoxxed
0cb62920a7
hyprland/focus_grab: handle destruction of tracked windows 2026-03-18 02:39:22 -07:00
outfoxxed
3520c85d77
wayland: remove --require-defined linker argument
Not supported by lld
2026-03-17 19:42:47 -07:00
outfoxxed
3cf65af49f
docs: ask users not to submit v1 crash reports 2026-03-17 10:10:01 -07:00
-k
a51dcd0a01
wayland: use patched surfaceRole accessor on FreeBSD 2026-03-17 00:08:25 -07:00
-k
97b2688ad6
core/log: fix non-linux typo and import unistd on freebsd 2026-03-17 00:01:34 -07:00
-k
0a859d51f2
service/pam: include signal.h on freebsd 2026-03-17 00:01:24 -07:00
outfoxxed
1bd5b083cb
hyprland/ipc: add null checks and ws preinit to toplevel object init
Previously HyprlandToplevel::updateFromObject did not call
findWorkspaceByName with createIfMissing=true, leaving bWorkspace null
for a later insertToplevel call from HyprlandIpc::refreshToplevels.
2026-03-16 22:47:01 -07:00
outfoxxed
365bf16b1e
wayland: hook wl_proxy_get_listener avoiding QTBUG-145022 crash
Co-authored-by: Lemmy <studio@quadbyte.net>
2026-03-16 21:42:20 -07:00
outfoxxed
6705e2da77
wm: add WindowManager module with ext-workspace support 2026-03-16 01:08:26 -07:00
outfoxxed
9e8eecf2b8
core: log qt related environment variables in debuginfo 2026-03-15 21:13:35 -07:00
outfoxxed
1b2519d9f3
core: log gpu information in debuginfo 2026-03-14 02:31:47 -07:00
outfoxxed
1123d5ab4f
core: move crash/version debug info to one place 2026-03-14 02:31:28 -07:00
outfoxxed
4b77936c80
crash: allow overriding crash reporter url 2026-03-13 02:04:01 -07:00
outfoxxed
e32b909354
core: add disable env vars for file watcher and crash handler 2026-03-13 01:10:09 -07:00
outfoxxed
178c04b59c
docs: revise contribution policy and related files 2026-03-13 00:33:36 -07:00
outfoxxed
706d6de7b0
crash: unmask signals in coredump fork
Fixes the fork just sticking around and not dumping a core.
2026-03-12 04:02:24 -07:00
outfoxxed
9a9c605250
core: hash scanned files and don't trigger a reload if matching
Nix builds often trip QFileSystemWatcher, causing random reloads.
2026-03-11 21:52:13 -07:00
outfoxxed
bd62179277
all: retry incomplete socket reads
Fixes greetd and hyprland ipc sockets reads being incomplete and
breaking said integrations on slow machines.
2026-03-10 00:54:45 -07:00
-k
cf1a2aeb2d
wayland/toplevel: clear activeToplevel on deactivation 2026-03-09 19:37:15 -07:00
outfoxxed
15a8409765
ipc: handle null currentGeneration in IpcKillCommand::exec 2026-03-07 15:19:36 -08:00
Moraxyc
6bcd3d9bbf
nix: use libxcb directly 2026-03-06 03:15:20 -08:00
outfoxxed
c030300191
core/desktopentry: preserve desktop action order 2026-03-06 01:40:02 -08:00
outfoxxed
5721955686
services/pipewire: ignore ENOENT errors
Pipewire describes all errors as fatal, however these just aren't,
don't seem to be squashable, and resetting for them breaks users.
2026-03-04 23:26:33 -08:00
outfoxxed
a849a88893
build: remove DISTRIBUTOR_DEBUGINFO_AVAILABLE 2026-03-03 00:40:36 -08:00
outfoxxed
cdde4c63f4
crash: switch to cpptrace from breakpad 2026-03-02 19:35:38 -08:00
Carson Powers
cddb4f061b
build: fix lint-staged to ignore deleted files
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-02-24 01:43:02 -08:00
outfoxxed
6e17efab83
wayland/screencopy: enable vulkan dmabuf support on session locks
Also reformat dmabuf
2026-02-24 00:05:20 -08:00
bbedward
36517a2c10
services/pipewire: manage default objs using normal qt properties
Fixes use after free bugs due to pointer mismatches in destructors.
Drops SimpleObjectHandle.
2026-02-23 23:17:42 -08:00
reakjra
c3c3e2ca25
wayland/screencopy: pin XRGB alpha to 1 in vulkan mode
While EGL handles this internally, vulkan's alpha channel behavior is
undefined when rendering depending on the driver. Notably intel does
not treat it as 1.0.
2026-02-23 22:47:42 -08:00
bbedward
2cf57f43d5
core/proxywindow: expose updatesEnabled property 2026-02-22 22:38:22 -08:00
reakjra
a99519c3ad
wayland/screencopy: support dmabufs in vulkan mode 2026-02-22 22:11:19 -08:00
Bryan Paradis
158db16b93
wayland: check screen isPlaceholder and if wl_output is null
Fixes crashes on disconnected monitors
2026-02-22 19:27:26 -08:00
outfoxxed
e7cd1e9982
core: add env and isEnvSet functions to pragma context
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-02-21 21:11:45 -08:00
Andrei
afbc5ffd4e
services/pipewire: use node volume control when device missing
Some outputs which present a pipewire device object do not present
routes, instead expecting volume to be set on the associated pipewire node.
2026-02-21 20:39:03 -08:00
outfoxxed
dacfa9de82
widgets/cliprect: use ShaderEffectSource to propagate mouse events
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-02-09 19:14:36 -08:00
outfoxxed
4429c03837
widgets/cliprect: fix ShaderEffect warnings on reload
layer.effect causes warnings on reload for an unknown reason which
seems to be ownership or destruction time related. This commit uses
an alternate strategy to create the shader which does not show this
warning.
2026-02-08 20:10:11 -08:00
kossLAN
395a1301a8
core: add hasThemeIcon mapping
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-02-08 01:26:08 -08:00
outfoxxed
1e4d804e7f
widgets/cliprect: use layer.effect on content item over property
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
ShaderEffectSource as a property not parented to an item does not
update its sourceItem's QQuickWindow when its own is changed. This
lead to use after frees and broken effects when using ClippingRectangle.
2026-01-28 01:43:31 -08:00
Manuel Romei
191085a882
ipc: use deleteLater() in IpcServerConnection to prevent use-after-free
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-21 00:50:39 -08:00
bbedward
8fd0de4580 core/proxywindow: create window on visibility for lazily initialized windows 2026-01-20 16:10:45 -05:00
bbedward
7a427ce197 core: fix inverted inHeader condition in preprocesso
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-17 17:30:40 -05:00
outfoxxed
5eb6f51f4a
core: add preprocessor for versioning
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-17 03:14:30 -08:00
outfoxxed
d03c59768c
io/ipchandler: add signal listener support
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-15 23:40:03 -08:00
outfoxxed
783b97152a
build: update CI, nix checkouts, lints
Some checks failed
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Nix-32 (push) Has been cancelled
Build / Nix-33 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-13 23:20:55 -08:00
outfoxxed
dca652366a
core/popupwindow: add grabFocus
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
Allows standard wayland focus grabs on non hyprland compositors.
2026-01-13 01:25:38 -08:00
outfoxxed
de1bfe028d
core/popupwindow: clean up popup lifecycle and window init
- Makes popup lifecycle less complex
- Creates all QWindows lazily
- May break live reloading of open popups to some degree
2026-01-13 01:21:08 -08:00
Carson Powers
db37dc580a
networking: add networking library 2026-01-11 23:51:29 -08:00
outfoxxed
bcc3d4265e
core: switch to custom incubation controller
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
This change requires more QtPrivate usage but eliminates generation or
cleanup related window incubation controller bugs. Additionally it
enables async loads prior to rendering windows.
2026-01-10 13:22:50 -08:00
outfoxxed
eecc2f88b3
services/pipewire: ignore monitors in PwNodeLinkTracker
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2026-01-09 01:09:25 -08:00
outfoxxed
11d6d67961
services/pipewire: add peak detection 2026-01-09 01:09:24 -08:00
outfoxxed
5d8354a88b
services/pipewire: add reconnect support 2026-01-08 04:11:09 -08:00
outfoxxed
8d19beb69e
core/log: copy early logs with sendfile/readwrite again
copy_file_range does not work across devices and memfds count as a
separate device.
2026-01-08 02:35:08 -08:00
molyuu
6742148cf4
all: initial support for freebsd
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
- Use `copy_file_range(2)` over `sendfile(2)` which has wider
compatibility.
- Special case pam on freebsd and document `configDirectory`
incompatibility.
- Disable jemalloc for FreeBSD by default as it is the system allocator.
- Disable breakpad by default on FreeBSD as breakpad is not supported.
2026-01-06 01:50:58 -08:00
outfoxxed
341a07d05b
io/process: use QVariantHash over QHash in Q_PROPERTY
Fixes qmlls for these properties
2026-01-06 01:05:57 -08:00
outfoxxed
41828c4180
services/pipewire: use node volume controls when routeDevice missing
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
For bluez audio streams and potentially other types of synthetic
device, volume controls are managed via the node and persistence is
handled by the service.
2025-12-25 20:58:05 -08:00
bbedward
3918290c1b
core/window: add min/max/fullscreen properties, and move/resize fns to FloatingWindow
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-12-21 23:01:36 -08:00
Tobias Pisani
26531fc46e
service/tray: emit change signals for item title and description
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-12-02 00:22:52 -08:00
Alejandro Pinar Ruiz
667bd38489
nix: update version to 0.2.1 2025-12-02 00:13:23 -08:00
EvilLary
9cdda21974
core/command: reset color after compatibility warning msg 2025-12-01 15:10:59 +03:00
nemalex
d24e8e9736
hyprland/ipc: swap windowTitle and windowClass in openwindow handler
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
The openwindow event format is ADDRESS,WORKSPACE,CLASS,TITLE but the
handler was parsing args.at(2) as title and args.at(3) as class,
which is reversed.

This caused windows to display their class name instead of their
actual title when the openwindow event arrived after windowtitlev2,
since updateInitial would overwrite the correct title with the class.
2025-11-29 22:06:37 -08:00
outfoxxed
e9bad67619
hyprland/ipc: fix activeToplevel not resetting after closewindow
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-11-24 20:39:43 -08:00
bbedward
ed036d514b
wayland/shortcuts-inhibit: add shortcuts inhibitor
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-11-20 01:12:14 -08:00
cameron
1ddb355121
core/icon: add searching custom file paths
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-11-17 22:16:14 -08:00
Ala Alkhafaji
ab494dd982
i3/ipc: implement IPC listener to receive arbitrary events 2025-11-17 22:04:58 -08:00
outfoxxed
fdbb86a06a
core/model: fix recursion in emptyInstance
Some checks failed
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Nix-30 (push) Has been cancelled
Build / Nix-31 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-11-15 17:41:54 -08:00
outfoxxed
0a7dcf30ea
build: update clang tooling and reformat 2025-11-15 04:43:27 -08:00
outfoxxed
1552aca3df
build: fix new clang-tidy lints 2025-11-15 04:29:12 -08:00
outfoxxed
0a36e3ed40
ci: add qt6.10.0 checkout 2025-11-15 02:31:58 -08:00
outfoxxed
a00ff03944
services/pipewire: cache route device volumes to initialize nodes
Nodes referencing a device can be bound later than the device is
bound. If this happens, the node will not receive an initial route
device volume change event. This change caches the last known route
device volume and initializes the device with it if present.
2025-11-14 02:12:42 -08:00
outfoxxed
fc704e6b5d
core: reference scanned paths by QDir over QString
Some checks failed
Build / Nix-1 (push) Has been cancelled
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Fixes a bug introduced in 3e2ce40 where a directory imported with a
"../name" path import would be passed to scanDir as ending in '/' which
created an invalid duplicate scan entry.
2025-10-31 00:56:30 -07:00
Cu3PO42
db1777c20b
service/polkit: add service module to write Polkit agents
Some checks failed
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-10-30 03:53:01 -07:00
bbedward
1b147a2c78
core/desktopentry: handle string escape sequences
Some checks failed
Build / Nix-2 (push) Has been cancelled
Build / Nix-3 (push) Has been cancelled
Build / Nix-4 (push) Has been cancelled
Build / Nix-5 (push) Has been cancelled
Build / Nix-6 (push) Has been cancelled
Build / Nix-7 (push) Has been cancelled
Build / Nix-8 (push) Has been cancelled
Build / Nix-9 (push) Has been cancelled
Build / Nix-10 (push) Has been cancelled
Build / Nix-11 (push) Has been cancelled
Build / Nix-12 (push) Has been cancelled
Build / Nix-13 (push) Has been cancelled
Build / Nix-14 (push) Has been cancelled
Build / Nix-15 (push) Has been cancelled
Build / Nix-16 (push) Has been cancelled
Build / Nix-17 (push) Has been cancelled
Build / Nix-18 (push) Has been cancelled
Build / Nix-19 (push) Has been cancelled
Build / Nix-20 (push) Has been cancelled
Build / Nix-21 (push) Has been cancelled
Build / Nix-22 (push) Has been cancelled
Build / Nix-23 (push) Has been cancelled
Build / Nix-24 (push) Has been cancelled
Build / Nix-25 (push) Has been cancelled
Build / Nix-26 (push) Has been cancelled
Build / Nix-27 (push) Has been cancelled
Build / Nix-28 (push) Has been cancelled
Build / Nix-29 (push) Has been cancelled
Build / Archlinux (push) Has been cancelled
Lint / Lint (push) Has been cancelled
2025-10-28 02:20:28 -07:00
outfoxxed
3e2ce40b18
core: reference configs by absolute instead of canonical paths 2025-10-18 14:22:26 -07:00
outfoxxed
00858812f2
core/command: filter instance selection by current display 2025-10-12 17:33:21 -07:00
outfoxxed
1e8cc2e78d
core: add CacheDir pragma
Closes #293
2025-10-12 00:14:36 -07:00
outfoxxed
ea79eaceb0
services/pipewire: do not use device for pro audio node controls
Note that the device object is currently still bound. This should not
be necessary.

Fixes #178
2025-10-11 21:42:58 -07:00
outfoxxed
c9d3ffb604
version: bump to 0.2.1 2025-10-11 17:16:19 -07:00
Gregor Kleen
f12f0e7c7d
service/greetd: always send responses 2025-10-11 01:03:05 -07:00
bbedward
3e32ae595f
core/desktopentry: don't match keys with wrong modifier or country 2025-10-09 01:12:48 -07:00
bbedward
2eacb713b9
core/desktopentry: mask entries with priority less than hidden entry 2025-10-09 01:11:50 -07:00
outfoxxed
c5c438f1cd
all: fix gcc warnings and lints 2025-10-04 13:43:41 -07:00
outfoxxed
9bb2c043ae
nix: remove qtwayland dependency when qt >= 6.10
QtWaylandClient was moved into QtBase in 6.10. The QtWayland packages
is now only the wayland server code which Quickshell does not need.
2025-10-04 13:00:35 -07:00
outfoxxed
3bcc1993f4
wayland/lock: support Qt 6.10 2025-10-04 13:00:33 -07:00
outfoxxed
9662234759
services/pipewire: consider device volume step when sending updates
Previously a hardcoded 0.0001 offset was used to determine if a volume
change was significant enough to send to a device, however some
devices have a much more granular step size, which caused future
volume updates to be blocked.

This change replaces the hardcoded offset with the volumeStep device
route property which should be large enough for the device to work with.

Fixes #279
2025-10-01 00:29:45 -07:00
outfoxxed
475856b767
docs: start tracking qs-next changelog 2025-09-30 23:28:05 -07:00
outfoxxed
482744cfa9
ci: fix magic-nix-cache write permissions 2025-09-29 21:59:46 -07:00
outfoxxed
6092b37c56
build: explicitly depend on private qt modules
In Qt 6.10, private Qt modules must be depended on explicitly.
2025-09-29 21:33:34 -07:00
outfoxxed
1d94144976
all: fix lints 2025-09-28 23:56:32 -07:00
outfoxxed
f78078dfaf
nix: update flake + tidyfox 2025-09-28 23:56:32 -07:00
outfoxxed
eeb8181cb1
ci: add detsys nix cache 2025-09-28 23:56:32 -07:00
outfoxxed
a922694a7d
ci: use unwrapped package for dependencies derivation
Since adding the wrapper, CI built qs as it was a dependency of the
wrapper instead of dependencies of qs itself.
2025-09-28 23:56:32 -07:00
outfoxxed
afada1eb6c
ci: add qt 6.9.2 and 6.9.1 checkouts 2025-09-28 23:56:32 -07:00
outfoxxed
b9905ef824
nix: add overlay 2025-09-28 23:56:30 -07:00
outfoxxed
2119eb2205
build: fix cross compilation 2025-09-28 18:55:45 -07:00
outfoxxed
e9a574d919
core: derive incubation controllers from tracked windows list
Replaces the attempts to track incubation controllers directly with a
list of all known windows, then pulls the first usable incubation
controller when an assignment is requested.

This should finally fix incubation controller related use after free crashes.
2025-09-19 02:15:51 -07:00
bbedward
59f5744f30
core/desktopentry: watch for changes and rescan entries 2025-09-16 22:55:49 -07:00
outfoxxed
49646e4407
ci: use latest wayland-protocol for all test cases
Fixes missing protocols on old nixpkgs versions
2025-09-16 00:15:13 -07:00
outfoxxed
6eb12551ba
wayland/idle-notify: add idle notify 2025-09-04 03:21:00 -07:00
outfoxxed
b8fa424f85
wayland/idle-inhibit: fix formatting + lints, destructor, add logs 2025-09-04 03:11:34 -07:00
outfoxxed
2c2983462c
wayland/idle-inhibit: stop vendoring protocol
Idle-inhibit is included in wayland-protocols and this was vendored by mistake.
2025-09-04 00:51:56 -07:00
kossLAN
f592793873
hyprland/ipc: fix focusedWorkspaceChanged connection 2025-09-02 12:39:56 -04:00
Derock
f7597cdae2
core/log: fix nullptr crash in ThreadLogging 2025-08-27 20:44:39 -07:00
bbedward
42420ea26d
wayland/idle-inhibit: use bindable .value() instead of implicit cast
Fixes compilation on some targets.
2025-08-27 20:41:07 -07:00
outfoxxed
b8625aa098
wayland/idle-inhibit: add idle inhibitor 2025-08-27 02:30:16 -07:00
269 changed files with 14906 additions and 2208 deletions

View file

@ -1,6 +1,6 @@
AlignArrayOfStructures: None AlignArrayOfStructures: None
AlignAfterOpenBracket: BlockIndent AlignAfterOpenBracket: BlockIndent
AllowShortBlocksOnASingleLine: Always AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All

View file

@ -20,6 +20,8 @@ Checks: >
-cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-use-enum-class,
google-global-names-in-headers, google-global-names-in-headers,
google-readability-casting, google-readability-casting,
google-runtime-int, google-runtime-int,
@ -63,6 +65,8 @@ CheckOptions:
readability-identifier-naming.ParameterCase: camelBack readability-identifier-naming.ParameterCase: camelBack
readability-identifier-naming.VariableCase: camelBack readability-identifier-naming.VariableCase: camelBack
misc-const-correctness.WarnPointersAsPointers: false
# does not appear to work # does not appear to work
readability-operators-representation.BinaryOperators: '&&;&=;&;|;~;!;!=;||;|=;^;^=' readability-operators-representation.BinaryOperators: '&&;&=;&;|;~;!;!=;||;|=;^;^='
readability-operators-representation.OverloadedOperators: '&&;&=;&;|;~;!;!=;||;|=;^;^=' readability-operators-representation.OverloadedOperators: '&&;&=;&;|;~;!;!=;||;|=;^;^='

View file

@ -1,82 +1,17 @@
name: Crash Report name: Crash Report (v1)
description: Quickshell has crashed description: Quickshell has crashed (old)
labels: ["bug", "crash"] labels: ["unactionable"]
body: body:
- type: textarea - type: markdown
id: crashinfo
attributes: attributes:
label: General crash information value: |
description: | Thank you for taking the time to click the report button.
Paste the contents of the `info.txt` file in your crash folder here. At this point most of the worst issues in 0.2.1 and before have been fixed and we are
value: "<details> <summary>General information</summary> preparing for a new release. Please do not submit this report.
- type: checkboxes
id: donotcheck
``` attributes:
label: Read the text above. Do not submit the report.
<Paste the contents of the file here inside of the triple backticks> options:
- label: Yes I want this report to be deleted.
```
</details>"
validations:
required: true required: true
- type: textarea
id: userinfo
attributes:
label: What caused the crash
description: |
Any information likely to help debug the crash. What were you doing when the crash occurred,
what changes did you make, can you get it to happen again?
- type: textarea
id: dump
attributes:
label: Minidump
description: |
Attach `minidump.dmp.log` here. If it is too big to upload, compress it.
You may skip this step if quickshell crashed while processing a password
or other sensitive information. If you skipped it write why instead.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Log file
description: |
Attach `log.qslog.log` here. If it is too big to upload, compress it.
You can preview the log if you'd like using `quickshell read-log <path-to-log>`.
validations:
required: true
- type: textarea
id: config
attributes:
label: Configuration
description: |
Attach your configuration here, preferrably in full (not just one file).
Compress it into a zip, tar, etc.
This will help us reproduce the crash ourselves.
- type: textarea
id: bt
attributes:
label: Backtrace
description: |
If you have gdb installed and use systemd, or otherwise know how to get a backtrace,
we would appreciate one. (You may have gdb installed without knowing it)
1. Run `coredumpctl debug <pid>` where `pid` is the number shown after "Crashed process ID"
in the crash reporter.
2. Once it loads, type `bt -full` (then enter)
3. Copy the output and attach it as a file or in a spoiler.
- type: textarea
id: exe
attributes:
label: Executable
description: |
If the crash folder contains a executable.txt file, upload it here. If not you can ignore this field.
If it is too big to upload, compress it.
Note: executable.txt is the quickshell binary. It has a .txt extension due to github's limitations on
filetypes.

49
.github/ISSUE_TEMPLATE/crash2.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Crash Report (v2)
description: Quickshell has crashed
labels: ["bug", "crash"]
body:
- type: textarea
id: userinfo
attributes:
label: What caused the crash
description: |
Any information likely to help debug the crash. What were you doing when the crash occurred,
what changes did you make, can you get it to happen again?
- type: upload
id: report
attributes:
label: Report file
description: Attach `report.txt` here.
validations:
required: true
- type: upload
id: logs
attributes:
label: Log file
description: |
Attach `log.qslog.log` here. If it is too big to upload, compress it.
You can preview the log if you'd like using `qs log <path-to-log> -r '*=true'`.
validations:
required: true
- type: textarea
id: config
attributes:
label: Configuration
description: |
Attach or link your configuration here, preferrably in full (not just one file).
Compress it into a zip, tar, etc.
This will help us reproduce the crash ourselves.
- type: textarea
id: bt
attributes:
label: Backtrace
description: |
GDB usually produces better stacktraces than quickshell can. Consider attaching a gdb backtrace
following the instructions below.
1. Run `coredumpctl debug <pid>` where `pid` is the number shown after "Crashed process ID"
in the crash reporter.
2. Once it loads, type `bt -full` (then enter)
3. Copy the output and attach it as a file or in a spoiler.

View file

@ -6,7 +6,7 @@ jobs:
name: Nix name: Nix
strategy: strategy:
matrix: matrix:
qtver: [qt6.9.2, qt6.9.1, qt6.9.0, qt6.8.3, qt6.8.2, qt6.8.1, qt6.8.0, qt6.7.3, qt6.7.2, qt6.7.1, qt6.7.0, qt6.6.3, qt6.6.2, qt6.6.1, qt6.6.0] qtver: [qt6.10.1, qt6.10.0, qt6.9.2, qt6.9.1, qt6.9.0, qt6.8.3, qt6.8.2, qt6.8.1, qt6.8.0, qt6.7.3, qt6.7.2, qt6.7.1, qt6.7.0, qt6.6.3, qt6.6.2, qt6.6.1, qt6.6.0]
compiler: [clang, gcc] compiler: [clang, gcc]
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@ -50,13 +50,16 @@ jobs:
wayland-protocols \ wayland-protocols \
wayland \ wayland \
libdrm \ libdrm \
vulkan-headers \
libxcb \ libxcb \
libpipewire \ libpipewire \
cli11 \ cli11 \
jemalloc polkit \
jemalloc \
libunwind \
git # for cpptrace clone
- name: Build - name: Build
# breakpad is annoying to build in ci due to makepkg not running as root
run: | run: |
cmake -GNinja -B build -DCRASH_REPORTER=OFF cmake -GNinja -B build -DVENDOR_CPPTRACE=ON
cmake --build build cmake --build build

View file

@ -15,15 +15,7 @@ Please make this descriptive enough to identify your specific package, for examp
- `Nixpkgs` - `Nixpkgs`
- `Fedora COPR (errornointernet/quickshell)` - `Fedora COPR (errornointernet/quickshell)`
`-DDISTRIBUTOR_DEBUGINFO_AVAILABLE=YES/NO` If you are forking quickshell, please change `CRASHREPORT_URL` to your own issue tracker.
If we can retrieve binaries and debug information for the package without actually running your
distribution (e.g. from an website), and you would like to strip the binary, please set this to `YES`.
If we cannot retrieve debug information, please set this to `NO` and
**ensure you aren't distributing stripped (non debuggable) binaries**.
In both cases you should build with `-DCMAKE_BUILD_TYPE=RelWithDebInfo` (then split or keep the debuginfo).
### QML Module dir ### QML Module dir
Currently all QML modules are statically linked to quickshell, but this is where Currently all QML modules are statically linked to quickshell, but this is where
@ -41,6 +33,7 @@ Quickshell has a set of base dependencies you will always need, names vary by di
- `cmake` - `cmake`
- `qt6base` - `qt6base`
- `qt6declarative` - `qt6declarative`
- `libdrm`
- `qtshadertools` (build-time) - `qtshadertools` (build-time)
- `spirv-tools` (build-time) - `spirv-tools` (build-time)
- `pkg-config` (build-time) - `pkg-config` (build-time)
@ -64,14 +57,24 @@ At least Qt 6.6 is required.
All features are enabled by default and some have their own dependencies. All features are enabled by default and some have their own dependencies.
### Crash Reporter ### Crash Handler
The crash reporter catches crashes, restarts quickshell when it crashes, The crash reporter catches crashes, restarts Quickshell when it crashes,
and collects useful crash information in one place. Leaving this enabled will and collects useful crash information in one place. Leaving this enabled will
enable us to fix bugs far more easily. enable us to fix bugs far more easily.
To disable: `-DCRASH_REPORTER=OFF` To disable: `-DCRASH_HANDLER=OFF`
Dependencies: `google-breakpad` (static library) Dependencies: `cpptrace`
Note: `-DVENDOR_CPPTRACE=ON` can be set to vendor cpptrace using FetchContent.
When using FetchContent, `libunwind` is required, and `libdwarf` can be provided by the
package manager or fetched with FetchContent.
*Please ensure binaries have usable symbols.* We do not necessarily need full debuginfo, but
leaving symbols in the binary is extremely helpful. You can check if symbols are useful
by sending a SIGSEGV to the process and ensuring symbols for the quickshell binary are present
in the trace.
### Jemalloc ### Jemalloc
We recommend leaving Jemalloc enabled as it will mask memory fragmentation caused We recommend leaving Jemalloc enabled as it will mask memory fragmentation caused
@ -144,8 +147,8 @@ Enables streaming video from monitors and toplevel windows through various proto
To disable: `-DSCREENCOPY=OFF` To disable: `-DSCREENCOPY=OFF`
Dependencies: Dependencies:
- `libdrm`
- `libgbm` - `libgbm`
- `vulkan-headers` (build-time)
Specific protocols can also be disabled: Specific protocols can also be disabled:
- `DSCREENCOPY_ICC=OFF` - Disable screencopy via [ext-image-copy-capture-v1] - `DSCREENCOPY_ICC=OFF` - Disable screencopy via [ext-image-copy-capture-v1]
@ -192,6 +195,13 @@ To disable: `-DSERVICE_PAM=OFF`
Dependencies: `pam` Dependencies: `pam`
### Polkit
This feature enables creating Polkit agents that can prompt user for authentication.
To disable: `-DSERVICE_POLKIT=OFF`
Dependencies: `polkit`, `glib`
### Hyprland ### Hyprland
This feature enables hyprland specific integrations. It requires wayland support This feature enables hyprland specific integrations. It requires wayland support
but has no extra dependencies. but has no extra dependencies.
@ -232,7 +242,7 @@ Only `ninja` builds are tested, but makefiles may work.
#### Configuring the build #### Configuring the build
```sh ```sh
$ cmake -GNinja -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo [additional disable flags from above here] $ cmake -GNinja -B build -DCMAKE_BUILD_TYPE=Release [additional disable flags from above here]
``` ```
Note that features you do not supply dependencies for MUST be disabled with their associated flags Note that features you do not supply dependencies for MUST be disabled with their associated flags

View file

@ -1,12 +1,21 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
project(quickshell VERSION "0.2.1" LANGUAGES CXX C) project(quickshell VERSION "0.2.1" LANGUAGES CXX C)
set(UNRELEASED_FEATURES
"network.2"
"colorquant-imagerect"
"window-parent"
)
set(QT_MIN_VERSION "6.6.0") set(QT_MIN_VERSION "6.6.0")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QS_BUILD_OPTIONS "") set(QS_BUILD_OPTIONS "")
# should be changed for forks
set(CRASHREPORT_URL "https://github.com/outfoxxed/quickshell/issues/new?template=crash2.yml" CACHE STRING "Bugreport URL")
function(boption VAR NAME DEFAULT) function(boption VAR NAME DEFAULT)
cmake_parse_arguments(PARSE_ARGV 3 arg "" "REQUIRES" "") cmake_parse_arguments(PARSE_ARGV 3 arg "" "REQUIRES" "")
@ -38,14 +47,17 @@ string(APPEND QS_BUILD_OPTIONS " Distributor: ${DISTRIBUTOR}")
message(STATUS "Quickshell configuration") message(STATUS "Quickshell configuration")
message(STATUS " Distributor: ${DISTRIBUTOR}") message(STATUS " Distributor: ${DISTRIBUTOR}")
boption(DISTRIBUTOR_DEBUGINFO_AVAILABLE "Distributor provided debuginfo" NO)
boption(NO_PCH "Disable precompild headers (dev)" OFF) boption(NO_PCH "Disable precompild headers (dev)" OFF)
boption(BUILD_TESTING "Build tests (dev)" OFF) boption(BUILD_TESTING "Build tests (dev)" OFF)
boption(ASAN "ASAN (dev)" OFF) # note: better output with gcc than clang boption(ASAN "ASAN (dev)" OFF) # note: better output with gcc than clang
boption(FRAME_POINTERS "Keep Frame Pointers (dev)" ${ASAN}) boption(FRAME_POINTERS "Keep Frame Pointers (dev)" ${ASAN})
boption(CRASH_REPORTER "Crash Handling" ON) if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
boption(USE_JEMALLOC "Use jemalloc" ON) boption(USE_JEMALLOC "Use jemalloc" OFF)
else()
boption(USE_JEMALLOC "Use jemalloc" ON)
endif()
boption(CRASH_HANDLER "Crash Handling" ON)
boption(SOCKETS "Unix Sockets" ON) boption(SOCKETS "Unix Sockets" ON)
boption(WAYLAND "Wayland" ON) boption(WAYLAND "Wayland" ON)
boption(WAYLAND_WLR_LAYERSHELL " Wlroots Layer-Shell" ON REQUIRES WAYLAND) boption(WAYLAND_WLR_LAYERSHELL " Wlroots Layer-Shell" ON REQUIRES WAYLAND)
@ -67,18 +79,21 @@ boption(SERVICE_STATUS_NOTIFIER "System Tray" ON)
boption(SERVICE_PIPEWIRE "PipeWire" ON) boption(SERVICE_PIPEWIRE "PipeWire" ON)
boption(SERVICE_MPRIS "Mpris" ON) boption(SERVICE_MPRIS "Mpris" ON)
boption(SERVICE_PAM "Pam" ON) boption(SERVICE_PAM "Pam" ON)
boption(SERVICE_POLKIT "Polkit" ON)
boption(SERVICE_GREETD "Greetd" ON) boption(SERVICE_GREETD "Greetd" ON)
boption(SERVICE_UPOWER "UPower" ON) boption(SERVICE_UPOWER "UPower" ON)
boption(SERVICE_NOTIFICATIONS "Notifications" ON) boption(SERVICE_NOTIFICATIONS "Notifications" ON)
boption(BLUETOOTH "Bluetooth" ON) boption(BLUETOOTH "Bluetooth" ON)
boption(NETWORK "Network" ON)
include(cmake/install-qml-module.cmake) include(cmake/install-qml-module.cmake)
include(cmake/util.cmake) include(cmake/util.cmake)
add_compile_options(-Wall -Wextra -Wno-vla-cxx-extension) add_compile_options(-Wall -Wextra -Wno-vla-cxx-extension)
# pipewire defines this, breaking PCH # pipewire defines these, breaking PCH
add_compile_definitions(_REENTRANT) add_compile_definitions(_REENTRANT)
add_compile_options(-fno-strict-overflow)
if (FRAME_POINTERS) if (FRAME_POINTERS)
add_compile_options(-fno-omit-frame-pointer) add_compile_options(-fno-omit-frame-pointer)
@ -119,7 +134,7 @@ if (WAYLAND)
list(APPEND QT_PRIVDEPS WaylandClientPrivate) list(APPEND QT_PRIVDEPS WaylandClientPrivate)
endif() endif()
if (SERVICE_STATUS_NOTIFIER OR SERVICE_MPRIS OR SERVICE_UPOWER OR SERVICE_NOTIFICATIONS OR BLUETOOTH) if (SERVICE_STATUS_NOTIFIER OR SERVICE_MPRIS OR SERVICE_UPOWER OR SERVICE_NOTIFICATIONS OR BLUETOOTH OR NETWORK)
set(DBUS ON) set(DBUS ON)
endif() endif()

View file

@ -1,235 +1,40 @@
# Contributing / Development # Contributing
Instructions for development setup and upstreaming patches.
If you just want to build or package quickshell see [BUILD.md](BUILD.md). Thank you for taking the time to contribute.
To ensure nobody's time is wasted, please follow the rules below.
## Development ## Acceptable Code Contributions
Install the dependencies listed in [BUILD.md](BUILD.md). - All changes submitted MUST be **fully understood by the submitter**. If you do not know why or how
You probably want all of them even if you don't use all of them your change works, do not submit it to be merged. You must be able to explain your reasoning
to ensure tests work correctly and avoid passing a bunch of configure for every change.
flags when you need to wipe the build directory.
Quickshell also uses `just` for common development command aliases. - Changes MUST be submitted by a human who will be responsible for them. Changes submitted without
a human in the loop such as automated tooling and AI Agents are **strictly disallowed**. Accounts
responsible for such contribution attempts **will be banned**.
The dependencies are also available as a nix shell or nix flake which we recommend - Changes MUST respect Quickshell's license and the license of any source works. Changes including
using with nix-direnv. code from any other works must disclose the source of the code, explain why it was used, and
ensure the license is compatible.
Common aliases: - Changes must follow the guidelines outlined in [HACKING.md](HACKING.md) for style and substance.
- `just configure [<debug|release> [extra cmake args]]` (note that you must specify debug/release to specify extra args)
- `just build` - runs the build, configuring if not configured already.
- `just run [args]` - runs quickshell with the given arguments
- `just clean` - clean up build artifacts. `just clean build` is somewhat common.
### Formatting - Changes must stand on their own as a unit. Do not make multiple unrelated changes in one PR.
All contributions should be formatted similarly to what already exists. Changes depending on prior merges should be marked as a draft.
Group related functionality together.
Run the formatter using `just fmt`. ## Acceptable Non-code Contributions
If the results look stupid, fix the clang-format file if possible,
or disable clang-format in the affected area
using `// clang-format off` and `// clang-format on`.
#### Style preferences not caught by clang-format - Bug and crash reports. You must follow the instructions in the issue templates and provide the
These are flexible. You can ignore them if it looks or works better to information requested.
for one reason or another.
Use `auto` if the type of a variable can be deduced automatically, instead of - Feature requests can be made via Issues. Please check to ensure nobody else has requested the same feature.
redeclaring the returned value's type. Additionally, auto should be used when a
constructor takes arguments.
```cpp - Do not make insubstantial or pointless changes.
auto x = <expr>; // ok
auto x = QString::number(3); // ok
QString x; // ok
QString x = "foo"; // ok
auto x = QString("foo"); // ok
auto x = QString(); // avoid - Changes to project rules / policy / governance will not be entertained, except from significant
QString x(); // avoid long-term contributors. These changes should not be addressed through contribution channels.
QString x("foo"); // avoid
```
Put newlines around logical units of code, and after closing braces. If the ## Merge timelines
most reasonable logical unit of code takes only a single line, it should be
merged into the next single line logical unit if applicable.
```cpp
// multiple units
auto x = <expr>; // unit 1
auto y = <expr>; // unit 2
auto x = <expr>; // unit 1 We handle work for the most part on a push basis. If your PR has been ignored for a while
emit this->y(); // unit 2 and is still relevant please bump it.
auto x1 = <expr>; // unit 1
auto x2 = <expr>; // unit 1
auto x3 = <expr>; // unit 1
auto y1 = <expr>; // unit 2
auto y2 = <expr>; // unit 2
auto y3 = <expr>; // unit 2
// one unit
auto x = <expr>;
if (x...) {
// ...
}
// if more than one variable needs to be used then add a newline
auto x = <expr>;
auto y = <expr>;
if (x && y) {
// ...
}
```
Class formatting:
```cpp
//! Doc comment summary
/// Doc comment body
class Foo: public QObject {
// The Q_OBJECT macro comes first. Macros are ; terminated.
Q_OBJECT;
QML_ELEMENT;
QML_CLASSINFO(...);
// Properties must stay on a single line or the doc generator won't be able to pick them up
Q_PROPERTY(...);
/// Doc comment
Q_PROPERTY(...);
/// Doc comment
Q_PROPERTY(...);
public:
// Classes should have explicit constructors if they aren't intended to
// implicitly cast. The constructor can be inline in the header if it has no body.
explicit Foo(QObject* parent = nullptr): QObject(parent) {}
// Instance functions if applicable.
static Foo* instance();
// Member functions unrelated to properties come next
void function();
void function();
void function();
// Then Q_INVOKABLEs
Q_INVOKABLE function();
/// Doc comment
Q_INVOKABLE function();
/// Doc comment
Q_INVOKABLE function();
// Then property related functions, in the order (bindable, getter, setter).
// Related functions may be included here as well. Function bodies may be inline
// if they are a single expression. There should be a newline between each
// property's methods.
[[nodiscard]] QBindable<T> bindableFoo() { return &this->bFoo; }
[[nodiscard]] T foo() const { return this->foo; }
void setFoo();
[[nodiscard]] T bar() const { return this->foo; }
void setBar();
signals:
// Signals that are not property change related go first.
// Property change signals go in property definition order.
void asd();
void asd2();
void fooChanged();
void barChanged();
public slots:
// generally Q_INVOKABLEs are preferred to public slots.
void slot();
private slots:
// ...
private:
// statics, then functions, then fields
static const foo BAR;
static void foo();
void foo();
void bar();
// property related members are prefixed with `m`.
QString mFoo;
QString bar;
// Bindables go last and should be prefixed with `b`.
Q_OBJECT_BINDABLE_PROPERTY(Foo, QString, bFoo, &Foo::fooChanged);
};
```
### Linter
All contributions should pass the linter.
Note that running the linter requires disabling precompiled
headers and including the test codepaths:
```sh
$ just configure debug -DNO_PCH=ON -DBUILD_TESTING=ON
$ just lint-changed
```
If the linter is complaining about something that you think it should not,
please disable the lint in your MR and explain your reasoning if it isn't obvious.
### Tests
If you feel like the feature you are working on is very complex or likely to break,
please write some tests. We will ask you to directly if you send in an MR for an
overly complex or breakable feature.
At least all tests that passed before your changes should still be passing
by the time your contribution is ready.
You can run the tests using `just test` but you must enable them first
using `-DBUILD_TESTING=ON`.
### Documentation
Most of quickshell's documentation is automatically generated from the source code.
You should annotate `Q_PROPERTY`s and `Q_INVOKABLE`s with doc comments. Note that the parser
cannot handle random line breaks and will usually require you to disable clang-format if the
lines are too long.
Before submitting an MR, if adding new features please make sure the documentation is generated
reasonably using the `quickshell-docs` repo. We recommend checking it out at `/docs` in this repo.
Doc comments take the form `///` or `///!` (summary) and work with markdown.
You can reference other types using the `@@[Module.][Type.][member]` shorthand
where all parts are optional. If module or type are not specified they will
be inferred as the current module. Member can be a `property`, `function()` or `signal(s)`.
Look at existing code for how it works.
Quickshell modules additionally have a `module.md` file which contains a summary, description,
and list of headers to scan for documentation.
## Contributing
### Commits
Please structure your commit messages as `scope[!]: commit` where
the scope is something like `core` or `service/mpris`. (pick what has been
used historically or what makes sense if new). Add `!` for changes that break
existing APIs or functionality.
Commit descriptions should contain a summary of the changes if they are not
sufficiently addressed in the commit message.
Please squash/rebase additions or edits to previous changes and follow the
commit style to keep the history easily searchable at a glance.
Depending on the change, it is often reasonable to squash it into just
a single commit. (If you do not follow this we will squash your changes
for you.)
### Sending patches
You may contribute by submitting a pull request on github, asking for
an account on our git server, or emailing patches / git bundles
directly to `outfoxxed@outfoxxed.me`.
### Getting help
If you're getting stuck, you can come talk to us in the
[quickshell-development matrix room](https://matrix.to/#/#quickshell-development:outfoxxed.me)
for help on implementation, conventions, etc.
Feel free to ask for advice early in your implementation if you are
unsure.

226
HACKING.md Normal file
View file

@ -0,0 +1,226 @@
## Development
Install the dependencies listed in [BUILD.md](BUILD.md).
You probably want all of them even if you don't use all of them
to ensure tests work correctly and avoid passing a bunch of configure
flags when you need to wipe the build directory.
The dependencies are also available as a nix shell or nix flake which we recommend
using with nix-direnv.
Quickshell uses `just` for common development command aliases.
Common aliases:
- `just configure [<debug|release> [extra cmake args]]` (note that you must specify debug/release to specify extra args)
- `just build` - runs the build, configuring if not configured already.
- `just run [args]` - runs quickshell with the given arguments
- `just clean` - clean up build artifacts. `just clean build` is somewhat common.
### Formatting
All contributions should be formatted similarly to what already exists.
Group related functionality together.
Run the formatter using `just fmt`.
If the results look stupid, fix the clang-format file if possible,
or disable clang-format in the affected area
using `// clang-format off` and `// clang-format on`.
#### Style preferences not caught by clang-format
These are flexible. You can ignore them if it looks or works better to
for one reason or another.
Use `auto` if the type of a variable can be deduced automatically, instead of
redeclaring the returned value's type. Additionally, auto should be used when a
constructor takes arguments.
```cpp
auto x = <expr>; // ok
auto x = QString::number(3); // ok
QString x; // ok
QString x = "foo"; // ok
auto x = QString("foo"); // ok
auto x = QString(); // avoid
QString x(); // avoid
QString x("foo"); // avoid
```
Put newlines around logical units of code, and after closing braces. If the
most reasonable logical unit of code takes only a single line, it should be
merged into the next single line logical unit if applicable.
```cpp
// multiple units
auto x = <expr>; // unit 1
auto y = <expr>; // unit 2
auto x = <expr>; // unit 1
emit this->y(); // unit 2
auto x1 = <expr>; // unit 1
auto x2 = <expr>; // unit 1
auto x3 = <expr>; // unit 1
auto y1 = <expr>; // unit 2
auto y2 = <expr>; // unit 2
auto y3 = <expr>; // unit 2
// one unit
auto x = <expr>;
if (x...) {
// ...
}
// if more than one variable needs to be used then add a newline
auto x = <expr>;
auto y = <expr>;
if (x && y) {
// ...
}
```
Class formatting:
```cpp
//! Doc comment summary
/// Doc comment body
class Foo: public QObject {
// The Q_OBJECT macro comes first. Macros are ; terminated.
Q_OBJECT;
QML_ELEMENT;
QML_CLASSINFO(...);
// Properties must stay on a single line or the doc generator won't be able to pick them up
Q_PROPERTY(...);
/// Doc comment
Q_PROPERTY(...);
/// Doc comment
Q_PROPERTY(...);
public:
// Classes should have explicit constructors if they aren't intended to
// implicitly cast. The constructor can be inline in the header if it has no body.
explicit Foo(QObject* parent = nullptr): QObject(parent) {}
// Instance functions if applicable.
static Foo* instance();
// Member functions unrelated to properties come next
void function();
void function();
void function();
// Then Q_INVOKABLEs
Q_INVOKABLE function();
/// Doc comment
Q_INVOKABLE function();
/// Doc comment
Q_INVOKABLE function();
// Then property related functions, in the order (bindable, getter, setter).
// Related functions may be included here as well. Function bodies may be inline
// if they are a single expression. There should be a newline between each
// property's methods.
[[nodiscard]] QBindable<T> bindableFoo() { return &this->bFoo; }
[[nodiscard]] T foo() const { return this->foo; }
void setFoo();
[[nodiscard]] T bar() const { return this->foo; }
void setBar();
signals:
// Signals that are not property change related go first.
// Property change signals go in property definition order.
void asd();
void asd2();
void fooChanged();
void barChanged();
public slots:
// generally Q_INVOKABLEs are preferred to public slots.
void slot();
private slots:
// ...
private:
// statics, then functions, then fields
static const foo BAR;
static void foo();
void foo();
void bar();
// property related members are prefixed with `m`.
QString mFoo;
QString bar;
// Bindables go last and should be prefixed with `b`.
Q_OBJECT_BINDABLE_PROPERTY(Foo, QString, bFoo, &Foo::fooChanged);
};
```
Use lowercase .h suffixed Qt headers, e.g. `<qwindow.h>` over `<QWindow>`.
### Linter
All contributions should pass the linter.
Note that running the linter requires disabling precompiled
headers and including the test codepaths:
```sh
$ just configure debug -DNO_PCH=ON -DBUILD_TESTING=ON
$ just lint-changed
```
If the linter is complaining about something that you think it should not,
please disable the lint in your MR and explain your reasoning if it isn't obvious.
### Tests
If you feel like the feature you are working on is very complex or likely to break,
please write some tests. We will ask you to directly if you send in an MR for an
overly complex or breakable feature.
At least all tests that passed before your changes should still be passing
by the time your contribution is ready.
You can run the tests using `just test` but you must enable them first
using `-DBUILD_TESTING=ON`.
### Documentation
Most of quickshell's documentation is automatically generated from the source code.
You should annotate `Q_PROPERTY`s and `Q_INVOKABLE`s with doc comments. Note that the parser
cannot handle random line breaks and will usually require you to disable clang-format if the
lines are too long.
Make sure new files containing doc comments are added to a `module.md` file.
See existing module files for reference.
Doc comments take the form `///` or `///!` (summary) and work with markdown.
You can reference other types using the `@@[Module.][Type.][member]` shorthand
where all parts are optional. If module or type are not specified they will
be inferred as the current module. Member can be a `property`, `function()` or `signal(s)`.
Look at existing code for how it works.
If you have made a user visible change since the last tagged release, describe it in
[changelog/next.md](changelog/next.md).
## Contributing
### Commits
Please structure your commit messages as `scope: commit` where
the scope is something like `core` or `service/mpris`. (pick what has been
used historically or what makes sense if new).
Commit descriptions should contain a summary of the changes if they are not
sufficiently addressed in the commit message.
Please squash/rebase additions or edits to previous changes and follow the
commit style to keep the history easily searchable at a glance.
Depending on the change, it is often reasonable to squash it into just
a single commit. (If you do not follow this we will squash your changes
for you.)
### Getting help
If you're getting stuck, you can come talk to us in the
[quickshell-development matrix room](https://matrix.to/#/#quickshell-development:outfoxxed.me)
for help on implementation, conventions, etc. There is also a bridged [discord server](https://discord.gg/UtZeT3xNyT).
Feel free to ask for advice early in your implementation if you are
unsure.

View file

@ -13,7 +13,7 @@ lint-changed:
git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }} git diff --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
lint-staged: lint-staged:
git diff --staged --name-only HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }} git diff --staged --name-only --diff-filter=d HEAD | grep "^.*\.cpp\$" | parallel -j$(nproc) --no-notice --will-cite --tty --bar clang-tidy --load={{ env_var("TIDYFOX") }}
configure target='debug' *FLAGS='': configure target='debug' *FLAGS='':
cmake -GNinja -B {{builddir}} \ cmake -GNinja -B {{builddir}} \

View file

@ -7,7 +7,9 @@ This repo is hosted at:
- https://github.com/quickshell-mirror/quickshell - https://github.com/quickshell-mirror/quickshell
# Contributing / Development # Contributing / Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for details. - [HACKING.md](HACKING.md) - Development instructions and policy.
- [CONTRIBUTING.md](CONTRIBUTING.md) - Contribution policy.
- [BUILD.md](BUILD.md) - Packaging and build instructions.
#### License #### License

84
changelog/next.md Normal file
View file

@ -0,0 +1,84 @@
## Breaking Changes
### Config paths are no longer canonicalized
This fixes nix configs changing shell-ids on rebuild as the shell id is now derived from
the symlink path. Configs with a symlink in their path will have a different shell id.
Shell ids are used to derive the default config / state / cache folders, so those files
will need to be manually moved if using a config behind a symlinked path without an explicitly
set shell id.
## New Features
- Added support for creating Polkit agents.
- Added support for creating wayland idle inhibitors.
- Added support for wayland idle timeouts.
- Added support for inhibiting wayland compositor shortcuts for focused windows.
- Added the ability to override Quickshell.cacheDir with a custom path.
- Added minimized, maximized, and fullscreen properties to FloatingWindow.
- Added the ability to handle move and resize events to FloatingWindow.
- Pipewire service now reconnects if pipewire dies or a protocol error occurs.
- Added pipewire audio peak detection.
- Added network management support.
- Added support for grabbing focus from popup windows.
- Added support for IPC signal listeners.
- Added Quickshell version checking and version gated preprocessing.
- Added a way to detect if an icon is from the system icon theme or not.
- Added vulkan support to screencopy.
- Added generic WindowManager interface implementing ext-workspace.
- Added ext-background-effect window blur support.
- Added per-corner radius support to Region.
- Added ColorQuantizer region selection.
- Added dialog window support to FloatingWindow.
## Other Changes
- FreeBSD is now partially supported.
- IPC operations filter available instances to the current display connection by default.
- PwNodeLinkTracker ignores sound level monitoring programs.
- Replaced breakpad with cpptrace.
- Reloads are prevented if no file content has changed.
- Added `QS_DISABLE_FILE_WATCHER` environment variable to disable file watching.
- Added `QS_DISABLE_CRASH_HANDLER` environment variable to disable crash handling.
- Added `QS_CRASHREPORT_URL` environment variable to allow overriding the crash reporter link.
- Added `AppId` pragma and `QS_APP_ID` environment variable to allow overriding the desktop application ID.
- Added `DropExpensiveFonts` pragma and `QS_DROP_EXPENSIVE_FONTS` environment variable which avoids loading fonts which may cause lag and excessive memory usage if many variants are used.
- Unrecognized pragmas are no longer a hard error for future backward compatibility.
## Bug Fixes
- Fixed volume control breaking with pipewire pro audio mode.
- Fixed volume control breaking with bluez streams and potentially others.
- Fixed volume control breaking for devices without route definitions.
- Fixed escape sequence handling in desktop entries.
- Fixed volumes not initializing if a pipewire device was already loaded before its node.
- Fixed hyprland active toplevel not resetting after window closes.
- Fixed hyprland ipc window names and titles being reversed.
- Fixed a hyprland ipc crash when refreshing toplevels before workspaces.
- Fixed missing signals for system tray item title and description updates.
- Fixed asynchronous loaders not working after reload.
- Fixed asynchronous loaders not working before window creation.
- Fixed memory leak in IPC handlers.
- Fixed ClippingRectangle related crashes.
- Fixed crashes when monitors are unplugged.
- Fixed crashes when default pipewire devices are lost.
- Fixed ToplevelManager not clearing activeToplevel on deactivation.
- Desktop action order is now preserved.
- Fixed partial socket reads in greetd and hyprland on slow machines.
- Worked around Qt bug causing crashes when plugging and unplugging monitors.
- Fixed HyprlandFocusGrab crashing if windows were destroyed after being passed to it.
- Fixed ScreencopyView pixelation when scaled.
- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject.
- Fixed JsonAdapter sending unnecessary property changes for primitive values.
- Fixed JsonAdapter serialization for lists.
- Fixed pipewire crashes after hotplugging devices and changing default outputs.
- Fixed launches failing for `--daemonize` on some systems.
## Packaging Changes
- `glib` and `polkit` have been added as dependencies when compiling with polkit agent support.
- `vulkan-headers` has been added as a build-time dependency for screencopy (Vulkan backend support).
- `breakpad` has been replaced by `cpptrace`, which is far easier to package, and the `CRASH_REPORTER` cmake variable has been replaced with `CRASH_HANDLER` to stop this from being easy to ignore.
- `DISTRIBUTOR_DEBUGINFO_AVAILABLE` was removed as it is no longer important without breakpad.
- `libdrm` is now unconditionally required as a direct dependency.

View file

@ -8,7 +8,17 @@ let
inherit sha256; inherit sha256;
}) {}; }) {};
in rec { in rec {
latest = qt6_9_0; latest = qt6_10_0;
qt6_10_1 = byCommit {
commit = "ffbc9f8cbaacfb331b6017d5a5abb21a492c9a38";
sha256 = "0fvbizl7j5rv2rf8j76yw0xb3d9l06hahkjys2a7k1yraznvnafm";
};
qt6_10_0 = byCommit {
commit = "c5ae371f1a6a7fd27823bc500d9390b38c05fa55";
sha256 = "18g0f8cb9m8mxnz9cf48sks0hib79b282iajl2nysyszph993yp0";
};
qt6_9_2 = byCommit { qt6_9_2 = byCommit {
commit = "e9f00bd893984bc8ce46c895c3bf7cac95331127"; commit = "e9f00bd893984bc8ce46c895c3bf7cac95331127";

View file

@ -10,17 +10,23 @@
ninja, ninja,
spirv-tools, spirv-tools,
qt6, qt6,
breakpad, cpptrace ? null,
libunwind,
libdwarf,
jemalloc, jemalloc,
cli11, cli11,
wayland, wayland,
wayland-protocols, wayland-protocols,
wayland-scanner, wayland-scanner,
xorg, xorg,
libxcb ? xorg.libxcb,
libdrm, libdrm,
libgbm ? null, libgbm ? null,
vulkan-headers,
pipewire, pipewire,
pam, pam,
polkit,
glib,
gitRev ? (let gitRev ? (let
headExists = builtins.pathExists ./.git/HEAD; headExists = builtins.pathExists ./.git/HEAD;
@ -43,10 +49,14 @@
withPam ? true, withPam ? true,
withHyprland ? true, withHyprland ? true,
withI3 ? true, withI3 ? true,
withPolkit ? true,
withNetworkManager ? true,
}: let }: let
withCrashHandler = withCrashReporter && cpptrace != null && lib.strings.compareVersions cpptrace.version "0.7.2" >= 0;
unwrapped = stdenv.mkDerivation { unwrapped = stdenv.mkDerivation {
pname = "quickshell${lib.optionalString debug "-debug"}"; pname = "quickshell${lib.optionalString debug "-debug"}";
version = "0.2.0"; version = "0.2.1";
src = nix-gitignore.gitignoreSource "/default.nix\n" ./.; src = nix-gitignore.gitignoreSource "/default.nix\n" ./.;
dontWrapQtApps = true; # see wrappers dontWrapQtApps = true; # see wrappers
@ -66,17 +76,24 @@
buildInputs = [ buildInputs = [
qt6.qtbase qt6.qtbase
qt6.qtdeclarative qt6.qtdeclarative
libdrm
cli11 cli11
] ]
++ lib.optional withQtSvg qt6.qtsvg ++ lib.optional withQtSvg qt6.qtsvg
++ lib.optional withCrashReporter breakpad ++ lib.optional withCrashHandler (cpptrace.overrideAttrs (prev: {
cmakeFlags = prev.cmakeFlags ++ [
"-DCPPTRACE_UNWIND_WITH_LIBUNWIND=TRUE"
];
buildInputs = prev.buildInputs ++ [ libunwind ];
}))
++ lib.optional withJemalloc jemalloc ++ lib.optional withJemalloc jemalloc
++ lib.optional (withWayland && lib.strings.compareVersions qt6.qtbase.version "6.10.0" == -1) qt6.qtwayland ++ lib.optional (withWayland && lib.strings.compareVersions qt6.qtbase.version "6.10.0" == -1) qt6.qtwayland
++ lib.optionals withWayland [ wayland wayland-protocols ] ++ lib.optionals withWayland [ wayland wayland-protocols ]
++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ] ++ lib.optionals (withWayland && libgbm != null) [ libgbm vulkan-headers ]
++ lib.optional withX11 xorg.libxcb ++ lib.optional withX11 libxcb
++ lib.optional withPam pam ++ lib.optional withPam pam
++ lib.optional withPipewire pipewire; ++ lib.optional withPipewire pipewire
++ lib.optionals withPolkit [ polkit glib ];
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo"; cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
@ -85,12 +102,14 @@
(lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix) (lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix)
(lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true) (lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true)
(lib.cmakeFeature "GIT_REVISION" gitRev) (lib.cmakeFeature "GIT_REVISION" gitRev)
(lib.cmakeBool "CRASH_REPORTER" withCrashReporter) (lib.cmakeBool "CRASH_HANDLER" withCrashHandler)
(lib.cmakeBool "USE_JEMALLOC" withJemalloc) (lib.cmakeBool "USE_JEMALLOC" withJemalloc)
(lib.cmakeBool "WAYLAND" withWayland) (lib.cmakeBool "WAYLAND" withWayland)
(lib.cmakeBool "SCREENCOPY" (libgbm != null)) (lib.cmakeBool "SCREENCOPY" (libgbm != null))
(lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire) (lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire)
(lib.cmakeBool "SERVICE_PAM" withPam) (lib.cmakeBool "SERVICE_PAM" withPam)
(lib.cmakeBool "SERVICE_NETWORKMANAGER" withNetworkManager)
(lib.cmakeBool "SERVICE_POLKIT" withPolkit)
(lib.cmakeBool "HYPRLAND" withHyprland) (lib.cmakeBool "HYPRLAND" withHyprland)
(lib.cmakeBool "I3" withI3) (lib.cmakeBool "I3" withI3)
]; ];

6
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1758690382, "lastModified": 1768127708,
"narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=", "narHash": "sha256-1Sm77VfZh3mU0F5OqKABNLWxOuDeHIlcFjsXeeiPazs=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e643668fd71b949c53f8626614b21ff71a07379d", "rev": "ffbc9f8cbaacfb331b6017d5a5abb21a492c9a38",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -42,6 +42,7 @@
libxcb libxcb
libxkbcommon libxkbcommon
linux-pam linux-pam
polkit
mesa mesa
pipewire pipewire
qtbase qtbase
@ -55,8 +56,7 @@
#~(list "-GNinja" #~(list "-GNinja"
"-DDISTRIBUTOR=\"In-tree Guix channel\"" "-DDISTRIBUTOR=\"In-tree Guix channel\""
"-DDISTRIBUTOR_DEBUGINFO_AVAILABLE=NO" "-DDISTRIBUTOR_DEBUGINFO_AVAILABLE=NO"
;; Breakpad is not currently packaged for Guix. "-DCRASH_HANDLER=OFF")
"-DCRASH_REPORTER=OFF")
#:phases #:phases
#~(modify-phases %standard-phases #~(modify-phases %standard-phases
(replace 'build (lambda _ (invoke "cmake" "--build" "."))) (replace 'build (lambda _ (invoke "cmake" "--build" ".")))

View file

@ -11,8 +11,9 @@ add_subdirectory(window)
add_subdirectory(io) add_subdirectory(io)
add_subdirectory(widgets) add_subdirectory(widgets)
add_subdirectory(ui) add_subdirectory(ui)
add_subdirectory(windowmanager)
if (CRASH_REPORTER) if (CRASH_HANDLER)
add_subdirectory(crash) add_subdirectory(crash)
endif() endif()
@ -33,3 +34,7 @@ add_subdirectory(services)
if (BLUETOOTH) if (BLUETOOTH)
add_subdirectory(bluetooth) add_subdirectory(bluetooth)
endif() endif()
if (NETWORK)
add_subdirectory(network)
endif()

View file

@ -9,7 +9,6 @@
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qstring.h> #include <qstring.h>
#include <qstringliteral.h>
#include <qtypes.h> #include <qtypes.h>
#include "../core/logcat.hpp" #include "../core/logcat.hpp"

View file

@ -8,7 +8,6 @@
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qstring.h> #include <qstring.h>
#include <qstringliteral.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>

View file

@ -9,16 +9,10 @@ if (NOT DEFINED GIT_REVISION)
) )
endif() endif()
if (CRASH_REPORTER) if (CRASH_HANDLER)
set(CRASH_REPORTER_DEF 1) set(CRASH_HANDLER_DEF 1)
else() else()
set(CRASH_REPORTER_DEF 0) set(CRASH_HANDLER_DEF 0)
endif()
if (DISTRIBUTOR_DEBUGINFO_AVAILABLE)
set(DEBUGINFO_AVAILABLE 1)
else()
set(DEBUGINFO_AVAILABLE 0)
endif() endif()
configure_file(build.hpp.in build.hpp @ONLY ESCAPE_QUOTES) configure_file(build.hpp.in build.hpp @ONLY ESCAPE_QUOTES)

View file

@ -1,12 +1,17 @@
#pragma once #pragma once
// NOLINTBEGIN // NOLINTBEGIN
#define QS_VERSION "@quickshell_VERSION@"
#define QS_VERSION_MAJOR @quickshell_VERSION_MAJOR@
#define QS_VERSION_MINOR @quickshell_VERSION_MINOR@
#define QS_VERSION_PATCH @quickshell_VERSION_PATCH@
#define QS_UNRELEASED_FEATURES "@UNRELEASED_FEATURES@"
#define GIT_REVISION "@GIT_REVISION@" #define GIT_REVISION "@GIT_REVISION@"
#define DISTRIBUTOR "@DISTRIBUTOR@" #define DISTRIBUTOR "@DISTRIBUTOR@"
#define DISTRIBUTOR_DEBUGINFO_AVAILABLE @DEBUGINFO_AVAILABLE@ #define CRASH_HANDLER @CRASH_HANDLER_DEF@
#define CRASH_REPORTER @CRASH_REPORTER_DEF@
#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" #define BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#define COMPILER "@CMAKE_CXX_COMPILER_ID@ (@CMAKE_CXX_COMPILER_VERSION@)" #define COMPILER "@CMAKE_CXX_COMPILER_ID@ (@CMAKE_CXX_COMPILER_VERSION@)"
#define COMPILE_FLAGS "@CMAKE_CXX_FLAGS@" #define COMPILE_FLAGS "@CMAKE_CXX_FLAGS@"
#define BUILD_CONFIGURATION "@QS_BUILD_OPTIONS@" #define BUILD_CONFIGURATION "@QS_BUILD_OPTIONS@"
#define CRASHREPORT_URL "@CRASHREPORT_URL@"
// NOLINTEND // NOLINTEND

View file

@ -1,3 +1,4 @@
pkg_check_modules(libdrm REQUIRED IMPORTED_TARGET libdrm)
qt_add_library(quickshell-core STATIC qt_add_library(quickshell-core STATIC
plugin.cpp plugin.cpp
shell.cpp shell.cpp
@ -12,6 +13,7 @@ qt_add_library(quickshell-core STATIC
singleton.cpp singleton.cpp
generation.cpp generation.cpp
scan.cpp scan.cpp
scanenv.cpp
qsintercept.cpp qsintercept.cpp
incubator.cpp incubator.cpp
lazyloader.cpp lazyloader.cpp
@ -24,7 +26,6 @@ qt_add_library(quickshell-core STATIC
elapsedtimer.cpp elapsedtimer.cpp
desktopentry.cpp desktopentry.cpp
desktopentrymonitor.cpp desktopentrymonitor.cpp
objectrepeater.cpp
platformmenu.cpp platformmenu.cpp
qsmenu.cpp qsmenu.cpp
retainable.cpp retainable.cpp
@ -40,6 +41,8 @@ qt_add_library(quickshell-core STATIC
scriptmodel.cpp scriptmodel.cpp
colorquantizer.cpp colorquantizer.cpp
toolsupport.cpp toolsupport.cpp
streamreader.cpp
debuginfo.cpp
) )
qt_add_qml_module(quickshell-core qt_add_qml_module(quickshell-core
@ -52,7 +55,7 @@ qt_add_qml_module(quickshell-core
install_qml_module(quickshell-core) install_qml_module(quickshell-core)
target_link_libraries(quickshell-core PRIVATE Qt::Quick Qt::Widgets) target_link_libraries(quickshell-core PRIVATE Qt::Quick Qt::QuickPrivate Qt::Widgets quickshell-build PkgConfig::libdrm)
qs_module_pch(quickshell-core SET large) qs_module_pch(quickshell-core SET large)

View file

@ -13,6 +13,7 @@
#include <qnumeric.h> #include <qnumeric.h>
#include <qobject.h> #include <qobject.h>
#include <qqmllist.h> #include <qqmllist.h>
#include <qrect.h>
#include <qrgb.h> #include <qrgb.h>
#include <qthreadpool.h> #include <qthreadpool.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
@ -24,9 +25,15 @@ namespace {
QS_LOGGING_CATEGORY(logColorQuantizer, "quickshell.colorquantizer", QtWarningMsg); QS_LOGGING_CATEGORY(logColorQuantizer, "quickshell.colorquantizer", QtWarningMsg);
} }
ColorQuantizerOperation::ColorQuantizerOperation(QUrl* source, qreal depth, qreal rescaleSize) ColorQuantizerOperation::ColorQuantizerOperation(
QUrl* source,
qreal depth,
QRect imageRect,
qreal rescaleSize
)
: source(source) : source(source)
, maxDepth(depth) , maxDepth(depth)
, imageRect(imageRect)
, rescaleSize(rescaleSize) { , rescaleSize(rescaleSize) {
this->setAutoDelete(false); this->setAutoDelete(false);
} }
@ -37,6 +44,11 @@ void ColorQuantizerOperation::quantizeImage(const QAtomicInteger<bool>& shouldCa
this->colors.clear(); this->colors.clear();
auto image = QImage(this->source->toLocalFile()); auto image = QImage(this->source->toLocalFile());
if (this->imageRect.isValid()) {
image = image.copy(this->imageRect);
}
if ((image.width() > this->rescaleSize || image.height() > this->rescaleSize) if ((image.width() > this->rescaleSize || image.height() > this->rescaleSize)
&& this->rescaleSize > 0) && this->rescaleSize > 0)
{ {
@ -198,16 +210,27 @@ void ColorQuantizer::setDepth(qreal depth) {
this->mDepth = depth; this->mDepth = depth;
emit this->depthChanged(); emit this->depthChanged();
if (this->componentCompleted) this->quantizeAsync(); if (this->componentCompleted && !this->mSource.isEmpty()) this->quantizeAsync();
} }
} }
void ColorQuantizer::setImageRect(QRect imageRect) {
if (this->mImageRect != imageRect) {
this->mImageRect = imageRect;
emit this->imageRectChanged();
if (this->componentCompleted && !this->mSource.isEmpty()) this->quantizeAsync();
}
}
void ColorQuantizer::resetImageRect() { this->setImageRect(QRect()); }
void ColorQuantizer::setRescaleSize(int rescaleSize) { void ColorQuantizer::setRescaleSize(int rescaleSize) {
if (this->mRescaleSize != rescaleSize) { if (this->mRescaleSize != rescaleSize) {
this->mRescaleSize = rescaleSize; this->mRescaleSize = rescaleSize;
emit this->rescaleSizeChanged(); emit this->rescaleSizeChanged();
if (this->componentCompleted) this->quantizeAsync(); if (this->componentCompleted && !this->mSource.isEmpty()) this->quantizeAsync();
} }
} }
@ -221,8 +244,13 @@ void ColorQuantizer::quantizeAsync() {
if (this->liveOperation) this->cancelAsync(); if (this->liveOperation) this->cancelAsync();
qCDebug(logColorQuantizer) << "Starting color quantization asynchronously"; qCDebug(logColorQuantizer) << "Starting color quantization asynchronously";
this->liveOperation =
new ColorQuantizerOperation(&this->mSource, this->mDepth, this->mRescaleSize); this->liveOperation = new ColorQuantizerOperation(
&this->mSource,
this->mDepth,
this->mImageRect,
this->mRescaleSize
);
QObject::connect( QObject::connect(
this->liveOperation, this->liveOperation,

View file

@ -5,6 +5,7 @@
#include <qproperty.h> #include <qproperty.h>
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qqmlparserstatus.h> #include <qqmlparserstatus.h>
#include <qrect.h>
#include <qrunnable.h> #include <qrunnable.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
@ -16,7 +17,7 @@ class ColorQuantizerOperation
Q_OBJECT; Q_OBJECT;
public: public:
explicit ColorQuantizerOperation(QUrl* source, qreal depth, qreal rescaleSize); explicit ColorQuantizerOperation(QUrl* source, qreal depth, QRect imageRect, qreal rescaleSize);
void run() override; void run() override;
void tryCancel(); void tryCancel();
@ -44,6 +45,7 @@ private:
QList<QColor> colors; QList<QColor> colors;
QUrl* source; QUrl* source;
qreal maxDepth; qreal maxDepth;
QRect imageRect;
qreal rescaleSize; qreal rescaleSize;
}; };
@ -78,6 +80,13 @@ class ColorQuantizer
/// binary split of the color space /// binary split of the color space
Q_PROPERTY(qreal depth READ depth WRITE setDepth NOTIFY depthChanged); Q_PROPERTY(qreal depth READ depth WRITE setDepth NOTIFY depthChanged);
// clang-format off
/// Rectangle that the source image is cropped to.
///
/// Can be set to `undefined` to reset.
Q_PROPERTY(QRect imageRect READ imageRect WRITE setImageRect RESET resetImageRect NOTIFY imageRectChanged);
// clang-format on
/// The size to rescale the image to, when rescaleSize is 0 then no scaling will be done. /// The size to rescale the image to, when rescaleSize is 0 then no scaling will be done.
/// > [!NOTE] Results from color quantization doesn't suffer much when rescaling, it's /// > [!NOTE] Results from color quantization doesn't suffer much when rescaling, it's
/// > reccommended to rescale, otherwise the quantization process will take much longer. /// > reccommended to rescale, otherwise the quantization process will take much longer.
@ -97,6 +106,10 @@ public:
[[nodiscard]] qreal depth() const { return this->mDepth; } [[nodiscard]] qreal depth() const { return this->mDepth; }
void setDepth(qreal depth); void setDepth(qreal depth);
[[nodiscard]] QRect imageRect() const { return this->mImageRect; }
void setImageRect(QRect imageRect);
void resetImageRect();
[[nodiscard]] qreal rescaleSize() const { return this->mRescaleSize; } [[nodiscard]] qreal rescaleSize() const { return this->mRescaleSize; }
void setRescaleSize(int rescaleSize); void setRescaleSize(int rescaleSize);
@ -104,6 +117,7 @@ signals:
void colorsChanged(); void colorsChanged();
void sourceChanged(); void sourceChanged();
void depthChanged(); void depthChanged();
void imageRectChanged();
void rescaleSizeChanged(); void rescaleSizeChanged();
public slots: public slots:
@ -117,6 +131,7 @@ private:
ColorQuantizerOperation* liveOperation = nullptr; ColorQuantizerOperation* liveOperation = nullptr;
QUrl mSource; QUrl mSource;
qreal mDepth = 0; qreal mDepth = 0;
QRect mImageRect;
qreal mRescaleSize = 0; qreal mRescaleSize = 0;
Q_OBJECT_BINDABLE_PROPERTY( Q_OBJECT_BINDABLE_PROPERTY(

176
src/core/debuginfo.cpp Normal file
View file

@ -0,0 +1,176 @@
#include "debuginfo.hpp"
#include <array>
#include <cstring>
#include <string_view>
#include <fcntl.h>
#include <qconfig.h>
#include <qcontainerfwd.h>
#include <qdebug.h>
#include <qfile.h>
#include <qfloat16.h>
#include <qhashfunctions.h>
#include <qscopeguard.h>
#include <qtversion.h>
#include <unistd.h>
#include <xf86drm.h>
#include "build.hpp"
extern char** environ; // NOLINT
namespace qs::debuginfo {
QString qsVersion() {
return QS_VERSION " (revision " GIT_REVISION ", distributed by " DISTRIBUTOR ")";
}
QString qtVersion() { return qVersion() % QStringLiteral(" (built against " QT_VERSION_STR ")"); }
QString gpuInfo() {
auto deviceCount = drmGetDevices2(0, nullptr, 0);
if (deviceCount < 0) return "Failed to get DRM device count: " % QString::number(deviceCount);
auto* devices = new drmDevicePtr[deviceCount];
auto devicesArrayGuard = qScopeGuard([&] { delete[] devices; });
auto r = drmGetDevices2(0, devices, deviceCount);
if (deviceCount < 0) return "Failed to get DRM devices: " % QString::number(r);
auto devicesGuard = qScopeGuard([&] {
for (auto i = 0; i != deviceCount; ++i) drmFreeDevice(&devices[i]); // NOLINT
});
QString info;
auto stream = QTextStream(&info);
for (auto i = 0; i != deviceCount; ++i) {
auto* device = devices[i]; // NOLINT
int deviceNodeType = -1;
if (device->available_nodes & (1 << DRM_NODE_RENDER)) deviceNodeType = DRM_NODE_RENDER;
else if (device->available_nodes & (1 << DRM_NODE_PRIMARY)) deviceNodeType = DRM_NODE_PRIMARY;
if (deviceNodeType == -1) continue;
auto* deviceNode = device->nodes[DRM_NODE_RENDER]; // NOLINT
auto driver = [&]() -> QString {
auto fd = open(deviceNode, O_RDWR | O_CLOEXEC);
if (fd == -1) return "<failed to open device node>";
auto fdGuard = qScopeGuard([&] { close(fd); });
auto* ver = drmGetVersion(fd);
if (!ver) return "<drmGetVersion failed>";
auto verGuard = qScopeGuard([&] { drmFreeVersion(ver); });
// clang-format off
return QString(ver->name)
% ' ' % QString::number(ver->version_major)
% '.' % QString::number(ver->version_minor)
% '.' % QString::number(ver->version_patchlevel)
% " (" % ver->desc % ')';
// clang-format on
}();
QString product = "unknown";
QString address = "unknown";
auto hex = [](int num, int pad) { return QString::number(num, 16).rightJustified(pad, '0'); };
switch (device->bustype) {
case DRM_BUS_PCI: {
auto* b = device->businfo.pci;
auto* d = device->deviceinfo.pci;
address = "PCI " % hex(b->bus, 2) % ':' % hex(b->dev, 2) % '.' % hex(b->func, 1);
product = hex(d->vendor_id, 4) % ':' % hex(d->device_id, 4);
} break;
case DRM_BUS_USB: {
auto* b = device->businfo.usb;
auto* d = device->deviceinfo.usb;
address = "USB " % QString::number(b->bus) % ':' % QString::number(b->dev);
product = hex(d->vendor, 4) % ':' % hex(d->product, 4);
} break;
default: break;
}
stream << "GPU " << deviceNode << "\n Driver: " << driver << "\n Model: " << product
<< "\n Address: " << address << '\n';
}
return info;
}
QString systemInfo() {
QString info;
auto stream = QTextStream(&info);
stream << gpuInfo() << '\n';
stream << "/etc/os-release:";
auto osReleaseFile = QFile("/etc/os-release");
if (osReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << osReleaseFile.readAll() << '\n';
osReleaseFile.close();
} else {
stream << "FAILED TO OPEN\n";
}
stream << "/etc/lsb-release:";
auto lsbReleaseFile = QFile("/etc/lsb-release");
if (lsbReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << lsbReleaseFile.readAll();
lsbReleaseFile.close();
} else {
stream << "FAILED TO OPEN\n";
}
return info;
}
QString envInfo() {
QString info;
auto stream = QTextStream(&info);
for (auto** envp = environ; *envp != nullptr; ++envp) { // NOLINT
auto prefixes = std::array<std::string_view, 6> {
"QS_",
"QT_",
"QML_",
"QML2_",
"QSG_",
"XDG_CURRENT_DESKTOP=",
};
for (const auto& prefix: prefixes) {
if (strncmp(prefix.data(), *envp, prefix.length()) == 0) goto print;
}
continue;
print:
stream << *envp << '\n';
}
return info;
}
QString combinedInfo() {
QString info;
auto stream = QTextStream(&info);
stream << "===== Version Information =====\n";
stream << "Quickshell: " << qsVersion() << '\n';
stream << "Qt: " << qtVersion() << '\n';
stream << "\n===== Build Information =====\n";
stream << "Build Type: " << BUILD_TYPE << '\n';
stream << "Compiler: " << COMPILER << '\n';
stream << "Compile Flags: " << COMPILE_FLAGS << '\n';
stream << "Configuration:\n" << BUILD_CONFIGURATION << '\n';
stream << "\n===== System Information =====\n";
stream << systemInfo();
stream << "\n===== Environment (trimmed) =====\n";
stream << envInfo();
return info;
}
} // namespace qs::debuginfo

14
src/core/debuginfo.hpp Normal file
View file

@ -0,0 +1,14 @@
#pragma once
#include <qcontainerfwd.h>
namespace qs::debuginfo {
QString qsVersion();
QString qtVersion();
QString gpuInfo();
QString systemInfo();
QString envInfo();
QString combinedInfo();
} // namespace qs::debuginfo

View file

@ -107,7 +107,10 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
auto groupName = QString(); auto groupName = QString();
auto entries = QHash<QString, QPair<Locale, QString>>(); auto entries = QHash<QString, QPair<Locale, QString>>();
auto finishCategory = [&data, &groupName, &entries]() { auto actionOrder = QStringList();
auto pendingActions = QHash<QString, DesktopActionData>();
auto finishCategory = [&data, &groupName, &entries, &actionOrder, &pendingActions]() {
if (groupName == "Desktop Entry") { if (groupName == "Desktop Entry") {
if (entries.value("Type").second != "Application") return; if (entries.value("Type").second != "Application") return;
@ -129,9 +132,10 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
else if (key == "Terminal") data.terminal = value == "true"; else if (key == "Terminal") data.terminal = value == "true";
else if (key == "Categories") data.categories = value.split(u';', Qt::SkipEmptyParts); else if (key == "Categories") data.categories = value.split(u';', Qt::SkipEmptyParts);
else if (key == "Keywords") data.keywords = value.split(u';', Qt::SkipEmptyParts); else if (key == "Keywords") data.keywords = value.split(u';', Qt::SkipEmptyParts);
else if (key == "Actions") actionOrder = value.split(u';', Qt::SkipEmptyParts);
} }
} else if (groupName.startsWith("Desktop Action ")) { } else if (groupName.startsWith("Desktop Action ")) {
auto actionName = groupName.sliced(16); auto actionName = groupName.sliced(15);
DesktopActionData action; DesktopActionData action;
action.id = actionName; action.id = actionName;
@ -147,7 +151,7 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
} }
} }
data.actions.insert(actionName, action); pendingActions.insert(actionName, action);
} }
entries.clear(); entries.clear();
@ -193,6 +197,13 @@ ParsedDesktopEntryData DesktopEntry::parseText(const QString& id, const QString&
} }
finishCategory(); finishCategory();
for (const auto& actionId: actionOrder) {
if (pendingActions.contains(actionId)) {
data.actions.append(pendingActions.value(actionId));
}
}
return data; return data;
} }
@ -216,17 +227,18 @@ void DesktopEntry::updateState(const ParsedDesktopEntryData& newState) {
this->updateActions(newState.actions); this->updateActions(newState.actions);
} }
void DesktopEntry::updateActions(const QHash<QString, DesktopActionData>& newActions) { void DesktopEntry::updateActions(const QVector<DesktopActionData>& newActions) {
auto old = this->mActions; auto old = this->mActions;
this->mActions.clear();
for (const auto& [key, d]: newActions.asKeyValueRange()) { for (const auto& d: newActions) {
DesktopAction* act = nullptr; DesktopAction* act = nullptr;
if (auto found = old.find(key); found != old.end()) { auto found = std::ranges::find(old, d.id, &DesktopAction::mId);
act = found.value(); if (found != old.end()) {
act = *found;
old.erase(found); old.erase(found);
} else { } else {
act = new DesktopAction(d.id, this); act = new DesktopAction(d.id, this);
this->mActions.insert(key, act);
} }
Qt::beginPropertyUpdateGroup(); Qt::beginPropertyUpdateGroup();
@ -237,6 +249,7 @@ void DesktopEntry::updateActions(const QHash<QString, DesktopActionData>& newAct
Qt::endPropertyUpdateGroup(); Qt::endPropertyUpdateGroup();
act->mEntries = d.entries; act->mEntries = d.entries;
this->mActions.append(act);
} }
for (auto* leftover: old) { for (auto* leftover: old) {
@ -250,7 +263,7 @@ void DesktopEntry::execute() const {
bool DesktopEntry::isValid() const { return !this->bName.value().isEmpty(); } bool DesktopEntry::isValid() const { return !this->bName.value().isEmpty(); }
QVector<DesktopAction*> DesktopEntry::actions() const { return this->mActions.values(); } QVector<DesktopAction*> DesktopEntry::actions() const { return this->mActions; }
QVector<QString> DesktopEntry::parseExecString(const QString& execString) { QVector<QString> DesktopEntry::parseExecString(const QString& execString) {
QVector<QString> arguments; QVector<QString> arguments;
@ -269,16 +282,22 @@ QVector<QString> DesktopEntry::parseExecString(const QString& execString) {
currentArgument += '\\'; currentArgument += '\\';
escape = 0; escape = 0;
} }
} else if (escape == 2) {
currentArgument += c;
escape = 0;
} else if (escape != 0) { } else if (escape != 0) {
if (escape != 2) { switch (c.unicode()) {
// Technically this is an illegal state, but the spec has a terrible double escape case 's': currentArgument += u' '; break;
// rule in strings for no discernable reason. Assuming someone might understandably case 'n': currentArgument += u'\n'; break;
// misunderstand it, treat it as a normal escape and log it. case 't': currentArgument += u'\t'; break;
case 'r': currentArgument += u'\r'; break;
case '\\': currentArgument += u'\\'; break;
default:
qCWarning(logDesktopEntry).noquote() qCWarning(logDesktopEntry).noquote()
<< "Illegal escape sequence in desktop entry exec string:" << execString; << "Illegal escape sequence in desktop entry exec string:" << execString;
}
currentArgument += c; currentArgument += c;
break;
}
escape = 0; escape = 0;
} else if (c == u'"' || c == u'\'') { } else if (c == u'"' || c == u'\'') {
parsingString = false; parsingString = false;

View file

@ -43,7 +43,7 @@ struct ParsedDesktopEntryData {
QVector<QString> categories; QVector<QString> categories;
QVector<QString> keywords; QVector<QString> keywords;
QHash<QString, QString> entries; QHash<QString, QString> entries;
QHash<QString, DesktopActionData> actions; QVector<DesktopActionData> actions;
}; };
/// A desktop entry. See @@DesktopEntries for details. /// A desktop entry. See @@DesktopEntries for details.
@ -164,10 +164,10 @@ public:
// clang-format on // clang-format on
private: private:
void updateActions(const QHash<QString, DesktopActionData>& newActions); void updateActions(const QVector<DesktopActionData>& newActions);
ParsedDesktopEntryData state; ParsedDesktopEntryData state;
QHash<QString, DesktopAction*> mActions; QVector<DesktopAction*> mActions;
friend class DesktopAction; friend class DesktopAction;
}; };

View file

@ -49,7 +49,8 @@ EngineGeneration::EngineGeneration(const QDir& rootPath, QmlScanner scanner)
this->engine->addImportPath("qs:@/"); this->engine->addImportPath("qs:@/");
this->engine->setNetworkAccessManagerFactory(&this->interceptNetFactory); this->engine->setNetworkAccessManagerFactory(&this->interceptNetFactory);
this->engine->setIncubationController(&this->delayedIncubationController); this->incubationController.initLoop();
this->engine->setIncubationController(&this->incubationController);
this->engine->addImageProvider("icon", new IconImageProvider()); this->engine->addImageProvider("icon", new IconImageProvider());
this->engine->addImageProvider("qsimage", new QsImageProvider()); this->engine->addImageProvider("qsimage", new QsImageProvider());
@ -134,7 +135,7 @@ void EngineGeneration::onReload(EngineGeneration* old) {
// new generation acquires it then incubators will hang intermittently // new generation acquires it then incubators will hang intermittently
qCDebug(logIncubator) << "Locking incubation controllers of old generation" << old; qCDebug(logIncubator) << "Locking incubation controllers of old generation" << old;
old->incubationControllersLocked = true; old->incubationControllersLocked = true;
old->assignIncubationController(); old->updateIncubationMode();
} }
QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit); QObject::connect(this->engine, &QQmlEngine::quit, this, &EngineGeneration::quit);
@ -208,6 +209,8 @@ bool EngineGeneration::setExtraWatchedFiles(const QVector<QString>& files) {
for (const auto& file: files) { for (const auto& file: files) {
if (!this->scanner.scannedFiles.contains(file)) { if (!this->scanner.scannedFiles.contains(file)) {
this->extraWatchedFiles.append(file); this->extraWatchedFiles.append(file);
QByteArray data;
this->scanner.readAndHashFile(file, data);
} }
} }
@ -228,6 +231,11 @@ void EngineGeneration::onFileChanged(const QString& name) {
auto fileInfo = QFileInfo(name); auto fileInfo = QFileInfo(name);
if (fileInfo.isFile() && fileInfo.size() == 0) return; if (fileInfo.isFile() && fileInfo.size() == 0) return;
if (!this->scanner.hasFileContentChanged(name)) {
qCDebug(logQmlScanner) << "Ignoring file change with unchanged content:" << name;
return;
}
emit this->filesChanged(); emit this->filesChanged();
} }
} }
@ -236,6 +244,11 @@ void EngineGeneration::onDirectoryChanged() {
// try to find any files that were just deleted from a replace operation // try to find any files that were just deleted from a replace operation
for (auto& file: this->deletedWatchedFiles) { for (auto& file: this->deletedWatchedFiles) {
if (QFileInfo(file).exists()) { if (QFileInfo(file).exists()) {
if (!this->scanner.hasFileContentChanged(file)) {
qCDebug(logQmlScanner) << "Ignoring restored file with unchanged content:" << file;
continue;
}
emit this->filesChanged(); emit this->filesChanged();
break; break;
} }
@ -288,29 +301,18 @@ void EngineGeneration::trackWindowIncubationController(QQuickWindow* window) {
QObject::connect(window, &QObject::destroyed, this, &EngineGeneration::onTrackedWindowDestroyed); QObject::connect(window, &QObject::destroyed, this, &EngineGeneration::onTrackedWindowDestroyed);
this->trackedWindows.append(window); this->trackedWindows.append(window);
this->assignIncubationController(); this->updateIncubationMode();
} }
void EngineGeneration::onTrackedWindowDestroyed(QObject* object) { void EngineGeneration::onTrackedWindowDestroyed(QObject* object) {
this->trackedWindows.removeAll(static_cast<QQuickWindow*>(object)); // NOLINT this->trackedWindows.removeAll(static_cast<QQuickWindow*>(object)); // NOLINT
this->assignIncubationController(); this->updateIncubationMode();
} }
void EngineGeneration::assignIncubationController() { void EngineGeneration::updateIncubationMode() {
QQmlIncubationController* controller = &this->delayedIncubationController; // If we're in a situation with only hidden but tracked windows this might be wrong,
// but it seems to at least work.
for (auto* window: this->trackedWindows) { this->incubationController.setIncubationMode(!this->trackedWindows.empty());
if (auto* wctl = window->incubationController()) {
controller = wctl;
break;
}
}
qCDebug(logIncubator) << "Assigning incubation controller" << controller << "to generation"
<< this
<< "fallback:" << (controller == &this->delayedIncubationController);
this->engine->setIncubationController(controller);
} }
EngineGeneration* EngineGeneration::currentGeneration() { EngineGeneration* EngineGeneration::currentGeneration() {

View file

@ -65,7 +65,7 @@ public:
QFileSystemWatcher* watcher = nullptr; QFileSystemWatcher* watcher = nullptr;
QVector<QString> deletedWatchedFiles; QVector<QString> deletedWatchedFiles;
QVector<QString> extraWatchedFiles; QVector<QString> extraWatchedFiles;
DelayedQmlIncubationController delayedIncubationController; QsIncubationController incubationController;
bool reloadComplete = false; bool reloadComplete = false;
QuickshellGlobal* qsgInstance = nullptr; QuickshellGlobal* qsgInstance = nullptr;
@ -89,7 +89,7 @@ private slots:
private: private:
void postReload(); void postReload();
void assignIncubationController(); void updateIncubationMode();
QVector<QQuickWindow*> trackedWindows; QVector<QQuickWindow*> trackedWindows;
bool incubationControllersLocked = false; bool incubationControllersLocked = false;
QHash<const void*, EngineGenerationExt*> extensions; QHash<const void*, EngineGenerationExt*> extensions;

View file

@ -19,8 +19,7 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
if (splitIdx != -1) { if (splitIdx != -1) {
iconName = id.sliced(0, splitIdx); iconName = id.sliced(0, splitIdx);
path = id.sliced(splitIdx + 6); path = id.sliced(splitIdx + 6);
qWarning() << "Searching custom icon paths is not yet supported. Icon path will be ignored for" path = QString("/%1/%2").arg(path, iconName.sliced(iconName.lastIndexOf('/') + 1));
<< id;
} else { } else {
splitIdx = id.indexOf("?fallback="); splitIdx = id.indexOf("?fallback=");
if (splitIdx != -1) { if (splitIdx != -1) {
@ -32,7 +31,8 @@ IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& re
} }
auto icon = QIcon::fromTheme(iconName); auto icon = QIcon::fromTheme(iconName);
if (icon.isNull()) icon = QIcon::fromTheme(fallbackName); if (icon.isNull() && !fallbackName.isEmpty()) icon = QIcon::fromTheme(fallbackName);
if (icon.isNull() && !path.isEmpty()) icon = QPixmap(path);
auto targetSize = requestedSize.isValid() ? requestedSize : QSize(100, 100); auto targetSize = requestedSize.isValid() ? requestedSize : QSize(100, 100);
if (targetSize.width() == 0 || targetSize.height() == 0) targetSize = QSize(2, 2); if (targetSize.width() == 0 || targetSize.height() == 0) targetSize = QSize(2, 2);

View file

@ -22,8 +22,8 @@ class PixmapCacheIconEngine: public QIconEngine {
QIcon::Mode /*unused*/, QIcon::Mode /*unused*/,
QIcon::State /*unused*/ QIcon::State /*unused*/
) override { ) override {
qFatal( qFatal()
) << "Unexpected icon paint request bypassed pixmap method. Please report this as a bug."; << "Unexpected icon paint request bypassed pixmap method. Please report this as a bug.";
} }
QPixmap pixmap(const QSize& size, QIcon::Mode /*unused*/, QIcon::State /*unused*/) override { QPixmap pixmap(const QSize& size, QIcon::Mode /*unused*/, QIcon::State /*unused*/) override {

View file

@ -1,7 +1,16 @@
#include "incubator.hpp" #include "incubator.hpp"
#include <private/qsgrenderloop_p.h>
#include <qabstractanimation.h>
#include <qguiapplication.h>
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h>
#include <qminmax.h>
#include <qnamespace.h>
#include <qobject.h>
#include <qobjectdefs.h>
#include <qqmlincubator.h> #include <qqmlincubator.h>
#include <qscreen.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "logcat.hpp" #include "logcat.hpp"
@ -15,3 +24,112 @@ void QsQmlIncubator::statusChanged(QQmlIncubator::Status status) {
default: break; default: break;
} }
} }
void QsIncubationController::initLoop() {
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance()); // NOLINT
this->renderLoop = QSGRenderLoop::instance();
QObject::connect(
app,
&QGuiApplication::screenAdded,
this,
&QsIncubationController::updateIncubationTime
);
QObject::connect(
app,
&QGuiApplication::screenRemoved,
this,
&QsIncubationController::updateIncubationTime
);
this->updateIncubationTime();
QObject::connect(
this->renderLoop,
&QSGRenderLoop::timeToIncubate,
this,
&QsIncubationController::incubate
);
QAnimationDriver* animationDriver = this->renderLoop->animationDriver();
if (animationDriver) {
QObject::connect(
animationDriver,
&QAnimationDriver::stopped,
this,
&QsIncubationController::animationStopped
);
} else {
qCInfo(logIncubator) << "Render loop does not have animation driver, animationStopped cannot "
"be used to trigger incubation.";
}
}
void QsIncubationController::setIncubationMode(bool render) {
if (render == this->followRenderloop) return;
this->followRenderloop = render;
if (render) {
qCDebug(logIncubator) << "Incubation mode changed: render loop driven";
} else {
qCDebug(logIncubator) << "Incubation mode changed: event loop driven";
}
if (!render && this->incubatingObjectCount()) this->incubateLater();
}
void QsIncubationController::timerEvent(QTimerEvent* /*event*/) {
this->killTimer(this->timerId);
this->timerId = 0;
this->incubate();
}
void QsIncubationController::incubateLater() {
if (this->followRenderloop) {
if (this->timerId != 0) {
this->killTimer(this->timerId);
this->timerId = 0;
}
// Incubate again at the end of the event processing queue
QMetaObject::invokeMethod(this, &QsIncubationController::incubate, Qt::QueuedConnection);
} else if (this->timerId == 0) {
// Wait for a while before processing the next batch. Using a
// timer to avoid starvation of system events.
this->timerId = this->startTimer(this->incubationTime);
}
}
void QsIncubationController::incubate() {
if ((!this->followRenderloop || this->renderLoop) && this->incubatingObjectCount()) {
if (!this->followRenderloop) {
this->incubateFor(10);
if (this->incubatingObjectCount()) this->incubateLater();
} else if (this->renderLoop->interleaveIncubation()) {
this->incubateFor(this->incubationTime);
} else {
this->incubateFor(this->incubationTime * 2);
if (this->incubatingObjectCount()) this->incubateLater();
}
}
}
void QsIncubationController::animationStopped() { this->incubate(); }
void QsIncubationController::incubatingObjectCountChanged(int count) {
if (count
&& (!this->followRenderloop
|| (this->renderLoop && !this->renderLoop->interleaveIncubation())))
{
this->incubateLater();
}
}
void QsIncubationController::updateIncubationTime() {
auto* screen = QGuiApplication::primaryScreen();
if (!screen) return;
// 1/3 frame on primary screen
this->incubationTime = qMax(1, static_cast<int>(1000 / screen->refreshRate() / 3));
}

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <qobject.h> #include <qobject.h>
#include <qpointer.h>
#include <qqmlincubator.h> #include <qqmlincubator.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
@ -25,7 +26,37 @@ signals:
void failed(); void failed();
}; };
class DelayedQmlIncubationController: public QQmlIncubationController { class QSGRenderLoop;
// Do nothing.
// This ensures lazy loaders don't start blocking before onReload creates windows. class QsIncubationController
: public QObject
, public QQmlIncubationController {
Q_OBJECT
public:
void initLoop();
void setIncubationMode(bool render);
void incubateLater();
protected:
void timerEvent(QTimerEvent* event) override;
public slots:
void incubate();
void animationStopped();
void updateIncubationTime();
protected:
void incubatingObjectCountChanged(int count) override;
private:
// QPointer did not work with forward declarations prior to 6.7
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QPointer<QSGRenderLoop> renderLoop = nullptr;
#else
QSGRenderLoop* renderLoop = nullptr;
#endif
int incubationTime = 0;
int timerId = 0;
bool followRenderloop = false;
}; };

View file

@ -3,12 +3,14 @@
#include <qdatastream.h> #include <qdatastream.h>
QDataStream& operator<<(QDataStream& stream, const InstanceInfo& info) { QDataStream& operator<<(QDataStream& stream, const InstanceInfo& info) {
stream << info.instanceId << info.configPath << info.shellId << info.launchTime << info.pid; stream << info.instanceId << info.configPath << info.shellId << info.appId << info.launchTime
<< info.pid << info.display;
return stream; return stream;
} }
QDataStream& operator>>(QDataStream& stream, InstanceInfo& info) { QDataStream& operator>>(QDataStream& stream, InstanceInfo& info) {
stream >> info.instanceId >> info.configPath >> info.shellId >> info.launchTime >> info.pid; stream >> info.instanceId >> info.configPath >> info.shellId >> info.appId >> info.launchTime
>> info.pid >> info.display;
return stream; return stream;
} }

View file

@ -9,8 +9,10 @@ struct InstanceInfo {
QString instanceId; QString instanceId;
QString configPath; QString configPath;
QString shellId; QString shellId;
QString appId;
QDateTime launchTime; QDateTime launchTime;
pid_t pid = -1; pid_t pid = -1;
QString display;
static InstanceInfo CURRENT; // NOLINT static InstanceInfo CURRENT; // NOLINT
}; };
@ -34,6 +36,8 @@ namespace qs::crash {
struct CrashInfo { struct CrashInfo {
int logFd = -1; int logFd = -1;
int traceFd = -1;
int infoFd = -1;
static CrashInfo INSTANCE; // NOLINT static CrashInfo INSTANCE; // NOLINT
}; };

View file

@ -82,9 +82,6 @@
/// > Notably, @@Variants does not corrently support asynchronous /// > Notably, @@Variants does not corrently support asynchronous
/// > loading, meaning using it inside a LazyLoader will block similarly to not /// > loading, meaning using it inside a LazyLoader will block similarly to not
/// > having a loader to start with. /// > having a loader to start with.
///
/// > [!WARNING] LazyLoaders do not start loading before the first window is created,
/// > meaning if you create all windows inside of lazy loaders, none of them will ever load.
class LazyLoader: public Reloadable { class LazyLoader: public Reloadable {
Q_OBJECT; Q_OBJECT;
/// The fully loaded item if the loader is @@loading or @@active, or `null` /// The fully loaded item if the loader is @@loading or @@active, or `null`

View file

@ -14,6 +14,7 @@
#include <qlist.h> #include <qlist.h>
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qmutex.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h> #include <qobject.h>
#include <qobjectdefs.h> #include <qobjectdefs.h>
@ -27,7 +28,13 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include <sys/mman.h> #include <sys/mman.h>
#ifdef __linux__
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/types.h>
#endif
#ifdef __FreeBSD__
#include <unistd.h>
#endif
#include "instanceinfo.hpp" #include "instanceinfo.hpp"
#include "logcat.hpp" #include "logcat.hpp"
@ -43,6 +50,57 @@ using namespace qt_logging_registry;
QS_LOGGING_CATEGORY(logLogging, "quickshell.logging", QtWarningMsg); QS_LOGGING_CATEGORY(logLogging, "quickshell.logging", QtWarningMsg);
namespace {
bool copyFileData(int sourceFd, int destFd, qint64 size) {
auto usize = static_cast<size_t>(size);
#ifdef __linux__
off_t offset = 0;
auto remaining = usize;
while (remaining > 0) {
auto r = sendfile(destFd, sourceFd, &offset, remaining);
if (r == -1) {
if (errno == EINTR) continue;
return false;
}
if (r == 0) break;
remaining -= static_cast<size_t>(r);
}
return true;
#else
std::array<char, 64 * 1024> buffer = {};
auto remaining = usize;
while (remaining > 0) {
auto chunk = std::min(remaining, buffer.size());
auto r = ::read(sourceFd, buffer.data(), chunk);
if (r == -1) {
if (errno == EINTR) continue;
return false;
}
if (r == 0) break;
auto readBytes = static_cast<size_t>(r);
size_t written = 0;
while (written < readBytes) {
auto w = ::write(destFd, buffer.data() + written, readBytes - written);
if (w == -1) {
if (errno == EINTR) continue;
return false;
}
written += static_cast<size_t>(w);
}
remaining -= readBytes;
}
return true;
#endif
}
} // namespace
bool LogMessage::operator==(const LogMessage& other) const { bool LogMessage::operator==(const LogMessage& other) const {
// note: not including time // note: not including time
return this->type == other.type && this->category == other.category && this->body == other.body; return this->type == other.type && this->category == other.category && this->body == other.body;
@ -163,6 +221,7 @@ void LogManager::messageHandler(
} }
if (display) { if (display) {
auto locker = QMutexLocker(&self->stdoutMutex);
LogMessage::formatMessage( LogMessage::formatMessage(
self->stdoutStream, self->stdoutStream,
message, message,
@ -251,10 +310,15 @@ void LogManager::init(
instance->rules->append(parser.rules()); instance->rules->append(parser.rules());
} }
qInstallMessageHandler(&LogManager::messageHandler);
instance->lastCategoryFilter = QLoggingCategory::installFilter(&LogManager::filterCategory); instance->lastCategoryFilter = QLoggingCategory::installFilter(&LogManager::filterCategory);
if (instance->lastCategoryFilter == &LogManager::filterCategory) {
qCFatal(logLogging) << "Quickshell's log filter has been installed twice. This is a bug.";
instance->lastCategoryFilter = nullptr;
}
qInstallMessageHandler(&LogManager::messageHandler);
qCDebug(logLogging) << "Creating offthread logger..."; qCDebug(logLogging) << "Creating offthread logger...";
auto* thread = new QThread(); auto* thread = new QThread();
instance->threadProxy.moveToThread(thread); instance->threadProxy.moveToThread(thread);
@ -361,7 +425,8 @@ void ThreadLogging::initFs() {
auto* runDir = QsPaths::instance()->instanceRunDir(); auto* runDir = QsPaths::instance()->instanceRunDir();
if (!runDir) { if (!runDir) {
qCCritical(logLogging qCCritical(
logLogging
) << "Could not start filesystem logging as the runtime directory could not be created."; ) << "Could not start filesystem logging as the runtime directory could not be created.";
return; return;
} }
@ -372,7 +437,8 @@ void ThreadLogging::initFs() {
auto* detailedFile = new QFile(detailedPath); auto* detailedFile = new QFile(detailedPath);
if (!file->open(QFile::ReadWrite | QFile::Truncate)) { if (!file->open(QFile::ReadWrite | QFile::Truncate)) {
qCCritical(logLogging qCCritical(
logLogging
) << "Could not start filesystem logger as the log file could not be created:" ) << "Could not start filesystem logger as the log file could not be created:"
<< path; << path;
delete file; delete file;
@ -383,13 +449,14 @@ void ThreadLogging::initFs() {
// buffered by WriteBuffer // buffered by WriteBuffer
if (!detailedFile->open(QFile::ReadWrite | QFile::Truncate | QFile::Unbuffered)) { if (!detailedFile->open(QFile::ReadWrite | QFile::Truncate | QFile::Unbuffered)) {
qCCritical(logLogging qCCritical(
logLogging
) << "Could not start detailed filesystem logger as the log file could not be created:" ) << "Could not start detailed filesystem logger as the log file could not be created:"
<< detailedPath; << detailedPath;
delete detailedFile; delete detailedFile;
detailedFile = nullptr; detailedFile = nullptr;
} else { } else {
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,
@ -411,7 +478,11 @@ void ThreadLogging::initFs() {
auto* oldFile = this->file; auto* oldFile = this->file;
if (oldFile) { if (oldFile) {
oldFile->seek(0); oldFile->seek(0);
sendfile(file->handle(), oldFile->handle(), nullptr, oldFile->size());
if (!copyFileData(oldFile->handle(), file->handle(), oldFile->size())) {
qCritical(logLogging) << "Failed to copy log from memfd with error code " << errno
<< qt_error_string(errno);
}
} }
this->file = file; this->file = file;
@ -423,7 +494,10 @@ void ThreadLogging::initFs() {
auto* oldFile = this->detailedFile; auto* oldFile = this->detailedFile;
if (oldFile) { if (oldFile) {
oldFile->seek(0); oldFile->seek(0);
sendfile(detailedFile->handle(), oldFile->handle(), nullptr, oldFile->size()); if (!copyFileData(oldFile->handle(), detailedFile->handle(), oldFile->size())) {
qCritical(logLogging) << "Failed to copy detailed log from memfd with error code " << errno
<< qt_error_string(errno);
}
} }
crash::CrashInfo::INSTANCE.logFd = detailedFile->handle(); crash::CrashInfo::INSTANCE.logFd = detailedFile->handle();
@ -746,11 +820,11 @@ bool EncodedLogReader::readVarInt(quint32* slot) {
if (!this->reader.skip(1)) return false; if (!this->reader.skip(1)) return false;
*slot = qFromLittleEndian(n); *slot = qFromLittleEndian(n);
} else if ((bytes[1] != 0xff || bytes[2] != 0xff) && readLength >= 3) { } else if ((bytes[1] != 0xff || bytes[2] != 0xff) && readLength >= 3) {
auto n = *reinterpret_cast<quint16*>(bytes.data() + 1); auto n = *reinterpret_cast<quint16*>(bytes.data() + 1); // NOLINT
if (!this->reader.skip(3)) return false; if (!this->reader.skip(3)) return false;
*slot = qFromLittleEndian(n); *slot = qFromLittleEndian(n);
} else if (readLength == 7) { } else if (readLength == 7) {
auto n = *reinterpret_cast<quint32*>(bytes.data() + 3); auto n = *reinterpret_cast<quint32*>(bytes.data() + 3); // NOLINT
if (!this->reader.skip(7)) return false; if (!this->reader.skip(7)) return false;
*slot = qFromLittleEndian(n); *slot = qFromLittleEndian(n);
} else return false; } else return false;
@ -886,7 +960,7 @@ bool LogReader::continueReading() {
} }
void LogFollower::FcntlWaitThread::run() { void LogFollower::FcntlWaitThread::run() {
auto lock = flock { struct flock lock = {
.l_type = F_RDLCK, // won't block other read locks when we take it .l_type = F_RDLCK, // won't block other read locks when we take it
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,

View file

@ -10,6 +10,7 @@
#include <qlatin1stringview.h> #include <qlatin1stringview.h>
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qmutex.h>
#include <qobject.h> #include <qobject.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
@ -135,6 +136,7 @@ private:
QHash<QLatin1StringView, CategoryFilter> allFilters; QHash<QLatin1StringView, CategoryFilter> allFilters;
QTextStream stdoutStream; QTextStream stdoutStream;
QMutex stdoutMutex;
LoggingThreadProxy threadProxy; LoggingThreadProxy threadProxy;
friend void initLogCategoryLevel(const char* name, QtMsgType defaultLevel); friend void initLogCategoryLevel(const char* name, QtMsgType defaultLevel);

View file

@ -1,81 +1,14 @@
#include "model.hpp" #include "model.hpp"
#include <qabstractitemmodel.h> #include <qbytearray.h>
#include <qhash.h> #include <qhash.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h>
#include <qqmllist.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qvariant.h>
qint32 UntypedObjectModel::rowCount(const QModelIndex& parent) const {
if (parent != QModelIndex()) return 0;
return static_cast<qint32>(this->valuesList.length());
}
QVariant UntypedObjectModel::data(const QModelIndex& index, qint32 role) const {
if (role != Qt::UserRole) return QVariant();
return QVariant::fromValue(this->valuesList.at(index.row()));
}
QHash<int, QByteArray> UntypedObjectModel::roleNames() const { QHash<int, QByteArray> UntypedObjectModel::roleNames() const {
return {{Qt::UserRole, "modelData"}}; return {{Qt::UserRole, "modelData"}};
} }
void UntypedObjectModel::insertObject(QObject* object, qsizetype index) {
auto iindex = index == -1 ? this->valuesList.length() : index;
emit this->objectInsertedPre(object, iindex);
auto intIndex = static_cast<qint32>(iindex);
this->beginInsertRows(QModelIndex(), intIndex, intIndex);
this->valuesList.insert(iindex, object);
this->endInsertRows();
emit this->valuesChanged();
emit this->objectInsertedPost(object, iindex);
}
void UntypedObjectModel::removeAt(qsizetype index) {
auto* object = this->valuesList.at(index);
emit this->objectRemovedPre(object, index);
auto intIndex = static_cast<qint32>(index);
this->beginRemoveRows(QModelIndex(), intIndex, intIndex);
this->valuesList.removeAt(index);
this->endRemoveRows();
emit this->valuesChanged();
emit this->objectRemovedPost(object, index);
}
bool UntypedObjectModel::removeObject(const QObject* object) {
auto index = this->valuesList.indexOf(object);
if (index == -1) return false;
this->removeAt(index);
return true;
}
void UntypedObjectModel::diffUpdate(const QVector<QObject*>& newValues) {
for (qsizetype i = 0; i < this->valuesList.length();) {
if (newValues.contains(this->valuesList.at(i))) i++;
else this->removeAt(i);
}
qsizetype oi = 0;
for (auto* object: newValues) {
if (this->valuesList.length() == oi || this->valuesList.at(oi) != object) {
this->insertObject(object, oi);
}
oi++;
}
}
qsizetype UntypedObjectModel::indexOf(QObject* object) { return this->valuesList.indexOf(object); }
UntypedObjectModel* UntypedObjectModel::emptyInstance() { UntypedObjectModel* UntypedObjectModel::emptyInstance() {
static auto* instance = new UntypedObjectModel(nullptr); // NOLINT static auto* instance = new ObjectModel<void>(nullptr);
return instance; return instance;
} }

View file

@ -2,7 +2,7 @@
#include <functional> #include <functional>
#include <bit> #include <QtCore/qtmetamacros.h>
#include <qabstractitemmodel.h> #include <qabstractitemmodel.h>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qobject.h> #include <qobject.h>
@ -49,14 +49,11 @@ class UntypedObjectModel: public QAbstractListModel {
public: public:
explicit UntypedObjectModel(QObject* parent): QAbstractListModel(parent) {} explicit UntypedObjectModel(QObject* parent): QAbstractListModel(parent) {}
[[nodiscard]] qint32 rowCount(const QModelIndex& parent) const override;
[[nodiscard]] QVariant data(const QModelIndex& index, qint32 role) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override; [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] QList<QObject*> values() const { return this->valuesList; } [[nodiscard]] virtual QList<QObject*> values() = 0;
void removeAt(qsizetype index);
Q_INVOKABLE qsizetype indexOf(QObject* object); Q_INVOKABLE virtual qsizetype indexOf(QObject* object) const = 0;
static UntypedObjectModel* emptyInstance(); static UntypedObjectModel* emptyInstance();
@ -71,15 +68,6 @@ signals:
/// Sent immediately after an object is removed from the list. /// Sent immediately after an object is removed from the list.
void objectRemovedPost(QObject* object, qsizetype index); void objectRemovedPost(QObject* object, qsizetype index);
protected:
void insertObject(QObject* object, qsizetype index = -1);
bool removeObject(const QObject* object);
// Assumes only one instance of a specific value
void diffUpdate(const QVector<QObject*>& newValues);
QVector<QObject*> valuesList;
private: private:
static qsizetype valuesCount(QQmlListProperty<QObject>* property); static qsizetype valuesCount(QQmlListProperty<QObject>* property);
static QObject* valueAt(QQmlListProperty<QObject>* property, qsizetype index); static QObject* valueAt(QQmlListProperty<QObject>* property, qsizetype index);
@ -90,14 +78,20 @@ class ObjectModel: public UntypedObjectModel {
public: public:
explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {} explicit ObjectModel(QObject* parent): UntypedObjectModel(parent) {}
[[nodiscard]] QVector<T*>& valueList() { return *std::bit_cast<QVector<T*>*>(&this->valuesList); } [[nodiscard]] const QList<T*>& valueList() const { return this->mValuesList; }
[[nodiscard]] QList<T*>& valueList() { return this->mValuesList; }
[[nodiscard]] const QVector<T*>& valueList() const {
return *std::bit_cast<const QVector<T*>*>(&this->valuesList);
}
void insertObject(T* object, qsizetype index = -1) { void insertObject(T* object, qsizetype index = -1) {
this->UntypedObjectModel::insertObject(object, index); auto iindex = index == -1 ? this->mValuesList.length() : index;
emit this->objectInsertedPre(object, iindex);
auto intIndex = static_cast<qint32>(iindex);
this->beginInsertRows(QModelIndex(), intIndex, intIndex);
this->mValuesList.insert(iindex, object);
this->endInsertRows();
emit this->valuesChanged();
emit this->objectInsertedPost(object, iindex);
} }
void insertObjectSorted(T* object, const std::function<bool(T*, T*)>& compare) { void insertObjectSorted(T* object, const std::function<bool(T*, T*)>& compare) {
@ -110,17 +104,71 @@ public:
} }
auto idx = iter - list.begin(); auto idx = iter - list.begin();
this->UntypedObjectModel::insertObject(object, idx); this->insertObject(object, idx);
} }
void removeObject(const T* object) { this->UntypedObjectModel::removeObject(object); } bool removeObject(const T* object) {
auto index = this->mValuesList.indexOf(object);
if (index == -1) return false;
this->removeAt(index);
return true;
}
void removeAt(qsizetype index) {
auto* object = this->mValuesList.at(index);
emit this->objectRemovedPre(object, index);
auto intIndex = static_cast<qint32>(index);
this->beginRemoveRows(QModelIndex(), intIndex, intIndex);
this->mValuesList.removeAt(index);
this->endRemoveRows();
emit this->valuesChanged();
emit this->objectRemovedPost(object, index);
}
// Assumes only one instance of a specific value // Assumes only one instance of a specific value
void diffUpdate(const QVector<T*>& newValues) { void diffUpdate(const QList<T*>& newValues) {
this->UntypedObjectModel::diffUpdate(*std::bit_cast<const QVector<QObject*>*>(&newValues)); for (qsizetype i = 0; i < this->mValuesList.length();) {
if (newValues.contains(this->mValuesList.at(i))) i++;
else this->removeAt(i);
}
qsizetype oi = 0;
for (auto* object: newValues) {
if (this->mValuesList.length() == oi || this->mValuesList.at(oi) != object) {
this->insertObject(object, oi);
}
oi++;
}
} }
static ObjectModel<T>* emptyInstance() { static ObjectModel<T>* emptyInstance() {
return static_cast<ObjectModel<T>*>(UntypedObjectModel::emptyInstance()); return static_cast<ObjectModel<T>*>(UntypedObjectModel::emptyInstance());
} }
[[nodiscard]] qint32 rowCount(const QModelIndex& parent) const override {
if (parent != QModelIndex()) return 0;
return static_cast<qint32>(this->mValuesList.length());
}
[[nodiscard]] QVariant data(const QModelIndex& index, qint32 role) const override {
if (role != Qt::UserRole) return QVariant();
// Values must be QObject derived, but we can't assert that here without breaking forward decls,
// so no static_cast.
return QVariant::fromValue(reinterpret_cast<QObject*>(this->mValuesList.at(index.row())));
}
qsizetype indexOf(QObject* object) const override {
return this->mValuesList.indexOf(reinterpret_cast<T*>(object));
}
[[nodiscard]] QList<QObject*> values() override {
return *reinterpret_cast<QList<QObject*>*>(&this->mValuesList);
}
private:
QList<T*> mValuesList;
}; };

View file

@ -21,7 +21,6 @@ headers = [
"model.hpp", "model.hpp",
"elapsedtimer.hpp", "elapsedtimer.hpp",
"desktopentry.hpp", "desktopentry.hpp",
"objectrepeater.hpp",
"qsmenu.hpp", "qsmenu.hpp",
"retainable.hpp", "retainable.hpp",
"popupanchor.hpp", "popupanchor.hpp",

View file

@ -1,190 +0,0 @@
#include "objectrepeater.hpp"
#include <utility>
#include <qabstractitemmodel.h>
#include <qcontainerfwd.h>
#include <qhash.h>
#include <qlogging.h>
#include <qobject.h>
#include <qqmlcomponent.h>
#include <qqmlcontext.h>
#include <qqmlengine.h>
#include <qqmllist.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qvariant.h>
QVariant ObjectRepeater::model() const { return this->mModel; }
void ObjectRepeater::setModel(QVariant model) {
if (model == this->mModel) return;
if (this->itemModel != nullptr) {
QObject::disconnect(this->itemModel, nullptr, this, nullptr);
}
this->mModel = std::move(model);
emit this->modelChanged();
this->reloadElements();
}
void ObjectRepeater::onModelDestroyed() {
this->mModel.clear();
this->itemModel = nullptr;
emit this->modelChanged();
this->reloadElements();
}
QQmlComponent* ObjectRepeater::delegate() const { return this->mDelegate; }
void ObjectRepeater::setDelegate(QQmlComponent* delegate) {
if (delegate == this->mDelegate) return;
if (this->mDelegate != nullptr) {
QObject::disconnect(this->mDelegate, nullptr, this, nullptr);
}
this->mDelegate = delegate;
if (delegate != nullptr) {
QObject::connect(
this->mDelegate,
&QObject::destroyed,
this,
&ObjectRepeater::onDelegateDestroyed
);
}
emit this->delegateChanged();
this->reloadElements();
}
void ObjectRepeater::onDelegateDestroyed() {
this->mDelegate = nullptr;
emit this->delegateChanged();
this->reloadElements();
}
void ObjectRepeater::reloadElements() {
for (auto i = this->valuesList.length() - 1; i >= 0; i--) {
this->removeComponent(i);
}
if (this->mDelegate == nullptr || !this->mModel.isValid()) return;
if (this->mModel.canConvert<QAbstractItemModel*>()) {
auto* model = this->mModel.value<QAbstractItemModel*>();
this->itemModel = model;
this->insertModelElements(model, 0, model->rowCount() - 1); // -1 is fine
// clang-format off
QObject::connect(model, &QObject::destroyed, this, &ObjectRepeater::onModelDestroyed);
QObject::connect(model, &QAbstractItemModel::rowsInserted, this, &ObjectRepeater::onModelRowsInserted);
QObject::connect(model, &QAbstractItemModel::rowsRemoved, this, &ObjectRepeater::onModelRowsRemoved);
QObject::connect(model, &QAbstractItemModel::rowsMoved, this, &ObjectRepeater::onModelRowsMoved);
QObject::connect(model, &QAbstractItemModel::modelAboutToBeReset, this, &ObjectRepeater::onModelAboutToBeReset);
// clang-format on
} else if (this->mModel.canConvert<QQmlListReference>()) {
auto values = this->mModel.value<QQmlListReference>();
auto len = values.count();
for (auto i = 0; i != len; i++) {
this->insertComponent(i, {{"modelData", QVariant::fromValue(values.at(i))}});
}
} else if (this->mModel.canConvert<QVector<QVariant>>()) {
auto values = this->mModel.value<QVector<QVariant>>();
for (auto& value: values) {
this->insertComponent(this->valuesList.length(), {{"modelData", value}});
}
} else {
qCritical() << this
<< "Cannot create components as the model is not compatible:" << this->mModel;
}
}
void ObjectRepeater::insertModelElements(QAbstractItemModel* model, int first, int last) {
auto roles = model->roleNames();
auto roleDataVec = QVector<QModelRoleData>();
for (auto id: roles.keys()) {
roleDataVec.push_back(QModelRoleData(id));
}
auto values = QModelRoleDataSpan(roleDataVec);
auto props = QVariantMap();
for (auto i = first; i != last + 1; i++) {
auto index = model->index(i, 0);
model->multiData(index, values);
for (auto [id, name]: roles.asKeyValueRange()) {
props.insert(name, *values.dataForRole(id));
}
this->insertComponent(i, props);
props.clear();
}
}
void ObjectRepeater::onModelRowsInserted(const QModelIndex& parent, int first, int last) {
if (parent != QModelIndex()) return;
this->insertModelElements(this->itemModel, first, last);
}
void ObjectRepeater::onModelRowsRemoved(const QModelIndex& parent, int first, int last) {
if (parent != QModelIndex()) return;
for (auto i = last; i != first - 1; i--) {
this->removeComponent(i);
}
}
void ObjectRepeater::onModelRowsMoved(
const QModelIndex& sourceParent,
int sourceStart,
int sourceEnd,
const QModelIndex& destParent,
int destStart
) {
auto hasSource = sourceParent != QModelIndex();
auto hasDest = destParent != QModelIndex();
if (!hasSource && !hasDest) return;
if (hasSource) {
this->onModelRowsRemoved(sourceParent, sourceStart, sourceEnd);
}
if (hasDest) {
this->onModelRowsInserted(destParent, destStart, destStart + (sourceEnd - sourceStart));
}
}
void ObjectRepeater::onModelAboutToBeReset() {
auto last = static_cast<int>(this->valuesList.length() - 1);
this->onModelRowsRemoved(QModelIndex(), 0, last); // -1 is fine
}
void ObjectRepeater::insertComponent(qsizetype index, const QVariantMap& properties) {
auto* context = QQmlEngine::contextForObject(this);
auto* instance = this->mDelegate->createWithInitialProperties(properties, context);
if (instance == nullptr) {
qWarning().noquote() << this->mDelegate->errorString();
qWarning() << this << "failed to create object for model data" << properties;
} else {
QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership);
instance->setParent(this);
}
this->insertObject(instance, index);
}
void ObjectRepeater::removeComponent(qsizetype index) {
auto* instance = this->valuesList.at(index);
this->removeAt(index);
delete instance;
}

View file

@ -1,85 +0,0 @@
#pragma once
#include <qabstractitemmodel.h>
#include <qobject.h>
#include <qqmlcomponent.h>
#include <qqmlintegration.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include <qvariant.h>
#include "model.hpp"
///! A Repeater / for loop / map for non Item derived objects.
/// > [!ERROR] Removed in favor of @@QtQml.Models.Instantiator
///
/// The ObjectRepeater creates instances of the provided delegate for every entry in the
/// given model, similarly to a @@QtQuick.Repeater but for non visual types.
class ObjectRepeater: public ObjectModel<QObject> {
Q_OBJECT;
/// The model providing data to the ObjectRepeater.
///
/// Currently accepted model types are `list<T>` lists, javascript arrays,
/// and [QAbstractListModel] derived models, though only one column will be repeated
/// from the latter.
///
/// Note: @@ObjectModel is a [QAbstractListModel] with a single column.
///
/// [QAbstractListModel]: https://doc.qt.io/qt-6/qabstractlistmodel.html
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged);
/// The delegate component to repeat.
///
/// The delegate is given the same properties as in a Repeater, except `index` which
/// is not currently implemented.
///
/// If the model is a `list<T>` or javascript array, a `modelData` property will be
/// exposed containing the entry from the model. If the model is a [QAbstractListModel],
/// the roles from the model will be exposed.
///
/// Note: @@ObjectModel has a single role named `modelData` for compatibility with normal lists.
///
/// [QAbstractListModel]: https://doc.qt.io/qt-6/qabstractlistmodel.html
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged);
Q_CLASSINFO("DefaultProperty", "delegate");
QML_ELEMENT;
QML_UNCREATABLE("ObjectRepeater has been removed in favor of QtQml.Models.Instantiator.");
public:
explicit ObjectRepeater(QObject* parent = nullptr): ObjectModel(parent) {}
[[nodiscard]] QVariant model() const;
void setModel(QVariant model);
[[nodiscard]] QQmlComponent* delegate() const;
void setDelegate(QQmlComponent* delegate);
signals:
void modelChanged();
void delegateChanged();
private slots:
void onDelegateDestroyed();
void onModelDestroyed();
void onModelRowsInserted(const QModelIndex& parent, int first, int last);
void onModelRowsRemoved(const QModelIndex& parent, int first, int last);
void onModelRowsMoved(
const QModelIndex& sourceParent,
int sourceStart,
int sourceEnd,
const QModelIndex& destParent,
int destStart
);
void onModelAboutToBeReset();
private:
void reloadElements();
void insertModelElements(QAbstractItemModel* model, int first, int last);
void insertComponent(qsizetype index, const QVariantMap& properties);
void removeComponent(qsizetype index);
QVariant mModel;
QAbstractItemModel* itemModel = nullptr;
QQmlComponent* mDelegate = nullptr;
};

View file

@ -27,12 +27,19 @@ QsPaths* QsPaths::instance() {
return instance; return instance;
} }
void QsPaths::init(QString shellId, QString pathId, QString dataOverride, QString stateOverride) { void QsPaths::init(
QString shellId,
QString pathId,
QString dataOverride,
QString stateOverride,
QString cacheOverride
) {
auto* instance = QsPaths::instance(); auto* instance = QsPaths::instance();
instance->shellId = std::move(shellId); instance->shellId = std::move(shellId);
instance->pathId = std::move(pathId); instance->pathId = std::move(pathId);
instance->shellDataOverride = std::move(dataOverride); instance->shellDataOverride = std::move(dataOverride);
instance->shellStateOverride = std::move(stateOverride); instance->shellStateOverride = std::move(stateOverride);
instance->shellCacheOverride = std::move(cacheOverride);
} }
QDir QsPaths::crashDir(const QString& id) { QDir QsPaths::crashDir(const QString& id) {
@ -57,7 +64,7 @@ QDir* QsPaths::baseRunDir() {
if (this->baseRunState == DirState::Unknown) { if (this->baseRunState == DirState::Unknown) {
auto runtimeDir = qEnvironmentVariable("XDG_RUNTIME_DIR"); auto runtimeDir = qEnvironmentVariable("XDG_RUNTIME_DIR");
if (runtimeDir.isEmpty()) { if (runtimeDir.isEmpty()) {
runtimeDir = QString("/run/user/$1").arg(getuid()); runtimeDir = QString("/run/user/%1").arg(getuid());
qCInfo(logPaths) << "XDG_RUNTIME_DIR was not set, defaulting to" << runtimeDir; qCInfo(logPaths) << "XDG_RUNTIME_DIR was not set, defaulting to" << runtimeDir;
} }
@ -168,7 +175,8 @@ void QsPaths::linkRunDir() {
auto* shellDir = this->shellRunDir(); auto* shellDir = this->shellRunDir();
if (!shellDir) { if (!shellDir) {
qCCritical(logPaths qCCritical(
logPaths
) << "Could not create by-id symlink as the shell runtime path could not be created."; ) << "Could not create by-id symlink as the shell runtime path could not be created.";
} else { } else {
auto shellPath = shellDir->filePath(runDir->dirName()); auto shellPath = shellDir->filePath(runDir->dirName());
@ -316,9 +324,16 @@ QDir QsPaths::shellStateDir() {
QDir QsPaths::shellCacheDir() { QDir QsPaths::shellCacheDir() {
if (this->shellCacheState == DirState::Unknown) { if (this->shellCacheState == DirState::Unknown) {
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); QDir dir;
if (this->shellCacheOverride.isEmpty()) {
dir = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
dir = QDir(dir.filePath("by-shell")); dir = QDir(dir.filePath("by-shell"));
dir = QDir(dir.filePath(this->shellId)); dir = QDir(dir.filePath(this->shellId));
} else {
auto basedir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
dir = QDir(this->shellCacheOverride.replace("$BASE", basedir));
}
this->mShellCacheDir = dir; this->mShellCacheDir = dir;
qCDebug(logPaths) << "Initialized cache path:" << dir.path(); qCDebug(logPaths) << "Initialized cache path:" << dir.path();
@ -346,7 +361,7 @@ void QsPaths::createLock() {
return; return;
} }
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,
@ -364,7 +379,8 @@ void QsPaths::createLock() {
qCDebug(logPaths) << "Created instance lock at" << path; qCDebug(logPaths) << "Created instance lock at" << path;
} }
} else { } else {
qCCritical(logPaths qCCritical(
logPaths
) << "Could not create instance lock, as the instance runtime directory could not be created."; ) << "Could not create instance lock, as the instance runtime directory could not be created.";
} }
} }
@ -373,7 +389,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
auto file = QFile(QDir(path).filePath("instance.lock")); auto file = QFile(QDir(path).filePath("instance.lock"));
if (!file.open(QFile::ReadOnly)) return false; if (!file.open(QFile::ReadOnly)) return false;
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, .l_whence = SEEK_SET,
.l_start = 0, .l_start = 0,
@ -397,7 +413,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
} }
QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>> QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>>
QsPaths::collectInstances(const QString& path) { QsPaths::collectInstances(const QString& path, const QString& display) {
qCDebug(logPaths) << "Collecting instances from" << path; qCDebug(logPaths) << "Collecting instances from" << path;
auto liveInstances = QVector<InstanceLockInfo>(); auto liveInstances = QVector<InstanceLockInfo>();
auto deadInstances = QVector<InstanceLockInfo>(); auto deadInstances = QVector<InstanceLockInfo>();
@ -411,6 +427,11 @@ QsPaths::collectInstances(const QString& path) {
qCDebug(logPaths).nospace() << "Found instance " << info.instance.instanceId << " (pid " qCDebug(logPaths).nospace() << "Found instance " << info.instance.instanceId << " (pid "
<< info.pid << ") at " << path; << info.pid << ") at " << path;
if (!display.isEmpty() && info.instance.display != display) {
qCDebug(logPaths) << "Skipped instance with mismatched display at" << path;
continue;
}
if (info.pid == -1) { if (info.pid == -1) {
deadInstances.push_back(info); deadInstances.push_back(info);
} else { } else {

View file

@ -17,14 +17,20 @@ QDataStream& operator>>(QDataStream& stream, InstanceLockInfo& info);
class QsPaths { class QsPaths {
public: public:
static QsPaths* instance(); static QsPaths* instance();
static void init(QString shellId, QString pathId, QString dataOverride, QString stateOverride); static void init(
QString shellId,
QString pathId,
QString dataOverride,
QString stateOverride,
QString cacheOverride
);
static QDir crashDir(const QString& id); static QDir crashDir(const QString& id);
static QString basePath(const QString& id); static QString basePath(const QString& id);
static QString ipcPath(const QString& id); static QString ipcPath(const QString& id);
static bool static bool
checkLock(const QString& path, InstanceLockInfo* info = nullptr, bool allowDead = false); checkLock(const QString& path, InstanceLockInfo* info = nullptr, bool allowDead = false);
static QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>> static QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>>
collectInstances(const QString& path); collectInstances(const QString& path, const QString& display);
QDir* baseRunDir(); QDir* baseRunDir();
QDir* shellRunDir(); QDir* shellRunDir();
@ -65,4 +71,5 @@ private:
QString shellDataOverride; QString shellDataOverride;
QString shellStateOverride; QString shellStateOverride;
QString shellCacheOverride;
}; };

View file

@ -18,7 +18,6 @@
#include <qwindow.h> #include <qwindow.h>
#include "../window/proxywindow.hpp" #include "../window/proxywindow.hpp"
#include "../window/windowinterface.hpp"
#include "iconprovider.hpp" #include "iconprovider.hpp"
#include "model.hpp" #include "model.hpp"
#include "platformmenu_p.hpp" #include "platformmenu_p.hpp"
@ -91,10 +90,8 @@ bool PlatformMenuEntry::display(QObject* parentWindow, int relativeX, int relati
} else if (parentWindow == nullptr) { } else if (parentWindow == nullptr) {
qCritical() << "Cannot display PlatformMenuEntry with null parent window."; qCritical() << "Cannot display PlatformMenuEntry with null parent window.";
return false; return false;
} else if (auto* proxy = qobject_cast<ProxyWindowBase*>(parentWindow)) { } else if (auto* proxy = ProxyWindowBase::forObject(parentWindow)) {
window = proxy->backingWindow(); window = proxy->backingWindow();
} else if (auto* interface = qobject_cast<WindowInterface*>(parentWindow)) {
window = interface->proxyWindow()->backingWindow();
} else { } else {
qCritical() << "PlatformMenuEntry.display() must be called with a window."; qCritical() << "PlatformMenuEntry.display() must be called with a window.";
return false; return false;

View file

@ -9,6 +9,18 @@ static QVector<QsEnginePlugin*> plugins; // NOLINT
void QsEnginePlugin::registerPlugin(QsEnginePlugin& plugin) { plugins.push_back(&plugin); } void QsEnginePlugin::registerPlugin(QsEnginePlugin& plugin) { plugins.push_back(&plugin); }
void QsEnginePlugin::preinitPluginsOnly() {
plugins.removeIf([](QsEnginePlugin* plugin) { return !plugin->applies(); });
std::ranges::sort(plugins, [](QsEnginePlugin* a, QsEnginePlugin* b) {
return b->dependencies().contains(a->name());
});
for (QsEnginePlugin* plugin: plugins) {
plugin->preinit();
}
}
void QsEnginePlugin::initPlugins() { void QsEnginePlugin::initPlugins() {
plugins.removeIf([](QsEnginePlugin* plugin) { return !plugin->applies(); }); plugins.removeIf([](QsEnginePlugin* plugin) { return !plugin->applies(); });
@ -16,6 +28,10 @@ void QsEnginePlugin::initPlugins() {
return b->dependencies().contains(a->name()); return b->dependencies().contains(a->name());
}); });
for (QsEnginePlugin* plugin: plugins) {
plugin->preinit();
}
for (QsEnginePlugin* plugin: plugins) { for (QsEnginePlugin* plugin: plugins) {
plugin->init(); plugin->init();
} }

View file

@ -18,12 +18,14 @@ public:
virtual QString name() { return QString(); } virtual QString name() { return QString(); }
virtual QList<QString> dependencies() { return {}; } virtual QList<QString> dependencies() { return {}; }
virtual bool applies() { return true; } virtual bool applies() { return true; }
virtual void preinit() {}
virtual void init() {} virtual void init() {}
virtual void registerTypes() {} virtual void registerTypes() {}
virtual void constructGeneration(EngineGeneration& /*unused*/) {} // NOLINT virtual void constructGeneration(EngineGeneration& /*unused*/) {} // NOLINT
virtual void onReload() {} virtual void onReload() {}
static void registerPlugin(QsEnginePlugin& plugin); static void registerPlugin(QsEnginePlugin& plugin);
static void preinitPluginsOnly();
static void initPlugins(); static void initPlugins();
static void runConstructGeneration(EngineGeneration& generation); static void runConstructGeneration(EngineGeneration& generation);
static void runOnReload(); static void runOnReload();

View file

@ -11,7 +11,6 @@
#include <qwindow.h> #include <qwindow.h>
#include "../window/proxywindow.hpp" #include "../window/proxywindow.hpp"
#include "../window/windowinterface.hpp"
#include "types.hpp" #include "types.hpp"
bool PopupAnchorState::operator==(const PopupAnchorState& other) const { bool PopupAnchorState::operator==(const PopupAnchorState& other) const {
@ -28,7 +27,7 @@ void PopupAnchor::markClean() { this->lastState = this->state; }
void PopupAnchor::markDirty() { this->lastState.reset(); } void PopupAnchor::markDirty() { this->lastState.reset(); }
QWindow* PopupAnchor::backingWindow() const { QWindow* PopupAnchor::backingWindow() const {
return this->mProxyWindow ? this->mProxyWindow->backingWindow() : nullptr; return this->bProxyWindow ? this->bProxyWindow->backingWindow() : nullptr;
} }
void PopupAnchor::setWindowInternal(QObject* window) { void PopupAnchor::setWindowInternal(QObject* window) {
@ -36,14 +35,12 @@ void PopupAnchor::setWindowInternal(QObject* window) {
if (this->mWindow) { if (this->mWindow) {
QObject::disconnect(this->mWindow, nullptr, this, nullptr); QObject::disconnect(this->mWindow, nullptr, this, nullptr);
QObject::disconnect(this->mProxyWindow, nullptr, this, nullptr); QObject::disconnect(this->bProxyWindow, nullptr, this, nullptr);
} }
if (window) { if (window) {
if (auto* proxy = qobject_cast<ProxyWindowBase*>(window)) { if (auto* proxy = ProxyWindowBase::forObject(window)) {
this->mProxyWindow = proxy; this->bProxyWindow = proxy;
} else if (auto* interface = qobject_cast<WindowInterface*>(window)) {
this->mProxyWindow = interface->proxyWindow();
} else { } else {
qWarning() << "Tried to set popup anchor window to" << window qWarning() << "Tried to set popup anchor window to" << window
<< "which is not a quickshell window."; << "which is not a quickshell window.";
@ -55,7 +52,7 @@ void PopupAnchor::setWindowInternal(QObject* window) {
QObject::connect(this->mWindow, &QObject::destroyed, this, &PopupAnchor::onWindowDestroyed); QObject::connect(this->mWindow, &QObject::destroyed, this, &PopupAnchor::onWindowDestroyed);
QObject::connect( QObject::connect(
this->mProxyWindow, this->bProxyWindow,
&ProxyWindowBase::backerVisibilityChanged, &ProxyWindowBase::backerVisibilityChanged,
this, this,
&PopupAnchor::backingWindowVisibilityChanged &PopupAnchor::backingWindowVisibilityChanged
@ -70,7 +67,7 @@ void PopupAnchor::setWindowInternal(QObject* window) {
setnull: setnull:
if (this->mWindow) { if (this->mWindow) {
this->mWindow = nullptr; this->mWindow = nullptr;
this->mProxyWindow = nullptr; this->bProxyWindow = nullptr;
emit this->windowChanged(); emit this->windowChanged();
emit this->backingWindowVisibilityChanged(); emit this->backingWindowVisibilityChanged();
@ -100,7 +97,7 @@ void PopupAnchor::setItem(QQuickItem* item) {
void PopupAnchor::onWindowDestroyed() { void PopupAnchor::onWindowDestroyed() {
this->mWindow = nullptr; this->mWindow = nullptr;
this->mProxyWindow = nullptr; this->bProxyWindow = nullptr;
emit this->windowChanged(); emit this->windowChanged();
emit this->backingWindowVisibilityChanged(); emit this->backingWindowVisibilityChanged();
} }
@ -186,11 +183,11 @@ void PopupAnchor::updatePlacement(const QPoint& anchorpoint, const QSize& size)
} }
void PopupAnchor::updateAnchor() { void PopupAnchor::updateAnchor() {
if (this->mItem && this->mProxyWindow) { if (this->mItem && this->bProxyWindow) {
auto baseRect = auto baseRect =
this->mUserRect.isEmpty() ? this->mItem->boundingRect() : this->mUserRect.qrect(); this->mUserRect.isEmpty() ? this->mItem->boundingRect() : this->mUserRect.qrect();
auto rect = this->mProxyWindow->contentItem()->mapFromItem( auto rect = this->bProxyWindow->contentItem()->mapFromItem(
this->mItem, this->mItem,
baseRect.marginsRemoved(this->mMargins.qmargins()) baseRect.marginsRemoved(this->mMargins.qmargins())
); );

View file

@ -6,6 +6,7 @@
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h> #include <qobject.h>
#include <qpoint.h> #include <qpoint.h>
#include <qproperty.h>
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qquickitem.h> #include <qquickitem.h>
#include <qsize.h> #include <qsize.h>
@ -139,7 +140,9 @@ public:
void markDirty(); void markDirty();
[[nodiscard]] QObject* window() const { return this->mWindow; } [[nodiscard]] QObject* window() const { return this->mWindow; }
[[nodiscard]] ProxyWindowBase* proxyWindow() const { return this->mProxyWindow; } [[nodiscard]] QBindable<ProxyWindowBase*> bindableProxyWindow() const {
return &this->bProxyWindow;
}
[[nodiscard]] QWindow* backingWindow() const; [[nodiscard]] QWindow* backingWindow() const;
void setWindowInternal(QObject* window); void setWindowInternal(QObject* window);
void setWindow(QObject* window); void setWindow(QObject* window);
@ -193,11 +196,12 @@ private slots:
private: private:
QObject* mWindow = nullptr; QObject* mWindow = nullptr;
QQuickItem* mItem = nullptr; QQuickItem* mItem = nullptr;
ProxyWindowBase* mProxyWindow = nullptr;
PopupAnchorState state; PopupAnchorState state;
Box mUserRect; Box mUserRect;
Margins mMargins; Margins mMargins;
std::optional<PopupAnchorState> lastState; std::optional<PopupAnchorState> lastState;
Q_OBJECT_BINDABLE_PROPERTY(PopupAnchor, ProxyWindowBase*, bProxyWindow);
}; };
class PopupPositioner { class PopupPositioner {

View file

@ -26,9 +26,11 @@
#include "../io/processcore.hpp" #include "../io/processcore.hpp"
#include "generation.hpp" #include "generation.hpp"
#include "iconimageprovider.hpp" #include "iconimageprovider.hpp"
#include "instanceinfo.hpp"
#include "paths.hpp" #include "paths.hpp"
#include "qmlscreen.hpp" #include "qmlscreen.hpp"
#include "rootwrapper.hpp" #include "rootwrapper.hpp"
#include "scanenv.hpp"
QuickshellSettings::QuickshellSettings() { QuickshellSettings::QuickshellSettings() {
QObject::connect( QObject::connect(
@ -59,7 +61,9 @@ void QuickshellSettings::setWorkingDirectory(QString workingDirectory) { // NOLI
emit this->workingDirectoryChanged(); emit this->workingDirectoryChanged();
} }
bool QuickshellSettings::watchFiles() const { return this->mWatchFiles; } bool QuickshellSettings::watchFiles() const {
return this->mWatchFiles && qEnvironmentVariableIsEmpty("QS_DISABLE_FILE_WATCHER");
}
void QuickshellSettings::setWatchFiles(bool watchFiles) { void QuickshellSettings::setWatchFiles(bool watchFiles) {
if (watchFiles == this->mWatchFiles) return; if (watchFiles == this->mWatchFiles) return;
@ -150,6 +154,22 @@ qint32 QuickshellGlobal::processId() const { // NOLINT
return getpid(); return getpid();
} }
QString QuickshellGlobal::instanceId() const { // NOLINT
return InstanceInfo::CURRENT.instanceId;
}
QString QuickshellGlobal::shellId() const { // NOLINT
return InstanceInfo::CURRENT.shellId;
}
QString QuickshellGlobal::appId() const { // NOLINT
return InstanceInfo::CURRENT.appId;
}
QDateTime QuickshellGlobal::launchTime() const { // NOLINT
return InstanceInfo::CURRENT.launchTime;
}
qsizetype QuickshellGlobal::screensCount(QQmlListProperty<QuickshellScreenInfo>* /*unused*/) { qsizetype QuickshellGlobal::screensCount(QQmlListProperty<QuickshellScreenInfo>* /*unused*/) {
return QuickshellTracked::instance()->screens.size(); return QuickshellTracked::instance()->screens.size();
} }
@ -313,6 +333,16 @@ QString QuickshellGlobal::iconPath(const QString& icon, const QString& fallback)
return IconImageProvider::requestString(icon, "", fallback); return IconImageProvider::requestString(icon, "", fallback);
} }
bool QuickshellGlobal::hasThemeIcon(const QString& icon) { return QIcon::hasThemeIcon(icon); }
bool QuickshellGlobal::hasVersion(qint32 major, qint32 minor, const QStringList& features) {
return qs::scan::env::PreprocEnv::hasVersion(major, minor, features);
}
bool QuickshellGlobal::hasVersion(qint32 major, qint32 minor) {
return QuickshellGlobal::hasVersion(major, minor, QStringList());
}
QuickshellGlobal* QuickshellGlobal::create(QQmlEngine* engine, QJSEngine* /*unused*/) { QuickshellGlobal* QuickshellGlobal::create(QQmlEngine* engine, QJSEngine* /*unused*/) {
auto* qsg = new QuickshellGlobal(); auto* qsg = new QuickshellGlobal();
auto* generation = EngineGeneration::findEngineGeneration(engine); auto* generation = EngineGeneration::findEngineGeneration(engine);

View file

@ -17,6 +17,7 @@
#include "../io/processcore.hpp" #include "../io/processcore.hpp"
#include "doc.hpp" #include "doc.hpp"
#include "instanceinfo.hpp"
#include "qmlscreen.hpp" #include "qmlscreen.hpp"
///! Accessor for some options under the Quickshell type. ///! Accessor for some options under the Quickshell type.
@ -83,6 +84,21 @@ class QuickshellGlobal: public QObject {
// clang-format off // clang-format off
/// Quickshell's process id. /// Quickshell's process id.
Q_PROPERTY(qint32 processId READ processId CONSTANT); Q_PROPERTY(qint32 processId READ processId CONSTANT);
/// A unique identifier for this Quickshell instance
Q_PROPERTY(QString instanceId READ instanceId CONSTANT)
/// The shell ID, used to differentiate between different shell configurations.
///
/// Defaults to a stable value derived from the config path.
/// Can be overridden with `//@ pragma ShellId <id>` in the root qml file.
Q_PROPERTY(QString shellId READ shellId CONSTANT)
/// The desktop application ID.
///
/// Defaults to `org.quickshell`.
/// Can be overridden with `//@ pragma AppId <id>` in the root qml file
/// or the `QS_APP_ID` environment variable.
Q_PROPERTY(QString appId READ appId CONSTANT)
/// The time at which this Quickshell instance was launched.
Q_PROPERTY(QDateTime launchTime READ launchTime CONSTANT)
/// All currently connected screens. /// All currently connected screens.
/// ///
/// This property updates as connected screens change. /// This property updates as connected screens change.
@ -127,18 +143,21 @@ class QuickshellGlobal: public QObject {
/// Usually `~/.local/share/quickshell/by-shell/<shell-id>` /// Usually `~/.local/share/quickshell/by-shell/<shell-id>`
/// ///
/// Can be overridden using `//@ pragma DataDir $BASE/path` in the root qml file, where `$BASE` /// Can be overridden using `//@ pragma DataDir $BASE/path` in the root qml file, where `$BASE`
/// corrosponds to `$XDG_DATA_HOME` (usually `~/.local/share`). /// corresponds to `$XDG_DATA_HOME` (usually `~/.local/share`).
Q_PROPERTY(QString dataDir READ dataDir CONSTANT); Q_PROPERTY(QString dataDir READ dataDir CONSTANT);
/// The per-shell state directory. /// The per-shell state directory.
/// ///
/// Usually `~/.local/state/quickshell/by-shell/<shell-id>` /// Usually `~/.local/state/quickshell/by-shell/<shell-id>`
/// ///
/// Can be overridden using `//@ pragma StateDir $BASE/path` in the root qml file, where `$BASE` /// Can be overridden using `//@ pragma StateDir $BASE/path` in the root qml file, where `$BASE`
/// corrosponds to `$XDG_STATE_HOME` (usually `~/.local/state`). /// corresponds to `$XDG_STATE_HOME` (usually `~/.local/state`).
Q_PROPERTY(QString stateDir READ stateDir CONSTANT); Q_PROPERTY(QString stateDir READ stateDir CONSTANT);
/// The per-shell cache directory. /// The per-shell cache directory.
/// ///
/// Usually `~/.cache/quickshell/by-shell/<shell-id>` /// Usually `~/.cache/quickshell/by-shell/<shell-id>`
///
/// Can be overridden using `//@ pragma CacheDir $BASE/path` in the root qml file, where `$BASE`
/// corresponds to `$XDG_CACHE_HOME` (usually `~/.cache`).
Q_PROPERTY(QString cacheDir READ cacheDir CONSTANT); Q_PROPERTY(QString cacheDir READ cacheDir CONSTANT);
// clang-format on // clang-format on
QML_SINGLETON; QML_SINGLETON;
@ -146,6 +165,10 @@ class QuickshellGlobal: public QObject {
public: public:
[[nodiscard]] qint32 processId() const; [[nodiscard]] qint32 processId() const;
[[nodiscard]] QString instanceId() const;
[[nodiscard]] QString shellId() const;
[[nodiscard]] QString appId() const;
[[nodiscard]] QDateTime launchTime() const;
QQmlListProperty<QuickshellScreenInfo> screens(); QQmlListProperty<QuickshellScreenInfo> screens();
@ -199,6 +222,8 @@ public:
/// Setting the `fallback` parameter of `iconPath` will attempt to load the fallback /// Setting the `fallback` parameter of `iconPath` will attempt to load the fallback
/// icon if the requested one could not be loaded. /// icon if the requested one could not be loaded.
Q_INVOKABLE static QString iconPath(const QString& icon, const QString& fallback); Q_INVOKABLE static QString iconPath(const QString& icon, const QString& fallback);
/// Check if specified icon has an available icon in your icon theme
Q_INVOKABLE static bool hasThemeIcon(const QString& icon);
/// Equivalent to `${Quickshell.configDir}/${path}` /// Equivalent to `${Quickshell.configDir}/${path}`
Q_INVOKABLE [[nodiscard]] QString shellPath(const QString& path) const; Q_INVOKABLE [[nodiscard]] QString shellPath(const QString& path) const;
/// > [!WARNING] Deprecated: Renamed to @@shellPath() for clarity. /// > [!WARNING] Deprecated: Renamed to @@shellPath() for clarity.
@ -214,6 +239,21 @@ public:
/// ///
/// The popup can also be blocked by setting `QS_NO_RELOAD_POPUP=1`. /// The popup can also be blocked by setting `QS_NO_RELOAD_POPUP=1`.
Q_INVOKABLE void inhibitReloadPopup() { this->mInhibitReloadPopup = true; } Q_INVOKABLE void inhibitReloadPopup() { this->mInhibitReloadPopup = true; }
/// Check if Quickshell's version is at least `major.minor` and the listed
/// unreleased features are available. If Quickshell is newer than the given version
/// it is assumed that all unreleased features are present. The unreleased feature list
/// may be omitted.
///
/// > [!NOTE] You can feature gate code blocks using Quickshell's preprocessor which
/// > has the same function available.
/// >
/// > ```qml
/// > //@ if hasVersion(0, 3, ["feature"])
/// > ...
/// > //@ endif
/// > ```
Q_INVOKABLE static bool hasVersion(qint32 major, qint32 minor, const QStringList& features);
Q_INVOKABLE static bool hasVersion(qint32 major, qint32 minor);
void clearReloadPopupInhibit() { this->mInhibitReloadPopup = false; } void clearReloadPopupInhibit() { this->mInhibitReloadPopup = false; }
[[nodiscard]] bool isReloadPopupInhibited() const { return this->mInhibitReloadPopup; } [[nodiscard]] bool isReloadPopupInhibited() const { return this->mInhibitReloadPopup; }

View file

@ -1,4 +1,5 @@
#include "region.hpp" #include "region.hpp"
#include <algorithm>
#include <cmath> #include <cmath>
#include <qobject.h> #include <qobject.h>
@ -18,6 +19,11 @@ PendingRegion::PendingRegion(QObject* parent): QObject(parent) {
QObject::connect(this, &PendingRegion::yChanged, this, &PendingRegion::changed); QObject::connect(this, &PendingRegion::yChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::widthChanged, this, &PendingRegion::changed); QObject::connect(this, &PendingRegion::widthChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::heightChanged, this, &PendingRegion::changed); QObject::connect(this, &PendingRegion::heightChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::radiusChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::topLeftRadiusChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::topRightRadiusChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::bottomLeftRadiusChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::bottomRightRadiusChanged, this, &PendingRegion::changed);
QObject::connect(this, &PendingRegion::childrenChanged, this, &PendingRegion::changed); QObject::connect(this, &PendingRegion::childrenChanged, this, &PendingRegion::changed);
} }
@ -45,6 +51,79 @@ void PendingRegion::onItemDestroyed() { this->mItem = nullptr; }
void PendingRegion::onChildDestroyed() { this->mRegions.removeAll(this->sender()); } void PendingRegion::onChildDestroyed() { this->mRegions.removeAll(this->sender()); }
qint32 PendingRegion::radius() const { return this->mRadius; }
void PendingRegion::setRadius(qint32 radius) {
if (radius == this->mRadius) return;
this->mRadius = radius;
emit this->radiusChanged();
if (!(this->mCornerOverrides & TopLeft)) emit this->topLeftRadiusChanged();
if (!(this->mCornerOverrides & TopRight)) emit this->topRightRadiusChanged();
if (!(this->mCornerOverrides & BottomLeft)) emit this->bottomLeftRadiusChanged();
if (!(this->mCornerOverrides & BottomRight)) emit this->bottomRightRadiusChanged();
}
qint32 PendingRegion::topLeftRadius() const {
return (this->mCornerOverrides & TopLeft) ? this->mTopLeftRadius : this->mRadius;
}
void PendingRegion::setTopLeftRadius(qint32 radius) {
this->mTopLeftRadius = radius;
this->mCornerOverrides |= TopLeft;
emit this->topLeftRadiusChanged();
}
void PendingRegion::resetTopLeftRadius() {
this->mCornerOverrides &= ~TopLeft;
emit this->topLeftRadiusChanged();
}
qint32 PendingRegion::topRightRadius() const {
return (this->mCornerOverrides & TopRight) ? this->mTopRightRadius : this->mRadius;
}
void PendingRegion::setTopRightRadius(qint32 radius) {
this->mTopRightRadius = radius;
this->mCornerOverrides |= TopRight;
emit this->topRightRadiusChanged();
}
void PendingRegion::resetTopRightRadius() {
this->mCornerOverrides &= ~TopRight;
emit this->topRightRadiusChanged();
}
qint32 PendingRegion::bottomLeftRadius() const {
return (this->mCornerOverrides & BottomLeft) ? this->mBottomLeftRadius : this->mRadius;
}
void PendingRegion::setBottomLeftRadius(qint32 radius) {
this->mBottomLeftRadius = radius;
this->mCornerOverrides |= BottomLeft;
emit this->bottomLeftRadiusChanged();
}
void PendingRegion::resetBottomLeftRadius() {
this->mCornerOverrides &= ~BottomLeft;
emit this->bottomLeftRadiusChanged();
}
qint32 PendingRegion::bottomRightRadius() const {
return (this->mCornerOverrides & BottomRight) ? this->mBottomRightRadius : this->mRadius;
}
void PendingRegion::setBottomRightRadius(qint32 radius) {
this->mBottomRightRadius = radius;
this->mCornerOverrides |= BottomRight;
emit this->bottomRightRadiusChanged();
}
void PendingRegion::resetBottomRightRadius() {
this->mCornerOverrides &= ~BottomRight;
emit this->bottomRightRadiusChanged();
}
QQmlListProperty<PendingRegion> PendingRegion::regions() { QQmlListProperty<PendingRegion> PendingRegion::regions() {
return QQmlListProperty<PendingRegion>( return QQmlListProperty<PendingRegion>(
this, this,
@ -90,6 +169,60 @@ QRegion PendingRegion::build() const {
region = QRegion(this->mX, this->mY, this->mWidth, this->mHeight, type); region = QRegion(this->mX, this->mY, this->mWidth, this->mHeight, type);
} }
if (this->mShape == RegionShape::Rect && !region.isEmpty()) {
auto tl = std::max(this->topLeftRadius(), 0);
auto tr = std::max(this->topRightRadius(), 0);
auto bl = std::max(this->bottomLeftRadius(), 0);
auto br = std::max(this->bottomRightRadius(), 0);
if (tl > 0 || tr > 0 || bl > 0 || br > 0) {
auto rect = region.boundingRect();
auto x = rect.x();
auto y = rect.y();
auto w = rect.width();
auto h = rect.height();
// Normalize so adjacent corners don't exceed their shared edge.
// Each corner is scaled by the tightest constraint of its two edges.
auto topScale = tl + tr > w ? static_cast<double>(w) / (tl + tr) : 1.0;
auto bottomScale = bl + br > w ? static_cast<double>(w) / (bl + br) : 1.0;
auto leftScale = tl + bl > h ? static_cast<double>(h) / (tl + bl) : 1.0;
auto rightScale = tr + br > h ? static_cast<double>(h) / (tr + br) : 1.0;
tl = static_cast<qint32>(tl * std::min(topScale, leftScale));
tr = static_cast<qint32>(tr * std::min(topScale, rightScale));
bl = static_cast<qint32>(bl * std::min(bottomScale, leftScale));
br = static_cast<qint32>(br * std::min(bottomScale, rightScale));
// Unlock each corner: subtract (cornerBox - quarterEllipse) from the
// full rect. Each corner only modifies pixels inside its own box,
// so no diagonal overlap is possible.
if (tl > 0) {
auto box = QRegion(x, y, tl, tl);
auto ellipse = QRegion(x, y, tl * 2, tl * 2, QRegion::Ellipse);
region -= box - (ellipse & box);
}
if (tr > 0) {
auto box = QRegion(x + w - tr, y, tr, tr);
auto ellipse = QRegion(x + w - tr * 2, y, tr * 2, tr * 2, QRegion::Ellipse);
region -= box - (ellipse & box);
}
if (bl > 0) {
auto box = QRegion(x, y + h - bl, bl, bl);
auto ellipse = QRegion(x, y + h - bl * 2, bl * 2, bl * 2, QRegion::Ellipse);
region -= box - (ellipse & box);
}
if (br > 0) {
auto box = QRegion(x + w - br, y + h - br, br, br);
auto ellipse = QRegion(x + w - br * 2, y + h - br * 2, br * 2, br * 2, QRegion::Ellipse);
region -= box - (ellipse & box);
}
}
}
for (const auto& childRegion: this->mRegions) { for (const auto& childRegion: this->mRegions) {
region = childRegion->applyTo(region); region = childRegion->applyTo(region);
} }

View file

@ -66,6 +66,29 @@ class PendingRegion: public QObject {
Q_PROPERTY(qint32 width MEMBER mWidth NOTIFY widthChanged); Q_PROPERTY(qint32 width MEMBER mWidth NOTIFY widthChanged);
/// Defaults to 0. Does nothing if @@item is set. /// Defaults to 0. Does nothing if @@item is set.
Q_PROPERTY(qint32 height MEMBER mHeight NOTIFY heightChanged); Q_PROPERTY(qint32 height MEMBER mHeight NOTIFY heightChanged);
// clang-format off
/// Corner radius for rounded rectangles. Only applies when @@shape is `Rect`. Defaults to 0.
///
/// Acts as the default for @@topLeftRadius, @@topRightRadius, @@bottomLeftRadius,
/// and @@bottomRightRadius.
Q_PROPERTY(qint32 radius READ radius WRITE setRadius NOTIFY radiusChanged);
/// Top-left corner radius. Only applies when @@shape is `Rect`.
///
/// Defaults to @@radius, and may be reset by assigning `undefined`.
Q_PROPERTY(qint32 topLeftRadius READ topLeftRadius WRITE setTopLeftRadius RESET resetTopLeftRadius NOTIFY topLeftRadiusChanged);
/// Top-right corner radius. Only applies when @@shape is `Rect`.
///
/// Defaults to @@radius, and may be reset by assigning `undefined`.
Q_PROPERTY(qint32 topRightRadius READ topRightRadius WRITE setTopRightRadius RESET resetTopRightRadius NOTIFY topRightRadiusChanged);
/// Bottom-left corner radius. Only applies when @@shape is `Rect`.
///
/// Defaults to @@radius, and may be reset by assigning `undefined`.
Q_PROPERTY(qint32 bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius RESET resetBottomLeftRadius NOTIFY bottomLeftRadiusChanged);
/// Bottom-right corner radius. Only applies when @@shape is `Rect`.
///
/// Defaults to @@radius, and may be reset by assigning `undefined`.
Q_PROPERTY(qint32 bottomRightRadius READ bottomRightRadius WRITE setBottomRightRadius RESET resetBottomRightRadius NOTIFY bottomRightRadiusChanged);
// clang-format on
/// Regions to apply on top of this region. /// Regions to apply on top of this region.
/// ///
@ -91,6 +114,25 @@ public:
void setItem(QQuickItem* item); void setItem(QQuickItem* item);
[[nodiscard]] qint32 radius() const;
void setRadius(qint32 radius);
[[nodiscard]] qint32 topLeftRadius() const;
void setTopLeftRadius(qint32 radius);
void resetTopLeftRadius();
[[nodiscard]] qint32 topRightRadius() const;
void setTopRightRadius(qint32 radius);
void resetTopRightRadius();
[[nodiscard]] qint32 bottomLeftRadius() const;
void setBottomLeftRadius(qint32 radius);
void resetBottomLeftRadius();
[[nodiscard]] qint32 bottomRightRadius() const;
void setBottomRightRadius(qint32 radius);
void resetBottomRightRadius();
QQmlListProperty<PendingRegion> regions(); QQmlListProperty<PendingRegion> regions();
[[nodiscard]] bool empty() const; [[nodiscard]] bool empty() const;
@ -109,6 +151,11 @@ signals:
void yChanged(); void yChanged();
void widthChanged(); void widthChanged();
void heightChanged(); void heightChanged();
void radiusChanged();
void topLeftRadiusChanged();
void topRightRadiusChanged();
void bottomLeftRadiusChanged();
void bottomRightRadiusChanged();
void childrenChanged(); void childrenChanged();
/// Triggered when the region's geometry changes. /// Triggered when the region's geometry changes.
@ -130,12 +177,25 @@ private:
static void static void
regionsReplace(QQmlListProperty<PendingRegion>* prop, qsizetype i, PendingRegion* region); regionsReplace(QQmlListProperty<PendingRegion>* prop, qsizetype i, PendingRegion* region);
enum CornerOverride : quint8 {
TopLeft = 0b1,
TopRight = 0b10,
BottomLeft = 0b100,
BottomRight = 0b1000,
};
QQuickItem* mItem = nullptr; QQuickItem* mItem = nullptr;
qint32 mX = 0; qint32 mX = 0;
qint32 mY = 0; qint32 mY = 0;
qint32 mWidth = 0; qint32 mWidth = 0;
qint32 mHeight = 0; qint32 mHeight = 0;
qint32 mRadius = 0;
qint32 mTopLeftRadius = 0;
qint32 mTopRightRadius = 0;
qint32 mBottomLeftRadius = 0;
qint32 mBottomRightRadius = 0;
quint8 mCornerOverrides = 0;
QList<PendingRegion*> mRegions; QList<PendingRegion*> mRegions;
}; };

View file

@ -63,9 +63,6 @@ void RootWrapper::reloadGraph(bool hard) {
qs::core::QmlToolingSupport::updateTooling(rootPath, scanner); qs::core::QmlToolingSupport::updateTooling(rootPath, scanner);
this->configDirWatcher.addPath(rootPath.path()); this->configDirWatcher.addPath(rootPath.path());
auto* generation = new EngineGeneration(rootPath, std::move(scanner));
generation->wrapper = this;
// todo: move into EngineGeneration // todo: move into EngineGeneration
if (this->generation != nullptr) { if (this->generation != nullptr) {
qInfo() << "Reloading configuration..."; qInfo() << "Reloading configuration...";
@ -74,6 +71,33 @@ void RootWrapper::reloadGraph(bool hard) {
QDir::setCurrent(this->originalWorkingDirectory); QDir::setCurrent(this->originalWorkingDirectory);
if (!scanner.scanErrors.isEmpty()) {
qCritical() << "Failed to load configuration";
QString errorString = "Failed to load configuration";
for (auto& error: scanner.scanErrors) {
const auto& file = error.file;
QString rel;
if (file.startsWith(rootPath.path() % '/')) {
rel = '@' % file.sliced(rootPath.path().length() + 1);
} else {
rel = file;
}
auto msg = " error in " % rel % '[' % QString::number(error.line) % ":0]: " % error.message;
errorString += '\n' % msg;
qCritical().noquote() << msg;
}
if (this->generation != nullptr && this->generation->qsgInstance != nullptr) {
emit this->generation->qsgInstance->reloadFailed(errorString);
}
return;
}
auto* generation = new EngineGeneration(rootPath, std::move(scanner));
generation->wrapper = this;
QUrl url; QUrl url;
url.setScheme("qs"); url.setScheme("qs");
url.setPath("@/qs/" % rootFile.fileName()); url.setPath("@/qs/" % rootFile.fileName());

View file

@ -1,9 +1,12 @@
#include "scan.hpp" #include "scan.hpp"
#include <cmath> #include <cmath>
#include <utility>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qcryptographichash.h>
#include <qdir.h> #include <qdir.h>
#include <qfileinfo.h> #include <qfileinfo.h>
#include <qjsengine.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsondocument.h> #include <qjsondocument.h>
#include <qjsonobject.h> #include <qjsonobject.h>
@ -12,19 +15,39 @@
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qpair.h> #include <qpair.h>
#include <qstring.h> #include <qstring.h>
#include <qstringliteral.h>
#include <qtextstream.h> #include <qtextstream.h>
#include "logcat.hpp" #include "logcat.hpp"
#include "scanenv.hpp"
QS_LOGGING_CATEGORY(logQmlScanner, "quickshell.qmlscanner", QtWarningMsg); QS_LOGGING_CATEGORY(logQmlScanner, "quickshell.qmlscanner", QtWarningMsg);
void QmlScanner::scanDir(const QString& path) { bool QmlScanner::readAndHashFile(const QString& path, QByteArray& data) {
if (this->scannedDirs.contains(path)) return; auto file = QFile(path);
this->scannedDirs.push_back(path); if (!file.open(QFile::ReadOnly)) return false;
data = file.readAll();
this->fileHashes.insert(path, QCryptographicHash::hash(data, QCryptographicHash::Md5));
return true;
}
bool QmlScanner::hasFileContentChanged(const QString& path) const {
auto it = this->fileHashes.constFind(path);
if (it == this->fileHashes.constEnd()) return true;
auto file = QFile(path);
if (!file.open(QFile::ReadOnly)) return true;
auto newHash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5);
return newHash != it.value();
}
void QmlScanner::scanDir(const QDir& dir) {
if (this->scannedDirs.contains(dir)) return;
this->scannedDirs.push_back(dir);
const auto& path = dir.path();
qCDebug(logQmlScanner) << "Scanning directory" << path; qCDebug(logQmlScanner) << "Scanning directory" << path;
auto dir = QDir(path);
struct Entry { struct Entry {
QString name; QString name;
@ -37,7 +60,8 @@ void QmlScanner::scanDir(const QString& path) {
for (auto& name: dir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { for (auto& name: dir.entryList(QDir::Files | QDir::NoDotAndDotDot)) {
if (name == "qmldir") { if (name == "qmldir") {
qCDebug(logQmlScanner qCDebug(
logQmlScanner
) << "Found qmldir file, qmldir synthesization will be disabled for directory" ) << "Found qmldir file, qmldir synthesization will be disabled for directory"
<< path; << path;
seenQmldir = true; seenQmldir = true;
@ -105,21 +129,36 @@ bool QmlScanner::scanQmlFile(const QString& path, bool& singleton, bool& interna
qCDebug(logQmlScanner) << "Scanning qml file" << path; qCDebug(logQmlScanner) << "Scanning qml file" << path;
auto file = QFile(path); QByteArray fileData;
if (!file.open(QFile::ReadOnly | QFile::Text)) { if (!this->readAndHashFile(path, fileData)) {
qCWarning(logQmlScanner) << "Failed to open file" << path; qCWarning(logQmlScanner) << "Failed to open file" << path;
return false; return false;
} }
auto stream = QTextStream(&file); auto stream = QTextStream(&fileData);
auto imports = QVector<QString>(); auto imports = QVector<QString>();
bool inHeader = true;
auto ifScopes = QVector<bool>();
bool sourceMasked = false;
int lineNum = 0;
QString overrideText;
bool isOverridden = false;
auto& pragmaEngine = *QmlScanner::preprocEngine();
auto postError = [&, this](QString error) {
this->scanErrors.append({.file = path, .message = std::move(error), .line = lineNum});
};
while (!stream.atEnd()) { while (!stream.atEnd()) {
auto line = stream.readLine().trimmed(); ++lineNum;
bool hideMask = false;
auto rawLine = stream.readLine();
auto line = rawLine.trimmed();
if (!sourceMasked && inHeader) {
if (!singleton && line == "pragma Singleton") { if (!singleton && line == "pragma Singleton") {
singleton = true; singleton = true;
} else if (!internal && line == "//@ pragma Internal") {
internal = true;
} else if (line.startsWith("import")) { } else if (line.startsWith("import")) {
// we dont care about "import qs" as we always load the root folder // we dont care about "import qs" as we always load the root folder
if (auto importCursor = line.indexOf(" qs."); importCursor != -1) { if (auto importCursor = line.indexOf(" qs."); importCursor != -1) {
@ -152,21 +191,63 @@ bool QmlScanner::scanQmlFile(const QString& path, bool& singleton, bool& interna
auto name = line.sliced(startQuot + 1, endQuot - startQuot - 1); auto name = line.sliced(startQuot + 1, endQuot - startQuot - 1);
imports.push_back(name); imports.push_back(name);
} }
} else if (line.contains('{')) break; } else if (!internal && line == "//@ pragma Internal") {
internal = true;
} else if (line.contains('{')) {
inHeader = false;
}
}
if (line.startsWith("//@ if ")) {
auto code = line.sliced(7);
auto value = pragmaEngine.evaluate(code, path, 1234);
bool mask = true;
if (value.isError()) {
postError(QString("Evaluating if: %0").arg(value.toString()));
} else if (!value.isBool()) {
postError(QString("If expression \"%0\" is not a boolean").arg(value.toString()));
} else if (value.toBool()) {
mask = false;
}
if (!sourceMasked && mask) hideMask = true;
mask = sourceMasked || mask; // cant unmask if a nested if passes
ifScopes.append(mask);
if (mask) isOverridden = true;
sourceMasked = mask;
} else if (line.startsWith("//@ endif")) {
if (ifScopes.isEmpty()) {
postError("endif without matching if");
} else {
ifScopes.pop_back();
if (ifScopes.isEmpty()) sourceMasked = false;
else sourceMasked = ifScopes.last();
}
}
if (!hideMask && sourceMasked) overrideText.append("// MASKED: " % rawLine % '\n');
else overrideText.append(rawLine % '\n');
next:; next:;
} }
file.close(); if (!ifScopes.isEmpty()) {
postError("unclosed preprocessor if block");
}
if (isOverridden) {
this->fileIntercepts.insert(path, overrideText);
}
if (logQmlScanner().isDebugEnabled() && !imports.isEmpty()) { if (logQmlScanner().isDebugEnabled() && !imports.isEmpty()) {
qCDebug(logQmlScanner) << "Found imports" << imports; qCDebug(logQmlScanner) << "Found imports" << imports;
} }
auto currentdir = QDir(QFileInfo(path).canonicalPath()); auto currentdir = QDir(QFileInfo(path).absolutePath());
// the root can never be a singleton so it dosent matter if we skip it // the root can never be a singleton so it dosent matter if we skip it
this->scanDir(currentdir.path()); this->scanDir(currentdir);
for (auto& import: imports) { for (auto& import: imports) {
QString ipath; QString ipath;
@ -179,9 +260,9 @@ bool QmlScanner::scanQmlFile(const QString& path, bool& singleton, bool& interna
} }
auto pathInfo = QFileInfo(ipath); auto pathInfo = QFileInfo(ipath);
auto cpath = pathInfo.canonicalFilePath(); auto cpath = pathInfo.absoluteFilePath();
if (cpath.isEmpty()) { if (!pathInfo.exists()) {
qCWarning(logQmlScanner) << "Ignoring unresolvable import" << ipath << "from" << path; qCWarning(logQmlScanner) << "Ignoring unresolvable import" << ipath << "from" << path;
continue; continue;
} }
@ -191,8 +272,11 @@ bool QmlScanner::scanQmlFile(const QString& path, bool& singleton, bool& interna
continue; continue;
} }
if (import.endsWith(".js")) this->scannedFiles.push_back(cpath); if (import.endsWith(".js")) {
else this->scanDir(cpath); this->scannedFiles.push_back(cpath);
QByteArray jsData;
this->readAndHashFile(cpath, jsData);
} else this->scanDir(cpath);
} }
return true; return true;
@ -207,14 +291,12 @@ void QmlScanner::scanQmlRoot(const QString& path) {
bool QmlScanner::scanQmlJson(const QString& path) { bool QmlScanner::scanQmlJson(const QString& path) {
qCDebug(logQmlScanner) << "Scanning qml.json file" << path; qCDebug(logQmlScanner) << "Scanning qml.json file" << path;
auto file = QFile(path); QByteArray data;
if (!file.open(QFile::ReadOnly | QFile::Text)) { if (!this->readAndHashFile(path, data)) {
qCWarning(logQmlScanner) << "Failed to open file" << path; qCWarning(logQmlScanner) << "Failed to open file" << path;
return false; return false;
} }
auto data = file.readAll();
// Importing this makes CI builds fail for some reason. // Importing this makes CI builds fail for some reason.
QJsonParseError error; // NOLINT (misc-include-cleaner) QJsonParseError error; // NOLINT (misc-include-cleaner)
auto json = QJsonDocument::fromJson(data, &error); auto json = QJsonDocument::fromJson(data, &error);
@ -285,3 +367,13 @@ QPair<QString, QString> QmlScanner::jsonToQml(const QJsonValue& value, int inden
return qMakePair(QStringLiteral("var"), "null"); return qMakePair(QStringLiteral("var"), "null");
} }
} }
QJSEngine* QmlScanner::preprocEngine() {
static auto* engine = [] {
auto* engine = new QJSEngine();
engine->globalObject().setPrototype(engine->newQObject(new qs::scan::env::PreprocEnv()));
return engine;
}();
return engine;
}

View file

@ -1,8 +1,10 @@
#pragma once #pragma once
#include <qbytearray.h>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qdir.h> #include <qdir.h>
#include <qhash.h> #include <qhash.h>
#include <qjsengine.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qvector.h> #include <qvector.h>
@ -16,19 +18,31 @@ public:
QmlScanner() = default; QmlScanner() = default;
QmlScanner(const QDir& rootPath): rootPath(rootPath) {} QmlScanner(const QDir& rootPath): rootPath(rootPath) {}
// path must be canonical void scanDir(const QDir& dir);
void scanDir(const QString& path);
void scanQmlRoot(const QString& path); void scanQmlRoot(const QString& path);
QVector<QString> scannedDirs; QVector<QDir> scannedDirs;
QVector<QString> scannedFiles; QVector<QString> scannedFiles;
QHash<QString, QByteArray> fileHashes;
QHash<QString, QString> fileIntercepts; QHash<QString, QString> fileIntercepts;
struct ScanError {
QString file;
QString message;
int line;
};
QVector<ScanError> scanErrors;
bool readAndHashFile(const QString& path, QByteArray& data);
[[nodiscard]] bool hasFileContentChanged(const QString& path) const;
private: private:
QDir rootPath; QDir rootPath;
bool scanQmlFile(const QString& path, bool& singleton, bool& internal); bool scanQmlFile(const QString& path, bool& singleton, bool& internal);
bool scanQmlJson(const QString& path); bool scanQmlJson(const QString& path);
[[nodiscard]] static QPair<QString, QString> jsonToQml(const QJsonValue& value, int indent = 0); [[nodiscard]] static QPair<QString, QString> jsonToQml(const QJsonValue& value, int indent = 0);
static QJSEngine* preprocEngine();
}; };

31
src/core/scanenv.cpp Normal file
View file

@ -0,0 +1,31 @@
#include "scanenv.hpp"
#include <qcontainerfwd.h>
#include <qtenvironmentvariables.h>
#include "build.hpp"
namespace qs::scan::env {
bool PreprocEnv::hasVersion(int major, int minor, const QStringList& features) {
if (QS_VERSION_MAJOR > major) return true;
if (QS_VERSION_MAJOR == major && QS_VERSION_MINOR > minor) return true;
auto availFeatures = QString(QS_UNRELEASED_FEATURES).split(';');
for (const auto& feature: features) {
if (!availFeatures.contains(feature)) return false;
}
return QS_VERSION_MAJOR == major && QS_VERSION_MINOR == minor;
}
QString PreprocEnv::env(const QString& variable) {
return qEnvironmentVariable(variable.toStdString().c_str());
}
bool PreprocEnv::isEnvSet(const QString& variable) {
return qEnvironmentVariableIsSet(variable.toStdString().c_str());
}
} // namespace qs::scan::env

20
src/core/scanenv.hpp Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include <qcontainerfwd.h>
#include <qobject.h>
#include <qtmetamacros.h>
namespace qs::scan::env {
class PreprocEnv: public QObject {
Q_OBJECT;
public:
Q_INVOKABLE static bool
hasVersion(int major, int minor, const QStringList& features = QStringList());
Q_INVOKABLE static QString env(const QString& variable);
Q_INVOKABLE static bool isEnvSet(const QString& variable);
};
} // namespace qs::scan::env

View file

@ -72,8 +72,8 @@ void ScriptModel::updateValuesUnique(const QVariantList& newValues) {
do { do {
++iter; ++iter;
} while (iter != this->mValues.end() } while (iter != this->mValues.end()
&& std::find_if(newIter, newValues.end(), eqPredicate(*iter)) == newValues.end() && std::find_if(newIter, newValues.end(), eqPredicate(*iter))
); == newValues.end());
auto index = static_cast<qint32>(std::distance(this->mValues.begin(), iter)); auto index = static_cast<qint32>(std::distance(this->mValues.begin(), iter));
auto startIndex = static_cast<qint32>(std::distance(this->mValues.begin(), startIter)); auto startIndex = static_cast<qint32>(std::distance(this->mValues.begin(), startIter));

98
src/core/streamreader.cpp Normal file
View file

@ -0,0 +1,98 @@
#include "streamreader.hpp"
#include <cstring>
#include <qbytearray.h>
#include <qiodevice.h>
#include <qtypes.h>
void StreamReader::setDevice(QIODevice* device) {
this->reset();
this->device = device;
}
void StreamReader::startTransaction() {
this->cursor = 0;
this->failed = false;
}
bool StreamReader::fill() {
auto available = this->device->bytesAvailable();
if (available <= 0) return false;
auto oldSize = this->buffer.size();
this->buffer.resize(oldSize + available);
auto bytesRead = this->device->read(this->buffer.data() + oldSize, available); // NOLINT
if (bytesRead <= 0) {
this->buffer.resize(oldSize);
return false;
}
this->buffer.resize(oldSize + bytesRead);
return true;
}
QByteArray StreamReader::readBytes(qsizetype count) {
if (this->failed) return {};
auto needed = this->cursor + count;
while (this->buffer.size() < needed) {
if (!this->fill()) {
this->failed = true;
return {};
}
}
auto result = this->buffer.mid(this->cursor, count);
this->cursor += count;
return result;
}
QByteArray StreamReader::readUntil(char terminator) {
if (this->failed) return {};
auto searchFrom = this->cursor;
auto idx = this->buffer.indexOf(terminator, searchFrom);
while (idx == -1) {
searchFrom = this->buffer.size();
if (!this->fill()) {
this->failed = true;
return {};
}
idx = this->buffer.indexOf(terminator, searchFrom);
}
auto length = idx - this->cursor + 1;
auto result = this->buffer.mid(this->cursor, length);
this->cursor += length;
return result;
}
void StreamReader::readInto(char* ptr, qsizetype count) {
auto data = this->readBytes(count);
if (!data.isEmpty()) memcpy(ptr, data.data(), count);
}
qint32 StreamReader::readI32() {
qint32 value = 0;
this->readInto(reinterpret_cast<char*>(&value), sizeof(qint32));
return value;
}
bool StreamReader::commitTransaction() {
if (this->failed) {
this->cursor = 0;
return false;
}
this->buffer.remove(0, this->cursor);
this->cursor = 0;
return true;
}
void StreamReader::reset() {
this->buffer.clear();
this->cursor = 0;
}

26
src/core/streamreader.hpp Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include <qbytearray.h>
#include <qiodevice.h>
#include <qtypes.h>
class StreamReader {
public:
void setDevice(QIODevice* device);
void startTransaction();
QByteArray readBytes(qsizetype count);
QByteArray readUntil(char terminator);
void readInto(char* ptr, qsizetype count);
qint32 readI32();
bool commitTransaction();
void reset();
private:
bool fill();
QIODevice* device = nullptr;
QByteArray buffer;
qsizetype cursor = 0;
bool failed = false;
};

View file

@ -54,7 +54,7 @@ bool QmlToolingSupport::lockTooling() {
return false; return false;
} }
auto lock = flock { struct flock lock = {
.l_type = F_WRLCK, .l_type = F_WRLCK,
.l_whence = SEEK_SET, // NOLINT (fcntl.h??) .l_whence = SEEK_SET, // NOLINT (fcntl.h??)
.l_start = 0, .l_start = 0,
@ -177,6 +177,8 @@ void QmlToolingSupport::updateToolingFs(
auto fileInfo = QFileInfo(path); auto fileInfo = QFileInfo(path);
if (!fileInfo.isFile()) continue; if (!fileInfo.isFile()) continue;
if (scanner.fileIntercepts.contains(path)) continue;
auto spath = linkDir.filePath(name); auto spath = linkDir.filePath(name);
auto sFileInfo = QFileInfo(spath); auto sFileInfo = QFileInfo(spath);
@ -205,8 +207,10 @@ void QmlToolingSupport::updateToolingFs(
} }
auto spath = linkDir.filePath(name); auto spath = linkDir.filePath(name);
QFile::remove(spath);
auto file = QFile(spath); auto file = QFile(spath);
if (!file.open(QFile::ReadWrite | QFile::Text)) { if (!file.open(QFile::ReadWrite | QFile::Text | QFile::NewOnly)) {
qCCritical(logTooling) << "Failed to open injected file" << spath; qCCritical(logTooling) << "Failed to open injected file" << spath;
continue; continue;
} }

View file

@ -29,7 +29,7 @@ struct StringLiteral16 {
} }
[[nodiscard]] constexpr const QChar* qCharPtr() const noexcept { [[nodiscard]] constexpr const QChar* qCharPtr() const noexcept {
return std::bit_cast<const QChar*>(&this->value); return std::bit_cast<const QChar*>(&this->value); // NOLINT
} }
[[nodiscard]] Q_ALWAYS_INLINE operator QString() const noexcept { [[nodiscard]] Q_ALWAYS_INLINE operator QString() const noexcept {
@ -251,37 +251,6 @@ public:
GuardedEmitBlocker block() { return GuardedEmitBlocker(&this->blocked); } GuardedEmitBlocker block() { return GuardedEmitBlocker(&this->blocked); }
}; };
template <auto member, auto destroyedSlot, auto changedSignal>
class SimpleObjectHandleOps {
using Traits = MemberPointerTraits<decltype(member)>;
public:
static bool setObject(Traits::Class* parent, Traits::Type value) {
if (value == parent->*member) return false;
if (parent->*member != nullptr) {
QObject::disconnect(parent->*member, &QObject::destroyed, parent, destroyedSlot);
}
parent->*member = value;
if (value != nullptr) {
QObject::connect(parent->*member, &QObject::destroyed, parent, destroyedSlot);
}
if constexpr (changedSignal != nullptr) {
emit(parent->*changedSignal)();
}
return true;
}
};
template <auto member, auto destroyedSlot, auto changedSignal = nullptr>
bool setSimpleObjectHandle(auto* parent, auto* value) {
return SimpleObjectHandleOps<member, destroyedSlot, changedSignal>::setObject(parent, value);
}
template <auto methodPtr> template <auto methodPtr>
class MethodFunctor { class MethodFunctor {
using PtrMeta = MemberPointerTraits<decltype(methodPtr)>; using PtrMeta = MemberPointerTraits<decltype(methodPtr)>;

View file

@ -6,12 +6,51 @@ qt_add_library(quickshell-crash STATIC
qs_pch(quickshell-crash SET large) qs_pch(quickshell-crash SET large)
find_package(PkgConfig REQUIRED) if (VENDOR_CPPTRACE)
pkg_check_modules(breakpad REQUIRED IMPORTED_TARGET breakpad) message(STATUS "Vendoring cpptrace...")
# only need client?? take only includes from pkg config todo include(FetchContent)
target_link_libraries(quickshell-crash PRIVATE PkgConfig::breakpad -lbreakpad_client)
# For use without internet access see: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_SOURCE_DIR_%3CuppercaseName%3E
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v1.0.4
)
set(CPPTRACE_UNWIND_WITH_LIBUNWIND TRUE)
FetchContent_MakeAvailable(cpptrace)
else ()
find_package(cpptrace REQUIRED)
# useful for cross after you have already checked cpptrace is built correctly
if (NOT DO_NOT_CHECK_CPPTRACE_USABILITY)
try_run(CPPTRACE_SIGNAL_SAFE_UNWIND CPPTRACE_SIGNAL_SAFE_UNWIND_COMP
SOURCE_FROM_CONTENT check.cxx "
#include <cpptrace/basic.hpp>
int main() {
return cpptrace::can_signal_safe_unwind() ? 0 : 1;
}
"
LOG_DESCRIPTION "Checking ${CPPTRACE_SIGNAL_SAFE_UNWIND}"
LINK_LIBRARIES cpptrace::cpptrace
COMPILE_OUTPUT_VARIABLE CPPTRACE_SIGNAL_SAFE_UNWIND_LOG
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
)
if (NOT CPPTRACE_SIGNAL_SAFE_UNWIND_COMP)
message(STATUS "${CPPTRACE_SIGNAL_SAFE_UNWIND_LOG}")
message(FATAL_ERROR "Failed to compile cpptrace signal safe unwind tester.")
endif()
if (NOT CPPTRACE_SIGNAL_SAFE_UNWIND EQUAL 0)
message(STATUS "Cpptrace signal safe unwind test exited with: ${CPPTRACE_SIGNAL_SAFE_UNWIND}")
message(FATAL_ERROR "Cpptrace was built without CPPTRACE_UNWIND_WITH_LIBUNWIND set to true. Enable libunwind support in the package or set VENDOR_CPPTRACE to true when building Quickshell.")
endif()
endif ()
endif ()
# quick linked for pch compat # quick linked for pch compat
target_link_libraries(quickshell-crash PRIVATE quickshell-build Qt::Quick Qt::Widgets) target_link_libraries(quickshell-crash PRIVATE quickshell-build Qt::Quick Qt::Widgets cpptrace::cpptrace)
target_link_libraries(quickshell PRIVATE quickshell-crash) target_link_libraries(quickshell PRIVATE quickshell-crash)

View file

@ -1,12 +1,15 @@
#include "handler.hpp" #include "handler.hpp"
#include <algorithm>
#include <array> #include <array>
#include <cerrno>
#include <csignal>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <exception>
#include <bits/types/sigset_t.h> #include <cpptrace/basic.hpp>
#include <breakpad/client/linux/handler/exception_handler.h> #include <cpptrace/forward.hpp>
#include <breakpad/client/linux/handler/minidump_descriptor.h> #include <cpptrace/utils.hpp>
#include <breakpad/common/linux/linux_libc_support.h>
#include <qdatastream.h> #include <qdatastream.h>
#include <qfile.h> #include <qfile.h>
#include <qlogging.h> #include <qlogging.h>
@ -19,95 +22,77 @@
extern char** environ; // NOLINT extern char** environ; // NOLINT
using namespace google_breakpad;
namespace qs::crash { namespace qs::crash {
namespace { namespace {
QS_LOGGING_CATEGORY(logCrashHandler, "quickshell.crashhandler", QtWarningMsg); QS_LOGGING_CATEGORY(logCrashHandler, "quickshell.crashhandler", QtWarningMsg);
}
struct CrashHandlerPrivate { void writeEnvInt(char* buf, const char* name, int value) {
ExceptionHandler* exceptionHandler = nullptr; // NOLINTBEGIN (cppcoreguidelines-pro-bounds-pointer-arithmetic)
int minidumpFd = -1; while (*name != '\0') *buf++ = *name++;
int infoFd = -1; *buf++ = '=';
static bool minidumpCallback(const MinidumpDescriptor& descriptor, void* context, bool succeeded); if (value < 0) {
}; *buf++ = '-';
value = -value;
CrashHandler::CrashHandler(): d(new CrashHandlerPrivate()) {}
void CrashHandler::init() {
// MinidumpDescriptor has no move constructor and the copy constructor breaks fds.
auto createHandler = [this](const MinidumpDescriptor& desc) {
this->d->exceptionHandler = new ExceptionHandler(
desc,
nullptr,
&CrashHandlerPrivate::minidumpCallback,
this->d,
true,
-1
);
};
qCDebug(logCrashHandler) << "Starting crash handler...";
this->d->minidumpFd = memfd_create("quickshell:minidump", MFD_CLOEXEC);
if (this->d->minidumpFd == -1) {
qCCritical(logCrashHandler
) << "Failed to allocate minidump memfd, minidumps will be saved in the working directory.";
createHandler(MinidumpDescriptor("."));
} else {
qCDebug(logCrashHandler) << "Created memfd" << this->d->minidumpFd
<< "for holding possible minidumps.";
createHandler(MinidumpDescriptor(this->d->minidumpFd));
} }
qCInfo(logCrashHandler) << "Crash handler initialized."; if (value == 0) {
} *buf++ = '0';
*buf = '\0';
void CrashHandler::setRelaunchInfo(const RelaunchInfo& info) {
this->d->infoFd = memfd_create("quickshell:instance_info", MFD_CLOEXEC);
if (this->d->infoFd == -1) {
qCCritical(logCrashHandler
) << "Failed to allocate instance info memfd, crash recovery will not work.";
return; return;
} }
QFile file; auto* start = buf;
while (value > 0) {
if (!file.open(this->d->infoFd, QFile::ReadWrite)) { *buf++ = static_cast<char>('0' + (value % 10));
qCCritical(logCrashHandler value /= 10;
) << "Failed to open instance info memfd, crash recovery will not work.";
} }
QDataStream ds(&file); *buf = '\0';
ds << info; std::reverse(start, buf);
file.flush(); // NOLINTEND
qCDebug(logCrashHandler) << "Stored instance info in memfd" << this->d->infoFd;
} }
CrashHandler::~CrashHandler() { void signalHandler(
delete this->d->exceptionHandler; int sig,
delete this->d; siginfo_t* /*info*/, // NOLINT (misc-include-cleaner)
} void* /*context*/
bool CrashHandlerPrivate::minidumpCallback(
const MinidumpDescriptor& /*descriptor*/,
void* context,
bool /*success*/
) { ) {
// A fork that just dies to ensure the coredump is caught by the system. // NOLINTBEGIN (misc-include-cleaner)
auto coredumpPid = fork(); sigset_t set;
sigfillset(&set);
sigprocmask(SIG_UNBLOCK, &set, nullptr);
// NOLINTEND
if (coredumpPid == 0) { if (CrashInfo::INSTANCE.traceFd != -1) {
return false; auto traceBuffer = std::array<cpptrace::frame_ptr, 1024>();
auto frameCount = cpptrace::safe_generate_raw_trace(traceBuffer.data(), traceBuffer.size(), 1);
for (size_t i = 0; i < static_cast<size_t>(frameCount); i++) {
auto frame = cpptrace::safe_object_frame();
cpptrace::get_safe_object_frame(traceBuffer[i], &frame);
auto* wptr = reinterpret_cast<char*>(&frame);
auto* end = wptr + sizeof(cpptrace::safe_object_frame); // NOLINT
while (wptr != end) {
auto r = write(CrashInfo::INSTANCE.traceFd, &frame, sizeof(cpptrace::safe_object_frame));
if (r < 0 && errno == EINTR) continue;
if (r <= 0) goto fail;
wptr += r; // NOLINT
}
} }
auto* self = static_cast<CrashHandlerPrivate*>(context); fail:;
}
// TODO: coredump fork and crash reporter remain as zombies, fix
auto coredumpPid = fork();
if (coredumpPid == 0) {
raise(sig);
_exit(-1);
}
auto exe = std::array<char, 4096>(); auto exe = std::array<char, 4096>();
if (readlink("/proc/self/exe", exe.data(), exe.size() - 1) == -1) { if (readlink("/proc/self/exe", exe.data(), exe.size() - 1) == -1) {
@ -120,17 +105,19 @@ bool CrashHandlerPrivate::minidumpCallback(
auto env = std::array<char*, 4096>(); auto env = std::array<char*, 4096>();
auto envi = 0; auto envi = 0;
auto infoFd = dup(self->infoFd); // dup to remove CLOEXEC
auto infoFdStr = std::array<char, 38>(); auto infoFdStr = std::array<char, 48>();
memcpy(infoFdStr.data(), "__QUICKSHELL_CRASH_INFO_FD=-1" /*\0*/, 30); writeEnvInt(infoFdStr.data(), "__QUICKSHELL_CRASH_INFO_FD", dup(CrashInfo::INSTANCE.infoFd));
if (infoFd != -1) my_uitos(&infoFdStr[27], infoFd, 10);
env[envi++] = infoFdStr.data(); env[envi++] = infoFdStr.data();
auto corePidStr = std::array<char, 39>(); auto corePidStr = std::array<char, 48>();
memcpy(corePidStr.data(), "__QUICKSHELL_CRASH_DUMP_PID=-1" /*\0*/, 31); writeEnvInt(corePidStr.data(), "__QUICKSHELL_CRASH_DUMP_PID", coredumpPid);
if (coredumpPid != -1) my_uitos(&corePidStr[28], coredumpPid, 10);
env[envi++] = corePidStr.data(); env[envi++] = corePidStr.data();
auto sigStr = std::array<char, 48>();
writeEnvInt(sigStr.data(), "__QUICKSHELL_CRASH_SIGNAL", sig);
env[envi++] = sigStr.data();
auto populateEnv = [&]() { auto populateEnv = [&]() {
auto senvi = 0; auto senvi = 0;
while (envi != 4095) { while (envi != 4095) {
@ -142,30 +129,17 @@ bool CrashHandlerPrivate::minidumpCallback(
env[envi] = nullptr; env[envi] = nullptr;
}; };
sigset_t sigset;
sigemptyset(&sigset); // NOLINT (include)
sigprocmask(SIG_SETMASK, &sigset, nullptr); // NOLINT
auto pid = fork(); auto pid = fork();
if (pid == -1) { if (pid == -1) {
perror("Failed to fork and launch crash reporter.\n"); perror("Failed to fork and launch crash reporter.\n");
return false; _exit(-1);
} else if (pid == 0) { } else if (pid == 0) {
// dup to remove CLOEXEC // dup to remove CLOEXEC
// if already -1 will return -1 auto dumpFdStr = std::array<char, 48>();
auto dumpFd = dup(self->minidumpFd); auto logFdStr = std::array<char, 48>();
auto logFd = dup(CrashInfo::INSTANCE.logFd); writeEnvInt(dumpFdStr.data(), "__QUICKSHELL_CRASH_DUMP_FD", dup(CrashInfo::INSTANCE.traceFd));
writeEnvInt(logFdStr.data(), "__QUICKSHELL_CRASH_LOG_FD", dup(CrashInfo::INSTANCE.logFd));
// allow up to 10 digits, which should never happen
auto dumpFdStr = std::array<char, 38>();
auto logFdStr = std::array<char, 37>();
memcpy(dumpFdStr.data(), "__QUICKSHELL_CRASH_DUMP_FD=-1" /*\0*/, 30);
memcpy(logFdStr.data(), "__QUICKSHELL_CRASH_LOG_FD=-1" /*\0*/, 29);
if (dumpFd != -1) my_uitos(&dumpFdStr[27], dumpFd, 10);
if (logFd != -1) my_uitos(&logFdStr[26], logFd, 10);
env[envi++] = dumpFdStr.data(); env[envi++] = dumpFdStr.data();
env[envi++] = logFdStr.data(); env[envi++] = logFdStr.data();
@ -182,8 +156,99 @@ bool CrashHandlerPrivate::minidumpCallback(
perror("Failed to relaunch quickshell.\n"); perror("Failed to relaunch quickshell.\n");
_exit(-1); _exit(-1);
} }
}
return false; // should make sure it hits the system coredump handler void handleCppTerminate() {
if (auto ptr = std::current_exception()) {
try {
std::rethrow_exception(ptr);
} catch (std::exception& e) {
qFatal().nospace() << "Terminate called with C++ exception ("
<< cpptrace::demangle(typeid(e).name()).data() << "): " << e.what();
} catch (...) {
qFatal() << "Terminate called with non exception object";
}
}
qFatal() << "Terminate called without active C++ exception";
}
} // namespace
void CrashHandler::init() {
qCDebug(logCrashHandler) << "Starting crash handler...";
CrashInfo::INSTANCE.traceFd = memfd_create("quickshell:trace", MFD_CLOEXEC);
if (CrashInfo::INSTANCE.traceFd == -1) {
qCCritical(logCrashHandler) << "Failed to allocate trace memfd, stack traces will not be "
"available in crash reports.";
} else {
qCDebug(logCrashHandler) << "Created memfd" << CrashInfo::INSTANCE.traceFd
<< "for holding possible stack traces.";
}
{
// Preload anything dynamically linked to avoid malloc etc in the dynamic loader.
// See cpptrace documentation for more information.
auto buffer = std::array<cpptrace::frame_ptr, 10>();
cpptrace::safe_generate_raw_trace(buffer.data(), buffer.size());
auto frame = cpptrace::safe_object_frame();
cpptrace::get_safe_object_frame(buffer[0], &frame);
}
// NOLINTBEGIN (misc-include-cleaner)
// Set up alternate signal stack for stack overflow handling
auto ss = stack_t();
ss.ss_sp = new char[SIGSTKSZ];
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;
sigaltstack(&ss, nullptr);
// Install signal handlers
struct sigaction sa {};
sa.sa_sigaction = &signalHandler;
sa.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESETHAND;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, nullptr);
sigaction(SIGABRT, &sa, nullptr);
sigaction(SIGFPE, &sa, nullptr);
sigaction(SIGILL, &sa, nullptr);
sigaction(SIGBUS, &sa, nullptr);
sigaction(SIGTRAP, &sa, nullptr);
// NOLINTEND (misc-include-cleaner)
std::set_terminate(&handleCppTerminate);
qCInfo(logCrashHandler) << "Crash handler initialized.";
}
void CrashHandler::setRelaunchInfo(const RelaunchInfo& info) {
CrashInfo::INSTANCE.infoFd = memfd_create("quickshell:instance_info", MFD_CLOEXEC);
if (CrashInfo::INSTANCE.infoFd == -1) {
qCCritical(
logCrashHandler
) << "Failed to allocate instance info memfd, crash recovery will not work.";
return;
}
QFile file;
if (!file.open(CrashInfo::INSTANCE.infoFd, QFile::ReadWrite)) {
qCCritical(
logCrashHandler
) << "Failed to open instance info memfd, crash recovery will not work.";
}
QDataStream ds(&file);
ds << info;
file.flush();
qCDebug(logCrashHandler) << "Stored instance info in memfd" << CrashInfo::INSTANCE.infoFd;
} }
} // namespace qs::crash } // namespace qs::crash

View file

@ -5,19 +5,10 @@
#include "../core/instanceinfo.hpp" #include "../core/instanceinfo.hpp"
namespace qs::crash { namespace qs::crash {
struct CrashHandlerPrivate;
class CrashHandler { class CrashHandler {
public: public:
explicit CrashHandler(); static void init();
~CrashHandler(); static void setRelaunchInfo(const RelaunchInfo& info);
Q_DISABLE_COPY_MOVE(CrashHandler);
void init();
void setRelaunchInfo(const RelaunchInfo& info);
private:
CrashHandlerPrivate* d;
}; };
} // namespace qs::crash } // namespace qs::crash

View file

@ -5,6 +5,7 @@
#include <qapplication.h> #include <qapplication.h>
#include <qboxlayout.h> #include <qboxlayout.h>
#include <qconfig.h> #include <qconfig.h>
#include <qcontainerfwd.h>
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <qfont.h> #include <qfont.h>
#include <qfontinfo.h> #include <qfontinfo.h>
@ -12,11 +13,22 @@
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h> #include <qobject.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qtenvironmentvariables.h>
#include <qtversion.h> #include <qtversion.h>
#include <qwidget.h> #include <qwidget.h>
#include "build.hpp" #include "build.hpp"
namespace {
QString crashreportUrl() {
if (auto url = qEnvironmentVariable("QS_CRASHREPORT_URL"); !url.isEmpty()) {
return url;
}
return CRASHREPORT_URL;
}
} // namespace
class ReportLabel: public QWidget { class ReportLabel: public QWidget {
public: public:
ReportLabel(const QString& label, const QString& content, QWidget* parent): QWidget(parent) { ReportLabel(const QString& label, const QString& content, QWidget* parent): QWidget(parent) {
@ -66,22 +78,17 @@ CrashReporterGui::CrashReporterGui(QString reportFolder, int pid)
mainLayout->addSpacing(textHeight); mainLayout->addSpacing(textHeight);
if (qtVersionMatches) { if (qtVersionMatches) {
mainLayout->addWidget(new QLabel("Please open a bug report for this issue via github or email.") mainLayout->addWidget(
new QLabel("Please open a bug report for this issue on the issue tracker.")
); );
} else { } else {
mainLayout->addWidget(new QLabel( mainLayout->addWidget(new QLabel(
"Please rebuild Quickshell against the current Qt version.\n" "Please rebuild Quickshell against the current Qt version.\n"
"If this does not solve the problem, please open a bug report via github or email." "If this does not solve the problem, please open a bug report on the issue tracker."
)); ));
} }
mainLayout->addWidget(new ReportLabel( mainLayout->addWidget(new ReportLabel("Tracker:", crashreportUrl(), this));
"Github:",
"https://github.com/quickshell-mirror/quickshell/issues/new?template=crash.yml",
this
));
mainLayout->addWidget(new ReportLabel("Email:", "quickshell-bugs@outfoxxed.me", this));
auto* buttons = new QWidget(this); auto* buttons = new QWidget(this);
buttons->setMinimumWidth(900); buttons->setMinimumWidth(900);
@ -111,10 +118,5 @@ void CrashReporterGui::openFolder() {
QDesktopServices::openUrl(QUrl::fromLocalFile(this->reportFolder)); QDesktopServices::openUrl(QUrl::fromLocalFile(this->reportFolder));
} }
void CrashReporterGui::openReportUrl() { void CrashReporterGui::openReportUrl() { QDesktopServices::openUrl(QUrl(crashreportUrl())); }
QDesktopServices::openUrl(
QUrl("https://github.com/outfoxxed/quickshell/issues/new?template=crash.yml")
);
}
void CrashReporterGui::cancel() { QApplication::quit(); } void CrashReporterGui::cancel() { QApplication::quit(); }

View file

@ -1,9 +1,11 @@
#include "main.hpp" #include "main.hpp"
#include <cerrno> #include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <cpptrace/basic.hpp>
#include <cpptrace/formatting.hpp>
#include <qapplication.h> #include <qapplication.h>
#include <qconfig.h>
#include <qcoreapplication.h> #include <qcoreapplication.h>
#include <qdatastream.h> #include <qdatastream.h>
#include <qdir.h> #include <qdir.h>
@ -12,15 +14,19 @@
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qtenvironmentvariables.h> #include <qtenvironmentvariables.h>
#include <qtextstream.h> #include <qtextstream.h>
#include <qtversion.h> #include <qtypes.h>
#include <sys/sendfile.h> #include <sys/sendfile.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h>
#include "../core/debuginfo.hpp"
#include "../core/instanceinfo.hpp" #include "../core/instanceinfo.hpp"
#include "../core/logcat.hpp" #include "../core/logcat.hpp"
#include "../core/logging.hpp" #include "../core/logging.hpp"
#include "../core/logging_p.hpp"
#include "../core/paths.hpp" #include "../core/paths.hpp"
#include "build.hpp" #include "../core/plugin.hpp"
#include "../core/ringbuf.hpp"
#include "interface.hpp" #include "interface.hpp"
namespace { namespace {
@ -61,6 +67,76 @@ int tryDup(int fd, const QString& path) {
return 0; return 0;
} }
QString readRecentLogs(int logFd, int maxLines, qint64 maxAgeSecs) {
QFile file;
if (!file.open(logFd, QFile::ReadOnly, QFile::AutoCloseHandle)) {
return QStringLiteral("(failed to open log fd)\n");
}
file.seek(0);
qs::log::EncodedLogReader reader;
reader.setDevice(&file);
bool readable = false;
quint8 logVersion = 0;
quint8 readerVersion = 0;
if (!reader.readHeader(&readable, &logVersion, &readerVersion) || !readable) {
return QStringLiteral("(failed to read log header)\n");
}
// Read all messages, keeping last maxLines in a ring buffer
auto tail = RingBuffer<qs::log::LogMessage>(maxLines);
qs::log::LogMessage message;
while (reader.read(&message)) {
tail.emplace(message);
}
if (tail.size() == 0) {
return QStringLiteral("(no logs)\n");
}
// Filter to only messages within maxAgeSecs of the newest message
auto cutoff = tail.at(0).time.addSecs(-maxAgeSecs);
QString result;
auto stream = QTextStream(&result);
for (auto i = tail.size() - 1; i != -1; i--) {
if (tail.at(i).time < cutoff) continue;
qs::log::LogMessage::formatMessage(stream, tail.at(i), false, true);
stream << '\n';
}
if (result.isEmpty()) {
return QStringLiteral("(no recent logs)\n");
}
return result;
}
cpptrace::stacktrace resolveStacktrace(int dumpFd) {
QFile sourceFile;
if (!sourceFile.open(dumpFd, QFile::ReadOnly, QFile::AutoCloseHandle)) {
qCCritical(logCrashReporter) << "Failed to open trace memfd.";
return {};
}
sourceFile.seek(0);
auto data = sourceFile.readAll();
auto frameCount = static_cast<size_t>(data.size()) / sizeof(cpptrace::safe_object_frame);
if (frameCount == 0) return {};
const auto* frames = reinterpret_cast<const cpptrace::safe_object_frame*>(data.constData());
cpptrace::object_trace objectTrace;
for (size_t i = 0; i < frameCount; i++) {
objectTrace.frames.push_back(frames[i].resolve()); // NOLINT
}
return objectTrace.resolve();
}
void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) { void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) {
qCDebug(logCrashReporter) << "Recording crash information at" << crashDir.path(); qCDebug(logCrashReporter) << "Recording crash information at" << crashDir.path();
@ -71,74 +147,49 @@ void recordCrashInfo(const QDir& crashDir, const InstanceInfo& instance) {
} }
auto crashProc = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt(); auto crashProc = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_PID").toInt();
auto crashSignal = qEnvironmentVariable("__QUICKSHELL_CRASH_SIGNAL").toInt();
auto dumpFd = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_FD").toInt(); auto dumpFd = qEnvironmentVariable("__QUICKSHELL_CRASH_DUMP_FD").toInt();
auto logFd = qEnvironmentVariable("__QUICKSHELL_CRASH_LOG_FD").toInt(); auto logFd = qEnvironmentVariable("__QUICKSHELL_CRASH_LOG_FD").toInt();
qCDebug(logCrashReporter) << "Saving minidump from fd" << dumpFd; qCDebug(logCrashReporter) << "Resolving stacktrace from fd" << dumpFd;
auto dumpDupStatus = tryDup(dumpFd, crashDir.filePath("minidump.dmp.log")); auto stacktrace = resolveStacktrace(dumpFd);
if (dumpDupStatus != 0) {
qCCritical(logCrashReporter) << "Failed to write minidump:" << dumpDupStatus;
}
qCDebug(logCrashReporter) << "Saving log from fd" << logFd; qCDebug(logCrashReporter) << "Reading recent log lines from fd" << logFd;
auto logDupStatus = tryDup(logFd, crashDir.filePath("log.qslog.log")); auto logDupFd = dup(logFd);
auto recentLogs = readRecentLogs(logFd, 100, 10);
qCDebug(logCrashReporter) << "Saving log from fd" << logDupFd;
auto logDupStatus = tryDup(logDupFd, crashDir.filePath("log.qslog.log"));
if (logDupStatus != 0) { if (logDupStatus != 0) {
qCCritical(logCrashReporter) << "Failed to save log:" << logDupStatus; qCCritical(logCrashReporter) << "Failed to save log:" << logDupStatus;
} }
auto copyBinStatus = 0;
if (!DISTRIBUTOR_DEBUGINFO_AVAILABLE) {
qCDebug(logCrashReporter) << "Copying binary to crash folder";
if (!QFile(QCoreApplication::applicationFilePath()).copy(crashDir.filePath("executable.txt"))) {
copyBinStatus = 1;
qCCritical(logCrashReporter) << "Failed to copy binary.";
}
}
{ {
auto extraInfoFile = QFile(crashDir.filePath("info.txt")); auto extraInfoFile = QFile(crashDir.filePath("report.txt"));
if (!extraInfoFile.open(QFile::WriteOnly)) { if (!extraInfoFile.open(QFile::WriteOnly)) {
qCCritical(logCrashReporter) << "Failed to open crash info file for writing."; qCCritical(logCrashReporter) << "Failed to open crash info file for writing.";
} else { } else {
auto stream = QTextStream(&extraInfoFile); auto stream = QTextStream(&extraInfoFile);
stream << "===== Build Information =====\n"; stream << qs::debuginfo::combinedInfo();
stream << "Git Revision: " << GIT_REVISION << '\n';
stream << "Buildtime Qt Version: " << QT_VERSION_STR << "\n";
stream << "Build Type: " << BUILD_TYPE << '\n';
stream << "Compiler: " << COMPILER << '\n';
stream << "Complie Flags: " << COMPILE_FLAGS << "\n\n";
stream << "Build configuration:\n" << BUILD_CONFIGURATION << "\n";
stream << "\n===== Runtime Information =====\n"; stream << "\n===== Instance Information =====\n";
stream << "Runtime Qt Version: " << qVersion() << '\n'; stream << "Signal: " << strsignal(crashSignal) << " (" << crashSignal << ")\n"; // NOLINT
stream << "Crashed process ID: " << crashProc << '\n'; stream << "Crashed process ID: " << crashProc << '\n';
stream << "Run ID: " << instance.instanceId << '\n'; stream << "Run ID: " << instance.instanceId << '\n';
stream << "Shell ID: " << instance.shellId << '\n'; stream << "Shell ID: " << instance.shellId << '\n';
stream << "Config Path: " << instance.configPath << '\n'; stream << "Config Path: " << instance.configPath << '\n';
stream << "\n===== Report Integrity =====\n"; stream << "\n===== Stacktrace =====\n";
stream << "Minidump save status: " << dumpDupStatus << '\n'; if (stacktrace.empty()) {
stream << "Log save status: " << logDupStatus << '\n'; stream << "(no trace available)\n";
stream << "Binary copy status: " << copyBinStatus << '\n';
stream << "\n===== System Information =====\n\n";
stream << "/etc/os-release:";
auto osReleaseFile = QFile("/etc/os-release");
if (osReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << osReleaseFile.readAll() << '\n';
osReleaseFile.close();
} else { } else {
stream << "FAILED TO OPEN\n"; auto formatter = cpptrace::formatter().header(std::string());
auto traceStr = formatter.format(stacktrace);
stream << QString::fromStdString(traceStr) << '\n';
} }
stream << "/etc/lsb-release:"; stream << "\n===== Log Tail =====\n";
auto lsbReleaseFile = QFile("/etc/lsb-release"); stream << recentLogs;
if (lsbReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << lsbReleaseFile.readAll();
lsbReleaseFile.close();
} else {
stream << "FAILED TO OPEN\n";
}
extraInfoFile.close(); extraInfoFile.close();
} }
@ -180,12 +231,17 @@ void qsCheckCrash(int argc, char** argv) {
); );
auto app = QApplication(argc, argv); auto app = QApplication(argc, argv);
QApplication::setDesktopFileName("org.quickshell"); auto desktopId =
info.instance.appId.isEmpty() ? QStringLiteral("org.quickshell") : info.instance.appId;
QApplication::setDesktopFileName(desktopId);
auto crashDir = QsPaths::crashDir(info.instance.instanceId); auto crashDir = QsPaths::crashDir(info.instance.instanceId);
qCInfo(logCrashReporter) << "Starting crash reporter..."; qCInfo(logCrashReporter) << "Starting crash reporter...";
// Required platform compatibility hooks
QsEnginePlugin::preinitPluginsOnly();
recordCrashInfo(crashDir, info.instance); recordCrashInfo(crashDir, info.instance);
auto gui = CrashReporterGui(crashDir.path(), crashProc); auto gui = CrashReporterGui(crashDir.path(), crashProc);

View file

@ -214,8 +214,10 @@ void DBusPropertyGroup::updatePropertySet(const QVariantMap& properties, bool co
} }
} }
void DBusPropertyGroup::tryUpdateProperty(DBusPropertyCore* property, const QVariant& variant) void DBusPropertyGroup::tryUpdateProperty(
const { DBusPropertyCore* property,
const QVariant& variant
) const {
property->mExists = true; property->mExists = true;
auto error = property->store(variant); auto error = property->store(variant);

View file

@ -217,7 +217,7 @@ protected:
private: private:
[[nodiscard]] constexpr Owner* owner() const { [[nodiscard]] constexpr Owner* owner() const {
auto* self = std::bit_cast<char*>(this); auto* self = std::bit_cast<char*>(this); // NOLINT
return std::bit_cast<Owner*>(self - offset()); // NOLINT return std::bit_cast<Owner*>(self - offset()); // NOLINT
} }

View file

@ -9,7 +9,7 @@
#include <qqmlinfo.h> #include <qqmlinfo.h>
#include <qquickitem.h> #include <qquickitem.h>
#include <qquickwindow.h> #include <qquickwindow.h>
#include <qstringliteral.h> #include <qstring.h>
#include "../core/logcat.hpp" #include "../core/logcat.hpp"

View file

@ -24,7 +24,7 @@ qt_add_qml_module(quickshell-io
qs_add_module_deps_light(quickshell-io Quickshell) qs_add_module_deps_light(quickshell-io Quickshell)
install_qml_module(quickshell-io) install_qml_module(quickshell-io)
target_link_libraries(quickshell-io PRIVATE Qt::Quick) target_link_libraries(quickshell-io PRIVATE Qt::Quick quickshell-ipc)
target_link_libraries(quickshell PRIVATE quickshell-ioplugin) target_link_libraries(quickshell PRIVATE quickshell-ioplugin)
qs_module_pch(quickshell-io) qs_module_pch(quickshell-io)

View file

@ -190,6 +190,14 @@ QString WirePropertyDefinition::toString() const {
return "property " % this->name % ": " % this->type; return "property " % this->name % ": " % this->type;
} }
QString WireSignalDefinition::toString() const {
if (this->rettype.isEmpty()) {
return "signal " % this->name % "()";
} else {
return "signal " % this->name % "(" % this->retname % ": " % this->rettype % ')';
}
}
QString WireTargetDefinition::toString() const { QString WireTargetDefinition::toString() const {
QString accum = "target " % this->name; QString accum = "target " % this->name;
@ -201,6 +209,10 @@ QString WireTargetDefinition::toString() const {
accum += "\n " % prop.toString(); accum += "\n " % prop.toString();
} }
for (const auto& sig: this->signalFunctions) {
accum += "\n " % sig.toString();
}
return accum; return accum;
} }

View file

@ -146,14 +146,31 @@ struct WirePropertyDefinition {
DEFINE_SIMPLE_DATASTREAM_OPS(WirePropertyDefinition, data.name, data.type); DEFINE_SIMPLE_DATASTREAM_OPS(WirePropertyDefinition, data.name, data.type);
struct WireTargetDefinition { struct WireSignalDefinition {
QString name; QString name;
QVector<WireFunctionDefinition> functions; QString retname;
QVector<WirePropertyDefinition> properties; QString rettype;
[[nodiscard]] QString toString() const; [[nodiscard]] QString toString() const;
}; };
DEFINE_SIMPLE_DATASTREAM_OPS(WireTargetDefinition, data.name, data.functions, data.properties); DEFINE_SIMPLE_DATASTREAM_OPS(WireSignalDefinition, data.name, data.retname, data.rettype);
struct WireTargetDefinition {
QString name;
QVector<WireFunctionDefinition> functions;
QVector<WirePropertyDefinition> properties;
QVector<WireSignalDefinition> signalFunctions;
[[nodiscard]] QString toString() const;
};
DEFINE_SIMPLE_DATASTREAM_OPS(
WireTargetDefinition,
data.name,
data.functions,
data.properties,
data.signalFunctions
);
} // namespace qs::io::ipc } // namespace qs::io::ipc

View file

@ -1,10 +1,11 @@
#include "ipccomm.hpp" #include "ipccomm.hpp"
#include <cstdio> #include <utility>
#include <variant> #include <variant>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qlogging.h> #include <qlogging.h>
#include <qloggingcategory.h> #include <qloggingcategory.h>
#include <qobject.h>
#include <qtextstream.h> #include <qtextstream.h>
#include <qtypes.h> #include <qtypes.h>
@ -19,10 +20,6 @@ using namespace qs::ipc;
namespace qs::io::ipc::comm { namespace qs::io::ipc::comm {
struct NoCurrentGeneration: std::monostate {};
struct TargetNotFound: std::monostate {};
struct EntryNotFound: std::monostate {};
using QueryResponse = std::variant< using QueryResponse = std::variant<
std::monostate, std::monostate,
NoCurrentGeneration, NoCurrentGeneration,
@ -314,4 +311,106 @@ int getProperty(IpcClient* client, const QString& target, const QString& propert
return -1; return -1;
} }
int listenToSignal(IpcClient* client, const QString& target, const QString& signal, bool once) {
if (target.isEmpty()) {
qCCritical(logBare) << "Target required to listen for signals.";
return -1;
} else if (signal.isEmpty()) {
qCCritical(logBare) << "Signal required to listen.";
return -1;
}
client->sendMessage(IpcCommand(SignalListenCommand {.target = target, .signal = signal}));
while (true) {
SignalListenResponse slot;
if (!client->waitForResponse(slot)) return -1;
if (std::holds_alternative<SignalResponse>(slot)) {
auto& result = std::get<SignalResponse>(slot);
QTextStream(stdout) << result.response << Qt::endl;
if (once) return 0;
else continue;
} else if (std::holds_alternative<TargetNotFound>(slot)) {
qCCritical(logBare) << "Target not found.";
} else if (std::holds_alternative<EntryNotFound>(slot)) {
qCCritical(logBare) << "Signal not found.";
} else if (std::holds_alternative<NoCurrentGeneration>(slot)) {
qCCritical(logBare) << "Not ready to accept queries yet.";
} else {
qCCritical(logIpc) << "Received invalid IPC response from" << client;
}
break;
}
return -1;
}
void SignalListenCommand::exec(qs::ipc::IpcServerConnection* conn) {
auto resp = conn->responseStream<SignalListenResponse>();
if (auto* generation = EngineGeneration::currentGeneration()) {
auto* registry = IpcHandlerRegistry::forGeneration(generation);
auto* handler = registry->findHandler(this->target);
if (!handler) {
resp << TargetNotFound();
return;
}
auto* signal = handler->findSignal(this->signal);
if (!signal) {
resp << EntryNotFound();
return;
}
new RemoteSignalListener(conn, *this);
} else {
conn->respond(SignalListenResponse(NoCurrentGeneration()));
}
}
RemoteSignalListener::RemoteSignalListener(
qs::ipc::IpcServerConnection* conn,
SignalListenCommand command
)
: conn(conn)
, command(std::move(command)) {
conn->setParent(this);
QObject::connect(
IpcSignalRemoteListener::instance(),
&IpcSignalRemoteListener::triggered,
this,
&RemoteSignalListener::onSignal
);
QObject::connect(
conn,
&qs::ipc::IpcServerConnection::destroyed,
this,
&RemoteSignalListener::onConnDestroyed
);
qCDebug(logIpc) << "Remote listener created for" << this->command.target << this->command.signal
<< ":" << this;
}
RemoteSignalListener::~RemoteSignalListener() {
qCDebug(logIpc) << "Destroying remote listener" << this;
}
void RemoteSignalListener::onSignal(
const QString& target,
const QString& signal,
const QString& value
) {
if (target != this->command.target || signal != this->command.signal) return;
qCDebug(logIpc) << "Remote signal" << signal << "triggered on" << target << "with value" << value;
this->conn->respond(SignalListenResponse(SignalResponse {.response = value}));
}
void RemoteSignalListener::onConnDestroyed() { this->deleteLater(); }
} // namespace qs::io::ipc::comm } // namespace qs::io::ipc::comm

View file

@ -2,6 +2,8 @@
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qflags.h> #include <qflags.h>
#include <qobject.h>
#include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../ipc/ipc.hpp" #include "../ipc/ipc.hpp"
@ -48,4 +50,52 @@ DEFINE_SIMPLE_DATASTREAM_OPS(StringPropReadCommand, data.target, data.property);
int getProperty(qs::ipc::IpcClient* client, const QString& target, const QString& property); int getProperty(qs::ipc::IpcClient* client, const QString& target, const QString& property);
struct SignalListenCommand {
QString target;
QString signal;
void exec(qs::ipc::IpcServerConnection* conn);
};
DEFINE_SIMPLE_DATASTREAM_OPS(SignalListenCommand, data.target, data.signal);
int listenToSignal(
qs::ipc::IpcClient* client,
const QString& target,
const QString& signal,
bool once
);
struct NoCurrentGeneration: std::monostate {};
struct TargetNotFound: std::monostate {};
struct EntryNotFound: std::monostate {};
struct SignalResponse {
QString response;
};
DEFINE_SIMPLE_DATASTREAM_OPS(SignalResponse, data.response);
using SignalListenResponse = std::
variant<std::monostate, NoCurrentGeneration, TargetNotFound, EntryNotFound, SignalResponse>;
class RemoteSignalListener: public QObject {
Q_OBJECT;
public:
explicit RemoteSignalListener(qs::ipc::IpcServerConnection* conn, SignalListenCommand command);
~RemoteSignalListener() override;
Q_DISABLE_COPY_MOVE(RemoteSignalListener);
private slots:
void onSignal(const QString& target, const QString& signal, const QString& value);
void onConnDestroyed();
private:
qs::ipc::IpcServerConnection* conn;
SignalListenCommand command;
};
} // namespace qs::io::ipc::comm } // namespace qs::io::ipc::comm

View file

@ -1,5 +1,7 @@
#include "ipchandler.hpp" #include "ipchandler.hpp"
#include <cstddef> #include <cstddef>
#include <memory>
#include <utility>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qdebug.h> #include <qdebug.h>
@ -139,6 +141,75 @@ WirePropertyDefinition IpcProperty::wireDef() const {
return wire; return wire;
} }
WireSignalDefinition IpcSignal::wireDef() const {
WireSignalDefinition wire;
wire.name = this->signal.name();
if (this->targetSlot != IpcSignalListener::SLOT_VOID) {
wire.retname = this->signal.parameterNames().value(0);
if (this->targetSlot == IpcSignalListener::SLOT_STRING) wire.rettype = "string";
else if (this->targetSlot == IpcSignalListener::SLOT_INT) wire.rettype = "int";
else if (this->targetSlot == IpcSignalListener::SLOT_BOOL) wire.rettype = "bool";
else if (this->targetSlot == IpcSignalListener::SLOT_REAL) wire.rettype = "real";
else if (this->targetSlot == IpcSignalListener::SLOT_COLOR) wire.rettype = "color";
}
return wire;
}
// NOLINTBEGIN (cppcoreguidelines-interfaces-global-init)
// clang-format off
const int IpcSignalListener::SLOT_VOID = IpcSignalListener::staticMetaObject.indexOfSlot("invokeVoid()");
const int IpcSignalListener::SLOT_STRING = IpcSignalListener::staticMetaObject.indexOfSlot("invokeString(QString)");
const int IpcSignalListener::SLOT_INT = IpcSignalListener::staticMetaObject.indexOfSlot("invokeInt(int)");
const int IpcSignalListener::SLOT_BOOL = IpcSignalListener::staticMetaObject.indexOfSlot("invokeBool(bool)");
const int IpcSignalListener::SLOT_REAL = IpcSignalListener::staticMetaObject.indexOfSlot("invokeReal(double)");
const int IpcSignalListener::SLOT_COLOR = IpcSignalListener::staticMetaObject.indexOfSlot("invokeColor(QColor)");
// clang-format on
// NOLINTEND
bool IpcSignal::resolve(QString& error) {
if (this->signal.parameterCount() > 1) {
error = "Due to technical limitations, IPC signals can have at most one argument.";
return false;
}
auto slot = IpcSignalListener::SLOT_VOID;
if (this->signal.parameterCount() == 1) {
auto paramType = this->signal.parameterType(0);
if (paramType == QMetaType::QString) slot = IpcSignalListener::SLOT_STRING;
else if (paramType == QMetaType::Int) slot = IpcSignalListener::SLOT_INT;
else if (paramType == QMetaType::Bool) slot = IpcSignalListener::SLOT_BOOL;
else if (paramType == QMetaType::Double) slot = IpcSignalListener::SLOT_REAL;
else if (paramType == QMetaType::QColor) slot = IpcSignalListener::SLOT_COLOR;
else {
error = QString("Type of argument (%2: %3) cannot be used across IPC.")
.arg(this->signal.parameterNames().value(0))
.arg(QMetaType(paramType).name());
return false;
}
}
this->targetSlot = slot;
return true;
}
void IpcSignal::connectListener(IpcHandler* handler) {
if (this->targetSlot == -1) {
qFatal() << "Tried to connect unresolved IPC signal";
}
this->listener = std::make_shared<IpcSignalListener>(this->signal.name());
QMetaObject::connect(handler, this->signal.methodIndex(), this->listener.get(), this->targetSlot);
QObject::connect(
this->listener.get(),
&IpcSignalListener::triggered,
handler,
&IpcHandler::onSignalTriggered
);
}
IpcCallStorage::IpcCallStorage(const IpcFunction& function): returnSlot(function.returnType) { IpcCallStorage::IpcCallStorage(const IpcFunction& function): returnSlot(function.returnType) {
for (const auto& arg: function.argumentTypes) { for (const auto& arg: function.argumentTypes) {
this->argumentSlots.emplace_back(arg); this->argumentSlots.emplace_back(arg);
@ -172,8 +243,7 @@ void IpcHandler::onPostReload() {
// which should handle inheritance on the qml side. // which should handle inheritance on the qml side.
for (auto i = smeta.methodCount(); i != meta->methodCount(); i++) { for (auto i = smeta.methodCount(); i != meta->methodCount(); i++) {
const auto& method = meta->method(i); const auto& method = meta->method(i);
if (method.methodType() != QMetaMethod::Slot) continue; if (method.methodType() == QMetaMethod::Slot) {
auto ipcFunc = IpcFunction(method); auto ipcFunc = IpcFunction(method);
QString error; QString error;
@ -183,6 +253,19 @@ void IpcHandler::onPostReload() {
} else { } else {
this->functionMap.insert(method.name(), ipcFunc); this->functionMap.insert(method.name(), ipcFunc);
} }
} else if (method.methodType() == QMetaMethod::Signal) {
qmlDebug(this) << "Signal detected: " << method.name();
auto ipcSig = IpcSignal(method);
QString error;
if (!ipcSig.resolve(error)) {
qmlWarning(this).nospace().noquote()
<< "Error parsing signal \"" << method.name() << "\": " << error;
} else {
ipcSig.connectListener(this);
this->signalMap.emplace(method.name(), std::move(ipcSig));
}
}
} }
for (auto i = smeta.propertyCount(); i != meta->propertyCount(); i++) { for (auto i = smeta.propertyCount(); i != meta->propertyCount(); i++) {
@ -222,6 +305,11 @@ IpcHandlerRegistry* IpcHandlerRegistry::forGeneration(EngineGeneration* generati
return dynamic_cast<IpcHandlerRegistry*>(ext); return dynamic_cast<IpcHandlerRegistry*>(ext);
} }
void IpcHandler::onSignalTriggered(const QString& signal, const QString& value) const {
emit IpcSignalRemoteListener::instance()
-> triggered(this->registeredState.target, signal, value);
}
void IpcHandler::updateRegistration(bool destroying) { void IpcHandler::updateRegistration(bool destroying) {
if (!this->complete) return; if (!this->complete) return;
@ -324,6 +412,10 @@ WireTargetDefinition IpcHandler::wireDef() const {
wire.properties += prop.wireDef(); wire.properties += prop.wireDef();
} }
for (const auto& sig: this->signalMap.values()) {
wire.signalFunctions += sig.wireDef();
}
return wire; return wire;
} }
@ -368,6 +460,13 @@ IpcProperty* IpcHandler::findProperty(const QString& name) {
else return &*itr; else return &*itr;
} }
IpcSignal* IpcHandler::findSignal(const QString& name) {
auto itr = this->signalMap.find(name);
if (itr == this->signalMap.end()) return nullptr;
else return &*itr;
}
IpcHandler* IpcHandlerRegistry::findHandler(const QString& target) { IpcHandler* IpcHandlerRegistry::findHandler(const QString& target) {
return this->handlers.value(target); return this->handlers.value(target);
} }
@ -382,4 +481,9 @@ QVector<WireTargetDefinition> IpcHandlerRegistry::wireTargets() const {
return wire; return wire;
} }
IpcSignalRemoteListener* IpcSignalRemoteListener::instance() {
static auto* instance = new IpcSignalRemoteListener();
return instance;
}
} // namespace qs::io::ipc } // namespace qs::io::ipc

View file

@ -1,8 +1,10 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <memory>
#include <vector> #include <vector>
#include <qcolor.h>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qdebug.h> #include <qdebug.h>
#include <qhash.h> #include <qhash.h>
@ -67,6 +69,54 @@ public:
const IpcType* type = nullptr; const IpcType* type = nullptr;
}; };
class IpcSignalListener: public QObject {
Q_OBJECT;
public:
IpcSignalListener(QString signal): signal(std::move(signal)) {}
static const int SLOT_VOID;
static const int SLOT_STRING;
static const int SLOT_INT;
static const int SLOT_BOOL;
static const int SLOT_REAL;
static const int SLOT_COLOR;
signals:
void triggered(const QString& signal, const QString& value);
private slots:
void invokeVoid() { this->triggered(this->signal, "void"); }
void invokeString(const QString& value) { this->triggered(this->signal, value); }
void invokeInt(int value) { this->triggered(this->signal, QString::number(value)); }
void invokeBool(bool value) { this->triggered(this->signal, value ? "true" : "false"); }
void invokeReal(double value) { this->triggered(this->signal, QString::number(value)); }
void invokeColor(QColor value) { this->triggered(this->signal, value.name(QColor::HexArgb)); }
private:
QString signal;
};
class IpcHandler;
class IpcSignal {
public:
explicit IpcSignal(QMetaMethod signal): signal(signal) {}
bool resolve(QString& error);
[[nodiscard]] WireSignalDefinition wireDef() const;
QMetaMethod signal;
int targetSlot = -1;
void connectListener(IpcHandler* handler);
private:
void connectListener(QObject* handler, IpcSignalListener* listener) const;
std::shared_ptr<IpcSignalListener> listener;
};
class IpcHandlerRegistry; class IpcHandlerRegistry;
///! Handler for IPC message calls. ///! Handler for IPC message calls.
@ -100,6 +150,11 @@ class IpcHandlerRegistry;
/// - `real` will be converted to a string and returned. /// - `real` will be converted to a string and returned.
/// - `color` will be converted to a hex string in the form `#AARRGGBB` and returned. /// - `color` will be converted to a hex string in the form `#AARRGGBB` and returned.
/// ///
/// #### Signals
/// IPC handler signals can be observed remotely using `qs ipc wait` (one call)
/// and `qs ipc listen` (many calls). IPC signals may have zero or one argument, where
/// the argument is one of the types listed above, or no arguments for void.
///
/// #### Example /// #### Example
/// The following example creates ipc functions to control and retrieve the appearance /// The following example creates ipc functions to control and retrieve the appearance
/// of a Rectangle. /// of a Rectangle.
@ -119,10 +174,18 @@ class IpcHandlerRegistry;
/// ///
/// function setColor(color: color): void { rect.color = color; } /// function setColor(color: color): void { rect.color = color; }
/// function getColor(): color { return rect.color; } /// function getColor(): color { return rect.color; }
///
/// function setAngle(angle: real): void { rect.rotation = angle; } /// function setAngle(angle: real): void { rect.rotation = angle; }
/// function getAngle(): real { return rect.rotation; } /// function getAngle(): real { return rect.rotation; }
/// function setRadius(radius: int): void { rect.radius = radius; } ///
/// function setRadius(radius: int): void {
/// rect.radius = radius;
/// this.radiusChanged(radius);
/// }
///
/// function getRadius(): int { return rect.radius; } /// function getRadius(): int { return rect.radius; }
///
/// signal radiusChanged(newRadius: int);
/// } /// }
/// } /// }
/// ``` /// ```
@ -136,6 +199,7 @@ class IpcHandlerRegistry;
/// function getAngle(): real /// function getAngle(): real
/// function setRadius(radius: int): void /// function setRadius(radius: int): void
/// function getRadius(): int /// function getRadius(): int
/// signal radiusChanged(newRadius: int)
/// ``` /// ```
/// ///
/// and then invoked using `qs ipc call`. /// and then invoked using `qs ipc call`.
@ -179,14 +243,15 @@ public:
QString listMembers(qsizetype indent); QString listMembers(qsizetype indent);
[[nodiscard]] IpcFunction* findFunction(const QString& name); [[nodiscard]] IpcFunction* findFunction(const QString& name);
[[nodiscard]] IpcProperty* findProperty(const QString& name); [[nodiscard]] IpcProperty* findProperty(const QString& name);
[[nodiscard]] IpcSignal* findSignal(const QString& name);
[[nodiscard]] WireTargetDefinition wireDef() const; [[nodiscard]] WireTargetDefinition wireDef() const;
signals: signals:
void enabledChanged(); void enabledChanged();
void targetChanged(); void targetChanged();
private slots: public slots:
//void handleIpcPropertyChange(); void onSignalTriggered(const QString& signal, const QString& value) const;
private: private:
void updateRegistration(bool destroying = false); void updateRegistration(bool destroying = false);
@ -204,6 +269,7 @@ private:
QHash<QString, IpcFunction> functionMap; QHash<QString, IpcFunction> functionMap;
QHash<QString, IpcProperty> propertyMap; QHash<QString, IpcProperty> propertyMap;
QHash<QString, IpcSignal> signalMap;
friend class IpcHandlerRegistry; friend class IpcHandlerRegistry;
}; };
@ -227,4 +293,14 @@ private:
QHash<QString, QVector<IpcHandler*>> knownHandlers; QHash<QString, QVector<IpcHandler*>> knownHandlers;
}; };
class IpcSignalRemoteListener: public QObject {
Q_OBJECT;
public:
static IpcSignalRemoteListener* instance();
signals:
void triggered(const QString& target, const QString& signal, const QString& value);
};
} // namespace qs::io::ipc } // namespace qs::io::ipc

View file

@ -1,11 +1,13 @@
#include "jsonadapter.hpp" #include "jsonadapter.hpp"
#include <qassociativeiterable.h>
#include <qcontainerfwd.h> #include <qcontainerfwd.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsondocument.h> #include <qjsondocument.h>
#include <qjsonobject.h> #include <qjsonobject.h>
#include <qjsonvalue.h> #include <qjsonvalue.h>
#include <qjsvalue.h> #include <qjsvalue.h>
#include <qmetacontainer.h>
#include <qmetaobject.h> #include <qmetaobject.h>
#include <qnamespace.h> #include <qnamespace.h>
#include <qobject.h> #include <qobject.h>
@ -14,6 +16,7 @@
#include <qqmlengine.h> #include <qqmlengine.h>
#include <qqmlinfo.h> #include <qqmlinfo.h>
#include <qqmllist.h> #include <qqmllist.h>
#include <qsequentialiterable.h>
#include <qstringview.h> #include <qstringview.h>
#include <qvariant.h> #include <qvariant.h>
@ -131,13 +134,22 @@ QJsonObject JsonAdapter::serializeRec(const QObject* obj, const QMetaObject* bas
} }
json.insert(prop.name(), array); json.insert(prop.name(), array);
} else if (val.canConvert<QJSValue>()) {
auto variant = val.value<QJSValue>().toVariant();
auto jv = QJsonValue::fromVariant(variant);
json.insert(prop.name(), jv);
} else { } else {
auto jv = QJsonValue::fromVariant(val); if (val.canConvert<QJSValue>()) val = val.value<QJSValue>().toVariant();
json.insert(prop.name(), jv);
auto jsonVal = QJsonValue::fromVariant(val);
if (jsonVal.isNull() && !val.isNull() && val.isValid()) {
if (val.canConvert<QAssociativeIterable>()) {
val.convert(QMetaType::fromType<QVariantMap>());
} else if (val.canConvert<QSequentialIterable>()) {
val.convert(QMetaType::fromType<QVariantList>());
}
jsonVal = QJsonValue::fromVariant(val);
}
json.insert(prop.name(), jsonVal);
} }
} }
} }
@ -154,14 +166,16 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
auto jval = json.value(prop.name()); auto jval = json.value(prop.name());
if (prop.metaType() == QMetaType::fromType<QVariant>()) { if (prop.metaType() == QMetaType::fromType<QVariant>()) {
auto variant = jval.toVariant(); auto newVariant = jval.toVariant();
auto oldValue = prop.read(this).value<QJSValue>(); auto oldValue = prop.read(obj);
auto oldVariant =
oldValue.canConvert<QJSValue>() ? oldValue.value<QJSValue>().toVariant() : oldValue;
// Calling prop.write with a new QJSValue will cause a property update // Calling prop.write with a new QJSValue will cause a property update
// even if content is identical. // even if content is identical.
if (jval.toVariant() != oldValue.toVariant()) { if (newVariant != oldVariant) {
auto jsValue = qmlEngine(this)->fromVariant<QJSValue>(jval.toVariant()); auto jsValue = qmlEngine(this)->fromVariant<QJSValue>(newVariant);
prop.write(this, QVariant::fromValue(jsValue)); prop.write(obj, QVariant::fromValue(jsValue));
} }
} else if (QMetaType::canView(prop.metaType(), QMetaType::fromType<JsonObject*>())) { } else if (QMetaType::canView(prop.metaType(), QMetaType::fromType<JsonObject*>())) {
// FIXME: This doesn't support creating descendants of JsonObject, as QMetaType.metaObject() // FIXME: This doesn't support creating descendants of JsonObject, as QMetaType.metaObject()
@ -196,7 +210,7 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
QMetaType::fromType<QQmlListProperty<JsonObject>>() QMetaType::fromType<QQmlListProperty<JsonObject>>()
)) ))
{ {
auto pval = prop.read(this); auto pval = prop.read(obj);
if (pval.canConvert<QQmlListProperty<JsonObject>>()) { if (pval.canConvert<QQmlListProperty<JsonObject>>()) {
auto lp = pval.value<QQmlListProperty<JsonObject>>(); auto lp = pval.value<QQmlListProperty<JsonObject>>();
@ -247,12 +261,35 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
} }
} else { } else {
auto variant = jval.toVariant(); auto variant = jval.toVariant();
auto convVariant = variant;
if (variant.convert(prop.metaType())) { if (convVariant.convert(prop.metaType())) {
prop.write(obj, variant); prop.write(obj, convVariant);
} else {
auto pval = prop.read(obj);
if (variant.canConvert<QSequentialIterable>() && pval.canView<QSequentialIterable>()) {
auto targetv = QVariant(pval.metaType());
auto target = targetv.view<QSequentialIterable>().metaContainer();
auto valueType = target.valueMetaType();
auto i = 0;
for (QVariant item: variant.value<QSequentialIterable>()) {
if (item.convert(valueType)) {
target.addValueAtEnd(targetv.data(), item.constData());
} else {
qmlWarning(this) << "Failed to deserialize list member " << i << " of property "
<< prop.name() << ": expected " << valueType.name() << " but got "
<< item.typeName();
}
++i;
}
prop.write(obj, targetv);
} else { } else {
qmlWarning(this) << "Failed to deserialize property " << prop.name() << ": expected " qmlWarning(this) << "Failed to deserialize property " << prop.name() << ": expected "
<< prop.metaType().name() << " but got " << jval.toVariant().typeName(); << prop.metaType().name() << " but got "
<< jval.toVariant().typeName();
}
} }
} }
} }

View file

@ -102,7 +102,7 @@ class Process: public PostReloadHook {
/// If the process is already running changing this property will affect the next /// If the process is already running changing this property will affect the next
/// started process. If the property has been changed after starting a process it will /// started process. If the property has been changed after starting a process it will
/// return the new value, not the one for the currently running process. /// return the new value, not the one for the currently running process.
Q_PROPERTY(QHash<QString, QVariant> environment READ environment WRITE setEnvironment NOTIFY environmentChanged); Q_PROPERTY(QVariantHash environment READ environment WRITE setEnvironment NOTIFY environmentChanged);
/// If the process's environment should be cleared prior to applying @@environment. /// If the process's environment should be cleared prior to applying @@environment.
/// Defaults to false. /// Defaults to false.
/// ///

View file

@ -13,7 +13,7 @@ namespace qs::io::process {
class ProcessContext { class ProcessContext {
Q_PROPERTY(QList<QString> command MEMBER command WRITE setCommand); Q_PROPERTY(QList<QString> command MEMBER command WRITE setCommand);
Q_PROPERTY(QHash<QString, QVariant> environment MEMBER environment WRITE setEnvironment); Q_PROPERTY(QVariantHash environment MEMBER environment WRITE setEnvironment);
Q_PROPERTY(bool clearEnvironment MEMBER clearEnvironment WRITE setClearEnvironment); Q_PROPERTY(bool clearEnvironment MEMBER clearEnvironment WRITE setClearEnvironment);
Q_PROPERTY(QString workingDirectory MEMBER workingDirectory WRITE setWorkingDirectory); Q_PROPERTY(QString workingDirectory MEMBER workingDirectory WRITE setWorkingDirectory);
Q_PROPERTY(bool unbindStdout MEMBER unbindStdout WRITE setUnbindStdout); Q_PROPERTY(bool unbindStdout MEMBER unbindStdout WRITE setUnbindStdout);

View file

@ -3,6 +3,7 @@
#include <variant> #include <variant>
#include <qbuffer.h> #include <qbuffer.h>
#include <qcoreapplication.h>
#include <qlocalserver.h> #include <qlocalserver.h>
#include <qlocalsocket.h> #include <qlocalsocket.h>
#include <qlogging.h> #include <qlogging.h>
@ -36,7 +37,8 @@ void IpcServer::start() {
auto path = run->filePath("ipc.sock"); auto path = run->filePath("ipc.sock");
new IpcServer(path); new IpcServer(path);
} else { } else {
qCCritical(logIpc qCCritical(
logIpc
) << "Could not start IPC server as the instance runtime path could not be created."; ) << "Could not start IPC server as the instance runtime path could not be created.";
} }
} }
@ -60,6 +62,7 @@ IpcServerConnection::IpcServerConnection(QLocalSocket* socket, IpcServer* server
void IpcServerConnection::onDisconnected() { void IpcServerConnection::onDisconnected() {
qCInfo(logIpc) << "IPC connection disconnected" << this; qCInfo(logIpc) << "IPC connection disconnected" << this;
this->deleteLater();
} }
void IpcServerConnection::onReadyRead() { void IpcServerConnection::onReadyRead() {
@ -83,6 +86,11 @@ void IpcServerConnection::onReadyRead() {
); );
if (!this->stream.commitTransaction()) return; if (!this->stream.commitTransaction()) return;
// async connections reparent
if (dynamic_cast<IpcServer*>(this->parent()) != nullptr) {
this->deleteLater();
}
} }
IpcClient::IpcClient(const QString& path) { IpcClient::IpcClient(const QString& path) {
@ -120,7 +128,9 @@ int IpcClient::connect(const QString& id, const std::function<void(IpcClient& cl
void IpcKillCommand::exec(IpcServerConnection* /*unused*/) { void IpcKillCommand::exec(IpcServerConnection* /*unused*/) {
qInfo() << "Exiting due to IPC request."; qInfo() << "Exiting due to IPC request.";
EngineGeneration::currentGeneration()->quit(); auto* generation = EngineGeneration::currentGeneration();
if (generation) generation->quit();
else QCoreApplication::exit(0);
} }
} // namespace qs::ipc } // namespace qs::ipc

View file

@ -16,6 +16,7 @@ using IpcCommand = std::variant<
IpcKillCommand, IpcKillCommand,
qs::io::ipc::comm::QueryMetadataCommand, qs::io::ipc::comm::QueryMetadataCommand,
qs::io::ipc::comm::StringCallCommand, qs::io::ipc::comm::StringCallCommand,
qs::io::ipc::comm::SignalListenCommand,
qs::io::ipc::comm::StringPropReadCommand>; qs::io::ipc::comm::StringPropReadCommand>;
} // namespace qs::ipc } // namespace qs::ipc

View file

@ -1,7 +1,6 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cerrno> #include <cerrno>
#include <cstdio>
#include <cstring> #include <cstring>
#include <utility> #include <utility>
@ -13,6 +12,7 @@
#include <qdebug.h> #include <qdebug.h>
#include <qdir.h> #include <qdir.h>
#include <qfileinfo.h> #include <qfileinfo.h>
#include <qguiapplication.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsondocument.h> #include <qjsondocument.h>
#include <qjsonobject.h> #include <qjsonobject.h>
@ -25,12 +25,12 @@
#include <qtversion.h> #include <qtversion.h>
#include <unistd.h> #include <unistd.h>
#include "../core/debuginfo.hpp"
#include "../core/instanceinfo.hpp" #include "../core/instanceinfo.hpp"
#include "../core/logging.hpp" #include "../core/logging.hpp"
#include "../core/paths.hpp" #include "../core/paths.hpp"
#include "../io/ipccomm.hpp" #include "../io/ipccomm.hpp"
#include "../ipc/ipc.hpp" #include "../ipc/ipc.hpp"
#include "build.hpp"
#include "launch_p.hpp" #include "launch_p.hpp"
namespace qs::launch { namespace qs::launch {
@ -89,8 +89,8 @@ int locateConfigFile(CommandState& cmd, QString& path) {
} }
if (!manifestPath.isEmpty()) { if (!manifestPath.isEmpty()) {
qWarning( qWarning()
) << "Config manifests (manifest.conf) are deprecated and will be removed in a future " << "Config manifests (manifest.conf) are deprecated and will be removed in a future "
"release."; "release.";
qWarning() << "Consider using symlinks to a subfolder of quickshell's XDG config dirs."; qWarning() << "Consider using symlinks to a subfolder of quickshell's XDG config dirs.";
@ -109,7 +109,7 @@ int locateConfigFile(CommandState& cmd, QString& path) {
} }
if (split[0].trimmed() == *cmd.config.name) { if (split[0].trimmed() == *cmd.config.name) {
path = QDir(QFileInfo(file).canonicalPath()).filePath(split[1].trimmed()); path = QDir(QFileInfo(file).absolutePath()).filePath(split[1].trimmed());
break; break;
} }
} }
@ -129,7 +129,8 @@ int locateConfigFile(CommandState& cmd, QString& path) {
if (path.isEmpty()) { if (path.isEmpty()) {
if (name == "default") { if (name == "default") {
qCCritical(logBare qCCritical(
logBare
) << "Could not find \"default\" config directory or shell.qml in any valid config path."; ) << "Could not find \"default\" config directory or shell.qml in any valid config path.";
} else { } else {
qCCritical(logBare) << "Could not find" << name qCCritical(logBare) << "Could not find" << name
@ -139,8 +140,7 @@ int locateConfigFile(CommandState& cmd, QString& path) {
return -1; return -1;
} }
path = QFileInfo(path).canonicalFilePath(); goto rpath;
return 0;
} }
} }
@ -153,7 +153,8 @@ int locateConfigFile(CommandState& cmd, QString& path) {
return -1; return -1;
} }
path = QFileInfo(path).canonicalFilePath(); rpath:
path = QFileInfo(path).absoluteFilePath();
return 0; return 0;
} }
@ -178,7 +179,8 @@ int selectInstance(CommandState& cmd, InstanceLockInfo* instance, bool deadFallb
} }
} else if (!cmd.instance.id->isEmpty()) { } else if (!cmd.instance.id->isEmpty()) {
path = basePath->filePath("by-pid"); path = basePath->filePath("by-pid");
auto [liveInstances, deadInstances] = QsPaths::collectInstances(path); auto [liveInstances, deadInstances] =
QsPaths::collectInstances(path, cmd.config.anyDisplay ? "" : getDisplayConnection());
liveInstances.removeIf([&](const InstanceLockInfo& info) { liveInstances.removeIf([&](const InstanceLockInfo& info) {
return !info.instance.instanceId.startsWith(*cmd.instance.id); return !info.instance.instanceId.startsWith(*cmd.instance.id);
@ -228,7 +230,8 @@ int selectInstance(CommandState& cmd, InstanceLockInfo* instance, bool deadFallb
path = QDir(basePath->filePath("by-path")).filePath(pathId); path = QDir(basePath->filePath("by-path")).filePath(pathId);
auto [liveInstances, deadInstances] = QsPaths::collectInstances(path); auto [liveInstances, deadInstances] =
QsPaths::collectInstances(path, cmd.config.anyDisplay ? "" : getDisplayConnection());
auto instances = liveInstances; auto instances = liveInstances;
if (instances.isEmpty() && deadFallback) { if (instances.isEmpty() && deadFallback) {
@ -311,7 +314,10 @@ int listInstances(CommandState& cmd) {
path = QDir(basePath->filePath("by-path")).filePath(pathId); path = QDir(basePath->filePath("by-path")).filePath(pathId);
} }
auto [liveInstances, deadInstances] = QsPaths::collectInstances(path); auto [liveInstances, deadInstances] = QsPaths::collectInstances(
path,
cmd.config.anyDisplay || cmd.instance.all ? "" : getDisplayConnection()
);
sortInstances(liveInstances, cmd.config.newest); sortInstances(liveInstances, cmd.config.newest);
@ -373,6 +379,7 @@ int listInstances(CommandState& cmd) {
<< " Process ID: " << instance.instance.pid << '\n' << " Process ID: " << instance.instance.pid << '\n'
<< " Shell ID: " << instance.instance.shellId << '\n' << " Shell ID: " << instance.instance.shellId << '\n'
<< " Config path: " << instance.instance.configPath << '\n' << " Config path: " << instance.instance.configPath << '\n'
<< " Display connection: " << instance.instance.display << '\n'
<< " Launch time: " << launchTimeStr << " Launch time: " << launchTimeStr
<< (isDead ? "" : " (running for " + runtimeStr + ")") << '\n' << (isDead ? "" : " (running for " + runtimeStr + ")") << '\n'
<< (gray ? "\033[0m" : ""); << (gray ? "\033[0m" : "");
@ -404,6 +411,10 @@ int ipcCommand(CommandState& cmd) {
return qs::io::ipc::comm::queryMetadata(&client, *cmd.ipc.target, *cmd.ipc.name); return qs::io::ipc::comm::queryMetadata(&client, *cmd.ipc.target, *cmd.ipc.name);
} else if (*cmd.ipc.getprop) { } else if (*cmd.ipc.getprop) {
return qs::io::ipc::comm::getProperty(&client, *cmd.ipc.target, *cmd.ipc.name); return qs::io::ipc::comm::getProperty(&client, *cmd.ipc.target, *cmd.ipc.name);
} else if (*cmd.ipc.wait) {
return qs::io::ipc::comm::listenToSignal(&client, *cmd.ipc.target, *cmd.ipc.name, true);
} else if (*cmd.ipc.listen) {
return qs::io::ipc::comm::listenToSignal(&client, *cmd.ipc.target, *cmd.ipc.name, false);
} else { } else {
QVector<QString> arguments; QVector<QString> arguments;
for (auto& arg: cmd.ipc.arguments) { for (auto& arg: cmd.ipc.arguments) {
@ -453,7 +464,7 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt " QTextStream(stdout) << "\033[31mCOMPATIBILITY WARNING: Quickshell was built against Qt "
<< QT_VERSION_STR << " but the system has updated to Qt " << qVersion() << QT_VERSION_STR << " but the system has updated to Qt " << qVersion()
<< " without rebuilding the package. This is likely to cause crashes, so " << " without rebuilding the package. This is likely to cause crashes, so "
"you must rebuild the quickshell package.\n"; "you must rebuild the quickshell package.\n\033[0m";
return 1; return 1;
} }
@ -508,20 +519,10 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
} }
if (state.misc.printVersion) { if (state.misc.printVersion) {
qCInfo(logBare).noquote().nospace() if (state.log.verbosity == 0) {
<< "quickshell 0.2.1, revision " << GIT_REVISION << ", distributed by: " << DISTRIBUTOR; qCInfo(logBare).noquote() << "Quickshell" << qs::debuginfo::qsVersion();
} else {
if (state.log.verbosity > 1) { qCInfo(logBare).noquote() << qs::debuginfo::combinedInfo();
qCInfo(logBare).noquote() << "\nBuildtime Qt Version:" << QT_VERSION_STR;
qCInfo(logBare).noquote() << "Runtime Qt Version:" << qVersion();
qCInfo(logBare).noquote() << "Compiler:" << COMPILER;
qCInfo(logBare).noquote() << "Compile Flags:" << COMPILE_FLAGS;
}
if (state.log.verbosity > 0) {
qCInfo(logBare).noquote() << "\nBuild Type:" << BUILD_TYPE;
qCInfo(logBare).noquote() << "Build configuration:";
qCInfo(logBare).noquote().nospace() << BUILD_CONFIGURATION;
} }
} else if (*state.subcommand.log) { } else if (*state.subcommand.log) {
return readLogFile(state); return readLogFile(state);
@ -545,4 +546,18 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
return 0; return 0;
} }
QString getDisplayConnection() {
auto platform = qEnvironmentVariable("QT_QPA_PLATFORM");
auto wlDisplay = qEnvironmentVariable("WAYLAND_DISPLAY");
auto xDisplay = qEnvironmentVariable("DISPLAY");
if (platform == "wayland" || (platform.isEmpty() && !wlDisplay.isEmpty())) {
return "wayland," + wlDisplay;
} else if (platform == "xcb" || (platform.isEmpty() && !xDisplay.isEmpty())) {
return "x11," + xDisplay;
} else {
return "unk," + QGuiApplication::platformName();
}
}
} // namespace qs::launch } // namespace qs::launch

View file

@ -27,7 +27,7 @@
#include "build.hpp" #include "build.hpp"
#include "launch_p.hpp" #include "launch_p.hpp"
#if CRASH_REPORTER #if CRASH_HANDLER
#include "../crash/handler.hpp" #include "../crash/handler.hpp"
#endif #endif
@ -76,8 +76,11 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
bool useSystemStyle = false; bool useSystemStyle = false;
QString iconTheme = qEnvironmentVariable("QS_ICON_THEME"); QString iconTheme = qEnvironmentVariable("QS_ICON_THEME");
QHash<QString, QString> envOverrides; QHash<QString, QString> envOverrides;
QString appId = qEnvironmentVariable("QS_APP_ID");
bool dropExpensiveFonts = false;
QString dataDir; QString dataDir;
QString stateDir; QString stateDir;
QString cacheDir;
} pragmas; } pragmas;
auto stream = QTextStream(&file); auto stream = QTextStream(&file);
@ -90,6 +93,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true; else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true;
else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false; else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false;
else if (pragma == "RespectSystemStyle") pragmas.useSystemStyle = true; else if (pragma == "RespectSystemStyle") pragmas.useSystemStyle = true;
else if (pragma == "DropExpensiveFonts") pragmas.dropExpensiveFonts = true;
else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10); else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10);
else if (pragma.startsWith("Env ")) { else if (pragma.startsWith("Env ")) {
auto envPragma = pragma.sliced(4); auto envPragma = pragma.sliced(4);
@ -103,15 +107,18 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
auto var = envPragma.sliced(0, splitIdx).trimmed(); auto var = envPragma.sliced(0, splitIdx).trimmed();
auto val = envPragma.sliced(splitIdx + 1).trimmed(); auto val = envPragma.sliced(splitIdx + 1).trimmed();
pragmas.envOverrides.insert(var, val); pragmas.envOverrides.insert(var, val);
} else if (pragma.startsWith("AppId ")) {
pragmas.appId = pragma.sliced(6).trimmed();
} else if (pragma.startsWith("ShellId ")) { } else if (pragma.startsWith("ShellId ")) {
shellId = pragma.sliced(8).trimmed(); shellId = pragma.sliced(8).trimmed();
} else if (pragma.startsWith("DataDir ")) { } else if (pragma.startsWith("DataDir ")) {
pragmas.dataDir = pragma.sliced(8).trimmed(); pragmas.dataDir = pragma.sliced(8).trimmed();
} else if (pragma.startsWith("StateDir ")) { } else if (pragma.startsWith("StateDir ")) {
pragmas.stateDir = pragma.sliced(9).trimmed(); pragmas.stateDir = pragma.sliced(9).trimmed();
} else if (pragma.startsWith("CacheDir ")) {
pragmas.cacheDir = pragma.sliced(9).trimmed();
} else { } else {
qCritical() << "Unrecognized pragma" << pragma; qWarning() << "Unrecognized pragma" << pragma;
return -1;
} }
} else if (line.startsWith("import")) break; } else if (line.startsWith("import")) break;
} }
@ -125,21 +132,26 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
qInfo() << "Shell ID:" << shellId << "Path ID" << pathId; qInfo() << "Shell ID:" << shellId << "Path ID" << pathId;
auto launchTime = qs::Common::LAUNCH_TIME.toSecsSinceEpoch(); auto launchTime = qs::Common::LAUNCH_TIME.toSecsSinceEpoch();
auto appId = pragmas.appId.isEmpty() ? QStringLiteral("org.quickshell") : pragmas.appId;
InstanceInfo::CURRENT = InstanceInfo { InstanceInfo::CURRENT = InstanceInfo {
.instanceId = base36Encode(getpid()) + base36Encode(launchTime), .instanceId = base36Encode(getpid()) + base36Encode(launchTime),
.configPath = args.configPath, .configPath = args.configPath,
.shellId = shellId, .shellId = shellId,
.appId = appId,
.launchTime = qs::Common::LAUNCH_TIME, .launchTime = qs::Common::LAUNCH_TIME,
.pid = getpid(), .pid = getpid(),
.display = getDisplayConnection(),
}; };
#if CRASH_REPORTER #if CRASH_HANDLER
auto crashHandler = crash::CrashHandler(); if (qEnvironmentVariableIsSet("QS_DISABLE_CRASH_HANDLER")) {
crashHandler.init(); qInfo() << "Crash handling disabled.";
} else {
crash::CrashHandler::init();
{
auto* log = LogManager::instance(); auto* log = LogManager::instance();
crashHandler.setRelaunchInfo({ crash::CrashHandler::setRelaunchInfo({
.instance = InstanceInfo::CURRENT, .instance = InstanceInfo::CURRENT,
.noColor = !log->colorLogs, .noColor = !log->colorLogs,
.timestamp = log->timestampLogs, .timestamp = log->timestampLogs,
@ -150,7 +162,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
} }
#endif #endif
QsPaths::init(shellId, pathId, pragmas.dataDir, pragmas.stateDir); QsPaths::init(shellId, pathId, pragmas.dataDir, pragmas.stateDir, pragmas.cacheDir);
QsPaths::instance()->linkRunDir(); QsPaths::instance()->linkRunDir();
QsPaths::instance()->linkPathDir(); QsPaths::instance()->linkPathDir();
LogManager::initFs(); LogManager::initFs();
@ -166,6 +178,48 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
qputenv(var.toUtf8(), val.toUtf8()); qputenv(var.toUtf8(), val.toUtf8());
} }
pragmas.dropExpensiveFonts |= qEnvironmentVariableIntValue("QS_DROP_EXPENSIVE_FONTS") == 1;
if (pragmas.dropExpensiveFonts) {
if (auto* runDir = QsPaths::instance()->instanceRunDir()) {
auto baseConfigPath = qEnvironmentVariable("FONTCONFIG_FILE");
if (baseConfigPath.isEmpty()) baseConfigPath = "/etc/fonts/fonts.conf";
auto filterPath = runDir->filePath("fonts-override.conf");
auto filterFile = QFile(filterPath);
if (filterFile.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) {
auto filterTemplate = QStringLiteral(R"(<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<include ignore_missing="no">%1</include>
<selectfont>
<rejectfont>
<pattern>
<patelt name="fontwrapper">
<string>woff</string>
</patelt>
</pattern>
<pattern>
<patelt name="fontwrapper">
<string>woff2</string>
</patelt>
</pattern>
</rejectfont>
</selectfont>
</fontconfig>
)");
QTextStream(&filterFile) << filterTemplate.arg(baseConfigPath);
filterFile.close();
qputenv("FONTCONFIG_FILE", filterPath.toUtf8());
} else {
qCritical() << "Could not write fontconfig filter to" << filterPath;
}
} else {
qCritical() << "Could not create fontconfig filter: instance run directory unavailable";
}
}
// The qml engine currently refuses to cache non file (qsintercept) paths. // The qml engine currently refuses to cache non file (qsintercept) paths.
// if (auto* cacheDir = QsPaths::instance()->cacheDir()) { // if (auto* cacheDir = QsPaths::instance()->cacheDir()) {
@ -226,7 +280,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
app = new QGuiApplication(qArgC, argv); app = new QGuiApplication(qArgC, argv);
} }
QGuiApplication::setDesktopFileName("org.quickshell"); QGuiApplication::setDesktopFileName(appId);
if (args.debugPort != -1) { if (args.debugPort != -1) {
QQmlDebuggingEnabler::enableDebugging(true); QQmlDebuggingEnabler::enableDebugging(true);

View file

@ -50,6 +50,7 @@ struct CommandState {
QStringOption manifest; QStringOption manifest;
QStringOption name; QStringOption name;
bool newest = false; bool newest = false;
bool anyDisplay = false;
} config; } config;
struct { struct {
@ -73,6 +74,8 @@ struct CommandState {
CLI::App* show = nullptr; CLI::App* show = nullptr;
CLI::App* call = nullptr; CLI::App* call = nullptr;
CLI::App* getprop = nullptr; CLI::App* getprop = nullptr;
CLI::App* wait = nullptr;
CLI::App* listen = nullptr;
bool showOld = false; bool showOld = false;
QStringOption target; QStringOption target;
QStringOption name; QStringOption name;
@ -106,6 +109,8 @@ void exitDaemon(int code);
int parseCommand(int argc, char** argv, CommandState& state); int parseCommand(int argc, char** argv, CommandState& state);
int runCommand(int argc, char** argv, QCoreApplication* coreApplication); int runCommand(int argc, char** argv, QCoreApplication* coreApplication);
QString getDisplayConnection();
int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplication); int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplication);
} // namespace qs::launch } // namespace qs::launch

View file

@ -16,7 +16,7 @@
#include "build.hpp" #include "build.hpp"
#include "launch_p.hpp" #include "launch_p.hpp"
#if CRASH_REPORTER #if CRASH_HANDLER
#include "../crash/main.hpp" #include "../crash/main.hpp"
#endif #endif
@ -25,7 +25,7 @@ namespace qs::launch {
namespace { namespace {
void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) { void checkCrashRelaunch(char** argv, QCoreApplication* coreApplication) {
#if CRASH_REPORTER #if CRASH_HANDLER
auto lastInfoFdStr = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD"); auto lastInfoFdStr = qEnvironmentVariable("__QUICKSHELL_CRASH_INFO_FD");
if (!lastInfoFdStr.isEmpty()) { if (!lastInfoFdStr.isEmpty()) {
@ -84,27 +84,35 @@ void exitDaemon(int code) {
close(DAEMON_PIPE); close(DAEMON_PIPE);
close(STDIN_FILENO); auto fd = open("/dev/null", O_RDWR);
close(STDOUT_FILENO); if (fd == -1) {
close(STDERR_FILENO); qCritical().nospace() << "Failed to open /dev/null for daemon stdio" << errno << ": "
<< qt_error_string();
if (open("/dev/null", O_RDONLY) != STDIN_FILENO) { // NOLINT return;
qFatal() << "Failed to open /dev/null on stdin";
} }
if (open("/dev/null", O_WRONLY) != STDOUT_FILENO) { // NOLINT if (dup2(fd, STDIN_FILENO) != STDIN_FILENO) { // NOLINT
qFatal() << "Failed to open /dev/null on stdout"; qCritical().nospace() << "Failed to set daemon stdin to /dev/null" << errno << ": "
<< qt_error_string();
} }
if (open("/dev/null", O_WRONLY) != STDERR_FILENO) { // NOLINT if (dup2(fd, STDOUT_FILENO) != STDOUT_FILENO) { // NOLINT
qFatal() << "Failed to open /dev/null on stderr"; qCritical().nospace() << "Failed to set daemon stdout to /dev/null" << errno << ": "
<< qt_error_string();
} }
if (dup2(fd, STDERR_FILENO) != STDERR_FILENO) { // NOLINT
qCritical().nospace() << "Failed to set daemon stderr to /dev/null" << errno << ": "
<< qt_error_string();
}
close(fd);
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
QCoreApplication::setApplicationName("quickshell"); QCoreApplication::setApplicationName("quickshell");
#if CRASH_REPORTER #if CRASH_HANDLER
qsCheckCrash(argc, argv); qsCheckCrash(argc, argv);
#endif #endif

View file

@ -1,6 +1,7 @@
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <utility>
#include <CLI/App.hpp> #include <CLI/App.hpp>
#include <CLI/CLI.hpp> // NOLINT: Need to include this for impls of some CLI11 classes #include <CLI/CLI.hpp> // NOLINT: Need to include this for impls of some CLI11 classes
@ -16,7 +17,7 @@ int parseCommand(int argc, char** argv, CommandState& state) {
.argv = argv, .argv = argv,
}; };
auto addConfigSelection = [&](CLI::App* cmd, bool withNewestOption = false) { auto addConfigSelection = [&](CLI::App* cmd, bool filtering = false) {
auto* group = auto* group =
cmd->add_option_group("Config Selection") cmd->add_option_group("Config Selection")
->description( ->description(
@ -43,15 +44,23 @@ int parseCommand(int argc, char** argv, CommandState& state) {
->excludes(path); ->excludes(path);
group->add_option("-m,--manifest", state.config.manifest) group->add_option("-m,--manifest", state.config.manifest)
->description("[DEPRECATED] Path to a quickshell manifest.\n" ->description(
"[DEPRECATED] Path to a quickshell manifest.\n"
"If a manifest is specified, configs named by -c will point to its entries.\n" "If a manifest is specified, configs named by -c will point to its entries.\n"
"Defaults to $XDG_CONFIG_HOME/quickshell/manifest.conf") "Defaults to $XDG_CONFIG_HOME/quickshell/manifest.conf"
)
->envname("QS_MANIFEST") ->envname("QS_MANIFEST")
->excludes(path); ->excludes(path);
if (withNewestOption) { if (filtering) {
group->add_flag("-n,--newest", state.config.newest) group->add_flag("-n,--newest", state.config.newest)
->description("Operate on the most recently launched instance instead of the oldest"); ->description("Operate on the most recently launched instance instead of the oldest");
group->add_flag("--any-display", state.config.anyDisplay)
->description(
"If passed, instances will not be filtered by the display connection they "
"were launched on."
);
} }
return group; return group;
@ -75,9 +84,11 @@ int parseCommand(int argc, char** argv, CommandState& state) {
auto* group = noGroup ? cmd : cmd->add_option_group(noDisplay ? "" : "Logging"); auto* group = noGroup ? cmd : cmd->add_option_group(noDisplay ? "" : "Logging");
group->add_flag("--no-color", state.log.noColor) group->add_flag("--no-color", state.log.noColor)
->description("Disables colored logging.\n" ->description(
"Disables colored logging.\n"
"Colored logging can also be disabled by specifying a non empty value " "Colored logging can also be disabled by specifying a non empty value "
"for the NO_COLOR environment variable."); "for the NO_COLOR environment variable."
);
group->add_flag("--log-times", state.log.timestamp) group->add_flag("--log-times", state.log.timestamp)
->description("Log timestamps with each message."); ->description("Log timestamps with each message.");
@ -86,9 +97,11 @@ int parseCommand(int argc, char** argv, CommandState& state) {
->description("Log rules to apply, in the format of QT_LOGGING_RULES."); ->description("Log rules to apply, in the format of QT_LOGGING_RULES.");
group->add_flag("-v,--verbose", [&](size_t count) { state.log.verbosity = count; }) group->add_flag("-v,--verbose", [&](size_t count) { state.log.verbosity = count; })
->description("Increases log verbosity.\n" ->description(
"Increases log verbosity.\n"
"-v will show INFO level internal logs.\n" "-v will show INFO level internal logs.\n"
"-vv will show DEBUG level internal logs."); "-vv will show DEBUG level internal logs."
);
auto* hgroup = cmd->add_option_group(""); auto* hgroup = cmd->add_option_group("");
hgroup->add_flag("--no-detailed-logs", state.log.sparse); hgroup->add_flag("--no-detailed-logs", state.log.sparse);
@ -98,9 +111,11 @@ int parseCommand(int argc, char** argv, CommandState& state) {
auto* group = cmd->add_option_group("Instance Selection"); auto* group = cmd->add_option_group("Instance Selection");
group->add_option("-i,--id", state.instance.id) group->add_option("-i,--id", state.instance.id)
->description("The instance id to operate on.\n" ->description(
"The instance id to operate on.\n"
"You may also use a substring the id as long as it is unique, " "You may also use a substring the id as long as it is unique, "
"for example \"abc\" will select \"abcdefg\"."); "for example \"abc\" will select \"abcdefg\"."
);
group->add_option("--pid", state.instance.pid) group->add_option("--pid", state.instance.pid)
->description("The process id of the instance to operate on."); ->description("The process id of the instance to operate on.");
@ -157,9 +172,11 @@ int parseCommand(int argc, char** argv, CommandState& state) {
auto* sub = cli->add_subcommand("list", "List running quickshell instances."); auto* sub = cli->add_subcommand("list", "List running quickshell instances.");
auto* all = sub->add_flag("-a,--all", state.instance.all) auto* all = sub->add_flag("-a,--all", state.instance.all)
->description("List all instances.\n" ->description(
"List all instances.\n"
"If unspecified, only instances of" "If unspecified, only instances of"
"the selected config will be listed."); "the selected config will be listed."
);
sub->add_flag("-j,--json", state.output.json, "Output the list as a json."); sub->add_flag("-j,--json", state.output.json, "Output the list as a json.");
@ -210,6 +227,16 @@ int parseCommand(int argc, char** argv, CommandState& state) {
->allow_extra_args(); ->allow_extra_args();
} }
auto signalCmd = [&](std::string cmd, std::string desc) {
auto* scmd = sub->add_subcommand(std::move(cmd), std::move(desc));
scmd->add_option("target", state.ipc.target, "The target to listen on.");
scmd->add_option("signal", state.ipc.name, "The signal to listen for.");
return scmd;
};
state.ipc.wait = signalCmd("wait", "Wait for one IpcHandler signal.");
state.ipc.listen = signalCmd("listen", "Listen for IpcHandler signals.");
{ {
auto* prop = auto* prop =
sub->add_subcommand("prop", "Manipulate IpcHandler properties.")->require_subcommand(); sub->add_subcommand("prop", "Manipulate IpcHandler properties.")->require_subcommand();
@ -235,8 +262,10 @@ int parseCommand(int argc, char** argv, CommandState& state) {
->allow_extra_args(); ->allow_extra_args();
sub->add_flag("-s,--show", state.ipc.showOld) sub->add_flag("-s,--show", state.ipc.showOld)
->description("Print information about a function or target if given, or all available " ->description(
"targets if not."); "Print information about a function or target if given, or all available "
"targets if not."
);
auto* instance = addInstanceSelection(sub); auto* instance = addInstanceSelection(sub);
addConfigSelection(sub, true)->excludes(instance); addConfigSelection(sub, true)->excludes(instance);

View file

@ -0,0 +1,25 @@
add_subdirectory(nm)
qt_add_library(quickshell-network STATIC
network.cpp
device.cpp
wifi.cpp
enums.cpp
)
target_include_directories(quickshell-network PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)
qt_add_qml_module(quickshell-network
URI Quickshell.Networking
VERSION 0.1
DEPENDENCIES QtQml
)
qs_add_module_deps_light(quickshell-network Quickshell)
install_qml_module(quickshell-network)
target_link_libraries(quickshell-network PRIVATE quickshell-network-nm Qt::Qml Qt::DBus)
qs_add_link_dependencies(quickshell-network quickshell-dbus)
target_link_libraries(quickshell PRIVATE quickshell-networkplugin)
qs_module_pch(quickshell-network SET dbus)

48
src/network/device.cpp Normal file
View file

@ -0,0 +1,48 @@
#include "device.hpp"
#include <qdebug.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qobject.h>
#include <qstring.h>
#include <qtmetamacros.h>
#include "../core/logcat.hpp"
#include "enums.hpp"
namespace qs::network {
namespace {
QS_LOGGING_CATEGORY(logNetworkDevice, "quickshell.network.device", QtWarningMsg);
} // namespace
NetworkDevice::NetworkDevice(DeviceType::Enum type, QObject* parent): QObject(parent), mType(type) {
this->bindableConnected().setBinding([this]() {
return this->bState == ConnectionState::Connected;
});
};
void NetworkDevice::setAutoconnect(bool autoconnect) {
if (this->bAutoconnect == autoconnect) return;
emit this->requestSetAutoconnect(autoconnect);
}
void NetworkDevice::setNmManaged(bool managed) {
if (this->bNmManaged == managed) return;
emit this->requestSetNmManaged(managed);
}
void NetworkDevice::disconnect() {
if (this->bState == ConnectionState::Disconnected) {
qCCritical(logNetworkDevice) << "Device" << this << "is already disconnected";
return;
}
if (this->bState == ConnectionState::Disconnecting) {
qCCritical(logNetworkDevice) << "Device" << this << "is already disconnecting";
return;
}
qCDebug(logNetworkDevice) << "Disconnecting from device" << this;
this->requestDisconnect();
}
} // namespace qs::network

84
src/network/device.hpp Normal file
View file

@ -0,0 +1,84 @@
#pragma once
#include <qobject.h>
#include <qproperty.h>
#include <qqmlintegration.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include "../core/doc.hpp"
#include "enums.hpp"
namespace qs::network {
///! A network device.
/// The @@type property may be used to determine if this device is a @@WifiDevice.
class NetworkDevice: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_UNCREATABLE("Devices can only be acquired through Network");
// clang-format off
/// The device type.
///
/// When the device type is `Wifi`, the device object is a @@WifiDevice which exposes wifi network
/// connection and scanning.
Q_PROPERTY(DeviceType::Enum type READ type CONSTANT);
/// The name of the device's control interface.
Q_PROPERTY(QString name READ name NOTIFY nameChanged BINDABLE bindableName);
/// The hardware address of the device in the XX:XX:XX:XX:XX:XX format.
Q_PROPERTY(QString address READ default NOTIFY addressChanged BINDABLE bindableAddress);
/// True if the device is connected.
Q_PROPERTY(bool connected READ default NOTIFY connectedChanged BINDABLE bindableConnected);
/// Connection state of the device.
Q_PROPERTY(qs::network::ConnectionState::Enum state READ default NOTIFY stateChanged BINDABLE bindableState);
/// True if the device is managed by NetworkManager.
///
/// > [!WARNING] Only valid for the NetworkManager backend.
Q_PROPERTY(bool nmManaged READ nmManaged WRITE setNmManaged NOTIFY nmManagedChanged)
/// True if the device is allowed to autoconnect to a network.
Q_PROPERTY(bool autoconnect READ autoconnect WRITE setAutoconnect NOTIFY autoconnectChanged);
// clang-format on
public:
explicit NetworkDevice(DeviceType::Enum type, QObject* parent = nullptr);
/// Disconnects the device and prevents it from automatically activating further connections.
Q_INVOKABLE void disconnect();
[[nodiscard]] DeviceType::Enum type() const { return this->mType; }
QBindable<QString> bindableName() { return &this->bName; }
[[nodiscard]] QString name() const { return this->bName; }
QBindable<QString> bindableAddress() { return &this->bAddress; }
QBindable<bool> bindableConnected() { return &this->bConnected; }
QBindable<ConnectionState::Enum> bindableState() { return &this->bState; }
QBindable<bool> bindableNmManaged() { return &this->bNmManaged; }
[[nodiscard]] bool nmManaged() { return this->bNmManaged; }
void setNmManaged(bool managed);
QBindable<bool> bindableAutoconnect() { return &this->bAutoconnect; }
[[nodiscard]] bool autoconnect() { return this->bAutoconnect; }
void setAutoconnect(bool autoconnect);
signals:
QSDOC_HIDE void requestDisconnect();
QSDOC_HIDE void requestSetAutoconnect(bool autoconnect);
QSDOC_HIDE void requestSetNmManaged(bool managed);
void nameChanged();
void addressChanged();
void connectedChanged();
void stateChanged();
void nmManagedChanged();
void autoconnectChanged();
private:
DeviceType::Enum mType;
// clang-format off
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, QString, bName, &NetworkDevice::nameChanged);
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, QString, bAddress, &NetworkDevice::addressChanged);
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, bool, bConnected, &NetworkDevice::connectedChanged);
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, ConnectionState::Enum, bState, &NetworkDevice::stateChanged);
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, bool, bNmManaged, &NetworkDevice::nmManagedChanged);
Q_OBJECT_BINDABLE_PROPERTY(NetworkDevice, bool, bAutoconnect, &NetworkDevice::autoconnectChanged);
// clang-format on
};
} // namespace qs::network

86
src/network/enums.cpp Normal file
View file

@ -0,0 +1,86 @@
#include "enums.hpp"
#include <qstring.h>
namespace qs::network {
QString NetworkConnectivity::toString(NetworkConnectivity::Enum conn) {
switch (conn) {
case Unknown: return QStringLiteral("Unknown");
case None: return QStringLiteral("Not connected to a network");
case Portal: return QStringLiteral("Connection intercepted by a captive portal");
case Limited: return QStringLiteral("Partial internet connectivity");
case Full: return QStringLiteral("Full internet connectivity");
default: return QStringLiteral("Unknown");
}
}
QString NetworkBackendType::toString(NetworkBackendType::Enum type) {
switch (type) {
case NetworkBackendType::None: return "None";
case NetworkBackendType::NetworkManager: return "NetworkManager";
default: return "Unknown";
}
}
QString ConnectionState::toString(ConnectionState::Enum state) {
switch (state) {
case Unknown: return QStringLiteral("Unknown");
case Connecting: return QStringLiteral("Connecting");
case Connected: return QStringLiteral("Connected");
case Disconnecting: return QStringLiteral("Disconnecting");
case Disconnected: return QStringLiteral("Disconnected");
default: return QStringLiteral("Unknown");
}
}
QString ConnectionFailReason::toString(ConnectionFailReason::Enum reason) {
switch (reason) {
case Unknown: return QStringLiteral("Unknown");
case NoSecrets: return QStringLiteral("Secrets were required but not provided");
case WifiClientDisconnected: return QStringLiteral("Wi-Fi supplicant diconnected");
case WifiClientFailed: return QStringLiteral("Wi-Fi supplicant failed");
case WifiAuthTimeout: return QStringLiteral("Wi-Fi connection took too long to authenticate");
case WifiNetworkLost: return QStringLiteral("Wi-Fi network could not be found");
default: return QStringLiteral("Unknown");
}
}
QString DeviceType::toString(DeviceType::Enum type) {
switch (type) {
case None: return QStringLiteral("None");
case Wifi: return QStringLiteral("Wifi");
default: return QStringLiteral("Unknown");
}
}
QString WifiSecurityType::toString(WifiSecurityType::Enum type) {
switch (type) {
case Unknown: return QStringLiteral("Unknown");
case Wpa3SuiteB192: return QStringLiteral("WPA3 Suite B 192-bit");
case Sae: return QStringLiteral("WPA3");
case Wpa2Eap: return QStringLiteral("WPA2 Enterprise");
case Wpa2Psk: return QStringLiteral("WPA2");
case WpaEap: return QStringLiteral("WPA Enterprise");
case WpaPsk: return QStringLiteral("WPA");
case StaticWep: return QStringLiteral("WEP");
case DynamicWep: return QStringLiteral("Dynamic WEP");
case Leap: return QStringLiteral("LEAP");
case Owe: return QStringLiteral("OWE");
case Open: return QStringLiteral("Open");
default: return QStringLiteral("Unknown");
}
}
QString WifiDeviceMode::toString(WifiDeviceMode::Enum mode) {
switch (mode) {
case Unknown: return QStringLiteral("Unknown");
case AdHoc: return QStringLiteral("Ad-Hoc");
case Station: return QStringLiteral("Station");
case AccessPoint: return QStringLiteral("Access Point");
case Mesh: return QStringLiteral("Mesh");
default: return QStringLiteral("Unknown");
};
}
} // namespace qs::network

154
src/network/enums.hpp Normal file
View file

@ -0,0 +1,154 @@
#pragma once
#include <qobject.h>
#include <qqmlintegration.h>
#include <qtypes.h>
namespace qs::network {
///! The degree to which the host can reach the internet.
class NetworkConnectivity: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
/// Network connectivity is unknown. This means the connectivity checks are disabled or have not run yet.
Unknown = 0,
/// The host is not connected to any network.
None = 1,
/// The internet connection is hijacked by a captive portal gateway.
/// This indicates the shell should open a sandboxed web browser window for the purpose of authenticating to a gateway.
Portal = 2,
/// The host is connected to a network but does not appear to be able to reach the full internet.
Limited = 3,
/// The host is connected to a network and appears to be able to reach the full internet.
Full = 4,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(NetworkConnectivity::Enum conn);
};
///! The backend supplying the Network service.
class NetworkBackendType: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
None = 0,
NetworkManager = 1,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(NetworkBackendType::Enum type);
};
///! The connection state of a device or network.
class ConnectionState: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
Unknown = 0,
Connecting = 1,
Connected = 2,
Disconnecting = 3,
Disconnected = 4,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(ConnectionState::Enum state);
};
///! The reason a connection failed.
class ConnectionFailReason: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
/// The connection failed for an unknown reason.
Unknown = 0,
/// Secrets were required, but not provided.
NoSecrets = 1,
/// The Wi-Fi supplicant disconnected.
WifiClientDisconnected = 2,
/// The Wi-Fi supplicant failed.
WifiClientFailed = 3,
/// The Wi-Fi connection took too long to authenticate.
WifiAuthTimeout = 4,
/// The Wi-Fi network could not be found.
WifiNetworkLost = 5,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(ConnectionFailReason::Enum reason);
};
///! Type of a @@NetworkDevice.
class DeviceType: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
None = 0,
Wifi = 1,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(DeviceType::Enum type);
};
///! The security type of a @@WifiNetwork.
class WifiSecurityType: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
Wpa3SuiteB192 = 0,
Sae = 1,
Wpa2Eap = 2,
Wpa2Psk = 3,
WpaEap = 4,
WpaPsk = 5,
StaticWep = 6,
DynamicWep = 7,
Leap = 8,
Owe = 9,
Open = 10,
Unknown = 11,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(WifiSecurityType::Enum type);
};
///! The 802.11 mode of a @@WifiDevice.
class WifiDeviceMode: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_SINGLETON;
public:
enum Enum : quint8 {
/// The device is part of an Ad-Hoc network without a central access point.
AdHoc = 0,
/// The device is a station that can connect to networks.
Station = 1,
/// The device is a local hotspot/access point.
AccessPoint = 2,
/// The device is an 802.11s mesh point.
Mesh = 3,
/// The device mode is unknown.
Unknown = 4,
};
Q_ENUM(Enum);
Q_INVOKABLE static QString toString(WifiDeviceMode::Enum mode);
};
} // namespace qs::network

15
src/network/module.md Normal file
View file

@ -0,0 +1,15 @@
name = "Quickshell.Networking"
description = "Network API"
headers = [
"network.hpp",
"device.hpp",
"wifi.hpp",
"enums.hpp",
"nm/settings.hpp",
]
-----
This module exposes Network management APIs provided by a supported network backend.
For now, the only backend available is the NetworkManager DBus interface.
Both DBus and NetworkManager must be running to use it.
See the @@Quickshell.Networking.Networking singleton.

131
src/network/network.cpp Normal file
View file

@ -0,0 +1,131 @@
#include "network.hpp"
#include <utility>
#include <qdebug.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qobject.h>
#include <qstring.h>
#include <qtmetamacros.h>
#include "../core/logcat.hpp"
#include "device.hpp"
#include "enums.hpp"
#include "nm/backend.hpp"
#include "nm/settings.hpp"
namespace qs::network {
namespace {
QS_LOGGING_CATEGORY(logNetwork, "quickshell.network", QtWarningMsg);
} // namespace
Networking::Networking(QObject* parent): QObject(parent) {
// Try to create the NetworkManager backend and bind to it.
auto* nm = new NetworkManager(this);
if (nm->isAvailable()) {
// clang-format off
QObject::connect(nm, &NetworkManager::deviceAdded, this, &Networking::deviceAdded);
QObject::connect(nm, &NetworkManager::deviceRemoved, this, &Networking::deviceRemoved);
QObject::connect(this, &Networking::requestSetWifiEnabled, nm, &NetworkManager::setWifiEnabled);
QObject::connect(this, &Networking::requestSetConnectivityCheckEnabled, nm, &NetworkManager::setConnectivityCheckEnabled);
QObject::connect(this, &Networking::requestCheckConnectivity, nm, &NetworkManager::checkConnectivity);
this->bindableWifiEnabled().setBinding([nm]() { return nm->wifiEnabled(); });
this->bindableWifiHardwareEnabled().setBinding([nm]() { return nm->wifiHardwareEnabled(); });
this->bindableCanCheckConnectivity().setBinding([nm]() { return nm->connectivityCheckAvailable(); });
this->bindableConnectivityCheckEnabled().setBinding([nm]() { return nm->connectivityCheckEnabled(); });
this->bindableConnectivity().setBinding([nm]() { return static_cast<NetworkConnectivity::Enum>(nm->connectivity()); });
// clang-format on
this->mBackend = nm;
this->mBackendType = NetworkBackendType::NetworkManager;
return;
} else {
delete nm;
}
qCCritical(logNetwork) << "Network will not work. Could not find an available backend.";
}
Networking* Networking::instance() {
static Networking* instance = new Networking(); // NOLINT
return instance;
}
void Networking::deviceAdded(NetworkDevice* dev) { this->mDevices.insertObject(dev); }
void Networking::deviceRemoved(NetworkDevice* dev) { this->mDevices.removeObject(dev); }
void Networking::checkConnectivity() {
if (!this->bConnectivityCheckEnabled || !this->bCanCheckConnectivity) return;
emit this->requestCheckConnectivity();
}
void Networking::setWifiEnabled(bool enabled) {
if (this->bWifiEnabled == enabled) return;
emit this->requestSetWifiEnabled(enabled);
}
void Networking::setConnectivityCheckEnabled(bool enabled) {
if (this->bConnectivityCheckEnabled == enabled) return;
emit this->requestSetConnectivityCheckEnabled(enabled);
}
NetworkingQml::NetworkingQml(QObject* parent): QObject(parent) {
// clang-format off
QObject::connect(Networking::instance(), &Networking::wifiEnabledChanged, this, &NetworkingQml::wifiEnabledChanged);
QObject::connect(Networking::instance(), &Networking::wifiHardwareEnabledChanged, this, &NetworkingQml::wifiHardwareEnabledChanged);
QObject::connect(Networking::instance(), &Networking::canCheckConnectivityChanged, this, &NetworkingQml::canCheckConnectivityChanged);
QObject::connect(Networking::instance(), &Networking::connectivityCheckEnabledChanged, this, &NetworkingQml::connectivityCheckEnabledChanged);
QObject::connect(Networking::instance(), &Networking::connectivityChanged, this, &NetworkingQml::connectivityChanged);
// clang-format on
}
void NetworkingQml::checkConnectivity() { Networking::instance()->checkConnectivity(); }
Network::Network(QString name, QObject* parent): QObject(parent), mName(std::move(name)) {
this->bStateChanging.setBinding([this] {
auto state = this->bState.value();
return state == ConnectionState::Connecting || state == ConnectionState::Disconnecting;
});
};
void Network::connect() {
if (this->bConnected) {
qCCritical(logNetwork) << this << "is already connected.";
return;
}
this->requestConnect();
}
void Network::connectWithSettings(NMSettings* settings) {
if (this->bConnected) {
qCCritical(logNetwork) << this << "is already connected.";
return;
}
if (this->bNmSettings.value().indexOf(settings) == -1) return;
this->requestConnectWithSettings(settings);
}
void Network::disconnect() {
if (!this->bConnected) {
qCCritical(logNetwork) << this << "is not currently connected";
return;
}
this->requestDisconnect();
}
void Network::forget() { this->requestForget(); }
void Network::settingsAdded(NMSettings* settings) {
auto list = this->bNmSettings.value();
if (list.contains(settings)) return;
list.append(settings);
this->bNmSettings = list;
}
void Network::settingsRemoved(NMSettings* settings) {
auto list = this->bNmSettings.value();
list.removeOne(settings);
this->bNmSettings = list;
}
} // namespace qs::network

233
src/network/network.hpp Normal file
View file

@ -0,0 +1,233 @@
#pragma once
#include <qobject.h>
#include <qproperty.h>
#include <qqmlintegration.h>
#include <qtmetamacros.h>
#include <qtypes.h>
#include "../core/doc.hpp"
#include "../core/model.hpp"
#include "device.hpp"
#include "enums.hpp"
#include "nm/settings.hpp"
namespace qs::network {
class NetworkBackend: public QObject {
Q_OBJECT;
public:
[[nodiscard]] virtual bool isAvailable() const = 0;
protected:
explicit NetworkBackend(QObject* parent = nullptr): QObject(parent) {};
};
class Networking: public QObject {
Q_OBJECT;
public:
static Networking* instance();
void checkConnectivity();
[[nodiscard]] ObjectModel<NetworkDevice>* devices() { return &this->mDevices; }
[[nodiscard]] NetworkBackendType::Enum backend() const { return this->mBackendType; }
QBindable<bool> bindableWifiEnabled() { return &this->bWifiEnabled; }
[[nodiscard]] bool wifiEnabled() const { return this->bWifiEnabled; }
void setWifiEnabled(bool enabled);
QBindable<bool> bindableWifiHardwareEnabled() { return &this->bWifiHardwareEnabled; }
QBindable<bool> bindableCanCheckConnectivity() { return &this->bCanCheckConnectivity; }
QBindable<bool> bindableConnectivityCheckEnabled() { return &this->bConnectivityCheckEnabled; }
[[nodiscard]] bool connectivityCheckEnabled() const { return this->bConnectivityCheckEnabled; }
void setConnectivityCheckEnabled(bool enabled);
QBindable<NetworkConnectivity::Enum> bindableConnectivity() { return &this->bConnectivity; }
signals:
void requestSetWifiEnabled(bool enabled);
void requestSetConnectivityCheckEnabled(bool enabled);
void requestCheckConnectivity();
void wifiEnabledChanged();
void wifiHardwareEnabledChanged();
void canCheckConnectivityChanged();
void connectivityCheckEnabledChanged();
void connectivityChanged();
private slots:
void deviceAdded(NetworkDevice* dev);
void deviceRemoved(NetworkDevice* dev);
private:
explicit Networking(QObject* parent = nullptr);
ObjectModel<NetworkDevice> mDevices {this};
NetworkBackend* mBackend = nullptr;
NetworkBackendType::Enum mBackendType = NetworkBackendType::None;
// clang-format off
Q_OBJECT_BINDABLE_PROPERTY(Networking, bool, bWifiEnabled, &Networking::wifiEnabledChanged);
Q_OBJECT_BINDABLE_PROPERTY(Networking, bool, bWifiHardwareEnabled, &Networking::wifiHardwareEnabledChanged);
Q_OBJECT_BINDABLE_PROPERTY(Networking, bool, bCanCheckConnectivity, &Networking::canCheckConnectivityChanged);
Q_OBJECT_BINDABLE_PROPERTY(Networking, bool, bConnectivityCheckEnabled, &Networking::connectivityCheckEnabledChanged);
Q_OBJECT_BINDABLE_PROPERTY(Networking, NetworkConnectivity::Enum, bConnectivity, &Networking::connectivityChanged);
// clang-format on
};
///! The Network service.
/// An interface to a network backend (currently only NetworkManager),
/// which can be used to view, configure, and connect to various networks.
class NetworkingQml: public QObject {
Q_OBJECT;
QML_NAMED_ELEMENT(Networking);
QML_SINGLETON;
// clang-format off
/// A list of all network devices. Networks are exposed through their respective devices.
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::network::NetworkDevice>*);
Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT);
/// The backend being used to power the Network service.
Q_PROPERTY(qs::network::NetworkBackendType::Enum backend READ backend CONSTANT);
/// Switch for the rfkill software block of all wireless devices.
Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setWifiEnabled NOTIFY wifiEnabledChanged);
/// State of the rfkill hardware block of all wireless devices.
Q_PROPERTY(bool wifiHardwareEnabled READ default NOTIFY wifiHardwareEnabledChanged BINDABLE bindableWifiHardwareEnabled);
/// True if the @@backend supports connectivity checks.
Q_PROPERTY(bool canCheckConnectivity READ default NOTIFY canCheckConnectivityChanged BINDABLE bindableCanCheckConnectivity);
/// True if connectivity checking is enabled.
Q_PROPERTY(bool connectivityCheckEnabled READ connectivityCheckEnabled WRITE setConnectivityCheckEnabled NOTIFY connectivityCheckEnabledChanged);
/// The result of the last connectivity check.
///
/// Connectivity checks may require additional configuration depending on your distro.
///
/// > [!NOTE] This property can be used to determine if network access is restricted
/// > or gated behind a captive portal.
/// >
/// > If checking for captive portals, @@checkConnectivity() should be called after
/// > the portal is dismissed to update this property.
Q_PROPERTY(qs::network::NetworkConnectivity::Enum connectivity READ default NOTIFY connectivityChanged BINDABLE bindableConnectivity);
// clang-format on
public:
explicit NetworkingQml(QObject* parent = nullptr);
/// Re-check the network connectivity state immediately.
/// > [!NOTE] This should be invoked after a user dismisses a web browser that was opened to authenticate via a captive portal.
Q_INVOKABLE static void checkConnectivity();
[[nodiscard]] static ObjectModel<NetworkDevice>* devices() {
return Networking::instance()->devices();
}
[[nodiscard]] static NetworkBackendType::Enum backend() {
return Networking::instance()->backend();
}
[[nodiscard]] static bool wifiEnabled() { return Networking::instance()->wifiEnabled(); }
static void setWifiEnabled(bool enabled) { Networking::instance()->setWifiEnabled(enabled); }
[[nodiscard]] static QBindable<bool> bindableWifiHardwareEnabled() {
return Networking::instance()->bindableWifiHardwareEnabled();
}
[[nodiscard]] static QBindable<bool> bindableWifiEnabled() {
return Networking::instance()->bindableWifiEnabled();
}
[[nodiscard]] static QBindable<bool> bindableCanCheckConnectivity() {
return Networking::instance()->bindableCanCheckConnectivity();
}
[[nodiscard]] static bool connectivityCheckEnabled() {
return Networking::instance()->connectivityCheckEnabled();
}
static void setConnectivityCheckEnabled(bool enabled) {
Networking::instance()->setConnectivityCheckEnabled(enabled);
}
[[nodiscard]] static QBindable<NetworkConnectivity::Enum> bindableConnectivity() {
return Networking::instance()->bindableConnectivity();
}
signals:
void wifiEnabledChanged();
void wifiHardwareEnabledChanged();
void canCheckConnectivityChanged();
void connectivityCheckEnabledChanged();
void connectivityChanged();
};
///! A network.
/// A network. Networks derived from a @@WifiDevice are @@WifiNetwork instances.
class Network: public QObject {
Q_OBJECT;
QML_ELEMENT;
QML_UNCREATABLE("Network can only be aqcuired through networking devices");
// clang-format off
/// The name of the network.
Q_PROPERTY(QString name READ name CONSTANT);
/// A list of NetworkManager connnection settings profiles for this network.
///
/// > [!WARNING] Only valid for the NetworkManager backend.
Q_PROPERTY(QList<NMSettings*> nmSettings READ nmSettings NOTIFY nmSettingsChanged BINDABLE bindableNmSettings);
/// True if the network is connected.
Q_PROPERTY(bool connected READ default NOTIFY connectedChanged BINDABLE bindableConnected);
/// True if the wifi network has known connection settings saved.
Q_PROPERTY(bool known READ default NOTIFY knownChanged BINDABLE bindableKnown);
/// The connectivity state of the network.
Q_PROPERTY(ConnectionState::Enum state READ default NOTIFY stateChanged BINDABLE bindableState);
/// If the network is currently connecting or disconnecting. Shorthand for checking @@state.
Q_PROPERTY(bool stateChanging READ default NOTIFY stateChangingChanged BINDABLE bindableStateChanging);
// clang-format on
public:
explicit Network(QString name, QObject* parent = nullptr);
/// Attempt to connect to the network.
///
/// > [!NOTE] If the network is a @@WifiNetwork and requires secrets, a @@connectionFailed(s)
/// > signal will be emitted with `NoSecrets`.
/// > @@WifiNetwork.connectWithPsk() can be used to provide secrets.
Q_INVOKABLE void connect();
/// Attempt to connect to the network with a specific @@nmSettings entry.
///
/// > [!WARNING] Only valid for the NetworkManager backend.
Q_INVOKABLE void connectWithSettings(NMSettings* settings);
/// Disconnect from the network.
Q_INVOKABLE void disconnect();
/// Forget all connection settings for this network.
Q_INVOKABLE void forget();
void settingsAdded(NMSettings* settings);
void settingsRemoved(NMSettings* settings);
// clang-format off
[[nodiscard]] QString name() const { return this->mName; }
[[nodiscard]] const QList<NMSettings*>& nmSettings() const { return this->bNmSettings; }
QBindable<QList<NMSettings*>> bindableNmSettings() const { return &this->bNmSettings; }
QBindable<bool> bindableConnected() { return &this->bConnected; }
QBindable<bool> bindableKnown() { return &this->bKnown; }
[[nodiscard]] ConnectionState::Enum state() const { return this->bState; }
QBindable<ConnectionState::Enum> bindableState() { return &this->bState; }
QBindable<bool> bindableStateChanging() { return &this->bStateChanging; }
// clang-format on
signals:
/// Signals that a connection to the network has failed because of the given @@ConnectionFailReason.
void connectionFailed(ConnectionFailReason::Enum reason);
void connectedChanged();
void knownChanged();
void stateChanged();
void stateChangingChanged();
void nmSettingsChanged();
QSDOC_HIDE void requestConnect();
QSDOC_HIDE void requestConnectWithSettings(NMSettings* settings);
QSDOC_HIDE void requestDisconnect();
QSDOC_HIDE void requestForget();
protected:
QString mName;
// clang-format off
Q_OBJECT_BINDABLE_PROPERTY(Network, bool, bConnected, &Network::connectedChanged);
Q_OBJECT_BINDABLE_PROPERTY(Network, bool, bKnown, &Network::knownChanged);
Q_OBJECT_BINDABLE_PROPERTY(Network, ConnectionState::Enum, bState, &Network::stateChanged);
Q_OBJECT_BINDABLE_PROPERTY(Network, bool, bStateChanging, &Network::stateChangingChanged);
Q_OBJECT_BINDABLE_PROPERTY(Network, QList<NMSettings*>, bNmSettings, &Network::nmSettingsChanged);
// clang-format on
};
} // namespace qs::network

View file

@ -0,0 +1,81 @@
set_source_files_properties(org.freedesktop.NetworkManager.xml PROPERTIES
CLASSNAME DBusNetworkManagerProxy
NO_NAMESPACE TRUE
INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/dbus_types.hpp
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.xml
dbus_nm_backend
)
set_source_files_properties(org.freedesktop.NetworkManager.Device.xml PROPERTIES
CLASSNAME DBusNMDeviceProxy
NO_NAMESPACE TRUE
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.Device.xml
dbus_nm_device
)
set_source_files_properties(org.freedesktop.NetworkManager.Device.Wireless.xml PROPERTIES
CLASSNAME DBusNMWirelessProxy
NO_NAMESPACE TRUE
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.Device.Wireless.xml
dbus_nm_wireless
)
set_source_files_properties(org.freedesktop.NetworkManager.AccessPoint.xml PROPERTIES
CLASSNAME DBusNMAccessPointProxy
NO_NAMESPACE TRUE
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.AccessPoint.xml
dbus_nm_accesspoint
)
set_source_files_properties(org.freedesktop.NetworkManager.Settings.Connection.xml PROPERTIES
CLASSNAME DBusNMConnectionSettingsProxy
NO_NAMESPACE TRUE
INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/dbus_types.hpp
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.Settings.Connection.xml
dbus_nm_connection_settings
)
set_source_files_properties(org.freedesktop.NetworkManager.Connection.Active.xml PROPERTIES
CLASSNAME DBusNMActiveConnectionProxy
NO_NAMESPACE TRUE
)
qt_add_dbus_interface(NM_DBUS_INTERFACES
org.freedesktop.NetworkManager.Connection.Active.xml
dbus_nm_active_connection
)
qt_add_library(quickshell-network-nm STATIC
backend.cpp
device.cpp
active_connection.cpp
settings.cpp
accesspoint.cpp
wireless.cpp
utils.cpp
dbus_types.cpp
enums.hpp
${NM_DBUS_INTERFACES}
)
target_include_directories(quickshell-network-nm PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(quickshell-network-nm PRIVATE Qt::Qml Qt::DBus)
qs_add_link_dependencies(quickshell-network-nm quickshell-dbus)

View file

@ -0,0 +1,71 @@
#include "accesspoint.hpp"
#include <qdbusconnection.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qnamespace.h>
#include <qobject.h>
#include <qstring.h>
#include <qtypes.h>
#include "../../core/logcat.hpp"
#include "../../dbus/properties.hpp"
#include "dbus_nm_accesspoint.h"
#include "enums.hpp"
namespace qs::network {
using namespace qs::dbus;
namespace {
QS_LOGGING_CATEGORY(logNetworkManager, "quickshell.network.networkmanager", QtWarningMsg);
}
NMAccessPoint::NMAccessPoint(const QString& path, QObject* parent): QObject(parent) {
this->proxy = new DBusNMAccessPointProxy(
"org.freedesktop.NetworkManager",
path,
QDBusConnection::systemBus(),
this
);
if (!this->proxy->isValid()) {
qCWarning(logNetworkManager) << "Cannot create DBus interface for access point at" << path;
return;
}
QObject::connect(
&this->accessPointProperties,
&DBusPropertyGroup::getAllFinished,
this,
&NMAccessPoint::loaded,
Qt::SingleShotConnection
);
this->accessPointProperties.setInterface(this->proxy);
this->accessPointProperties.updateAllViaGetAll();
}
bool NMAccessPoint::isValid() const { return this->proxy && this->proxy->isValid(); }
QString NMAccessPoint::address() const { return this->proxy ? this->proxy->service() : QString(); }
QString NMAccessPoint::path() const { return this->proxy ? this->proxy->path() : QString(); }
} // namespace qs::network
namespace qs::dbus {
DBusResult<qs::network::NM80211ApFlags::Enum>
DBusDataTransform<qs::network::NM80211ApFlags::Enum>::fromWire(quint32 wire) {
return DBusResult(static_cast<qs::network::NM80211ApFlags::Enum>(wire));
}
DBusResult<qs::network::NM80211ApSecurityFlags::Enum>
DBusDataTransform<qs::network::NM80211ApSecurityFlags::Enum>::fromWire(quint32 wire) {
return DBusResult(static_cast<qs::network::NM80211ApSecurityFlags::Enum>(wire));
}
DBusResult<qs::network::NM80211Mode::Enum>
DBusDataTransform<qs::network::NM80211Mode::Enum>::fromWire(quint32 wire) {
return DBusResult(static_cast<qs::network::NM80211Mode::Enum>(wire));
}
} // namespace qs::dbus

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