not cycling to windows that request to not be in skipped in a pager. the problem...
[bbkeys.git] / src / window.hh
blob614079c777037e92f426b8bdbb80f5b33582418c
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>
4 //
5 // Modified for use and inclusion in bbkeys by Jason 'vanRijn' Kasper
6 //
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.
25 #ifndef __window_hh
26 #define __window_hh
28 extern "C" {
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
33 #include <list>
34 #include <string>
36 // blackbox lib....
37 #include "Application.hh"
38 #include "Util.hh"
39 #include "Display.hh"
40 #include "EventHandler.hh"
42 #include "Netclient.h"
44 class XWindow : public bt::EventHandler {
45 public:
46 enum Max {
47 Max_None,
48 Max_Horz,
49 Max_Vert,
50 Max_Full
53 private:
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;
60 Window _window;
61 Display * _display;
62 Window _root;
63 Netclient * _netclient;
64 const bt::ScreenInfo & _screenInfo;
65 bt::Application & _app;
67 unsigned int _desktop;
68 std::string _title;
69 std::string _app_name;
70 std::string _app_class;
71 bt::Rect _rect;
72 int _inc_x, _inc_y; // resize increments
73 int _base_x, _base_y; // base size
74 int _gravity;
75 bool _can_focus;
77 // states
78 bool _shaded;
79 bool _iconic;
80 bool _skip_pager;
81 bool _max_vert;
82 bool _max_horz;
83 bool _decorated;
85 bool _unmapped;
87 void updateDimensions();
88 void updateDimensions(const XConfigureEvent * const e);
89 void updateBlackboxAttributes();
90 void updateNormalHints();
91 void updateWMHints();
92 void updateState();
93 void updateDesktop();
94 void updateTitle();
95 void updateClass();
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);
105 // Window hidden.
106 void unmapNotifyEvent(const XUnmapEvent * const e);
108 // Window destroyed.
109 void destroyNotifyEvent(const XDestroyWindowEvent * const e);
111 public:
112 XWindow(Window window, Netclient * netclient,
113 const bt::ScreenInfo & screenInfo, bt::Application & app);
114 virtual ~XWindow();
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;
138 void close() const;
139 void raise() const;
140 void lower() 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