Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / gtk / nsWidgetFactory.cpp
blob7f06e8f9f3cb7bdb9b81c2268c14c8f42d6ea09b
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 #include "nsClipboard.h"
24 #include "TaskbarProgress.h"
25 #include "nsFilePicker.h"
26 #include "nsSound.h"
27 #include "nsGTKToolkit.h"
28 #include "WakeLockListener.h"
30 #include "mozilla/gfx/2D.h"
31 #include "mozilla/widget/ScreenManager.h"
32 #include <gtk/gtk.h>
34 using namespace mozilla;
35 using namespace mozilla::widget;
37 NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
38 nsCOMPtr<nsIClipboard> inst;
39 if (gfxPlatform::IsHeadless()) {
40 inst = new HeadlessClipboard();
41 } else {
42 auto clipboard = MakeRefPtr<nsClipboard>();
43 if (NS_FAILED(clipboard->Init())) {
44 return nullptr;
46 inst = std::move(clipboard);
49 return inst.forget().downcast<nsISupports>();
52 nsresult nsWidgetGtk2ModuleCtor() { return nsAppShellInit(); }
54 void nsWidgetGtk2ModuleDtor() {
55 // Shutdown all XP level widget classes.
56 WidgetUtils::Shutdown();
58 NativeKeyBindings::Shutdown();
59 nsLookAndFeel::Shutdown();
60 nsFilePicker::Shutdown();
61 nsSound::Shutdown();
62 nsWindow::ReleaseGlobals();
63 IMContextWrapper::Shutdown();
64 KeymapWrapper::Shutdown();
65 nsGTKToolkit::Shutdown();
66 nsAppShellShutdown();