如何在XFCE桌面环境上使用程序获得DPI?

发布于 2025-01-19 09:32:43 字数 252 浏览 0 评论 0原文

Xfce 支持 HiDPI 缩放,可以使用设置管理器启用:

1.转到设置管理器 >外观>设置>窗口缩放并选择 2 作为缩放因子。

我想知道如果我们将“Window Scaling”调整为“2X”,此时DPI的值是多少?以及如何使用程序(C/C++)获取DPI值?

在此处输入图片说明

Xfce supports HiDPI scaling which can be enabled using the settings manager:

1.Go to Settings Manager > Appearance > Settings > Window Scaling and select 2 as the scaling factor.

I wonder to know if we adjust 'Window Scaling' is '2X', at this point, what is the value of DPI ? And how get the DPI value using program(C/C++)?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2025-01-26 09:32:43

缩放和DPI可能很棘手,如果可能的话,只需将其留给GTK即可处理它们。如果您可以解释为什么需要他们的价值观,那就太好了。

这是一种查询它们的一种方法的示例:

gint dpi, scale;
GtkSettings *settings;

settings = gtk_settings_get_default ();

g_object_get (settings, "gtk-xft-dpi", &dpi, NULL);
scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());

g_print("Scale is %d\n", scale);
g_print("DPI is %d\n", dpi / 1024);

或者,可以使用XFConf_Channel_get_int查询两个值,请参阅XFCE4-SETTING “ nofollow noreferrer”>代码作为参考。

Scaling and DPI can be tricky, if possible just leave it to Gtk to handle them. It would be nice if you could explain why do you need their values.

Here is a sample of one way to query them:

gint dpi, scale;
GtkSettings *settings;

settings = gtk_settings_get_default ();

g_object_get (settings, "gtk-xft-dpi", &dpi, NULL);
scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());

g_print("Scale is %d\n", scale);
g_print("DPI is %d\n", dpi / 1024);

Alternatively, both values can be queried using xfconf_channel_get_int, see xfce4-settings code as reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文