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"
14 struct xdg_dbus_annotation_v1
;
25 class MenubarModelDBus
;
27 class NativeMenuGtk
: public NativeMenu
{
29 // Whether we can use native menu popups on GTK.
32 explicit NativeMenuGtk(dom::Element
* aElement
);
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();
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
> {
68 MOZ_DECLARE_REFCOUNTED_TYPENAME(DBusMenuBar
)
69 static RefPtr
<DBusMenuBar
> Create(dom::Element
*);
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
;
83 xdg_dbus_annotation_v1
* mAnnotation
= nullptr;
90 } // namespace mozilla