[Libreoffice-commits] core.git: vcl/inc vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 17 19:26:31 UTC 2021


 vcl/inc/unx/gtk/gtkframe.hxx |    4 +++-
 vcl/unx/gtk3/gtkframe.cxx    |   22 ++++++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 3a2d142b99cbd57bacda8746541d4cdb4216adeb
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jun 17 15:33:51 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jun 17 21:25:42 2021 +0200

    gtk4: listen to display's setting-changed
    
    in the absence of style-updated
    
    e.g. changing theme to a dark/light should change the brand image
    in the start center
    
    Change-Id: I7242019069b13093fee1430ade816a48fc0687f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117390
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index b1ddd52913b8..6fd9592c083e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -239,10 +239,12 @@ class GtkSalFrame final : public SalFrame
     void InitCommon();
     void InvalidateGraphics();
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
     // signals
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static gboolean     signalButton( GtkWidget*, GdkEventButton*, gpointer );
     static void         signalStyleUpdated(GtkWidget*, gpointer);
+#else
+    static void         signalStyleUpdated(GtkWidget*, const gchar* pSetting, pointer);
 #endif
     void DrawingAreaResized(GtkWidget* pWidget, int nWidth, int nHeight);
     void DrawingAreaDraw(cairo_t *cr);
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 14f2a2e76c59..7dcfade40a59 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -939,12 +939,14 @@ void GtkSalFrame::InitCommon()
     gtk_widget_set_redraw_on_allocate(GTK_WIDGET(m_pDrawingArea), false);
 #endif
 
-#if !GTK_CHECK_VERSION(4,0,0)
-    // connect signals
+#if GTK_CHECK_VERSION(4,0,0)
+    g_signal_connect(G_OBJECT(gtk_widget_get_display(pEventWidget)), "setting-changed", G_CALLBACK(signalStyleUpdated), this);
+#else
     // use pEventWidget instead of m_pWindow to avoid infinite event loop under Linux Mint Mate 18.3
-    g_signal_connect( G_OBJECT(pEventWidget), "style-updated", G_CALLBACK(signalStyleUpdated), this );
+    g_signal_connect(G_OBJECT(pEventWidget), "style-updated", G_CALLBACK(signalStyleUpdated), this);
 #endif
     gtk_widget_set_has_tooltip(pEventWidget, true);
+    // connect signals
     m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "query-tooltip", G_CALLBACK(signalTooltipQuery), this ));
 #if !GTK_CHECK_VERSION(4,0,0)
     m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this ));
@@ -4074,14 +4076,24 @@ gboolean GtkSalFrame::signalDelete(GtkWidget*, GdkEvent*, gpointer frame)
 }
 #endif
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+void GtkSalFrame::signalStyleUpdated(GtkWidget*, const gchar* pSetting, gpointer frame)
+#else
 void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame)
+#endif
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
 
     // note: settings changed for multiple frames is avoided in winproc.cxx ImplHandleSettings
     GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::SettingsChanged );
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+    OString sSetting(pSetting);
+    if (sSetting.startsWith("gtk-xft"))
+        GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
     // fire off font-changed when the system cairo font hints change
     GtkInstance *pInstance = static_cast<GtkInstance*>(GetSalData()->m_pInstance);
     const cairo_font_options_t* pLastCairoFontOptions = pInstance->GetLastSeenCairoFontOptions();
@@ -4096,8 +4108,10 @@ void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame)
         pInstance->ResetLastSeenCairoFontOptions(pCurrentCairoFontOptions);
         GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
     }
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 gboolean GtkSalFrame::signalWindowState( GtkWidget*, GdkEvent* pEvent, gpointer frame )
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);


More information about the Libreoffice-commits mailing list