Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / gtk / WidgetUtilsGtk.h
blobffd7425ae5cb1e2226308defd2a913da8b9b9f3c
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 #ifndef WidgetUtilsGtk_h__
7 #define WidgetUtilsGtk_h__
9 #include "nsString.h"
10 #include "nsTArray.h"
11 #include "mozilla/MozPromise.h"
13 #include <stdint.h>
15 typedef struct _GdkDisplay GdkDisplay;
16 typedef struct _GdkDevice GdkDevice;
17 typedef struct _GError GError;
18 typedef union _GdkEvent GdkEvent;
19 class nsWindow;
21 namespace mozilla::widget {
23 class WidgetUtilsGTK {
24 public:
25 /* See WidgetUtils::IsTouchDeviceSupportPresent(). */
26 static int32_t IsTouchDeviceSupportPresent();
29 bool IsMainWindowTransparent();
31 bool GdkIsWaylandDisplay(GdkDisplay* display);
32 bool GdkIsX11Display(GdkDisplay* display);
34 bool GdkIsWaylandDisplay();
35 bool GdkIsX11Display();
37 bool IsXWaylandProtocol();
39 GdkDevice* GdkGetPointer();
41 // Sets / returns the last mouse press event we processed.
42 void SetLastMousePressEvent(GdkEvent*);
43 GdkEvent* GetLastMousePressEvent();
45 // Return the snap's instance name, or null when not running as a snap.
46 const char* GetSnapInstanceName();
47 bool IsRunningUnderSnap();
48 bool IsRunningUnderFlatpak();
49 bool IsPackagedAppFileExists();
50 inline bool IsRunningUnderFlatpakOrSnap() {
51 return IsRunningUnderFlatpak() || IsRunningUnderSnap();
54 enum class PortalKind {
55 FilePicker,
56 MimeHandler,
57 Settings,
58 Location,
59 OpenUri,
61 bool ShouldUsePortal(PortalKind);
63 // Tries to get a descriptive identifier for the desktop environment that the
64 // program is running under. Always normalized to lowercase.
65 // See the implementation for the different environment variables and desktop
66 // information we try to use.
68 // If we can't find a reasonable environment, the empty string is returned.
69 const nsCString& GetDesktopEnvironmentIdentifier();
70 bool IsGnomeDesktopEnvironment();
71 bool IsKdeDesktopEnvironment();
73 // Parse text/uri-list
74 nsTArray<nsCString> ParseTextURIList(const nsACString& data);
76 using FocusRequestPromise = MozPromise<nsCString, bool, false>;
77 RefPtr<FocusRequestPromise> RequestWaylandFocusPromise();
79 bool IsCancelledGError(GError* aGError);
81 } // namespace mozilla::widget
83 #endif // WidgetUtilsGtk_h__