diff options
| author | Helmut Eller | 2026-02-13 09:10:16 +0100 |
|---|---|---|
| committer | Helmut Eller | 2026-02-13 09:10:16 +0100 |
| commit | 91c9e9883488d715a30877dfd7641ef4b3c62658 (patch) | |
| tree | e2c4525147e443f86baf9d0144aeadec082d7564 /src/xsettings.c | |
| parent | 9a4a54af9192a6653164364c75721ee814ffb1e8 (diff) | |
| parent | f1fe4d46190263e164ccd1e066095d46a156297f (diff) | |
| download | emacs-feature/igc.tar.gz emacs-feature/igc.zip | |
Merge branch 'master' into feature/igcfeature/igc
Diffstat (limited to 'src/xsettings.c')
| -rw-r--r-- | src/xsettings.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/xsettings.c b/src/xsettings.c index 25edce78841..71cd6a9ad6c 100644 --- a/src/xsettings.c +++ b/src/xsettings.c | |||
| @@ -187,6 +187,8 @@ store_tool_bar_style_changed (const char *newstyle, | |||
| 187 | #ifndef HAVE_PGTK | 187 | #ifndef HAVE_PGTK |
| 188 | #if defined USE_CAIRO || defined HAVE_XFT | 188 | #if defined USE_CAIRO || defined HAVE_XFT |
| 189 | #define XSETTINGS_FONT_NAME "Gtk/FontName" | 189 | #define XSETTINGS_FONT_NAME "Gtk/FontName" |
| 190 | #define XSETTINGS_GDK_DPI_NAME "Gdk/UnscaledDPI" | ||
| 191 | #define XSETTINGS_GDK_WSCALE_NAME "Gdk/WindowScalingFactor" | ||
| 190 | #endif | 192 | #endif |
| 191 | #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" | 193 | #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" |
| 192 | #endif | 194 | #endif |
| @@ -626,6 +628,15 @@ parse_settings (unsigned char *prop, | |||
| 626 | int bytes_parsed = 0; | 628 | int bytes_parsed = 0; |
| 627 | int settings_seen = 0; | 629 | int settings_seen = 0; |
| 628 | int i = 0; | 630 | int i = 0; |
| 631 | #if defined USE_CAIRO || defined HAVE_XFT | ||
| 632 | /* Some X environments, e.g. XWayland, communicate DPI changes only | ||
| 633 | through the GDK xsettings values and not the regular Xft one, so | ||
| 634 | recognize both schemes. We want to see both the GDK window scaling | ||
| 635 | factor and the post-scaling DPI so we can compute our desired | ||
| 636 | actual DPI. */ | ||
| 637 | int gdk_unscaled_dpi = 0; | ||
| 638 | int gdk_window_scale = 0; | ||
| 639 | #endif | ||
| 629 | 640 | ||
| 630 | /* First 4 bytes is a serial number, skip that. */ | 641 | /* First 4 bytes is a serial number, skip that. */ |
| 631 | 642 | ||
| @@ -668,7 +679,9 @@ parse_settings (unsigned char *prop, | |||
| 668 | want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; | 679 | want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; |
| 669 | #if defined USE_CAIRO || defined HAVE_XFT | 680 | #if defined USE_CAIRO || defined HAVE_XFT |
| 670 | if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0) | 681 | if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0) |
| 671 | || strcmp (XSETTINGS_FONT_NAME, name) == 0) | 682 | || strcmp (XSETTINGS_FONT_NAME, name) == 0 |
| 683 | || strcmp (XSETTINGS_GDK_DPI_NAME, name) == 0 | ||
| 684 | || strcmp (XSETTINGS_GDK_WSCALE_NAME, name) == 0) | ||
| 672 | want_this = true; | 685 | want_this = true; |
| 673 | #endif | 686 | #endif |
| 674 | 687 | ||
| @@ -769,6 +782,10 @@ parse_settings (unsigned char *prop, | |||
| 769 | settings->seen |= SEEN_DPI; | 782 | settings->seen |= SEEN_DPI; |
| 770 | settings->dpi = ival / 1024.0; | 783 | settings->dpi = ival / 1024.0; |
| 771 | } | 784 | } |
| 785 | else if (strcmp (name, XSETTINGS_GDK_DPI_NAME) == 0) | ||
| 786 | gdk_unscaled_dpi = ival; | ||
| 787 | else if (strcmp (name, XSETTINGS_GDK_WSCALE_NAME) == 0) | ||
| 788 | gdk_window_scale = ival; | ||
| 772 | else if (strcmp (name, "Xft/lcdfilter") == 0) | 789 | else if (strcmp (name, "Xft/lcdfilter") == 0) |
| 773 | { | 790 | { |
| 774 | settings->seen |= SEEN_LCDFILTER; | 791 | settings->seen |= SEEN_LCDFILTER; |
| @@ -786,6 +803,19 @@ parse_settings (unsigned char *prop, | |||
| 786 | } | 803 | } |
| 787 | } | 804 | } |
| 788 | 805 | ||
| 806 | #if defined USE_CAIRO || defined HAVE_XFT | ||
| 807 | if (gdk_unscaled_dpi > 0 && gdk_window_scale > 0) | ||
| 808 | { | ||
| 809 | /* Override any previous DPI settings. GDK ones are intended to | ||
| 810 | be authoritative. | ||
| 811 | See | ||
| 812 | https://mail.gnome.org/archives/commits-list/2013-June/msg06726.html | ||
| 813 | */ | ||
| 814 | settings->seen |= SEEN_DPI; | ||
| 815 | settings->dpi = gdk_window_scale * gdk_unscaled_dpi / 1024.0; | ||
| 816 | } | ||
| 817 | #endif | ||
| 818 | |||
| 789 | return settings_seen; | 819 | return settings_seen; |
| 790 | } | 820 | } |
| 791 | #endif | 821 | #endif |