1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
11 #include "otk/strut.hh"
12 #include "otk/rect.hh"
23 enum WindowType { Type_Desktop,
32 enum MwmFlags { MwmFlag_Functions = 1 << 0,
33 MwmFlag_Decorations = 1 << 1 };
35 enum MwmFunctions { MwmFunc_All = 1 << 0,
36 MwmFunc_Resize = 1 << 1,
37 MwmFunc_Move = 1 << 2,
38 MwmFunc_Iconify = 1 << 3,
39 MwmFunc_Maximize = 1 << 4
40 //MwmFunc_Close = 1 << 5
43 enum MemDecorations { MwmDecor_All = 1 << 0,
44 MwmDecor_Border = 1 << 1,
45 MwmDecor_Handle = 1 << 2,
46 MwmDecor_Title = 1 << 3,
47 //MwmDecor_Menu = 1 << 4,
48 MwmDecor_Iconify = 1 << 5,
49 MwmDecor_Maximize = 1 << 6 };
51 // the things the user can do to the client window
52 enum Function { Func_Resize = 1 << 0,
54 Func_Iconify = 1 << 2,
55 Func_Maximize = 1 << 3,
56 Func_Close = 1 << 4 };
57 typedef unsigned char FunctionFlags;
59 // the decorations the client window wants to be displayed on it
60 enum Decoration { Decor_Titlebar = 1 << 0,
61 Decor_Handle = 1 << 1,
62 Decor_Border = 1 << 2,
63 Decor_Iconify = 1 << 3,
64 Decor_Maximize = 1 << 4,
65 Decor_Close = 1 << 5 };
66 typedef unsigned char DecorationFlags;
68 // this structure only contains 3 elements... the Motif 2.0 structure
69 // contains 5... we only need the first 3... so that is all we will define
70 typedef struct MwmHints {
71 static const unsigned int elements = 3;
73 unsigned long functions;
74 unsigned long decorations;
77 enum StateAction { State_Remove = 0, // _NET_WM_STATE_REMOVE
78 State_Add, // _NET_WM_STATE_ADD
79 State_Toggle // _NET_WM_STATE_TOGGLE
83 //! The actual window that this class is wrapping up
86 //! The id of the group the window belongs to
89 // XXX: transient_for, transients
91 //! The desktop on which the window resides (0xffffffff for all desktops)
92 unsigned long _desktop;
94 //! Normal window title
95 std::string _title; // XXX: Have to keep track if this string is Utf8 or not
96 //! Window title when iconifiged
97 std::string _icon_title;
99 //! The application that created the window
100 std::string _app_name;
101 //! The class of the window, can used for grouping
102 std::string _app_class;
104 //! The type of window (what its function is)
107 //! Position and size of the window (relative to the root window)
110 //! Width of the border on the window.
112 The window manager will set this to 0 while the window is being managed,
113 but needs to restore it afterwards, so it is saved here.
118 // if min > max, then the window is not resizable
119 int _min_x, _min_y; // minumum size
120 int _max_x, _max_y; // maximum size
121 int _inc_x, _inc_y; // resize increments
122 int _base_x, _base_y; // base size
124 //! Where to place the decorated window in relation to the undecorated window
127 //! The state of the window, one of WithdrawnState, IconicState, or
131 //! Was the window's position requested by the application? if not, we should
132 //! place the window ourselves when it first appears
135 //! Can the window receive input focus?
139 //! Notify the window when it receives focus?
142 //! The window uses shape extension to be non-rectangular?
145 //! The window is modal, so it must be processed before any windows it is
146 //! related to can be focused
148 //! Only the window's titlebar is displayed
150 //! The window is iconified
152 //! The window is maximized to fill the screen vertically
154 //! The window is maximized to fill the screen horizontally
156 //! The window is a 'fullscreen' window, and should be on top of all others
158 //! The window should be on top of other windows of the same type
161 //! A bitmask of values in the OBClient::Decoration enum
163 The values in the variable are the decorations that the client wants to be
166 DecorationFlags _decorations;
168 //! A bitmask of values in the OBClient::Function enum
170 The values in the variable specify the ways in which the user is allowed to
173 FunctionFlags _functions;
182 void setWMState(long state);
183 void setDesktop(long desktop);
184 void setState(StateAction action, long data1, long data2);
186 void updateProtocols();
187 void updateNormalHints();
188 void updateWMHints();
189 // XXX: updateTransientFor();
194 OBClient(Window window);
197 inline Window window() const { return _window; }
199 inline WindowType type() const { return _type; }
200 inline unsigned long desktop() const { return _desktop; }
201 inline const std::string &title() const { return _title; }
202 inline const std::string &iconTitle() const { return _title; }
203 inline const std::string &appName() const { return _app_name; }
204 inline const std::string &appClass() const { return _app_class; }
205 inline bool canFocus() const { return _can_focus; }
206 inline bool urgent() const { return _urgent; }
207 inline bool focusNotify() const { return _focus_notify; }
208 inline bool shaped() const { return _shaped; }
209 inline int gravity() const { return _gravity; }
210 inline bool positionRequested() const { return _positioned; }
211 inline DecorationFlags decorations() const { return _decorations; }
212 inline FunctionFlags funtions() const { return _functions; }
215 inline bool modal() const { return _modal; }
216 inline bool shaded() const { return _shaded; }
217 inline bool iconic() const { return _iconic; }
218 inline bool maxVert() const { return _max_vert; }
219 inline bool maxHorz() const { return _max_horz; }
220 inline bool fullscreen() const { return _fullscreen; }
221 inline bool floating() const { return _floating; }
223 inline int borderWidth() const { return _border_width; }
224 inline int minX() const { return _min_x; }
225 inline int minY() const { return _min_y; }
226 inline int maxX() const { return _max_x; }
227 inline int maxY() const { return _max_y; }
228 inline int incrementX() const { return _inc_x; }
229 inline int incrementY() const { return _inc_y; }
230 inline int baseX() const { return _base_x; }
231 inline int baseY() const { return _base_y; }
233 inline const otk::Rect &area() const { return _area; }
235 void update(const XPropertyEvent &e);
236 void update(const XClientMessageEvent &e);
238 void setArea(const otk::Rect &area);
243 #endif // __client_hh