parent
18e919c1d6
commit
4b799c8e78
@ -0,0 +1,240 @@
|
||||
From d002f74d3e83d9a074c4a141a204d0e779dfdb4a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
||||
Date: Thu, 18 Feb 2016 21:00:57 +0000
|
||||
Subject: [PATCH] gtk3: get app menu working again under gtk3
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
and get it working under wayland too
|
||||
|
||||
Reviewed-on: https://gerrit.libreoffice.org/22491
|
||||
Tested-by: Jenkins <ci@libreoffice.org>
|
||||
Tested-by: Caolán McNamara <caolanm@redhat.com>
|
||||
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
|
||||
(cherry picked from commit 59d978389721c780b1df5e54b833fe75576dd034)
|
||||
|
||||
Change-Id: I57592acc4b7ea4a55296541ab4b3bf0c8fd98c5b
|
||||
|
||||
loplugin: checkconfigmacros
|
||||
|
||||
I suppose
|
||||
|
||||
Change-Id: I2821665548077162c4a434876aee407127b312a4
|
||||
(cherry picked from commit 2f3d85182ff9f2f1174a47b6139f358d232ee5e3)
|
||||
---
|
||||
vcl/inc/unx/gtk/gtkframe.hxx | 4 ++-
|
||||
vcl/inc/unx/gtk/gtksalmenu.hxx | 6 +++--
|
||||
vcl/unx/gtk/gtksalframe.cxx | 10 +++++---
|
||||
vcl/unx/gtk3/gtk3gtkframe.cxx | 57 ++++++++++++++++++++++++------------------
|
||||
4 files changed, 46 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
index 20a1e84..1d8334c 100644
|
||||
--- a/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
@@ -49,6 +49,8 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
+#include <config_vclplug.h>
|
||||
+
|
||||
class GtkSalGraphics;
|
||||
class GtkSalDisplay;
|
||||
|
||||
@@ -222,7 +224,7 @@ class GtkSalFrame : public SalFrame
|
||||
|
||||
SalMenu* m_pSalMenu;
|
||||
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
public:
|
||||
void EnsureDbusMenuSynced();
|
||||
private:
|
||||
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
|
||||
index 998a925..5d9c262 100644
|
||||
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
|
||||
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
|
||||
@@ -10,15 +10,17 @@
|
||||
#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKSALMENU_HXX
|
||||
#define INCLUDED_VCL_INC_UNX_GTK_GTKSALMENU_HXX
|
||||
|
||||
+#include <config_vclplug.h>
|
||||
+
|
||||
#include <vector>
|
||||
-#ifdef ENABLE_GIO
|
||||
+#if ENABLE_GIO
|
||||
#include <gio/gio.h>
|
||||
#endif
|
||||
|
||||
#include <unx/salmenu.h>
|
||||
#include <unx/gtk/gtkframe.hxx>
|
||||
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO) && \
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO && \
|
||||
(GLIB_MAJOR_VERSION > 2 || GLIB_MINOR_VERSION >= 36)
|
||||
# define ENABLE_GMENU_INTEGRATION
|
||||
# include <unx/gtk/glomenu.h>
|
||||
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
|
||||
index 7a7c293..95fd581 100644
|
||||
--- a/vcl/unx/gtk/gtksalframe.cxx
|
||||
+++ b/vcl/unx/gtk/gtksalframe.cxx
|
||||
@@ -38,8 +38,10 @@
|
||||
#include <vcl/window.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
|
||||
+#include <config_vclplug.h>
|
||||
+
|
||||
#include <unx/x11/xlimits.hxx>
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
# include <unx/gtk/gtksalmenu.hxx>
|
||||
#endif
|
||||
#if defined ENABLE_GMENU_INTEGRATION // defined in gtksalmenu.hxx above
|
||||
@@ -432,7 +434,7 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
|
||||
m_bDefaultPos = true;
|
||||
m_bDefaultSize = ( (nStyle & SalFrameStyleFlags::SIZEABLE) && ! pParent );
|
||||
m_bWindowIsGtkPlug = false;
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
m_pLastSyncedDbusMenu = nullptr;
|
||||
#endif
|
||||
Init( pParent, nStyle );
|
||||
@@ -446,7 +448,7 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
|
||||
GetGenericData()->ErrorTrapPush();
|
||||
m_bDefaultPos = true;
|
||||
m_bDefaultSize = true;
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
m_pLastSyncedDbusMenu = nullptr;
|
||||
#endif
|
||||
Init( pSysData );
|
||||
@@ -486,7 +488,7 @@ static void ObjectDestroyedNotify( gpointer data )
|
||||
}
|
||||
}
|
||||
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
void GtkSalFrame::EnsureDbusMenuSynced()
|
||||
{
|
||||
GtkSalMenu* pSalMenu = static_cast<GtkSalMenu*>(GetMenu());
|
||||
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
|
||||
index f3bdfb2..f018576 100644
|
||||
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
|
||||
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
|
||||
@@ -38,7 +38,9 @@
|
||||
#include <vcl/window.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#include <config_vclplug.h>
|
||||
+
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
# include <unx/gtk/gtksalmenu.hxx>
|
||||
#endif
|
||||
#if defined ENABLE_GMENU_INTEGRATION // defined in gtksalmenu.hxx above
|
||||
@@ -479,7 +481,7 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
|
||||
m_bDefaultPos = true;
|
||||
m_bDefaultSize = ( (nStyle & SalFrameStyleFlags::SIZEABLE) && ! pParent );
|
||||
m_bWindowIsGtkPlug = false;
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
m_pLastSyncedDbusMenu = nullptr;
|
||||
#endif
|
||||
Init( pParent, nStyle );
|
||||
@@ -495,7 +497,7 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
|
||||
GetGenericData()->ErrorTrapPush();
|
||||
m_bDefaultPos = true;
|
||||
m_bDefaultSize = true;
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
m_pLastSyncedDbusMenu = nullptr;
|
||||
#endif
|
||||
Init( pSysData );
|
||||
@@ -503,13 +505,6 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
|
||||
|
||||
#ifdef ENABLE_GMENU_INTEGRATION
|
||||
|
||||
-static void
|
||||
-gdk_x11_window_set_utf8_property (GdkWindow * /*window*/,
|
||||
- const gchar * /*name*/,
|
||||
- const gchar * /*value*/)
|
||||
-{
|
||||
-}
|
||||
-
|
||||
// AppMenu watch functions.
|
||||
|
||||
static void ObjectDestroyedNotify( gpointer data )
|
||||
@@ -519,7 +514,7 @@ static void ObjectDestroyedNotify( gpointer data )
|
||||
}
|
||||
}
|
||||
|
||||
-#if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
|
||||
+#if defined(ENABLE_DBUS) && ENABLE_GIO
|
||||
void GtkSalFrame::EnsureDbusMenuSynced()
|
||||
{
|
||||
GtkSalMenu* pSalMenu = static_cast<GtkSalMenu*>(GetMenu());
|
||||
@@ -628,7 +623,7 @@ gboolean ensure_dbus_setup( gpointer data )
|
||||
GActionGroup* pActionGroup = reinterpret_cast<GActionGroup*>(g_lo_action_group_new( static_cast< gpointer >( pSalFrame ) ));
|
||||
|
||||
// Generate menu paths.
|
||||
- ::Window windowId = GDK_WINDOW_XID( gdkWindow );
|
||||
+ sal_uIntPtr windowId = pSalFrame->GetNativeWindowHandle(pSalFrame->getWindow());
|
||||
gchar* aDBusWindowPath = g_strdup_printf( "/org/libreoffice/window/%lu", windowId );
|
||||
gchar* aDBusMenubarPath = g_strdup_printf( "/org/libreoffice/window/%lu/menus/menubar", windowId );
|
||||
|
||||
@@ -636,12 +631,32 @@ gboolean 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 );
|
||||
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice" );
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) );
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_OBJECT_PATH", "/org/libreoffice" );
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath );
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath );
|
||||
-
|
||||
+ GdkDisplay *pDisplay = pSalFrame->getGdkDisplay();
|
||||
+ // fdo#70885 we don't want app menu under Unity
|
||||
+ const bool bDesktopIsUnity = (SalGetDesktopEnvironment() == "UNITY");
|
||||
+#if defined(GDK_WINDOWING_X11)
|
||||
+ if (GDK_IS_X11_DISPLAY(pDisplay))
|
||||
+ {
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice" );
|
||||
+ if (!bDesktopIsUnity)
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APP_MENU_OBJECT_PATH", "/org/libreoffice/menus/appmenu" );
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath );
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath );
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_OBJECT_PATH", "/org/libreoffice" );
|
||||
+ gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) );
|
||||
+ }
|
||||
+#endif
|
||||
+#if defined(GDK_WINDOWING_WAYLAND)
|
||||
+ if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
|
||||
+ {
|
||||
+ gdk_wayland_window_set_dbus_properties_libgtk_only(gdkWindow, "org.libreoffice",
|
||||
+ "/org/libreoffice/menus/appmenu",
|
||||
+ !bDesktopIsUnity ? aDBusMenubarPath : nullptr,
|
||||
+ aDBusWindowPath,
|
||||
+ "/org/libreoffice",
|
||||
+ g_dbus_connection_get_unique_name( pSessionBus ));
|
||||
+ }
|
||||
+#endif
|
||||
// Publish the menu model and the action group.
|
||||
SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId);
|
||||
pSalFrame->m_nMenuExportId = g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, nullptr);
|
||||
@@ -649,12 +664,6 @@ gboolean ensure_dbus_setup( gpointer data )
|
||||
pSalFrame->m_nActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, aDBusWindowPath, pActionGroup, nullptr);
|
||||
pSalFrame->m_nHudAwarenessId = hud_awareness_register( pSessionBus, aDBusMenubarPath, hud_activated, pSalFrame, nullptr, nullptr );
|
||||
|
||||
- // fdo#70885 we don't want app menu under Unity
|
||||
- bool bDesktopIsUnity = (SalGetDesktopEnvironment() == "UNITY");
|
||||
-
|
||||
- if (!bDesktopIsUnity)
|
||||
- gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APP_MENU_OBJECT_PATH", "/org/libreoffice/menus/appmenu" );
|
||||
-
|
||||
//app menu, to-do translations, block normal menus when active, honor use appmenu settings
|
||||
ResMgr* pMgr = ImplGetResMgr();
|
||||
if( pMgr && !bDesktopIsUnity )
|
||||
--
|
||||
2.7.1
|
||||
|
Loading…
Reference in new issue