Commit Graph

45 Commits

Author SHA1 Message Date
a51bddab9e fix(label): compare markup cache by raw bytes, not collation
2190871a (perf(label): skip redundant markup updates) caches the last
label/tooltip markup as Glib::ustring and skips set_markup() when the
new markup compares equal. Glib::ustring::operator== goes through
g_utf8_collate(), and under the UTF-8 locale GTK sets at startup,
Unicode private-use codepoints carry no collation weight. All nerd-font
icons live in the PUA, so two labels that differ only in their icon
glyph collate as equal and the visual update is silently dropped.

idle_inhibitor is the visible victim (#5169): clicking toggles the
state class (highlight changes) but the {icon} glyph never switches
between the activated/deactivated icons, while plain-text icons like
"YES"/"NO" work. Any ALabel module whose consecutive updates differ
only by a PUA glyph is affected. The module only started routing
through this cache when db4941ef migrated it onto the shared
setLabelMarkup()/setTooltipMarkup() helpers, which is why it broke in
the latest batch of refactors.

Store the cache as raw UTF-8 bytes (std::string via ustring::raw())
and compare those instead, so the skip only triggers on byte-identical
markup. Reproduced and verified under a nested niri session: before the
fix RTMIN+n toggled the state class but left the sleep glyph unchanged;
after it the glyph flips as expected, and byte-identical updates are
still skipped.
2026-07-05 01:18:53 -05:00
003d531701 refactor(AModule): hoist format/tooltip resolution to the base module
Move resolveTooltipFormat() (and add resolveFormat()) from ALabel down into
AModule, and add a generic updateTooltip(Gtk::Widget&, ...) helper. This lets
modules that are not ALabel-derived reuse the shared tooltip logic instead of
re-implementing it. Migrate gamemode (the only non-ALabel module reading
tooltip-format) to updateTooltip(box_, ...). ALabel inherits the resolvers.
2026-07-04 00:17:14 +02:00
8dbba448ce refactor(modules): migrate state modules to ALabel tooltip helper
Migrate cpu, cpu_usage, cpu_frequency and memory to the generic
updateLabelAndTooltip/ForState helper so label and tooltip rendering go
through the dedup-aware setters and shared tooltip-format resolution.

Add store-accepting overloads of the helper to ALabel for modules that
build a dynamic fmt argument store (per-core cpu stats). cpu keeps its
tooltip-format-<state> selection via the state overload; the others keep
their existing tooltip-format-only behavior.
2026-07-04 00:05:17 +02:00
8eb916ac84 refactor(ALabel): add generic label+tooltip helper to remove duplication
Modules duplicated the same boilerplate to format their label and tooltip
(read tooltip-format, fmt::format, set_tooltip_markup) across ~29 modules.

Add updateLabelAndTooltip(labelFormat, tooltipDefault, args...) and its
state-aware variant updateLabelAndTooltipForState(state, ...) to ALabel: they
build a single fmt arg store, render the label and the resolved tooltip format
(tooltip-format[-state] or default) through the dedup-aware setters, honoring
the tooltip toggle. resolveTooltipFormat() centralizes the format resolution.

Migrate temperature and disk as the first adopters.
2026-07-03 23:46:31 +02:00
e7d19ad60f Merge branch 'master' into 4655 2026-07-03 22:21:52 +02:00
2190871a68 perf(label): skip redundant markup updates 2026-06-04 15:18:43 -07:00
fff1495efb adding a new keyword 'on-click-copy' that accepts a bool and copies to clipboard on true' 2026-03-24 20:12:30 +01:00
47fb21a2c1 chore: upgrade to clang-format@21 2026-02-04 09:24:14 +01:00
6dc5a73a02 initial changes 2025-08-16 15:29:59 -07:00
21751b2faa 🎨 clang-tidy 2024-05-09 20:59:25 +02:00
3b87b83076 ♻️ move GMenu to ALabel class 2024-05-09 18:34:26 +02:00
61a6c00c02 Happy clang 2023-03-02 16:57:32 +03:00
f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
9c2b5efe7b Support per-device icon in pulseaudio 2021-07-15 09:20:43 +02:00
c6743988d3 Removing 'click_param' as it is no longer used. 2020-11-01 16:03:39 +00:00
62082bdb01 clock: scroll through multiple timezones 2020-08-13 18:53:18 -04:00
6ca4e14b29 Feat icons vector (#716) 2020-05-22 21:23:04 +02:00
a6980fca7f feat: ellipsize modules 2019-06-28 14:16:09 +02:00
340ec7be91 refactor: AModule 2019-06-15 14:57:52 +02:00
ae397c8fa2 ALabel: add smooth-scrolling-threshold 2019-06-11 17:56:10 +02:00
d24d85bebf refactor: move label name and id to label contructor 2019-05-22 12:06:24 +02:00
963d4f68e4 refactor: remove useless param 2019-05-16 09:39:06 +02:00
7e8eee0571 fix state behavior 2019-05-15 22:14:51 -05:00
92967c7c06 fix(Label): reverse only battery states 2019-05-13 11:36:34 +02:00
fcb23d3104 feat(temperature): format-icons 2019-05-13 11:31:05 +02:00
Dan
e158a3e132 feat(states): add generic 'states' to all labels 2019-05-02 22:24:29 -04:00
5623bbecfe feat(idle_inhibitor): pass status to click events exec 2019-05-02 16:56:45 +02:00
311c34ecbc feat(Bar): handle widget size changes 2019-04-24 12:37:24 +02:00
90d89fe974 refactor: kill custom modules scripts en destroy 2019-04-23 15:56:38 +02:00
6ed8f94dab refactor: format code 2019-04-18 17:52:00 +02:00
80ef63791d [bugfix] idle_inhibitor handles click events correctly
- Declare event handler in ALabel virtual so the idle_inhibitor can
  overriding them
- Handle the right click event in idle_inhibitor and call ALabel handler if needed
2019-03-03 22:02:34 +01:00
83a6475510 feat: can disable tooltip 2019-02-22 11:35:47 +01:00
eace8c549f fix(Network): format-alt 2019-01-13 22:36:37 +01:00
29a2ee1744 refactor: Replace all occurencec of gtkmm.h and only use the necessary headers 2019-01-08 21:05:44 +01:00
b554094c7e feat: args && class id 2018-12-18 17:30:54 +01:00
ad7400d5ce refactor(ALabel): add interval 2018-11-23 11:57:37 +01:00
8db94f7efd revert(ALabel): ref on format 2018-11-22 16:50:42 +01:00
ba79b4d397 refactor(tray): cleanup and fixes 2018-11-22 15:47:23 +01:00
9d4048983d refactor: remove useless tmp variable 2018-11-01 09:27:00 +01:00
d7d1ebd736 ALabel: Add support for configurable mouse events
This patch adds 3 new configuration options applicable for
subclasses of ALabel. The options can be used to execute
user defined code in response to the 3 mouse events:
* on-click: The left mouse button click
* on-scroll-up
* on-scroll-down
This patch also modifies the behaviour of the format-alt toggle
such that when the on-click event is configured, format-alt is
toggled on any mouse click other than left click. When on-click
is not defined, any mouse button would toggle format-alt.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2018-10-30 20:52:23 +05:30
6dd9b5ccc4 feat(Pulseadio): port icons 2018-08-29 23:50:41 +02:00
53956d9d18 feat(ALabel): Toggleable labels 2018-08-27 01:36:25 +02:00
49232eed8d Clean (#31) 2018-08-20 14:50:45 +02:00
27dfffa4e3 refactor: style issue 2018-08-18 15:05:18 +02:00
b1fd4d7b82 feat(modules): generic label module to allow max-length on all labels 2018-08-18 11:43:48 +02:00