1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // BaseDisplay.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
24 #ifndef __BaseDisplay_hh
25 #define __BaseDisplay_hh
29 #include <X11/Xatom.h>
35 // forward declaration
44 BaseDisplay
*basedisplay
;
50 unsigned int screen_number
;
51 std::string display_string
;
54 RectList xinerama_areas
;
59 ScreenInfo(BaseDisplay
*d
, unsigned int num
);
61 inline BaseDisplay
*getBaseDisplay(void) const { return basedisplay
; }
62 inline Visual
*getVisual(void) const { return visual
; }
63 inline Window
getRootWindow(void) const { return root_window
; }
64 inline Colormap
getColormap(void) const { return colormap
; }
65 inline int getDepth(void) const { return depth
; }
66 inline unsigned int getScreenNumber(void) const
67 { return screen_number
; }
68 inline const Rect
& getRect(void) const { return rect
; }
69 inline unsigned int getWidth(void) const { return rect
.width(); }
70 inline unsigned int getHeight(void) const { return rect
.height(); }
71 inline const std::string
& displayString(void) const
72 { return display_string
; }
74 inline const RectList
&getXineramaAreas(void) const { return xinerama_areas
; }
75 inline bool isXineramaActive(void) const { return xinerama_active
; }
80 class BaseDisplay
: public TimerQueueManager
{
84 int event_basep
, error_basep
;
91 int event_basep
, error_basep
;
92 int major
, minor
; // version
97 unsigned int MaskList
[8];
98 size_t MaskListLength
;
100 enum RunState
{ STARTUP
, RUNNING
, SHUTDOWN
};
104 mutable BGCCache
*gccache
;
106 typedef std::vector
<ScreenInfo
> ScreenInfoList
;
107 ScreenInfoList screenInfoList
;
108 TimerQueue timerList
;
110 const char *display_name
, *application_name
;
113 BaseDisplay(const BaseDisplay
&);
114 BaseDisplay
& operator=(const BaseDisplay
&);
117 // pure virtual function... you must override this
118 virtual void process_event(XEvent
*e
) = 0;
120 // the masks of the modifiers which are ignored in button events.
121 int NumLockMask
, ScrollLockMask
;
125 BaseDisplay(const char *app_name
, const char *dpy_name
= 0);
126 virtual ~BaseDisplay(void);
128 const ScreenInfo
* getScreenInfo(const unsigned int s
) const;
130 BGCCache
*gcCache(void) const;
132 inline bool hasShapeExtensions(void) const
133 { return shape
.extensions
; }
135 inline bool hasXineramaExtensions(void) const
136 { return xinerama
.extensions
; }
138 inline bool doShutdown(void) const
139 { return run_state
== SHUTDOWN
; }
140 inline bool isStartup(void) const
141 { return run_state
== STARTUP
; }
143 inline Display
*getXDisplay(void) const { return display
; }
145 inline const char *getXDisplayName(void) const
146 { return display_name
; }
147 inline const char *getApplicationName(void) const
148 { return application_name
; }
150 inline unsigned int getNumberOfScreens(void) const
151 { return screenInfoList
.size(); }
152 inline int getShapeEventBase(void) const
153 { return shape
.event_basep
; }
155 inline int getXineramaMajorVersion(void) const
156 { return xinerama
.major
; }
159 inline void shutdown(void) { run_state
= SHUTDOWN
; }
160 inline void run(void) { run_state
= RUNNING
; }
162 void grabButton(unsigned int button
, unsigned int modifiers
,
163 Window grab_window
, bool owner_events
,
164 unsigned int event_mask
, int pointer_mode
,
165 int keyboard_mode
, Window confine_to
, Cursor cursor
,
166 bool allow_scroll_lock
) const;
167 void ungrabButton(unsigned int button
, unsigned int modifiers
,
168 Window grab_window
) const;
170 void eventLoop(void);
172 // from TimerQueueManager interface
173 virtual void addTimer(BTimer
*timer
);
174 virtual void removeTimer(BTimer
*timer
);
176 // another pure virtual... this is used to handle signals that BaseDisplay
177 // doesn't understand itself
178 virtual bool handleSignal(int sig
) = 0;
182 #endif // __BaseDisplay_hh