MythTV  master
mythxdisplay.h
Go to the documentation of this file.
1 #ifndef MYTHXDISPLAY_X_
2 #define MYTHXDISPLAY_X_
3 
4 // Qt
5 #include <QString>
6 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
7 #include <QMutex>
8 #else
9 #include <QRecursiveMutex>
10 #endif
11 #include <QSize>
12 
13 // MythTV
14 #include "mythuiexp.h"
15 
16 // X11
17 #include <X11/Xlib.h>
18 
19 #define XLOCK(dpy, arg) { (dpy)->Lock(); arg; (dpy)->Unlock(); }
20 
22 {
23  public:
24 
25  static MythXDisplay* OpenMythXDisplay(bool Warn = true);
26  static void SetQtX11Display (const QString &DisplayStr);
27  static bool DisplayIsRemote ();
28 
29  MythXDisplay() = default;
30  ~MythXDisplay();
31  Display* GetDisplay() { return m_disp; }
32  QString GetDisplayName() const{ return m_displayName; }
33  int GetScreen() const { return m_screenNum; }
34  void Lock() { m_lock.lock(); }
35  void Unlock() { m_lock.unlock(); }
36  int GetDepth() const { return m_depth; }
37  Window GetRoot() const { return m_root; }
38  bool Open();
39  QSize GetDisplayDimensions();
40  void Sync(bool Flush = false);
41 
42  private:
43  static inline QString s_QtX11Display;
44 
45  Display* m_disp { nullptr };
46  int m_screenNum { 0 };
47  Screen* m_screen { nullptr };
48  int m_depth { 0 };
49  Window m_root { 0 };
50 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
51  QMutex m_lock { QMutex::Recursive };
52 #else
53  QRecursiveMutex m_lock;
54 #endif
55  QString m_displayName { };
56 };
57 
58 // These X11 defines conflict with the QT key event enum values
59 #undef KeyPress
60 #undef KeyRelease
61 
62 #endif
MythXDisplay::Lock
void Lock()
Definition: mythxdisplay.h:34
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythXDisplay::GetDisplay
Display * GetDisplay()
Definition: mythxdisplay.h:31
MythXDisplay::GetScreen
int GetScreen() const
Definition: mythxdisplay.h:33
MythXDisplay::GetDepth
int GetDepth() const
Definition: mythxdisplay.h:36
MythXDisplay::GetDisplayName
QString GetDisplayName() const
Definition: mythxdisplay.h:32
MythXDisplay::s_QtX11Display
static QString s_QtX11Display
Definition: mythxdisplay.h:43
MythXDisplay::m_lock
QRecursiveMutex m_lock
Definition: mythxdisplay.h:53
MythXDisplay::Unlock
void Unlock()
Definition: mythxdisplay.h:35
MythXDisplay
Definition: mythxdisplay.h:21
MythXDisplay::GetRoot
Window GetRoot() const
Definition: mythxdisplay.h:37
mythuiexp.h