Commit Graph

47 Commits

Author SHA1 Message Date
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
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
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
Alex
ef3d55980e fix: some crashes 2026-02-24 00:49:08 +01:00
Alexis Rouillard
64ecdcfa87 Merge pull request #4846 from BlueManCZ/fix-mpris-fallback-player
fix(mpris): fall back to next non-ignored player and prefer playing players
2026-02-23 23:51:04 +01:00
Prakhar Chhalotre
3e7976c8eb fix: use pango markup for consistent formatting in format and tooltip-format 2026-02-13 02:23:16 +05:30
BlueManCZ
a871d90161 Fix button action handling to consistently use the active player 2026-02-11 12:09:20 +01:00
BlueManCZ
0a50e82d0d Prioritize currently playing player 2026-02-11 11:47:05 +01:00
BlueManCZ
a69b7a5536 Handle fallback player for ignored MPRIS players 2026-02-11 10:53:48 +01:00
Alex
ee91d18ad9 fix: lint 2025-06-22 10:01:36 +02:00
Alexis Rouillard
780e96bd78 Merge pull request #4131 from belcaik/master
Add support for mouse side buttons (back/forward) to control track navigation in mpris module
2025-06-22 08:45:41 +01:00
Alex
286cff2e3d fix: lint 2025-06-22 09:44:35 +02:00
markx86
c266befe0a fix: MPRIS widget not hiding when no player is active 2025-06-20 14:02:01 +02:00
belcaik
d41a664779 refactor: use command pattern for button actions 2025-05-19 23:12:42 -04:00
belcaik
cdf3ca910d feat: Add support for side buttons mouse navigation in handleToggle
mapped buttons config on-click-backward and on-click-forward on mpris module to previous/next handle
GTK codes are 9 and 8
2025-05-19 22:52:01 -04:00
giskard
7721dcdae8 mpris: some clang-tidy fix 2024-06-10 17:31:00 +08:00
giskard
e8d91eb14b mpris: hide on current player vanished 2024-06-10 17:31:00 +08:00
Viktar Lukashonak
9012cebbf2 Happy Linter
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
2023-10-31 23:31:58 +03:00
cvhere
67422eea36 Skips logging NoActivePlayer error msgs 2023-10-31 11:14:23 +05:30
Tamino Bauknecht
68dfd6aa3a scope_guard/modules: Rename scope_guard to ScopeGuard
Using pascal case for the class name keeps it more consistent with the
majority of the other class names.
2023-10-24 17:51:38 +02:00
Tamino Bauknecht
dd1de3efbf Revert "Revert "Fix potential memory leaks""
This reverts commit 2d33c20231 and
reapplies various patches for memory leaks.
The reason for the revert was a bug for a maximum duration interval
which caused sleep_for() to cause unpredictable behavior.
2023-10-24 17:51:38 +02:00
Alexis Rouillard
9ecdbcc7bc Merge pull request #2596 from rehanzo/master 2023-10-22 09:46:35 +02:00
Alexis Rouillard
2d33c20231 Revert "Fix potential memory leaks" 2023-10-22 09:44:46 +02:00
Rehan
5963bf6ace modules/mpris: change default interval value to 0 2023-10-21 18:14:46 -04:00
Tamino Bauknecht
ae748b2644 modules+util: fix actual (potential) memory leaks 2023-10-21 11:51:33 +02:00
Akshett Rai Jindal
1af02e0a67 fix(modules/mpris): fix on-*-click typos
In all other places, the norm is to use `on-click-(middle|right)` but in
the mpris module, `on-(middle|right)-click` was being used which caused
clicks to malfunction if set to some custom commands
2023-10-09 11:48:49 +05:30
Alex
fc632f50ec fix: lint 2023-07-04 22:52:24 +02:00
Alexis Rouillard
0d1016d4d2 Merge pull request #2203 from rodrgz/mprisImprovement
mpris: dynamic tag ordering and separator customization
2023-07-04 22:44:21 +02:00
Skirmantas Kligys
c2f9d889f4 Stop MPRIS module from updating every ~20ms as onPlayerMetadata(), onPlayerPlay()
callbacks get triggered without regard for update interval.
2023-07-03 13:52:57 -07:00
Erik Rodriguez
66ce74d29b mpris: Rename dynamic-priority to dynamic-importance-order keeping backward compatibility 2023-06-22 02:13:44 -03:00
Erik Rodriguez
77a8420aaf mpris: Add dynamic-order and dynamic-separator
This commit allows better handling of ordering and exclusion of the tags in Dynamics tags.
It also becomes possible to choose the separator between the tags.
2023-06-22 02:13:34 -03:00
Finlay Davidson
4bc30e040f mpris: Hide label if empty 2023-05-10 13:43:43 +02:00
chayleaf
659fea07ee mpris: fix non-dynamic tags not being html escaped 2023-04-06 13:24:28 +07:00
chayleaf
cb82326b22 mpris: fix css class application
apply styles to label rather than event_box (fixes play/pause state and
per-player selectors)
2023-04-06 04:50:32 +07:00
Alex
3d980f92a3 fix: build 2023-04-03 10:59:29 +02:00
Alex
626a1f58be fix: build 2023-04-03 10:51:36 +02:00
Alex
60e0584d16 fix: lint 2023-04-03 09:41:24 +02:00
Alex
ba6faa7859 Merge pull request #2011 from chayleaf/improve-mpris 2023-04-03 09:40:01 +02:00
Alex
02b3c125a1 fix: init optional to null 2023-04-03 09:38:12 +02:00
chayleaf
0cfd1c7094 mpris: don't put ellipsis after whitespace 2023-03-31 19:54:44 +07:00
chayleaf
e5524d5059 mpris: switch base class from AModule to ALabel 2023-03-31 19:54:39 +07:00
chayleaf
774d8880cd mpris: fix potentially invalid seconds count on >1h media 2023-03-31 19:54:39 +07:00
chayleaf
a301b8c4cd mpris: update docs 2023-03-31 19:54:27 +07:00
chayleaf
5383f7bd56 mpris: add unicode support; add position tag 2023-03-31 19:54:20 +07:00
chayleaf
a53c97f7f6 mpris: add tooltip and length limits 2023-03-31 19:53:53 +07:00
Aleksei Bavshin
ea17a66dfc fix: compilation errors with cpp_std=c++20
There were two main issues with fmtlib and C++20 mode:

 - `fmt::format` defaults to compile-time argument checking and requires
   using `fmt::runtime(format_string)` to bypass that.
 - `std::format` implementation introduces conflicting declarations and
   we have to specify the namespace for all `format`/`format_to` calls.
2023-01-20 22:50:02 -08:00
Robert Günzler
0bc5314e08 Add mpris module
Uses libplayerctl to use the MPRIS dbus protocol to query, listen and
control media players.

Signed-off-by: Robert Günzler <r@gnzler.io>
2023-01-06 20:55:31 +01:00