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