]> Dogcows Code - chaz/openbox/blob - src/Slit.hh
- raise the window during maximization if the user clicked the maximize button, but...
[chaz/openbox] / src / Slit.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Slit.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)
5 //
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:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
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.
23
24 #ifndef __Slit_hh
25 #define __Slit_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29 #include <X11/Xutil.h>
30 }
31
32 #include <list>
33
34 #include "Screen.hh"
35 #include "Basemenu.hh"
36
37 // forward declaration
38 class Slit;
39 class Slitmenu;
40
41 class Slitmenu : public Basemenu {
42 private:
43 class Directionmenu : public Basemenu {
44 private:
45 Directionmenu(const Directionmenu&);
46 Directionmenu& operator=(const Directionmenu&);
47
48 protected:
49 virtual void itemSelected(int button, unsigned int index);
50
51 public:
52 Directionmenu(Slitmenu *sm);
53 };
54
55 class Placementmenu : public Basemenu {
56 private:
57 Placementmenu(const Placementmenu&);
58 Placementmenu& operator=(const Placementmenu&);
59
60 protected:
61 virtual void itemSelected(int buton, unsigned int index);
62
63 public:
64 Placementmenu(Slitmenu *sm);
65 };
66
67 Directionmenu *directionmenu;
68 Placementmenu *placementmenu;
69
70 Slit *slit;
71
72 friend class Directionmenu;
73 friend class Placementmenu;
74 friend class Slit;
75
76 Slitmenu(const Slitmenu&);
77 Slitmenu& operator=(const Slitmenu&);
78
79 protected:
80 virtual void itemSelected(int button, unsigned int index);
81 virtual void internal_hide(void);
82
83 public:
84 Slitmenu(Slit *sl);
85 virtual ~Slitmenu(void);
86
87 inline Basemenu *getDirectionmenu(void) { return directionmenu; }
88 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
89
90 void reconfigure(void);
91 };
92
93
94 class Slit : public TimeoutHandler {
95 public:
96 struct SlitClient {
97 Window window, client_window, icon_window;
98
99 Rect rect;
100 };
101
102 private:
103 typedef std::list<SlitClient*> SlitClientList;
104
105 bool on_top, hidden, do_auto_hide;
106 Display *display;
107
108 Blackbox *blackbox;
109 BScreen *screen;
110 BTimer *timer;
111 Strut strut;
112
113 SlitClientList clientList;
114 Slitmenu *slitmenu;
115
116 struct SlitFrame {
117 Pixmap pixmap;
118 Window window;
119
120 int x_hidden, y_hidden;
121 Rect rect;
122 } frame;
123
124 void updateStrut(void);
125
126 friend class Slitmenu;
127 friend class Slitmenu::Directionmenu;
128 friend class Slitmenu::Placementmenu;
129
130 Slit(const Slit&);
131 Slit& operator=(const Slit&);
132
133 public:
134 Slit(BScreen *scr);
135 virtual ~Slit(void);
136
137 inline bool isOnTop(void) const { return on_top; }
138 inline bool isHidden(void) const { return hidden; }
139 inline bool doAutoHide(void) const { return do_auto_hide; }
140
141 inline Slitmenu *getMenu(void) { return slitmenu; }
142
143 inline Window getWindowID(void) const { return frame.window; }
144
145 inline int getX(void) const
146 { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
147 inline int getY(void) const
148 { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
149
150 inline unsigned int getWidth(void) const { return frame.rect.width(); }
151 inline unsigned int getExposedWidth(void) const {
152 if (screen->getSlitDirection() == Vertical && do_auto_hide)
153 return screen->getBevelWidth();
154 return frame.rect.width();
155 }
156 inline unsigned int getHeight(void) const { return frame.rect.height(); }
157 inline unsigned int getExposedHeight(void) const {
158 if (screen->getSlitDirection() == Horizontal && do_auto_hide)
159 return screen->getBevelWidth();
160 return frame.rect.height();
161 }
162
163 void addClient(Window w);
164 void removeClient(SlitClient *client, bool remap = True);
165 void removeClient(Window w, bool remap = True);
166 void reconfigure(void);
167 void updateSlit(void);
168 void reposition(void);
169 void shutdown(void);
170 void toggleAutoHide(void);
171
172 void buttonPressEvent(XButtonEvent *e);
173 void enterNotifyEvent(XCrossingEvent * /*unused*/);
174 void leaveNotifyEvent(XCrossingEvent * /*unused*/);
175 void configureRequestEvent(XConfigureRequestEvent *e);
176 void unmapNotifyEvent(XUnmapEvent *e);
177
178 virtual void timeout(void);
179
180 enum { Vertical = 1, Horizontal };
181 enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter,
182 TopRight, CenterRight, BottomRight };
183 };
184
185
186 #endif // __Slit_hh
This page took 0.046951 seconds and 4 git commands to generate.