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>
35 #include "Basemenu.hh"
37 // forward declaration
41 class Slitmenu
: public Basemenu
{
43 class Directionmenu
: public Basemenu
{
45 Directionmenu(const Directionmenu
&);
46 Directionmenu
& operator=(const Directionmenu
&);
49 virtual void itemSelected(int button
, unsigned int index
);
52 Directionmenu(Slitmenu
*sm
);
55 class Placementmenu
: public Basemenu
{
57 Placementmenu(const Placementmenu
&);
58 Placementmenu
& operator=(const Placementmenu
&);
61 virtual void itemSelected(int buton
, unsigned int index
);
64 Placementmenu(Slitmenu
*sm
);
67 Directionmenu
*directionmenu
;
68 Placementmenu
*placementmenu
;
72 friend class Directionmenu
;
73 friend class Placementmenu
;
76 Slitmenu(const Slitmenu
&);
77 Slitmenu
& operator=(const Slitmenu
&);
80 virtual void itemSelected(int button
, unsigned int index
);
81 virtual void internal_hide(void);
85 virtual ~Slitmenu(void);
87 inline Basemenu
*getDirectionmenu(void) { return directionmenu
; }
88 inline Basemenu
*getPlacementmenu(void) { return placementmenu
; }
90 void reconfigure(void);
94 class Slit
: public TimeoutHandler
{
97 Window window
, client_window
, icon_window
;
103 typedef std::list
<SlitClient
*> SlitClientList
;
105 bool on_top
, hidden
, do_auto_hide
;
113 SlitClientList clientList
;
120 int x_hidden
, y_hidden
;
124 void updateStrut(void);
126 friend class Slitmenu
;
127 friend class Slitmenu::Directionmenu
;
128 friend class Slitmenu::Placementmenu
;
131 Slit
& operator=(const Slit
&);
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
; }
141 inline Slitmenu
*getMenu(void) { return slitmenu
; }
143 inline Window
getWindowID(void) const { return frame
.window
; }
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()); }
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();
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();
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);
170 void toggleAutoHide(void);
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
);
178 virtual void timeout(void);
180 enum { Vertical
= 1, Horizontal
};
181 enum { TopLeft
= 1, CenterLeft
, BottomLeft
, TopCenter
, BottomCenter
,
182 TopRight
, CenterRight
, BottomRight
};