From b9ad43e8b1cfaa7213be0eb33ed179285c33c67a Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Sun, 19 Sep 2021 11:55:08 +1000 Subject: Respond to changes in system font scaling by clearing any cached layout data. --- doc/ScintillaHistory.html | 3 +++ gtk/ScintillaGTK.cxx | 13 +++++++++++++ gtk/ScintillaGTK.h | 1 + 3 files changed, 17 insertions(+) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 1b16f2d18..3f9dd09e5 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -609,6 +609,9 @@ DejaVu Sans Mono 10.
  • + On GTK, respond to changes in system font scaling by clearing any cached layout data. +
  • +
  • On Cocoa, fix memory leak caused by circular references. Bug #2268.
  • diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 7b47d6348..92973a083 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -231,6 +231,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : im_context(nullptr), lastNonCommonScript(G_UNICODE_SCRIPT_INVALID_CODE), settings(nullptr), + settingsHandlerId(0), lastWheelMouseTime(0), lastWheelMouseDirection(0), wheelMouseIntensity(0), @@ -277,6 +278,9 @@ ScintillaGTK::~ScintillaGTK() { } ClearPrimarySelection(); wPreedit.Destroy(); + if (settingsHandlerId) { + g_signal_handler_disconnect(settings, settingsHandlerId); + } if (settings) { g_object_unref(settings); } @@ -357,6 +361,15 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { cursor = gdk_cursor_new_for_display(pdisplay, GDK_LEFT_PTR); gdk_window_set_cursor(PWindow(scrollbarh), cursor); UnRefCursor(cursor); + + using NotifyLambda = void (*)(GObject *, GParamSpec *, ScintillaGTK *); + if (settings) { + settingsHandlerId = g_signal_connect(settings, "notify::gtk-xft-dpi", + G_CALLBACK(static_cast([](GObject *, GParamSpec *, ScintillaGTK *sciThis) { + sciThis->InvalidateStyleRedraw(); + })), + this); + } } void ScintillaGTK::Realize(GtkWidget *widget) { diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index da2f74c90..022471699 100755 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -63,6 +63,7 @@ class ScintillaGTK : public ScintillaBase { GUnicodeScript lastNonCommonScript; GtkSettings *settings; + gulong settingsHandlerId; // Wheel mouse support unsigned int linesPerScroll; -- cgit v1.2.3