Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / thebes / XlibDisplay.h
blob0c0f8413a43c83d936a681c84c07668ef1617041
1 /* -*- Mode: C++; tab-width: 20; 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 GFX_XLIBDISPLAY_H
7 #define GFX_XLIBDISPLAY_H
9 #include <X11/Xlib.h>
10 #include "X11UndefineNone.h"
12 #include <memory>
14 namespace mozilla::gfx {
16 // Represents an X11 display connection which may be either borrowed
17 // (e.g., from GTK) or owned; in the latter case it will be closed
18 // with this object becomes unreferenced. See also the `EglDisplay`
19 // class.
20 class XlibDisplay final {
21 public:
22 ~XlibDisplay();
24 // Explicit `->get()` may be needed with some `Xlib.h` macros that
25 // expand to C-style pointer casts.
26 Display* get() const { return mDisplay; }
27 operator Display*() const { return mDisplay; }
29 static std::shared_ptr<XlibDisplay> Borrow(Display* aDisplay);
30 static std::shared_ptr<XlibDisplay> Open(const char* aDisplayName);
32 private:
33 Display* const mDisplay;
34 bool const mOwned;
36 XlibDisplay(Display*, bool);
39 } // namespace mozilla::gfx
41 #endif // GFX_XLIBDISPLAY_H