2 * client.h - client management header
4 * Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_CLIENT_H
23 #define AWESOME_CLIENT_H
27 #include "common/luaobject.h"
29 #define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
30 | XCB_EVENT_MASK_PROPERTY_CHANGE \
31 | XCB_EVENT_MASK_ENTER_WINDOW \
32 | XCB_EVENT_MASK_LEAVE_WINDOW \
33 | XCB_EVENT_MASK_FOCUS_CHANGE)
38 WINDOW_TYPE_NORMAL
= 0,
43 /* The ones below may have TRANSIENT_FOR, but are not plain dialogs.
44 * They were purposefully placed below DIALOG.
49 /* This ones are usually set on override-redirect windows. */
50 WINDOW_TYPE_DROPDOWN_MENU
,
51 WINDOW_TYPE_POPUP_MENU
,
53 WINDOW_TYPE_NOTIFICATION
,
61 uint16_t left
, right
, top
, bottom
;
62 uint16_t left_start_y
, left_end_y
;
63 uint16_t right_start_y
, right_end_y
;
64 uint16_t top_start_x
, top_end_x
;
65 uint16_t bottom_start_x
, bottom_end_x
;
72 /** Valid, or not ? */
75 char *name
, *icon_name
;
77 char *class, *instance
;
80 /** Window geometry */
84 /** Client geometry when (un)fullscreen */
86 /** Client geometry when (un)-max */
88 /** Internal geometry (matching X11 protocol) */
93 /** Border width and pre-fullscreen border width */
94 int border_width
, border_width_fs
;
95 xcolor_t border_color
;
96 /** True if the client is sticky */
98 /** Has urgency hint */
100 /** True if the client is hidden */
102 /** True if the client is minimized */
104 /** True if the client is fullscreen */
106 /** True if the client is maximized horizontally */
107 bool maximized_horizontal
;
108 /** True if the client is maximized vertically */
109 bool maximized_vertical
;
110 /** True if the client is above others */
112 /** True if the client is below others */
114 /** True if the client is modal */
116 /** True if the client is on top */
118 /** True if a client is banned to a position outside the viewport.
119 * Note that the geometry remains unchanged and that the window is still mapped.
122 /** true if the client must be skipped from task bar client list */
124 /** True if the client cannot have focus */
126 /** The window type */
128 /** Window of the client */
130 /** Window of the group leader */
131 xcb_window_t group_window
;
132 /** Window holding command needed to start it (session management related) */
133 xcb_window_t leader_window
;
134 /** Client's WM_PROTOCOLS property */
135 xcb_get_wm_protocols_reply_t protocols
;
136 /** Client logical screen */
138 /** Client physical screen */
142 /** Button bindings */
143 button_array_t buttons
;
149 xcb_size_hints_t size_hints
;
150 bool size_hints_honor
;
151 /** Machine the client is running on. */
153 /** Role of the client */
157 /** Window it is transient for */
158 client_t
*transient_for
;
159 /** Window opacity */
163 client_t
* luaA_client_checkudata(lua_State
*, int);
165 ARRAY_FUNCS(client_t
*, client
, DO_NOTHING
)
168 lua_class_t client_class
;
170 LUA_OBJECT_FUNCS(client_class
, client_t
, client
)
172 #define client_need_reban(c) \
174 if(!c->screen->need_reban \
175 && client_isvisible(c, (c)->screen)) \
176 c->screen->need_reban = true; \
179 bool client_maybevisible(client_t
*, screen_t
*);
180 client_t
* client_getbywin(xcb_window_t
);
181 void client_ban(client_t
*);
182 void client_unban(client_t
*);
183 void client_manage(xcb_window_t
, xcb_get_geometry_reply_t
*, int, bool);
184 area_t
client_geometry_hints(client_t
*, area_t
);
185 bool client_resize(client_t
*, area_t
, bool);
186 void client_unmanage(client_t
*);
187 void client_kill(client_t
*);
188 void client_set_sticky(lua_State
*, int, bool);
189 void client_set_above(lua_State
*, int, bool);
190 void client_set_below(lua_State
*, int, bool);
191 void client_set_modal(lua_State
*, int, bool);
192 void client_set_ontop(lua_State
*, int, bool);
193 void client_set_fullscreen(lua_State
*, int, bool);
194 void client_set_maximized_horizontal(lua_State
*, int, bool);
195 void client_set_maximized_vertical(lua_State
*, int, bool);
196 void client_set_minimized(lua_State
*, int, bool);
197 void client_set_border_width(lua_State
*, int, int);
198 void client_set_urgent(lua_State
*, int, bool);
199 void client_set_pid(lua_State
*, int, uint32_t);
200 void client_set_role(lua_State
*, int, const char *);
201 void client_set_machine(lua_State
*, int, const char *);
202 void client_set_icon_name(lua_State
*, int, const char *);
203 void client_set_class_instance(lua_State
*, int, const char *, const char *);
204 void client_set_type(lua_State
*L
, int, window_type_t
);
205 void client_set_transient_for(lua_State
*L
, int, client_t
*);
206 void client_set_name(lua_State
*L
, int, const char *);
207 void client_set_group_window(lua_State
*, int, xcb_window_t
);
208 void client_set_icon(lua_State
*, int, int);
209 void client_set_skip_taskbar(lua_State
*, int, bool);
210 void client_set_opacity(lua_State
*, int, double);
211 void client_focus(client_t
*);
212 void client_focus_update(client_t
*);
213 void client_unfocus(client_t
*);
214 void client_unfocus_update(client_t
*);
215 void client_stack_refresh(void);
216 bool client_hasproto(client_t
*, xcb_atom_t
);
217 void client_set_focus(client_t
*, bool);
218 void client_ignore_enterleave_events(void);
219 void client_restore_enterleave_events(void);
220 void client_class_setup(lua_State
*);
225 globalconf
.client_need_stack_refresh
= true;
228 /** Put client on top of the stack.
229 * \param c The client to raise.
232 client_raise(client_t
*c
)
237 /* Find number of transient layers. */
238 for(counter
= 0; tc
->transient_for
; counter
++)
239 tc
= tc
->transient_for
;
241 /* Push them in reverse order. */
242 for(; counter
> 0; counter
--)
245 for(int i
= 0; i
< counter
; i
++)
246 tc
= tc
->transient_for
;
247 stack_client_append(tc
);
250 /* Push c on top of the stack. */
251 stack_client_append(c
);
255 /** Put client on the end of the stack.
256 * \param c The client to lower.
259 client_lower(client_t
*c
)
261 stack_luaA_object_push(c
);
263 /* Traverse all transient layers. */
264 for(client_t
*tc
= c
->transient_for
; tc
; tc
= tc
->transient_for
)
265 stack_luaA_object_push(tc
);
270 /** Check if a client has fixed size.
272 * \return A boolean value, true if the client has a fixed size.
275 client_isfixed(client_t
*c
)
277 return (c
->size_hints
.flags
& XCB_SIZE_HINT_P_MAX_SIZE
278 && c
->size_hints
.flags
& XCB_SIZE_HINT_P_MIN_SIZE
279 && c
->size_hints
.max_width
== c
->size_hints
.min_width
280 && c
->size_hints
.max_height
== c
->size_hints
.min_height
281 && c
->size_hints
.max_width
282 && c
->size_hints
.max_height
);
285 /** Returns true if a client is tagged with one of the tags of the
286 * specified screen and is not hidden. Note that "banned" clients are included.
287 * \param c The client to check.
288 * \param screen Virtual screen number.
289 * \return true if the client is visible, false otherwise.
292 client_isvisible(client_t
*c
, screen_t
*screen
)
294 return (!c
->hidden
&& !c
->minimized
&& client_maybevisible(c
, screen
));
297 /** Check if a client has strut information.
299 * \return A boolean value, true if the client has strut information.
302 client_hasstrut(client_t
*c
)
304 return (c
->strut
.left
308 || c
->strut
.left_start_y
309 || c
->strut
.left_end_y
310 || c
->strut
.right_start_y
311 || c
->strut
.right_end_y
312 || c
->strut
.top_start_x
313 || c
->strut
.top_end_x
314 || c
->strut
.bottom_start_x
315 || c
->strut
.bottom_end_x
);
319 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80