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
28 #define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
29 | XCB_EVENT_MASK_PROPERTY_CHANGE \
30 | XCB_EVENT_MASK_ENTER_WINDOW \
31 | XCB_EVENT_MASK_LEAVE_WINDOW \
32 | XCB_EVENT_MASK_FOCUS_CHANGE)
37 WINDOW_TYPE_NORMAL
= 0,
42 /* The ones below may have TRANSIENT_FOR, but are not plain dialogs.
43 * They were purposefully placed below DIALOG.
48 /* This ones are usually set on override-redirect windows. */
49 WINDOW_TYPE_DROPDOWN_MENU
,
50 WINDOW_TYPE_POPUP_MENU
,
52 WINDOW_TYPE_NOTIFICATION
,
60 uint16_t left
, right
, top
, bottom
;
61 uint16_t left_start_y
, left_end_y
;
62 uint16_t right_start_y
, right_end_y
;
63 uint16_t top_start_x
, top_end_x
;
64 uint16_t bottom_start_x
, bottom_end_x
;
70 /** Lua reference counter */
71 luaA_ref_array_t refs
;
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 /** Ignore strut temporarily. */
95 /** Border width and pre-fullscreen border width */
96 int border
, border_fs
;
97 xcolor_t border_color
;
98 /** True if the client is sticky */
100 /** Has urgency hint */
102 /** True if the client is hidden */
104 /** True if the client is minimized */
106 /** True if the client is fullscreen */
108 /** True if the client is maximized horizontally */
110 /** True if the client is maximized vertically */
112 /** True if the client is above others */
114 /** True if the client is below others */
116 /** True if the client is modal */
118 /** True if the client is on top */
120 /** True if a client is banned to a position outside the viewport.
121 * Note that the geometry remains unchanged and that the window is still mapped.
124 /** true if the client must be skipped from task bar client list */
126 /** True if the client cannot have focus */
128 /** The window type */
130 /** Window of the client */
132 /** Window of the group leader */
133 xcb_window_t group_win
;
134 /** Window holding command needed to start it (session management related) */
135 xcb_window_t leader_win
;
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 /** Window it is transient for */
152 client_t
*transient_for
;
155 client_t
* luaA_client_checkudata(lua_State
*, int);
157 ARRAY_FUNCS(client_t
*, client
, DO_NOTHING
)
158 LUA_OBJECT_FUNCS(client_t
, client
, "client")
160 #define client_need_arrange(c) \
162 if(!c->screen->need_arrange \
163 && client_isvisible(c, (c)->screen)) \
164 c->screen->need_arrange = true; \
167 bool client_maybevisible(client_t
*, screen_t
*);
168 client_t
* client_getbywin(xcb_window_t
);
169 void client_ban(client_t
*);
170 void client_unban(client_t
*);
171 void client_manage(xcb_window_t
, xcb_get_geometry_reply_t
*, int, bool);
172 area_t
client_geometry_hints(client_t
*, area_t
);
173 bool client_resize(client_t
*, area_t
, bool);
174 void client_update_strut_positions(screen_t
*);
175 void client_unmanage(client_t
*);
176 void client_kill(client_t
*);
177 void client_setsticky(client_t
*, bool);
178 void client_setabove(client_t
*, bool);
179 void client_setbelow(client_t
*, bool);
180 void client_setmodal(client_t
*, bool);
181 void client_setontop(client_t
*, bool);
182 void client_setfullscreen(client_t
*, bool);
183 void client_setmaxhoriz(client_t
*, bool);
184 void client_setmaxvert(client_t
*, bool);
185 void client_setminimized(client_t
*, bool);
186 void client_setborder(client_t
*, int);
187 void client_seturgent(client_t
*, bool);
188 void client_focus(client_t
*);
189 void client_focus_update(client_t
*);
190 void client_unfocus(client_t
*);
191 void client_unfocus_update(client_t
*);
192 void client_stack_refresh(void);
197 globalconf
.client_need_stack_refresh
= true;
200 /** Put client on top of the stack.
201 * \param c The client to raise.
204 client_raise(client_t
*c
)
209 /* Find number of transient layers. */
210 for(counter
= 0; tc
->transient_for
; counter
++)
211 tc
= tc
->transient_for
;
213 /* Push them in reverse order. */
214 for(; counter
> 0; counter
--)
217 for(int i
= 0; i
< counter
; i
++)
218 tc
= tc
->transient_for
;
219 stack_client_append(tc
);
222 /* Push c on top of the stack. */
223 stack_client_append(c
);
227 /** Put client on the end of the stack.
228 * \param c The client to lower.
231 client_lower(client_t
*c
)
233 stack_client_push(c
);
235 /* Traverse all transient layers. */
236 for(client_t
*tc
= c
->transient_for
; tc
; tc
= tc
->transient_for
)
237 stack_client_push(tc
);
242 /** Check if a client has fixed size.
244 * \return A boolean value, true if the client has a fixed size.
247 client_isfixed(client_t
*c
)
249 return (c
->size_hints
.flags
& XCB_SIZE_HINT_P_MAX_SIZE
250 && c
->size_hints
.flags
& XCB_SIZE_HINT_P_MIN_SIZE
251 && c
->size_hints
.max_width
== c
->size_hints
.min_width
252 && c
->size_hints
.max_height
== c
->size_hints
.min_height
253 && c
->size_hints
.max_width
254 && c
->size_hints
.max_height
);
257 /** Returns true if a client is tagged with one of the tags of the
258 * specified screen and is not hidden. Note that "banned" clients are included.
259 * \param c The client to check.
260 * \param screen Virtual screen number.
261 * \return true if the client is visible, false otherwise.
264 client_isvisible(client_t
*c
, screen_t
*screen
)
266 return (!c
->ishidden
&& !c
->isminimized
&& client_maybevisible(c
, screen
));
269 /** Check if a client has strut information.
271 * \return A boolean value, true if the client has strut information.
274 client_hasstrut(client_t
*c
)
276 return (c
->strut
.left
280 || c
->strut
.left_start_y
281 || c
->strut
.left_end_y
282 || c
->strut
.right_start_y
283 || c
->strut
.right_end_y
284 || c
->strut
.top_start_x
285 || c
->strut
.top_end_x
286 || c
->strut
.bottom_start_x
287 || c
->strut
.bottom_end_x
);
291 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80