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