]> Dogcows Code - chaz/openbox/blob - src/client.hh
moving strut into its own .hh. adding OBClient class
[chaz/openbox] / src / client.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __client_hh
3 #define __client_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 }
8
9 #include <string>
10
11 #include "otk/strut.hh"
12 #include "otk/rect.hh"
13
14 namespace ob {
15
16 class BScreen;
17
18 class OBClient {
19 public:
20 enum Max { Max_None,
21 Max_Horz,
22 Max_Vert,
23 Max_Full };
24
25 enum WindowType { Type_Desktop,
26 Type_Dock,
27 Type_Toolbar,
28 Type_Menu,
29 Type_Utility,
30 Type_Splash,
31 Type_Dialog,
32 Type_Normal };
33
34 enum MwmFlags { Functions = 1 << 0,
35 Decorations = 1 << 1 };
36
37 enum MwmFunctions { MwmFunc_All = 1 << 0,
38 MwmFunc_Resize = 1 << 1,
39 MwmFunc_Move = 1 << 2,
40 MwmFunc_Iconify = 1 << 3,
41 MwmFunc_Maximize = 1 << 4,
42 MwmFunc_Close = 1 << 5 };
43
44 enum MemDecorations { MemDecor_All = 1 << 0,
45 MemDecor_Border = 1 << 1,
46 MemDecor_Handle = 1 << 2,
47 MemDecor_Title = 1 << 3,
48 //MemDecor_Menu = 1 << 4,
49 MemDecor_Iconify = 1 << 5,
50 MemDecor_Maximize = 1 << 6 };
51
52 // this structure only contains 3 elements... the Motif 2.0 structure
53 // contains 5... we only need the first 3... so that is all we will define
54 typedef struct MwmHints {
55 static const int elements = 3;
56 unsigned long flags;
57 unsigned long functions;
58 unsigned long decorations;
59 };
60
61 enum StateAction { State_Remove = 0, // _NET_WM_STATE_REMOVE
62 State_Add, // _NET_WM_STATE_ADD
63 State_Toggle // _NET_WM_STATE_TOGGLE
64 };
65
66 private:
67 BScreen *_screen;
68 Window _window;
69
70 //! The id of the group the window belongs to
71 XID _group;
72
73 // XXX: transient_for, transients
74
75 //! The desktop on which the window resides (0xffffffff for all desktops)
76 unsigned int _desktop;
77
78 //! Normal window title
79 std::string _title;
80 //! Window title when iconifiged
81 std::string _icon_title;
82
83 //! The application that created the window
84 std::string _app_name;
85 //! The class of the window, can used for grouping
86 std::string _app_class;
87
88 //! The type of window (what its function is)
89 WindowType _type;
90
91 //! Position and size of the window (relative to the root window)
92 otk::Rect _area;
93
94 // size bounds
95 // if min > max, then the window is not resizable
96 int _min_x, _min_y; // minumum size
97 int _max_x, _max_y; // maximum size
98 int _inc_x, _inc_y; // resize increments
99 int _base_x, _base_y; // base size
100
101 //! Where to place the decorated window in relation to the undecorated window
102 int _gravity;
103
104 //! The state of the window, one of WithdrawnState, IconicState, or
105 //! NormalState
106 long _state;
107
108 //! Can the window receive input focus?
109 bool _can_focus;
110 //! Urgency flag
111 bool _urgent;
112 //! Notify the window when it receives focus?
113 bool _focus_notify;
114
115 //! The window uses shape extension to be non-rectangular?
116 bool _shaped;
117
118 //! The window is modal, so it must be processed before any windows it is
119 //! related to can be focused
120 bool _modal;
121 //! Only the window's titlebar is displayed
122 bool _shaded;
123 //! The window is iconified
124 bool _iconic;
125 //! The window is maximized to fill the screen vertically
126 bool _max_vert;
127 //! The window is maximized to fill the screen horizontally
128 bool _max_horz;
129 //! The window is a 'fullscreen' window, and should be on top of all others
130 bool _fullscreen;
131 //! The window should be on top of other windows of the same type
132 bool _floating;
133
134 // XXX: motif decoration hints!
135
136 void setWMState(long state);
137 void setDesktop(long desktop);
138 void setState(StateAction action, long data1, long data2);
139
140 void updateNormalHints();
141 void updateWMHints();
142 void updateTitle();
143 void updateClass();
144
145 public:
146 OBClient(BScreen *screen, Window window);
147 virtual ~OBClient();
148
149 inline Window window() const { return _window; }
150
151 inline WindowType type() const { return _type; }
152 inline unsigned int desktop() const { return _desktop; }
153 inline const std::string &title() const { return _title; }
154 inline const std::string &iconTitle() const { return _title; }
155 inline const std::string &appName() const { return _app_name; }
156 inline const std::string &appClass() const { return _app_class; }
157 inline bool canFocus() const { return _can_focus; }
158 inline bool urgent() const { return _urgent; }
159 inline bool focusNotify() const { return _focus_notify; }
160 inline bool shaped() const { return _shaped; }
161 inline int gravity() const { return _gravity; }
162
163 // states
164 inline bool modal() const { return _modal; }
165 inline bool shaded() const { return _shaded; }
166 inline bool iconic() const { return _iconic; }
167 inline bool maxVert() const { return _max_vert; }
168 inline bool maxHorz() const { return _max_horz; }
169 inline bool fullscreen() const { return _fullscreen; }
170 inline bool floating() const { return _floating; }
171
172 inline int minX() const { return _min_x; }
173 inline int minY() const { return _min_y; }
174 inline int maxX() const { return _max_x; }
175 inline int maxY() const { return _max_y; }
176 inline int incrementX() const { return _inc_x; }
177 inline int incrementY() const { return _inc_y; }
178 inline int baseX() const { return _base_x; }
179 inline int baseY() const { return _base_y; }
180
181 inline const otk::Rect &area() const { return _area; }
182
183 void update(const XPropertyEvent &e);
184 void update(const XClientMessageEvent &e);
185 };
186
187 }
188
189 #endif // __client_hh
This page took 0.039313 seconds and 4 git commands to generate.