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
18 class BaseDisplay
: public TimerQueueManager
{
22 int event_basep
, error_basep
;
29 int event_basep
, error_basep
;
30 int major
, minor
; // version
35 unsigned int MaskList
[8];
36 size_t MaskListLength
;
38 enum RunState
{ STARTUP
, RUNNING
, SHUTDOWN
};
42 mutable BGCCache
*gccache
;
44 typedef std::vector
<ScreenInfo
> ScreenInfoList
;
45 ScreenInfoList screenInfoList
;
48 const char *display_name
, *application_name
;
51 BaseDisplay(const BaseDisplay
&);
52 BaseDisplay
& operator=(const BaseDisplay
&);
55 // pure virtual function... you must override this
56 virtual void process_event(XEvent
*e
) = 0;
58 // the masks of the modifiers which are ignored in button events.
59 int NumLockMask
, ScrollLockMask
;
63 BaseDisplay(const char *app_name
, const char *dpy_name
= 0);
64 virtual ~BaseDisplay(void);
66 const ScreenInfo
* getScreenInfo(const unsigned int s
) const;
68 BGCCache
*gcCache(void) const;
70 inline bool hasShapeExtensions(void) const
71 { return shape
.extensions
; }
73 inline bool hasXineramaExtensions(void) const
74 { return xinerama
.extensions
; }
76 inline bool doShutdown(void) const
77 { return run_state
== SHUTDOWN
; }
78 inline bool isStartup(void) const
79 { return run_state
== STARTUP
; }
81 inline Display
*getXDisplay(void) const { return display
; }
83 inline const char *getXDisplayName(void) const
84 { return display_name
; }
85 inline const char *getApplicationName(void) const
86 { return application_name
; }
88 inline unsigned int getNumberOfScreens(void) const
89 { return screenInfoList
.size(); }
90 inline int getShapeEventBase(void) const
91 { return shape
.event_basep
; }
93 inline int getXineramaMajorVersion(void) const
94 { return xinerama
.major
; }
97 inline void shutdown(void) { run_state
= SHUTDOWN
; }
98 inline void run(void) { run_state
= RUNNING
; }
100 void grabButton(unsigned int button
, unsigned int modifiers
,
101 Window grab_window
, bool owner_events
,
102 unsigned int event_mask
, int pointer_mode
,
103 int keyboard_mode
, Window confine_to
, Cursor cursor
,
104 bool allow_scroll_lock
) const;
105 void ungrabButton(unsigned int button
, unsigned int modifiers
,
106 Window grab_window
) const;
108 void eventLoop(void);
110 // from TimerQueueManager interface
111 virtual void addTimer(BTimer
*timer
);
112 virtual void removeTimer(BTimer
*timer
);
114 // another pure virtual... this is used to handle signals that BaseDisplay
115 // doesn't understand itself
116 virtual bool handleSignal(int sig
) = 0;
120 #endif // __BaseDisplay_hh