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__
11 #include "mozilla/MozPromise.h"
14 typedef struct _GdkDisplay GdkDisplay
;
15 typedef struct _GdkDevice GdkDevice
;
16 typedef struct _GError GError
;
17 typedef union _GdkEvent GdkEvent
;
20 namespace mozilla::widget
{
22 class WidgetUtilsGTK
{
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
{
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
);
82 // Used by startup notifications
83 nsCString
SynthesizeStartupToken();
84 void FindLatestUserTime(GdkDisplay
* aDisplay
, uintptr_t aWindow
,
85 unsigned long* aLatestTime
);
88 } // namespace mozilla::widget
90 #endif // WidgetUtilsGtk_h__