MythTV  master
mythxdisplay.h
Go to the documentation of this file.
1 
3 #ifndef _MYTHXDISPLAY_X_
4 #define _MYTHXDISPLAY_X_
5 
6 #include <QMutex>
7 
8 #ifdef USING_X11
9 #include <QSize>
10 #include <QRect>
11 #include <X11/Xlib.h>
12 #include <vector>
13 
14 #include "mythuiexp.h"
15 
17 {
18  public:
19  MythXDisplay() = default;
20  ~MythXDisplay();
21  Display *GetDisplay(void) { return m_disp; }
22  int GetScreen(void) const { return m_screen_num; }
23  void Lock(void) { m_lock.lock(); }
24  void Unlock(void) { m_lock.unlock(); }
25  int GetDepth(void) const { return m_depth; }
26  Window GetRoot(void) const { return m_root; }
27  GC GetGC(void) const { return m_gc; }
28  unsigned long GetBlack(void) const { return m_black; }
29  bool Open(void);
30  bool CreateGC(Window win);
31  void SetForeground(unsigned long color);
32  void FillRectangle(Window win, const QRect &rect);
33  void MoveResizeWin(Window win, const QRect &rect);
34  QSize GetDisplaySize(void);
35  QSize GetDisplayDimensions(void);
36  float GetRefreshRate(void);
37  void Sync(bool flush = false);
38  void StartLog(void);
39  bool StopLog(void);
40 
41  private:
42  bool CheckErrors(Display *disp = nullptr);
43  void CheckOrphanedErrors(void);
44 
45  Display *m_disp {nullptr};
46  int m_screen_num {0};
47  Screen *m_screen {nullptr};
48  int m_depth {0};
49  unsigned long m_black {0};
50  GC m_gc {nullptr};
51  Window m_root {0};
52  QMutex m_lock {QMutex::Recursive};
53 };
54 
56 {
57  public:
59  {
60  if (disp) disp->Lock();
61  }
62 
64  {
65  if (disp) disp->Unlock();
66  }
67 
68  private:
69  MythXDisplay *disp {nullptr};
70 };
71 
72 MUI_PUBLIC void LockMythXDisplays(bool lock);
75 #define XLOCK(dpy, arg) { dpy->Lock(); arg; dpy->Unlock(); }
76 #endif // USING_X11
77 
78 // These X11 defines conflict with the QT key event enum values
79 #undef KeyPress
80 #undef KeyRelease
81 
82 #endif // _MYTHXDISPLAY_X_
Display * GetDisplay(void)
Definition: mythxdisplay.h:21
MUI_PUBLIC MythXDisplay * OpenMythXDisplay(void)
MUI_PUBLIC void LockMythXDisplays(bool lock)
MythXDisplay * disp
Definition: mythxdisplay.h:69
void Unlock(void)
Definition: mythxdisplay.h:24
This file is intended to hold X11 specific utility functions.
Definition: mythxdisplay.h:16
void Lock(void)
Definition: mythxdisplay.h:23
MythXLocker(MythXDisplay *d)
Definition: mythxdisplay.h:58
unsigned long GetBlack(void) const
Definition: mythxdisplay.h:28
int GetScreen(void) const
Definition: mythxdisplay.h:22
int GetDepth(void) const
Definition: mythxdisplay.h:25
static const uint16_t * d
#define MUI_PUBLIC
Definition: mythuiexp.h:9
GC GetGC(void) const
Definition: mythxdisplay.h:27
MUI_PUBLIC MythXDisplay * GetMythXDisplay(Display *)
Window GetRoot(void) const
Definition: mythxdisplay.h:26