aboutsummaryrefslogtreecommitdiff
path: root/src/Window.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
committerfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
commit18830ac9add80cbd3bf7369307d7e35a519dca9b (patch)
tree4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/Window.hh
parent1523b48bff07dead084af3064ad11c79a9b25df0 (diff)
downloadfluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip
fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2
Initial revision
Diffstat (limited to 'src/Window.hh')
-rw-r--r--src/Window.hh321
1 files changed, 321 insertions, 0 deletions
diff --git a/src/Window.hh b/src/Window.hh
new file mode 100644
index 0000000..f08acb0
--- /dev/null
+++ b/src/Window.hh
@@ -0,0 +1,321 @@
1// Window.hh for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22//
23//Changes for Fluxbox made by Henrik Kinnunen (fluxgen@linuxmail.org)
24// See LICENSE for copyright and license
25
26#ifndef _WINDOW_HH_
27#define _WINDOW_HH_
28
29#include <X11/Xlib.h>
30#include <X11/Xutil.h>
31
32#ifdef SHAPE
33# include <X11/extensions/shape.h>
34#endif // SHAPE
35
36// forward declaration
37class FluxboxWindow;
38class Tab;
39
40#include "fluxbox.hh"
41
42#include <vector>
43#include <string>
44#ifndef _BASEDISPLAY_HH_
45#include "BaseDisplay.hh"
46#endif
47#ifndef _TIMER_HH_
48#include "Timer.hh"
49#endif
50#ifndef _WINDOWMENU_HH_
51#include "Windowmenu.hh"
52#endif
53
54#define MwmHintsFunctions (1l << 0)
55#define MwmHintsDecorations (1l << 1)
56
57#define MwmFuncAll (1l << 0)
58#define MwmFuncResize (1l << 1)
59#define MwmFuncMove (1l << 2)
60#define MwmFuncIconify (1l << 3)
61#define MwmFuncMaximize (1l << 4)
62#define MwmFuncClose (1l << 5)
63
64#define MwmDecorAll (1l << 0)
65#define MwmDecorBorder (1l << 1)
66#define MwmDecorHandle (1l << 2)
67#define MwmDecorTitle (1l << 3)
68#define MwmDecorMenu (1l << 4)
69#define MwmDecorIconify (1l << 5)
70#define MwmDecorMaximize (1l << 6)
71//names for buttons
72#define NAME_STICKY "sticky"
73#define NAME_MAXIMIZE "maximize"
74#define NAME_MINIMIZE "minimize"
75#define NAME_SHADE "shade"
76#define NAME_CLOSE "close"
77#define NAME_ICONIFY "iconify"
78#define NAME_MENU "menu"
79#define NAME_NONE "none"
80
81
82#define PropMwmHintsElements 3
83
84class FluxboxWindow : public TimeoutHandler {
85public:
86 FluxboxWindow(Window, BScreen * = (BScreen *) 0);
87 virtual ~FluxboxWindow(void);
88
89 inline const bool isTransient(void) const
90 { return ((transient) ? true : false); }
91 inline const bool hasTransient(void) const
92 { return ((client.transient) ? true : false); }
93 inline const bool &isFocused(void) const { return focused; }
94 inline const bool &isVisible(void) const { return visible; }
95 inline const bool &isIconic(void) const { return iconic; }
96 inline const bool &isShaded(void) const { return shaded; }
97 inline const bool &isMaximized(void) const { return maximized; }
98 inline const bool &isIconifiable(void) const { return functions.iconify; }
99 inline const bool &isMaximizable(void) const { return functions.maximize; }
100 inline const bool &isResizable(void) const { return functions.resize; }
101 inline const bool &isClosable(void) const { return functions.close; }
102 inline const bool &isStuck(void) const { return stuck; }
103 inline const bool &hasTitlebar(void) const { return decorations.titlebar; }
104 inline const bool hasTab(void) const { return (tab!=0 ? true : false); }
105
106 inline BScreen *getScreen(void) { return screen; }
107 inline Tab *getTab(void) { return tab; }
108 inline FluxboxWindow *getTransient(void) { return client.transient; }
109 inline FluxboxWindow *getTransientFor(void) { return client.transient_for; }
110
111 inline const Window &getFrameWindow(void) const { return frame.window; }
112 inline const Window &getClientWindow(void) const { return client.window; }
113
114 inline Windowmenu *getWindowmenu(void) { return windowmenu; }
115
116 inline char **getTitle(void) { return &client.title; }
117 inline char **getIconTitle(void) { return &client.icon_title; }
118 inline const int &getXFrame(void) const { return frame.x; }
119 inline const int &getYFrame(void) const { return frame.y; }
120 inline const int &getXClient(void) const { return client.x; }
121 inline const int &getYClient(void) const { return client.y; }
122 inline const int &getWorkspaceNumber(void) const { return workspace_number; }
123 inline const int &getWindowNumber(void) const { return window_number; }
124
125 inline const unsigned int &getWidth(void) const { return frame.width; }
126 inline const unsigned int &getHeight(void) const { return frame.height; }
127 inline const unsigned int &getClientHeight(void) const
128 { return client.height; }
129 inline const unsigned int &getClientWidth(void) const
130 { return client.width; }
131 inline const unsigned int &getTitleHeight(void) const
132 { return frame.title_h; }
133
134 inline void setWindowNumber(int n) { window_number = n; }
135
136 bool validateClient(void);
137 bool setInputFocus(void);
138 void setTab(bool flag);
139 void setFocusFlag(bool);
140 void iconify(void);
141 void deiconify(bool = true, bool = true);
142 void close(void);
143 void withdraw(void);
144 void maximize(unsigned int);
145 void shade(void);
146 void stick(void);
147 void unstick(void);
148 void reconfigure(void);
149 void installColormap(bool);
150 void restore(void);
151 void configure(int dx, int dy, unsigned int dw, unsigned int dh);
152 void setWorkspace(int n);
153 void changeBlackboxHints(BlackboxHints *);
154 void restoreAttributes(void);
155
156 void buttonPressEvent(XButtonEvent *);
157 void buttonReleaseEvent(XButtonEvent *);
158 void motionNotifyEvent(XMotionEvent *);
159 void destroyNotifyEvent(XDestroyWindowEvent *);
160 void mapRequestEvent(XMapRequestEvent *);
161 void mapNotifyEvent(XMapEvent *);
162 void unmapNotifyEvent(XUnmapEvent *);
163 void propertyNotifyEvent(Atom);
164 void exposeEvent(XExposeEvent *);
165 void configureRequestEvent(XConfigureRequestEvent *);
166
167#ifdef SHAPE
168 void shapeEvent(XShapeEvent *);
169#endif // SHAPE
170
171 virtual void timeout(void);
172
173 // this structure only contains 3 elements... the Motif 2.0 structure contains
174 // 5... we only need the first 3... so that is all we will define
175 typedef struct MwmHints {
176 unsigned long flags, functions, decorations;
177 } MwmHints;
178
179private:
180 BImageControl *image_ctrl;
181 //Fluxbox *fluxbox;
182
183 bool moving, resizing, shaded, maximized, visible, iconic, transient,
184 focused, stuck, modal, send_focus_message, managed;
185 BScreen *screen;
186 BTimer *timer;
187 Display *display;
188 BlackboxAttributes blackbox_attrib;
189
190 Time lastButtonPressTime;
191 Windowmenu *windowmenu;
192
193 int focus_mode, window_number, workspace_number;
194 unsigned long current_state;
195
196 struct _client {
197 FluxboxWindow *transient_for, // which window are we a transient for?
198 *transient; // which window is our transient?
199 Window window, window_group;
200
201 char *title, *icon_title;
202 int x, y, old_bw, title_len;
203 unsigned int width, height, title_text_w,
204 min_width, min_height, max_width, max_height, width_inc, height_inc,
205 min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y,
206 base_width, base_height, win_gravity;
207 unsigned long initial_state, normal_hint_flags, wm_hint_flags;
208
209 MwmHints *mwm_hint;
210 BlackboxHints *blackbox_hint;
211 } client;
212
213 struct _decorations {
214 bool titlebar, handle, border, iconify,
215 maximize, close, menu, sticky, shade, tab;
216 } decorations;
217
218 struct _functions {
219 bool resize, move, iconify, maximize, close;
220 } functions;
221
222 bool usetab;
223 Tab *tab;
224 //Tab is also a friend
225 friend class Tab;
226
227 typedef void (*ButtonDrawProc)(FluxboxWindow *, Window, bool);
228 typedef void (*ButtonEventProc)(FluxboxWindow *, XButtonEvent *);
229
230 struct Button {
231 int type;
232 Window win;
233 bool used;
234 ButtonEventProc pressed;
235 ButtonEventProc released;
236 ButtonDrawProc draw;
237 };
238
239 std::vector<Button> buttonlist;
240
241 struct _frame {
242 //different bool because of XShapeQueryExtension
243 Bool shaped;
244 unsigned long ulabel_pixel, flabel_pixel, utitle_pixel,
245 ftitle_pixel, uhandle_pixel, fhandle_pixel, ubutton_pixel,
246 fbutton_pixel, pbutton_pixel, uborder_pixel, fborder_pixel,
247 ugrip_pixel, fgrip_pixel;
248 Pixmap ulabel, flabel, utitle, ftitle, uhandle, fhandle,
249 ubutton, fbutton, pbutton, ugrip, fgrip;
250
251 Window window, plate, title, label, handle,
252 right_grip, left_grip;
253
254 int x, y, resize_x, resize_y, move_x, move_y, grab_x, grab_y,
255 y_border, y_handle;
256 unsigned int width, height, title_h, label_w, label_h, handle_h,
257 button_w, button_h, grip_w, grip_h, mwm_border_w, border_h,
258 bevel_w, resize_w, resize_h, snap_w, snap_h;
259 } frame;
260
261 enum { F_NoInput = 0, F_Passive, F_LocallyActive, F_GloballyActive };
262
263 void createButton(int type, ButtonEventProc, ButtonEventProc, ButtonDrawProc);
264 Window findTitleButton(int type);
265protected:
266 //event callbacks
267 static void stickyButton_cb(FluxboxWindow *, XButtonEvent *);
268 static void stickyPressed_cb(FluxboxWindow *, XButtonEvent *);
269 static void iconifyButton_cb(FluxboxWindow *, XButtonEvent *);
270 static void iconifyPressed_cb(FluxboxWindow *, XButtonEvent *);
271 static void maximizeButton_cb(FluxboxWindow *, XButtonEvent *);
272 static void maximizePressed_cb(FluxboxWindow *, XButtonEvent *);
273 static void closeButton_cb(FluxboxWindow *, XButtonEvent *);
274 static void closePressed_cb(FluxboxWindow *, XButtonEvent *);
275 static void shadeButton_cb(FluxboxWindow *, XButtonEvent *);
276 //draw callbacks
277 static void stickyDraw_cb(FluxboxWindow *, Window, bool);
278 static void iconifyDraw_cb(FluxboxWindow *, Window, bool);
279 static void maximizeDraw_cb(FluxboxWindow *, Window, bool);
280 static void closeDraw_cb(FluxboxWindow *, Window, bool);
281 static void shadeDraw_cb(FluxboxWindow *, Window, bool);
282
283 static void grabButton(Display *display, unsigned int button, Window window, Cursor cursor);
284 //button base draw... background
285 void drawButtonBase(Window, bool);
286
287 bool getState(void);
288 Window createToplevelWindow(int, int, unsigned int, unsigned int,
289 unsigned int);
290 Window createChildWindow(Window, Cursor = None);
291
292 void getWMName(void);
293 void getWMIconName(void);
294 void getWMNormalHints(void);
295 void getWMProtocols(void);
296 void getWMHints(void);
297 void getMWMHints(void);
298 void getBlackboxHints(void);
299 void setNetWMAttributes(void);
300 void associateClientWindow(void);
301 void decorate(void);
302 void decorateLabel(void);
303 void positionButtons(bool redecorate_label = false);
304 void positionWindows(void);
305
306 void redrawLabel(void);
307 void redrawAllButtons(void);
308
309 void restoreGravity(void);
310 void setGravityOffsets(void);
311 void setState(unsigned long);
312 void upsize(void);
313 void downsize(void);
314 void right_fixsize(int * = 0, int * = 0);
315 void left_fixsize(int * = 0, int * = 0);
316
317
318};
319
320
321#endif // __Window_hh