Skip to content

Commit 7ebf4e1

Browse files
committed
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)
1 parent 8d8a65e commit 7ebf4e1

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/gui_gtk_x11.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,29 @@ property_event(GtkWidget *widget,
788788
}
789789
#endif /* defined(FEAT_CLIENTSERVER) */
790790

791+
/*
792+
* Handle changes to the "Xft/DPI" setting
793+
*/
794+
static void
795+
gtk_settings_xft_dpi_changed_cb(GtkSettings *gtk_settings UNUSED,
796+
GParamSpec *pspec UNUSED,
797+
gpointer data UNUSED)
798+
{
799+
// Create a new PangoContext for this screen, and initialize it
800+
// with the current font if necessary.
801+
if (gui.text_context != NULL)
802+
g_object_unref(gui.text_context);
803+
804+
gui.text_context = gtk_widget_create_pango_context(gui.mainwin);
805+
pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR);
806+
807+
if (gui.norm_font != NULL)
808+
{
809+
// force default font
810+
gui_mch_init_font(*p_guifont == NUL ? NULL : p_guifont, FALSE);
811+
gui_set_shellsize(TRUE, FALSE, RESIZE_BOTH);
812+
}
813+
}
791814

792815
#if GTK_CHECK_VERSION(3,0,0)
793816
typedef gboolean timeout_cb_type;
@@ -4383,6 +4406,15 @@ gui_mch_init(void)
43834406
/* Pretend we don't have input focus, we will get an event if we do. */
43844407
gui.in_focus = FALSE;
43854408

4409+
// Handle changes to the "Xft/DPI" setting.
4410+
{
4411+
GtkSettings *gtk_settings =
4412+
gtk_settings_get_for_screen(gdk_screen_get_default());
4413+
4414+
g_signal_connect(gtk_settings, "notify::gtk-xft-dpi",
4415+
G_CALLBACK(gtk_settings_xft_dpi_changed_cb), NULL);
4416+
}
4417+
43864418
return OK;
43874419
}
43884420

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
249,
797799
/**/
798800
248,
799801
/**/

0 commit comments

Comments
 (0)