2 * client.h - client management header
4 * Copyright © 2007-2009 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_OBJECTS_CLIENT_H
23 #define AWESOME_OBJECTS_CLIENT_H
29 #include "objects/window.h"
30 #include "common/luaobject.h"
32 #define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
33 | XCB_EVENT_MASK_PROPERTY_CHANGE \
34 | XCB_EVENT_MASK_FOCUS_CHANGE)
36 #define FRAME_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
37 | XCB_EVENT_MASK_ENTER_WINDOW \
38 | XCB_EVENT_MASK_LEAVE_WINDOW \
39 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT)
45 /** Client logical screen */
48 char *name
, *alt_name
, *icon_name
, *alt_icon_name
;
50 char *class, *instance
;
51 /** Window geometry */
53 /** True if the client is sticky */
55 /** Has urgency hint */
57 /** True if the client is hidden */
59 /** True if the client is minimized */
61 /** True if the client is fullscreen */
63 /** True if the client is maximized horizontally */
64 bool maximized_horizontal
;
65 /** True if the client is maximized vertically */
66 bool maximized_vertical
;
67 /** True if the client is above others */
69 /** True if the client is below others */
71 /** True if the client is modal */
73 /** True if the client is on top */
75 /** True if a client is banned to a position outside the viewport.
76 * Note that the geometry remains unchanged and that the window is still mapped.
79 /** true if the client must be skipped from task bar client list */
81 /** True if the client cannot have focus */
83 /** Window of the group leader */
84 xcb_window_t group_window
;
85 /** Window holding command needed to start it (session management related) */
86 xcb_window_t leader_window
;
87 /** Client's WM_PROTOCOLS property */
88 xcb_icccm_get_wm_protocols_reply_t protocols
;
92 cairo_surface_t
*icon
;
94 xcb_size_hints_t size_hints
;
95 bool size_hints_honor
;
96 /** Machine the client is running on. */
98 /** Role of the client */
102 /** Window it is transient for */
103 client_t
*transient_for
;
106 ARRAY_FUNCS(client_t
*, client
, DO_NOTHING
)
109 lua_class_t client_class
;
111 LUA_OBJECT_FUNCS(client_class
, client_t
, client
)
113 bool client_maybevisible(client_t
*);
114 client_t
* client_getbywin(xcb_window_t
);
115 client_t
* client_getbyframewin(xcb_window_t
);
117 void client_ban(client_t
*);
118 void client_ban_unfocus(client_t
*);
119 void client_unban(client_t
*);
120 void client_manage(xcb_window_t
, xcb_get_geometry_reply_t
*, bool);
121 bool client_resize(client_t
*, area_t
);
122 void client_unmanage(client_t
*, bool);
123 void client_kill(client_t
*);
124 void client_set_sticky(lua_State
*, int, bool);
125 void client_set_above(lua_State
*, int, bool);
126 void client_set_below(lua_State
*, int, bool);
127 void client_set_modal(lua_State
*, int, bool);
128 void client_set_ontop(lua_State
*, int, bool);
129 void client_set_fullscreen(lua_State
*, int, bool);
130 void client_set_maximized_horizontal(lua_State
*, int, bool);
131 void client_set_maximized_vertical(lua_State
*, int, bool);
132 void client_set_minimized(lua_State
*, int, bool);
133 void client_set_urgent(lua_State
*, int, bool);
134 void client_set_pid(lua_State
*, int, uint32_t);
135 void client_set_role(lua_State
*, int, char *);
136 void client_set_machine(lua_State
*, int, char *);
137 void client_set_icon_name(lua_State
*, int, char *);
138 void client_set_alt_icon_name(lua_State
*, int, char *);
139 void client_set_class_instance(lua_State
*, int, const char *, const char *);
140 void client_set_type(lua_State
*L
, int, window_type_t
);
141 void client_set_transient_for(lua_State
*L
, int, client_t
*);
142 void client_set_name(lua_State
*L
, int, char *);
143 void client_set_alt_name(lua_State
*L
, int, char *);
144 void client_set_group_window(lua_State
*, int, xcb_window_t
);
145 void client_set_icon(client_t
*c
, cairo_surface_t
*s
);
146 void client_set_skip_taskbar(lua_State
*, int, bool);
147 void client_focus(client_t
*);
148 void client_focus_update(client_t
*);
149 void client_focus_refresh(void);
150 bool client_hasproto(client_t
*, xcb_atom_t
);
151 void client_ignore_enterleave_events(void);
152 void client_restore_enterleave_events(void);
153 void client_class_setup(lua_State
*);
155 /** Put client on top of the stack.
156 * \param c The client to raise.
159 client_raise(client_t
*c
)
164 /* Find number of transient layers.
165 * We limit the counter to the stack length: if some case, a buggy
166 * application might set transient_for as a loop… */
167 for(counter
= 0; tc
->transient_for
&& counter
<= globalconf
.stack
.len
; counter
++)
168 tc
= tc
->transient_for
;
170 /* Push them in reverse order. */
171 for(; counter
> 0; counter
--)
174 for(int i
= 0; i
< counter
; i
++)
175 tc
= tc
->transient_for
;
176 stack_client_append(tc
);
179 /* Push c on top of the stack. */
180 stack_client_append(c
);
183 /** Check if a client has fixed size.
185 * \return A boolean value, true if the client has a fixed size.
188 client_isfixed(client_t
*c
)
190 return (c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MAX_SIZE
191 && c
->size_hints
.flags
& XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
192 && c
->size_hints
.max_width
== c
->size_hints
.min_width
193 && c
->size_hints
.max_height
== c
->size_hints
.min_height
194 && c
->size_hints
.max_width
195 && c
->size_hints
.max_height
196 && c
->size_hints_honor
);
199 /** Returns true if a client is tagged with one of the tags of the
200 * specified screen and is not hidden. Note that "banned" clients are included.
201 * \param c The client to check.
202 * \param screen Virtual screen number.
203 * \return true if the client is visible, false otherwise.
206 client_isvisible(client_t
*c
)
208 return (!c
->hidden
&& !c
->minimized
&& client_maybevisible(c
));
212 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80