Bug 1908539 restrict MacOS platform audio processing to Nightly r=webrtc-reviewers...
[gecko.git] / widget / gtk / NativeMenuGtk.h
blobca0f64c8ff3fc854af28e3bb7efda8d30ad9ceb6
1 /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_widget_NativeMenuGtk_h
7 #define mozilla_widget_NativeMenuGtk_h
9 #include "mozilla/RefCounted.h"
10 #include "mozilla/widget/NativeMenu.h"
11 #include "mozilla/EventForwards.h"
12 #include "GRefPtr.h"
14 struct xdg_dbus_annotation_v1;
16 namespace mozilla {
18 namespace dom {
19 class Element;
22 namespace widget {
24 class MenuModelGMenu;
25 class MenubarModelDBus;
27 class NativeMenuGtk : public NativeMenu {
28 public:
29 // Whether we can use native menu popups on GTK.
30 static bool CanUse();
32 explicit NativeMenuGtk(dom::Element* aElement);
34 // NativeMenu
35 MOZ_CAN_RUN_SCRIPT_BOUNDARY void ShowAsContextMenu(
36 nsIFrame* aClickedFrame, const CSSIntPoint& aPosition,
37 bool aIsContextMenu) override;
38 bool Close() override;
39 void ActivateItem(dom::Element* aItemElement, Modifiers aModifiers,
40 int16_t aButton, ErrorResult& aRv) override;
41 void OpenSubmenu(dom::Element* aMenuElement) override;
42 void CloseSubmenu(dom::Element* aMenuElement) override;
43 RefPtr<dom::Element> Element() override;
44 void AddObserver(NativeMenu::Observer* aObserver) override {
45 mObservers.AppendElement(aObserver);
47 void RemoveObserver(NativeMenu::Observer* aObserver) override {
48 mObservers.RemoveElement(aObserver);
51 MOZ_CAN_RUN_SCRIPT void OnUnmap();
53 protected:
54 virtual ~NativeMenuGtk();
56 MOZ_CAN_RUN_SCRIPT void FireEvent(EventMessage);
58 bool mPoppedUp = false;
59 RefPtr<GtkWidget> mNativeMenu;
60 RefPtr<MenuModelGMenu> mMenuModel;
61 nsTArray<NativeMenu::Observer*> mObservers;
64 #ifdef MOZ_ENABLE_DBUS
66 class DBusMenuBar final : public RefCounted<DBusMenuBar> {
67 public:
68 MOZ_DECLARE_REFCOUNTED_TYPENAME(DBusMenuBar)
69 static RefPtr<DBusMenuBar> Create(dom::Element*);
70 ~DBusMenuBar();
72 protected:
73 explicit DBusMenuBar(dom::Element* aElement);
75 static void NameOwnerChangedCallback(GObject*, GParamSpec*, gpointer);
76 void OnNameOwnerChanged();
78 nsCString mObjectPath;
79 RefPtr<MenubarModelDBus> mMenuModel;
80 RefPtr<DbusmenuServer> mServer;
81 RefPtr<GDBusProxy> mProxy;
82 # ifdef MOZ_WAYLAND
83 xdg_dbus_annotation_v1* mAnnotation = nullptr;
84 # endif
87 #endif
89 } // namespace widget
90 } // namespace mozilla
92 #endif