Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / widget / gtk / NativeMenuSupport.cpp
blob60517cd5265e68cc4de120ef67414003408c3723
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 #include "mozilla/widget/NativeMenuSupport.h"
8 #include "mozilla/StaticPrefs_widget.h"
9 #include "MainThreadUtils.h"
10 #include "NativeMenuGtk.h"
11 #include "DBusMenu.h"
12 #include "nsWindow.h"
14 namespace mozilla::widget {
16 void NativeMenuSupport::CreateNativeMenuBar(nsIWidget* aParent,
17 dom::Element* aMenuBarElement) {
18 MOZ_RELEASE_ASSERT(NS_IsMainThread(),
19 "Attempting to create native menu bar on wrong thread!");
21 #ifdef MOZ_ENABLE_DBUS
22 if (aMenuBarElement && StaticPrefs::widget_gtk_global_menu_enabled() &&
23 DBusMenuFunctions::Init()) {
24 static_cast<nsWindow*>(aParent)->SetDBusMenuBar(
25 DBusMenuBar::Create(aMenuBarElement));
27 #endif
30 already_AddRefed<NativeMenu> NativeMenuSupport::CreateNativeContextMenu(
31 dom::Element* aPopup) {
32 return MakeAndAddRef<NativeMenuGtk>(aPopup);
35 bool NativeMenuSupport::ShouldUseNativeContextMenus() {
36 return NativeMenuGtk::CanUse();
39 } // namespace mozilla::widget