summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-05-11 15:04:51 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-05-11 17:38:02 +0200
commit07d235414f95a74561204a3643975590cde89299 (patch)
tree35887f067f7dcf54d5eaf983e1ec885a71b8771d /vcl
parent3cc2ea2da2dad635e7e0d4375668c55b16bada55 (diff)
gtk4: tidy up messy xid/native handle behind GtkSalFrame::GetNativeWindowHandle
Change-Id: Icefbfe3922b46de8da54a8117709e3a01b4b21db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115430 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkdata.hxx7
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx2
-rw-r--r--vcl/unx/gtk3/gtkframe.cxx28
3 files changed, 17 insertions, 20 deletions
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index 85db523c2caf..747ad505abb5 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -46,13 +46,6 @@ namespace com::sun::star::accessibility { class XAccessibleEventListener; }
class GtkSalDisplay;
class DocumentFocusListener;
-#if !GTK_CHECK_VERSION(4,0,0)
-inline ::Window widget_get_xid(GtkWidget *widget)
-{
- return GDK_WINDOW_XID(gtk_widget_get_window(widget));
-}
-#endif
-
inline void main_loop_run(GMainLoop* pLoop)
{
#if !GTK_CHECK_VERSION(4, 0, 0)
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 0f74ca131e3d..189a097fd40e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -583,7 +583,7 @@ public:
static GtkSalFrame *getFromWindow( GtkWidget *pWindow );
- sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget) const;
+ static sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget);
//Call the usual SalFrame Callback, but catch uno exceptions and delegate
//to GtkSalData to rethrow them after the gsignal is processed when its safe
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 6a5df5eafb20..45df011039ef 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -65,6 +65,8 @@
# define GDK_ALT_MASK GDK_MOD1_MASK
# define GDK_TOPLEVEL_STATE_MAXIMIZED GDK_WINDOW_STATE_MAXIMIZED
# define GDK_TOPLEVEL_STATE_MINIMIZED GDK_WINDOW_STATE_ICONIFIED
+# define gdk_wayland_surface_get_wl_surface gdk_wayland_window_get_wl_surface
+# define gdk_x11_surface_get_xid gdk_x11_window_get_xid
#endif
using namespace com::sun::star;
@@ -541,7 +543,7 @@ static void attach_menu_model(GtkSalFrame* pSalFrame)
return;
// Generate menu paths.
- sal_uIntPtr windowId = pSalFrame->GetNativeWindowHandle(pWidget);
+ sal_uIntPtr windowId = GtkSalFrame::GetNativeWindowHandle(pWidget);
gchar* aDBusWindowPath = g_strdup_printf( "/org/libreoffice/window/%lu", windowId );
gchar* aDBusMenubarPath = g_strdup_printf( "/org/libreoffice/window/%lu/menus/menubar", windowId );
@@ -2149,7 +2151,7 @@ void GtkSalFrame::updateWMClass()
pClass->res_name = const_cast<char*>(aResName.getStr());
pClass->res_class = const_cast<char*>(pResClass);
XSetClassHint( display,
- widget_get_xid(m_pWindow),
+ GtkSalFrame::GetNativeWindowHandle(m_pWindow),
pClass );
XFree( pClass );
}
@@ -2195,7 +2197,7 @@ void GtkSalFrame::StartPresentation( bool bStart )
#if !GTK_CHECK_VERSION(4, 0, 0)
if( getDisplay()->IsX11Display() )
{
- aWindow = widget_get_xid(m_pWindow);
+ aWindow = GtkSalFrame::GetNativeWindowHandle(m_pWindow);
aDisplay = GDK_DISPLAY_XDISPLAY( getGdkDisplay() );
}
#endif
@@ -5232,28 +5234,30 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
return Size( aRect.GetWidth(), aRect.GetHeight() );
}
-sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) const
+sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget)
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
- (void) this; // Silence loplugin:staticmethods
+#if !GTK_CHECK_VERSION(4,0,0)
+ GdkSurface* pSurface = gtk_widget_get_window(pWidget);
+#else
+ GdkSurface* pSurface = gtk_native_get_surface(gtk_widget_get_native(pWidget));
+#endif
+
GdkDisplay *pDisplay = getGdkDisplay();
- GdkWindow *pWindow = gtk_widget_get_window(pWidget);
#if defined(GDK_WINDOWING_X11)
if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
{
- return GDK_WINDOW_XID(pWindow);
+ return gdk_x11_surface_get_xid(pSurface);
}
#endif
+
#if defined(GDK_WINDOWING_WAYLAND)
if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
{
- return reinterpret_cast<sal_uIntPtr>(gdk_wayland_window_get_wl_surface(pWindow));
+ return reinterpret_cast<sal_uIntPtr>(gdk_wayland_surface_get_wl_surface(pSurface));
}
#endif
-#else
- (void)pWidget;
-#endif
+
return 0;
}