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 #include <QRect>
9 
10 // MythTV
11 #include "mythuiexp.h"
12 
13 // X11
14 #include <X11/Xlib.h>
15 
16 // Std
17 #include <vector>
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 &Display);
27  static bool DisplayIsRemote (void);
28 
29  MythXDisplay() = default;
30  ~MythXDisplay();
31  Display *GetDisplay(void) { return m_disp; }
32  QString GetDisplayName(void) const{ return m_displayName; }
33  int GetScreen(void) const { return m_screenNum; }
34  void Lock(void) { m_lock.lock(); }
35  void Unlock(void) { m_lock.unlock(); }
36  int GetDepth(void) const { return m_depth; }
37  Window GetRoot(void) const { return m_root; }
38  bool Open(void);
39  QSize GetDisplayDimensions(void);
40  void Sync(bool Flush = false);
41  void StartLog(void);
42  bool StopLog(void);
43 
44  private:
45  bool CheckErrors(Display *Disp = nullptr);
46  void CheckOrphanedErrors(void);
47 
48  static QString s_QtX11Display;
49 
50  Display *m_disp { nullptr };
51  int m_screenNum { 0 };
52  Screen *m_screen { nullptr };
53  int m_depth { 0 };
54  Window m_root { 0 };
55  QMutex m_lock { QMutex::Recursive };
56  QString m_displayName{ };
57 };
58 
59 // These X11 defines conflict with the QT key event enum values
60 #undef KeyPress
61 #undef KeyRelease
62 
63 #endif // MYTHXDISPLAY_X_
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythXDisplay::GetDepth
int GetDepth(void) const
Definition: mythxdisplay.h:36
MythXDisplay::GetDisplayName
QString GetDisplayName(void) const
Definition: mythxdisplay.h:32
MythXDisplay::MythXDisplay
MythXDisplay()=default
MythXDisplay::GetRoot
Window GetRoot(void) const
Definition: mythxdisplay.h:37
MythXDisplay::Unlock
void Unlock(void)
Definition: mythxdisplay.h:35
MythXDisplay::s_QtX11Display
static QString s_QtX11Display
Definition: mythxdisplay.h:48
MythXDisplay::GetDisplay
Display * GetDisplay(void)
Definition: mythxdisplay.h:31
MythXDisplay::GetScreen
int GetScreen(void) const
Definition: mythxdisplay.h:33
MythXDisplay
Definition: mythxdisplay.h:22
MythXDisplay::Lock
void Lock(void)
Definition: mythxdisplay.h:34
mythuiexp.h