1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __BaseDisplay_hh
3 #define __BaseDisplay_hh
5 #include "screeninfo.hh"
10 #include <X11/Xatom.h>
15 // forward declaration
19 class BaseDisplay: public TimerQueueManager {
23 int event_basep, error_basep;
30 int event_basep, error_basep;
31 int major, minor; // version
36 unsigned int MaskList[8];
37 size_t MaskListLength;
39 enum RunState { STARTUP, RUNNING, SHUTDOWN };
43 mutable BGCCache *gccache;
45 typedef std::vector<ScreenInfo> ScreenInfoList;
46 ScreenInfoList screenInfoList;
49 const char *display_name, *application_name;
52 BaseDisplay(const BaseDisplay &);
53 BaseDisplay& operator=(const BaseDisplay&);
56 // pure virtual function... you must override this
57 virtual void process_event(XEvent *e) = 0;
59 // the masks of the modifiers which are ignored in button events.
60 int NumLockMask, ScrollLockMask;
64 BaseDisplay(const char *app_name, const char *dpy_name = 0);
65 virtual ~BaseDisplay(void);
67 const ScreenInfo* getScreenInfo(const unsigned int s) const;
69 BGCCache *gcCache(void) const;
71 inline bool hasShapeExtensions(void) const
72 { return shape.extensions; }
74 inline bool hasXineramaExtensions(void) const
75 { return xinerama.extensions; }
77 inline bool doShutdown(void) const
78 { return run_state == SHUTDOWN; }
79 inline bool isStartup(void) const
80 { return run_state == STARTUP; }
82 inline Display *getXDisplay(void) const { return display; }
84 inline const char *getXDisplayName(void) const
85 { return display_name; }
86 inline const char *getApplicationName(void) const
87 { return application_name; }
89 inline unsigned int getNumberOfScreens(void) const
90 { return screenInfoList.size(); }
91 inline int getShapeEventBase(void) const
92 { return shape.event_basep; }
94 inline int getXineramaMajorVersion(void) const
95 { return xinerama.major; }
98 inline void shutdown(void) { run_state = SHUTDOWN; }
99 inline void run(void) { run_state = RUNNING; }
101 void grabButton(unsigned int button, unsigned int modifiers,
102 Window grab_window, bool owner_events,
103 unsigned int event_mask, int pointer_mode,
104 int keyboard_mode, Window confine_to, Cursor cursor,
105 bool allow_scroll_lock) const;
106 void ungrabButton(unsigned int button, unsigned int modifiers,
107 Window grab_window) const;
109 void eventLoop(void);
111 // from TimerQueueManager interface
112 virtual void addTimer(BTimer *timer);
113 virtual void removeTimer(BTimer *timer);
115 // another pure virtual... this is used to handle signals that BaseDisplay
116 // doesn't understand itself
117 virtual bool handleSignal(int sig) = 0;
121 #endif // __BaseDisplay_hh