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
10 #include "X11UndefineNone.h"
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`
20 class XlibDisplay final
{
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
);
33 Display
* const mDisplay
;
36 XlibDisplay(Display
*, bool);
39 } // namespace mozilla::gfx
41 #endif // GFX_XLIBDISPLAY_H