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

未关闭
#3,878 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
desktop

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C
星标
1.6k
派生
387
平均合并
2 天 19 小时
30 天内合并 PR
4

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

linuxmint/nemo 的其他 Issue

查看 linuxmint/nemo 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。