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"
45 class XWindow
: public bt::EventHandler
{
55 // defined by black/openbox
56 static const unsigned long PropBlackboxAttributesElements
= 9;
57 static const unsigned long AttribDecoration
= 1 << 6;
58 static const unsigned long DecorNone
= 0;
59 static const unsigned long DecorNormal
= 2;
64 Netclient
* _netclient
;
65 const bt::ScreenInfo
& _screenInfo
;
66 bt::Application
& _app
;
68 unsigned int _desktop
;
70 std::string _app_name
;
71 std::string _app_class
;
73 int _inc_x
, _inc_y
; // resize increments
74 int _base_x
, _base_y
; // base size
88 void updateDimensions();
89 void updateDimensions(const XConfigureEvent
* const e
);
90 void updateBlackboxAttributes();
91 void updateNormalHints();
97 void updateMotifHints();
99 // EventHandler methods....
101 // Window configure (size, position, stacking, etc.).
102 void configureNotifyEvent(const XConfigureEvent
* const e
);
104 // Window property changed/added/deleted.
105 void propertyNotifyEvent(const XPropertyEvent
* const e
);
108 void unmapNotifyEvent(const XUnmapEvent
* const e
);
111 void destroyNotifyEvent(const XDestroyWindowEvent
* const e
);
114 XWindow(Window window
, Netclient
* netclient
,
115 const bt::ScreenInfo
& screenInfo
, bt::Application
& app
);
118 inline unsigned int getScreenNumber() const { return _screenInfo
.screenNumber(); }
119 inline Window
window() const { return _window
; }
121 inline unsigned int desktop() const { return _desktop
; }
122 inline const bt::ustring
&title() const { return _title
; }
123 inline const std::string
&appName() const { return _app_name
; }
124 inline const std::string
&appClass() const { return _app_class
; }
125 inline bool canFocus() const { return _can_focus
; }
126 inline bool isSticky() const { return 0xFFFFFFFF == _desktop
; }
128 inline bool shaded() const { return _shaded
; }
129 inline bool iconic() const { return _iconic
; }
130 inline bool skipPager() const { return _skip_pager
; }
131 inline bool maxVert() const { return _max_vert
; }
132 inline bool maxHorz() const { return _max_horz
; }
133 inline bool decorated() const { return _decorated
; }
134 inline const bt::Rect
&area() const { return _rect
; }
135 inline unsigned int x() const { return _rect
.x(); }
136 inline unsigned int y() const { return _rect
.y(); }
137 inline unsigned int width() const { return _rect
.width(); }
138 inline unsigned int height() const { return _rect
.height(); }
140 void shade(const bool sh
) const;
144 void iconify() const;
145 void focus(bool raise
= true) const;
146 void decorate(bool d
) const;
147 void sendTo(unsigned int dest
) const;
148 void move(int x
, int y
) const;
149 void resizeRel(int dwidth
, int dheight
) const;
150 void resizeAbs(unsigned int width
, unsigned int height
) const;
151 void toggleMaximize(Max max
) const; // i hate toggle functions
152 void maximize(Max max
) const;
154 bool operator == (const XWindow
&w
) const { return w
._window
== _window
; }
155 bool operator == (const Window
&w
) const { return w
== _window
; }
158 typedef std::list
<XWindow
*> WindowList
;
160 #endif // __window_hh