1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // window.hh for Epistrophy - a key handler for NETWM/EWMH window managers.
3 // Copyright (c) 2002 - 2002 Ben Jansens <ben at orodu.net>
5 // Modified for use and inclusion in bbkeys by Jason 'vanRijn' Kasper
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
30 #include <X11/Xutil.h>
37 #include "Application.hh"
40 #include "EventHandler.hh"
42 #include "Netclient.h"
44 class XWindow
: public bt::EventHandler
{
54 // defined by black/openbox
55 static const unsigned long PropBlackboxAttributesElements
= 9;
56 static const unsigned long AttribDecoration
= 1 << 6;
57 static const unsigned long DecorNone
= 0;
58 static const unsigned long DecorNormal
= 2;
63 Netclient
* _netclient
;
64 const bt::ScreenInfo
& _screenInfo
;
65 bt::Application
& _app
;
67 unsigned int _desktop
;
69 std::string _app_name
;
70 std::string _app_class
;
72 int _inc_x
, _inc_y
; // resize increments
73 int _base_x
, _base_y
; // base size
87 void updateDimensions();
88 void updateDimensions(const XConfigureEvent
* const e
);
89 void updateBlackboxAttributes();
90 void updateNormalHints();
97 // EventHandler methods....
99 // Window configure (size, position, stacking, etc.).
100 void configureNotifyEvent(const XConfigureEvent
* const e
);
102 // Window property changed/added/deleted.
103 void propertyNotifyEvent(const XPropertyEvent
* const e
);
106 void unmapNotifyEvent(const XUnmapEvent
* const e
);
109 void destroyNotifyEvent(const XDestroyWindowEvent
* const e
);
112 XWindow(Window window
, Netclient
* netclient
,
113 const bt::ScreenInfo
& screenInfo
, bt::Application
& app
);
116 inline unsigned int getScreenNumber() const { return _screenInfo
.screenNumber(); }
117 inline Window
window() const { return _window
; }
119 inline unsigned int desktop() const { return _desktop
; }
120 inline const std::string
&title() const { return _title
; }
121 inline const std::string
&appName() const { return _app_name
; }
122 inline const std::string
&appClass() const { return _app_class
; }
123 inline bool canFocus() const { return _can_focus
; }
125 inline bool shaded() const { return _shaded
; }
126 inline bool iconic() const { return _iconic
; }
127 inline bool skipPager() const { return _skip_pager
; }
128 inline bool maxVert() const { return _max_vert
; }
129 inline bool maxHorz() const { return _max_horz
; }
130 inline bool decorated() const { return _decorated
; }
131 inline const bt::Rect
&area() const { return _rect
; }
132 inline unsigned int x() const { return _rect
.x(); }
133 inline unsigned int y() const { return _rect
.y(); }
134 inline unsigned int width() const { return _rect
.width(); }
135 inline unsigned int height() const { return _rect
.height(); }
137 void shade(const bool sh
) const;
141 void iconify() const;
142 void focus(bool raise
= true) const;
143 void decorate(bool d
) const;
144 void sendTo(unsigned int dest
) const;
145 void move(int x
, int y
) const;
146 void resizeRel(int dwidth
, int dheight
) const;
147 void resizeAbs(unsigned int width
, unsigned int height
) const;
148 void toggleMaximize(Max max
) const; // i hate toggle functions
149 void maximize(Max max
) const;
151 bool operator == (const XWindow
&w
) const { return w
._window
== _window
; }
152 bool operator == (const Window
&w
) const { return w
== _window
; }
155 typedef std::list
<XWindow
*> WindowList
;
157 #endif // __window_hh