Merge lp:~noskcaj/ubuntu/trusty/xfwm4/merge into lp:ubuntu/trusty/xfwm4
- Trusty (14.04)
- merge
- Merge into trusty
Proposed by
Jackson Doak
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | Dmitry Shachnev | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~noskcaj/ubuntu/trusty/xfwm4/merge | ||||
Merge into: | lp:ubuntu/trusty/xfwm4 | ||||
Diff against target: |
4137 lines (+77/-3988) 8 files modified
.pc/8563.patch/src/client.c (+0/-3926) .pc/applied-patches (+0/-1) debian/changelog (+19/-0) debian/patches/0001-fix-fullscreen-qt4-behavior-bug-8563.patch (+50/-0) debian/patches/8563.patch (+0/-50) debian/patches/series (+1/-1) debian/rules (+1/-0) src/client.c (+6/-10) |
||||
To merge this branch: | bzr merge lp:~noskcaj/ubuntu/trusty/xfwm4/merge | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dmitry Shachnev | Approve | ||
Ubuntu branches | Pending | ||
Review via email:
|
Commit message
Description of the change
Merge from debian (no real changes)
Add build flags to enable xubuntu seamless greeter to desktop transition.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed directory '.pc/8563.patch' | |||
2 | === removed directory '.pc/8563.patch/src' | |||
3 | === removed file '.pc/8563.patch/src/client.c' | |||
4 | --- .pc/8563.patch/src/client.c 2013-12-03 15:24:16 +0000 | |||
5 | +++ .pc/8563.patch/src/client.c 1970-01-01 00:00:00 +0000 | |||
6 | @@ -1,3926 +0,0 @@ | |||
7 | 1 | /* $Id$ | ||
8 | 2 | |||
9 | 3 | This program is free software; you can redistribute it and/or modify | ||
10 | 4 | it under the terms of the GNU General Public License as published by | ||
11 | 5 | the Free Software Foundation; either version 2, or (at your option) | ||
12 | 6 | any later version. | ||
13 | 7 | |||
14 | 8 | This program is distributed in the hope that it will be useful, | ||
15 | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | 11 | GNU General Public License for more details. | ||
18 | 12 | |||
19 | 13 | You should have received a copy of the GNU General Public License | ||
20 | 14 | along with this program; if not, write to the Free Software | ||
21 | 15 | Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
22 | 16 | MA 02110-1301, USA. | ||
23 | 17 | |||
24 | 18 | |||
25 | 19 | oroborus - (c) 2001 Ken Lynch | ||
26 | 20 | xfwm4 - (c) 2002-2011 Olivier Fourdan | ||
27 | 21 | |||
28 | 22 | */ | ||
29 | 23 | |||
30 | 24 | #ifdef HAVE_CONFIG_H | ||
31 | 25 | #include "config.h" | ||
32 | 26 | #endif | ||
33 | 27 | |||
34 | 28 | #include <sys/types.h> | ||
35 | 29 | #include <signal.h> | ||
36 | 30 | #include <unistd.h> | ||
37 | 31 | #include <errno.h> | ||
38 | 32 | |||
39 | 33 | #include <X11/X.h> | ||
40 | 34 | #include <X11/Xlib.h> | ||
41 | 35 | #include <X11/Xutil.h> | ||
42 | 36 | #include <X11/Xatom.h> | ||
43 | 37 | #include <X11/extensions/shape.h> | ||
44 | 38 | |||
45 | 39 | #include <glib.h> | ||
46 | 40 | #include <gdk/gdk.h> | ||
47 | 41 | #include <gdk/gdkx.h> | ||
48 | 42 | #include <gtk/gtk.h> | ||
49 | 43 | #include <libxfce4util/libxfce4util.h> | ||
50 | 44 | |||
51 | 45 | #include "client.h" | ||
52 | 46 | #include "compositor.h" | ||
53 | 47 | #include "focus.h" | ||
54 | 48 | #include "frame.h" | ||
55 | 49 | #include "hints.h" | ||
56 | 50 | #include "icons.h" | ||
57 | 51 | #include "misc.h" | ||
58 | 52 | #include "moveresize.h" | ||
59 | 53 | #include "mypixmap.h" | ||
60 | 54 | #include "mywindow.h" | ||
61 | 55 | #include "netwm.h" | ||
62 | 56 | #include "placement.h" | ||
63 | 57 | #include "screen.h" | ||
64 | 58 | #include "session.h" | ||
65 | 59 | #include "settings.h" | ||
66 | 60 | #include "stacking.h" | ||
67 | 61 | #include "startup_notification.h" | ||
68 | 62 | #include "transients.h" | ||
69 | 63 | #include "workspaces.h" | ||
70 | 64 | #include "xsync.h" | ||
71 | 65 | #include "event_filter.h" | ||
72 | 66 | |||
73 | 67 | /* Event mask definition */ | ||
74 | 68 | |||
75 | 69 | #define POINTER_EVENT_MASK \ | ||
76 | 70 | ButtonPressMask|\ | ||
77 | 71 | ButtonReleaseMask | ||
78 | 72 | |||
79 | 73 | #define FRAME_EVENT_MASK \ | ||
80 | 74 | SubstructureNotifyMask|\ | ||
81 | 75 | SubstructureRedirectMask|\ | ||
82 | 76 | PointerMotionMask|\ | ||
83 | 77 | ButtonMotionMask|\ | ||
84 | 78 | FocusChangeMask|\ | ||
85 | 79 | EnterWindowMask|\ | ||
86 | 80 | PropertyChangeMask | ||
87 | 81 | |||
88 | 82 | #define CLIENT_EVENT_MASK \ | ||
89 | 83 | StructureNotifyMask|\ | ||
90 | 84 | FocusChangeMask|\ | ||
91 | 85 | PropertyChangeMask | ||
92 | 86 | |||
93 | 87 | #define BUTTON_EVENT_MASK \ | ||
94 | 88 | EnterWindowMask|\ | ||
95 | 89 | LeaveWindowMask | ||
96 | 90 | |||
97 | 91 | /* Useful macros */ | ||
98 | 92 | #define START_ICONIC(c) \ | ||
99 | 93 | ((c->wmhints) && \ | ||
100 | 94 | (c->wmhints->initial_state == IconicState) && \ | ||
101 | 95 | !clientIsTransientOrModal (c)) | ||
102 | 96 | |||
103 | 97 | #define OPACITY_SET_STEP (guint) 0x16000000 | ||
104 | 98 | #define OPACITY_SET_MIN (guint) 0x40000000 | ||
105 | 99 | |||
106 | 100 | typedef struct _ButtonPressData ButtonPressData; | ||
107 | 101 | struct _ButtonPressData | ||
108 | 102 | { | ||
109 | 103 | int b; | ||
110 | 104 | Client *c; | ||
111 | 105 | }; | ||
112 | 106 | |||
113 | 107 | /* Forward decl */ | ||
114 | 108 | static void | ||
115 | 109 | clientUpdateIconPix (Client *c); | ||
116 | 110 | static gboolean | ||
117 | 111 | clientNewMaxSize (Client *c, XWindowChanges *wc, GdkRectangle *, tilePositionType tile); | ||
118 | 112 | |||
119 | 113 | Display * | ||
120 | 114 | clientGetXDisplay (Client *c) | ||
121 | 115 | { | ||
122 | 116 | g_return_val_if_fail (c, NULL); | ||
123 | 117 | |||
124 | 118 | return myScreenGetXDisplay (c->screen_info); | ||
125 | 119 | } | ||
126 | 120 | |||
127 | 121 | void | ||
128 | 122 | clientInstallColormaps (Client *c) | ||
129 | 123 | { | ||
130 | 124 | XWindowAttributes attr; | ||
131 | 125 | gboolean installed; | ||
132 | 126 | int i; | ||
133 | 127 | |||
134 | 128 | g_return_if_fail (c != NULL); | ||
135 | 129 | TRACE ("entering clientInstallColormaps"); | ||
136 | 130 | |||
137 | 131 | installed = FALSE; | ||
138 | 132 | if (c->ncmap) | ||
139 | 133 | { | ||
140 | 134 | for (i = c->ncmap - 1; i >= 0; i--) | ||
141 | 135 | { | ||
142 | 136 | XGetWindowAttributes (clientGetXDisplay (c), c->cmap_windows[i], &attr); | ||
143 | 137 | XInstallColormap (clientGetXDisplay (c), attr.colormap); | ||
144 | 138 | if (c->cmap_windows[i] == c->window) | ||
145 | 139 | { | ||
146 | 140 | installed = TRUE; | ||
147 | 141 | } | ||
148 | 142 | } | ||
149 | 143 | } | ||
150 | 144 | if ((!installed) && (c->cmap)) | ||
151 | 145 | { | ||
152 | 146 | XInstallColormap (clientGetXDisplay (c), c->cmap); | ||
153 | 147 | } | ||
154 | 148 | } | ||
155 | 149 | |||
156 | 150 | void | ||
157 | 151 | clientUpdateColormaps (Client *c) | ||
158 | 152 | { | ||
159 | 153 | g_return_if_fail (c != NULL); | ||
160 | 154 | TRACE ("entering clientUpdateColormaps"); | ||
161 | 155 | |||
162 | 156 | if (c->ncmap) | ||
163 | 157 | { | ||
164 | 158 | XFree (c->cmap_windows); | ||
165 | 159 | c->ncmap = 0; | ||
166 | 160 | } | ||
167 | 161 | if (!XGetWMColormapWindows (clientGetXDisplay (c), c->window, &c->cmap_windows, &c->ncmap)) | ||
168 | 162 | { | ||
169 | 163 | c->cmap_windows = NULL; | ||
170 | 164 | c->ncmap = 0; | ||
171 | 165 | } | ||
172 | 166 | } | ||
173 | 167 | |||
174 | 168 | static gchar* | ||
175 | 169 | clientCreateTitleName (Client *c, gchar *name, gchar *hostname) | ||
176 | 170 | { | ||
177 | 171 | ScreenInfo *screen_info; | ||
178 | 172 | DisplayInfo *display_info; | ||
179 | 173 | gchar *title; | ||
180 | 174 | |||
181 | 175 | g_return_val_if_fail (c != NULL, NULL); | ||
182 | 176 | TRACE ("entering clientCreateTitleName"); | ||
183 | 177 | |||
184 | 178 | screen_info = c->screen_info; | ||
185 | 179 | display_info = screen_info->display_info; | ||
186 | 180 | |||
187 | 181 | if (strlen (hostname) && (display_info->hostname) && (g_ascii_strcasecmp (display_info->hostname, hostname))) | ||
188 | 182 | { | ||
189 | 183 | /* TRANSLATORS: "(on %s)" is like "running on" the name of the other host */ | ||
190 | 184 | title = g_strdup_printf (_("%s (on %s)"), name, hostname); | ||
191 | 185 | } | ||
192 | 186 | else | ||
193 | 187 | { | ||
194 | 188 | title = g_strdup (name); | ||
195 | 189 | } | ||
196 | 190 | |||
197 | 191 | return title; | ||
198 | 192 | } | ||
199 | 193 | |||
200 | 194 | void | ||
201 | 195 | clientUpdateName (Client *c) | ||
202 | 196 | { | ||
203 | 197 | ScreenInfo *screen_info; | ||
204 | 198 | DisplayInfo *display_info; | ||
205 | 199 | gchar *hostname; | ||
206 | 200 | gchar *wm_name; | ||
207 | 201 | gchar *name; | ||
208 | 202 | gboolean refresh; | ||
209 | 203 | |||
210 | 204 | g_return_if_fail (c != NULL); | ||
211 | 205 | TRACE ("entering clientUpdateName"); | ||
212 | 206 | |||
213 | 207 | screen_info = c->screen_info; | ||
214 | 208 | display_info = screen_info->display_info; | ||
215 | 209 | |||
216 | 210 | getWindowName (display_info, c->window, &wm_name); | ||
217 | 211 | getWindowHostname (display_info, c->window, &hostname); | ||
218 | 212 | refresh = FALSE; | ||
219 | 213 | |||
220 | 214 | /* Update hostname too, as it's used when terminating a client */ | ||
221 | 215 | if (hostname) | ||
222 | 216 | { | ||
223 | 217 | if (c->hostname) | ||
224 | 218 | { | ||
225 | 219 | g_free (c->hostname); | ||
226 | 220 | } | ||
227 | 221 | c->hostname = hostname; | ||
228 | 222 | } | ||
229 | 223 | |||
230 | 224 | if (wm_name) | ||
231 | 225 | { | ||
232 | 226 | name = clientCreateTitleName (c, wm_name, hostname); | ||
233 | 227 | g_free (wm_name); | ||
234 | 228 | if (c->name) | ||
235 | 229 | { | ||
236 | 230 | if (strcmp (name, c->name)) | ||
237 | 231 | { | ||
238 | 232 | refresh = TRUE; | ||
239 | 233 | FLAG_SET (c->flags, CLIENT_FLAG_NAME_CHANGED); | ||
240 | 234 | } | ||
241 | 235 | g_free (c->name); | ||
242 | 236 | } | ||
243 | 237 | c->name = name; | ||
244 | 238 | } | ||
245 | 239 | |||
246 | 240 | if (refresh) | ||
247 | 241 | { | ||
248 | 242 | frameQueueDraw (c, TRUE); | ||
249 | 243 | } | ||
250 | 244 | } | ||
251 | 245 | |||
252 | 246 | void | ||
253 | 247 | clientUpdateAllFrames (ScreenInfo *screen_info, int mask) | ||
254 | 248 | { | ||
255 | 249 | Client *c; | ||
256 | 250 | XWindowChanges wc; | ||
257 | 251 | guint i; | ||
258 | 252 | |||
259 | 253 | g_return_if_fail (screen_info != NULL); | ||
260 | 254 | |||
261 | 255 | TRACE ("entering clientRedrawAllFrames"); | ||
262 | 256 | for (c = screen_info->clients, i = 0; i < screen_info->client_count; c = c->next, i++) | ||
263 | 257 | { | ||
264 | 258 | unsigned long configure_flags = 0L; | ||
265 | 259 | |||
266 | 260 | if (mask & UPDATE_BUTTON_GRABS) | ||
267 | 261 | { | ||
268 | 262 | clientUngrabButtons (c); | ||
269 | 263 | clientGrabButtons (c); | ||
270 | 264 | clientGrabMouseButton (c); | ||
271 | 265 | } | ||
272 | 266 | if (mask & UPDATE_CACHE) | ||
273 | 267 | { | ||
274 | 268 | clientUpdateIconPix (c); | ||
275 | 269 | } | ||
276 | 270 | if (mask & UPDATE_GRAVITY) | ||
277 | 271 | { | ||
278 | 272 | clientCoordGravitate (c, c->gravity, REMOVE, &c->x, &c->y); | ||
279 | 273 | clientCoordGravitate (c, c->gravity, APPLY, &c->x, &c->y); | ||
280 | 274 | setNetFrameExtents (screen_info->display_info, | ||
281 | 275 | c->window, | ||
282 | 276 | frameTop (c), | ||
283 | 277 | frameLeft (c), | ||
284 | 278 | frameRight (c), | ||
285 | 279 | frameBottom (c)); | ||
286 | 280 | configure_flags |= CFG_FORCE_REDRAW; | ||
287 | 281 | mask &= ~UPDATE_FRAME; | ||
288 | 282 | } | ||
289 | 283 | if (mask & UPDATE_MAXIMIZE) | ||
290 | 284 | { | ||
291 | 285 | unsigned long maximization_flags = 0L; | ||
292 | 286 | |||
293 | 287 | /* Recompute size and position of maximized windows */ | ||
294 | 288 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_MAXIMIZED_VERT)) | ||
295 | 289 | { | ||
296 | 290 | maximization_flags = c->flags & CLIENT_FLAG_MAXIMIZED; | ||
297 | 291 | |||
298 | 292 | /* Force an update by clearing the internal flags */ | ||
299 | 293 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ | CLIENT_FLAG_MAXIMIZED_VERT); | ||
300 | 294 | clientToggleMaximized (c, maximization_flags, FALSE); | ||
301 | 295 | |||
302 | 296 | configure_flags |= CFG_FORCE_REDRAW; | ||
303 | 297 | mask &= ~UPDATE_FRAME; | ||
304 | 298 | } | ||
305 | 299 | } | ||
306 | 300 | if (configure_flags != 0L) | ||
307 | 301 | { | ||
308 | 302 | wc.x = c->x; | ||
309 | 303 | wc.y = c->y; | ||
310 | 304 | wc.width = c->width; | ||
311 | 305 | wc.height = c->height; | ||
312 | 306 | clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, configure_flags); | ||
313 | 307 | } | ||
314 | 308 | if (mask & UPDATE_FRAME) | ||
315 | 309 | { | ||
316 | 310 | frameQueueDraw (c, TRUE); | ||
317 | 311 | } | ||
318 | 312 | |||
319 | 313 | } | ||
320 | 314 | } | ||
321 | 315 | |||
322 | 316 | void | ||
323 | 317 | clientGrabButtons (Client *c) | ||
324 | 318 | { | ||
325 | 319 | ScreenInfo *screen_info; | ||
326 | 320 | |||
327 | 321 | g_return_if_fail (c != NULL); | ||
328 | 322 | TRACE ("entering clientGrabButtons"); | ||
329 | 323 | TRACE ("grabbing buttons for client \"%s\" (0x%lx)", c->name, c->window); | ||
330 | 324 | |||
331 | 325 | screen_info = c->screen_info; | ||
332 | 326 | if (screen_info->params->easy_click) | ||
333 | 327 | { | ||
334 | 328 | grabButton(clientGetXDisplay (c), AnyButton, screen_info->params->easy_click, c->window); | ||
335 | 329 | } | ||
336 | 330 | } | ||
337 | 331 | |||
338 | 332 | void | ||
339 | 333 | clientUngrabButtons (Client *c) | ||
340 | 334 | { | ||
341 | 335 | g_return_if_fail (c != NULL); | ||
342 | 336 | TRACE ("entering clientUngrabButtons"); | ||
343 | 337 | TRACE ("grabbing buttons for client \"%s\" (0x%lx)", c->name, c->window); | ||
344 | 338 | |||
345 | 339 | XUngrabButton (clientGetXDisplay (c), AnyButton, AnyModifier, c->window); | ||
346 | 340 | } | ||
347 | 341 | |||
348 | 342 | static gboolean | ||
349 | 343 | urgent_cb (gpointer data) | ||
350 | 344 | { | ||
351 | 345 | Client *c; | ||
352 | 346 | ScreenInfo *screen_info; | ||
353 | 347 | |||
354 | 348 | c = (Client *) data; | ||
355 | 349 | g_return_val_if_fail (c != NULL, FALSE); | ||
356 | 350 | TRACE ("entering urgent_cb, iteration %i", c->blink_iterations); | ||
357 | 351 | screen_info = c->screen_info; | ||
358 | 352 | |||
359 | 353 | if (c != clientGetFocus ()) | ||
360 | 354 | { | ||
361 | 355 | /* | ||
362 | 356 | * If we do not blink on urgency, check if the window was last | ||
363 | 357 | * drawn focused and redraw it unfocused. | ||
364 | 358 | * This is for th case when the tuser changes the settings | ||
365 | 359 | * in between two redraws. | ||
366 | 360 | */ | ||
367 | 361 | if (!screen_info->params->urgent_blink) | ||
368 | 362 | { | ||
369 | 363 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE)) | ||
370 | 364 | { | ||
371 | 365 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE); | ||
372 | 366 | frameQueueDraw (c, FALSE); | ||
373 | 367 | } | ||
374 | 368 | |||
375 | 369 | if (c->blink_iterations) | ||
376 | 370 | { | ||
377 | 371 | c->blink_iterations = 0; | ||
378 | 372 | } | ||
379 | 373 | return TRUE; | ||
380 | 374 | } | ||
381 | 375 | /* | ||
382 | 376 | * If we blink on urgency, check if we've not reach the number | ||
383 | 377 | * of iterations and if not, simply change the status and redraw | ||
384 | 378 | */ | ||
385 | 379 | if (c->blink_iterations < (2 * MAX_BLINK_ITERATIONS)) | ||
386 | 380 | { | ||
387 | 381 | c->blink_iterations++; | ||
388 | 382 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE); | ||
389 | 383 | frameQueueDraw (c, FALSE); | ||
390 | 384 | return TRUE; | ||
391 | 385 | } | ||
392 | 386 | /* | ||
393 | 387 | * If we reached the max number of iterations, check if we | ||
394 | 388 | * repeat. If repeat_urgent_blink is set, redraw the frame and | ||
395 | 389 | * restart counting from 1 | ||
396 | 390 | */ | ||
397 | 391 | if (screen_info->params->repeat_urgent_blink) | ||
398 | 392 | { | ||
399 | 393 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE); | ||
400 | 394 | frameQueueDraw (c, FALSE); | ||
401 | 395 | c->blink_iterations = 1; | ||
402 | 396 | return TRUE; | ||
403 | 397 | } | ||
404 | 398 | } | ||
405 | 399 | else if (c->blink_iterations) | ||
406 | 400 | { | ||
407 | 401 | c->blink_iterations = 0; | ||
408 | 402 | } | ||
409 | 403 | return (TRUE); | ||
410 | 404 | } | ||
411 | 405 | |||
412 | 406 | void | ||
413 | 407 | clientUpdateUrgency (Client *c) | ||
414 | 408 | { | ||
415 | 409 | g_return_if_fail (c != NULL); | ||
416 | 410 | |||
417 | 411 | TRACE ("entering clientUpdateUrgency"); | ||
418 | 412 | |||
419 | 413 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE); | ||
420 | 414 | if (c->blink_timeout_id) | ||
421 | 415 | { | ||
422 | 416 | g_source_remove (c->blink_timeout_id); | ||
423 | 417 | frameQueueDraw (c, FALSE); | ||
424 | 418 | } | ||
425 | 419 | FLAG_UNSET (c->wm_flags, WM_FLAG_URGENT); | ||
426 | 420 | |||
427 | 421 | c->blink_timeout_id = 0; | ||
428 | 422 | c->blink_iterations = 0; | ||
429 | 423 | if ((c->wmhints) && (c->wmhints->flags & XUrgencyHint)) | ||
430 | 424 | { | ||
431 | 425 | FLAG_SET (c->wm_flags, WM_FLAG_URGENT); | ||
432 | 426 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
433 | 427 | { | ||
434 | 428 | c->blink_timeout_id = | ||
435 | 429 | g_timeout_add_full (G_PRIORITY_DEFAULT, | ||
436 | 430 | CLIENT_BLINK_TIMEOUT, | ||
437 | 431 | (GtkFunction) urgent_cb, | ||
438 | 432 | (gpointer) c, NULL); | ||
439 | 433 | } | ||
440 | 434 | } | ||
441 | 435 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE) | ||
442 | 436 | && !FLAG_TEST (c->wm_flags, WM_FLAG_URGENT) | ||
443 | 437 | && (c != clientGetFocus ())) | ||
444 | 438 | { | ||
445 | 439 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE); | ||
446 | 440 | frameQueueDraw (c, FALSE); | ||
447 | 441 | } | ||
448 | 442 | } | ||
449 | 443 | |||
450 | 444 | void | ||
451 | 445 | clientCoordGravitate (Client *c, int gravity, int mode, int *x, int *y) | ||
452 | 446 | { | ||
453 | 447 | int dx, dy; | ||
454 | 448 | |||
455 | 449 | g_return_if_fail (c != NULL); | ||
456 | 450 | TRACE ("entering clientCoordGravitate"); | ||
457 | 451 | |||
458 | 452 | switch (gravity) | ||
459 | 453 | { | ||
460 | 454 | case CenterGravity: | ||
461 | 455 | dx = (c->border_width * 2) - ((frameLeft (c) + | ||
462 | 456 | frameRight (c)) / 2); | ||
463 | 457 | dy = (c->border_width * 2) - ((frameTop (c) + | ||
464 | 458 | frameBottom (c)) / 2); | ||
465 | 459 | break; | ||
466 | 460 | case NorthGravity: | ||
467 | 461 | dx = (c->border_width * 2) - ((frameLeft (c) + | ||
468 | 462 | frameRight (c)) / 2); | ||
469 | 463 | dy = frameTop (c); | ||
470 | 464 | break; | ||
471 | 465 | case SouthGravity: | ||
472 | 466 | dx = (c->border_width * 2) - ((frameLeft (c) + | ||
473 | 467 | frameRight (c)) / 2); | ||
474 | 468 | dy = (c->border_width * 2) - frameBottom (c); | ||
475 | 469 | break; | ||
476 | 470 | case EastGravity: | ||
477 | 471 | dx = (c->border_width * 2) - frameRight (c); | ||
478 | 472 | dy = (c->border_width * 2) - ((frameTop (c) + | ||
479 | 473 | frameBottom (c)) / 2); | ||
480 | 474 | break; | ||
481 | 475 | case WestGravity: | ||
482 | 476 | dx = frameLeft (c); | ||
483 | 477 | dy = (c->border_width * 2) - ((frameTop (c) + | ||
484 | 478 | frameBottom (c)) / 2); | ||
485 | 479 | break; | ||
486 | 480 | case NorthWestGravity: | ||
487 | 481 | dx = frameLeft (c); | ||
488 | 482 | dy = frameTop (c); | ||
489 | 483 | break; | ||
490 | 484 | case NorthEastGravity: | ||
491 | 485 | dx = (c->border_width * 2) - frameRight (c); | ||
492 | 486 | dy = frameTop (c); | ||
493 | 487 | break; | ||
494 | 488 | case SouthWestGravity: | ||
495 | 489 | dx = frameLeft (c); | ||
496 | 490 | dy = (c->border_width * 2) - frameBottom (c); | ||
497 | 491 | break; | ||
498 | 492 | case SouthEastGravity: | ||
499 | 493 | dx = (c->border_width * 2) - frameRight (c); | ||
500 | 494 | dy = (c->border_width * 2) - frameBottom (c); | ||
501 | 495 | break; | ||
502 | 496 | default: | ||
503 | 497 | dx = 0; | ||
504 | 498 | dy = 0; | ||
505 | 499 | break; | ||
506 | 500 | } | ||
507 | 501 | *x = *x + (dx * mode); | ||
508 | 502 | *y = *y + (dy * mode); | ||
509 | 503 | } | ||
510 | 504 | |||
511 | 505 | void | ||
512 | 506 | clientAdjustCoordGravity (Client *c, int gravity, unsigned long *mask, XWindowChanges *wc) | ||
513 | 507 | { | ||
514 | 508 | int tx, ty, dw, dh; | ||
515 | 509 | |||
516 | 510 | g_return_if_fail (c != NULL); | ||
517 | 511 | TRACE ("entering clientAdjustCoordGravity"); | ||
518 | 512 | |||
519 | 513 | tx = wc->x; | ||
520 | 514 | ty = wc->y; | ||
521 | 515 | clientCoordGravitate (c, gravity, APPLY, &tx, &ty); | ||
522 | 516 | |||
523 | 517 | switch (gravity) | ||
524 | 518 | { | ||
525 | 519 | case CenterGravity: | ||
526 | 520 | dw = (c->width - wc->width) / 2; | ||
527 | 521 | dh = (c->height - wc->height) / 2; | ||
528 | 522 | break; | ||
529 | 523 | case NorthGravity: | ||
530 | 524 | dw = (c->width - wc->width) / 2; | ||
531 | 525 | dh = 0; | ||
532 | 526 | break; | ||
533 | 527 | case SouthGravity: | ||
534 | 528 | dw = (c->width - wc->width) / 2; | ||
535 | 529 | dh = (c->height - wc->height); | ||
536 | 530 | break; | ||
537 | 531 | case EastGravity: | ||
538 | 532 | dw = (c->width - wc->width); | ||
539 | 533 | dh = (c->height - wc->height) / 2; | ||
540 | 534 | break; | ||
541 | 535 | case WestGravity: | ||
542 | 536 | dw = 0; | ||
543 | 537 | dh = (c->height - wc->height) / 2; | ||
544 | 538 | break; | ||
545 | 539 | case NorthWestGravity: | ||
546 | 540 | dw = 0; | ||
547 | 541 | dh = 0; | ||
548 | 542 | break; | ||
549 | 543 | case NorthEastGravity: | ||
550 | 544 | dw = (c->width - wc->width); | ||
551 | 545 | dh = 0; | ||
552 | 546 | break; | ||
553 | 547 | case SouthWestGravity: | ||
554 | 548 | dw = 0; | ||
555 | 549 | dh = (c->height - wc->height); | ||
556 | 550 | break; | ||
557 | 551 | case SouthEastGravity: | ||
558 | 552 | dw = (c->width - wc->width); | ||
559 | 553 | dh = (c->height - wc->height); | ||
560 | 554 | break; | ||
561 | 555 | default: | ||
562 | 556 | dw = 0; | ||
563 | 557 | dh = 0; | ||
564 | 558 | break; | ||
565 | 559 | } | ||
566 | 560 | |||
567 | 561 | if (*mask & CWX) | ||
568 | 562 | { | ||
569 | 563 | wc->x = tx; | ||
570 | 564 | } | ||
571 | 565 | else if (*mask & CWWidth) | ||
572 | 566 | { | ||
573 | 567 | wc->x = c->x + dw; | ||
574 | 568 | *mask |= CWX; | ||
575 | 569 | } | ||
576 | 570 | |||
577 | 571 | if (*mask & CWY) | ||
578 | 572 | { | ||
579 | 573 | wc->y = ty; | ||
580 | 574 | } | ||
581 | 575 | else if (*mask & CWHeight) | ||
582 | 576 | { | ||
583 | 577 | wc->y = c->y + dh; | ||
584 | 578 | *mask |= CWY; | ||
585 | 579 | } | ||
586 | 580 | } | ||
587 | 581 | |||
588 | 582 | #define WIN_MOVED (mask & (CWX | CWY)) | ||
589 | 583 | #define WIN_RESIZED (mask & (CWWidth | CWHeight)) | ||
590 | 584 | |||
591 | 585 | static void | ||
592 | 586 | clientConfigureWindows (Client *c, XWindowChanges * wc, unsigned long mask, unsigned short flags) | ||
593 | 587 | { | ||
594 | 588 | unsigned long change_mask_frame, change_mask_client; | ||
595 | 589 | XWindowChanges change_values; | ||
596 | 590 | DisplayInfo *display_info; | ||
597 | 591 | ScreenInfo *screen_info; | ||
598 | 592 | |||
599 | 593 | screen_info = c->screen_info; | ||
600 | 594 | display_info = screen_info->display_info; | ||
601 | 595 | |||
602 | 596 | change_mask_frame = mask & (CWX | CWY | CWWidth | CWHeight); | ||
603 | 597 | change_mask_client = mask & (CWWidth | CWHeight); | ||
604 | 598 | |||
605 | 599 | if ((WIN_RESIZED) || (flags & CFG_FORCE_REDRAW)) | ||
606 | 600 | { | ||
607 | 601 | frameDraw (c, (flags & CFG_FORCE_REDRAW)); | ||
608 | 602 | } | ||
609 | 603 | |||
610 | 604 | if (flags & CFG_FORCE_REDRAW) | ||
611 | 605 | { | ||
612 | 606 | change_mask_client |= (CWX | CWY); | ||
613 | 607 | } | ||
614 | 608 | |||
615 | 609 | if (change_mask_frame & (CWX | CWY | CWWidth | CWHeight)) | ||
616 | 610 | { | ||
617 | 611 | change_values.x = frameX (c); | ||
618 | 612 | change_values.y = frameY (c); | ||
619 | 613 | change_values.width = frameWidth (c); | ||
620 | 614 | change_values.height = frameHeight (c); | ||
621 | 615 | XConfigureWindow (display_info->dpy, c->frame, change_mask_frame, &change_values); | ||
622 | 616 | } | ||
623 | 617 | |||
624 | 618 | if (change_mask_client & (CWX | CWY | CWWidth | CWHeight)) | ||
625 | 619 | { | ||
626 | 620 | change_values.x = frameLeft (c); | ||
627 | 621 | change_values.y = frameTop (c); | ||
628 | 622 | change_values.width = c->width; | ||
629 | 623 | change_values.height = c->height; | ||
630 | 624 | XConfigureWindow (display_info->dpy, c->window, change_mask_client, &change_values); | ||
631 | 625 | } | ||
632 | 626 | if (WIN_RESIZED) | ||
633 | 627 | { | ||
634 | 628 | compositorResizeWindow (display_info, c->frame, frameX (c), frameY (c), frameWidth (c), frameHeight (c)); | ||
635 | 629 | } | ||
636 | 630 | } | ||
637 | 631 | |||
638 | 632 | void | ||
639 | 633 | clientConfigure (Client *c, XWindowChanges * wc, unsigned long mask, unsigned short flags) | ||
640 | 634 | { | ||
641 | 635 | XConfigureEvent ce; | ||
642 | 636 | int px, py, pwidth, pheight; | ||
643 | 637 | |||
644 | 638 | g_return_if_fail (c != NULL); | ||
645 | 639 | g_return_if_fail (c->window != None); | ||
646 | 640 | |||
647 | 641 | TRACE ("entering clientConfigure"); | ||
648 | 642 | TRACE ("configuring client \"%s\" (0x%lx) %s, type %u", c->name, | ||
649 | 643 | c->window, flags & CFG_CONSTRAINED ? "constrained" : "not contrained", c->type); | ||
650 | 644 | |||
651 | 645 | px = c->x; | ||
652 | 646 | py = c->y; | ||
653 | 647 | pwidth = c->width; | ||
654 | 648 | pheight = c->height; | ||
655 | 649 | |||
656 | 650 | if (mask & CWX) | ||
657 | 651 | { | ||
658 | 652 | if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING)) | ||
659 | 653 | { | ||
660 | 654 | c->x = wc->x; | ||
661 | 655 | } | ||
662 | 656 | } | ||
663 | 657 | if (mask & CWY) | ||
664 | 658 | { | ||
665 | 659 | if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING)) | ||
666 | 660 | { | ||
667 | 661 | c->y = wc->y; | ||
668 | 662 | } | ||
669 | 663 | } | ||
670 | 664 | if (mask & CWWidth) | ||
671 | 665 | { | ||
672 | 666 | clientSetWidth (c, wc->width, flags & CFG_REQUEST); | ||
673 | 667 | } | ||
674 | 668 | if (mask & CWHeight) | ||
675 | 669 | { | ||
676 | 670 | clientSetHeight (c, wc->height, flags & CFG_REQUEST); | ||
677 | 671 | } | ||
678 | 672 | if (mask & CWBorderWidth) | ||
679 | 673 | { | ||
680 | 674 | c->border_width = wc->border_width; | ||
681 | 675 | } | ||
682 | 676 | if (mask & CWStackMode) | ||
683 | 677 | { | ||
684 | 678 | switch (wc->stack_mode) | ||
685 | 679 | { | ||
686 | 680 | /* | ||
687 | 681 | * Limitation: we don't support neither | ||
688 | 682 | * TopIf, BottomIf nor Opposite ... | ||
689 | 683 | */ | ||
690 | 684 | case Above: | ||
691 | 685 | TRACE ("Above"); | ||
692 | 686 | if (mask & CWSibling) | ||
693 | 687 | { | ||
694 | 688 | clientRaise (c, wc->sibling); | ||
695 | 689 | } | ||
696 | 690 | else | ||
697 | 691 | { | ||
698 | 692 | clientRaise (c, None); | ||
699 | 693 | } | ||
700 | 694 | break; | ||
701 | 695 | case Below: | ||
702 | 696 | TRACE ("Below"); | ||
703 | 697 | if (mask & CWSibling) | ||
704 | 698 | { | ||
705 | 699 | clientLower (c, wc->sibling); | ||
706 | 700 | } | ||
707 | 701 | else | ||
708 | 702 | { | ||
709 | 703 | clientLower (c, None); | ||
710 | 704 | } | ||
711 | 705 | |||
712 | 706 | break; | ||
713 | 707 | case Opposite: | ||
714 | 708 | case TopIf: | ||
715 | 709 | case BottomIf: | ||
716 | 710 | default: | ||
717 | 711 | break; | ||
718 | 712 | } | ||
719 | 713 | } | ||
720 | 714 | mask &= ~(CWStackMode | CWSibling); | ||
721 | 715 | |||
722 | 716 | /* Keep control over what the application does. */ | ||
723 | 717 | if (((flags & (CFG_CONSTRAINED | CFG_REQUEST)) == (CFG_CONSTRAINED | CFG_REQUEST)) | ||
724 | 718 | && CONSTRAINED_WINDOW (c)) | ||
725 | 719 | { | ||
726 | 720 | clientConstrainPos (c, flags & CFG_KEEP_VISIBLE); | ||
727 | 721 | |||
728 | 722 | if (c->x != px) | ||
729 | 723 | { | ||
730 | 724 | mask |= CWX; | ||
731 | 725 | } | ||
732 | 726 | else | ||
733 | 727 | { | ||
734 | 728 | mask &= ~CWX; | ||
735 | 729 | } | ||
736 | 730 | |||
737 | 731 | if (c->y != py) | ||
738 | 732 | { | ||
739 | 733 | mask |= CWY; | ||
740 | 734 | } | ||
741 | 735 | else | ||
742 | 736 | { | ||
743 | 737 | mask &= ~CWY; | ||
744 | 738 | } | ||
745 | 739 | |||
746 | 740 | if (c->width != pwidth) | ||
747 | 741 | { | ||
748 | 742 | mask |= CWWidth; | ||
749 | 743 | } | ||
750 | 744 | else | ||
751 | 745 | { | ||
752 | 746 | mask &= ~CWWidth; | ||
753 | 747 | } | ||
754 | 748 | if (c->height != pheight) | ||
755 | 749 | { | ||
756 | 750 | mask |= CWHeight; | ||
757 | 751 | } | ||
758 | 752 | else | ||
759 | 753 | { | ||
760 | 754 | mask &= ~CWHeight; | ||
761 | 755 | } | ||
762 | 756 | } | ||
763 | 757 | |||
764 | 758 | clientConfigureWindows (c, wc, mask, flags); | ||
765 | 759 | /* | ||
766 | 760 | |||
767 | 761 | We reparent the client window. According to the ICCCM spec, the | ||
768 | 762 | WM must send a senthetic event when the window is moved and not resized. | ||
769 | 763 | |||
770 | 764 | But, since we reparent the window, we must also send a synthetic | ||
771 | 765 | configure event when the window is moved and resized. | ||
772 | 766 | |||
773 | 767 | See this thread for the rational: | ||
774 | 768 | http://www.mail-archive.com/wm-spec-list@gnome.org/msg00379.html | ||
775 | 769 | |||
776 | 770 | And specifically this post from Carsten Haitzler: | ||
777 | 771 | http://www.mail-archive.com/wm-spec-list@gnome.org/msg00382.html | ||
778 | 772 | |||
779 | 773 | */ | ||
780 | 774 | if ((WIN_MOVED) || (flags & CFG_NOTIFY) || | ||
781 | 775 | ((flags & CFG_REQUEST) && !(WIN_MOVED || WIN_RESIZED))) | ||
782 | 776 | { | ||
783 | 777 | DBG ("Sending ConfigureNotify"); | ||
784 | 778 | ce.type = ConfigureNotify; | ||
785 | 779 | ce.display = clientGetXDisplay (c); | ||
786 | 780 | ce.event = c->window; | ||
787 | 781 | ce.window = c->window; | ||
788 | 782 | ce.x = c->x; | ||
789 | 783 | ce.y = c->y; | ||
790 | 784 | ce.width = c->width; | ||
791 | 785 | ce.height = c->height; | ||
792 | 786 | ce.border_width = 0; | ||
793 | 787 | ce.above = c->frame; | ||
794 | 788 | ce.override_redirect = FALSE; | ||
795 | 789 | XSendEvent (clientGetXDisplay (c), c->window, FALSE, | ||
796 | 790 | StructureNotifyMask, (XEvent *) & ce); | ||
797 | 791 | } | ||
798 | 792 | #undef WIN_MOVED | ||
799 | 793 | #undef WIN_RESIZED | ||
800 | 794 | } | ||
801 | 795 | |||
802 | 796 | void | ||
803 | 797 | clientMoveResizeWindow (Client *c, XWindowChanges * wc, unsigned long mask) | ||
804 | 798 | { | ||
805 | 799 | ScreenInfo *screen_info; | ||
806 | 800 | DisplayInfo *display_info; | ||
807 | 801 | unsigned short flags; | ||
808 | 802 | |||
809 | 803 | g_return_if_fail (c != NULL); | ||
810 | 804 | TRACE ("entering clientMoveResizeWindow"); | ||
811 | 805 | TRACE ("client \"%s\" (0x%lx)", c->name, c->window); | ||
812 | 806 | |||
813 | 807 | screen_info = c->screen_info; | ||
814 | 808 | display_info = screen_info->display_info; | ||
815 | 809 | if (c->type == WINDOW_DESKTOP) | ||
816 | 810 | { | ||
817 | 811 | /* Ignore stacking request for DESKTOP windows */ | ||
818 | 812 | mask &= ~(CWSibling | CWStackMode); | ||
819 | 813 | } | ||
820 | 814 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN) | ||
821 | 815 | || (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) | ||
822 | 816 | && (screen_info->params->borderless_maximize))) | ||
823 | 817 | { | ||
824 | 818 | /* Not allowed in fullscreen or maximzed mode */ | ||
825 | 819 | mask &= ~(CWX | CWY | CWWidth | CWHeight); | ||
826 | 820 | } | ||
827 | 821 | /*clean up buggy requests that set all flags */ | ||
828 | 822 | if ((mask & CWX) && (wc->x == c->x)) | ||
829 | 823 | { | ||
830 | 824 | mask &= ~CWX; | ||
831 | 825 | } | ||
832 | 826 | if ((mask & CWY) && (wc->y == c->y)) | ||
833 | 827 | { | ||
834 | 828 | mask &= ~CWY; | ||
835 | 829 | } | ||
836 | 830 | if ((mask & CWWidth) && (wc->width == c->width)) | ||
837 | 831 | { | ||
838 | 832 | mask &= ~CWWidth; | ||
839 | 833 | } | ||
840 | 834 | if ((mask & CWHeight) && (wc->height == c->height)) | ||
841 | 835 | { | ||
842 | 836 | mask &= ~CWHeight; | ||
843 | 837 | } | ||
844 | 838 | |||
845 | 839 | /* Still a move/resize after cleanup? */ | ||
846 | 840 | flags = CFG_REQUEST; | ||
847 | 841 | if (mask & (CWX | CWY | CWWidth | CWHeight)) | ||
848 | 842 | { | ||
849 | 843 | /* Clear any previously saved pos flag from screen resize */ | ||
850 | 844 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_SAVED_POS); | ||
851 | 845 | |||
852 | 846 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
853 | 847 | { | ||
854 | 848 | clientRemoveMaximizeFlag (c); | ||
855 | 849 | } | ||
856 | 850 | |||
857 | 851 | flags |= CFG_REQUEST | CFG_CONSTRAINED; | ||
858 | 852 | } | ||
859 | 853 | if ((mask & (CWWidth | CWHeight)) && !(mask & (CWX | CWY))) | ||
860 | 854 | { | ||
861 | 855 | /* | ||
862 | 856 | * The client is resizing its window, but did not specify a | ||
863 | 857 | * position, make sure the window remains fully visible in that | ||
864 | 858 | *case so that the user does not have to relocate the window | ||
865 | 859 | */ | ||
866 | 860 | flags |= CFG_KEEP_VISIBLE; | ||
867 | 861 | } | ||
868 | 862 | /* | ||
869 | 863 | * Let's say that if the client performs a XRaiseWindow, we show the window if focus | ||
870 | 864 | * stealing prevention is not activated, otherwise we just set the "demands attention" | ||
871 | 865 | * flag... | ||
872 | 866 | */ | ||
873 | 867 | if ((mask & CWStackMode) && (wc->stack_mode == Above) && (wc->sibling == None) && !(c->type & WINDOW_TYPE_DONT_FOCUS)) | ||
874 | 868 | { | ||
875 | 869 | Client *last_raised; | ||
876 | 870 | |||
877 | 871 | last_raised = clientGetLastRaise (screen_info); | ||
878 | 872 | if (last_raised && (c != last_raised)) | ||
879 | 873 | { | ||
880 | 874 | if ((screen_info->params->prevent_focus_stealing) && (screen_info->params->activate_action == ACTIVATE_ACTION_NONE)) | ||
881 | 875 | { | ||
882 | 876 | mask &= ~(CWSibling | CWStackMode); | ||
883 | 877 | TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window); | ||
884 | 878 | FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION); | ||
885 | 879 | clientSetNetState (c); | ||
886 | 880 | } | ||
887 | 881 | else | ||
888 | 882 | { | ||
889 | 883 | clientActivate (c, getXServerTime (display_info), FALSE); | ||
890 | 884 | } | ||
891 | 885 | } | ||
892 | 886 | } | ||
893 | 887 | /* And finally, configure the window */ | ||
894 | 888 | clientConfigure (c, wc, mask, flags); | ||
895 | 889 | } | ||
896 | 890 | |||
897 | 891 | void | ||
898 | 892 | clientGetMWMHints (Client *c, gboolean update) | ||
899 | 893 | { | ||
900 | 894 | ScreenInfo *screen_info; | ||
901 | 895 | DisplayInfo *display_info; | ||
902 | 896 | PropMwmHints *mwm_hints; | ||
903 | 897 | XWindowChanges wc; | ||
904 | 898 | |||
905 | 899 | g_return_if_fail (c != NULL); | ||
906 | 900 | g_return_if_fail (c->window != None); | ||
907 | 901 | |||
908 | 902 | TRACE ("entering clientGetMWMHints client \"%s\" (0x%lx)", c->name, | ||
909 | 903 | c->window); | ||
910 | 904 | |||
911 | 905 | screen_info = c->screen_info; | ||
912 | 906 | display_info = screen_info->display_info; | ||
913 | 907 | |||
914 | 908 | mwm_hints = getMotifHints (display_info, c->window); | ||
915 | 909 | if (mwm_hints) | ||
916 | 910 | { | ||
917 | 911 | if ((mwm_hints->flags & MWM_HINTS_DECORATIONS)) | ||
918 | 912 | { | ||
919 | 913 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_HAS_SHAPE)) | ||
920 | 914 | { | ||
921 | 915 | if (mwm_hints->decorations & MWM_DECOR_ALL) | ||
922 | 916 | { | ||
923 | 917 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_HAS_BORDER | XFWM_FLAG_HAS_MENU); | ||
924 | 918 | } | ||
925 | 919 | else | ||
926 | 920 | { | ||
927 | 921 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_HAS_BORDER | XFWM_FLAG_HAS_MENU); | ||
928 | 922 | FLAG_SET (c->xfwm_flags, (mwm_hints-> decorations & (MWM_DECOR_TITLE | MWM_DECOR_BORDER)) | ||
929 | 923 | ? XFWM_FLAG_HAS_BORDER : 0); | ||
930 | 924 | FLAG_SET (c->xfwm_flags, (mwm_hints->decorations & (MWM_DECOR_MENU)) | ||
931 | 925 | ? XFWM_FLAG_HAS_MENU : 0); | ||
932 | 926 | /* | ||
933 | 927 | FLAG_UNSET(c->xfwm_flags, XFWM_FLAG_HAS_HIDE); | ||
934 | 928 | FLAG_UNSET(c->xfwm_flags, XFWM_FLAG_HAS_MAXIMIZE); | ||
935 | 929 | FLAG_SET(c->xfwm_flags, (mwm_hints->decorations & (MWM_DECOR_MINIMIZE)) ? XFWM_FLAG_HAS_HIDE : 0); | ||
936 | 930 | FLAG_SET(c->xfwm_flags, (mwm_hints->decorations & (MWM_DECOR_MAXIMIZE)) ? XFWM_FLAG_HAS_MAXIMIZE : 0); | ||
937 | 931 | */ | ||
938 | 932 | } | ||
939 | 933 | } | ||
940 | 934 | } | ||
941 | 935 | /* The following is from Metacity : */ | ||
942 | 936 | if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) | ||
943 | 937 | { | ||
944 | 938 | if (!(mwm_hints->functions & MWM_FUNC_ALL)) | ||
945 | 939 | { | ||
946 | 940 | FLAG_UNSET (c->xfwm_flags, | ||
947 | 941 | XFWM_FLAG_HAS_CLOSE | XFWM_FLAG_HAS_HIDE | | ||
948 | 942 | XFWM_FLAG_HAS_MAXIMIZE | XFWM_FLAG_HAS_MOVE | | ||
949 | 943 | XFWM_FLAG_HAS_RESIZE); | ||
950 | 944 | } | ||
951 | 945 | else | ||
952 | 946 | { | ||
953 | 947 | FLAG_SET (c->xfwm_flags, | ||
954 | 948 | XFWM_FLAG_HAS_CLOSE | XFWM_FLAG_HAS_HIDE | | ||
955 | 949 | XFWM_FLAG_HAS_MAXIMIZE | XFWM_FLAG_HAS_MOVE | | ||
956 | 950 | XFWM_FLAG_HAS_RESIZE); | ||
957 | 951 | } | ||
958 | 952 | |||
959 | 953 | if (mwm_hints->functions & MWM_FUNC_CLOSE) | ||
960 | 954 | { | ||
961 | 955 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_HAS_CLOSE); | ||
962 | 956 | } | ||
963 | 957 | if (mwm_hints->functions & MWM_FUNC_MINIMIZE) | ||
964 | 958 | { | ||
965 | 959 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_HAS_HIDE); | ||
966 | 960 | } | ||
967 | 961 | if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) | ||
968 | 962 | { | ||
969 | 963 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_HAS_MAXIMIZE); | ||
970 | 964 | } | ||
971 | 965 | if (mwm_hints->functions & MWM_FUNC_RESIZE) | ||
972 | 966 | { | ||
973 | 967 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_HAS_RESIZE); | ||
974 | 968 | } | ||
975 | 969 | if (mwm_hints->functions & MWM_FUNC_MOVE) | ||
976 | 970 | { | ||
977 | 971 | FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_HAS_MOVE); | ||
978 | 972 | } | ||
979 | 973 | } | ||
980 | 974 | g_free (mwm_hints); | ||
981 | 975 | } | ||
982 | 976 | |||
983 | 977 | if (update) | ||
984 | 978 | { | ||
985 | 979 | wc.x = c->x; | ||
986 | 980 | wc.y = c->y; | ||
987 | 981 | wc.width = c->width; | ||
988 | 982 | wc.height = c->height; | ||
989 | 983 | |||
990 | 984 | /* If client is maximized, we need to update its coordonates and size as well */ | ||
991 | 985 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
992 | 986 | { | ||
993 | 987 | GdkRectangle rect; | ||
994 | 988 | myScreenFindMonitorAtPoint (screen_info, | ||
995 | 989 | frameX (c) + (frameWidth (c) / 2), | ||
996 | 990 | frameY (c) + (frameHeight (c) / 2), &rect); | ||
997 | 991 | clientNewMaxSize (c, &wc, &rect, TILE_NONE); | ||
998 | 992 | } | ||
999 | 993 | |||
1000 | 994 | clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, CFG_FORCE_REDRAW); | ||
1001 | 995 | |||
1002 | 996 | /* MWM hints can add or remove decorations, update NET_FRAME_EXTENTS accordingly */ | ||
1003 | 997 | setNetFrameExtents (display_info, | ||
1004 | 998 | c->window, | ||
1005 | 999 | frameTop (c), | ||
1006 | 1000 | frameLeft (c), | ||
1007 | 1001 | frameRight (c), | ||
1008 | 1002 | frameBottom (c)); | ||
1009 | 1003 | } | ||
1010 | 1004 | } | ||
1011 | 1005 | |||
1012 | 1006 | void | ||
1013 | 1007 | clientGetWMNormalHints (Client *c, gboolean update) | ||
1014 | 1008 | { | ||
1015 | 1009 | XWindowChanges wc; | ||
1016 | 1010 | unsigned long previous_value; | ||
1017 | 1011 | long dummy; | ||
1018 | 1012 | |||
1019 | 1013 | g_return_if_fail (c != NULL); | ||
1020 | 1014 | g_return_if_fail (c->window != None); | ||
1021 | 1015 | |||
1022 | 1016 | TRACE ("entering clientGetWMNormalHints client \"%s\" (0x%lx)", c->name, | ||
1023 | 1017 | c->window); | ||
1024 | 1018 | |||
1025 | 1019 | if (!c->size) | ||
1026 | 1020 | { | ||
1027 | 1021 | c->size = XAllocSizeHints (); | ||
1028 | 1022 | } | ||
1029 | 1023 | g_assert (c->size); | ||
1030 | 1024 | |||
1031 | 1025 | dummy = 0; | ||
1032 | 1026 | if (!XGetWMNormalHints (clientGetXDisplay (c), c->window, c->size, &dummy)) | ||
1033 | 1027 | { | ||
1034 | 1028 | c->size->flags = 0; | ||
1035 | 1029 | } | ||
1036 | 1030 | |||
1037 | 1031 | /* Set/update gravity */ | ||
1038 | 1032 | c->gravity = c->size->flags & PWinGravity ? c->size->win_gravity : NorthWestGravity; | ||
1039 | 1033 | |||
1040 | 1034 | previous_value = FLAG_TEST (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE); | ||
1041 | 1035 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE); | ||
1042 | 1036 | |||
1043 | 1037 | wc.x = c->x; | ||
1044 | 1038 | wc.y = c->y; | ||
1045 | 1039 | wc.width = c->width; | ||
1046 | 1040 | wc.height = c->height; | ||
1047 | 1041 | |||
1048 | 1042 | if (!(c->size->flags & PMaxSize)) | ||
1049 | 1043 | { | ||
1050 | 1044 | c->size->max_width = G_MAXINT; | ||
1051 | 1045 | c->size->max_height = G_MAXINT; | ||
1052 | 1046 | c->size->flags |= PMaxSize; | ||
1053 | 1047 | } | ||
1054 | 1048 | |||
1055 | 1049 | if (!(c->size->flags & PBaseSize)) | ||
1056 | 1050 | { | ||
1057 | 1051 | c->size->base_width = 0; | ||
1058 | 1052 | c->size->base_height = 0; | ||
1059 | 1053 | } | ||
1060 | 1054 | |||
1061 | 1055 | if (!(c->size->flags & PMinSize)) | ||
1062 | 1056 | { | ||
1063 | 1057 | if ((c->size->flags & PBaseSize)) | ||
1064 | 1058 | { | ||
1065 | 1059 | c->size->min_width = c->size->base_width; | ||
1066 | 1060 | c->size->min_height = c->size->base_height; | ||
1067 | 1061 | } | ||
1068 | 1062 | else | ||
1069 | 1063 | { | ||
1070 | 1064 | c->size->min_width = 1; | ||
1071 | 1065 | c->size->min_height = 1; | ||
1072 | 1066 | } | ||
1073 | 1067 | c->size->flags |= PMinSize; | ||
1074 | 1068 | } | ||
1075 | 1069 | |||
1076 | 1070 | if (c->size->flags & PResizeInc) | ||
1077 | 1071 | { | ||
1078 | 1072 | if (c->size->width_inc < 1) | ||
1079 | 1073 | { | ||
1080 | 1074 | c->size->width_inc = 1; | ||
1081 | 1075 | } | ||
1082 | 1076 | if (c->size->height_inc < 1) | ||
1083 | 1077 | { | ||
1084 | 1078 | c->size->height_inc = 1; | ||
1085 | 1079 | } | ||
1086 | 1080 | } | ||
1087 | 1081 | else | ||
1088 | 1082 | { | ||
1089 | 1083 | c->size->width_inc = 1; | ||
1090 | 1084 | c->size->height_inc = 1; | ||
1091 | 1085 | } | ||
1092 | 1086 | |||
1093 | 1087 | if (c->size->flags & PAspect) | ||
1094 | 1088 | { | ||
1095 | 1089 | if (c->size->min_aspect.x < 1) | ||
1096 | 1090 | { | ||
1097 | 1091 | c->size->min_aspect.x = 1; | ||
1098 | 1092 | } | ||
1099 | 1093 | if (c->size->min_aspect.y < 1) | ||
1100 | 1094 | { | ||
1101 | 1095 | c->size->min_aspect.y = 1; | ||
1102 | 1096 | } | ||
1103 | 1097 | if (c->size->max_aspect.x < 1) | ||
1104 | 1098 | { | ||
1105 | 1099 | c->size->max_aspect.x = 1; | ||
1106 | 1100 | } | ||
1107 | 1101 | if (c->size->max_aspect.y < 1) | ||
1108 | 1102 | { | ||
1109 | 1103 | c->size->max_aspect.y = 1; | ||
1110 | 1104 | } | ||
1111 | 1105 | } | ||
1112 | 1106 | else | ||
1113 | 1107 | { | ||
1114 | 1108 | c->size->min_aspect.x = 1; | ||
1115 | 1109 | c->size->min_aspect.y = 1; | ||
1116 | 1110 | c->size->max_aspect.x = G_MAXINT; | ||
1117 | 1111 | c->size->max_aspect.y = G_MAXINT; | ||
1118 | 1112 | } | ||
1119 | 1113 | |||
1120 | 1114 | if (c->size->min_width < 1) | ||
1121 | 1115 | { | ||
1122 | 1116 | c->size->min_width = 1; | ||
1123 | 1117 | } | ||
1124 | 1118 | if (c->size->min_height < 1) | ||
1125 | 1119 | { | ||
1126 | 1120 | c->size->min_height = 1; | ||
1127 | 1121 | } | ||
1128 | 1122 | if (c->size->max_width < 1) | ||
1129 | 1123 | { | ||
1130 | 1124 | c->size->max_width = 1; | ||
1131 | 1125 | } | ||
1132 | 1126 | if (c->size->max_height < 1) | ||
1133 | 1127 | { | ||
1134 | 1128 | c->size->max_height = 1; | ||
1135 | 1129 | } | ||
1136 | 1130 | if (wc.width > c->size->max_width) | ||
1137 | 1131 | { | ||
1138 | 1132 | wc.width = c->size->max_width; | ||
1139 | 1133 | } | ||
1140 | 1134 | if (wc.height > c->size->max_height) | ||
1141 | 1135 | { | ||
1142 | 1136 | wc.height = c->size->max_height; | ||
1143 | 1137 | } | ||
1144 | 1138 | if (wc.width < c->size->min_width) | ||
1145 | 1139 | { | ||
1146 | 1140 | wc.width = c->size->min_width; | ||
1147 | 1141 | } | ||
1148 | 1142 | if (wc.height < c->size->min_height) | ||
1149 | 1143 | { | ||
1150 | 1144 | wc.height = c->size->min_height; | ||
1151 | 1145 | } | ||
1152 | 1146 | |||
1153 | 1147 | if ((c->size->min_width < c->size->max_width) || | ||
1154 | 1148 | (c->size->min_height < c->size->max_height)) | ||
1155 | 1149 | { | ||
1156 | 1150 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE); | ||
1157 | 1151 | } | ||
1158 | 1152 | |||
1159 | 1153 | if (update) | ||
1160 | 1154 | { | ||
1161 | 1155 | if ((c->width != wc.width) || (c->height != wc.height)) | ||
1162 | 1156 | { | ||
1163 | 1157 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
1164 | 1158 | { | ||
1165 | 1159 | clientRemoveMaximizeFlag (c); | ||
1166 | 1160 | } | ||
1167 | 1161 | clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, CFG_CONSTRAINED | CFG_FORCE_REDRAW); | ||
1168 | 1162 | } | ||
1169 | 1163 | else if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE) != previous_value) | ||
1170 | 1164 | { | ||
1171 | 1165 | frameQueueDraw (c, FALSE); | ||
1172 | 1166 | } | ||
1173 | 1167 | } | ||
1174 | 1168 | else | ||
1175 | 1169 | { | ||
1176 | 1170 | c->width = wc.width; | ||
1177 | 1171 | c->height = wc.height; | ||
1178 | 1172 | } | ||
1179 | 1173 | } | ||
1180 | 1174 | |||
1181 | 1175 | void | ||
1182 | 1176 | clientGetWMProtocols (Client *c) | ||
1183 | 1177 | { | ||
1184 | 1178 | ScreenInfo *screen_info; | ||
1185 | 1179 | DisplayInfo *display_info; | ||
1186 | 1180 | unsigned int wm_protocols_flags; | ||
1187 | 1181 | |||
1188 | 1182 | g_return_if_fail (c != NULL); | ||
1189 | 1183 | g_return_if_fail (c->window != None); | ||
1190 | 1184 | |||
1191 | 1185 | TRACE ("entering clientGetWMProtocols client \"%s\" (0x%lx)", c->name, | ||
1192 | 1186 | c->window); | ||
1193 | 1187 | |||
1194 | 1188 | screen_info = c->screen_info; | ||
1195 | 1189 | display_info = screen_info->display_info; | ||
1196 | 1190 | |||
1197 | 1191 | wm_protocols_flags = getWMProtocols (display_info, c->window); | ||
1198 | 1192 | FLAG_SET (c->wm_flags, | ||
1199 | 1193 | (wm_protocols_flags & WM_PROTOCOLS_DELETE_WINDOW) ? | ||
1200 | 1194 | WM_FLAG_DELETE : 0); | ||
1201 | 1195 | FLAG_SET (c->wm_flags, | ||
1202 | 1196 | (wm_protocols_flags & WM_PROTOCOLS_TAKE_FOCUS) ? | ||
1203 | 1197 | WM_FLAG_TAKEFOCUS : 0); | ||
1204 | 1198 | /* KDE extension */ | ||
1205 | 1199 | FLAG_SET (c->wm_flags, | ||
1206 | 1200 | (wm_protocols_flags & WM_PROTOCOLS_CONTEXT_HELP) ? | ||
1207 | 1201 | WM_FLAG_CONTEXT_HELP : 0); | ||
1208 | 1202 | /* Ping */ | ||
1209 | 1203 | FLAG_SET (c->wm_flags, | ||
1210 | 1204 | (wm_protocols_flags & WM_PROTOCOLS_PING) ? | ||
1211 | 1205 | WM_FLAG_PING : 0); | ||
1212 | 1206 | } | ||
1213 | 1207 | |||
1214 | 1208 | static void | ||
1215 | 1209 | clientFree (Client *c) | ||
1216 | 1210 | { | ||
1217 | 1211 | g_return_if_fail (c != NULL); | ||
1218 | 1212 | |||
1219 | 1213 | TRACE ("entering clientFree"); | ||
1220 | 1214 | TRACE ("freeing client \"%s\" (0x%lx)", c->name, c->window); | ||
1221 | 1215 | |||
1222 | 1216 | clientClearFocus (c); | ||
1223 | 1217 | if (clientGetLastRaise (c->screen_info) == c) | ||
1224 | 1218 | { | ||
1225 | 1219 | clientClearLastRaise (c->screen_info); | ||
1226 | 1220 | } | ||
1227 | 1221 | if (clientGetDelayedFocus () == c) | ||
1228 | 1222 | { | ||
1229 | 1223 | clientClearDelayedFocus (); | ||
1230 | 1224 | } | ||
1231 | 1225 | if (c->blink_timeout_id) | ||
1232 | 1226 | { | ||
1233 | 1227 | g_source_remove (c->blink_timeout_id); | ||
1234 | 1228 | } | ||
1235 | 1229 | if (c->icon_timeout_id) | ||
1236 | 1230 | { | ||
1237 | 1231 | g_source_remove (c->icon_timeout_id); | ||
1238 | 1232 | } | ||
1239 | 1233 | if (c->frame_timeout_id) | ||
1240 | 1234 | { | ||
1241 | 1235 | g_source_remove (c->frame_timeout_id); | ||
1242 | 1236 | } | ||
1243 | 1237 | if (c->ping_timeout_id) | ||
1244 | 1238 | { | ||
1245 | 1239 | clientRemoveNetWMPing (c); | ||
1246 | 1240 | } | ||
1247 | 1241 | if (c->name) | ||
1248 | 1242 | { | ||
1249 | 1243 | g_free (c->name); | ||
1250 | 1244 | } | ||
1251 | 1245 | if (c->hostname) | ||
1252 | 1246 | { | ||
1253 | 1247 | g_free (c->hostname); | ||
1254 | 1248 | } | ||
1255 | 1249 | #ifdef HAVE_XSYNC | ||
1256 | 1250 | if (c->xsync_alarm != None) | ||
1257 | 1251 | { | ||
1258 | 1252 | clientDestroyXSyncAlarm (c); | ||
1259 | 1253 | } | ||
1260 | 1254 | if (c->xsync_timeout_id) | ||
1261 | 1255 | { | ||
1262 | 1256 | g_source_remove (c->xsync_timeout_id); | ||
1263 | 1257 | } | ||
1264 | 1258 | #endif /* HAVE_XSYNC */ | ||
1265 | 1259 | #ifdef HAVE_LIBSTARTUP_NOTIFICATION | ||
1266 | 1260 | if (c->startup_id) | ||
1267 | 1261 | { | ||
1268 | 1262 | g_free (c->startup_id); | ||
1269 | 1263 | } | ||
1270 | 1264 | #endif /* HAVE_LIBSTARTUP_NOTIFICATION */ | ||
1271 | 1265 | if (c->size) | ||
1272 | 1266 | { | ||
1273 | 1267 | XFree (c->size); | ||
1274 | 1268 | } | ||
1275 | 1269 | if (c->wmhints) | ||
1276 | 1270 | { | ||
1277 | 1271 | XFree (c->wmhints); | ||
1278 | 1272 | } | ||
1279 | 1273 | if ((c->ncmap > 0) && (c->cmap_windows)) | ||
1280 | 1274 | { | ||
1281 | 1275 | XFree (c->cmap_windows); | ||
1282 | 1276 | } | ||
1283 | 1277 | if (c->class.res_name) | ||
1284 | 1278 | { | ||
1285 | 1279 | XFree (c->class.res_name); | ||
1286 | 1280 | } | ||
1287 | 1281 | if (c->class.res_class) | ||
1288 | 1282 | { | ||
1289 | 1283 | XFree (c->class.res_class); | ||
1290 | 1284 | } | ||
1291 | 1285 | if (c->dialog_pid) | ||
1292 | 1286 | { | ||
1293 | 1287 | kill (c->dialog_pid, SIGKILL); | ||
1294 | 1288 | } | ||
1295 | 1289 | if (c->dialog_fd >= 0) | ||
1296 | 1290 | { | ||
1297 | 1291 | close (c->dialog_fd); | ||
1298 | 1292 | } | ||
1299 | 1293 | |||
1300 | 1294 | g_free (c); | ||
1301 | 1295 | } | ||
1302 | 1296 | |||
1303 | 1297 | static void | ||
1304 | 1298 | clientApplyInitialState (Client *c) | ||
1305 | 1299 | { | ||
1306 | 1300 | g_return_if_fail (c != NULL); | ||
1307 | 1301 | |||
1308 | 1302 | TRACE ("entering clientApplyInitialState"); | ||
1309 | 1303 | |||
1310 | 1304 | /* We check that afterwards to make sure all states are now known */ | ||
1311 | 1305 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
1312 | 1306 | { | ||
1313 | 1307 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MAXIMIZE)) | ||
1314 | 1308 | { | ||
1315 | 1309 | unsigned long mode = 0L; | ||
1316 | 1310 | |||
1317 | 1311 | TRACE ("Applying client's initial state: maximized"); | ||
1318 | 1312 | mode = c->flags & CLIENT_FLAG_MAXIMIZED; | ||
1319 | 1313 | |||
1320 | 1314 | /* Unset fullscreen mode so that clientToggleMaximized() really change the state */ | ||
1321 | 1315 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED); | ||
1322 | 1316 | clientToggleMaximized (c, mode, FALSE); | ||
1323 | 1317 | } | ||
1324 | 1318 | } | ||
1325 | 1319 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
1326 | 1320 | { | ||
1327 | 1321 | TRACE ("Applying client's initial state: fullscreen"); | ||
1328 | 1322 | clientUpdateFullscreenState (c); | ||
1329 | 1323 | } | ||
1330 | 1324 | if (FLAG_TEST_AND_NOT (c->flags, CLIENT_FLAG_ABOVE, CLIENT_FLAG_BELOW)) | ||
1331 | 1325 | { | ||
1332 | 1326 | TRACE ("Applying client's initial state: above"); | ||
1333 | 1327 | clientUpdateLayerState (c); | ||
1334 | 1328 | } | ||
1335 | 1329 | if (FLAG_TEST_AND_NOT (c->flags, CLIENT_FLAG_BELOW, CLIENT_FLAG_ABOVE)) | ||
1336 | 1330 | { | ||
1337 | 1331 | TRACE ("Applying client's initial state: below"); | ||
1338 | 1332 | clientUpdateLayerState (c); | ||
1339 | 1333 | } | ||
1340 | 1334 | if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY) && | ||
1341 | 1335 | FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_STICK)) | ||
1342 | 1336 | { | ||
1343 | 1337 | TRACE ("Applying client's initial state: sticky"); | ||
1344 | 1338 | clientStick (c, TRUE); | ||
1345 | 1339 | } | ||
1346 | 1340 | if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
1347 | 1341 | { | ||
1348 | 1342 | TRACE ("Applying client's initial state: shaded"); | ||
1349 | 1343 | clientShade (c); | ||
1350 | 1344 | } | ||
1351 | 1345 | } | ||
1352 | 1346 | |||
1353 | 1347 | static gboolean | ||
1354 | 1348 | clientCheckShape (Client *c) | ||
1355 | 1349 | { | ||
1356 | 1350 | ScreenInfo *screen_info; | ||
1357 | 1351 | DisplayInfo *display_info; | ||
1358 | 1352 | int xws, yws, xbs, ybs; | ||
1359 | 1353 | unsigned wws, hws, wbs, hbs; | ||
1360 | 1354 | int boundingShaped, clipShaped; | ||
1361 | 1355 | |||
1362 | 1356 | g_return_val_if_fail (c != NULL, FALSE); | ||
1363 | 1357 | |||
1364 | 1358 | screen_info = c->screen_info; | ||
1365 | 1359 | display_info = screen_info->display_info; | ||
1366 | 1360 | |||
1367 | 1361 | if (display_info->have_shape) | ||
1368 | 1362 | { | ||
1369 | 1363 | XShapeQueryExtents (display_info->dpy, c->window, &boundingShaped, &xws, &yws, &wws, | ||
1370 | 1364 | &hws, &clipShaped, &xbs, &ybs, &wbs, &hbs); | ||
1371 | 1365 | return (boundingShaped != 0); | ||
1372 | 1366 | } | ||
1373 | 1367 | return FALSE; | ||
1374 | 1368 | } | ||
1375 | 1369 | |||
1376 | 1370 | static void | ||
1377 | 1371 | clientUpdateIconPix (Client *c) | ||
1378 | 1372 | { | ||
1379 | 1373 | ScreenInfo *screen_info; | ||
1380 | 1374 | DisplayInfo *display_info; | ||
1381 | 1375 | gint size; | ||
1382 | 1376 | GdkPixbuf *icon; | ||
1383 | 1377 | int i; | ||
1384 | 1378 | |||
1385 | 1379 | g_return_if_fail (c != NULL); | ||
1386 | 1380 | g_return_if_fail (c->window != None); | ||
1387 | 1381 | |||
1388 | 1382 | TRACE ("entering clientUpdateIconPix for \"%s\" (0x%lx)", c->name, c->window); | ||
1389 | 1383 | |||
1390 | 1384 | screen_info = c->screen_info; | ||
1391 | 1385 | display_info = screen_info->display_info; | ||
1392 | 1386 | |||
1393 | 1387 | for (i = 0; i < STATE_TOGGLED; i++) | ||
1394 | 1388 | { | ||
1395 | 1389 | xfwmPixmapFree (&c->appmenu[i]); | ||
1396 | 1390 | } | ||
1397 | 1391 | |||
1398 | 1392 | if (xfwmPixmapNone(&screen_info->buttons[MENU_BUTTON][ACTIVE])) | ||
1399 | 1393 | { | ||
1400 | 1394 | /* The current theme has no menu button */ | ||
1401 | 1395 | return; | ||
1402 | 1396 | } | ||
1403 | 1397 | |||
1404 | 1398 | for (i = 0; i < STATE_TOGGLED; i++) | ||
1405 | 1399 | { | ||
1406 | 1400 | if (!xfwmPixmapNone(&screen_info->buttons[MENU_BUTTON][i])) | ||
1407 | 1401 | { | ||
1408 | 1402 | xfwmPixmapDuplicate (&screen_info->buttons[MENU_BUTTON][i], &c->appmenu[i]); | ||
1409 | 1403 | } | ||
1410 | 1404 | } | ||
1411 | 1405 | size = MIN (screen_info->buttons[MENU_BUTTON][ACTIVE].width, | ||
1412 | 1406 | screen_info->buttons[MENU_BUTTON][ACTIVE].height); | ||
1413 | 1407 | |||
1414 | 1408 | if (size > 1) | ||
1415 | 1409 | { | ||
1416 | 1410 | icon = getAppIcon (display_info, c->window, size, size); | ||
1417 | 1411 | |||
1418 | 1412 | for (i = 0; i < STATE_TOGGLED; i++) | ||
1419 | 1413 | { | ||
1420 | 1414 | if (!xfwmPixmapNone(&c->appmenu[i])) | ||
1421 | 1415 | { | ||
1422 | 1416 | xfwmPixmapRenderGdkPixbuf (&c->appmenu[i], icon); | ||
1423 | 1417 | } | ||
1424 | 1418 | } | ||
1425 | 1419 | g_object_unref (icon); | ||
1426 | 1420 | } | ||
1427 | 1421 | } | ||
1428 | 1422 | |||
1429 | 1423 | static gboolean | ||
1430 | 1424 | update_icon_idle_cb (gpointer data) | ||
1431 | 1425 | { | ||
1432 | 1426 | Client *c; | ||
1433 | 1427 | |||
1434 | 1428 | TRACE ("entering update_icon_idle_cb"); | ||
1435 | 1429 | |||
1436 | 1430 | c = (Client *) data; | ||
1437 | 1431 | g_return_val_if_fail (c, FALSE); | ||
1438 | 1432 | |||
1439 | 1433 | clientUpdateIconPix (c); | ||
1440 | 1434 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
1441 | 1435 | { | ||
1442 | 1436 | frameQueueDraw (c, FALSE); | ||
1443 | 1437 | } | ||
1444 | 1438 | c->icon_timeout_id = 0; | ||
1445 | 1439 | |||
1446 | 1440 | return (FALSE); | ||
1447 | 1441 | } | ||
1448 | 1442 | |||
1449 | 1443 | void | ||
1450 | 1444 | clientUpdateIcon (Client *c) | ||
1451 | 1445 | { | ||
1452 | 1446 | g_return_if_fail (c); | ||
1453 | 1447 | |||
1454 | 1448 | TRACE ("entering clientUpdateIcon for \"%s\" (0x%lx)", c->name, c->window); | ||
1455 | 1449 | |||
1456 | 1450 | if (c->icon_timeout_id == 0) | ||
1457 | 1451 | { | ||
1458 | 1452 | c->icon_timeout_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, | ||
1459 | 1453 | update_icon_idle_cb, c, NULL); | ||
1460 | 1454 | } | ||
1461 | 1455 | } | ||
1462 | 1456 | |||
1463 | 1457 | void | ||
1464 | 1458 | clientSaveSizePos (Client *c) | ||
1465 | 1459 | { | ||
1466 | 1460 | g_return_if_fail (c != NULL); | ||
1467 | 1461 | |||
1468 | 1462 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ)) | ||
1469 | 1463 | { | ||
1470 | 1464 | c->old_x = c->x; | ||
1471 | 1465 | c->old_width = c->width; | ||
1472 | 1466 | } | ||
1473 | 1467 | |||
1474 | 1468 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT)) | ||
1475 | 1469 | { | ||
1476 | 1470 | c->old_y = c->y; | ||
1477 | 1471 | c->old_height = c->height; | ||
1478 | 1472 | } | ||
1479 | 1473 | } | ||
1480 | 1474 | |||
1481 | 1475 | Client * | ||
1482 | 1476 | clientFrame (DisplayInfo *display_info, Window w, gboolean recapture) | ||
1483 | 1477 | { | ||
1484 | 1478 | ScreenInfo *screen_info; | ||
1485 | 1479 | XWindowAttributes attr; | ||
1486 | 1480 | XWindowChanges wc; | ||
1487 | 1481 | XSetWindowAttributes attributes; | ||
1488 | 1482 | Client *c = NULL; | ||
1489 | 1483 | gboolean shaped; | ||
1490 | 1484 | unsigned long valuemask; | ||
1491 | 1485 | long pid; | ||
1492 | 1486 | int i; | ||
1493 | 1487 | |||
1494 | 1488 | g_return_val_if_fail (w != None, NULL); | ||
1495 | 1489 | g_return_val_if_fail (display_info != NULL, NULL); | ||
1496 | 1490 | |||
1497 | 1491 | TRACE ("entering clientFrame"); | ||
1498 | 1492 | TRACE ("framing client (0x%lx)", w); | ||
1499 | 1493 | |||
1500 | 1494 | gdk_error_trap_push (); | ||
1501 | 1495 | myDisplayGrabServer (display_info); | ||
1502 | 1496 | |||
1503 | 1497 | if (!XGetWindowAttributes (display_info->dpy, w, &attr)) | ||
1504 | 1498 | { | ||
1505 | 1499 | g_warning ("Cannot get window attributes for window (0x%lx)", w); | ||
1506 | 1500 | myDisplayUngrabServer (display_info); | ||
1507 | 1501 | gdk_error_trap_pop (); | ||
1508 | 1502 | return NULL; | ||
1509 | 1503 | } | ||
1510 | 1504 | |||
1511 | 1505 | screen_info = myDisplayGetScreenFromRoot (display_info, attr.root); | ||
1512 | 1506 | if (!screen_info) | ||
1513 | 1507 | { | ||
1514 | 1508 | g_warning ("Cannot determine screen info from window (0x%lx)", w); | ||
1515 | 1509 | myDisplayUngrabServer (display_info); | ||
1516 | 1510 | gdk_error_trap_pop (); | ||
1517 | 1511 | return NULL; | ||
1518 | 1512 | } | ||
1519 | 1513 | |||
1520 | 1514 | if (w == screen_info->xfwm4_win) | ||
1521 | 1515 | { | ||
1522 | 1516 | TRACE ("Not managing our own event window"); | ||
1523 | 1517 | compositorAddWindow (display_info, w, NULL); | ||
1524 | 1518 | myDisplayUngrabServer (display_info); | ||
1525 | 1519 | gdk_error_trap_pop (); | ||
1526 | 1520 | return NULL; | ||
1527 | 1521 | } | ||
1528 | 1522 | |||
1529 | 1523 | #ifdef ENABLE_KDE_SYSTRAY_PROXY | ||
1530 | 1524 | if (checkKdeSystrayWindow (display_info, w)) | ||
1531 | 1525 | { | ||
1532 | 1526 | TRACE ("Detected KDE systray windows"); | ||
1533 | 1527 | if (screen_info->systray != None) | ||
1534 | 1528 | { | ||
1535 | 1529 | sendSystrayReqDock (display_info, w, screen_info->systray); | ||
1536 | 1530 | myDisplayUngrabServer (display_info); | ||
1537 | 1531 | gdk_error_trap_pop (); | ||
1538 | 1532 | return NULL; | ||
1539 | 1533 | } | ||
1540 | 1534 | TRACE ("No systray found for this screen"); | ||
1541 | 1535 | } | ||
1542 | 1536 | #endif /* ENABLE_KDE_SYSTRAY_PROXY */ | ||
1543 | 1537 | |||
1544 | 1538 | if (attr.override_redirect) | ||
1545 | 1539 | { | ||
1546 | 1540 | TRACE ("Override redirect window 0x%lx", w); | ||
1547 | 1541 | compositorAddWindow (display_info, w, NULL); | ||
1548 | 1542 | myDisplayUngrabServer (display_info); | ||
1549 | 1543 | gdk_error_trap_pop (); | ||
1550 | 1544 | return NULL; | ||
1551 | 1545 | } | ||
1552 | 1546 | |||
1553 | 1547 | c = g_new0 (Client, 1); | ||
1554 | 1548 | if (!c) | ||
1555 | 1549 | { | ||
1556 | 1550 | TRACE ("Cannot allocate memory for the window structure"); | ||
1557 | 1551 | myDisplayUngrabServer (display_info); | ||
1558 | 1552 | gdk_error_trap_pop (); | ||
1559 | 1553 | return NULL; | ||
1560 | 1554 | } | ||
1561 | 1555 | |||
1562 | 1556 | c->window = w; | ||
1563 | 1557 | c->screen_info = screen_info; | ||
1564 | 1558 | c->serial = screen_info->client_serial++; | ||
1565 | 1559 | |||
1566 | 1560 | /* Termination dialog */ | ||
1567 | 1561 | c->dialog_pid = 0; | ||
1568 | 1562 | c->dialog_fd = -1; | ||
1569 | 1563 | |||
1570 | 1564 | getWindowName (display_info, c->window, &c->name); | ||
1571 | 1565 | getWindowHostname (display_info, c->window, &c->hostname); | ||
1572 | 1566 | getTransientFor (display_info, screen_info->xroot, c->window, &c->transient_for); | ||
1573 | 1567 | XChangeSaveSet(display_info->dpy, c->window, SetModeInsert); | ||
1574 | 1568 | |||
1575 | 1569 | /* Initialize structure */ | ||
1576 | 1570 | c->size = NULL; | ||
1577 | 1571 | c->flags = 0L; | ||
1578 | 1572 | c->wm_flags = 0L; | ||
1579 | 1573 | c->xfwm_flags = XFWM_FLAG_INITIAL_VALUES; | ||
1580 | 1574 | c->x = attr.x; | ||
1581 | 1575 | c->y = attr.y; | ||
1582 | 1576 | c->width = attr.width; | ||
1583 | 1577 | c->height = attr.height; | ||
1584 | 1578 | |||
1585 | 1579 | #ifdef HAVE_LIBSTARTUP_NOTIFICATION | ||
1586 | 1580 | c->startup_id = NULL; | ||
1587 | 1581 | #endif /* HAVE_LIBSTARTUP_NOTIFICATION */ | ||
1588 | 1582 | |||
1589 | 1583 | #ifdef HAVE_XSYNC | ||
1590 | 1584 | c->xsync_waiting = FALSE; | ||
1591 | 1585 | c->xsync_enabled = FALSE; | ||
1592 | 1586 | c->xsync_counter = None; | ||
1593 | 1587 | c->xsync_alarm = None; | ||
1594 | 1588 | c->xsync_timeout_id = 0; | ||
1595 | 1589 | if (display_info->have_xsync) | ||
1596 | 1590 | { | ||
1597 | 1591 | getXSyncCounter (display_info, c->window, &c->xsync_counter); | ||
1598 | 1592 | if ((c->xsync_counter) && clientCreateXSyncAlarm (c)) | ||
1599 | 1593 | { | ||
1600 | 1594 | c->xsync_enabled = TRUE; | ||
1601 | 1595 | } | ||
1602 | 1596 | } | ||
1603 | 1597 | #endif /* HAVE_XSYNC */ | ||
1604 | 1598 | |||
1605 | 1599 | clientGetWMNormalHints (c, FALSE); | ||
1606 | 1600 | |||
1607 | 1601 | c->size->x = c->x; | ||
1608 | 1602 | c->size->y = c->y; | ||
1609 | 1603 | c->size->width = c->width; | ||
1610 | 1604 | c->size->height = c->height; | ||
1611 | 1605 | c->previous_width = -1; | ||
1612 | 1606 | c->previous_height = -1; | ||
1613 | 1607 | c->border_width = attr.border_width; | ||
1614 | 1608 | c->cmap = attr.colormap; | ||
1615 | 1609 | |||
1616 | 1610 | shaped = clientCheckShape(c); | ||
1617 | 1611 | if (shaped) | ||
1618 | 1612 | { | ||
1619 | 1613 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_HAS_BORDER); | ||
1620 | 1614 | FLAG_SET (c->flags, CLIENT_FLAG_HAS_SHAPE); | ||
1621 | 1615 | } | ||
1622 | 1616 | |||
1623 | 1617 | if (((c->size->flags & (PMinSize | PMaxSize)) != (PMinSize | PMaxSize)) | ||
1624 | 1618 | || (((c->size->flags & (PMinSize | PMaxSize)) == | ||
1625 | 1619 | (PMinSize | PMaxSize)) | ||
1626 | 1620 | && ((c->size->min_width < c->size->max_width) | ||
1627 | 1621 | || (c->size->min_height < c->size->max_height)))) | ||
1628 | 1622 | { | ||
1629 | 1623 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE); | ||
1630 | 1624 | } | ||
1631 | 1625 | |||
1632 | 1626 | for (i = 0; i < BUTTON_COUNT; i++) | ||
1633 | 1627 | { | ||
1634 | 1628 | c->button_status[i] = BUTTON_STATE_NORMAL; | ||
1635 | 1629 | } | ||
1636 | 1630 | |||
1637 | 1631 | if (!XGetWMColormapWindows (display_info->dpy, c->window, &c->cmap_windows, &c->ncmap)) | ||
1638 | 1632 | { | ||
1639 | 1633 | c->ncmap = 0; | ||
1640 | 1634 | } | ||
1641 | 1635 | |||
1642 | 1636 | c->fullscreen_monitors[0] = 0; | ||
1643 | 1637 | c->fullscreen_monitors[1] = 0; | ||
1644 | 1638 | c->fullscreen_monitors[2] = 0; | ||
1645 | 1639 | c->fullscreen_monitors[3] = 0; | ||
1646 | 1640 | |||
1647 | 1641 | /* Opacity for compositing manager */ | ||
1648 | 1642 | c->opacity = NET_WM_OPAQUE; | ||
1649 | 1643 | getOpacity (display_info, c->window, &c->opacity); | ||
1650 | 1644 | c->opacity_applied = c->opacity; | ||
1651 | 1645 | c->opacity_flags = 0; | ||
1652 | 1646 | |||
1653 | 1647 | /* Keep count of blinking iterations */ | ||
1654 | 1648 | c->blink_iterations = 0; | ||
1655 | 1649 | |||
1656 | 1650 | if (getOpacityLock (display_info, c->window)) | ||
1657 | 1651 | { | ||
1658 | 1652 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_OPACITY_LOCKED); | ||
1659 | 1653 | } | ||
1660 | 1654 | |||
1661 | 1655 | /* Timout for asynchronous icon update */ | ||
1662 | 1656 | c->icon_timeout_id = 0; | ||
1663 | 1657 | /* Timout for asynchronous frame update */ | ||
1664 | 1658 | c->frame_timeout_id = 0; | ||
1665 | 1659 | /* Timeout for blinking on urgency */ | ||
1666 | 1660 | c->blink_timeout_id = 0; | ||
1667 | 1661 | /* Ping timeout */ | ||
1668 | 1662 | c->ping_timeout_id = 0; | ||
1669 | 1663 | /* Ping timeout */ | ||
1670 | 1664 | c->ping_time = 0; | ||
1671 | 1665 | |||
1672 | 1666 | c->class.res_name = NULL; | ||
1673 | 1667 | c->class.res_class = NULL; | ||
1674 | 1668 | XGetClassHint (display_info->dpy, w, &c->class); | ||
1675 | 1669 | c->wmhints = XGetWMHints (display_info->dpy, c->window); | ||
1676 | 1670 | c->group_leader = None; | ||
1677 | 1671 | if (c->wmhints) | ||
1678 | 1672 | { | ||
1679 | 1673 | if (c->wmhints->flags & WindowGroupHint) | ||
1680 | 1674 | { | ||
1681 | 1675 | c->group_leader = c->wmhints->window_group; | ||
1682 | 1676 | } | ||
1683 | 1677 | } | ||
1684 | 1678 | c->client_leader = getClientLeader (display_info, c->window); | ||
1685 | 1679 | |||
1686 | 1680 | TRACE ("\"%s\" (0x%lx) initial map_state = %s", | ||
1687 | 1681 | c->name, c->window, | ||
1688 | 1682 | (attr.map_state == IsUnmapped) ? | ||
1689 | 1683 | "IsUnmapped" : | ||
1690 | 1684 | (attr.map_state == IsViewable) ? | ||
1691 | 1685 | "IsViewable" : | ||
1692 | 1686 | (attr.map_state == IsUnviewable) ? | ||
1693 | 1687 | "IsUnviewable" : | ||
1694 | 1688 | "(unknown)"); | ||
1695 | 1689 | if (attr.map_state != IsUnmapped) | ||
1696 | 1690 | { | ||
1697 | 1691 | /* Reparent will send us unmap/map events */ | ||
1698 | 1692 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_MAP_PENDING); | ||
1699 | 1693 | } | ||
1700 | 1694 | c->ignore_unmap = 0; | ||
1701 | 1695 | c->type = UNSET; | ||
1702 | 1696 | c->type_atom = None; | ||
1703 | 1697 | |||
1704 | 1698 | FLAG_SET (c->flags, START_ICONIC (c) ? CLIENT_FLAG_ICONIFIED : 0); | ||
1705 | 1699 | FLAG_SET (c->wm_flags, HINTS_ACCEPT_INPUT (c->wmhints) ? WM_FLAG_INPUT : 0); | ||
1706 | 1700 | |||
1707 | 1701 | clientGetWMProtocols (c); | ||
1708 | 1702 | clientGetMWMHints (c, FALSE); | ||
1709 | 1703 | c->win_layer = WIN_LAYER_NORMAL; | ||
1710 | 1704 | c->fullscreen_old_layer = c->win_layer; | ||
1711 | 1705 | |||
1712 | 1706 | /* net_wm_user_time standard */ | ||
1713 | 1707 | c->user_time = 0; | ||
1714 | 1708 | c->user_time_win = getNetWMUserTimeWindow(display_info, c->window); | ||
1715 | 1709 | clientAddUserTimeWin (c); | ||
1716 | 1710 | clientGetUserTime (c); | ||
1717 | 1711 | |||
1718 | 1712 | /*client PID */ | ||
1719 | 1713 | getHint (display_info, c->window, NET_WM_PID, (long *) &pid); | ||
1720 | 1714 | c->pid = (GPid) pid; | ||
1721 | 1715 | TRACE ("Client \"%s\" (0x%lx) PID = %i", c->name, c->window, c->pid); | ||
1722 | 1716 | |||
1723 | 1717 | /* Apply startup notification properties if available */ | ||
1724 | 1718 | sn_client_startup_properties (c); | ||
1725 | 1719 | |||
1726 | 1720 | /* Reload from session */ | ||
1727 | 1721 | if (sessionMatchWinToSM (c)) | ||
1728 | 1722 | { | ||
1729 | 1723 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_SESSION_MANAGED); | ||
1730 | 1724 | } | ||
1731 | 1725 | |||
1732 | 1726 | /* Beware, order of calls is important here ! */ | ||
1733 | 1727 | clientGetNetState (c); | ||
1734 | 1728 | clientGetNetWmType (c); | ||
1735 | 1729 | clientGetInitialNetWmDesktop (c); | ||
1736 | 1730 | /* workarea will be updated when shown, no need to worry here */ | ||
1737 | 1731 | clientGetNetStruts (c); | ||
1738 | 1732 | |||
1739 | 1733 | /* Once we know the type of window, we can initialize window position */ | ||
1740 | 1734 | if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SESSION_MANAGED)) | ||
1741 | 1735 | { | ||
1742 | 1736 | clientCoordGravitate (c, c->gravity, APPLY, &c->x, &c->y); | ||
1743 | 1737 | if ((attr.map_state == IsUnmapped)) | ||
1744 | 1738 | { | ||
1745 | 1739 | clientInitPosition (c); | ||
1746 | 1740 | } | ||
1747 | 1741 | } | ||
1748 | 1742 | |||
1749 | 1743 | /* | ||
1750 | 1744 | Initialize "old" fields once the position is ensured, to avoid | ||
1751 | 1745 | initially maximized or fullscreen windows being placed offscreen | ||
1752 | 1746 | once de-maximized | ||
1753 | 1747 | */ | ||
1754 | 1748 | c->old_x = c->x; | ||
1755 | 1749 | c->old_y = c->y; | ||
1756 | 1750 | c->old_width = c->width; | ||
1757 | 1751 | c->old_height = c->height; | ||
1758 | 1752 | |||
1759 | 1753 | c->fullscreen_old_x = c->x; | ||
1760 | 1754 | c->fullscreen_old_y = c->y; | ||
1761 | 1755 | c->fullscreen_old_width = c->width; | ||
1762 | 1756 | c->fullscreen_old_height = c->height; | ||
1763 | 1757 | |||
1764 | 1758 | /* | ||
1765 | 1759 | We must call clientApplyInitialState() after having placed the | ||
1766 | 1760 | window so that the inital position values are correctly set if the | ||
1767 | 1761 | inital state is maximize or fullscreen | ||
1768 | 1762 | */ | ||
1769 | 1763 | clientApplyInitialState (c); | ||
1770 | 1764 | |||
1771 | 1765 | valuemask = CWEventMask|CWBitGravity|CWWinGravity; | ||
1772 | 1766 | attributes.event_mask = (FRAME_EVENT_MASK | POINTER_EVENT_MASK); | ||
1773 | 1767 | attributes.win_gravity = StaticGravity; | ||
1774 | 1768 | attributes.bit_gravity = StaticGravity; | ||
1775 | 1769 | |||
1776 | 1770 | #ifdef HAVE_RENDER | ||
1777 | 1771 | if ((attr.depth == 32) && (display_info->have_render)) | ||
1778 | 1772 | { | ||
1779 | 1773 | c->visual = attr.visual; | ||
1780 | 1774 | c->depth = attr.depth; | ||
1781 | 1775 | |||
1782 | 1776 | attributes.colormap = attr.colormap; | ||
1783 | 1777 | attributes.background_pixmap = None; | ||
1784 | 1778 | attributes.border_pixel = 0; | ||
1785 | 1779 | attributes.background_pixel = 0; | ||
1786 | 1780 | |||
1787 | 1781 | valuemask |= CWColormap|CWBackPixmap|CWBackPixel|CWBorderPixel; | ||
1788 | 1782 | } | ||
1789 | 1783 | else | ||
1790 | 1784 | { | ||
1791 | 1785 | /* Default depth/visual */ | ||
1792 | 1786 | c->visual = screen_info->visual; | ||
1793 | 1787 | c->depth = screen_info->depth; | ||
1794 | 1788 | } | ||
1795 | 1789 | #else /* HAVE_RENDER */ | ||
1796 | 1790 | /* We don't support multiple depth/visual w/out render */ | ||
1797 | 1791 | c->visual = screen_info->visual; | ||
1798 | 1792 | c->depth = screen_info->depth; | ||
1799 | 1793 | #endif /* HAVE_RENDER */ | ||
1800 | 1794 | |||
1801 | 1795 | c->frame = | ||
1802 | 1796 | XCreateWindow (display_info->dpy, screen_info->xroot, 0, 0, 1, 1, 0, | ||
1803 | 1797 | c->depth, InputOutput, c->visual, valuemask, &attributes); | ||
1804 | 1798 | |||
1805 | 1799 | XSelectInput (display_info->dpy, c->window, NoEventMask); | ||
1806 | 1800 | XSetWindowBorderWidth (display_info->dpy, c->window, 0); | ||
1807 | 1801 | if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
1808 | 1802 | { | ||
1809 | 1803 | XUnmapWindow (display_info->dpy, c->window); | ||
1810 | 1804 | } | ||
1811 | 1805 | XReparentWindow (display_info->dpy, c->window, c->frame, frameLeft (c), frameTop (c)); | ||
1812 | 1806 | valuemask = CWEventMask; | ||
1813 | 1807 | attributes.event_mask = (CLIENT_EVENT_MASK); | ||
1814 | 1808 | XChangeWindowAttributes (display_info->dpy, c->window, valuemask, &attributes); | ||
1815 | 1809 | if (display_info->have_shape) | ||
1816 | 1810 | { | ||
1817 | 1811 | XShapeSelectInput (display_info->dpy, c->window, ShapeNotifyMask); | ||
1818 | 1812 | } | ||
1819 | 1813 | |||
1820 | 1814 | clientAddToList (c); | ||
1821 | 1815 | clientGrabButtons(c); | ||
1822 | 1816 | |||
1823 | 1817 | /* Initialize per client menu button pixmap */ | ||
1824 | 1818 | |||
1825 | 1819 | for (i = 0; i < STATE_TOGGLED; i++) | ||
1826 | 1820 | { | ||
1827 | 1821 | xfwmPixmapInit (screen_info, &c->appmenu[i]); | ||
1828 | 1822 | } | ||
1829 | 1823 | |||
1830 | 1824 | for (i = 0; i < SIDE_TOP; i++) /* Keep SIDE_TOP for later */ | ||
1831 | 1825 | { | ||
1832 | 1826 | xfwmWindowCreate (screen_info, c->visual, c->depth, c->frame, | ||
1833 | 1827 | &c->sides[i], NoEventMask, | ||
1834 | 1828 | myDisplayGetCursorResize(screen_info->display_info, CORNER_COUNT + i)); | ||
1835 | 1829 | } | ||
1836 | 1830 | |||
1837 | 1831 | for (i = 0; i < CORNER_COUNT; i++) | ||
1838 | 1832 | { | ||
1839 | 1833 | xfwmWindowCreate (screen_info, c->visual, c->depth, c->frame, | ||
1840 | 1834 | &c->corners[i], NoEventMask, | ||
1841 | 1835 | myDisplayGetCursorResize(screen_info->display_info, i)); | ||
1842 | 1836 | } | ||
1843 | 1837 | |||
1844 | 1838 | xfwmWindowCreate (screen_info, c->visual, c->depth, c->frame, | ||
1845 | 1839 | &c->title, NoEventMask, None); | ||
1846 | 1840 | |||
1847 | 1841 | /*create the top side window AFTER the title window since they overlap | ||
1848 | 1842 | and the top side window should be on top */ | ||
1849 | 1843 | |||
1850 | 1844 | xfwmWindowCreate (screen_info, c->visual, c->depth, c->frame, | ||
1851 | 1845 | &c->sides[SIDE_TOP], NoEventMask, | ||
1852 | 1846 | myDisplayGetCursorResize(screen_info->display_info, | ||
1853 | 1847 | CORNER_COUNT + SIDE_TOP)); | ||
1854 | 1848 | |||
1855 | 1849 | for (i = 0; i < BUTTON_COUNT; i++) | ||
1856 | 1850 | { | ||
1857 | 1851 | xfwmWindowCreate (screen_info, c->visual, c->depth, c->frame, | ||
1858 | 1852 | &c->buttons[i], BUTTON_EVENT_MASK, None); | ||
1859 | 1853 | } | ||
1860 | 1854 | clientUpdateIconPix (c); | ||
1861 | 1855 | |||
1862 | 1856 | /* Put the window on top to avoid XShape, that speeds up hw accelerated | ||
1863 | 1857 | GL apps dramatically */ | ||
1864 | 1858 | XRaiseWindow (display_info->dpy, c->window); | ||
1865 | 1859 | |||
1866 | 1860 | TRACE ("now calling configure for the new window \"%s\" (0x%lx)", c->name, c->window); | ||
1867 | 1861 | wc.x = c->x; | ||
1868 | 1862 | wc.y = c->y; | ||
1869 | 1863 | wc.width = c->width; | ||
1870 | 1864 | wc.height = c->height; | ||
1871 | 1865 | clientConfigure (c, &wc, CWX | CWY | CWHeight | CWWidth, CFG_NOTIFY | CFG_FORCE_REDRAW); | ||
1872 | 1866 | |||
1873 | 1867 | /* Notify the compositor about this new window */ | ||
1874 | 1868 | compositorAddWindow (display_info, c->frame, c); | ||
1875 | 1869 | |||
1876 | 1870 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED)) | ||
1877 | 1871 | { | ||
1878 | 1872 | if ((c->win_workspace == screen_info->current_ws) || | ||
1879 | 1873 | FLAG_TEST(c->flags, CLIENT_FLAG_STICKY)) | ||
1880 | 1874 | { | ||
1881 | 1875 | if (recapture) | ||
1882 | 1876 | { | ||
1883 | 1877 | clientRaise (c, None); | ||
1884 | 1878 | clientShow (c, TRUE); | ||
1885 | 1879 | clientSortRing(c); | ||
1886 | 1880 | } | ||
1887 | 1881 | else | ||
1888 | 1882 | { | ||
1889 | 1883 | clientFocusNew(c); | ||
1890 | 1884 | } | ||
1891 | 1885 | } | ||
1892 | 1886 | else | ||
1893 | 1887 | { | ||
1894 | 1888 | clientRaise (c, None); | ||
1895 | 1889 | clientInitFocusFlag (c); | ||
1896 | 1890 | clientSetNetActions (c); | ||
1897 | 1891 | } | ||
1898 | 1892 | } | ||
1899 | 1893 | else | ||
1900 | 1894 | { | ||
1901 | 1895 | clientRaise (c, None); | ||
1902 | 1896 | setWMState (display_info, c->window, IconicState); | ||
1903 | 1897 | clientSetNetActions (c); | ||
1904 | 1898 | } | ||
1905 | 1899 | clientUpdateOpacity (c); | ||
1906 | 1900 | clientGrabMouseButton (c); | ||
1907 | 1901 | setNetFrameExtents (display_info, c->window, frameTop (c), frameLeft (c), | ||
1908 | 1902 | frameRight (c), frameBottom (c)); | ||
1909 | 1903 | clientSetNetState (c); | ||
1910 | 1904 | |||
1911 | 1905 | /* Window is reparented now, so we can safely release the grab | ||
1912 | 1906 | * on the server | ||
1913 | 1907 | */ | ||
1914 | 1908 | myDisplayUngrabServer (display_info); | ||
1915 | 1909 | gdk_error_trap_pop (); | ||
1916 | 1910 | |||
1917 | 1911 | DBG ("client \"%s\" (0x%lx) is now managed", c->name, c->window); | ||
1918 | 1912 | DBG ("client_count=%d", screen_info->client_count); | ||
1919 | 1913 | |||
1920 | 1914 | return c; | ||
1921 | 1915 | } | ||
1922 | 1916 | |||
1923 | 1917 | void | ||
1924 | 1918 | clientUnframe (Client *c, gboolean remap) | ||
1925 | 1919 | { | ||
1926 | 1920 | ScreenInfo *screen_info; | ||
1927 | 1921 | DisplayInfo *display_info; | ||
1928 | 1922 | XEvent ev; | ||
1929 | 1923 | int i; | ||
1930 | 1924 | gboolean reparented; | ||
1931 | 1925 | |||
1932 | 1926 | TRACE ("entering clientUnframe"); | ||
1933 | 1927 | TRACE ("unframing client \"%s\" (0x%lx) [%s]", | ||
1934 | 1928 | c->name, c->window, remap ? "remap" : "no remap"); | ||
1935 | 1929 | |||
1936 | 1930 | g_return_if_fail (c != NULL); | ||
1937 | 1931 | |||
1938 | 1932 | screen_info = c->screen_info; | ||
1939 | 1933 | display_info = screen_info->display_info; | ||
1940 | 1934 | |||
1941 | 1935 | clientRemoveFromList (c); | ||
1942 | 1936 | compositorSetClient (display_info, c->frame, NULL); | ||
1943 | 1937 | |||
1944 | 1938 | myDisplayGrabServer (display_info); | ||
1945 | 1939 | gdk_error_trap_push (); | ||
1946 | 1940 | clientRemoveUserTimeWin (c); | ||
1947 | 1941 | clientUngrabButtons (c); | ||
1948 | 1942 | XUnmapWindow (display_info->dpy, c->frame); | ||
1949 | 1943 | clientCoordGravitate (c, c->gravity, REMOVE, &c->x, &c->y); | ||
1950 | 1944 | XSelectInput (display_info->dpy, c->window, NoEventMask); | ||
1951 | 1945 | XChangeSaveSet(display_info->dpy, c->window, SetModeDelete); | ||
1952 | 1946 | |||
1953 | 1947 | reparented = XCheckTypedWindowEvent (display_info->dpy, c->window, ReparentNotify, &ev); | ||
1954 | 1948 | |||
1955 | 1949 | if (remap || !reparented) | ||
1956 | 1950 | { | ||
1957 | 1951 | XReparentWindow (display_info->dpy, c->window, c->screen_info->xroot, c->x, c->y); | ||
1958 | 1952 | XSetWindowBorderWidth (display_info->dpy, c->window, c->border_width); | ||
1959 | 1953 | if (remap) | ||
1960 | 1954 | { | ||
1961 | 1955 | compositorAddWindow (display_info, c->window, NULL); | ||
1962 | 1956 | XMapWindow (display_info->dpy, c->window); | ||
1963 | 1957 | } | ||
1964 | 1958 | else | ||
1965 | 1959 | { | ||
1966 | 1960 | XUnmapWindow (display_info->dpy, c->window); | ||
1967 | 1961 | setWMState (display_info, c->window, WithdrawnState); | ||
1968 | 1962 | } | ||
1969 | 1963 | } | ||
1970 | 1964 | |||
1971 | 1965 | if (!remap) | ||
1972 | 1966 | { | ||
1973 | 1967 | XDeleteProperty (display_info->dpy, c->window, | ||
1974 | 1968 | display_info->atoms[NET_WM_STATE]); | ||
1975 | 1969 | XDeleteProperty (display_info->dpy, c->window, | ||
1976 | 1970 | display_info->atoms[NET_WM_DESKTOP]); | ||
1977 | 1971 | XDeleteProperty (display_info->dpy, c->window, | ||
1978 | 1972 | display_info->atoms[NET_WM_ALLOWED_ACTIONS]); | ||
1979 | 1973 | } | ||
1980 | 1974 | |||
1981 | 1975 | xfwmWindowDelete (&c->title); | ||
1982 | 1976 | |||
1983 | 1977 | for (i = 0; i < SIDE_COUNT; i++) | ||
1984 | 1978 | { | ||
1985 | 1979 | xfwmWindowDelete (&c->sides[i]); | ||
1986 | 1980 | } | ||
1987 | 1981 | for (i = 0; i < CORNER_COUNT; i++) | ||
1988 | 1982 | { | ||
1989 | 1983 | xfwmWindowDelete (&c->corners[i]); | ||
1990 | 1984 | } | ||
1991 | 1985 | for (i = 0; i < STATE_TOGGLED; i++) | ||
1992 | 1986 | { | ||
1993 | 1987 | xfwmPixmapFree (&c->appmenu[i]); | ||
1994 | 1988 | } | ||
1995 | 1989 | for (i = 0; i < BUTTON_COUNT; i++) | ||
1996 | 1990 | { | ||
1997 | 1991 | xfwmWindowDelete (&c->buttons[i]); | ||
1998 | 1992 | } | ||
1999 | 1993 | if (FLAG_TEST (c->flags, CLIENT_FLAG_HAS_STRUT)) | ||
2000 | 1994 | { | ||
2001 | 1995 | workspaceUpdateArea (c->screen_info); | ||
2002 | 1996 | } | ||
2003 | 1997 | XDestroyWindow (display_info->dpy, c->frame); | ||
2004 | 1998 | |||
2005 | 1999 | myDisplayUngrabServer (display_info); | ||
2006 | 2000 | gdk_error_trap_pop (); | ||
2007 | 2001 | clientFree (c); | ||
2008 | 2002 | } | ||
2009 | 2003 | |||
2010 | 2004 | void | ||
2011 | 2005 | clientFrameAll (ScreenInfo *screen_info) | ||
2012 | 2006 | { | ||
2013 | 2007 | DisplayInfo *display_info; | ||
2014 | 2008 | XWindowAttributes attr; | ||
2015 | 2009 | xfwmWindow shield; | ||
2016 | 2010 | Window w1, w2, *wins; | ||
2017 | 2011 | unsigned int count, i; | ||
2018 | 2012 | |||
2019 | 2013 | TRACE ("entering clientFrameAll"); | ||
2020 | 2014 | |||
2021 | 2015 | display_info = screen_info->display_info; | ||
2022 | 2016 | clientSetFocus (screen_info, NULL, myDisplayGetCurrentTime (display_info), NO_FOCUS_FLAG); | ||
2023 | 2017 | xfwmWindowTemp (screen_info, | ||
2024 | 2018 | NULL, 0, | ||
2025 | 2019 | screen_info->xroot, | ||
2026 | 2020 | &shield, | ||
2027 | 2021 | 0, 0, | ||
2028 | 2022 | screen_info->width, | ||
2029 | 2023 | screen_info->height, | ||
2030 | 2024 | EnterWindowMask, | ||
2031 | 2025 | FALSE); | ||
2032 | 2026 | |||
2033 | 2027 | XSync (display_info->dpy, FALSE); | ||
2034 | 2028 | myDisplayGrabServer (display_info); | ||
2035 | 2029 | XQueryTree (display_info->dpy, screen_info->xroot, &w1, &w2, &wins, &count); | ||
2036 | 2030 | for (i = 0; i < count; i++) | ||
2037 | 2031 | { | ||
2038 | 2032 | XGetWindowAttributes (display_info->dpy, wins[i], &attr); | ||
2039 | 2033 | if ((attr.map_state == IsViewable) && (attr.root == screen_info->xroot)) | ||
2040 | 2034 | { | ||
2041 | 2035 | Client *c = clientFrame (display_info, wins[i], TRUE); | ||
2042 | 2036 | if ((c) && ((screen_info->params->raise_on_click) || (screen_info->params->click_to_focus))) | ||
2043 | 2037 | { | ||
2044 | 2038 | clientGrabMouseButton (c); | ||
2045 | 2039 | } | ||
2046 | 2040 | } | ||
2047 | 2041 | else | ||
2048 | 2042 | { | ||
2049 | 2043 | compositorAddWindow (display_info, wins[i], NULL); | ||
2050 | 2044 | } | ||
2051 | 2045 | } | ||
2052 | 2046 | if (wins) | ||
2053 | 2047 | { | ||
2054 | 2048 | XFree (wins); | ||
2055 | 2049 | } | ||
2056 | 2050 | clientFocusTop (screen_info, WIN_LAYER_FULLSCREEN, myDisplayGetCurrentTime (display_info)); | ||
2057 | 2051 | xfwmWindowDelete (&shield); | ||
2058 | 2052 | myDisplayUngrabServer (display_info); | ||
2059 | 2053 | XSync (display_info->dpy, FALSE); | ||
2060 | 2054 | } | ||
2061 | 2055 | |||
2062 | 2056 | void | ||
2063 | 2057 | clientUnframeAll (ScreenInfo *screen_info) | ||
2064 | 2058 | { | ||
2065 | 2059 | DisplayInfo *display_info; | ||
2066 | 2060 | Client *c; | ||
2067 | 2061 | Window w1, w2, *wins; | ||
2068 | 2062 | unsigned int count, i; | ||
2069 | 2063 | |||
2070 | 2064 | TRACE ("entering clientUnframeAll"); | ||
2071 | 2065 | |||
2072 | 2066 | display_info = screen_info->display_info; | ||
2073 | 2067 | clientSetFocus (screen_info, NULL, myDisplayGetCurrentTime (display_info), FOCUS_IGNORE_MODAL); | ||
2074 | 2068 | XSync (display_info->dpy, FALSE); | ||
2075 | 2069 | myDisplayGrabServer (display_info); | ||
2076 | 2070 | XQueryTree (display_info->dpy, screen_info->xroot, &w1, &w2, &wins, &count); | ||
2077 | 2071 | for (i = 0; i < count; i++) | ||
2078 | 2072 | { | ||
2079 | 2073 | c = myScreenGetClientFromWindow (screen_info, wins[i], SEARCH_FRAME); | ||
2080 | 2074 | if (c) | ||
2081 | 2075 | { | ||
2082 | 2076 | clientUnframe (c, TRUE); | ||
2083 | 2077 | } | ||
2084 | 2078 | } | ||
2085 | 2079 | myDisplayUngrabServer (display_info); | ||
2086 | 2080 | XSync(display_info->dpy, FALSE); | ||
2087 | 2081 | if (wins) | ||
2088 | 2082 | { | ||
2089 | 2083 | XFree (wins); | ||
2090 | 2084 | } | ||
2091 | 2085 | } | ||
2092 | 2086 | |||
2093 | 2087 | Client * | ||
2094 | 2088 | clientGetFromWindow (Client *c, Window w, unsigned short mode) | ||
2095 | 2089 | { | ||
2096 | 2090 | int b; | ||
2097 | 2091 | |||
2098 | 2092 | g_return_val_if_fail (w != None, NULL); | ||
2099 | 2093 | g_return_val_if_fail (c != NULL, NULL); | ||
2100 | 2094 | TRACE ("entering clientGetFromWindow"); | ||
2101 | 2095 | |||
2102 | 2096 | if (mode & SEARCH_WINDOW) | ||
2103 | 2097 | { | ||
2104 | 2098 | if (c->window == w) | ||
2105 | 2099 | { | ||
2106 | 2100 | TRACE ("found \"%s\" (mode WINDOW)", c->name); | ||
2107 | 2101 | return (c); | ||
2108 | 2102 | } | ||
2109 | 2103 | } | ||
2110 | 2104 | |||
2111 | 2105 | if (mode & SEARCH_FRAME) | ||
2112 | 2106 | { | ||
2113 | 2107 | if (c->frame == w) | ||
2114 | 2108 | { | ||
2115 | 2109 | TRACE ("found \"%s\" (mode FRAME)", c->name); | ||
2116 | 2110 | return (c); | ||
2117 | 2111 | } | ||
2118 | 2112 | } | ||
2119 | 2113 | |||
2120 | 2114 | if (mode & SEARCH_WIN_USER_TIME) | ||
2121 | 2115 | { | ||
2122 | 2116 | if (c->user_time_win == w) | ||
2123 | 2117 | { | ||
2124 | 2118 | TRACE ("found \"%s\" (mode WIN_USER_TIME)", c->name); | ||
2125 | 2119 | return (c); | ||
2126 | 2120 | } | ||
2127 | 2121 | } | ||
2128 | 2122 | |||
2129 | 2123 | if (mode & SEARCH_BUTTON) | ||
2130 | 2124 | { | ||
2131 | 2125 | for (b = 0; b < BUTTON_COUNT; b++) | ||
2132 | 2126 | { | ||
2133 | 2127 | if (MYWINDOW_XWINDOW(c->buttons[b]) == w) | ||
2134 | 2128 | { | ||
2135 | 2129 | TRACE ("found \"%s\" (mode BUTTON)", c->name); | ||
2136 | 2130 | return (c); | ||
2137 | 2131 | } | ||
2138 | 2132 | } | ||
2139 | 2133 | } | ||
2140 | 2134 | |||
2141 | 2135 | TRACE ("no client found"); | ||
2142 | 2136 | |||
2143 | 2137 | return NULL; | ||
2144 | 2138 | } | ||
2145 | 2139 | |||
2146 | 2140 | static void | ||
2147 | 2141 | clientSetWorkspaceSingle (Client *c, guint ws) | ||
2148 | 2142 | { | ||
2149 | 2143 | ScreenInfo *screen_info; | ||
2150 | 2144 | DisplayInfo *display_info; | ||
2151 | 2145 | |||
2152 | 2146 | g_return_if_fail (c != NULL); | ||
2153 | 2147 | |||
2154 | 2148 | TRACE ("entering clientSetWorkspaceSingle"); | ||
2155 | 2149 | |||
2156 | 2150 | screen_info = c->screen_info; | ||
2157 | 2151 | display_info = screen_info->display_info; | ||
2158 | 2152 | |||
2159 | 2153 | if (ws > screen_info->workspace_count - 1) | ||
2160 | 2154 | { | ||
2161 | 2155 | ws = screen_info->workspace_count - 1; | ||
2162 | 2156 | TRACE ("value off limits, using %i instead", ws); | ||
2163 | 2157 | } | ||
2164 | 2158 | |||
2165 | 2159 | if (c->win_workspace != ws) | ||
2166 | 2160 | { | ||
2167 | 2161 | TRACE ("setting client \"%s\" (0x%lx) to current_ws %d", c->name, c->window, ws); | ||
2168 | 2162 | c->win_workspace = ws; | ||
2169 | 2163 | if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) | ||
2170 | 2164 | { | ||
2171 | 2165 | setHint (display_info, c->window, NET_WM_DESKTOP, (unsigned long) ALL_WORKSPACES); | ||
2172 | 2166 | } | ||
2173 | 2167 | else | ||
2174 | 2168 | { | ||
2175 | 2169 | setHint (display_info, c->window, NET_WM_DESKTOP, (unsigned long) ws); | ||
2176 | 2170 | } | ||
2177 | 2171 | } | ||
2178 | 2172 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_WORKSPACE_SET); | ||
2179 | 2173 | } | ||
2180 | 2174 | |||
2181 | 2175 | void | ||
2182 | 2176 | clientSetWorkspace (Client *c, guint ws, gboolean manage_mapping) | ||
2183 | 2177 | { | ||
2184 | 2178 | Client *c2; | ||
2185 | 2179 | GList *list_of_windows; | ||
2186 | 2180 | GList *list; | ||
2187 | 2181 | guint previous_ws; | ||
2188 | 2182 | |||
2189 | 2183 | g_return_if_fail (c != NULL); | ||
2190 | 2184 | |||
2191 | 2185 | TRACE ("entering clientSetWorkspace"); | ||
2192 | 2186 | |||
2193 | 2187 | if (ws > c->screen_info->workspace_count - 1) | ||
2194 | 2188 | { | ||
2195 | 2189 | g_warning ("Requested workspace %d does not exist", ws); | ||
2196 | 2190 | return; | ||
2197 | 2191 | } | ||
2198 | 2192 | |||
2199 | 2193 | list_of_windows = clientListTransientOrModal (c); | ||
2200 | 2194 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
2201 | 2195 | { | ||
2202 | 2196 | c2 = (Client *) list->data; | ||
2203 | 2197 | |||
2204 | 2198 | if (c2->win_workspace != ws) | ||
2205 | 2199 | { | ||
2206 | 2200 | TRACE ("setting client \"%s\" (0x%lx) to current_ws %d", c->name, c->window, ws); | ||
2207 | 2201 | |||
2208 | 2202 | previous_ws = c2->win_workspace; | ||
2209 | 2203 | clientSetWorkspaceSingle (c2, ws); | ||
2210 | 2204 | |||
2211 | 2205 | if (manage_mapping && !FLAG_TEST (c2->flags, CLIENT_FLAG_ICONIFIED)) | ||
2212 | 2206 | { | ||
2213 | 2207 | if (previous_ws == c2->screen_info->current_ws) | ||
2214 | 2208 | { | ||
2215 | 2209 | clientWithdraw (c2, c2->screen_info->current_ws, FALSE); | ||
2216 | 2210 | } | ||
2217 | 2211 | if (FLAG_TEST (c2->flags, CLIENT_FLAG_STICKY) || (ws == c2->screen_info->current_ws)) | ||
2218 | 2212 | { | ||
2219 | 2213 | clientShow (c2, FALSE); | ||
2220 | 2214 | } | ||
2221 | 2215 | } | ||
2222 | 2216 | } | ||
2223 | 2217 | } | ||
2224 | 2218 | g_list_free (list_of_windows); | ||
2225 | 2219 | } | ||
2226 | 2220 | |||
2227 | 2221 | static void | ||
2228 | 2222 | clientShowSingle (Client *c, gboolean deiconify) | ||
2229 | 2223 | { | ||
2230 | 2224 | ScreenInfo *screen_info; | ||
2231 | 2225 | DisplayInfo *display_info; | ||
2232 | 2226 | |||
2233 | 2227 | g_return_if_fail (c != NULL); | ||
2234 | 2228 | |||
2235 | 2229 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
2236 | 2230 | { | ||
2237 | 2231 | /* Should we map the window if it is visible? */ | ||
2238 | 2232 | return; | ||
2239 | 2233 | } | ||
2240 | 2234 | |||
2241 | 2235 | screen_info = c->screen_info; | ||
2242 | 2236 | display_info = screen_info->display_info; | ||
2243 | 2237 | |||
2244 | 2238 | if ((c->win_workspace == screen_info->current_ws) || FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) | ||
2245 | 2239 | { | ||
2246 | 2240 | TRACE ("showing client \"%s\" (0x%lx)", c->name, c->window); | ||
2247 | 2241 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_VISIBLE); | ||
2248 | 2242 | XMapWindow (display_info->dpy, c->frame); | ||
2249 | 2243 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
2250 | 2244 | { | ||
2251 | 2245 | XMapWindow (display_info->dpy, c->window); | ||
2252 | 2246 | } | ||
2253 | 2247 | /* Adjust to urgency state as the window is visible */ | ||
2254 | 2248 | clientUpdateUrgency (c); | ||
2255 | 2249 | } | ||
2256 | 2250 | if (deiconify) | ||
2257 | 2251 | { | ||
2258 | 2252 | FLAG_UNSET (c->flags, CLIENT_FLAG_ICONIFIED); | ||
2259 | 2253 | setWMState (display_info, c->window, NormalState); | ||
2260 | 2254 | } | ||
2261 | 2255 | clientSetNetActions (c); | ||
2262 | 2256 | clientSetNetState (c); | ||
2263 | 2257 | } | ||
2264 | 2258 | |||
2265 | 2259 | void | ||
2266 | 2260 | clientShow (Client *c, gboolean deiconify) | ||
2267 | 2261 | { | ||
2268 | 2262 | Client *c2; | ||
2269 | 2263 | GList *list_of_windows; | ||
2270 | 2264 | GList *list; | ||
2271 | 2265 | |||
2272 | 2266 | g_return_if_fail (c != NULL); | ||
2273 | 2267 | TRACE ("entering clientShow \"%s\" (0x%lx)", c->name, c->window); | ||
2274 | 2268 | |||
2275 | 2269 | list_of_windows = clientListTransientOrModal (c); | ||
2276 | 2270 | for (list = g_list_last (list_of_windows); list; list = g_list_previous (list)) | ||
2277 | 2271 | { | ||
2278 | 2272 | c2 = (Client *) list->data; | ||
2279 | 2273 | clientSetWorkspaceSingle (c2, c->win_workspace); | ||
2280 | 2274 | /* Ignore request before if the window is not yet managed */ | ||
2281 | 2275 | if (!FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
2282 | 2276 | { | ||
2283 | 2277 | continue; | ||
2284 | 2278 | } | ||
2285 | 2279 | clientShowSingle (c2, deiconify); | ||
2286 | 2280 | } | ||
2287 | 2281 | g_list_free (list_of_windows); | ||
2288 | 2282 | |||
2289 | 2283 | /* Update working area as windows have been shown */ | ||
2290 | 2284 | workspaceUpdateArea (c->screen_info); | ||
2291 | 2285 | } | ||
2292 | 2286 | |||
2293 | 2287 | static void | ||
2294 | 2288 | clientWithdrawSingle (Client *c, GList *exclude_list, gboolean iconify) | ||
2295 | 2289 | { | ||
2296 | 2290 | ScreenInfo *screen_info; | ||
2297 | 2291 | DisplayInfo *display_info; | ||
2298 | 2292 | |||
2299 | 2293 | g_return_if_fail (c != NULL); | ||
2300 | 2294 | |||
2301 | 2295 | screen_info = c->screen_info; | ||
2302 | 2296 | display_info = screen_info->display_info; | ||
2303 | 2297 | |||
2304 | 2298 | TRACE ("hiding client \"%s\" (0x%lx)", c->name, c->window); | ||
2305 | 2299 | clientPassFocus(c->screen_info, c, exclude_list); | ||
2306 | 2300 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
2307 | 2301 | { | ||
2308 | 2302 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_VISIBLE); | ||
2309 | 2303 | c->ignore_unmap++; | ||
2310 | 2304 | /* Adjust to urgency state as the window is not visible */ | ||
2311 | 2305 | clientUpdateUrgency (c); | ||
2312 | 2306 | } | ||
2313 | 2307 | XUnmapWindow (display_info->dpy, c->window); | ||
2314 | 2308 | XUnmapWindow (display_info->dpy, c->frame); | ||
2315 | 2309 | if (iconify) | ||
2316 | 2310 | { | ||
2317 | 2311 | FLAG_SET (c->flags, CLIENT_FLAG_ICONIFIED); | ||
2318 | 2312 | setWMState (display_info, c->window, IconicState); | ||
2319 | 2313 | if (!screen_info->show_desktop) | ||
2320 | 2314 | { | ||
2321 | 2315 | clientSetLast (c); | ||
2322 | 2316 | } | ||
2323 | 2317 | } | ||
2324 | 2318 | clientSetNetActions (c); | ||
2325 | 2319 | clientSetNetState (c); | ||
2326 | 2320 | } | ||
2327 | 2321 | |||
2328 | 2322 | void | ||
2329 | 2323 | clientWithdraw (Client *c, guint ws, gboolean iconify) | ||
2330 | 2324 | { | ||
2331 | 2325 | Client *c2; | ||
2332 | 2326 | GList *list_of_windows; | ||
2333 | 2327 | GList *list; | ||
2334 | 2328 | |||
2335 | 2329 | g_return_if_fail (c != NULL); | ||
2336 | 2330 | TRACE ("entering clientWithdraw \"%s\" (0x%lx)", c->name, c->window); | ||
2337 | 2331 | |||
2338 | 2332 | list_of_windows = clientListTransientOrModal (c); | ||
2339 | 2333 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
2340 | 2334 | { | ||
2341 | 2335 | c2 = (Client *) list->data; | ||
2342 | 2336 | |||
2343 | 2337 | /* Ignore request before if the window is not yet managed */ | ||
2344 | 2338 | if (!FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
2345 | 2339 | { | ||
2346 | 2340 | continue; | ||
2347 | 2341 | } | ||
2348 | 2342 | |||
2349 | 2343 | if (FLAG_TEST (c2->flags, CLIENT_FLAG_STICKY) && !iconify) | ||
2350 | 2344 | { | ||
2351 | 2345 | continue; | ||
2352 | 2346 | } | ||
2353 | 2347 | |||
2354 | 2348 | if (clientIsTransientOrModalForGroup (c2)) | ||
2355 | 2349 | { | ||
2356 | 2350 | |||
2357 | 2351 | if (clientTransientOrModalHasAncestor (c2, c2->win_workspace)) | ||
2358 | 2352 | { | ||
2359 | 2353 | /* Other ancestors for that transient for group are still | ||
2360 | 2354 | * visible on current workspace, so don't hide it... | ||
2361 | 2355 | */ | ||
2362 | 2356 | continue; | ||
2363 | 2357 | } | ||
2364 | 2358 | if ((ws != c2->win_workspace) && | ||
2365 | 2359 | clientTransientOrModalHasAncestor (c2, ws)) | ||
2366 | 2360 | { | ||
2367 | 2361 | /* ws is used when transitioning between desktops, to avoid | ||
2368 | 2362 | hiding a transient for group that will be shown again on the new | ||
2369 | 2363 | workspace (transient for groups can be transients for multiple | ||
2370 | 2364 | ancesors splitted across workspaces...) | ||
2371 | 2365 | */ | ||
2372 | 2366 | continue; | ||
2373 | 2367 | } | ||
2374 | 2368 | } | ||
2375 | 2369 | clientWithdrawSingle (c2, list_of_windows, iconify); | ||
2376 | 2370 | } | ||
2377 | 2371 | g_list_free (list_of_windows); | ||
2378 | 2372 | |||
2379 | 2373 | /* Update working area as windows have been hidden */ | ||
2380 | 2374 | workspaceUpdateArea (c->screen_info); | ||
2381 | 2375 | } | ||
2382 | 2376 | |||
2383 | 2377 | void | ||
2384 | 2378 | clientWithdrawAll (Client *c, guint ws) | ||
2385 | 2379 | { | ||
2386 | 2380 | GList *list; | ||
2387 | 2381 | Client *c2; | ||
2388 | 2382 | ScreenInfo *screen_info; | ||
2389 | 2383 | |||
2390 | 2384 | g_return_if_fail (c != NULL); | ||
2391 | 2385 | |||
2392 | 2386 | TRACE ("entering clientWithdrawAll"); | ||
2393 | 2387 | |||
2394 | 2388 | screen_info = c->screen_info; | ||
2395 | 2389 | for (list = screen_info->windows_stack; list; list = g_list_next (list)) | ||
2396 | 2390 | { | ||
2397 | 2391 | c2 = (Client *) list->data; | ||
2398 | 2392 | |||
2399 | 2393 | if ((c2 != c) | ||
2400 | 2394 | && CLIENT_CAN_HIDE_WINDOW (c2) | ||
2401 | 2395 | && !clientIsTransientOrModal (c2)) | ||
2402 | 2396 | { | ||
2403 | 2397 | if (((!c) && (c2->win_workspace == ws)) | ||
2404 | 2398 | || ((c) && !clientIsTransientOrModalFor (c, c2) | ||
2405 | 2399 | && (c2->win_workspace == c->win_workspace))) | ||
2406 | 2400 | { | ||
2407 | 2401 | clientWithdraw (c2, ws, TRUE); | ||
2408 | 2402 | } | ||
2409 | 2403 | } | ||
2410 | 2404 | } | ||
2411 | 2405 | } | ||
2412 | 2406 | |||
2413 | 2407 | void | ||
2414 | 2408 | clientClearAllShowDesktop (ScreenInfo *screen_info) | ||
2415 | 2409 | { | ||
2416 | 2410 | GList *list; | ||
2417 | 2411 | |||
2418 | 2412 | TRACE ("entering clientClearShowDesktop"); | ||
2419 | 2413 | |||
2420 | 2414 | if (screen_info->show_desktop) | ||
2421 | 2415 | { | ||
2422 | 2416 | for (list = screen_info->windows_stack; list; list = g_list_next (list)) | ||
2423 | 2417 | { | ||
2424 | 2418 | Client *c = (Client *) list->data; | ||
2425 | 2419 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN); | ||
2426 | 2420 | } | ||
2427 | 2421 | screen_info->show_desktop = FALSE; | ||
2428 | 2422 | sendRootMessage (screen_info, NET_SHOWING_DESKTOP, screen_info->show_desktop, | ||
2429 | 2423 | myDisplayGetCurrentTime (screen_info->display_info)); | ||
2430 | 2424 | } | ||
2431 | 2425 | } | ||
2432 | 2426 | |||
2433 | 2427 | void | ||
2434 | 2428 | clientToggleShowDesktop (ScreenInfo *screen_info) | ||
2435 | 2429 | { | ||
2436 | 2430 | GList *list; | ||
2437 | 2431 | |||
2438 | 2432 | TRACE ("entering clientToggleShowDesktop"); | ||
2439 | 2433 | |||
2440 | 2434 | clientSetFocus (screen_info, NULL, | ||
2441 | 2435 | myDisplayGetCurrentTime (screen_info->display_info), | ||
2442 | 2436 | FOCUS_IGNORE_MODAL); | ||
2443 | 2437 | if (screen_info->show_desktop) | ||
2444 | 2438 | { | ||
2445 | 2439 | for (list = screen_info->windows_stack; list; list = g_list_next (list)) | ||
2446 | 2440 | { | ||
2447 | 2441 | Client *c = (Client *) list->data; | ||
2448 | 2442 | if ((c->type & WINDOW_REGULAR_FOCUSABLE) | ||
2449 | 2443 | && !FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED | CLIENT_FLAG_SKIP_TASKBAR)) | ||
2450 | 2444 | { | ||
2451 | 2445 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN); | ||
2452 | 2446 | clientWithdraw (c, c->win_workspace, TRUE); | ||
2453 | 2447 | } | ||
2454 | 2448 | } | ||
2455 | 2449 | clientFocusTop (screen_info, WIN_LAYER_DESKTOP, myDisplayGetCurrentTime (screen_info->display_info)); | ||
2456 | 2450 | } | ||
2457 | 2451 | else | ||
2458 | 2452 | { | ||
2459 | 2453 | for (list = g_list_last(screen_info->windows_stack); list; list = g_list_previous (list)) | ||
2460 | 2454 | { | ||
2461 | 2455 | Client *c = (Client *) list->data; | ||
2462 | 2456 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN)) | ||
2463 | 2457 | { | ||
2464 | 2458 | clientShow (c, TRUE); | ||
2465 | 2459 | } | ||
2466 | 2460 | FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN); | ||
2467 | 2461 | } | ||
2468 | 2462 | clientFocusTop (screen_info, WIN_LAYER_FULLSCREEN, myDisplayGetCurrentTime (screen_info->display_info)); | ||
2469 | 2463 | } | ||
2470 | 2464 | } | ||
2471 | 2465 | |||
2472 | 2466 | void | ||
2473 | 2467 | clientActivate (Client *c, guint32 timestamp, gboolean source_is_application) | ||
2474 | 2468 | { | ||
2475 | 2469 | ScreenInfo *screen_info; | ||
2476 | 2470 | Client *focused; | ||
2477 | 2471 | Client *sibling; | ||
2478 | 2472 | |||
2479 | 2473 | g_return_if_fail (c != NULL); | ||
2480 | 2474 | TRACE ("entering clientActivate \"%s\" (0x%lx)", c->name, c->window); | ||
2481 | 2475 | |||
2482 | 2476 | screen_info = c->screen_info; | ||
2483 | 2477 | sibling = clientGetTransientFor(c); | ||
2484 | 2478 | focused = clientGetFocus (); | ||
2485 | 2479 | |||
2486 | 2480 | if ((screen_info->current_ws == c->win_workspace) || (screen_info->params->activate_action != ACTIVATE_ACTION_NONE)) | ||
2487 | 2481 | { | ||
2488 | 2482 | if ((focused) && (c != focused)) | ||
2489 | 2483 | { | ||
2490 | 2484 | /* We might be able to avoid this if we are about to switch workspace */ | ||
2491 | 2485 | clientAdjustFullscreenLayer (focused, FALSE); | ||
2492 | 2486 | } | ||
2493 | 2487 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_WAS_SHOWN)) | ||
2494 | 2488 | { | ||
2495 | 2489 | /* We are explicitely activating a window that was shown before show-desktop */ | ||
2496 | 2490 | clientClearAllShowDesktop (screen_info); | ||
2497 | 2491 | } | ||
2498 | 2492 | if (screen_info->current_ws != c->win_workspace) | ||
2499 | 2493 | { | ||
2500 | 2494 | if (screen_info->params->activate_action == ACTIVATE_ACTION_BRING) | ||
2501 | 2495 | { | ||
2502 | 2496 | clientSetWorkspace (c, screen_info->current_ws, TRUE); | ||
2503 | 2497 | } | ||
2504 | 2498 | else | ||
2505 | 2499 | { | ||
2506 | 2500 | workspaceSwitch (screen_info, c->win_workspace, NULL, FALSE, timestamp); | ||
2507 | 2501 | } | ||
2508 | 2502 | } | ||
2509 | 2503 | clientRaise (sibling, None); | ||
2510 | 2504 | clientShow (sibling, TRUE); | ||
2511 | 2505 | if (source_is_application || screen_info->params->click_to_focus || (c->type & WINDOW_TYPE_DONT_FOCUS)) | ||
2512 | 2506 | { | ||
2513 | 2507 | /* | ||
2514 | 2508 | It's a bit tricky here, we want to honor the activate request only if: | ||
2515 | 2509 | |||
2516 | 2510 | - The window use the _NET_ACTIVE_WINDOW protocol and identify itself as an application, | ||
2517 | 2511 | - Or we use the click to focus model, in that case we focus the raised window anyway, | ||
2518 | 2512 | - Or the request comes from an application that we would not focus by default, | ||
2519 | 2513 | such as panels for example | ||
2520 | 2514 | */ | ||
2521 | 2515 | clientSetFocus (screen_info, c, timestamp, NO_FOCUS_FLAG); | ||
2522 | 2516 | } | ||
2523 | 2517 | clientSetLastRaise (c); | ||
2524 | 2518 | } | ||
2525 | 2519 | else | ||
2526 | 2520 | { | ||
2527 | 2521 | TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window); | ||
2528 | 2522 | FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION); | ||
2529 | 2523 | clientSetNetState (c); | ||
2530 | 2524 | } | ||
2531 | 2525 | } | ||
2532 | 2526 | |||
2533 | 2527 | void | ||
2534 | 2528 | clientClose (Client *c) | ||
2535 | 2529 | { | ||
2536 | 2530 | ScreenInfo *screen_info; | ||
2537 | 2531 | DisplayInfo *display_info; | ||
2538 | 2532 | guint32 timestamp; | ||
2539 | 2533 | |||
2540 | 2534 | g_return_if_fail (c != NULL); | ||
2541 | 2535 | |||
2542 | 2536 | TRACE ("entering clientClose"); | ||
2543 | 2537 | TRACE ("closing client \"%s\" (0x%lx)", c->name, c->window); | ||
2544 | 2538 | |||
2545 | 2539 | screen_info = c->screen_info; | ||
2546 | 2540 | display_info = screen_info->display_info; | ||
2547 | 2541 | timestamp = myDisplayGetCurrentTime (display_info); | ||
2548 | 2542 | timestamp = myDisplayGetTime (display_info, timestamp); | ||
2549 | 2543 | |||
2550 | 2544 | if (FLAG_TEST (c->wm_flags, WM_FLAG_DELETE)) | ||
2551 | 2545 | { | ||
2552 | 2546 | sendClientMessage (screen_info, c->window, WM_DELETE_WINDOW, timestamp); | ||
2553 | 2547 | } | ||
2554 | 2548 | else | ||
2555 | 2549 | { | ||
2556 | 2550 | clientKill (c); | ||
2557 | 2551 | } | ||
2558 | 2552 | if (FLAG_TEST (c->wm_flags, WM_FLAG_PING)) | ||
2559 | 2553 | { | ||
2560 | 2554 | clientSendNetWMPing (c, timestamp); | ||
2561 | 2555 | } | ||
2562 | 2556 | } | ||
2563 | 2557 | |||
2564 | 2558 | void | ||
2565 | 2559 | clientKill (Client *c) | ||
2566 | 2560 | { | ||
2567 | 2561 | g_return_if_fail (c != NULL); | ||
2568 | 2562 | TRACE ("entering clientKill"); | ||
2569 | 2563 | TRACE ("killing client \"%s\" (0x%lx)", c->name, c->window); | ||
2570 | 2564 | |||
2571 | 2565 | XKillClient (clientGetXDisplay (c), c->window); | ||
2572 | 2566 | } | ||
2573 | 2567 | |||
2574 | 2568 | void | ||
2575 | 2569 | clientTerminate (Client *c) | ||
2576 | 2570 | { | ||
2577 | 2571 | ScreenInfo *screen_info; | ||
2578 | 2572 | DisplayInfo *display_info; | ||
2579 | 2573 | |||
2580 | 2574 | g_return_if_fail (c != NULL); | ||
2581 | 2575 | TRACE ("entering clientTerminate"); | ||
2582 | 2576 | |||
2583 | 2577 | screen_info = c->screen_info; | ||
2584 | 2578 | display_info = screen_info->display_info; | ||
2585 | 2579 | |||
2586 | 2580 | if ((c->hostname) && (c->pid > 0)) | ||
2587 | 2581 | { | ||
2588 | 2582 | if (!strcmp (display_info->hostname, c->hostname)) | ||
2589 | 2583 | { | ||
2590 | 2584 | TRACE ("Sending client %s (pid %i) signal SIGKILL\n", c->name, c->pid); | ||
2591 | 2585 | |||
2592 | 2586 | if (kill (c->pid, SIGKILL) < 0) | ||
2593 | 2587 | { | ||
2594 | 2588 | g_warning ("Failed to kill client id %d: %s", c->pid, strerror (errno)); | ||
2595 | 2589 | } | ||
2596 | 2590 | } | ||
2597 | 2591 | } | ||
2598 | 2592 | |||
2599 | 2593 | clientKill (c); | ||
2600 | 2594 | } | ||
2601 | 2595 | |||
2602 | 2596 | void | ||
2603 | 2597 | clientEnterContextMenuState (Client *c) | ||
2604 | 2598 | { | ||
2605 | 2599 | ScreenInfo *screen_info; | ||
2606 | 2600 | DisplayInfo *display_info; | ||
2607 | 2601 | |||
2608 | 2602 | g_return_if_fail (c != NULL); | ||
2609 | 2603 | |||
2610 | 2604 | TRACE ("entering clientEnterContextMenuState"); | ||
2611 | 2605 | TRACE ("Showing the what's this help for client \"%s\" (0x%lx)", c->name, c->window); | ||
2612 | 2606 | |||
2613 | 2607 | screen_info = c->screen_info; | ||
2614 | 2608 | display_info = screen_info->display_info; | ||
2615 | 2609 | |||
2616 | 2610 | if (FLAG_TEST (c->wm_flags, WM_FLAG_CONTEXT_HELP)) | ||
2617 | 2611 | { | ||
2618 | 2612 | sendClientMessage (c->screen_info, c->window, NET_WM_CONTEXT_HELP, | ||
2619 | 2613 | myDisplayGetCurrentTime (display_info)); | ||
2620 | 2614 | } | ||
2621 | 2615 | } | ||
2622 | 2616 | |||
2623 | 2617 | void | ||
2624 | 2618 | clientSetLayer (Client *c, guint l) | ||
2625 | 2619 | { | ||
2626 | 2620 | GList *list_of_windows = NULL; | ||
2627 | 2621 | GList *list = NULL; | ||
2628 | 2622 | Client *c2 = NULL; | ||
2629 | 2623 | |||
2630 | 2624 | g_return_if_fail (c != NULL); | ||
2631 | 2625 | TRACE ("entering clientSetLayer for \"%s\" (0x%lx) on layer %d", c->name, c->window, l); | ||
2632 | 2626 | |||
2633 | 2627 | list_of_windows = clientListTransientOrModal (c); | ||
2634 | 2628 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
2635 | 2629 | { | ||
2636 | 2630 | c2 = (Client *) list->data; | ||
2637 | 2631 | if (c2->win_layer != l) | ||
2638 | 2632 | { | ||
2639 | 2633 | TRACE ("setting client \"%s\" (0x%lx) layer to %d", c2->name, | ||
2640 | 2634 | c2->window, l); | ||
2641 | 2635 | c2->win_layer = l; | ||
2642 | 2636 | } | ||
2643 | 2637 | } | ||
2644 | 2638 | g_list_free (list_of_windows); | ||
2645 | 2639 | |||
2646 | 2640 | if (clientGetLastRaise (c->screen_info) == c) | ||
2647 | 2641 | { | ||
2648 | 2642 | clientClearLastRaise (c->screen_info); | ||
2649 | 2643 | } | ||
2650 | 2644 | |||
2651 | 2645 | c2 = clientGetFocusOrPending (); | ||
2652 | 2646 | if (c2 && (c2 != c) && (c2->win_layer == c->win_layer)) | ||
2653 | 2647 | { | ||
2654 | 2648 | TRACE ("Placing %s under %s", c->name, c2->name); | ||
2655 | 2649 | clientLower (c, c2->frame); | ||
2656 | 2650 | } | ||
2657 | 2651 | else | ||
2658 | 2652 | { | ||
2659 | 2653 | TRACE ("Placing %s on top of its layer %lu", c->name, c->win_layer); | ||
2660 | 2654 | clientRaise (c, None); | ||
2661 | 2655 | } | ||
2662 | 2656 | } | ||
2663 | 2657 | |||
2664 | 2658 | void | ||
2665 | 2659 | clientShade (Client *c) | ||
2666 | 2660 | { | ||
2667 | 2661 | XWindowChanges wc; | ||
2668 | 2662 | ScreenInfo *screen_info; | ||
2669 | 2663 | DisplayInfo *display_info; | ||
2670 | 2664 | unsigned long mask; | ||
2671 | 2665 | |||
2672 | 2666 | g_return_if_fail (c != NULL); | ||
2673 | 2667 | TRACE ("entering clientToggleShaded"); | ||
2674 | 2668 | TRACE ("shading client \"%s\" (0x%lx)", c->name, c->window); | ||
2675 | 2669 | |||
2676 | 2670 | if (!FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER) | ||
2677 | 2671 | || FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
2678 | 2672 | { | ||
2679 | 2673 | TRACE ("cowardly refusing to shade \"%s\" (0x%lx) because it has no border", c->name, c->window); | ||
2680 | 2674 | return; | ||
2681 | 2675 | } | ||
2682 | 2676 | else if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
2683 | 2677 | { | ||
2684 | 2678 | TRACE ("\"%s\" (0x%lx) is already shaded", c->name, c->window); | ||
2685 | 2679 | return; | ||
2686 | 2680 | } | ||
2687 | 2681 | |||
2688 | 2682 | screen_info = c->screen_info; | ||
2689 | 2683 | display_info = screen_info->display_info; | ||
2690 | 2684 | |||
2691 | 2685 | FLAG_SET (c->flags, CLIENT_FLAG_SHADED); | ||
2692 | 2686 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
2693 | 2687 | { | ||
2694 | 2688 | mask = (CWWidth | CWHeight); | ||
2695 | 2689 | if (clientConstrainPos (c, FALSE)) | ||
2696 | 2690 | { | ||
2697 | 2691 | wc.x = c->x; | ||
2698 | 2692 | wc.y = c->y; | ||
2699 | 2693 | mask |= (CWX | CWY); | ||
2700 | 2694 | } | ||
2701 | 2695 | |||
2702 | 2696 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
2703 | 2697 | { | ||
2704 | 2698 | c->ignore_unmap++; | ||
2705 | 2699 | } | ||
2706 | 2700 | /* | ||
2707 | 2701 | * Shading unmaps the client window. We therefore have to transfer focus to its frame | ||
2708 | 2702 | * so that focus doesn't return to root. clientSetFocus() will take care of focusing | ||
2709 | 2703 | * the window frame since the SHADED flag is now set. | ||
2710 | 2704 | */ | ||
2711 | 2705 | if (c == clientGetFocus ()) | ||
2712 | 2706 | { | ||
2713 | 2707 | clientSetFocus (screen_info, c, myDisplayGetCurrentTime (display_info), FOCUS_FORCE); | ||
2714 | 2708 | } | ||
2715 | 2709 | XUnmapWindow (display_info->dpy, c->window); | ||
2716 | 2710 | |||
2717 | 2711 | wc.width = c->width; | ||
2718 | 2712 | wc.height = c->height; | ||
2719 | 2713 | clientConfigure (c, &wc, mask, CFG_FORCE_REDRAW); | ||
2720 | 2714 | } | ||
2721 | 2715 | clientSetNetState (c); | ||
2722 | 2716 | } | ||
2723 | 2717 | |||
2724 | 2718 | void | ||
2725 | 2719 | clientUnshade (Client *c) | ||
2726 | 2720 | { | ||
2727 | 2721 | XWindowChanges wc; | ||
2728 | 2722 | ScreenInfo *screen_info; | ||
2729 | 2723 | DisplayInfo *display_info; | ||
2730 | 2724 | |||
2731 | 2725 | g_return_if_fail (c != NULL); | ||
2732 | 2726 | TRACE ("entering clientToggleShaded"); | ||
2733 | 2727 | TRACE ("shading/unshading client \"%s\" (0x%lx)", c->name, c->window); | ||
2734 | 2728 | |||
2735 | 2729 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
2736 | 2730 | { | ||
2737 | 2731 | TRACE ("\"%s\" (0x%lx) is not shaded", c->name, c->window); | ||
2738 | 2732 | return; | ||
2739 | 2733 | } | ||
2740 | 2734 | |||
2741 | 2735 | screen_info = c->screen_info; | ||
2742 | 2736 | display_info = screen_info->display_info; | ||
2743 | 2737 | |||
2744 | 2738 | FLAG_UNSET (c->flags, CLIENT_FLAG_SHADED); | ||
2745 | 2739 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
2746 | 2740 | { | ||
2747 | 2741 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_VISIBLE)) | ||
2748 | 2742 | { | ||
2749 | 2743 | XMapWindow (display_info->dpy, c->window); | ||
2750 | 2744 | } | ||
2751 | 2745 | /* | ||
2752 | 2746 | * Unshading will show the client window, so we need to focus it when unshading. | ||
2753 | 2747 | */ | ||
2754 | 2748 | if (c == clientGetFocus ()) | ||
2755 | 2749 | { | ||
2756 | 2750 | clientSetFocus (screen_info, c, myDisplayGetCurrentTime (display_info), FOCUS_FORCE); | ||
2757 | 2751 | } | ||
2758 | 2752 | |||
2759 | 2753 | wc.width = c->width; | ||
2760 | 2754 | wc.height = c->height; | ||
2761 | 2755 | clientConfigure (c, &wc, CWWidth | CWHeight, CFG_FORCE_REDRAW); | ||
2762 | 2756 | } | ||
2763 | 2757 | clientSetNetState (c); | ||
2764 | 2758 | } | ||
2765 | 2759 | |||
2766 | 2760 | void | ||
2767 | 2761 | clientToggleShaded (Client *c) | ||
2768 | 2762 | { | ||
2769 | 2763 | if (FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)) | ||
2770 | 2764 | { | ||
2771 | 2765 | clientUnshade (c); | ||
2772 | 2766 | } | ||
2773 | 2767 | else | ||
2774 | 2768 | { | ||
2775 | 2769 | clientShade (c); | ||
2776 | 2770 | } | ||
2777 | 2771 | } | ||
2778 | 2772 | |||
2779 | 2773 | void | ||
2780 | 2774 | clientStick (Client *c, gboolean include_transients) | ||
2781 | 2775 | { | ||
2782 | 2776 | ScreenInfo *screen_info; | ||
2783 | 2777 | DisplayInfo *display_info; | ||
2784 | 2778 | Client *c2; | ||
2785 | 2779 | GList *list_of_windows; | ||
2786 | 2780 | GList *list; | ||
2787 | 2781 | |||
2788 | 2782 | g_return_if_fail (c != NULL); | ||
2789 | 2783 | TRACE ("entering clientStick"); | ||
2790 | 2784 | |||
2791 | 2785 | screen_info = c->screen_info; | ||
2792 | 2786 | display_info = screen_info->display_info; | ||
2793 | 2787 | |||
2794 | 2788 | if (include_transients) | ||
2795 | 2789 | { | ||
2796 | 2790 | list_of_windows = clientListTransientOrModal (c); | ||
2797 | 2791 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
2798 | 2792 | { | ||
2799 | 2793 | c2 = (Client *) list->data; | ||
2800 | 2794 | TRACE ("Sticking client \"%s\" (0x%lx)", c2->name, c2->window); | ||
2801 | 2795 | FLAG_SET (c2->flags, CLIENT_FLAG_STICKY); | ||
2802 | 2796 | setHint (display_info, c2->window, NET_WM_DESKTOP, (unsigned long) ALL_WORKSPACES); | ||
2803 | 2797 | frameQueueDraw (c2, FALSE); | ||
2804 | 2798 | } | ||
2805 | 2799 | g_list_free (list_of_windows); | ||
2806 | 2800 | } | ||
2807 | 2801 | else | ||
2808 | 2802 | { | ||
2809 | 2803 | TRACE ("Sticking client \"%s\" (0x%lx)", c->name, c->window); | ||
2810 | 2804 | FLAG_SET (c->flags, CLIENT_FLAG_STICKY); | ||
2811 | 2805 | setHint (display_info, c->window, NET_WM_DESKTOP, (unsigned long) ALL_WORKSPACES); | ||
2812 | 2806 | } | ||
2813 | 2807 | clientSetWorkspace (c, screen_info->current_ws, TRUE); | ||
2814 | 2808 | clientSetNetState (c); | ||
2815 | 2809 | } | ||
2816 | 2810 | |||
2817 | 2811 | void | ||
2818 | 2812 | clientUnstick (Client *c, gboolean include_transients) | ||
2819 | 2813 | { | ||
2820 | 2814 | ScreenInfo *screen_info; | ||
2821 | 2815 | DisplayInfo *display_info; | ||
2822 | 2816 | Client *c2; | ||
2823 | 2817 | GList *list_of_windows; | ||
2824 | 2818 | GList *list; | ||
2825 | 2819 | |||
2826 | 2820 | g_return_if_fail (c != NULL); | ||
2827 | 2821 | TRACE ("entering clientUnstick"); | ||
2828 | 2822 | |||
2829 | 2823 | screen_info = c->screen_info; | ||
2830 | 2824 | display_info = screen_info->display_info; | ||
2831 | 2825 | |||
2832 | 2826 | if (include_transients) | ||
2833 | 2827 | { | ||
2834 | 2828 | list_of_windows = clientListTransientOrModal (c); | ||
2835 | 2829 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
2836 | 2830 | { | ||
2837 | 2831 | c2 = (Client *) list->data; | ||
2838 | 2832 | TRACE ("Unsticking client \"%s\" (0x%lx)", c2->name, c2->window); | ||
2839 | 2833 | FLAG_UNSET (c2->flags, CLIENT_FLAG_STICKY); | ||
2840 | 2834 | setHint (display_info, c2->window, NET_WM_DESKTOP, (unsigned long) screen_info->current_ws); | ||
2841 | 2835 | frameQueueDraw (c2, FALSE); | ||
2842 | 2836 | } | ||
2843 | 2837 | g_list_free (list_of_windows); | ||
2844 | 2838 | } | ||
2845 | 2839 | else | ||
2846 | 2840 | { | ||
2847 | 2841 | TRACE ("Unsticking client \"%s\" (0x%lx)", c->name, c->window); | ||
2848 | 2842 | FLAG_UNSET (c->flags, CLIENT_FLAG_STICKY); | ||
2849 | 2843 | setHint (display_info, c->window, NET_WM_DESKTOP, (unsigned long) screen_info->current_ws); | ||
2850 | 2844 | } | ||
2851 | 2845 | clientSetWorkspace (c, screen_info->current_ws, TRUE); | ||
2852 | 2846 | clientSetNetState (c); | ||
2853 | 2847 | } | ||
2854 | 2848 | |||
2855 | 2849 | void | ||
2856 | 2850 | clientToggleSticky (Client *c, gboolean include_transients) | ||
2857 | 2851 | { | ||
2858 | 2852 | g_return_if_fail (c != NULL); | ||
2859 | 2853 | TRACE ("entering clientToggleSticky"); | ||
2860 | 2854 | TRACE ("sticking/unsticking client \"%s\" (0x%lx)", c->name, c->window); | ||
2861 | 2855 | |||
2862 | 2856 | if (FLAG_TEST (c->flags, CLIENT_FLAG_STICKY)) | ||
2863 | 2857 | { | ||
2864 | 2858 | clientUnstick (c, include_transients); | ||
2865 | 2859 | } | ||
2866 | 2860 | else | ||
2867 | 2861 | { | ||
2868 | 2862 | clientStick (c, include_transients); | ||
2869 | 2863 | } | ||
2870 | 2864 | } | ||
2871 | 2865 | |||
2872 | 2866 | void | ||
2873 | 2867 | clientUpdateFullscreenSize (Client *c) | ||
2874 | 2868 | { | ||
2875 | 2869 | ScreenInfo *screen_info; | ||
2876 | 2870 | XWindowChanges wc; | ||
2877 | 2871 | GdkRectangle monitor, rect; | ||
2878 | 2872 | int i; | ||
2879 | 2873 | |||
2880 | 2874 | g_return_if_fail (c != NULL); | ||
2881 | 2875 | TRACE ("entering clientUpdateFullscreenSize"); | ||
2882 | 2876 | TRACE ("Update fullscreen size for client \"%s\" (0x%lx)", c->name, c->window); | ||
2883 | 2877 | |||
2884 | 2878 | screen_info = c->screen_info; | ||
2885 | 2879 | |||
2886 | 2880 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
2887 | 2881 | { | ||
2888 | 2882 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREN_MONITORS)) | ||
2889 | 2883 | { | ||
2890 | 2884 | gdk_screen_get_monitor_geometry (screen_info->gscr, c->fullscreen_monitors[0], &rect); | ||
2891 | 2885 | for (i = 1; i < 4; i++) | ||
2892 | 2886 | { | ||
2893 | 2887 | gdk_screen_get_monitor_geometry (screen_info->gscr, c->fullscreen_monitors[i], &monitor); | ||
2894 | 2888 | gdk_rectangle_union (&rect, &monitor, &rect); | ||
2895 | 2889 | } | ||
2896 | 2890 | } | ||
2897 | 2891 | else | ||
2898 | 2892 | { | ||
2899 | 2893 | int cx, cy; | ||
2900 | 2894 | |||
2901 | 2895 | cx = frameX (c) + (frameWidth (c) / 2); | ||
2902 | 2896 | cy = frameY (c) + (frameHeight (c) / 2); | ||
2903 | 2897 | |||
2904 | 2898 | myScreenFindMonitorAtPoint (screen_info, cx, cy, &rect); | ||
2905 | 2899 | } | ||
2906 | 2900 | |||
2907 | 2901 | wc.x = rect.x; | ||
2908 | 2902 | wc.y = rect.y; | ||
2909 | 2903 | wc.width = rect.width; | ||
2910 | 2904 | wc.height = rect.height; | ||
2911 | 2905 | } | ||
2912 | 2906 | |||
2913 | 2907 | else | ||
2914 | 2908 | { | ||
2915 | 2909 | wc.x = c->fullscreen_old_x; | ||
2916 | 2910 | wc.y = c->fullscreen_old_y; | ||
2917 | 2911 | wc.width = c->fullscreen_old_width; | ||
2918 | 2912 | wc.height = c->fullscreen_old_height; | ||
2919 | 2913 | } | ||
2920 | 2914 | |||
2921 | 2915 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
2922 | 2916 | { | ||
2923 | 2917 | clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, CFG_FORCE_REDRAW); | ||
2924 | 2918 | } | ||
2925 | 2919 | else | ||
2926 | 2920 | { | ||
2927 | 2921 | c->x = wc.x; | ||
2928 | 2922 | c->y = wc.y; | ||
2929 | 2923 | c->height = wc.height; | ||
2930 | 2924 | c->width = wc.width; | ||
2931 | 2925 | } | ||
2932 | 2926 | } | ||
2933 | 2927 | |||
2934 | 2928 | void clientToggleFullscreen (Client *c) | ||
2935 | 2929 | { | ||
2936 | 2930 | g_return_if_fail (c != NULL); | ||
2937 | 2931 | TRACE ("entering clientToggleFullscreen"); | ||
2938 | 2932 | TRACE ("toggle fullscreen client \"%s\" (0x%lx)", c->name, c->window); | ||
2939 | 2933 | |||
2940 | 2934 | /*can we switch to full screen, does it make any sense? */ | ||
2941 | 2935 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN) && (c->size->flags & PMaxSize)) | ||
2942 | 2936 | { | ||
2943 | 2937 | GdkRectangle rect; | ||
2944 | 2938 | int cx, cy; | ||
2945 | 2939 | |||
2946 | 2940 | cx = frameX (c) + (frameWidth (c) / 2); | ||
2947 | 2941 | cy = frameY (c) + (frameHeight (c) / 2); | ||
2948 | 2942 | |||
2949 | 2943 | myScreenFindMonitorAtPoint (c->screen_info, cx, cy, &rect); | ||
2950 | 2944 | |||
2951 | 2945 | if ((c->size->max_width < rect.width) || (c->size->max_height < rect.height)) | ||
2952 | 2946 | { | ||
2953 | 2947 | return; | ||
2954 | 2948 | } | ||
2955 | 2949 | } | ||
2956 | 2950 | |||
2957 | 2951 | if (!clientIsTransientOrModal (c) && (c->type == WINDOW_NORMAL)) | ||
2958 | 2952 | { | ||
2959 | 2953 | FLAG_TOGGLE (c->flags, CLIENT_FLAG_FULLSCREEN); | ||
2960 | 2954 | clientUpdateFullscreenState (c); | ||
2961 | 2955 | } | ||
2962 | 2956 | } | ||
2963 | 2957 | |||
2964 | 2958 | void clientSetFullscreenMonitor (Client *c, gint top, gint bottom, gint left, gint right) | ||
2965 | 2959 | { | ||
2966 | 2960 | ScreenInfo *screen_info; | ||
2967 | 2961 | DisplayInfo *display_info; | ||
2968 | 2962 | gint num_monitors; | ||
2969 | 2963 | |||
2970 | 2964 | g_return_if_fail (c != NULL); | ||
2971 | 2965 | TRACE ("entering clientSetFullscreenMonitor"); | ||
2972 | 2966 | |||
2973 | 2967 | screen_info = c->screen_info; | ||
2974 | 2968 | display_info = screen_info->display_info; | ||
2975 | 2969 | |||
2976 | 2970 | num_monitors = gdk_screen_get_n_monitors (screen_info->gscr); | ||
2977 | 2971 | if ((top >= 0) && (top < num_monitors) && | ||
2978 | 2972 | (bottom >= 0) && (bottom < num_monitors) && | ||
2979 | 2973 | (left >= 0) && (left < num_monitors) && | ||
2980 | 2974 | (right >= 0) && (right < num_monitors)) | ||
2981 | 2975 | { | ||
2982 | 2976 | c->fullscreen_monitors[0] = top; | ||
2983 | 2977 | c->fullscreen_monitors[1] = bottom; | ||
2984 | 2978 | c->fullscreen_monitors[2] = left; | ||
2985 | 2979 | c->fullscreen_monitors[3] = right; | ||
2986 | 2980 | FLAG_SET (c->flags, CLIENT_FLAG_FULLSCREN_MONITORS); | ||
2987 | 2981 | } | ||
2988 | 2982 | else | ||
2989 | 2983 | { | ||
2990 | 2984 | c->fullscreen_monitors[0] = 0; | ||
2991 | 2985 | c->fullscreen_monitors[1] = 0; | ||
2992 | 2986 | c->fullscreen_monitors[2] = 0; | ||
2993 | 2987 | c->fullscreen_monitors[3] = 0; | ||
2994 | 2988 | FLAG_UNSET (c->flags, CLIENT_FLAG_FULLSCREN_MONITORS); | ||
2995 | 2989 | } | ||
2996 | 2990 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
2997 | 2991 | { | ||
2998 | 2992 | clientUpdateFullscreenSize (c); | ||
2999 | 2993 | } | ||
3000 | 2994 | if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREN_MONITORS)) | ||
3001 | 2995 | { | ||
3002 | 2996 | setNetFullscreenMonitors (display_info, c->window, top, bottom, left, right); | ||
3003 | 2997 | } | ||
3004 | 2998 | } | ||
3005 | 2999 | |||
3006 | 3000 | void clientToggleLayerAbove (Client *c) | ||
3007 | 3001 | { | ||
3008 | 3002 | g_return_if_fail (c != NULL); | ||
3009 | 3003 | TRACE ("entering clientToggleAbove"); | ||
3010 | 3004 | |||
3011 | 3005 | if ((c->type & WINDOW_REGULAR_FOCUSABLE) && | ||
3012 | 3006 | !clientIsTransientOrModal (c) && | ||
3013 | 3007 | !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
3014 | 3008 | { | ||
3015 | 3009 | FLAG_UNSET (c->flags, CLIENT_FLAG_BELOW); | ||
3016 | 3010 | FLAG_TOGGLE (c->flags, CLIENT_FLAG_ABOVE); | ||
3017 | 3011 | clientUpdateLayerState (c); | ||
3018 | 3012 | } | ||
3019 | 3013 | } | ||
3020 | 3014 | |||
3021 | 3015 | void clientToggleLayerBelow (Client *c) | ||
3022 | 3016 | { | ||
3023 | 3017 | g_return_if_fail (c != NULL); | ||
3024 | 3018 | TRACE ("entering clientToggleBelow"); | ||
3025 | 3019 | |||
3026 | 3020 | if ((c->type & WINDOW_REGULAR_FOCUSABLE) && | ||
3027 | 3021 | !clientIsTransientOrModal (c) && | ||
3028 | 3022 | !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
3029 | 3023 | { | ||
3030 | 3024 | FLAG_UNSET (c->flags, CLIENT_FLAG_ABOVE); | ||
3031 | 3025 | FLAG_TOGGLE (c->flags, CLIENT_FLAG_BELOW); | ||
3032 | 3026 | clientUpdateLayerState (c); | ||
3033 | 3027 | } | ||
3034 | 3028 | } | ||
3035 | 3029 | |||
3036 | 3030 | void clientSetLayerNormal (Client *c) | ||
3037 | 3031 | { | ||
3038 | 3032 | g_return_if_fail (c != NULL); | ||
3039 | 3033 | TRACE ("entering clientSetLayerNormal"); | ||
3040 | 3034 | |||
3041 | 3035 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
3042 | 3036 | { | ||
3043 | 3037 | FLAG_UNSET (c->flags, CLIENT_FLAG_ABOVE | CLIENT_FLAG_BELOW); | ||
3044 | 3038 | clientUpdateLayerState (c); | ||
3045 | 3039 | } | ||
3046 | 3040 | } | ||
3047 | 3041 | |||
3048 | 3042 | void | ||
3049 | 3043 | clientRemoveMaximizeFlag (Client *c) | ||
3050 | 3044 | { | ||
3051 | 3045 | g_return_if_fail (c != NULL); | ||
3052 | 3046 | TRACE ("entering clientRemoveMaximizeFlag"); | ||
3053 | 3047 | TRACE ("Removing maximize flag on client \"%s\" (0x%lx)", c->name, | ||
3054 | 3048 | c->window); | ||
3055 | 3049 | |||
3056 | 3050 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED); | ||
3057 | 3051 | frameQueueDraw (c, FALSE); | ||
3058 | 3052 | clientSetNetActions (c); | ||
3059 | 3053 | clientSetNetState (c); | ||
3060 | 3054 | } | ||
3061 | 3055 | |||
3062 | 3056 | static void | ||
3063 | 3057 | clientNewMaxState (Client *c, XWindowChanges *wc, int mode) | ||
3064 | 3058 | { | ||
3065 | 3059 | if (FLAG_TEST_ALL (mode, CLIENT_FLAG_MAXIMIZED)) | ||
3066 | 3060 | { | ||
3067 | 3061 | /* | ||
3068 | 3062 | * We need to test specifically for full de-maximization | ||
3069 | 3063 | * otherwise it's too confusing when the window changes | ||
3070 | 3064 | * from horiz to vertical maximization or vice-versa. | ||
3071 | 3065 | */ | ||
3072 | 3066 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
3073 | 3067 | { | ||
3074 | 3068 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED); | ||
3075 | 3069 | wc->x = c->old_x; | ||
3076 | 3070 | wc->y = c->old_y; | ||
3077 | 3071 | wc->width = c->old_width; | ||
3078 | 3072 | wc->height = c->old_height; | ||
3079 | 3073 | |||
3080 | 3074 | return; | ||
3081 | 3075 | } | ||
3082 | 3076 | } | ||
3083 | 3077 | |||
3084 | 3078 | if (FLAG_TEST (mode, CLIENT_FLAG_MAXIMIZED_HORIZ)) | ||
3085 | 3079 | { | ||
3086 | 3080 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ)) | ||
3087 | 3081 | { | ||
3088 | 3082 | FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ); | ||
3089 | 3083 | } | ||
3090 | 3084 | else | ||
3091 | 3085 | { | ||
3092 | 3086 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ); | ||
3093 | 3087 | wc->x = c->old_x; | ||
3094 | 3088 | wc->y = c->old_y; | ||
3095 | 3089 | wc->width = c->old_width; | ||
3096 | 3090 | wc->height = c->old_height; | ||
3097 | 3091 | } | ||
3098 | 3092 | } | ||
3099 | 3093 | |||
3100 | 3094 | if (FLAG_TEST (mode, CLIENT_FLAG_MAXIMIZED_VERT)) | ||
3101 | 3095 | { | ||
3102 | 3096 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT)) | ||
3103 | 3097 | { | ||
3104 | 3098 | FLAG_SET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT); | ||
3105 | 3099 | } | ||
3106 | 3100 | else | ||
3107 | 3101 | { | ||
3108 | 3102 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED_VERT); | ||
3109 | 3103 | wc->x = c->old_x; | ||
3110 | 3104 | wc->y = c->old_y; | ||
3111 | 3105 | wc->width = c->old_width; | ||
3112 | 3106 | wc->height = c->old_height; | ||
3113 | 3107 | } | ||
3114 | 3108 | } | ||
3115 | 3109 | } | ||
3116 | 3110 | |||
3117 | 3111 | static gboolean | ||
3118 | 3112 | clientNewMaxSize (Client *c, XWindowChanges *wc, GdkRectangle *rect, tilePositionType tile) | ||
3119 | 3113 | { | ||
3120 | 3114 | ScreenInfo *screen_info; | ||
3121 | 3115 | int full_x, full_y, full_w, full_h; | ||
3122 | 3116 | int tmp_x, tmp_y, tmp_w, tmp_h; | ||
3123 | 3117 | |||
3124 | 3118 | tmp_x = frameX (c); | ||
3125 | 3119 | tmp_y = frameY (c); | ||
3126 | 3120 | tmp_h = frameHeight (c); | ||
3127 | 3121 | tmp_w = frameWidth (c); | ||
3128 | 3122 | screen_info = c->screen_info; | ||
3129 | 3123 | |||
3130 | 3124 | full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect->x); | ||
3131 | 3125 | full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect->y); | ||
3132 | 3126 | full_w = MIN (screen_info->width - screen_info->params->xfwm_margins[STRUTS_RIGHT], | ||
3133 | 3127 | rect->x + rect->width) - full_x; | ||
3134 | 3128 | full_h = MIN (screen_info->height - screen_info->params->xfwm_margins[STRUTS_BOTTOM], | ||
3135 | 3129 | rect->y + rect->height) - full_y; | ||
3136 | 3130 | |||
3137 | 3131 | if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
3138 | 3132 | { | ||
3139 | 3133 | /* Adjust size to the largest size available, not covering struts */ | ||
3140 | 3134 | clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h); | ||
3141 | 3135 | wc->x = full_x + frameLeft (c); | ||
3142 | 3136 | wc->y = full_y + frameTop (c); | ||
3143 | 3137 | wc->width = full_w - frameLeft (c) - frameRight (c); | ||
3144 | 3138 | wc->height = full_h - frameTop (c) - frameBottom (c); | ||
3145 | 3139 | |||
3146 | 3140 | return ((wc->width <= c->size->max_width) && (wc->height <= c->size->max_height)); | ||
3147 | 3141 | } | ||
3148 | 3142 | |||
3149 | 3143 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_HORIZ)) | ||
3150 | 3144 | { | ||
3151 | 3145 | /* Adjust size to the widest size available, for the current vertical position/height */ | ||
3152 | 3146 | switch (tile) | ||
3153 | 3147 | { | ||
3154 | 3148 | case TILE_UP: | ||
3155 | 3149 | tmp_h = full_h / 2; | ||
3156 | 3150 | tmp_y = full_y; | ||
3157 | 3151 | clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h); | ||
3158 | 3152 | wc->y = tmp_y + frameTop (c); | ||
3159 | 3153 | wc->height = tmp_h - frameTop (c) - frameBottom (c); | ||
3160 | 3154 | break; | ||
3161 | 3155 | case TILE_DOWN: | ||
3162 | 3156 | tmp_h = full_h / 2; | ||
3163 | 3157 | tmp_y = full_y + full_h / 2; | ||
3164 | 3158 | clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h); | ||
3165 | 3159 | wc->y = tmp_y + frameTop (c); | ||
3166 | 3160 | wc->height = tmp_h - frameTop (c) - frameBottom (c); | ||
3167 | 3161 | break; | ||
3168 | 3162 | default: | ||
3169 | 3163 | clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h); | ||
3170 | 3164 | break; | ||
3171 | 3165 | } | ||
3172 | 3166 | |||
3173 | 3167 | wc->x = full_x + frameLeft (c); | ||
3174 | 3168 | wc->width = full_w - frameLeft (c) - frameRight (c); | ||
3175 | 3169 | |||
3176 | 3170 | return (wc->width <= c->size->max_width); | ||
3177 | 3171 | } | ||
3178 | 3172 | |||
3179 | 3173 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED_VERT)) | ||
3180 | 3174 | { | ||
3181 | 3175 | /* Adjust size to the tallest size available, for the current horizontal position/width */ | ||
3182 | 3176 | switch (tile) | ||
3183 | 3177 | { | ||
3184 | 3178 | case TILE_LEFT: | ||
3185 | 3179 | tmp_x = full_x; | ||
3186 | 3180 | tmp_w = full_w / 2; | ||
3187 | 3181 | clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h); | ||
3188 | 3182 | wc->x = tmp_x + frameLeft (c); | ||
3189 | 3183 | wc->width = tmp_w - frameLeft (c) - frameRight (c); | ||
3190 | 3184 | break; | ||
3191 | 3185 | case TILE_RIGHT: | ||
3192 | 3186 | tmp_x = full_x + full_w /2; | ||
3193 | 3187 | tmp_w = full_w / 2; | ||
3194 | 3188 | clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h); | ||
3195 | 3189 | wc->x = tmp_x + frameLeft (c); | ||
3196 | 3190 | wc->width = tmp_w - frameLeft (c) - frameRight (c); | ||
3197 | 3191 | break; | ||
3198 | 3192 | default: | ||
3199 | 3193 | clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h); | ||
3200 | 3194 | break; | ||
3201 | 3195 | } | ||
3202 | 3196 | |||
3203 | 3197 | wc->y = full_y + frameTop (c); | ||
3204 | 3198 | wc->height = full_h - frameTop (c) - frameBottom (c); | ||
3205 | 3199 | |||
3206 | 3200 | return (wc->height <= c->size->max_height); | ||
3207 | 3201 | } | ||
3208 | 3202 | |||
3209 | 3203 | return TRUE; | ||
3210 | 3204 | } | ||
3211 | 3205 | |||
3212 | 3206 | gboolean | ||
3213 | 3207 | clientToggleMaximized (Client *c, int mode, gboolean restore_position) | ||
3214 | 3208 | { | ||
3215 | 3209 | DisplayInfo *display_info; | ||
3216 | 3210 | ScreenInfo *screen_info; | ||
3217 | 3211 | XWindowChanges wc; | ||
3218 | 3212 | GdkRectangle rect; | ||
3219 | 3213 | unsigned long old_flags; | ||
3220 | 3214 | |||
3221 | 3215 | g_return_val_if_fail (c != NULL, FALSE); | ||
3222 | 3216 | |||
3223 | 3217 | TRACE ("entering clientToggleMaximized"); | ||
3224 | 3218 | TRACE ("maximzing/unmaximizing client \"%s\" (0x%lx)", c->name, c->window); | ||
3225 | 3219 | |||
3226 | 3220 | if (!CLIENT_CAN_MAXIMIZE_WINDOW (c)) | ||
3227 | 3221 | { | ||
3228 | 3222 | return FALSE; | ||
3229 | 3223 | } | ||
3230 | 3224 | |||
3231 | 3225 | screen_info = c->screen_info; | ||
3232 | 3226 | display_info = screen_info->display_info; | ||
3233 | 3227 | myScreenFindMonitorAtPoint (screen_info, | ||
3234 | 3228 | frameX (c) + (frameWidth (c) / 2), | ||
3235 | 3229 | frameY (c) + (frameHeight (c) / 2), &rect); | ||
3236 | 3230 | |||
3237 | 3231 | wc.x = c->x; | ||
3238 | 3232 | wc.y = c->y; | ||
3239 | 3233 | wc.width = c->width; | ||
3240 | 3234 | wc.height = c->height; | ||
3241 | 3235 | |||
3242 | 3236 | if (restore_position && | ||
3243 | 3237 | FLAG_TEST (mode, CLIENT_FLAG_MAXIMIZED) && | ||
3244 | 3238 | !FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
3245 | 3239 | { | ||
3246 | 3240 | clientSaveSizePos (c); | ||
3247 | 3241 | } | ||
3248 | 3242 | |||
3249 | 3243 | old_flags = c->flags; | ||
3250 | 3244 | |||
3251 | 3245 | /* 1) Compute the new state */ | ||
3252 | 3246 | clientNewMaxState (c, &wc, mode); | ||
3253 | 3247 | |||
3254 | 3248 | /* 2) Compute the new size, based on the state */ | ||
3255 | 3249 | if (!clientNewMaxSize (c, &wc, &rect, TILE_NONE)) | ||
3256 | 3250 | { | ||
3257 | 3251 | c->flags = old_flags; | ||
3258 | 3252 | return FALSE; | ||
3259 | 3253 | } | ||
3260 | 3254 | |||
3261 | 3255 | /* 3) Update size and position fields */ | ||
3262 | 3256 | c->x = wc.x; | ||
3263 | 3257 | c->y = wc.y; | ||
3264 | 3258 | c->height = wc.height; | ||
3265 | 3259 | c->width = wc.width; | ||
3266 | 3260 | |||
3267 | 3261 | /* Maximizing may remove decoration on the side, update NET_FRAME_EXTENTS accordingly */ | ||
3268 | 3262 | setNetFrameExtents (display_info, | ||
3269 | 3263 | c->window, | ||
3270 | 3264 | frameTop (c), | ||
3271 | 3265 | frameLeft (c), | ||
3272 | 3266 | frameRight (c), | ||
3273 | 3267 | frameBottom (c)); | ||
3274 | 3268 | |||
3275 | 3269 | /* Maximized windows w/out border cannot be resized, update allowed actions */ | ||
3276 | 3270 | clientSetNetActions (c); | ||
3277 | 3271 | if (restore_position && FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED)) | ||
3278 | 3272 | { | ||
3279 | 3273 | clientConfigure (c, &wc, CWWidth | CWHeight | CWX | CWY, CFG_FORCE_REDRAW); | ||
3280 | 3274 | } | ||
3281 | 3275 | clientSetNetState (c); | ||
3282 | 3276 | |||
3283 | 3277 | return TRUE; | ||
3284 | 3278 | } | ||
3285 | 3279 | |||
3286 | 3280 | gboolean | ||
3287 | 3281 | clientTile (Client *c, gint cx, gint cy, tilePositionType tile, gboolean send_configure) | ||
3288 | 3282 | { | ||
3289 | 3283 | DisplayInfo *display_info; | ||
3290 | 3284 | ScreenInfo *screen_info; | ||
3291 | 3285 | XWindowChanges wc; | ||
3292 | 3286 | GdkRectangle rect; | ||
3293 | 3287 | unsigned long old_flags; | ||
3294 | 3288 | int mode; | ||
3295 | 3289 | |||
3296 | 3290 | g_return_val_if_fail (c != NULL, FALSE); | ||
3297 | 3291 | |||
3298 | 3292 | TRACE ("entering clientTile"); | ||
3299 | 3293 | TRACE ("Tiling client \"%s\" (0x%lx)", c->name, c->window); | ||
3300 | 3294 | |||
3301 | 3295 | if (!CLIENT_CAN_TILE_WINDOW (c)) | ||
3302 | 3296 | { | ||
3303 | 3297 | return FALSE; | ||
3304 | 3298 | } | ||
3305 | 3299 | |||
3306 | 3300 | screen_info = c->screen_info; | ||
3307 | 3301 | display_info = screen_info->display_info; | ||
3308 | 3302 | myScreenFindMonitorAtPoint (screen_info, cx, cy, &rect); | ||
3309 | 3303 | |||
3310 | 3304 | wc.x = c->x; | ||
3311 | 3305 | wc.y = c->y; | ||
3312 | 3306 | wc.width = c->width; | ||
3313 | 3307 | wc.height = c->height; | ||
3314 | 3308 | |||
3315 | 3309 | switch (tile) | ||
3316 | 3310 | { | ||
3317 | 3311 | case TILE_LEFT: | ||
3318 | 3312 | case TILE_RIGHT: | ||
3319 | 3313 | mode = CLIENT_FLAG_MAXIMIZED_VERT; | ||
3320 | 3314 | break; | ||
3321 | 3315 | case TILE_UP: | ||
3322 | 3316 | case TILE_DOWN: | ||
3323 | 3317 | mode = CLIENT_FLAG_MAXIMIZED_HORIZ; | ||
3324 | 3318 | break; | ||
3325 | 3319 | default: | ||
3326 | 3320 | return FALSE; | ||
3327 | 3321 | break; | ||
3328 | 3322 | } | ||
3329 | 3323 | |||
3330 | 3324 | if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
3331 | 3325 | { | ||
3332 | 3326 | clientSaveSizePos (c); | ||
3333 | 3327 | } | ||
3334 | 3328 | |||
3335 | 3329 | old_flags = c->flags; | ||
3336 | 3330 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED); | ||
3337 | 3331 | clientNewMaxState (c, &wc, mode); | ||
3338 | 3332 | if (!clientNewMaxSize (c, &wc, &rect, tile)) | ||
3339 | 3333 | { | ||
3340 | 3334 | c->flags = old_flags; | ||
3341 | 3335 | return FALSE; | ||
3342 | 3336 | } | ||
3343 | 3337 | |||
3344 | 3338 | c->x = wc.x; | ||
3345 | 3339 | c->y = wc.y; | ||
3346 | 3340 | c->height = wc.height; | ||
3347 | 3341 | c->width = wc.width; | ||
3348 | 3342 | |||
3349 | 3343 | if (send_configure) | ||
3350 | 3344 | { | ||
3351 | 3345 | setNetFrameExtents (display_info, | ||
3352 | 3346 | c->window, | ||
3353 | 3347 | frameTop (c), | ||
3354 | 3348 | frameLeft (c), | ||
3355 | 3349 | frameRight (c), | ||
3356 | 3350 | frameBottom (c)); | ||
3357 | 3351 | |||
3358 | 3352 | clientSetNetActions (c); | ||
3359 | 3353 | |||
3360 | 3354 | clientConfigure (c, &wc, CWWidth | CWHeight | CWX | CWY, CFG_FORCE_REDRAW); | ||
3361 | 3355 | } | ||
3362 | 3356 | clientSetNetState (c); | ||
3363 | 3357 | |||
3364 | 3358 | return TRUE; | ||
3365 | 3359 | } | ||
3366 | 3360 | |||
3367 | 3361 | void | ||
3368 | 3362 | clientUpdateOpacity (Client *c) | ||
3369 | 3363 | { | ||
3370 | 3364 | ScreenInfo *screen_info; | ||
3371 | 3365 | DisplayInfo *display_info; | ||
3372 | 3366 | Client *focused; | ||
3373 | 3367 | gboolean opaque; | ||
3374 | 3368 | |||
3375 | 3369 | g_return_if_fail (c != NULL); | ||
3376 | 3370 | |||
3377 | 3371 | screen_info = c->screen_info; | ||
3378 | 3372 | display_info = screen_info->display_info; | ||
3379 | 3373 | if (!compositorIsUsable (display_info)) | ||
3380 | 3374 | { | ||
3381 | 3375 | return; | ||
3382 | 3376 | } | ||
3383 | 3377 | |||
3384 | 3378 | focused = clientGetFocus (); | ||
3385 | 3379 | opaque = (FLAG_TEST(c->type, WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DONT_FOCUS) | ||
3386 | 3380 | || (focused == c)); | ||
3387 | 3381 | |||
3388 | 3382 | clientSetOpacity (c, c->opacity, OPACITY_INACTIVE, opaque ? 0 : OPACITY_INACTIVE); | ||
3389 | 3383 | } | ||
3390 | 3384 | |||
3391 | 3385 | void | ||
3392 | 3386 | clientUpdateAllOpacity (ScreenInfo *screen_info) | ||
3393 | 3387 | { | ||
3394 | 3388 | DisplayInfo *display_info; | ||
3395 | 3389 | Client *c; | ||
3396 | 3390 | guint i; | ||
3397 | 3391 | |||
3398 | 3392 | g_return_if_fail (screen_info != NULL); | ||
3399 | 3393 | |||
3400 | 3394 | display_info = screen_info->display_info; | ||
3401 | 3395 | if (!compositorIsUsable (display_info)) | ||
3402 | 3396 | { | ||
3403 | 3397 | return; | ||
3404 | 3398 | } | ||
3405 | 3399 | |||
3406 | 3400 | for (c = screen_info->clients, i = 0; i < screen_info->client_count; c = c->next, ++i) | ||
3407 | 3401 | { | ||
3408 | 3402 | clientUpdateOpacity (c); | ||
3409 | 3403 | } | ||
3410 | 3404 | } | ||
3411 | 3405 | |||
3412 | 3406 | void | ||
3413 | 3407 | clientSetOpacity (Client *c, guint opacity, guint clear, guint xor) | ||
3414 | 3408 | { | ||
3415 | 3409 | ScreenInfo *screen_info; | ||
3416 | 3410 | DisplayInfo *display_info; | ||
3417 | 3411 | guint applied; | ||
3418 | 3412 | |||
3419 | 3413 | screen_info = c->screen_info; | ||
3420 | 3414 | display_info = screen_info->display_info; | ||
3421 | 3415 | |||
3422 | 3416 | if (!compositorIsUsable (display_info)) | ||
3423 | 3417 | { | ||
3424 | 3418 | return; | ||
3425 | 3419 | } | ||
3426 | 3420 | |||
3427 | 3421 | c->opacity_flags = (c->opacity_flags & ~clear) ^ xor; | ||
3428 | 3422 | |||
3429 | 3423 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_OPACITY_LOCKED)) | ||
3430 | 3424 | { | ||
3431 | 3425 | applied = c->opacity; | ||
3432 | 3426 | } | ||
3433 | 3427 | else | ||
3434 | 3428 | { | ||
3435 | 3429 | long long multiplier = 1, divisor = 1; | ||
3436 | 3430 | |||
3437 | 3431 | c->opacity = applied = opacity; | ||
3438 | 3432 | |||
3439 | 3433 | if (FLAG_TEST (c->opacity_flags, OPACITY_MOVE)) | ||
3440 | 3434 | { | ||
3441 | 3435 | multiplier *= c->screen_info->params->move_opacity; | ||
3442 | 3436 | divisor *= 100; | ||
3443 | 3437 | } | ||
3444 | 3438 | if (FLAG_TEST (c->opacity_flags, OPACITY_RESIZE)) | ||
3445 | 3439 | { | ||
3446 | 3440 | multiplier *= c->screen_info->params->resize_opacity; | ||
3447 | 3441 | divisor *= 100; | ||
3448 | 3442 | } | ||
3449 | 3443 | if (FLAG_TEST (c->opacity_flags, OPACITY_INACTIVE)) | ||
3450 | 3444 | { | ||
3451 | 3445 | multiplier *= c->screen_info->params->inactive_opacity; | ||
3452 | 3446 | divisor *= 100; | ||
3453 | 3447 | } | ||
3454 | 3448 | |||
3455 | 3449 | applied = (guint) ((long long) applied * multiplier / divisor); | ||
3456 | 3450 | } | ||
3457 | 3451 | |||
3458 | 3452 | if (applied != c->opacity_applied) | ||
3459 | 3453 | { | ||
3460 | 3454 | c->opacity_applied = applied; | ||
3461 | 3455 | compositorWindowSetOpacity (display_info, c->frame, applied); | ||
3462 | 3456 | } | ||
3463 | 3457 | } | ||
3464 | 3458 | |||
3465 | 3459 | void | ||
3466 | 3460 | clientDecOpacity (Client *c) | ||
3467 | 3461 | { | ||
3468 | 3462 | ScreenInfo *screen_info; | ||
3469 | 3463 | DisplayInfo *display_info; | ||
3470 | 3464 | |||
3471 | 3465 | screen_info = c->screen_info; | ||
3472 | 3466 | display_info = screen_info->display_info; | ||
3473 | 3467 | |||
3474 | 3468 | if (!compositorIsUsable (display_info)) | ||
3475 | 3469 | { | ||
3476 | 3470 | return; | ||
3477 | 3471 | } | ||
3478 | 3472 | |||
3479 | 3473 | if ((c->opacity > OPACITY_SET_MIN) && !(FLAG_TEST (c->xfwm_flags, XFWM_FLAG_OPACITY_LOCKED))) | ||
3480 | 3474 | { | ||
3481 | 3475 | clientSetOpacity (c, c->opacity - OPACITY_SET_STEP, 0, 0); | ||
3482 | 3476 | } | ||
3483 | 3477 | } | ||
3484 | 3478 | |||
3485 | 3479 | void | ||
3486 | 3480 | clientIncOpacity (Client *c) | ||
3487 | 3481 | { | ||
3488 | 3482 | ScreenInfo *screen_info; | ||
3489 | 3483 | DisplayInfo *display_info; | ||
3490 | 3484 | |||
3491 | 3485 | screen_info = c->screen_info; | ||
3492 | 3486 | display_info = screen_info->display_info; | ||
3493 | 3487 | |||
3494 | 3488 | if (!compositorIsUsable (display_info)) | ||
3495 | 3489 | { | ||
3496 | 3490 | return; | ||
3497 | 3491 | } | ||
3498 | 3492 | |||
3499 | 3493 | if ((c->opacity < NET_WM_OPAQUE) && !(FLAG_TEST (c->xfwm_flags, XFWM_FLAG_OPACITY_LOCKED))) | ||
3500 | 3494 | { | ||
3501 | 3495 | guint opacity = c->opacity + OPACITY_SET_STEP; | ||
3502 | 3496 | |||
3503 | 3497 | if (opacity < OPACITY_SET_MIN) | ||
3504 | 3498 | { | ||
3505 | 3499 | opacity = NET_WM_OPAQUE; | ||
3506 | 3500 | } | ||
3507 | 3501 | clientSetOpacity (c, opacity, 0, 0); | ||
3508 | 3502 | } | ||
3509 | 3503 | } | ||
3510 | 3504 | |||
3511 | 3505 | /* Xrandr stuff: on screen size change, make sure all clients are still visible */ | ||
3512 | 3506 | void | ||
3513 | 3507 | clientScreenResize(ScreenInfo *screen_info, gboolean fully_visible) | ||
3514 | 3508 | { | ||
3515 | 3509 | Client *c = NULL; | ||
3516 | 3510 | GList *list, *list_of_windows; | ||
3517 | 3511 | XWindowChanges wc; | ||
3518 | 3512 | unsigned short configure_flags; | ||
3519 | 3513 | |||
3520 | 3514 | list_of_windows = clientGetStackList (screen_info); | ||
3521 | 3515 | |||
3522 | 3516 | if (!list_of_windows) | ||
3523 | 3517 | { | ||
3524 | 3518 | return; | ||
3525 | 3519 | } | ||
3526 | 3520 | |||
3527 | 3521 | /* Revalidate client struts */ | ||
3528 | 3522 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
3529 | 3523 | { | ||
3530 | 3524 | c = (Client *) list->data; | ||
3531 | 3525 | if (FLAG_TEST (c->flags, CLIENT_FLAG_HAS_STRUT)) | ||
3532 | 3526 | { | ||
3533 | 3527 | clientValidateNetStrut (c); | ||
3534 | 3528 | } | ||
3535 | 3529 | } | ||
3536 | 3530 | |||
3537 | 3531 | for (list = list_of_windows; list; list = g_list_next (list)) | ||
3538 | 3532 | { | ||
3539 | 3533 | unsigned long maximization_flags = 0L; | ||
3540 | 3534 | |||
3541 | 3535 | c = (Client *) list->data; | ||
3542 | 3536 | if (!CONSTRAINED_WINDOW (c)) | ||
3543 | 3537 | { | ||
3544 | 3538 | continue; | ||
3545 | 3539 | } | ||
3546 | 3540 | |||
3547 | 3541 | /* Recompute size and position of maximized windows */ | ||
3548 | 3542 | if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED)) | ||
3549 | 3543 | { | ||
3550 | 3544 | maximization_flags = c->flags & CLIENT_FLAG_MAXIMIZED; | ||
3551 | 3545 | |||
3552 | 3546 | /* Force an update by clearing the internal flags */ | ||
3553 | 3547 | FLAG_UNSET (c->flags, CLIENT_FLAG_MAXIMIZED); | ||
3554 | 3548 | clientToggleMaximized (c, maximization_flags, FALSE); | ||
3555 | 3549 | |||
3556 | 3550 | wc.x = c->x; | ||
3557 | 3551 | wc.y = c->y; | ||
3558 | 3552 | wc.width = c->width; | ||
3559 | 3553 | wc.height = c->height; | ||
3560 | 3554 | clientConfigure (c, &wc, CWX | CWY | CWWidth | CWHeight, CFG_NOTIFY); | ||
3561 | 3555 | } | ||
3562 | 3556 | else if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)) | ||
3563 | 3557 | { | ||
3564 | 3558 | clientUpdateFullscreenSize (c); | ||
3565 | 3559 | } | ||
3566 | 3560 | else | ||
3567 | 3561 | { | ||
3568 | 3562 | configure_flags = CFG_CONSTRAINED | CFG_REQUEST; | ||
3569 | 3563 | if (fully_visible) | ||
3570 | 3564 | { | ||
3571 | 3565 | configure_flags |= CFG_KEEP_VISIBLE; | ||
3572 | 3566 | } | ||
3573 | 3567 | if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_SAVED_POS)) | ||
3574 | 3568 | { | ||
3575 | 3569 | wc.x = c->saved_x; | ||
3576 | 3570 | wc.y = c->saved_y; | ||
3577 | 3571 | } | ||
3578 | 3572 | else | ||
3579 | 3573 | { | ||
3580 | 3574 | FLAG_SET (c->xfwm_flags, XFWM_FLAG_SAVED_POS); | ||
3581 | 3575 | |||
3582 | 3576 | c->saved_x = c->x; | ||
3583 | 3577 | c->saved_y = c->y; | ||
3584 | 3578 | |||
3585 | 3579 | wc.x = c->x; | ||
3586 | 3580 | wc.y = c->y; | ||
3587 | 3581 | } | ||
3588 | 3582 | |||
3589 | 3583 | clientConfigure (c, &wc, CWX | CWY, configure_flags); | ||
3590 | 3584 | } | ||
3591 | 3585 | } | ||
3592 | 3586 | |||
3593 | 3587 | g_list_free (list_of_windows); | ||
3594 | 3588 | } | ||
3595 | 3589 | |||
3596 | 3590 | void | ||
3597 | 3591 | clientUpdateCursor (Client *c) | ||
3598 | 3592 | { | ||
3599 | 3593 | ScreenInfo *screen_info; | ||
3600 | 3594 | DisplayInfo *display_info; | ||
3601 | 3595 | guint i; | ||
3602 | 3596 | |||
3603 | 3597 | g_return_if_fail (c != NULL); | ||
3604 | 3598 | |||
3605 | 3599 | screen_info = c->screen_info; | ||
3606 | 3600 | display_info = screen_info->display_info; | ||
3607 | 3601 | |||
3608 | 3602 | for (i = 0; i <= SIDE_TOP; i++) | ||
3609 | 3603 | { | ||
3610 | 3604 | xfwmWindowSetCursor (&c->sides[i], | ||
3611 | 3605 | myDisplayGetCursorResize(display_info, CORNER_COUNT + i)); | ||
3612 | 3606 | } | ||
3613 | 3607 | |||
3614 | 3608 | for (i = 0; i < CORNER_COUNT; i++) | ||
3615 | 3609 | { | ||
3616 | 3610 | xfwmWindowSetCursor (&c->corners[i], | ||
3617 | 3611 | myDisplayGetCursorResize(display_info, i)); | ||
3618 | 3612 | } | ||
3619 | 3613 | } | ||
3620 | 3614 | |||
3621 | 3615 | void | ||
3622 | 3616 | clientUpdateAllCursor (ScreenInfo *screen_info) | ||
3623 | 3617 | { | ||
3624 | 3618 | Client *c; | ||
3625 | 3619 | guint i; | ||
3626 | 3620 | |||
3627 | 3621 | g_return_if_fail (screen_info != NULL); | ||
3628 | 3622 | |||
3629 | 3623 | for (c = screen_info->clients, i = 0; i < screen_info->client_count; c = c->next, ++i) | ||
3630 | 3624 | { | ||
3631 | 3625 | clientUpdateCursor (c); | ||
3632 | 3626 | } | ||
3633 | 3627 | } | ||
3634 | 3628 | |||
3635 | 3629 | static eventFilterStatus | ||
3636 | 3630 | clientButtonPressEventFilter (XEvent * xevent, gpointer data) | ||
3637 | 3631 | { | ||
3638 | 3632 | ScreenInfo *screen_info; | ||
3639 | 3633 | DisplayInfo *display_info; | ||
3640 | 3634 | Client *c; | ||
3641 | 3635 | ButtonPressData *passdata; | ||
3642 | 3636 | eventFilterStatus status; | ||
3643 | 3637 | int b; | ||
3644 | 3638 | gboolean pressed; | ||
3645 | 3639 | |||
3646 | 3640 | passdata = (ButtonPressData *) data; | ||
3647 | 3641 | c = passdata->c; | ||
3648 | 3642 | b = passdata->b; | ||
3649 | 3643 | |||
3650 | 3644 | screen_info = c->screen_info; | ||
3651 | 3645 | display_info = screen_info->display_info; | ||
3652 | 3646 | |||
3653 | 3647 | /* Update the display time */ | ||
3654 | 3648 | myDisplayUpdateCurrentTime (display_info, xevent); | ||
3655 | 3649 | |||
3656 | 3650 | status = EVENT_FILTER_STOP; | ||
3657 | 3651 | pressed = TRUE; | ||
3658 | 3652 | |||
3659 | 3653 | switch (xevent->type) | ||
3660 | 3654 | { | ||
3661 | 3655 | case EnterNotify: | ||
3662 | 3656 | if ((xevent->xcrossing.mode != NotifyGrab) && (xevent->xcrossing.mode != NotifyUngrab)) | ||
3663 | 3657 | { | ||
3664 | 3658 | c->button_status[b] = BUTTON_STATE_PRESSED; | ||
3665 | 3659 | frameQueueDraw (c, FALSE); | ||
3666 | 3660 | } | ||
3667 | 3661 | break; | ||
3668 | 3662 | case LeaveNotify: | ||
3669 | 3663 | if ((xevent->xcrossing.mode != NotifyGrab) && (xevent->xcrossing.mode != NotifyUngrab)) | ||
3670 | 3664 | { | ||
3671 | 3665 | c->button_status[b] = BUTTON_STATE_NORMAL; | ||
3672 | 3666 | frameQueueDraw (c, FALSE); | ||
3673 | 3667 | } | ||
3674 | 3668 | break; | ||
3675 | 3669 | case ButtonRelease: | ||
3676 | 3670 | pressed = FALSE; | ||
3677 | 3671 | break; | ||
3678 | 3672 | case UnmapNotify: | ||
3679 | 3673 | if (xevent->xunmap.window == c->window) | ||
3680 | 3674 | { | ||
3681 | 3675 | pressed = FALSE; | ||
3682 | 3676 | c->button_status[b] = BUTTON_STATE_NORMAL; | ||
3683 | 3677 | } | ||
3684 | 3678 | break; | ||
3685 | 3679 | case KeyPress: | ||
3686 | 3680 | case KeyRelease: | ||
3687 | 3681 | break; | ||
3688 | 3682 | default: | ||
3689 | 3683 | status = EVENT_FILTER_CONTINUE; | ||
3690 | 3684 | break; | ||
3691 | 3685 | } | ||
3692 | 3686 | |||
3693 | 3687 | if (!pressed) | ||
3694 | 3688 | { | ||
3695 | 3689 | TRACE ("event loop now finished"); | ||
3696 | 3690 | gtk_main_quit (); | ||
3697 | 3691 | } | ||
3698 | 3692 | |||
3699 | 3693 | return status; | ||
3700 | 3694 | } | ||
3701 | 3695 | |||
3702 | 3696 | void | ||
3703 | 3697 | clientButtonPress (Client *c, Window w, XButtonEvent * bev) | ||
3704 | 3698 | { | ||
3705 | 3699 | ScreenInfo *screen_info; | ||
3706 | 3700 | DisplayInfo *display_info; | ||
3707 | 3701 | ButtonPressData passdata; | ||
3708 | 3702 | int b, g1; | ||
3709 | 3703 | |||
3710 | 3704 | g_return_if_fail (c != NULL); | ||
3711 | 3705 | TRACE ("entering clientButtonPress"); | ||
3712 | 3706 | |||
3713 | 3707 | for (b = 0; b < BUTTON_COUNT; b++) | ||
3714 | 3708 | { | ||
3715 | 3709 | if (MYWINDOW_XWINDOW (c->buttons[b]) == w) | ||
3716 | 3710 | { | ||
3717 | 3711 | break; | ||
3718 | 3712 | } | ||
3719 | 3713 | } | ||
3720 | 3714 | |||
3721 | 3715 | screen_info = c->screen_info; | ||
3722 | 3716 | display_info = screen_info->display_info; | ||
3723 | 3717 | |||
3724 | 3718 | g1 = XGrabPointer (display_info->dpy, w, FALSE, | ||
3725 | 3719 | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask, | ||
3726 | 3720 | GrabModeAsync, GrabModeAsync, | ||
3727 | 3721 | screen_info->xroot, None, | ||
3728 | 3722 | myDisplayGetCurrentTime (display_info)); | ||
3729 | 3723 | |||
3730 | 3724 | if (g1 != GrabSuccess) | ||
3731 | 3725 | { | ||
3732 | 3726 | TRACE ("grab failed in clientButtonPress"); | ||
3733 | 3727 | gdk_beep (); | ||
3734 | 3728 | if (g1 == GrabSuccess) | ||
3735 | 3729 | { | ||
3736 | 3730 | XUngrabKeyboard (display_info->dpy, myDisplayGetCurrentTime (display_info)); | ||
3737 | 3731 | } | ||
3738 | 3732 | return; | ||
3739 | 3733 | } | ||
3740 | 3734 | |||
3741 | 3735 | passdata.c = c; | ||
3742 | 3736 | passdata.b = b; | ||
3743 | 3737 | |||
3744 | 3738 | c->button_status[b] = BUTTON_STATE_PRESSED; | ||
3745 | 3739 | frameQueueDraw (c, FALSE); |
I took the liberty to replace CFLAGS to CPPFLAGS (since defines are taken care of by the preprocessor), and uploaded. Thanks.