vcl/inc/unx/gtk/gtkframe.hxx | 7 ++++--- vcl/unx/gtk3/gtkframe.cxx | 27 ++++++++++++--------------- vcl/unx/gtk3/gtksalmenu.cxx | 8 +++++--- 3 files changed, 21 insertions(+), 21 deletions(-)
New commits: commit b9b7f6b36af919c1e99a8918986d22a58a9fb95c Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon May 10 10:13:38 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon May 10 12:45:42 2021 +0200 gtk4: get toplevel menubar and menus working with gtk_popover_menu_bar_new_from_model doesn't look great, long menus don't seem to scroll or anything like that, but the entries do work Change-Id: I69d6c324b9fe556067ded9acdf1af574ed784a09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115312 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index ab54f8fe3254..254d9b2ec4dd 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -57,6 +57,10 @@ class GtkInstDropTarget; class GtkInstDragSource; class GtkDnDTransferable; +#if !GTK_CHECK_VERSION(4,0,0) +typedef GdkWindow GdkSurface; +#endif + class GtkSalMenu; class GtkSalFrame final : public SalFrame @@ -221,13 +225,10 @@ class GtkSalFrame final : public SalFrame GtkSalMenu* m_pSalMenu; -#if !GTK_CHECK_VERSION(4, 0, 0) #if ENABLE_DBUS && ENABLE_GIO private: - friend void ensure_dbus_setup(GdkWindow* gdkWindow, GtkSalFrame* pSalFrame); friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer); friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer); -#endif #endif guint m_nWatcherId; diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index fb2c2554531e..52e7331ccc3b 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -491,7 +491,6 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData ) // AppMenu watch functions. -#if !GTK_CHECK_VERSION(4,0,0) static void ObjectDestroyedNotify( gpointer data ) { if ( data ) { @@ -515,7 +514,12 @@ static void hud_activated( gboolean hud_active, gpointer user_data ) static bool ensure_dbus_setup( gpointer data ) { GtkSalFrame* pSalFrame = static_cast< GtkSalFrame* >( data ); - GdkWindow* gdkWindow = gtk_widget_get_window( pSalFrame->getWindow() ); + GtkWidget* pWidget = pSalFrame->getWindow(); +#if !GTK_CHECK_VERSION(4,0,0) + GdkSurface* gdkWindow = gtk_widget_get_window(pWidget); +#else + GdkSurface* gdkWindow = gtk_native_get_surface(gtk_widget_get_native(pWidget)); +#endif if ( gdkWindow != nullptr && g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) == nullptr ) { @@ -540,8 +544,8 @@ static bool ensure_dbus_setup( gpointer data ) g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-menubar", pMenuModel, ObjectDestroyedNotify ); g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-action-group", pActionGroup, ObjectDestroyedNotify ); - GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay(); #if !GTK_CHECK_VERSION(4,0,0) + GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay(); #if defined(GDK_WINDOWING_X11) if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay)) { @@ -552,7 +556,6 @@ static bool ensure_dbus_setup( gpointer data ) gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) ); } #endif -#endif #if defined(GDK_WINDOWING_WAYLAND) if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay)) { @@ -563,6 +566,7 @@ static bool ensure_dbus_setup( gpointer data ) "/org/libreoffice", g_dbus_connection_get_unique_name( pSessionBus )); } +#endif #endif // Publish the menu model and the action group. SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId); @@ -576,7 +580,6 @@ static bool ensure_dbus_setup( gpointer data ) } return false; } -#endif void on_registrar_available( GDBusConnection * /*connection*/, const gchar * /*name*/, @@ -1131,12 +1134,8 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) #endif m_nStyle = nStyle; -#if !GTK_CHECK_VERSION(4,0,0) - GtkWindowType eWinType = ( (nStyle & SalFrameStyleFlags::FLOAT) && - ! (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) - ) - ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL; -#endif + bool bPopup = ((nStyle & SalFrameStyleFlags::FLOAT) && + !(nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION)); if( nStyle & SalFrameStyleFlags::SYSTEMCHILD ) { @@ -1153,7 +1152,7 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) else { #if !GTK_CHECK_VERSION(4,0,0) - m_pWindow = gtk_window_new(eWinType); + m_pWindow = gtk_window_new(bPopup ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL); #else m_pWindow = gtk_window_new(); #endif @@ -1273,13 +1272,11 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle ) InitCommon(); -#if !GTK_CHECK_VERSION(4,0,0) - if( eWinType == GTK_WINDOW_TOPLEVEL ) + if (!bPopup) { // Enable DBus native menu if available. ensure_dbus_setup( this ); } -#endif } #if !GTK_CHECK_VERSION(4,0,0) diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx index c02ea2004cb9..24e173711687 100644 --- a/vcl/unx/gtk3/gtksalmenu.cxx +++ b/vcl/unx/gtk3/gtksalmenu.cxx @@ -1133,10 +1133,13 @@ void GtkSalMenu::SetFrame(const SalFrame* pFrame) mpFrame->SetMenu( this ); mpFrame->EnsureAppMenuWatch(); -#if !GTK_CHECK_VERSION(4, 0, 0) // Clean menu model and action group if needed. GtkWidget* pWidget = mpFrame->getWindow(); - GdkWindow* gdkWindow = gtk_widget_get_window( pWidget ); +#if !GTK_CHECK_VERSION(4,0,0) + GdkSurface* gdkWindow = gtk_widget_get_window( pWidget ); +#else + GdkSurface* gdkWindow = gtk_native_get_surface(gtk_widget_get_native(pWidget)); +#endif GLOMenu* pMenuModel = G_LO_MENU( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) ); GLOActionGroup* pActionGroup = G_LO_ACTION_GROUP( g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-action-group" ) ); @@ -1167,7 +1170,6 @@ void GtkSalMenu::SetFrame(const SalFrame* pFrame) DestroyMenuBarWidget(); CreateMenuBarWidget(); } -#endif } const GtkSalFrame* GtkSalMenu::GetFrame() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits