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