Bug 1751217 Part 3: Make HDR-capable macOS screens report 30 pixelDepth. r=mstange
[gecko.git] / widget / gtk / nsWidgetFactory.cpp
blobd649c7e0bfe6c3df7ce2460f252b97aeabc89e37
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "nsWidgetFactory.h"
10 #include "mozilla/Components.h"
11 #include "mozilla/WidgetUtils.h"
12 #include "NativeKeyBindings.h"
13 #include "nsWidgetsCID.h"
14 #include "nsAppShell.h"
15 #include "nsAppShellSingleton.h"
16 #include "nsBaseWidget.h"
17 #include "nsGtkKeyUtils.h"
18 #include "nsLookAndFeel.h"
19 #include "nsWindow.h"
20 #include "nsHTMLFormatConverter.h"
21 #include "HeadlessClipboard.h"
22 #include "IMContextWrapper.h"
23 #ifdef MOZ_X11
24 # include "nsClipboard.h"
25 #endif
26 #include "TaskbarProgress.h"
27 #include "nsFilePicker.h"
28 #include "nsSound.h"
29 #include "nsGTKToolkit.h"
30 #include "WakeLockListener.h"
32 #include "mozilla/gfx/2D.h"
33 #include "mozilla/widget/ScreenManager.h"
34 #include <gtk/gtk.h>
36 using namespace mozilla;
37 using namespace mozilla::widget;
39 #ifdef MOZ_X11
40 NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
41 nsCOMPtr<nsIClipboard> inst;
42 if (gfxPlatform::IsHeadless()) {
43 inst = new HeadlessClipboard();
44 } else {
45 auto clipboard = MakeRefPtr<nsClipboard>();
46 if (NS_FAILED(clipboard->Init())) {
47 return nullptr;
49 inst = std::move(clipboard);
52 return inst.forget().downcast<nsISupports>();
54 #endif
56 nsresult nsWidgetGtk2ModuleCtor() { return nsAppShellInit(); }
58 void nsWidgetGtk2ModuleDtor() {
59 // Shutdown all XP level widget classes.
60 WidgetUtils::Shutdown();
62 NativeKeyBindings::Shutdown();
63 nsLookAndFeel::Shutdown();
64 nsFilePicker::Shutdown();
65 nsSound::Shutdown();
66 nsWindow::ReleaseGlobals();
67 IMContextWrapper::Shutdown();
68 KeymapWrapper::Shutdown();
69 nsGTKToolkit::Shutdown();
70 nsAppShellShutdown();
71 #ifdef MOZ_ENABLE_DBUS
72 WakeLockListener::Shutdown();
73 #endif