4472 Commits

Author SHA1 Message Date
Austin Horstman
b1a87f943c fix(hyprland/window): avoid stale state during IPC refresh
The window module re-entered the same shared_mutex while refreshing IPC state:
update() took the lock and then called queryActiveWorkspace(), which tried to
lock it again. That is undefined behavior for std::shared_mutex and could
manifest as a deadlock.

Remove the recursive lock path and reset the derived window state before each
IPC refresh. That keeps solo/floating/swallowing/fullscreen classes from
sticking around when the client lookup fails or a workspace becomes empty.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-07 21:06:30 -06:00
Austin Horstman
0a35b86e20 fix(hyprland/ipc): honor the requested instance signature
The Hyprland IPC helper cached the socket folder with the first instance
signature already appended, so later calls ignored their instanceSig argument
and always reused the first path. That made the helper violate its own API even
though most real Waybar sessions only talk to a single Hyprland instance.

Cache only the base socket directory and append the requested signature per
lookup. This fixes correctness for tests, nested or debug multi-instance
setups, and future code that needs to resolve a different signature, without
claiming support for one Waybar process managing multiple Hyprland sessions.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-07 21:06:30 -06:00
Alexis Rouillard
e425423648 Merge pull request #4911 from khaneliman/gtkmenu
fix(menu): keep popup menus alive after builder teardown
2026-03-07 17:46:27 +01:00
Austin Horstman
790101f824 chore: format
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-06 18:49:02 -06:00
Austin Horstman
f48fce57dc fix(menu): keep popup menus alive after builder teardown
The popup menu was retrieved from GtkBuilder and stored in menu_, but the builder was unref'd immediately after construction. That left the later popup path operating on a builder-owned GtkMenu whose lifetime was no longer guaranteed, which matches the GTK_IS_WIDGET and GTK_IS_MENU assertions from the regression report.

Take an owned reference to the built menu and release it in AModule teardown so popup menus stay valid without extending the lifetime of the whole builder.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-06 18:39:16 -06:00
Alexis Rouillard
68d4360c26 Merge pull request #4905 from sw1nn/master
fix(mpris): disconnect GLib signals before destroying objects
2026-03-04 22:42:43 +01:00
Alexis Rouillard
22b2aff374 Merge pull request #4900 from AlisonB319/ab319/fix-hover-2
fix: sync tooltip updates without resetting hover state
2026-03-04 22:42:16 +01:00
Alexis Rouillard
100d4ec4a4 Merge pull request #4891 from khaneliman/bugfix/stab-003-test-001-hyprland-ipc
fix(hyprland-ipc): harden fd lifecycle and listener loop
2026-03-04 22:41:30 +01:00
Alexis Rouillard
b31292dee2 Merge pull request #4898 from khaneliman/memory
perf(memory): optimize string operations; remove deep copies, memdup, and icon theme rescanning
2026-03-04 22:40:55 +01:00
Alexis Rouillard
a4a7fbbe09 Merge pull request #4897 from khaneliman/network
fix(network): align tooltip and tooltip text
2026-03-04 22:40:20 +01:00
Alexis Rouillard
66c9212217 Merge pull request #4892 from khaneliman/bugfix/stab-004-command-exec-failure
fix(command): return non-zero when child exec fails
2026-03-04 22:39:31 +01:00
Alexis Rouillard
4cc4c902da Merge pull request #4895 from BryceGust/fix/interval-cast
fix: float interval cast
2026-03-04 22:39:00 +01:00
Neale Swinnerton
a816218637 fix(mpris): disconnect GLib signals before destroying objects
Waybar SEGVs in Glib::DispatchNotifier::pipe_io_handler when the MPRIS
module is enabled. The crash is intermittent because it requires a race
between signal emission and object destruction: a playerctl GLib signal
callback (e.g. onPlayerPlay) calls dp.emit(), which writes a pointer to
the Dispatcher into an internal pipe. If the Mpris object is destroyed
before the GLib main loop reads that pipe entry, pipe_io_handler
dereferences a dangling pointer. This typically occurs when a media
player appears or vanishes on D-Bus (browser closing, player quitting)
or during waybar shutdown/config reload.

The root cause is that ~Mpris() calls g_object_unref() on the manager
and player GObjects without first disconnecting the signal handlers that
hold raw `this` pointers. If playerctl holds additional references to
these GObjects, they survive the unref and can still fire signals
targeting the already-destroyed Mpris instance.

Adopt the same cleanup pattern used by the Wireplumber module: call
g_signal_handlers_disconnect_by_data() to sever all signal connections
referencing `this` before releasing the GObjects with g_clear_object().
This guarantees no callbacks can enqueue stale Dispatcher notifications
after teardown begins.

Additionally:
- Clean up old player in onPlayerNameAppeared before replacing it,
  fixing a GObject leak and accumulation of dangling signal connections
- Remove duplicate onPlayerStop signal registration (copy-paste bug)
2026-03-03 16:02:04 +00:00
Alison
3eb2c7e8f4 sync tooltip updates without resetting hover state 2026-03-03 00:24:04 -08:00
Alison
a97e8dad7c Revert "Fix tooltip sync issue by removing conditional checks"
This reverts commit 2b29c9a5d6.
2026-03-03 00:23:57 -08:00
Austin Horstman
c5449bd361 fix(network): log new address only when state changes
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 23:12:54 -06:00
Austin Horstman
fe03dfaa3b perf(memory): eliminate deep copies in range-based for loops and lambdas
This commit addresses memory churn caused by implicit deep copies during traversal and allocation of complex structures:

- Replaced pass-by-value 'Json::Value' in std::ranges and range-based for loops with 'const auto&' or 'const Json::Value&' in Hyprland modules, preventing large JSON tree duplications on every update.

- Fixed implicit string and pair copies in UPower and CPU Frequency loops by converting 'auto' to 'const auto&' where possible.

- Added 'std::vector::reserve' calls before 'push_back' loops in MPRIS, Niri, and CFFI modules to prevent exponential vector reallocation during initialization.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 22:54:07 -06:00
Austin Horstman
7d8be29f97 perf(sni): eliminate icon theme rescanning from system tray hotpath
Valgrind Massif profiling revealed that invoking Gtk::IconTheme::rescan_if_needed() inside SNI updateImage() and getIconByName() loops caused considerable memory churn and potential filesystem stat overhead whenever a system tray app pushed a metadata update.

This commit removes the rescan polling from the SNI proxy callback pipeline and the DefaultGtkIconThemeWrapper, restricting icon theme caching to load boundaries.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 22:54:07 -06:00
Austin Horstman
e684e701df perf(sni): eliminate redundant g_memdup2 allocation for D-Bus pixbufs
Memory profiling via Valgrind Massif indicated that 10-20% of peak memory allocations within the SNI loop resulted from copying DBus image data payloads via g_memdup2 before modifying them from ARGB to RGBA.

This commit optimizes the pixel conversion by directly allocating the final array via g_malloc and running the ARGB->RGBA transposition in a single pass while copying from the read-only GVariant buffer, entirely eliminating the intermediate g_memdup stage.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 22:54:07 -06:00
Austin Horstman
4c71b2bf9f perf(memory): optimize C++ string operations to reduce heap fragmentation
- Replaced pass-by-value std::string parameters with const std::string&
or std::string_view to prevent SSO overallocations.

- Refactored static mapping functions in UPower to return
std::string_view instead of constructing std::string literals, enabling
perfect cache locality.

- Optimized string concatenation in hot loops (network IPs, inhibitor
lists, sway window marks) by using std::string::append() and
pre-reserving capacity instead of overloaded operator+ which produces
temporary heap instances.

These optimizations reduce high-frequency memory churn and overall heap
fragmentation within the main rendering loops.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 22:54:07 -06:00
Austin Horstman
25089b2456 fix(network): align tooltip and tooltip text
Closes https://github.com/Alexays/Waybar/issues/4867

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 21:24:12 -06:00
Bryce Gust
d929f1a62c Fix 4894 - float interval cast 2026-03-02 17:58:00 -06:00
Austin Horstman
79fb1d9f58 test(command): cover exec failure paths
Command tests did not assert behavior when exec fails in child processes.

I added deterministic regression coverage that forces execl/execlp failure and
verifies non-zero exit status propagation for both open() and forkExec paths.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:44:54 -06:00
Austin Horstman
5e7dbf1715 fix(command): return non-zero when child exec fails
Child exec failure paths were returning success, which masked command launch
errors from callers.

I switched the child-side failure exits to _exit(127) and added errno-specific
logging so failures propagate with actionable diagnostics.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:41:43 -06:00
Austin Horstman
8d22d3e07a refactor(sway): use shared ScopedFd for IPC sockets
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:23:06 -06:00
Austin Horstman
39e09118f9 refactor(wayfire): replace custom Sock with shared ScopedFd
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:21:20 -06:00
Austin Horstman
2ff77fb73d refactor(niri): use shared ScopedFd utility
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:21:17 -06:00
Austin Horstman
e83ab7609c refactor(hyprland): use shared ScopedFd utility
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:21:15 -06:00
Austin Horstman
6dfe1c3111 feat(util): add ScopedFd RAII utility for file descriptors
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:21:12 -06:00
Austin Horstman
04ddc5fd23 chore(test-hyprland): remove unused IPC test fixture
The hyprland IPC fixture was no longer used by the current test setup.

I removed the dead fixture so the test code reflects the actual execution path
and is easier to maintain.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:17:29 -06:00
Austin Horstman
87a5b7ed0f test(hyprland): add failure-path fd-leak coverage
Hyprland tests did not explicitly verify descriptor behavior on key failure
paths.

I added focused tests for missing instance signature and connect-failure paths
that assert file descriptor counts stay stable across repeated attempts.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:17:29 -06:00
Austin Horstman
d0363313b8 fix(hyprland-ipc): harden fd lifecycle and listener loop
Hyprland IPC had fd lifecycle risks on failure/shutdown paths and used a
spin-sleep listener model.

I initialized fd state defensively, tightened connect/close/shutdown handling,
moved to blocking read with newline framing, and added RAII-style fd cleanup in
socket1 reply paths.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 08:09:44 -06:00
Alexis Rouillard
fd086d0f33 Merge pull request #4890 from khaneliman/bugfix/perf-001-safe-signal-bounded-queue
fix(util): bound SafeSignal queue growth under burst load
2026-03-01 18:19:25 +01:00
Alexis Rouillard
47b2dfc6db Merge pull request #4889 from khaneliman/bugfix/stab-001-002-sleeper-thread
fix(util): ensure SleeperThread lifecycle safety and thread sync
2026-03-01 18:19:03 +01:00
Austin Horstman
e4ff024fa8 fix(util): bound SafeSignal queue growth under burst load
SafeSignal could queue events forever when worker threads emitted faster than
the main loop could consume, which risks memory growth and stale updates.

I added a queue cap with a drop-oldest policy so growth stays bounded under
burst load, plus a regression test that validates bounded delivery.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-02-28 22:57:49 -06:00
Austin Horstman
864523772d test(utils): stress SleeperThread wake and stop control flow
SleeperThread concurrency paths needed stress coverage around wake/stop races.

I added a subprocess stress test that repeatedly interleaves wake_up() and
stop() and verifies the worker exits cleanly.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-02-28 22:47:52 -06:00
Austin Horstman
44eed7afea fix(sleeper-thread): synchronize control flags with atomics
SleeperThread control flags were shared across threads without consistent
synchronization.

I converted the run/signal flags to atomics and updated wait predicates and
lifecycle transitions to use explicit atomic loads/stores.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-02-28 22:47:52 -06:00
Austin Horstman
1c61ecf864 test(utils): add SleeperThread reassignment regression
We needed a regression test for reassignment safety after lifecycle fixes.

I added a subprocess test that reassigns SleeperThread workers and verifies the
process exits normally instead of terminating.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-02-28 22:47:52 -06:00
Austin Horstman
dbbad059f7 fix(sleeper-thread): stop and join before worker reassignment
Reassigning SleeperThread could replace a joinable std::thread and trigger
std::terminate.

I now stop and join any existing worker before reassignment, then reset control
state before starting the replacement worker.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-02-28 22:28:22 -06:00
Alexis Rouillard
31b373b984 Merge pull request #4888 from Alexays/copilot/fix-waybar-deadlock-issue
[WIP] Fix waybar responsiveness and interaction issues
2026-02-28 15:29:02 +01:00
copilot-swe-agent[bot]
d5297bc424 fix: resolve PulseAudio/WirePlumber deadlock and freeze issues
- Fix AudioBackend destructor: properly lock the PA mainloop before
  disconnecting the context to prevent race conditions with PA callbacks

- Fix context leak on reconnect: call pa_context_unref() when the old
  context is replaced after PA_CONTEXT_FAILED to avoid resource leaks

- Fix PA mainloop killed on reconnect (critical): PA_CONTEXT_TERMINATED
  was unconditionally calling quit() on the mainloop, even during
  reconnection when the old context fires TERMINATED after the new one
  was created. This was killing the new context and preventing successful
  reconnection, causing Waybar to appear frozen. The fix only quits
  the mainloop when the terminating context is still the active one.

- Fix Wireplumber use-after-free: explicitly disconnect GObject signal
  handlers for mixer_api_, def_nodes_api_, and om_ before clearing the
  object references in the destructor to prevent callbacks from firing
  with a destroyed self pointer.

- Fix GVariant memory leak in Wireplumber::handleScroll: unref the
  GVariant created for the set-volume signal after the emit call.

Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com>
2026-02-28 14:27:22 +00:00
copilot-swe-agent[bot]
c504b7f437 Initial plan 2026-02-28 14:00:25 +00:00
6a503745fe Fix tooltips broken by 2b29c9a
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled
update-flake-lock / lockfile (push) Has been cancelled
Build and Push Docker Image / build-and-push (alpine) (push) Has been cancelled
Build and Push Docker Image / build-and-push (archlinux) (push) Has been cancelled
Build and Push Docker Image / build-and-push (debian) (push) Has been cancelled
Build and Push Docker Image / build-and-push (fedora) (push) Has been cancelled
Build and Push Docker Image / build-and-push (gentoo) (push) Has been cancelled
Build and Push Docker Image / build-and-push (opensuse) (push) Has been cancelled
2026-02-27 08:57:41 -08:00
267c327db9 Merge upstream/master
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled
2026-02-27 08:36:07 -08:00
57a9bd83ff Fix group signal-triggered group closing incorrectly
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled
2026-02-27 06:46:18 -08:00
Alex
7744320ab2 fix: build 2026-02-24 00:55:27 +01:00
Alex
802bf184fb fix: lint 2026-02-24 00:49:23 +01:00
Alex
ef3d55980e fix: some crashes 2026-02-24 00:49:08 +01:00
Alexis Rouillard
a32413a74f Merge pull request #4880 from Alexays/copilot/fix-mpd-module-crash
mpd: fix socket FD leak on system-level connection errors
2026-02-24 00:06:11 +01:00
copilot-swe-agent[bot]
82f076c6c2 mpd: fix FD leak by resetting connection on MPD_ERROR_SYSTEM errors
Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com>
2026-02-23 23:04:36 +00:00