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)
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.
29 #include <X11/Xutil.h>
36 #include "Basemenu.hh"
38 // forward declaration
42 class Slitmenu
: public Basemenu
{
44 class Directionmenu
: public Basemenu
{
46 Directionmenu(const Directionmenu
&);
47 Directionmenu
& operator=(const Directionmenu
&);
51 virtual void itemSelected(int button
, unsigned int index
);
52 virtual void setValues(void);
55 Directionmenu(Slitmenu
*sm
);
56 virtual void reconfigure(void);
59 class Placementmenu
: public Basemenu
{
61 Placementmenu(const Placementmenu
&);
62 Placementmenu
& operator=(const Placementmenu
&);
66 virtual void itemSelected(int buton
, unsigned int index
);
67 virtual void setValues(void);
70 Placementmenu(Slitmenu
*sm
);
71 virtual void reconfigure(void);
74 Directionmenu
*directionmenu
;
75 Placementmenu
*placementmenu
;
79 friend class Directionmenu
;
80 friend class Placementmenu
;
83 Slitmenu(const Slitmenu
&);
84 Slitmenu
& operator=(const Slitmenu
&);
87 virtual void itemSelected(int button
, unsigned int index
);
88 virtual void internal_hide(void);
92 virtual ~Slitmenu(void);
94 inline Basemenu
*getDirectionmenu(void) { return directionmenu
; }
95 inline Basemenu
*getPlacementmenu(void) { return placementmenu
; }
97 void reconfigure(void);
101 class Slit
: public TimeoutHandler
{
104 Window window
, client_window
, icon_window
;
110 typedef std::list
<SlitClient
*> SlitClientList
;
112 bool on_top
, hidden
, do_auto_hide
;
113 int direction
, placement
;
119 Configuration
*config
;
123 SlitClientList clientList
;
130 int x_hidden
, y_hidden
;
134 void updateStrut(void);
136 friend class Slitmenu
;
137 friend class Slitmenu::Directionmenu
;
138 friend class Slitmenu::Placementmenu
;
141 Slit
& operator=(const Slit
&);
147 inline bool isOnTop(void) const { return on_top
; }
148 inline bool isHidden(void) const { return hidden
; }
149 inline bool doAutoHide(void) const { return do_auto_hide
; }
150 inline int getPlacement(void) const { return placement
; }
151 inline int getDirection(void) const { return direction
; }
153 void saveOnTop(bool);
154 void saveAutoHide(bool);
155 void savePlacement(int);
156 void saveDirection(int);
158 inline Slitmenu
*getMenu(void) { return slitmenu
; }
160 inline Window
getWindowID(void) const { return frame
.window
; }
162 inline int getX(void) const
163 { return ((hidden
) ? frame
.x_hidden
: frame
.rect
.x()); }
164 inline int getY(void) const
165 { return ((hidden
) ? frame
.y_hidden
: frame
.rect
.y()); }
167 inline unsigned int getWidth(void) const { return frame
.rect
.width(); }
168 inline unsigned int getExposedWidth(void) const {
169 if (direction
== Vertical
&& do_auto_hide
)
170 return screen
->getBevelWidth();
171 return frame
.rect
.width();
173 inline unsigned int getHeight(void) const { return frame
.rect
.height(); }
174 inline unsigned int getExposedHeight(void) const {
175 if (direction
== Horizontal
&& do_auto_hide
)
176 return screen
->getBevelWidth();
177 return frame
.rect
.height();
180 void addClient(Window w
);
181 void removeClient(SlitClient
*client
, bool remap
= True
);
182 void removeClient(Window w
, bool remap
= True
);
185 void reconfigure(void);
186 void updateSlit(void);
187 void reposition(void);
189 void toggleAutoHide(void);
191 void buttonPressEvent(const XButtonEvent
*e
);
192 void enterNotifyEvent(const XCrossingEvent
* /*unused*/);
193 void leaveNotifyEvent(const XCrossingEvent
* /*unused*/);
194 void configureRequestEvent(const XConfigureRequestEvent
*e
);
195 void unmapNotifyEvent(const XUnmapEvent
*e
);
197 virtual void timeout(void);
199 enum { Vertical
= 1, Horizontal
};
200 enum { TopLeft
= 1, CenterLeft
, BottomLeft
, TopCenter
, BottomCenter
,
201 TopRight
, CenterRight
, BottomRight
};