awesomerc: remove marking
[awesome.git] / client.h
blob3b4ebf494e2414840d1bcf71e1f1fc44afdd0503
1 /*
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
25 #include "mouse.h"
26 #include "stack.h"
27 #include "common/luaclass.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)
35 /** Windows type */
36 typedef enum
38 WINDOW_TYPE_NORMAL = 0,
39 WINDOW_TYPE_DESKTOP,
40 WINDOW_TYPE_DOCK,
41 WINDOW_TYPE_SPLASH,
42 WINDOW_TYPE_DIALOG,
43 /* The ones below may have TRANSIENT_FOR, but are not plain dialogs.
44 * They were purposefully placed below DIALOG.
46 WINDOW_TYPE_MENU,
47 WINDOW_TYPE_TOOLBAR,
48 WINDOW_TYPE_UTILITY,
49 /* This ones are usually set on override-redirect windows. */
50 WINDOW_TYPE_DROPDOWN_MENU,
51 WINDOW_TYPE_POPUP_MENU,
52 WINDOW_TYPE_TOOLTIP,
53 WINDOW_TYPE_NOTIFICATION,
54 WINDOW_TYPE_COMBO,
55 WINDOW_TYPE_DND
56 } window_type_t;
58 /* Strut */
59 typedef struct
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;
66 } strut_t;
68 /** client_t type */
69 struct client_t
71 LUA_OBJECT_HEADER
72 /** Valid, or not ? */
73 bool invalid;
74 /** Client name */
75 char *name, *icon_name;
76 /** WM_CLASS stuff */
77 char *class, *instance;
78 /** Startup ID */
79 char *startup_id;
80 /** Window geometry */
81 area_t geometry;
82 struct
84 /** Client geometry when (un)fullscreen */
85 area_t fullscreen;
86 /** Client geometry when (un)-max */
87 area_t max;
88 /** Internal geometry (matching X11 protocol) */
89 area_t internal;
90 } geometries;
91 /** Strut */
92 strut_t strut;
93 /** Border width and pre-fullscreen border width */
94 int border, border_fs;
95 xcolor_t border_color;
96 /** True if the client is sticky */
97 bool issticky;
98 /** Has urgency hint */
99 bool isurgent;
100 /** True if the client is hidden */
101 bool ishidden;
102 /** True if the client is minimized */
103 bool isminimized;
104 /** True if the client is fullscreen */
105 bool isfullscreen;
106 /** True if the client is maximized horizontally */
107 bool ismaxhoriz;
108 /** True if the client is maximized vertically */
109 bool ismaxvert;
110 /** True if the client is above others */
111 bool isabove;
112 /** True if the client is below others */
113 bool isbelow;
114 /** True if the client is modal */
115 bool ismodal;
116 /** True if the client is on top */
117 bool isontop;
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.
121 bool isbanned;
122 /** true if the client must be skipped from task bar client list */
123 bool skiptb;
124 /** True if the client cannot have focus */
125 bool nofocus;
126 /** The window type */
127 window_type_t type;
128 /** Window of the client */
129 xcb_window_t win;
130 /** Window of the group leader */
131 xcb_window_t group_win;
132 /** Window holding command needed to start it (session management related) */
133 xcb_window_t leader_win;
134 /** Client's WM_PROTOCOLS property */
135 xcb_get_wm_protocols_reply_t protocols;
136 /** Client logical screen */
137 screen_t *screen;
138 /** Client physical screen */
139 int phys_screen;
140 /** Titlebar */
141 wibox_t *titlebar;
142 /** Button bindings */
143 button_array_t buttons;
144 /** Key bindings */
145 key_array_t keys;
146 /** Icon */
147 image_t *icon;
148 /** Size hints */
149 xcb_size_hints_t size_hints;
150 bool size_hints_honor;
151 /** Machine the client is running on. */
152 char *machine;
153 /** Role of the client */
154 char *role;
155 /** Client pid */
156 uint32_t pid;
157 /** Window it is transient for */
158 client_t *transient_for;
159 /** Window opacity */
160 double opacity;
163 client_t * luaA_client_checkudata(lua_State *, int);
165 ARRAY_FUNCS(client_t *, client, DO_NOTHING)
167 /** Client class */
168 lua_class_t client_class;
170 LUA_OBJECT_FUNCS(client_class, client_t, client, "client")
172 #define client_need_reban(c) \
173 do { \
174 if(!c->screen->need_reban \
175 && client_isvisible(c, (c)->screen)) \
176 c->screen->need_reban = true; \
177 } while(0)
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_setsticky(client_t *, bool);
189 void client_setabove(client_t *, bool);
190 void client_setbelow(client_t *, bool);
191 void client_setmodal(client_t *, bool);
192 void client_setontop(client_t *, bool);
193 void client_setfullscreen(client_t *, bool);
194 void client_setmaxhoriz(client_t *, bool);
195 void client_setmaxvert(client_t *, bool);
196 void client_setminimized(client_t *, bool);
197 void client_setborder(client_t *, int);
198 void client_seturgent(client_t *, bool);
199 void client_focus(client_t *);
200 void client_focus_update(client_t *);
201 void client_unfocus(client_t *);
202 void client_unfocus_update(client_t *);
203 void client_stack_refresh(void);
204 bool client_hasproto(client_t *, xcb_atom_t);
205 void client_setfocus(client_t *, bool);
206 void client_ignore_enterleave_events(void);
207 void client_restore_enterleave_events(void);
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 for(counter = 0; tc->transient_for; counter++)
226 tc = tc->transient_for;
228 /* Push them in reverse order. */
229 for(; counter > 0; counter--)
231 tc = c;
232 for(int i = 0; i < counter; i++)
233 tc = tc->transient_for;
234 stack_client_append(tc);
237 /* Push c on top of the stack. */
238 stack_client_append(c);
239 client_stack();
242 /** Put client on the end of the stack.
243 * \param c The client to lower.
245 static inline void
246 client_lower(client_t *c)
248 stack_client_push(c);
250 /* Traverse all transient layers. */
251 for(client_t *tc = c->transient_for; tc; tc = tc->transient_for)
252 stack_client_push(tc);
254 client_stack();
257 /** Check if a client has fixed size.
258 * \param c A client.
259 * \return A boolean value, true if the client has a fixed size.
261 static inline bool
262 client_isfixed(client_t *c)
264 return (c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE
265 && c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE
266 && c->size_hints.max_width == c->size_hints.min_width
267 && c->size_hints.max_height == c->size_hints.min_height
268 && c->size_hints.max_width
269 && c->size_hints.max_height);
272 /** Returns true if a client is tagged with one of the tags of the
273 * specified screen and is not hidden. Note that "banned" clients are included.
274 * \param c The client to check.
275 * \param screen Virtual screen number.
276 * \return true if the client is visible, false otherwise.
278 static inline bool
279 client_isvisible(client_t *c, screen_t *screen)
281 return (!c->ishidden && !c->isminimized && client_maybevisible(c, screen));
284 /** Check if a client has strut information.
285 * \param c A client.
286 * \return A boolean value, true if the client has strut information.
288 static inline bool
289 client_hasstrut(client_t *c)
291 return (c->strut.left
292 || c->strut.right
293 || c->strut.top
294 || c->strut.bottom
295 || c->strut.left_start_y
296 || c->strut.left_end_y
297 || c->strut.right_start_y
298 || c->strut.right_end_y
299 || c->strut.top_start_x
300 || c->strut.top_end_x
301 || c->strut.bottom_start_x
302 || c->strut.bottom_end_x);
305 #endif
306 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80