[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 17 19:27:06 UTC 2021
vcl/inc/unx/gtk/gtkframe.hxx | 3 +++
vcl/unx/gtk3/gtkframe.cxx | 28 ++++++++++++++++++----------
vcl/unx/gtk3/gtkinst.cxx | 11 ++++++++---
3 files changed, 29 insertions(+), 13 deletions(-)
New commits:
commit 560492cf578182df083fb8906a20994b3182a980
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jun 17 15:59:30 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jun 17 21:26:15 2021 +0200
gtk4: get the cairo_font_options from widget pango_context
in the absence of gdk_screen_get_font_options
SalEvent::FontChanged is successfully firing for me on changing hinting
in gnome-tweaks font section.
Change-Id: I035a07d585b59822b08c801283321ab2582649aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117393
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 6fd9592c083e..248b841dc07e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -181,6 +181,7 @@ class GtkSalFrame final : public SalFrame
GtkFixed* m_pFixedContainer;
GtkDrawingArea* m_pDrawingArea;
GtkEventControllerKey* m_pKeyController;
+ gulong m_nSettingChangedSignalId;
#endif
#if !GTK_CHECK_VERSION(4, 0, 0)
GdkWindow* m_pForeignParent;
@@ -613,6 +614,8 @@ public:
static OUString GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags);
static Selection CalcDeleteSurroundingSelection(const OUString& rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars);
+ const cairo_font_options_t* get_font_options();
+
void DisallowCycleFocusOut();
bool IsCycleFocusOutDisallowed() const;
void AllowCycleFocusOut();
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 7dcfade40a59..b32eb14ad5e7 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -705,6 +705,8 @@ GtkSalFrame::~GtkSalFrame()
gtk_widget_destroy( GTK_WIDGET(m_pEventBox) );
if( m_pTopLevelGrid )
gtk_widget_destroy( GTK_WIDGET(m_pTopLevelGrid) );
+#else
+ g_signal_handler_disconnect(G_OBJECT(gtk_widget_get_display(pEventWidget)), m_nSettingChangedSignalId);
#endif
{
SolarMutexGuard aGuard;
@@ -940,7 +942,7 @@ void GtkSalFrame::InitCommon()
#endif
#if GTK_CHECK_VERSION(4,0,0)
- g_signal_connect(G_OBJECT(gtk_widget_get_display(pEventWidget)), "setting-changed", G_CALLBACK(signalStyleUpdated), this);
+ m_nSettingChangedSignalId = 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);
@@ -4076,8 +4078,20 @@ gboolean GtkSalFrame::signalDelete(GtkWidget*, GdkEvent*, gpointer frame)
}
#endif
+const cairo_font_options_t* GtkSalFrame::get_font_options()
+{
+ GtkWidget* pWidget = getMouseEventWidget();
+#if GTK_CHECK_VERSION(4, 0, 0)
+ PangoContext* pContext = gtk_widget_get_pango_context(pWidget);
+ assert(pContext);
+ return pango_cairo_context_get_font_options(pContext);
+#else
+ return gdk_screen_get_font_options(gtk_widget_get_screen(pWidget));
+#endif
+}
+
#if GTK_CHECK_VERSION(4, 0, 0)
-void GtkSalFrame::signalStyleUpdated(GtkWidget*, const gchar* pSetting, gpointer frame)
+void GtkSalFrame::signalStyleUpdated(GtkWidget*, const gchar* /*pSetting*/, gpointer frame)
#else
void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame)
#endif
@@ -4087,17 +4101,12 @@ 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 );
-#if GTK_CHECK_VERSION(4, 0, 0)
- OString sSetting(pSetting);
- if (sSetting.startsWith("gtk-xft"))
- GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
-#endif
+ // a plausible alternative might be to send SalEvent::FontChanged if pSetting starts with "gtk-xft"
-#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();
- const cairo_font_options_t* pCurrentCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
+ const cairo_font_options_t* pCurrentCairoFontOptions = pThis->get_font_options();
bool bFontSettingsChanged = true;
if (pLastCairoFontOptions && pCurrentCairoFontOptions)
bFontSettingsChanged = !cairo_font_options_equal(pLastCairoFontOptions, pCurrentCairoFontOptions);
@@ -4108,7 +4117,6 @@ void GtkSalFrame::signalStyleUpdated(GtkWidget*, gpointer frame)
pInstance->ResetLastSeenCairoFontOptions(pCurrentCairoFontOptions);
GtkSalFrame::getDisplay()->SendInternalEvent( pThis, nullptr, SalEvent::FontChanged );
}
-#endif
}
#if !GTK_CHECK_VERSION(4, 0, 0)
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index d3ae900f75fa..5f28cb4d81c7 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -475,12 +475,17 @@ const cairo_font_options_t* GtkInstance::GetCairoFontOptions()
{
#if !GTK_CHECK_VERSION(4, 0, 0)
const cairo_font_options_t* pCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
+#else
+ auto pDefaultWin = ImplGetDefaultWindow();
+ assert(pDefaultWin);
+ SalFrame* pDefaultFrame = pDefaultWin->ImplGetFrame();
+ GtkSalFrame* pGtkFrame = dynamic_cast<GtkSalFrame*>(pDefaultFrame);
+ assert(pGtkFrame);
+ const cairo_font_options_t* pCairoFontOptions = pGtkFrame->get_font_options();
+#endif
if (!m_pLastCairoFontOptions && pCairoFontOptions)
m_pLastCairoFontOptions = cairo_font_options_copy(pCairoFontOptions);
return pCairoFontOptions;
-#else
- return nullptr;
-#endif
}
const cairo_font_options_t* GtkInstance::GetLastSeenCairoFontOptions() const
More information about the Libreoffice-commits
mailing list