Bug 1891710: part 2) Enable <Element-outerHTML.html> WPT for Trusted Types. r=smaug
[gecko.git] / gfx / src / X11Util.h
blob9f41882002862ae05cfdc482a972d242239ca41d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_X11Util_h
8 #define mozilla_X11Util_h
10 // Utilities common to all X clients, regardless of UI toolkit.
12 #if defined(MOZ_WIDGET_GTK)
13 # include <gdk/gdk.h>
14 # include <gdk/gdkx.h>
15 # include "mozilla/WidgetUtilsGtk.h"
16 # include "X11UndefineNone.h"
17 #else
18 # error Unknown toolkit
19 #endif
21 #include <string.h> // for memset
23 namespace mozilla {
25 /**
26 * Return the default X Display created and used by the UI toolkit.
28 inline Display* DefaultXDisplay() {
29 #if defined(MOZ_WIDGET_GTK)
30 GdkDisplay* gdkDisplay = gdk_display_get_default();
31 if (mozilla::widget::GdkIsX11Display(gdkDisplay)) {
32 return GDK_DISPLAY_XDISPLAY(gdkDisplay);
34 #endif
35 return nullptr;
38 /**
39 * Sets *aVisual to point to aDisplay's Visual struct corresponding to
40 * aVisualID, and *aDepth to its depth. When aVisualID is None, these are set
41 * to nullptr and 0 respectively. Both out-parameter pointers are assumed
42 * non-nullptr.
44 void FindVisualAndDepth(Display* aDisplay, VisualID aVisualID, Visual** aVisual,
45 int* aDepth);
47 /**
48 * Ensure that all X requests have been processed.
50 * This is similar to XSync, but doesn't need a round trip if the previous
51 * request was synchronous or if events have been received since the last
52 * request. Subsequent FinishX calls will be noops if there have been no
53 * intermediate requests.
56 void FinishX(Display* aDisplay);
58 } // namespace mozilla
60 #endif // mozilla_X11Util_h