00001
00003 #ifndef _MYTHXDISPLAY_X_
00004 #define _MYTHXDISPLAY_X_
00005
00006 #include <QMutex>
00007
00008 #ifdef USING_X11
00009 #include <QSize>
00010 #include <QRect>
00011 #include <X11/Xlib.h>
00012 #include <vector>
00013
00014 #include "mythuiexp.h"
00015
00016 class MUI_PUBLIC MythXDisplay
00017 {
00018 public:
00019 MythXDisplay();
00020 ~MythXDisplay();
00021 Display *GetDisplay(void) { return m_disp; }
00022 int GetScreen(void) const { return m_screen_num; }
00023 void Lock(void) { m_lock.lock(); }
00024 void Unlock(void) { m_lock.unlock(); }
00025 int GetDepth(void) const { return m_depth; }
00026 Window GetRoot(void) const { return m_root; }
00027 GC GetGC(void) const { return m_gc; }
00028 unsigned long GetBlack(void) const { return m_black; }
00029 bool Open(void);
00030 bool CreateGC(Window win);
00031 void SetForeground(unsigned long color);
00032 void FillRectangle(Window win, const QRect &rect);
00033 void MoveResizeWin(Window win, const QRect &rect);
00034 int GetNumberXineramaScreens(void);
00035 QSize GetDisplaySize(void);
00036 QSize GetDisplayDimensions(void);
00037 float GetRefreshRate(void);
00038 void Sync(bool flush = false);
00039 void StartLog(void);
00040 bool StopLog(void);
00041
00042 private:
00043 bool CheckErrors(Display *disp = NULL);
00044 void CheckOrphanedErrors(void);
00045
00046 Display *m_disp;
00047 int m_screen_num;
00048 Screen *m_screen;
00049 int m_depth;
00050 unsigned long m_black;
00051 GC m_gc;
00052 Window m_root;
00053 QMutex m_lock;
00054 };
00055
00056 class MythXLocker
00057 {
00058 public:
00059 MythXLocker(MythXDisplay*d) : disp(d)
00060 {
00061 if (disp) disp->Lock();
00062 }
00063
00064 ~MythXLocker()
00065 {
00066 if (disp) disp->Unlock();
00067 }
00068
00069 private:
00070 MythXDisplay *disp;
00071 };
00072
00073 MUI_PUBLIC void LockMythXDisplays(bool lock);
00074 MUI_PUBLIC MythXDisplay *GetMythXDisplay(Display*);
00075 MUI_PUBLIC MythXDisplay *OpenMythXDisplay(void);
00076 #define XLOCK(dpy, arg) { dpy->Lock(); arg; dpy->Unlock(); }
00077 #endif // USING_X11
00078
00079
00080 #undef KeyPress
00081 #undef KeyRelease
00082
00083 #endif // _MYTHXDISPLAY_X_