Desktop labels keep the old DPI after a gtk-xft-dpi change

Aperta
#3,878 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
desktop

Direzione di ricerca

Start in libnemo-private/nemo-icon-container.c and read style_updated() plus nemo_icon_container_invalidate_labels() to understand how the desktop container refreshes label layouts. The issue proposes updating the Pango context resolution in the desktop branch; it also flags font options as a possible related update. Done means desktop labels use the new DPI after an XSETTINGS change without restarting nemo-desktop; the GTK reproduction supports the approach, but the issue reports no Nemo build test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Distribution

Ubuntu 26.04, Unity session (X11). nemo-desktop draws the desktop.

Package version

6.4.5 (the same code is in master). GTK 3.24.52.

Frequency

Always

Bug description

The desktop icon labels do not follow a runtime change of gtk-xft-dpi. The labels keep the DPI that was active when nemo-desktop started. The icons and other windows use the new DPI.

On a real login this occurs when nemo-desktop starts before the XSETTINGS manager. GTK then uses Xft.dpi from the X resources. A HiDPI greeter can leave Xft.dpi: 192 there. The settings daemon then publishes 96 dpi, but the desktop labels stay at 2x until nemo-desktop restarts.

Steps to reproduce
  1. Start Xvfb :94 -screen 0 1600x900x24 -noreset.
  2. Run printf 'Xft.dpi: 192\n' | xrdb -nocpp -merge on :94.
  3. Start nemo-desktop on :94 with desktop-layout 'true::true' and the computer, home and trash icons visible.
  4. Publish XSETTINGS with Xft/DPI = 98304 (96 dpi). GTK reports gtk-xft-dpi 96 after this step.
  5. Compare the labels before and after step 4. Then restart nemo-desktop.
State gtk-xft-dpi "Home" label
Start, no XSETTINGS, Xft.dpi: 192 192 72x20 px
After XSETTINGS 96 dpi 96 72x20 px
After restart of nemo-desktop 96 36x10 px
Expected behavior

The "Home" label is 36x10 px after step 4, without a restart.

Additional information

style_updated() in libnemo-private/nemo-icon-container.c does not chain up for the desktop container:

/* Don't chain up to parent, if this is a desktop container,
 * because that resets the background of the window.
 */
if (!nemo_icon_container_get_is_desktop (container)) {
	GTK_WIDGET_CLASS (nemo_icon_container_parent_class)->style_updated (widget);
}

The default GtkWidget handler updates the Pango context of the widget, including its resolution. Without the chain-up, the desktop container keeps the old resolution. nemo_icon_container_invalidate_labels() then creates the new layouts from the same old context.

Minimal GTK reproduction, same setup as above (start with Xft.dpi: 192, then publish XSETTINGS 96 dpi):

before XSETTINGS: gtk-xft-dpi 192.0 | no chain-up 192.0 | chain-up 192.0 | no chain-up + set_resolution 192.0
after XSETTINGS:  gtk-xft-dpi 96.0  | no chain-up 192.0 | chain-up 96.0  | no chain-up + set_resolution 96.0

The three widgets are Gtk.DrawingArea subclasses. The "no chain-up" widget overrides do_style_updated with an empty function. The values are PangoCairo.context_get_resolution (widget.get_pango_context ()).

Possible fix: update the resolution of the Pango context in the desktop branch, without the chain-up that resets the background.

if (!nemo_icon_container_get_is_desktop (container)) {
	GTK_WIDGET_CLASS (nemo_icon_container_parent_class)->style_updated (widget);
} else {
	pango_cairo_context_set_resolution (gtk_widget_get_pango_context (widget),
	                                    gdk_screen_get_resolution (gtk_widget_get_screen (widget)));
}

The GTK reproduction confirms this approach. It is not tested in a nemo build. The font options of the context can need the same update (pango_cairo_context_set_font_options() with gdk_screen_get_font_options()).

A change of the text scaling factor in Cinnamon also changes Xft/DPI at runtime, so the desktop labels can show the same problem there. This is not tested.

Lingua principale
C
Stelle
1.6k
Fork
387
Merge medio
2g 19h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di linuxmint/nemo

Tutte le issue di linuxmint/nemo

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.