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
;
55 ScreenInfo(BaseDisplay
*d
, unsigned int num
);
57 inline BaseDisplay
*getBaseDisplay(void) const { return basedisplay
; }
58 inline Visual
*getVisual(void) const { return visual
; }
59 inline Window
getRootWindow(void) const { return root_window
; }
60 inline Colormap
getColormap(void) const { return colormap
; }
61 inline int getDepth(void) const { return depth
; }
62 inline unsigned int getScreenNumber(void) const
63 { return screen_number
; }
64 inline const Rect
& getRect(void) const { return rect
; }
65 inline unsigned int getWidth(void) const { return rect
.width(); }
66 inline unsigned int getHeight(void) const { return rect
.height(); }
67 inline const std::string
& displayString(void) const
68 { return display_string
; }
72 class BaseDisplay
: public TimerQueueManager
{
76 int event_basep
, error_basep
;
80 unsigned int MaskList
[8];
81 size_t MaskListLength
;
83 enum RunState
{ STARTUP
, RUNNING
, SHUTDOWN
};
87 mutable BGCCache
*gccache
;
89 typedef std::vector
<ScreenInfo
> ScreenInfoList
;
90 ScreenInfoList screenInfoList
;
93 const char *display_name
, *application_name
;
96 BaseDisplay(const BaseDisplay
&);
97 BaseDisplay
& operator=(const BaseDisplay
&);
100 // pure virtual function... you must override this
101 virtual void process_event(XEvent
*e
) = 0;
103 // the masks of the modifiers which are ignored in button events.
104 int NumLockMask
, ScrollLockMask
;
108 BaseDisplay(const char *app_name
, const char *dpy_name
= 0);
109 virtual ~BaseDisplay(void);
111 const ScreenInfo
* getScreenInfo(const unsigned int s
) const;
113 BGCCache
*gcCache(void) const;
115 inline bool hasShapeExtensions(void) const
116 { return shape
.extensions
; }
117 inline bool doShutdown(void) const
118 { return run_state
== SHUTDOWN
; }
119 inline bool isStartup(void) const
120 { return run_state
== STARTUP
; }
122 inline Display
*getXDisplay(void) const { return display
; }
124 inline const char *getXDisplayName(void) const
125 { return display_name
; }
126 inline const char *getApplicationName(void) const
127 { return application_name
; }
129 inline unsigned int getNumberOfScreens(void) const
130 { return screenInfoList
.size(); }
131 inline int getShapeEventBase(void) const
132 { return shape
.event_basep
; }
134 inline void shutdown(void) { run_state
= SHUTDOWN
; }
135 inline void run(void) { run_state
= RUNNING
; }
137 void grabButton(unsigned int button
, unsigned int modifiers
,
138 Window grab_window
, bool owner_events
,
139 unsigned int event_mask
, int pointer_mode
,
140 int keyboard_mode
, Window confine_to
, Cursor cursor
) const;
141 void ungrabButton(unsigned int button
, unsigned int modifiers
,
142 Window grab_window
) const;
144 void eventLoop(void);
146 // from TimerQueueManager interface
147 virtual void addTimer(BTimer
*timer
);
148 virtual void removeTimer(BTimer
*timer
);
150 // another pure virtual... this is used to handle signals that BaseDisplay
151 // doesn't understand itself
152 virtual bool handleSignal(int sig
) = 0;
156 #endif // __BaseDisplay_hh