Skip to content

wlr/taskbar: reload icon when the widget scale factor changes - #5262

Merged
Alexays merged 1 commit into
Alexays:masterfrom
teivng:taskbar-reload-icon-on-scale-change
Aug 27, 2026
Merged

wlr/taskbar: reload icon when the widget scale factor changes#5262
Alexays merged 1 commit into
Alexays:masterfrom
teivng:taskbar-reload-icon-on-scale-change

Conversation

@teivng

@teivng teivng commented Aug 20, 2026

Copy link
Copy Markdown

Problem

wlr/taskbar rasterizes each task's icon once, in Task::handle_app_id() / handle_title(), at icon-size × icon_.get_scale_factor() (IconLoader::image_load_icon). It is never re-rendered afterwards.

When a bar is created (waybar start, config reload, or an output being hotplugged) every already-existing toplevel gets its Task built before the bar's surface has entered its output. At that point gtk_widget_get_scale_factor() falls back to the scale of monitor 0 (GTK 3 gtkwidget.c). On a mixed-DPI setup that guess is wrong for any bar that isn't on monitor 0, so the icon is rasterized at the wrong scale and stays blurry until the application is restarted. Windows opened after the bar has settled get a correct, crisp icon — which makes the symptom look random.

Repro: laptop panel at scale 2 (or a fractional scale Hyprland rounds up to 2) plus an external monitor at scale 1 that is the first output, open a few windows, then restart waybar or replug the external monitor. Icons of the pre-existing windows are blurry on the HiDPI bar; newly opened windows are sharp.

Fix

Connect to the image's scale-factor property and reload the icon when it changes. GTK emits this once the surface enters its output (and on any later scale change), so tasks created during the window where the scale is still a guess get re-rasterized at the right size. No-op for bars whose guess was already right.

Tested on Hyprland with eDP-1 @1.5 + HDMI-A-1 @1 (waybar 0.15.0 + this patch, and current master builds).

Task icons are rasterized once, at toplevel creation, using
Gtk::Widget::get_scale_factor(). When a bar is (re)created every existing
toplevel gets its Task built before the bar surface has entered its output,
so GTK falls back to the scale of monitor 0. On a mixed-DPI setup that is
the wrong scale and the icon stays blurry until the app is restarted.

Reload the icon whenever the image's scale-factor property changes.
@Alexays
Alexays merged commit 5f78471 into Alexays:master Aug 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants