]> Dogcows Code - chaz/openbox/blob - src/Slit.h
confine the mouse to the window for button grabs so that alt-click-drag on a window...
[chaz/openbox] / src / Slit.h
1 // Slit.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22
23 #ifndef __Slit_hh
24 #define __Slit_hh
25
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28
29 #include "Basemenu.h"
30 #include "Geometry.h"
31 #include <list>
32
33 // forward declaration
34 class Slit;
35 class Slitmenu;
36
37 class Slitmenu : public Basemenu {
38 private:
39 class Directionmenu : public Basemenu {
40 private:
41 Slitmenu &slitmenu;
42
43 protected:
44 virtual void itemSelected(int, int);
45 virtual void setValues();
46
47 public:
48 Directionmenu(Slitmenu &);
49 void reconfigure();
50 };
51
52 class Placementmenu : public Basemenu {
53 private:
54 Slitmenu &slitmenu;
55
56 protected:
57 virtual void itemSelected(int, int);
58
59 public:
60 Placementmenu(Slitmenu &);
61 };
62
63 Directionmenu *directionmenu;
64 Placementmenu *placementmenu;
65
66 Slit &slit;
67
68 friend class Directionmenu;
69 friend class Placementmenu;
70 friend class Slit;
71
72
73 protected:
74 virtual void itemSelected(int, int);
75 virtual void internal_hide();
76 virtual void setValues();
77
78 public:
79 Slitmenu(Slit &);
80 virtual ~Slitmenu();
81
82 inline Basemenu *getDirectionmenu() { return directionmenu; }
83 inline Basemenu *getPlacementmenu() { return placementmenu; }
84
85 void reconfigure();
86 };
87
88
89 class Slit : public TimeoutHandler {
90 private:
91 class SlitClient {
92 public:
93 Window window, client_window, icon_window;
94
95 int x, y;
96 unsigned int width, height;
97 };
98
99 bool m_ontop, m_autohide, m_hidden;
100 int m_direction, m_placement;
101 Display *display;
102
103 Openbox &openbox;
104 BScreen &screen;
105 Resource &config;
106 BTimer *timer;
107
108 typedef std::list<SlitClient *> slitClientList;
109 slitClientList clientList;
110 Slitmenu *slitmenu;
111
112 struct frame {
113 Pixmap pixmap;
114 Window window;
115
116 Rect area;
117 Point hidden;
118 } frame;
119
120
121 friend class Slitmenu;
122 friend class Slitmenu::Directionmenu;
123 friend class Slitmenu::Placementmenu;
124
125
126 public:
127 Slit(BScreen &, Resource &);
128 virtual ~Slit();
129
130 inline Slitmenu *getMenu() { return slitmenu; }
131
132 inline const Window &getWindowID() const { return frame.window; }
133
134 inline const Point &origin() const { return frame.area.origin(); }
135 inline const Size &size() const { return frame.area.size(); }
136 inline const Rect &area() const { return frame.area; }
137 inline const Point &hiddenOrigin() const { return frame.hidden; }
138
139 void addClient(Window);
140 void removeClient(SlitClient *, Bool = True);
141 void removeClient(Window, Bool = True);
142 void reconfigure();
143 void load();
144 void save();
145 void reposition();
146 void shutdown();
147
148 void buttonPressEvent(XButtonEvent *);
149 void enterNotifyEvent(XCrossingEvent *);
150 void leaveNotifyEvent(XCrossingEvent *);
151 void configureRequestEvent(XConfigureRequestEvent *);
152
153 virtual void timeout();
154
155 inline bool isHidden() const { return m_hidden; }
156
157 inline bool onTop() const { return m_ontop; }
158 void setOnTop(bool);
159
160 inline bool autoHide() const { return m_autohide; }
161 void setAutoHide(bool);
162
163 inline int placement() const { return m_placement; }
164 void setPlacement(int);
165
166 inline int direction() const { return m_direction; }
167 void setDirection(int);
168
169 enum { Vertical = 1, Horizontal };
170 enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter,
171 TopRight, CenterRight, BottomRight };
172 };
173
174
175 #endif // __Slit_hh
This page took 0.044194 seconds and 4 git commands to generate.