change codename
[awesome.git] / client.h
blob9674fac85f7074f259bc2a384335846d7c620f7b
1 /*
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_CLIENT_H
23 #define AWESOME_CLIENT_H
25 #include "mouse.h"
26 #include "stack.h"
27 #include "strut.h"
28 #include "draw.h"
29 #include "banning.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_ENTER_WINDOW \
35 | XCB_EVENT_MASK_LEAVE_WINDOW \
36 | XCB_EVENT_MASK_FOCUS_CHANGE)
38 /** Windows type */
39 typedef enum
41 WINDOW_TYPE_NORMAL = 0,
42 WINDOW_TYPE_DESKTOP,
43 WINDOW_TYPE_DOCK,
44 WINDOW_TYPE_SPLASH,
45 WINDOW_TYPE_DIALOG,
46 /* The ones below may have TRANSIENT_FOR, but are not plain dialogs.
47 * They were purposefully placed below DIALOG.
49 WINDOW_TYPE_MENU,
50 WINDOW_TYPE_TOOLBAR,
51 WINDOW_TYPE_UTILITY,
52 /* This ones are usually set on override-redirect windows. */
53 WINDOW_TYPE_DROPDOWN_MENU,
54 WINDOW_TYPE_POPUP_MENU,
55 WINDOW_TYPE_TOOLTIP,
56 WINDOW_TYPE_NOTIFICATION,
57 WINDOW_TYPE_COMBO,
58 WINDOW_TYPE_DND
59 } window_type_t;
61 /** client_t type */
62 struct client_t
64 LUA_OBJECT_HEADER
65 /** Valid, or not ? */
66 bool invalid;
67 /** Client name */
68 char *name, *alt_name, *icon_name, *alt_icon_name;
69 /** WM_CLASS stuff */
70 char *class, *instance;
71 /** Window geometry */
72 area_t geometry;
73 struct
75 /** Client geometry when (un)fullscreen */
76 area_t fullscreen;
77 /** Client geometry when (un)-max */
78 area_t max;
79 /** Internal geometry (matching X11 protocol) */
80 area_t internal;
81 } geometries;
82 /** Strut */
83 strut_t strut;
84 /** Border width and pre-fullscreen border width */
85 int border_width, border_width_fs;
86 xcolor_t border_color;
87 /** True if the client is sticky */
88 bool sticky;
89 /** Has urgency hint */
90 bool urgent;
91 /** True if the client is hidden */
92 bool hidden;
93 /** True if the client is minimized */
94 bool minimized;
95 /** True if the client is fullscreen */
96 bool fullscreen;
97 /** True if the client is maximized horizontally */
98 bool maximized_horizontal;
99 /** True if the client is maximized vertically */
100 bool maximized_vertical;
101 /** True if the client is above others */
102 bool above;
103 /** True if the client is below others */
104 bool below;
105 /** True if the client is modal */
106 bool modal;
107 /** True if the client is on top */
108 bool ontop;
109 /** True if a client is banned to a position outside the viewport.
110 * Note that the geometry remains unchanged and that the window is still mapped.
112 bool isbanned;
113 /** true if the client must be skipped from task bar client list */
114 bool skip_taskbar;
115 /** True if the client cannot have focus */
116 bool nofocus;
117 /** The window type */
118 window_type_t type;
119 /** Window of the client */
120 xcb_window_t window;
121 /** Window of the group leader */
122 xcb_window_t group_window;
123 /** Window holding command needed to start it (session management related) */
124 xcb_window_t leader_window;
125 /** Client's WM_PROTOCOLS property */
126 xcb_icccm_get_wm_protocols_reply_t protocols;
127 /** Client logical screen */
128 screen_t *screen;
129 /** Client physical screen */
130 int phys_screen;
131 /** Titlebar */
132 wibox_t *titlebar;
133 /** Button bindings */
134 button_array_t buttons;
135 /** Key bindings */
136 key_array_t keys;
137 /** Icon */
138 image_t *icon;
139 /** Size hints */
140 xcb_size_hints_t size_hints;
141 bool size_hints_honor;
142 /** Machine the client is running on. */
143 char *machine;
144 /** Role of the client */
145 char *role;
146 /** Client pid */
147 uint32_t pid;
148 /** Window it is transient for */
149 client_t *transient_for;
150 /** Window opacity */
151 double opacity;
154 client_t * luaA_client_checkudata(lua_State *, int);
156 ARRAY_FUNCS(client_t *, client, DO_NOTHING)
158 /** Client class */
159 lua_class_t client_class;
161 LUA_OBJECT_FUNCS(client_class, client_t, client)
163 bool client_maybevisible(client_t *, screen_t *);
164 client_t * client_getbywin(xcb_window_t);
165 void client_ban(client_t *);
166 void client_ban_unfocus(client_t *);
167 void client_unban(client_t *);
168 void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, int, bool);
169 area_t client_geometry_hints(client_t *, area_t);
170 bool client_resize(client_t *, area_t, bool);
171 void client_unmanage(client_t *);
172 void client_kill(client_t *);
173 void client_set_sticky(lua_State *, int, bool);
174 void client_set_above(lua_State *, int, bool);
175 void client_set_below(lua_State *, int, bool);
176 void client_set_modal(lua_State *, int, bool);
177 void client_set_ontop(lua_State *, int, bool);
178 void client_set_fullscreen(lua_State *, int, bool);
179 void client_set_maximized_horizontal(lua_State *, int, bool);
180 void client_set_maximized_vertical(lua_State *, int, bool);
181 void client_set_minimized(lua_State *, int, bool);
182 void client_set_border_width(lua_State *, int, int);
183 void client_set_urgent(lua_State *, int, bool);
184 void client_set_pid(lua_State *, int, uint32_t);
185 void client_set_role(lua_State *, int, char *);
186 void client_set_machine(lua_State *, int, char *);
187 void client_set_icon_name(lua_State *, int, char *);
188 void client_set_alt_icon_name(lua_State *, int, char *);
189 void client_set_class_instance(lua_State *, int, const char *, const char *);
190 void client_set_type(lua_State *L, int, window_type_t);
191 void client_set_transient_for(lua_State *L, int, client_t *);
192 void client_set_name(lua_State *L, int, char *);
193 void client_set_alt_name(lua_State *L, int, char *);
194 void client_set_group_window(lua_State *, int, xcb_window_t);
195 void client_set_icon(lua_State *, int, int);
196 void client_set_skip_taskbar(lua_State *, int, bool);
197 void client_set_opacity(lua_State *, int, double);
198 void client_focus(client_t *);
199 void client_focus_update(client_t *);
200 void client_unfocus(client_t *);
201 void client_unfocus_update(client_t *);
202 void client_stack_refresh(void);
203 bool client_hasproto(client_t *, xcb_atom_t);
204 void client_set_focus(client_t *, bool);
205 void client_ignore_enterleave_events(void);
206 void client_restore_enterleave_events(void);
207 void client_class_setup(lua_State *);
209 static inline void
210 client_stack(void)
212 globalconf.client_need_stack_refresh = true;
215 /** Put client on top of the stack.
216 * \param c The client to raise.
218 static inline void
219 client_raise(client_t *c)
221 client_t *tc = c;
222 int counter = 0;
224 /* Find number of transient layers.
225 * We limit the counter to the stack length: if some case, a buggy
226 * application might set transient_for as a loop… */
227 for(counter = 0; tc->transient_for && counter <= globalconf.stack.len; counter++)
228 tc = tc->transient_for;
230 /* Push them in reverse order. */
231 for(; counter > 0; counter--)
233 tc = c;
234 for(int i = 0; i < counter; i++)
235 tc = tc->transient_for;
236 stack_client_append(tc);
239 /* Push c on top of the stack. */
240 stack_client_append(c);
241 client_stack();
244 /** Check if a client has fixed size.
245 * \param c A client.
246 * \return A boolean value, true if the client has a fixed size.
248 static inline bool
249 client_isfixed(client_t *c)
251 return (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE
252 && c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
253 && c->size_hints.max_width == c->size_hints.min_width
254 && c->size_hints.max_height == c->size_hints.min_height
255 && c->size_hints.max_width
256 && c->size_hints.max_height
257 && c->size_hints_honor);
260 /** Returns true if a client is tagged with one of the tags of the
261 * specified screen and is not hidden. Note that "banned" clients are included.
262 * \param c The client to check.
263 * \param screen Virtual screen number.
264 * \return true if the client is visible, false otherwise.
266 static inline bool
267 client_isvisible(client_t *c, screen_t *screen)
269 return (!c->hidden && !c->minimized && client_maybevisible(c, screen));
272 #endif
273 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80