Related: rhbz#1373933 gtk3 emits a lot of style-updated signals

f41
Caolán McNamara 8 years ago
parent 042c7d7b38
commit b5ebfbeb86

@ -0,0 +1,141 @@
From fce92e8db5bed5067e82a896513c9e43bdc40b4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 19 Sep 2016 09:26:22 +0100
Subject: [PATCH] Related: rhbz#1373933 gtk3 emits a lot of style-updateds
signals
so don't throw away font settings every time, check if the font settings
changed and only emit FontChanged if they differ from the last seen settings.
Change-Id: I129887e3e866f395da3b906a38cf568abea5de8e
---
vcl/inc/unx/gtk/gtkinst.hxx | 3 +++
vcl/unx/gtk/gtkinst.cxx | 21 ++++++++++++++++++++-
vcl/unx/gtk/gtksalframe.cxx | 16 +++++++++++++++-
vcl/unx/gtk3/gtk3gtkframe.cxx | 16 +++++++++++++++-
4 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 490cf69..514b13f 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -242,6 +242,8 @@ public:
#endif
virtual const cairo_font_options_t* GetCairoFontOptions() override;
+ const cairo_font_options_t* GetLastSeenCairoFontOptions();
+ void ResetLastSeenCairoFontOptions();
void RemoveTimer (SalTimer *pTimer);
@@ -254,6 +256,7 @@ private:
#endif
bool IsTimerExpired();
bool bNeedsInit;
+ cairo_font_options_t* m_pLastCairoFontOptions;
mutable std::shared_ptr<vcl::unx::GtkPrintWrapper> m_xPrintWrapper;
};
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 0f62467..9a535f0 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -155,6 +155,7 @@ GtkInstance::GtkInstance( SalYieldMutex* pMutex )
: X11SalInstance( pMutex )
#endif
, bNeedsInit(true)
+ , m_pLastCairoFontOptions(nullptr)
{
}
@@ -200,6 +201,7 @@ GtkInstance::~GtkInstance()
while( !m_aTimers.empty() )
delete *m_aTimers.begin();
DeInitAtkBridge();
+ ResetLastSeenCairoFontOptions();
}
SalFrame* GtkInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
@@ -483,7 +485,24 @@ GtkInstance::getPrintWrapper() const
const cairo_font_options_t* GtkInstance::GetCairoFontOptions()
{
- return gdk_screen_get_font_options(gdk_screen_get_default());
+ const cairo_font_options_t* pCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
+ if (!m_pLastCairoFontOptions && pCairoFontOptions)
+ m_pLastCairoFontOptions = cairo_font_options_copy(pCairoFontOptions);
+ return pCairoFontOptions;
+}
+
+const cairo_font_options_t* GtkInstance::GetLastSeenCairoFontOptions()
+{
+ return m_pLastCairoFontOptions;
+}
+
+void GtkInstance::ResetLastSeenCairoFontOptions()
+{
+ if (m_pLastCairoFontOptions)
+ {
+ cairo_font_options_destroy(m_pLastCairoFontOptions);
+ m_pLastCairoFontOptions = nullptr;
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 0d872cf..9167a3f 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -3235,7 +3235,21 @@ void GtkSalFrame::signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer fram
// so post user event to safely dispatch the SalEvent::SettingsChanged
// note: settings changed for multiple frames is avoided in winproc.cxx ImplHandleSettings
GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::SettingsChanged );
- GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
+
+ // 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();
+ const cairo_font_options_t* pCurrentCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
+ bool bFontSettingsChanged = true;
+ if (pLastCairoFontOptions && pCurrentCairoFontOptions)
+ bFontSettingsChanged = !cairo_font_options_equal(pLastCairoFontOptions, pCurrentCairoFontOptions);
+ else if (!pLastCairoFontOptions && !pCurrentCairoFontOptions)
+ bFontSettingsChanged = false;
+ if (bFontSettingsChanged)
+ {
+ pInstance->ResetLastSeenCairoFontOptions();
+ GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
+ }
}
/* #i64117# gtk sets a nice background pixmap
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 49bce84..3d3fc9e 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -3107,7 +3107,21 @@ void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame)
// note: settings changed for multiple frames is avoided in winproc.cxx ImplHandleSettings
GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::SettingsChanged );
- GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
+
+ // 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();
+ const cairo_font_options_t* pCurrentCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
+ bool bFontSettingsChanged = true;
+ if (pLastCairoFontOptions && pCurrentCairoFontOptions)
+ bFontSettingsChanged = !cairo_font_options_equal(pLastCairoFontOptions, pCurrentCairoFontOptions);
+ else if (!pLastCairoFontOptions && !pCurrentCairoFontOptions)
+ bFontSettingsChanged = false;
+ if (bFontSettingsChanged)
+ {
+ pInstance->ResetLastSeenCairoFontOptions();
+ GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
+ }
}
gboolean GtkSalFrame::signalWindowState( GtkWidget*, GdkEvent* pEvent, gpointer frame )
--
2.7.4

@ -242,6 +242,7 @@ Patch11: 0001-Resolves-rhbz-1352965-gtk3-infinite-clipboard-recurs.patch
Patch12: 0001-Related-rhbz-1351369-gtk3-clipboards-have-to-live-to.patch
Patch13: 0001-add-xdg-email-as-the-default-email-route.patch
Patch14: 0001-Resolves-rhbz-1373933-gtk-3.21-emits-a-lot-more-styl.patch
Patch15: 0001-Related-rhbz-1373933-gtk3-emits-a-lot-of-style-updat.patch
%if 0%{?rhel}
# not upstreamed

Loading…
Cancel
Save