summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-02-18 21:00:57 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-01 14:37:55 +0000
commit56972b9899b2ec3fdc8c35cb293e0a232d7ffca3 (patch)
treed0fb8c4d2c3dca0a3591ea141b194131054ef38a /vcl
parent0a5d00507d08179d2511de0b5152e17a238f4a2d (diff)
gtk3: get app menu working again under gtk3
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) Reviewed-on: https://gerrit.libreoffice.org/22672 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx4
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx6
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx10
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx57
4 files changed, 46 insertions, 31 deletions
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 20a1e848fb4f..1d8334c97e5e 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 998a9257d699..5d9c26256a69 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 7a7c293273fb..95fd581a42b8 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 f3bdfb251b4c..f018576c7f4d 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 )