diff options
author | Moonchild <moonchild@palemoon.org> | 2020-07-10 18:46:10 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-07-10 18:46:10 +0000 |
commit | f1b51be787c11090c8d9b2ec73255df7a67c7eb7 (patch) | |
tree | 9c6d35ce6f19e0fef3c47c7e2c152394854cf217 /widget/gtk/nsNativeMenuService.h | |
parent | 2deaddfca28508ac1a634eb6088a1da8e571ec6e (diff) | |
parent | 82faff19e1761797b7a75f9221f0709c5a38bfe6 (diff) | |
download | UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.gz UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.lz UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.xz UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.zip |
Merge branch 'redwood' into releaseRELBASE_20200711
Diffstat (limited to 'widget/gtk/nsNativeMenuService.h')
-rw-r--r-- | widget/gtk/nsNativeMenuService.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/widget/gtk/nsNativeMenuService.h b/widget/gtk/nsNativeMenuService.h new file mode 100644 index 000000000..5ce022526 --- /dev/null +++ b/widget/gtk/nsNativeMenuService.h @@ -0,0 +1,80 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __nsNativeMenuService_h__ +#define __nsNativeMenuService_h__ + +#include "mozilla/Attributes.h" +#include "nsCOMPtr.h" +#include "nsDataHashtable.h" +#include "nsINativeMenuService.h" +#include "nsTArray.h" + +#include <gdk/gdk.h> +#include <gio/gio.h> +#include <gtk/gtk.h> + +class nsMenuBar; + +/* + * The main native menu service singleton. nsWebShellWindow calls in to this when + * a new top level window is created. + * + * Menubars are owned by their nsWindow. This service holds a weak reference to + * each menubar for the purpose of re-registering them with the shell if it + * needs to. The menubar is responsible for notifying the service when the last + * reference to it is dropped. + */ +class nsNativeMenuService final : public nsINativeMenuService { +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD CreateNativeMenuBar(nsIWidget* aParent, nsIContent* aMenuBarNode) override; + + // Returns the singleton addref'd for the service manager + static already_AddRefed<nsNativeMenuService> GetInstanceForServiceManager(); + + // Returns the singleton without increasing the reference count + static nsNativeMenuService* GetSingleton(); + + // Called by a menubar when it is deleted + void NotifyNativeMenuBarDestroyed(nsMenuBar* aMenuBar); + +private: + nsNativeMenuService(); + ~nsNativeMenuService(); + nsresult Init(); + + static void EnsureInitialized(); + void SetOnline(bool aOnline); + void RegisterNativeMenuBar(nsMenuBar* aMenuBar); + static void name_owner_changed_cb(GObject* gobject, + GParamSpec* pspec, + gpointer user_data); + static void proxy_created_cb(GObject* source_object, + GAsyncResult* res, + gpointer user_data); + static void register_native_menubar_cb(GObject* source_object, + GAsyncResult* res, + gpointer user_data); + static gboolean map_event_cb(GtkWidget* widget, GdkEvent* event, + gpointer user_data); + void OnNameOwnerChanged(); + void OnProxyCreated(GDBusProxy* aProxy); + void OnNativeMenuBarRegistered(nsMenuBar* aMenuBar, + bool aSuccess); + static void PrefChangedCallback(const char* aPref, void* aClosure); + void PrefChanged(); + + GCancellable* mCreateProxyCancellable; + GDBusProxy* mDbusProxy; + bool mOnline; + nsTArray<nsMenuBar* > mMenuBars; + nsDataHashtable<nsPtrHashKey<nsMenuBar>, GCancellable*> mMenuBarRegistrationCancellables; + + static bool sShutdown; + static nsNativeMenuService* sService; +}; + +#endif /* __nsNativeMenuService_h__ */ |