Backed out 2 changesets (bug 1855992) for causing talos failures @ mozilla::net:...
[gecko.git] / widget / gtk / WidgetUtilsGtk.h
blobdd49e96c501ded0384bdf7a2b184de828487561e
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 union _GdkEvent GdkEvent;
18 class nsWindow;
20 namespace mozilla::widget {
22 class WidgetUtilsGTK {
23 public:
24 /* See WidgetUtils::IsTouchDeviceSupportPresent(). */
25 static int32_t IsTouchDeviceSupportPresent();
28 bool IsMainWindowTransparent();
30 bool GdkIsWaylandDisplay(GdkDisplay* display);
31 bool GdkIsX11Display(GdkDisplay* display);
33 bool GdkIsWaylandDisplay();
34 bool GdkIsX11Display();
36 bool IsXWaylandProtocol();
38 GdkDevice* GdkGetPointer();
40 // Sets / returns the last mouse press event we processed.
41 void SetLastMousePressEvent(GdkEvent*);
42 GdkEvent* GetLastMousePressEvent();
44 // Return the snap's instance name, or null when not running as a snap.
45 const char* GetSnapInstanceName();
46 bool IsRunningUnderSnap();
47 bool IsRunningUnderFlatpak();
48 bool IsPackagedAppFileExists();
49 inline bool IsRunningUnderFlatpakOrSnap() {
50 return IsRunningUnderFlatpak() || IsRunningUnderSnap();
53 enum class PortalKind {
54 FilePicker,
55 MimeHandler,
56 Settings,
57 Location,
58 OpenUri,
60 bool ShouldUsePortal(PortalKind);
62 // Tries to get a descriptive identifier for the desktop environment that the
63 // program is running under. Always normalized to lowercase.
64 // See the implementation for the different environment variables and desktop
65 // information we try to use.
67 // If we can't find a reasonable environment, the empty string is returned.
68 const nsCString& GetDesktopEnvironmentIdentifier();
69 bool IsGnomeDesktopEnvironment();
70 bool IsKdeDesktopEnvironment();
72 // Parse text/uri-list
73 nsTArray<nsCString> ParseTextURIList(const nsACString& data);
75 using FocusRequestPromise = MozPromise<nsCString, bool, false>;
76 RefPtr<FocusRequestPromise> RequestWaylandFocusPromise();
78 } // namespace mozilla::widget
80 #endif // WidgetUtilsGtk_h__