diff --git a/widget/gtk/NativeMenuGtk.cpp b/widget/gtk/NativeMenuGtk.cpp index 8806535f1e05..7c74e46f5e48 100644 --- a/widget/gtk/NativeMenuGtk.cpp +++ b/widget/gtk/NativeMenuGtk.cpp @@ -444,6 +444,8 @@ void NativeMenuGtk::CloseSubmenu(dom::Element*) { // TODO: For testing mostly. } +#ifdef MOZ_ENABLE_DBUS + class MenubarModelDBus final : public MenuModel { public: explicit MenubarModelDBus(dom::Element* aElement) : MenuModel(aElement) { @@ -517,7 +519,7 @@ static uint32_t KeyFrom(const dom::Element* aElement) { return ParseKey(key, keycode); } -// TODO(emilio): Unifiy with nsMenuUtilsX::GeckoModifiersForNodeAttribute (or +// TODO(emilio): Unify with nsMenuUtilsX::GeckoModifiersForNodeAttribute (or // at least switch to strtok_r). static uint32_t ParseModifiers(const nsAString& aModifiers) { if (aModifiers.IsEmpty()) { @@ -730,7 +732,7 @@ void DBusMenuBar::OnNameOwnerChanged() { return; } -#ifdef MOZ_WAYLAND +# ifdef MOZ_WAYLAND if (auto* display = widget::WaylandDisplayGet()) { xdg_dbus_annotation_manager_v1* annotationManager = display->GetXdgDbusAnnotationManager(); @@ -757,8 +759,8 @@ void DBusMenuBar::OnNameOwnerChanged() { mObjectPath.get()); return; } -#endif -#ifdef MOZ_X11 +# endif +# ifdef MOZ_X11 // legacy path auto xid = GDK_WINDOW_XID(gdkWin); widget::DBusProxyCall(mProxy, "RegisterWindow", @@ -774,7 +776,7 @@ void DBusMenuBar::OnNameOwnerChanged() { aError->message); self->mMenuModel->Element()->SetBoolAttr(nsGkAtoms::hidden, false); }); -#endif +# endif } static unsigned sID = 0; @@ -812,5 +814,6 @@ RefPtr DBusMenuBar::Create(dom::Element* aElement) { } DBusMenuBar::~DBusMenuBar() = default; +#endif } // namespace mozilla::widget diff --git a/widget/gtk/NativeMenuGtk.h b/widget/gtk/NativeMenuGtk.h index 5b8b0d7b5ac0..ca0f64c8ff3f 100644 --- a/widget/gtk/NativeMenuGtk.h +++ b/widget/gtk/NativeMenuGtk.h @@ -61,6 +61,8 @@ class NativeMenuGtk : public NativeMenu { nsTArray mObservers; }; +#ifdef MOZ_ENABLE_DBUS + class DBusMenuBar final : public RefCounted { public: MOZ_DECLARE_REFCOUNTED_TYPENAME(DBusMenuBar) @@ -77,11 +79,13 @@ class DBusMenuBar final : public RefCounted { RefPtr mMenuModel; RefPtr mServer; RefPtr mProxy; -#ifdef MOZ_WAYLAND +# ifdef MOZ_WAYLAND xdg_dbus_annotation_v1* mAnnotation = nullptr; -#endif +# endif }; +#endif + } // namespace widget } // namespace mozilla diff --git a/widget/gtk/NativeMenuSupport.cpp b/widget/gtk/NativeMenuSupport.cpp index 32f05ae1c3d6..60517cd5265e 100644 --- a/widget/gtk/NativeMenuSupport.cpp +++ b/widget/gtk/NativeMenuSupport.cpp @@ -18,11 +18,13 @@ void NativeMenuSupport::CreateNativeMenuBar(nsIWidget* aParent, MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Attempting to create native menu bar on wrong thread!"); +#ifdef MOZ_ENABLE_DBUS if (aMenuBarElement && StaticPrefs::widget_gtk_global_menu_enabled() && DBusMenuFunctions::Init()) { static_cast(aParent)->SetDBusMenuBar( DBusMenuBar::Create(aMenuBarElement)); } +#endif } already_AddRefed NativeMenuSupport::CreateNativeContextMenu( diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build index d92f56d3655c..87866b1a9b53 100644 --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build @@ -63,7 +63,6 @@ UNIFIED_SOURCES += [ "AsyncGtkClipboardRequest.cpp", "CompositorWidgetChild.cpp", "CompositorWidgetParent.cpp", - "DBusMenu.cpp", "DMABufLibWrapper.cpp", "DMABufSurface.cpp", "GfxInfo.cpp", @@ -174,6 +173,7 @@ if CONFIG["MOZ_ENABLE_DBUS"]: ] UNIFIED_SOURCES += [ "AsyncDBus.cpp", + "DBusMenu.cpp", ] CXXFLAGS += CONFIG["MOZ_DBUS_CFLAGS"] diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 4442506a8e45..d9d263997544 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -6984,10 +6984,12 @@ void nsWindow::UpdateWindowDraggingRegion( } } +#ifdef MOZ_ENABLE_DBUS void nsWindow::SetDBusMenuBar( RefPtr aDbusMenuBar) { mDBusMenuBar = std::move(aDbusMenuBar); } +#endif LayoutDeviceIntCoord nsWindow::GetTitlebarRadius() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index 4a2525294e4b..f8fe344f09b5 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -374,7 +374,9 @@ class nsWindow final : public nsBaseWidget { void UpdateWindowDraggingRegion( const LayoutDeviceIntRegion& aRegion) override; +#ifdef MOZ_ENABLE_DBUS void SetDBusMenuBar(RefPtr aDbusMenuBar); +#endif // HiDPI scale conversion gint GdkCeiledScaleFactor(); @@ -908,7 +910,9 @@ class nsWindow final : public nsBaseWidget { RefPtr mWaylandPopupNext; RefPtr mWaylandPopupPrev; +#ifdef MOZ_ENABLE_DBUS RefPtr mDBusMenuBar; +#endif // When popup is resized by Gtk by move-to-rect callback, // we store final popup size here. Then we use mMoveToRectPopupSize size