changeset 14471:2f6f886d9a87 v8.1.0249

patch 8.1.0249: GTK: when screen DPI changes Vim does not handle it commit https://github.com/vim/vim/commit/7ebf4e1c346783b25624258e5bcc599130fd18f9 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 7 20:01:40 2018 +0200 patch 8.1.0249: GTK: when screen DPI changes Vim does not handle it Problem: GTK: when screen DPI changes Vim does not handle it. Solution: Handle the gtk-xft-dpi signal. (Roel van de Kraats, closes #2357)
author Christian Brabandt <cb@256bit.org>
date Tue, 07 Aug 2018 20:15:05 +0200
parents e9ca6470e8c2
children 34f10c103329
files src/gui_gtk_x11.c src/version.c
diffstat 2 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -788,6 +788,29 @@ property_event(GtkWidget *widget,
 }
 #endif /* defined(FEAT_CLIENTSERVER) */
 
+/*
+ * Handle changes to the "Xft/DPI" setting
+ */
+    static void
+gtk_settings_xft_dpi_changed_cb(GtkSettings *gtk_settings UNUSED,
+                                GParamSpec *pspec UNUSED,
+                                gpointer data UNUSED)
+{
+    // Create a new PangoContext for this screen, and initialize it
+    // with the current font if necessary.
+    if (gui.text_context != NULL)
+	g_object_unref(gui.text_context);
+
+    gui.text_context = gtk_widget_create_pango_context(gui.mainwin);
+    pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR);
+
+    if (gui.norm_font != NULL)
+    {
+	// force default font
+	gui_mch_init_font(*p_guifont == NUL ? NULL : p_guifont, FALSE);
+	gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
+    }
+}
 
 #if GTK_CHECK_VERSION(3,0,0)
 typedef gboolean timeout_cb_type;
@@ -4383,6 +4406,15 @@ gui_mch_init(void)
     /* Pretend we don't have input focus, we will get an event if we do. */
     gui.in_focus = FALSE;
 
+    // Handle changes to the "Xft/DPI" setting.
+    {
+	GtkSettings *gtk_settings =
+			 gtk_settings_get_for_screen(gdk_screen_get_default());
+
+	g_signal_connect(gtk_settings, "notify::gtk-xft-dpi",
+			   G_CALLBACK(gtk_settings_xft_dpi_changed_cb), NULL);
+    }
+
     return OK;
 }
 
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    249,
+/**/
     248,
 /**/
     247,