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