[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/inc vcl/unx
Caolán McNamara
caolanm at redhat.com
Tue Sep 20 10:29:01 UTC 2016
vcl/inc/unx/gtk/gtkframe.hxx | 6 +++++-
vcl/inc/unx/gtk/gtkinst.hxx | 3 +++
vcl/unx/gtk/gtkinst.cxx | 21 ++++++++++++++++++++-
vcl/unx/gtk/gtksalframe.cxx | 16 +++++++++++++++-
vcl/unx/gtk3/gtk3gtkframe.cxx | 29 +++++++++++++++++------------
5 files changed, 60 insertions(+), 15 deletions(-)
New commits:
commit 2c91b27a968afb36b77e447dd623bbe81ea542f0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Sep 16 11:19:52 2016 +0100
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 at 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 also 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/28944
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 2b5dc55..1b48aa3 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -242,7 +242,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 6212d5d..f1ee273 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -239,6 +239,8 @@ public:
#endif
virtual const cairo_font_options_t* GetCairoFontOptions() override;
+ const cairo_font_options_t* GetLastSeenCairoFontOptions();
+ void ResetLastSeenCairoFontOptions();
void RemoveTimer (SalTimer *pTimer);
@@ -248,6 +250,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 c138005..1aa17fd 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 )
@@ -477,7 +479,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 031170b..c8c3869 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -3274,7 +3274,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 9ea6237..931ed03 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -993,7 +993,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 ));
@@ -3145,20 +3145,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 )
- {
- // 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 );
+ // 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)
+ {
+ pInstance->ResetLastSeenCairoFontOptions();
GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
}
}
More information about the Libreoffice-commits
mailing list