Set c.screen in ewmh.tag and before tags in rules.execute
[awesome.git] / objects / client.h
bloba5bbe902a7de3a13deb5062b4b672c9b4c591563
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_OBJECTS_CLIENT_H
23 #define AWESOME_OBJECTS_CLIENT_H
25 #include "mouse.h"
26 #include "stack.h"
27 #include "draw.h"
28 #include "banning.h"
29 #include "objects/window.h"
30 #include "objects/drawable.h"
31 #include "common/luaobject.h"
33 #define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
34 | XCB_EVENT_MASK_PROPERTY_CHANGE \
35 | XCB_EVENT_MASK_FOCUS_CHANGE)
37 #define FRAME_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
38 | XCB_EVENT_MASK_ENTER_WINDOW \
39 | XCB_EVENT_MASK_LEAVE_WINDOW \
40 | XCB_EVENT_MASK_EXPOSURE \
41 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT \
42 | XCB_EVENT_MASK_POINTER_MOTION \
43 | XCB_EVENT_MASK_BUTTON_PRESS \
44 | XCB_EVENT_MASK_BUTTON_RELEASE)
46 typedef enum {
47 CLIENT_TITLEBAR_TOP = 0,
48 CLIENT_TITLEBAR_RIGHT = 1,
49 CLIENT_TITLEBAR_BOTTOM = 2,
50 CLIENT_TITLEBAR_LEFT = 3,
51 /* This is not a valid value, but the number of valid values */
52 CLIENT_TITLEBAR_COUNT = 4
53 } client_titlebar_t;
55 /** client_t type */
56 struct client_t
58 WINDOW_OBJECT_HEADER
59 /** Client logical screen */
60 screen_t *screen;
61 /** Client name */
62 char *name, *alt_name, *icon_name, *alt_icon_name;
63 /** WM_CLASS stuff */
64 char *class, *instance;
65 /** Window geometry */
66 area_t geometry;
67 /** Startup ID */
68 char *startup_id;
69 /** True if the client is sticky */
70 bool sticky;
71 /** Has urgency hint */
72 bool urgent;
73 /** True if the client is hidden */
74 bool hidden;
75 /** True if the client is minimized */
76 bool minimized;
77 /** True if the client is fullscreen */
78 bool fullscreen;
79 /** True if the client is maximized horizontally */
80 bool maximized_horizontal;
81 /** True if the client is maximized vertically */
82 bool maximized_vertical;
83 /** True if the client is above others */
84 bool above;
85 /** True if the client is below others */
86 bool below;
87 /** True if the client is modal */
88 bool modal;
89 /** True if the client is on top */
90 bool ontop;
91 /** True if a client is banned to a position outside the viewport.
92 * Note that the geometry remains unchanged and that the window is still mapped.
94 bool isbanned;
95 /** true if the client must be skipped from task bar client list */
96 bool skip_taskbar;
97 /** True if the client cannot have focus */
98 bool nofocus;
99 /** Window of the group leader */
100 xcb_window_t group_window;
101 /** Window holding command needed to start it (session management related) */
102 xcb_window_t leader_window;
103 /** Client's WM_PROTOCOLS property */
104 xcb_icccm_get_wm_protocols_reply_t protocols;
105 /** Key bindings */
106 key_array_t keys;
107 /** Icon */
108 cairo_surface_t *icon;
109 /** Size hints */
110 xcb_size_hints_t size_hints;
111 /** The visualtype that c->window uses */
112 xcb_visualtype_t *visualtype;
113 /** Do we honor the client's size hints? */
114 bool size_hints_honor;
115 /** Machine the client is running on. */
116 char *machine;
117 /** Role of the client */
118 char *role;
119 /** Client pid */
120 uint32_t pid;
121 /** Window it is transient for */
122 client_t *transient_for;
123 /** Titelbar information */
124 struct {
125 /** The size of this bar. */
126 uint16_t size;
127 /** The drawable for this bar. */
128 drawable_t *drawable;
129 } titlebar[CLIENT_TITLEBAR_COUNT];
132 ARRAY_FUNCS(client_t *, client, DO_NOTHING)
134 /** Client class */
135 lua_class_t client_class;
137 LUA_OBJECT_FUNCS(client_class, client_t, client)
139 bool client_maybevisible(client_t *);
140 client_t * client_getbywin(xcb_window_t);
141 client_t * client_getbyframewin(xcb_window_t);
143 void client_ban(client_t *);
144 void client_ban_unfocus(client_t *);
145 void client_unban(client_t *);
146 void client_manage(xcb_window_t, xcb_get_geometry_reply_t *, xcb_get_window_attributes_reply_t *);
147 bool client_resize(client_t *, area_t, bool);
148 void client_unmanage(client_t *, bool);
149 void client_kill(client_t *);
150 void client_set_sticky(lua_State *, int, bool);
151 void client_set_above(lua_State *, int, bool);
152 void client_set_below(lua_State *, int, bool);
153 void client_set_modal(lua_State *, int, bool);
154 void client_set_ontop(lua_State *, int, bool);
155 void client_set_fullscreen(lua_State *, int, bool);
156 void client_set_maximized(lua_State *, int, bool);
157 void client_set_maximized_horizontal(lua_State *, int, bool);
158 void client_set_maximized_vertical(lua_State *, int, bool);
159 void client_set_minimized(lua_State *, int, bool);
160 void client_set_urgent(lua_State *, int, bool);
161 void client_set_pid(lua_State *, int, uint32_t);
162 void client_set_role(lua_State *, int, char *);
163 void client_set_machine(lua_State *, int, char *);
164 void client_set_icon_name(lua_State *, int, char *);
165 void client_set_alt_icon_name(lua_State *, int, char *);
166 void client_set_class_instance(lua_State *, int, const char *, const char *);
167 void client_set_type(lua_State *L, int, window_type_t);
168 void client_set_transient_for(lua_State *L, int, client_t *);
169 void client_set_name(lua_State *L, int, char *);
170 void client_set_alt_name(lua_State *L, int, char *);
171 void client_set_group_window(lua_State *, int, xcb_window_t);
172 void client_set_icon(client_t *c, cairo_surface_t *s);
173 void client_set_skip_taskbar(lua_State *, int, bool);
174 void client_focus(client_t *);
175 void client_focus_update(client_t *);
176 void client_focus_refresh(void);
177 bool client_hasproto(client_t *, xcb_atom_t);
178 void client_ignore_enterleave_events(void);
179 void client_restore_enterleave_events(void);
180 void client_refresh_partial(client_t *, int16_t, int16_t, uint16_t, uint16_t);
181 void client_class_setup(lua_State *);
182 void client_send_configure(client_t *);
183 drawable_t *client_get_drawable(client_t *, int, int);
184 drawable_t *client_get_drawable_offset(client_t *, int *, int *);
186 /** Put client on top of the stack.
187 * \param c The client to raise.
189 static inline void
190 client_raise(client_t *c)
192 client_t *tc = c;
193 int counter = 0;
195 /* Find number of transient layers. */
196 for(counter = 0; tc->transient_for; counter++)
197 tc = tc->transient_for;
199 /* Push them in reverse order. */
200 for(; counter > 0; counter--)
202 tc = c;
203 for(int i = 0; i < counter; i++)
204 tc = tc->transient_for;
205 stack_client_append(tc);
208 /* Push c on top of the stack. */
209 stack_client_append(c);
212 /** Check if a client has fixed size.
213 * \param c A client.
214 * \return A boolean value, true if the client has a fixed size.
216 static inline bool
217 client_isfixed(client_t *c)
219 return (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE
220 && c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
221 && c->size_hints.max_width == c->size_hints.min_width
222 && c->size_hints.max_height == c->size_hints.min_height
223 && c->size_hints.max_width
224 && c->size_hints.max_height
225 && c->size_hints_honor);
228 /** Returns true if a client is tagged with one of the tags of the
229 * specified screen and is not hidden. Note that "banned" clients are included.
230 * \param c The client to check.
231 * \param screen Virtual screen number.
232 * \return true if the client is visible, false otherwise.
234 static inline bool
235 client_isvisible(client_t *c)
237 return (!c->hidden && !c->minimized && client_maybevisible(c));
240 #endif
241 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80