Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / widget / gtk / WidgetUtilsGtk.h
blob8d6f1d67279e5d6dbac90ccd87d6ea33155679eb
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"
12 #include <stdint.h>
14 typedef struct _GdkDisplay GdkDisplay;
15 typedef struct _GdkDevice GdkDevice;
16 typedef struct _GError GError;
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 NativeMessaging,
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 #if defined(MOZ_X11)
82 // Used by startup notifications
83 nsCString SynthesizeStartupToken();
84 void FindLatestUserTime(GdkDisplay* aDisplay, uintptr_t aWindow,
85 unsigned long* aLatestTime);
86 #endif
88 } // namespace mozilla::widget
90 #endif // WidgetUtilsGtk_h__