1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 #ifndef __BaseDisplay_hh
3 #define __BaseDisplay_hh
13 // forward declaration
22 BaseDisplay
*basedisplay
;
28 unsigned int screen_number
;
29 std::string display_string
;
32 RectList xinerama_areas
;
37 ScreenInfo(BaseDisplay
*d
, unsigned int num
);
39 inline BaseDisplay
*getBaseDisplay(void) const { return basedisplay
; }
40 inline Visual
*getVisual(void) const { return visual
; }
41 inline Window
getRootWindow(void) const { return root_window
; }
42 inline Colormap
getColormap(void) const { return colormap
; }
43 inline int getDepth(void) const { return depth
; }
44 inline unsigned int getScreenNumber(void) const
45 { return screen_number
; }
46 inline const Rect
& getRect(void) const { return rect
; }
47 inline unsigned int getWidth(void) const { return rect
.width(); }
48 inline unsigned int getHeight(void) const { return rect
.height(); }
49 inline const std::string
& displayString(void) const
50 { return display_string
; }
52 inline const RectList
&getXineramaAreas(void) const { return xinerama_areas
; }
53 inline bool isXineramaActive(void) const { return xinerama_active
; }
58 class BaseDisplay
: public TimerQueueManager
{
62 int event_basep
, error_basep
;
69 int event_basep
, error_basep
;
70 int major
, minor
; // version
75 unsigned int MaskList
[8];
76 size_t MaskListLength
;
78 enum RunState
{ STARTUP
, RUNNING
, SHUTDOWN
};
82 mutable BGCCache
*gccache
;
84 typedef std::vector
<ScreenInfo
> ScreenInfoList
;
85 ScreenInfoList screenInfoList
;
88 const char *display_name
, *application_name
;
91 BaseDisplay(const BaseDisplay
&);
92 BaseDisplay
& operator=(const BaseDisplay
&);
95 // pure virtual function... you must override this
96 virtual void process_event(XEvent
*e
) = 0;
98 // the masks of the modifiers which are ignored in button events.
99 int NumLockMask
, ScrollLockMask
;
103 BaseDisplay(const char *app_name
, const char *dpy_name
= 0);
104 virtual ~BaseDisplay(void);
106 const ScreenInfo
* getScreenInfo(const unsigned int s
) const;
108 BGCCache
*gcCache(void) const;
110 inline bool hasShapeExtensions(void) const
111 { return shape
.extensions
; }
113 inline bool hasXineramaExtensions(void) const
114 { return xinerama
.extensions
; }
116 inline bool doShutdown(void) const
117 { return run_state
== SHUTDOWN
; }
118 inline bool isStartup(void) const
119 { return run_state
== STARTUP
; }
121 inline Display
*getXDisplay(void) const { return display
; }
123 inline const char *getXDisplayName(void) const
124 { return display_name
; }
125 inline const char *getApplicationName(void) const
126 { return application_name
; }
128 inline unsigned int getNumberOfScreens(void) const
129 { return screenInfoList
.size(); }
130 inline int getShapeEventBase(void) const
131 { return shape
.event_basep
; }
133 inline int getXineramaMajorVersion(void) const
134 { return xinerama
.major
; }
137 inline void shutdown(void) { run_state
= SHUTDOWN
; }
138 inline void run(void) { run_state
= RUNNING
; }
140 void grabButton(unsigned int button
, unsigned int modifiers
,
141 Window grab_window
, bool owner_events
,
142 unsigned int event_mask
, int pointer_mode
,
143 int keyboard_mode
, Window confine_to
, Cursor cursor
,
144 bool allow_scroll_lock
) const;
145 void ungrabButton(unsigned int button
, unsigned int modifiers
,
146 Window grab_window
) const;
148 void eventLoop(void);
150 // from TimerQueueManager interface
151 virtual void addTimer(BTimer
*timer
);
152 virtual void removeTimer(BTimer
*timer
);
154 // another pure virtual... this is used to handle signals that BaseDisplay
155 // doesn't understand itself
156 virtual bool handleSignal(int sig
) = 0;
160 #endif // __BaseDisplay_hh