diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-09-16 11:19:52 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-10-10 10:33:12 +0200 |
commit | 37daee34ad85cd9d2c69a44b470755ef346d645f (patch) | |
tree | 62e54e10b8fbbf9c909ca71e6dd58df37d4f8469 /vcl | |
parent | fe9fd49ffccb6bee448c87515ae69ddde3b179c3 (diff) |
Resolves: rhbz#1373933 gtk 3.21 emits a lot more "style-set" signals
also deb#837356
since gtk3 commit of...
commit 0f116135f4a5033ce4e9dfa19f10624701fa615c
Author: Matthias Clasen <mclasen@redhat.com>
Date: Fri May 6 10:12:14 2016 -0400
Avoid emitting ::style-set by name
GtkStyle is deprecated, but we still emit ::style-set quite
a bit, so lets at least not be slow while doing it.
docs say...
'GtkWidget::style-set has been deprecated since version 3.0 and should not be
used in newly-written code.
Use the “style-updated” signal'
and this code just came over from gtk2 without any thought about it at the
time, so change it over to the "style-updated" which makes everything happy
again
gtk3 still 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.
(cherry picked from commit ef7abe81df10cb8a8c04afbb1fbe700f94e73f04)
Change-Id: I9e920d2fb2d820ff1b1b5a9ecb228484df3d6146
Reviewed-on: https://gerrit.libreoffice.org/28946
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: jan iversen <jani@documentfoundation.org>
(cherry picked from commit 243698b5520e70b54f28eed8e29bdbd551bba793)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/gtk/gtkframe.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 21 | ||||
-rw-r--r-- | vcl/unx/gtk/gtksalframe.cxx | 16 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkframe.cxx | 27 |
5 files changed, 59 insertions, 14 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 3b81c5409c71..0793b52fcd7a 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -241,7 +241,11 @@ class GtkSalFrame : public SalFrame // signals static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer ); - static void signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer ); +#if GTK_CHECK_VERSION(3,0,0) + static void signalStyleUpdated(GtkWidget*, gpointer); +#else + static void signalStyleSet(GtkWidget*, GtkStyle* pPrevious, gpointer); +#endif #if GTK_CHECK_VERSION(3,0,0) static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer ); static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame); diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 099fa110e1e9..1e2ddba5e4ec 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -230,6 +230,8 @@ public: #endif virtual const cairo_font_options_t* GetCairoFontOptions() override; + const cairo_font_options_t* GetLastSeenCairoFontOptions(); + void ResetLastSeenCairoFontOptions(); void RemoveTimer (SalTimer *pTimer); @@ -239,6 +241,7 @@ private: std::vector<GtkSalTimer *> m_aTimers; 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 6bb7bb876751..0eb942cf218b 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -157,6 +157,7 @@ GtkInstance::GtkInstance( SalYieldMutex* pMutex ) : X11SalInstance( pMutex ) #endif , bNeedsInit(true) + , m_pLastCairoFontOptions(nullptr) { } @@ -202,6 +203,7 @@ GtkInstance::~GtkInstance() while( !m_aTimers.empty() ) delete *m_aTimers.begin(); DeInitAtkBridge(); + ResetLastSeenCairoFontOptions(); } SalFrame* GtkInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) @@ -478,7 +480,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 61a9637422d3..54486111775d 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -3289,7 +3289,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 d169db381d05..6165132e0918 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1019,7 +1019,7 @@ void GtkSalFrame::InitCommon() // connect signals - g_signal_connect( G_OBJECT(m_pWindow), "style-set", G_CALLBACK(signalStyleSet), this ); + g_signal_connect( G_OBJECT(m_pWindow), "style-updated", G_CALLBACK(signalStyleUpdated), this ); gtk_widget_set_has_tooltip(pEventWidget, true); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "query-tooltip", G_CALLBACK(signalTooltipQuery), this )); m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this )); @@ -3061,20 +3061,25 @@ gboolean GtkSalFrame::signalDelete( GtkWidget*, GdkEvent*, gpointer frame ) return true; } -void GtkSalFrame::signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer frame ) +void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame) { GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); - // every frame gets an initial style set on creation - // do not post these as the whole application tends to - // redraw itself to adjust to the new style - // where there IS no new style resulting in tremendous unnecessary flickering - if( pPrevious != nullptr ) + // note: settings changed for multiple frames is avoided in winproc.cxx ImplHandleSettings + GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SALEVENT_SETTINGSCHANGED ); + + // 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) { - // signalStyleSet does NOT usually have the gdk lock - // 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 ); + pInstance->ResetLastSeenCairoFontOptions(); GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SALEVENT_FONTCHANGED ); } } |