wmaker: allow alt+tabbed windows over fullscreen
[wmaker-crm.git] / src / actions.c
blob4bc3e075e59cf833a19e14b63cf052087d2bb2d6
1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
7 * Copyright (c) 2014 Window Maker Team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "wconfig.h"
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <unistd.h>
31 #include <math.h>
32 #include <time.h>
34 #include "WindowMaker.h"
35 #include "framewin.h"
36 #include "window.h"
37 #include "client.h"
38 #include "icon.h"
39 #include "colormap.h"
40 #include "application.h"
41 #include "actions.h"
42 #include "stacking.h"
43 #include "appicon.h"
44 #include "dock.h"
45 #include "appmenu.h"
46 #include "winspector.h"
47 #include "workspace.h"
48 #include "xinerama.h"
49 #include "usermenu.h"
50 #include "placement.h"
51 #include "misc.h"
52 #include "event.h"
55 #ifndef HAVE_FLOAT_MATHFUNC
56 #define sinf(x) ((float)sin((double)(x)))
57 #define cosf(x) ((float)cos((double)(x)))
58 #define sqrtf(x) ((float)sqrt((double)(x)))
59 #define atan2f(y, x) ((float)atan((double)(y) / (double)(x)))
60 #endif
62 static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x, int *new_y,
63 unsigned int *new_width, unsigned int *new_height);
64 static void save_old_geometry(WWindow *wwin, int directions);
66 /******* Local Variables *******/
67 #ifdef USE_ANIMATIONS
68 static struct {
69 int steps;
70 int delay;
71 } shadePars[5] = {
72 { SHADE_STEPS_UF, SHADE_DELAY_UF },
73 { SHADE_STEPS_F, SHADE_DELAY_F },
74 { SHADE_STEPS_M, SHADE_DELAY_M },
75 { SHADE_STEPS_S, SHADE_DELAY_S },
76 { SHADE_STEPS_US, SHADE_DELAY_US }
79 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
80 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
81 #endif
83 #define UNSHADE 0
84 #define SHADE 1
86 static int compareTimes(Time t1, Time t2)
88 Time diff;
89 if (t1 == t2)
90 return 0;
91 diff = t1 - t2;
92 return (diff < 60000) ? 1 : -1;
95 #ifdef USE_ANIMATIONS
96 static void shade_animate(WWindow *wwin, Bool what);
97 #else
98 static inline void shade_animate(WWindow *wwin, Bool what)
101 * This function is empty on purpose, so tell the compiler
102 * to not warn about parameters being not used
104 (void) wwin;
105 (void) what;
107 #endif
110 *----------------------------------------------------------------------
111 * wSetFocusTo--
112 * Changes the window focus to the one passed as argument.
113 * If the window to focus is not already focused, it will be brought
114 * to the head of the list of windows. Previously focused window is
115 * unfocused.
117 * Side effects:
118 * Window list may be reordered and the window focus is changed.
120 *----------------------------------------------------------------------
122 void wSetFocusTo(WScreen *scr, WWindow *wwin)
124 static WScreen *old_scr = NULL;
126 WWindow *old_focused;
127 WWindow *focused = scr->focused_window;
128 Time timestamp = w_global.timestamp.last_event;
129 WApplication *oapp = NULL, *napp = NULL;
130 int wasfocused;
132 if (scr->flags.ignore_focus_events || compareTimes(w_global.timestamp.focus_change, timestamp) > 0)
133 return;
135 if (!old_scr)
136 old_scr = scr;
138 old_focused = old_scr->focused_window;
140 w_global.timestamp.focus_change = timestamp;
142 if (old_focused)
143 oapp = wApplicationOf(old_focused->main_window);
145 if (wwin == NULL) {
146 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
147 if (old_focused)
148 wWindowUnfocus(old_focused);
150 if (oapp) {
151 wAppMenuUnmap(oapp->menu);
152 if (wPreferences.highlight_active_app)
153 wApplicationDeactivate(oapp);
156 WMPostNotificationName(WMNChangedFocus, NULL, (void *)True);
157 return;
160 if (old_scr != scr && old_focused)
161 wWindowUnfocus(old_focused);
163 wasfocused = wwin->flags.focused;
164 napp = wApplicationOf(wwin->main_window);
166 /* remember last workspace where the app has been */
167 if (napp)
168 napp->last_workspace = wwin->frame->workspace;
170 if (wwin->flags.mapped && !WFLAGP(wwin, no_focusable)) {
171 /* install colormap if colormap mode is lock mode */
172 if (wPreferences.colormap_mode == WCM_CLICK)
173 wColormapInstallForWindow(scr, wwin);
175 /* set input focus */
176 switch (wwin->focus_mode) {
177 case WFM_NO_INPUT:
178 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
179 break;
180 case WFM_PASSIVE:
181 case WFM_LOCALLY_ACTIVE:
182 XSetInputFocus(dpy, wwin->client_win, RevertToParent, CurrentTime);
183 break;
184 case WFM_GLOBALLY_ACTIVE:
185 break;
188 XFlush(dpy);
189 if (wwin->protocols.TAKE_FOCUS)
190 wClientSendProtocol(wwin, w_global.atom.wm.take_focus, timestamp);
192 XSync(dpy, False);
193 } else {
194 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
197 if (WFLAGP(wwin, no_focusable))
198 return;
200 /* if this is not the focused window focus it */
201 if (focused != wwin) {
202 /* change the focus window list order */
203 if (wwin->prev)
204 wwin->prev->next = wwin->next;
206 if (wwin->next)
207 wwin->next->prev = wwin->prev;
209 wwin->prev = focused;
210 focused->next = wwin;
211 wwin->next = NULL;
212 scr->focused_window = wwin;
214 if (oapp && oapp != napp) {
215 wAppMenuUnmap(oapp->menu);
216 if (wPreferences.highlight_active_app)
217 wApplicationDeactivate(oapp);
220 /* reset fullscreen if temporarily removed due to lost focus*/
221 if (wwin->flags.fullscreen)
222 ChangeStackingLevel(wwin->frame->core, WMFullscreenLevel);
225 wWindowFocus(wwin, focused);
227 if (napp && !wasfocused) {
228 #ifdef USER_MENU
229 wUserMenuRefreshInstances(napp->menu, wwin);
230 #endif /* USER_MENU */
232 /* kix: Only menu map with mouse, not alt+tab! */
233 if (wwin->flags.mapped)
234 wAppMenuMap(napp->menu, wwin);
236 if (napp && wPreferences.highlight_active_app)
237 wApplicationActivate(napp);
239 XFlush(dpy);
240 old_scr = scr;
243 void wShadeWindow(WWindow *wwin)
246 if (wwin->flags.shaded)
247 return;
249 XLowerWindow(dpy, wwin->client_win);
250 shade_animate(wwin, SHADE);
252 wwin->flags.skip_next_animation = 0;
253 wwin->flags.shaded = 1;
254 wwin->flags.mapped = 0;
255 /* prevent window withdrawal when getting UnmapNotify */
256 XSelectInput(dpy, wwin->client_win, wwin->event_mask & ~StructureNotifyMask);
257 XUnmapWindow(dpy, wwin->client_win);
258 XSelectInput(dpy, wwin->client_win, wwin->event_mask);
260 /* for the client it's just like iconification */
261 wFrameWindowResize(wwin->frame, wwin->frame->core->width, wwin->frame->top_width - 1);
263 wwin->client.y = wwin->frame_y - wwin->client.height + wwin->frame->top_width;
264 wWindowSynthConfigureNotify(wwin);
267 wClientSetState(wwin, IconicState, None);
270 WMPostNotificationName(WMNChangedState, wwin, "shade");
272 #ifdef USE_ANIMATIONS
273 if (!wwin->screen_ptr->flags.startup) {
274 /* Catch up with events not processed while animation was running */
275 ProcessPendingEvents();
277 #endif
280 void wUnshadeWindow(WWindow *wwin)
283 if (!wwin->flags.shaded)
284 return;
286 wwin->flags.shaded = 0;
287 wwin->flags.mapped = 1;
288 XMapWindow(dpy, wwin->client_win);
290 shade_animate(wwin, UNSHADE);
292 wwin->flags.skip_next_animation = 0;
293 wFrameWindowResize(wwin->frame, wwin->frame->core->width,
294 wwin->frame->top_width + wwin->client.height + wwin->frame->bottom_width);
296 wwin->client.y = wwin->frame_y + wwin->frame->top_width;
297 wWindowSynthConfigureNotify(wwin);
299 /* if the window is focused, set the focus again as it was disabled during
300 * shading */
301 if (wwin->flags.focused)
302 wSetFocusTo(wwin->screen_ptr, wwin);
304 WMPostNotificationName(WMNChangedState, wwin, "shade");
307 /* Set the old coordinates using the current values */
308 static void save_old_geometry(WWindow *wwin, int directions)
310 /* never been saved? */
311 if (!wwin->old_geometry.width)
312 directions |= SAVE_GEOMETRY_X | SAVE_GEOMETRY_WIDTH;
313 if (!wwin->old_geometry.height)
314 directions |= SAVE_GEOMETRY_Y | SAVE_GEOMETRY_HEIGHT;
316 if (directions & SAVE_GEOMETRY_X)
317 wwin->old_geometry.x = wwin->frame_x;
318 if (directions & SAVE_GEOMETRY_Y)
319 wwin->old_geometry.y = wwin->frame_y;
320 if (directions & SAVE_GEOMETRY_WIDTH)
321 wwin->old_geometry.width = wwin->client.width;
322 if (directions & SAVE_GEOMETRY_HEIGHT)
323 wwin->old_geometry.height = wwin->client.height;
326 static void remember_geometry(WWindow *wwin, int *x, int *y, int *w, int *h)
328 WMRect old_geom_rect;
329 int old_head;
330 Bool same_head;
332 old_geom_rect = wmkrect(wwin->old_geometry.x, wwin->old_geometry.y, wwin->old_geometry.width, wwin->old_geometry.height);
333 old_head = wGetHeadForRect(wwin->screen_ptr, old_geom_rect);
334 same_head = (wGetHeadForWindow(wwin) == old_head);
335 *x = ((wwin->old_geometry.x || wwin->old_geometry.width) && same_head) ? wwin->old_geometry.x : wwin->frame_x;
336 *y = ((wwin->old_geometry.y || wwin->old_geometry.height) && same_head) ? wwin->old_geometry.y : wwin->frame_y;
337 *w = wwin->old_geometry.width ? wwin->old_geometry.width : wwin->client.width;
338 *h = wwin->old_geometry.height ? wwin->old_geometry.height : wwin->client.height;
341 /* Remember geometry for unmaximizing */
342 void update_saved_geometry(WWindow *wwin)
344 /* NOT if we aren't already maximized
345 * we'll save geometry when maximizing */
346 if (!wwin->flags.maximized)
347 return;
349 /* NOT if we are fully maximized */
350 if ((wwin->flags.maximized & MAX_MAXIMUS) ||
351 ((wwin->flags.maximized & MAX_HORIZONTAL) &&
352 (wwin->flags.maximized & MAX_VERTICAL)))
353 return;
355 /* save the co-ordinate in the axis in which we AREN'T maximized */
356 if (wwin->flags.maximized & MAX_HORIZONTAL)
357 save_old_geometry(wwin, SAVE_GEOMETRY_Y);
358 if (wwin->flags.maximized & MAX_VERTICAL)
359 save_old_geometry(wwin, SAVE_GEOMETRY_X);
362 void wMaximizeWindow(WWindow *wwin, int directions)
364 unsigned int new_width, new_height, half_scr_width, half_scr_height;
365 int new_x = 0;
366 int new_y = 0;
367 int maximus_x = 0;
368 int maximus_y = 0;
369 unsigned int maximus_width = 0;
370 unsigned int maximus_height = 0;
371 WArea usableArea, totalArea;
372 Bool has_border = 1;
373 int adj_size;
374 WScreen *scr = wwin->screen_ptr;
376 if (!IS_RESIZABLE(wwin))
377 return;
379 if (!HAS_BORDER(wwin))
380 has_border = 0;
382 if (wPreferences.drag_maximized_window == DRAGMAX_NOMOVE)
383 wwin->client_flags.no_movable = 1;
385 /* the size to adjust the geometry */
386 adj_size = scr->frame_border_width * 2 * has_border;
388 /* save old coordinates before we change the current values */
389 if (!wwin->flags.maximized)
390 save_old_geometry(wwin, SAVE_GEOMETRY_ALL);
392 totalArea.x2 = scr->scr_width;
393 totalArea.y2 = scr->scr_height;
394 totalArea.x1 = 0;
395 totalArea.y1 = 0;
396 usableArea = totalArea;
398 if (!(directions & MAX_IGNORE_XINERAMA)) {
399 WScreen *scr = wwin->screen_ptr;
400 int head;
402 if (directions & MAX_KEYBOARD)
403 head = wGetHeadForWindow(wwin);
404 else
405 head = wGetHeadForPointerLocation(scr);
407 usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True);
411 /* Only save directions, not kbd or xinerama hints */
412 directions &= (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
414 if (WFLAGP(wwin, full_maximize))
415 usableArea = totalArea;
416 half_scr_width = (usableArea.x2 - usableArea.x1)/2;
417 half_scr_height = (usableArea.y2 - usableArea.y1)/2;
419 if (wwin->flags.shaded) {
420 wwin->flags.skip_next_animation = 1;
421 wUnshadeWindow(wwin);
424 if (directions & MAX_MAXIMUS) {
425 find_Maximus_geometry(wwin, usableArea, &maximus_x, &maximus_y, &maximus_width, &maximus_height);
426 new_width = maximus_width - adj_size;
427 new_height = maximus_height - adj_size;
428 new_x = maximus_x;
429 new_y = maximus_y;
430 if (WFLAGP(wwin, full_maximize) && (new_y == 0)) {
431 new_height += wwin->frame->bottom_width - 1;
432 new_y -= wwin->frame->top_width;
435 wwin->maximus_x = new_x;
436 wwin->maximus_y = new_y;
437 wwin->flags.old_maximized |= MAX_MAXIMUS;
438 } else {
439 /* set default values if no option set then */
440 if (!(directions & (MAX_HORIZONTAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_MAXIMUS))) {
441 new_width = (wwin->old_geometry.width) ? wwin->old_geometry.width : wwin->frame->core->width;
442 new_x = (wwin->old_geometry.x) ? wwin->old_geometry.x : wwin->frame_x;
444 if (!(directions & (MAX_VERTICAL | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS))) {
445 new_height = (wwin->old_geometry.height) ? wwin->old_geometry.height : wwin->frame->core->height;
446 new_y = (wwin->old_geometry.y) ? wwin->old_geometry.y : wwin->frame_y;
449 /* left|right position */
450 if (directions & MAX_LEFTHALF) {
451 new_width = half_scr_width - adj_size;
452 new_x = usableArea.x1;
453 } else if (directions & MAX_RIGHTHALF) {
454 new_width = half_scr_width - adj_size;
455 new_x = usableArea.x1 + half_scr_width;
457 /* top|bottom position */
458 if (directions & MAX_TOPHALF) {
459 new_height = half_scr_height - adj_size;
460 new_y = usableArea.y1;
461 } else if (directions & MAX_BOTTOMHALF) {
462 new_height = half_scr_height - adj_size;
463 new_y = usableArea.y1 + half_scr_height;
466 /* vertical|horizontal position */
467 if (directions & MAX_HORIZONTAL) {
468 new_width = usableArea.x2 - usableArea.x1 - adj_size;
469 new_x = usableArea.x1;
471 if (directions & MAX_VERTICAL) {
472 new_height = usableArea.y2 - usableArea.y1 - adj_size;
473 new_y = usableArea.y1;
474 if (WFLAGP(wwin, full_maximize) && (new_y == 0))
475 new_y -= wwin->frame->top_width;
479 if (!WFLAGP(wwin, full_maximize) && !(directions == MAX_MAXIMUS || directions == MAX_HORIZONTAL))
480 new_height -= wwin->frame->top_width + wwin->frame->bottom_width;
482 /* set maximization state */
483 wwin->flags.maximized = directions;
484 if ((wwin->flags.old_maximized & MAX_MAXIMUS) && !wwin->flags.maximized)
485 wwin->flags.maximized = MAX_MAXIMUS;
487 wWindowConstrainSize(wwin, &new_width, &new_height);
489 wWindowCropSize(wwin, usableArea.x2 - usableArea.x1,
490 usableArea.y2 - usableArea.y1, &new_width, &new_height);
492 wWindowConfigure(wwin, new_x, new_y, new_width, new_height);
493 wWindowSynthConfigureNotify(wwin);
495 WMPostNotificationName(WMNChangedState, wwin, "maximize");
498 /* generic (un)maximizer */
499 void handleMaximize(WWindow *wwin, int directions)
501 int current = wwin->flags.maximized;
502 int requested = directions & (MAX_HORIZONTAL | MAX_VERTICAL | MAX_LEFTHALF | MAX_RIGHTHALF | MAX_TOPHALF | MAX_BOTTOMHALF | MAX_MAXIMUS);
503 int effective = requested ^ current;
504 int flags = directions & ~requested;
506 if (!effective) {
507 /* allow wMaximizeWindow to restore the Maximusized size */
508 if ((wwin->flags.old_maximized & MAX_MAXIMUS) &&
509 !(requested & MAX_MAXIMUS))
510 wMaximizeWindow(wwin, MAX_MAXIMUS | flags);
511 else
512 wUnmaximizeWindow(wwin);
513 /* these alone mean vertical|horizontal toggle */
514 } else if ((effective == MAX_LEFTHALF) ||
515 (effective == MAX_RIGHTHALF) ||
516 (effective == MAX_TOPHALF) ||
517 (effective == MAX_BOTTOMHALF))
518 wUnmaximizeWindow(wwin);
519 else {
520 if ((requested == (MAX_HORIZONTAL | MAX_VERTICAL)) ||
521 (requested == MAX_MAXIMUS))
522 effective = requested;
523 else {
524 if (requested & MAX_LEFTHALF) {
525 if (!(requested & (MAX_TOPHALF | MAX_BOTTOMHALF)))
526 effective |= MAX_VERTICAL;
527 else
528 effective |= requested & (MAX_TOPHALF | MAX_BOTTOMHALF);
529 effective |= MAX_LEFTHALF;
530 effective &= ~(MAX_HORIZONTAL | MAX_RIGHTHALF);
531 } else if (requested & MAX_RIGHTHALF) {
532 if (!(requested & (MAX_TOPHALF | MAX_BOTTOMHALF)))
533 effective |= MAX_VERTICAL;
534 else
535 effective |= requested & (MAX_TOPHALF | MAX_BOTTOMHALF);
536 effective |= MAX_RIGHTHALF;
537 effective &= ~(MAX_HORIZONTAL | MAX_LEFTHALF);
539 if (requested & MAX_TOPHALF) {
540 if (!(requested & (MAX_LEFTHALF | MAX_RIGHTHALF)))
541 effective |= MAX_HORIZONTAL;
542 else
543 effective |= requested & (MAX_LEFTHALF | MAX_RIGHTHALF);
544 effective |= MAX_TOPHALF;
545 effective &= ~(MAX_VERTICAL | MAX_BOTTOMHALF);
546 } else if (requested & MAX_BOTTOMHALF) {
547 if (!(requested & (MAX_LEFTHALF | MAX_RIGHTHALF)))
548 effective |= MAX_HORIZONTAL;
549 else
550 effective |= requested & (MAX_LEFTHALF | MAX_RIGHTHALF);
551 effective |= MAX_BOTTOMHALF;
552 effective &= ~(MAX_VERTICAL | MAX_TOPHALF);
554 if (requested & MAX_HORIZONTAL)
555 effective &= ~(MAX_LEFTHALF | MAX_RIGHTHALF);
556 if (requested & MAX_VERTICAL)
557 effective &= ~(MAX_TOPHALF | MAX_BOTTOMHALF);
558 effective &= ~MAX_MAXIMUS;
560 wMaximizeWindow(wwin, effective | flags);
564 /* the window boundary coordinates */
565 typedef struct {
566 int left;
567 int right;
568 int bottom;
569 int top;
570 int width;
571 int height;
572 } win_coords;
574 static void set_window_coords(WWindow *wwin, win_coords *obs)
576 obs->left = wwin->frame_x;
577 obs->top = wwin->frame_y;
578 obs->width = wwin->frame->core->width;
579 obs->height = wwin->frame->core->height;
580 obs->bottom = obs->top + obs->height;
581 obs->right = obs->left + obs->width;
585 * Maximus: tiled maximization (maximize without overlapping other windows)
587 * The original window 'orig' will be maximized to new coordinates 'new'.
588 * The windows obstructing the maximization of 'orig' are denoted 'obs'.
590 static void find_Maximus_geometry(WWindow *wwin, WArea usableArea, int *new_x, int *new_y,
591 unsigned int *new_width, unsigned int *new_height)
593 WWindow *tmp;
594 short int tbar_height_0 = 0, rbar_height_0 = 0, bd_width_0 = 0;
595 short int adjust_height;
596 int x_intsect, y_intsect;
597 /* the obstructing, original and new windows */
598 win_coords obs, orig, new;
600 /* set the original coordinate positions of the window to be Maximumized */
601 if (wwin->flags.maximized) {
602 /* window is already maximized; consider original geometry */
603 remember_geometry(wwin, &orig.left, &orig.top, &orig.width, &orig.height);
604 orig.bottom = orig.top + orig.height;
605 orig.right = orig.left + orig.width;
606 } else
607 set_window_coords(wwin, &orig);
609 /* Try to fully maximize first, then readjust later */
610 new.left = usableArea.x1;
611 new.right = usableArea.x2;
612 new.top = usableArea.y1;
613 new.bottom = usableArea.y2;
615 if (HAS_TITLEBAR(wwin))
616 tbar_height_0 = TITLEBAR_HEIGHT;
617 if (HAS_RESIZEBAR(wwin))
618 rbar_height_0 = RESIZEBAR_HEIGHT;
619 if (HAS_BORDER(wwin))
620 bd_width_0 = wwin->screen_ptr->frame_border_width;
622 /* the length to be subtracted if the window has titlebar, etc */
623 adjust_height = tbar_height_0 + 2 * bd_width_0 + rbar_height_0;
625 tmp = wwin;
626 /* The focused window is always the last in the list */
627 while (tmp->prev) {
628 /* ignore windows in other workspaces etc */
629 if (tmp->prev->frame->workspace != wwin->screen_ptr->current_workspace
630 || tmp->prev->flags.miniaturized || tmp->prev->flags.hidden) {
631 tmp = tmp->prev;
632 continue;
634 tmp = tmp->prev;
636 /* Set the coordinates of obstructing window */
637 set_window_coords(tmp, &obs);
639 /* Try to maximize in the y direction first */
640 x_intsect = calcIntersectionLength(orig.left, orig.width, obs.left, obs.width);
641 if (x_intsect != 0) {
642 /* TODO: Consider the case when coords are equal */
643 if (obs.bottom < orig.top && obs.bottom > new.top) {
644 /* w_0 is below the bottom of w_j */
645 new.top = obs.bottom + 1;
647 if (orig.bottom < obs.top && obs.top < new.bottom) {
648 /* The bottom of w_0 is above the top of w_j */
649 new.bottom = obs.top - 1;
654 tmp = wwin;
655 while (tmp->prev) {
656 if (tmp->prev->frame->workspace != wwin->screen_ptr->current_workspace
657 || tmp->prev->flags.miniaturized || tmp->prev->flags.hidden) {
658 tmp = tmp->prev;
659 continue;
661 tmp = tmp->prev;
663 set_window_coords(tmp, &obs);
666 * Use the new.top and new.height instead of original values
667 * as they may have different intersections with the obstructing windows
669 new.height = new.bottom - new.top - adjust_height;
670 y_intsect = calcIntersectionLength(new.top, new.height, obs.top, obs.height);
671 if (y_intsect != 0) {
672 if (obs.right < orig.left && obs.right > new.left) {
673 /* w_0 is completely to the right of w_j */
674 new.left = obs.right + 1;
676 if (orig.right < obs.left && obs.left < new.right) {
677 /* w_0 is completely to the left of w_j */
678 new.right = obs.left - 1;
683 *new_x = new.left;
684 *new_y = new.top;
685 /* xcalc needs -7 here, but other apps don't */
686 *new_height = new.bottom - new.top - adjust_height - 1;
687 *new_width = new.right - new.left;
690 void wUnmaximizeWindow(WWindow *wwin)
692 int x, y, w, h;
694 if (!wwin->flags.maximized)
695 return;
697 if (wwin->flags.shaded) {
698 wwin->flags.skip_next_animation = 1;
699 wUnshadeWindow(wwin);
702 if (wPreferences.drag_maximized_window == DRAGMAX_NOMOVE)
703 wwin->client_flags.no_movable = 0;
705 /* Use old coordinates if they are set, current values otherwise */
706 remember_geometry(wwin, &x, &y, &w, &h);
708 /* unMaximusize relative to original position */
709 if (wwin->flags.maximized & MAX_MAXIMUS) {
710 x += wwin->frame_x - wwin->maximus_x;
711 y += wwin->frame_y - wwin->maximus_y;
714 wwin->flags.maximized = 0;
715 wwin->flags.old_maximized = 0;
716 wWindowConfigure(wwin, x, y, w, h);
717 wWindowSynthConfigureNotify(wwin);
719 WMPostNotificationName(WMNChangedState, wwin, "maximize");
722 void wFullscreenWindow(WWindow *wwin)
724 int head;
725 WMRect rect;
727 if (wwin->flags.fullscreen)
728 return;
730 wwin->flags.fullscreen = True;
732 wWindowConfigureBorders(wwin);
734 ChangeStackingLevel(wwin->frame->core, WMFullscreenLevel);
736 wwin->bfs_geometry.x = wwin->frame_x;
737 wwin->bfs_geometry.y = wwin->frame_y;
738 wwin->bfs_geometry.width = wwin->frame->core->width;
739 wwin->bfs_geometry.height = wwin->frame->core->height;
741 head = wGetHeadForWindow(wwin);
742 rect = wGetRectForHead(wwin->screen_ptr, head);
743 wWindowConfigure(wwin, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
745 wwin->screen_ptr->bfs_focused_window = wwin->screen_ptr->focused_window;
746 wSetFocusTo(wwin->screen_ptr, wwin);
748 WMPostNotificationName(WMNChangedState, wwin, "fullscreen");
751 void wUnfullscreenWindow(WWindow *wwin)
753 if (!wwin->flags.fullscreen)
754 return;
756 wwin->flags.fullscreen = False;
758 if (wwin->frame->core->stacking->window_level == WMFullscreenLevel) {
759 if (WFLAGP(wwin, sunken)) {
760 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
761 } else if (WFLAGP(wwin, floating)) {
762 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
763 } else {
764 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
768 wWindowConfigure(wwin, wwin->bfs_geometry.x, wwin->bfs_geometry.y,
769 wwin->bfs_geometry.width, wwin->bfs_geometry.height);
771 wWindowConfigureBorders(wwin);
773 // seems unnecessary, but also harmless (doesn't generate flicker) -Dan
774 wFrameWindowPaint(wwin->frame);
777 WMPostNotificationName(WMNChangedState, wwin, "fullscreen");
779 if (wwin->screen_ptr->bfs_focused_window) {
780 wSetFocusTo(wwin->screen_ptr, wwin->screen_ptr->bfs_focused_window);
781 wwin->screen_ptr->bfs_focused_window = NULL;
785 #ifdef USE_ANIMATIONS
786 static void animateResizeFlip(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
788 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
789 float cx, cy, cw, ch;
790 float xstep, ystep, wstep, hstep;
791 XPoint points[5];
792 float dx, dch, midy;
793 float angle, final_angle, delta;
795 xstep = (float)(fx - x) / steps;
796 ystep = (float)(fy - y) / steps;
797 wstep = (float)(fw - w) / steps;
798 hstep = (float)(fh - h) / steps;
800 cx = (float)x;
801 cy = (float)y;
802 cw = (float)w;
803 ch = (float)h;
805 final_angle = 2 * WM_PI * MINIATURIZE_ANIMATION_TWIST_F;
806 delta = (float)(final_angle / FRAMES);
807 for (angle = 0;; angle += delta) {
808 if (angle > final_angle)
809 angle = final_angle;
811 dx = (cw / 10) - ((cw / 5) * sinf(angle));
812 dch = (ch / 2) * cosf(angle);
813 midy = cy + (ch / 2);
815 points[0].x = cx + dx;
816 points[0].y = midy - dch;
817 points[1].x = cx + cw - dx;
818 points[1].y = points[0].y;
819 points[2].x = cx + cw + dx;
820 points[2].y = midy + dch;
821 points[3].x = cx - dx;
822 points[3].y = points[2].y;
823 points[4].x = points[0].x;
824 points[4].y = points[0].y;
826 XGrabServer(dpy);
827 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
828 XFlush(dpy);
829 wusleep(MINIATURIZE_ANIMATION_DELAY_F);
831 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
832 XUngrabServer(dpy);
833 cx += xstep;
834 cy += ystep;
835 cw += wstep;
836 ch += hstep;
837 if (angle >= final_angle)
838 break;
841 XFlush(dpy);
844 #undef FRAMES
846 static void
847 animateResizeTwist(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
849 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
850 float cx, cy, cw, ch;
851 float xstep, ystep, wstep, hstep;
852 XPoint points[5];
853 float angle, final_angle, a, d, delta;
855 x += w / 2;
856 y += h / 2;
857 fx += fw / 2;
858 fy += fh / 2;
860 xstep = (float)(fx - x) / steps;
861 ystep = (float)(fy - y) / steps;
862 wstep = (float)(fw - w) / steps;
863 hstep = (float)(fh - h) / steps;
865 cx = (float)x;
866 cy = (float)y;
867 cw = (float)w;
868 ch = (float)h;
870 final_angle = 2 * WM_PI * MINIATURIZE_ANIMATION_TWIST_T;
871 delta = (float)(final_angle / FRAMES);
872 for (angle = 0;; angle += delta) {
873 if (angle > final_angle)
874 angle = final_angle;
876 a = atan2f(ch, cw);
877 d = sqrtf((cw / 2) * (cw / 2) + (ch / 2) * (ch / 2));
879 points[0].x = cx + cosf(angle - a) * d;
880 points[0].y = cy + sinf(angle - a) * d;
881 points[1].x = cx + cosf(angle + a) * d;
882 points[1].y = cy + sinf(angle + a) * d;
883 points[2].x = cx + cosf(angle - a + (float)WM_PI) * d;
884 points[2].y = cy + sinf(angle - a + (float)WM_PI) * d;
885 points[3].x = cx + cosf(angle + a + (float)WM_PI) * d;
886 points[3].y = cy + sinf(angle + a + (float)WM_PI) * d;
887 points[4].x = cx + cosf(angle - a) * d;
888 points[4].y = cy + sinf(angle - a) * d;
889 XGrabServer(dpy);
890 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
891 XFlush(dpy);
892 wusleep(MINIATURIZE_ANIMATION_DELAY_T);
894 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
895 XUngrabServer(dpy);
896 cx += xstep;
897 cy += ystep;
898 cw += wstep;
899 ch += hstep;
900 if (angle >= final_angle)
901 break;
904 XFlush(dpy);
907 #undef FRAMES
909 static void animateResizeZoom(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps)
911 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
912 float cx[FRAMES], cy[FRAMES], cw[FRAMES], ch[FRAMES];
913 float xstep, ystep, wstep, hstep;
914 int i, j;
916 xstep = (float)(fx - x) / steps;
917 ystep = (float)(fy - y) / steps;
918 wstep = (float)(fw - w) / steps;
919 hstep = (float)(fh - h) / steps;
921 for (j = 0; j < FRAMES; j++) {
922 cx[j] = (float)x;
923 cy[j] = (float)y;
924 cw[j] = (float)w;
925 ch[j] = (float)h;
927 XGrabServer(dpy);
928 for (i = 0; i < steps; i++) {
929 for (j = 0; j < FRAMES; j++) {
930 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
931 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
933 XFlush(dpy);
934 wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
936 for (j = 0; j < FRAMES; j++) {
937 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
938 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
939 if (j < FRAMES - 1) {
940 cx[j] = cx[j + 1];
941 cy[j] = cy[j + 1];
942 cw[j] = cw[j + 1];
943 ch[j] = ch[j + 1];
944 } else {
945 cx[j] += xstep;
946 cy[j] += ystep;
947 cw[j] += wstep;
948 ch[j] += hstep;
953 for (j = 0; j < FRAMES; j++)
954 XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
955 XFlush(dpy);
956 wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
958 for (j = 0; j < FRAMES; j++)
959 XDrawRectangle(dpy, scr->root_win, scr->frame_gc, (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
961 XUngrabServer(dpy);
964 #undef FRAMES
966 void animateResize(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh)
968 int style = wPreferences.iconification_style; /* Catch the value */
969 int steps;
971 if (style == WIS_NONE)
972 return;
974 if (style == WIS_RANDOM)
975 style = rand() % 3;
977 switch (style) {
978 case WIS_TWIST:
979 steps = MINIATURIZE_ANIMATION_STEPS_T;
980 if (steps > 0)
981 animateResizeTwist(scr, x, y, w, h, fx, fy, fw, fh, steps);
982 break;
983 case WIS_FLIP:
984 steps = MINIATURIZE_ANIMATION_STEPS_F;
985 if (steps > 0)
986 animateResizeFlip(scr, x, y, w, h, fx, fy, fw, fh, steps);
987 break;
988 case WIS_ZOOM:
989 default:
990 steps = MINIATURIZE_ANIMATION_STEPS_Z;
991 if (steps > 0)
992 animateResizeZoom(scr, x, y, w, h, fx, fy, fw, fh, steps);
993 break;
996 #endif /* USE_ANIMATIONS */
998 static void flushExpose(void)
1000 XEvent tmpev;
1002 while (XCheckTypedEvent(dpy, Expose, &tmpev))
1003 WMHandleEvent(&tmpev);
1004 XSync(dpy, 0);
1007 static void unmapTransientsFor(WWindow *wwin)
1009 WWindow *tmp;
1011 tmp = wwin->screen_ptr->focused_window;
1012 while (tmp) {
1013 /* unmap the transients for this transient */
1014 if (tmp != wwin && tmp->transient_for == wwin->client_win
1015 && (tmp->flags.mapped || wwin->screen_ptr->flags.startup || tmp->flags.shaded)) {
1016 unmapTransientsFor(tmp);
1017 tmp->flags.miniaturized = 1;
1018 if (!tmp->flags.shaded)
1019 wWindowUnmap(tmp);
1020 else
1021 XUnmapWindow(dpy, tmp->frame->core->window);
1023 if (!tmp->flags.shaded)
1025 wClientSetState(tmp, IconicState, None);
1027 WMPostNotificationName(WMNChangedState, tmp, "iconify-transient");
1029 tmp = tmp->prev;
1033 static void mapTransientsFor(WWindow *wwin)
1035 WWindow *tmp;
1037 tmp = wwin->screen_ptr->focused_window;
1038 while (tmp) {
1039 /* recursively map the transients for this transient */
1040 if (tmp != wwin && tmp->transient_for == wwin->client_win && /*!tmp->flags.mapped */ tmp->flags.miniaturized
1041 && tmp->icon == NULL) {
1042 mapTransientsFor(tmp);
1043 tmp->flags.miniaturized = 0;
1044 if (!tmp->flags.shaded)
1045 wWindowMap(tmp);
1046 else
1047 XMapWindow(dpy, tmp->frame->core->window);
1048 tmp->flags.semi_focused = 0;
1050 if (!tmp->flags.shaded)
1052 wClientSetState(tmp, NormalState, None);
1054 WMPostNotificationName(WMNChangedState, tmp, "iconify-transient");
1056 tmp = tmp->prev;
1060 static WWindow *recursiveTransientFor(WWindow *wwin)
1062 int i;
1064 if (!wwin)
1065 return None;
1067 /* hackish way to detect transient_for cycle */
1068 i = wwin->screen_ptr->window_count + 1;
1070 while (wwin && wwin->transient_for != None && i > 0) {
1071 wwin = wWindowFor(wwin->transient_for);
1072 i--;
1074 if (i == 0 && wwin) {
1075 wwarning(_("window \"%s\" has a severely broken WM_TRANSIENT_FOR hint"),
1076 wwin->frame->title);
1077 return NULL;
1080 return wwin;
1083 #ifdef USE_ANIMATIONS
1084 static int getAnimationGeometry(WWindow *wwin, int *ix, int *iy, int *iw, int *ih)
1086 if (wwin->screen_ptr->flags.startup || wPreferences.no_animations
1087 || wwin->flags.skip_next_animation || wwin->icon == NULL)
1088 return 0;
1090 if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
1091 *ix = wwin->icon_x;
1092 *iy = wwin->icon_y;
1093 *iw = wwin->icon->core->width;
1094 *ih = wwin->icon->core->height;
1095 } else {
1096 if (wwin->flags.net_handle_icon) {
1097 *ix = wwin->icon_x;
1098 *iy = wwin->icon_y;
1099 *iw = wwin->icon_w;
1100 *ih = wwin->icon_h;
1101 } else {
1102 *ix = 0;
1103 *iy = 0;
1104 *iw = wwin->screen_ptr->scr_width;
1105 *ih = wwin->screen_ptr->scr_height;
1108 return 1;
1110 #endif /* USE_ANIMATIONS */
1112 void wIconifyWindow(WWindow *wwin)
1114 XWindowAttributes attribs;
1115 int present;
1117 if (!XGetWindowAttributes(dpy, wwin->client_win, &attribs))
1118 return; /* the window doesn't exist anymore */
1120 if (wwin->flags.miniaturized)
1121 return; /* already miniaturized */
1123 if (wwin->transient_for != None && wwin->transient_for != wwin->screen_ptr->root_win) {
1124 WWindow *owner = wWindowFor(wwin->transient_for);
1126 if (owner && owner->flags.miniaturized)
1127 return;
1130 present = wwin->frame->workspace == wwin->screen_ptr->current_workspace;
1132 /* if the window is in another workspace, simplify process */
1133 if (present) {
1134 /* icon creation may take a while */
1135 XGrabPointer(dpy, wwin->screen_ptr->root_win, False,
1136 ButtonMotionMask | ButtonReleaseMask, GrabModeAsync,
1137 GrabModeAsync, None, None, CurrentTime);
1140 if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
1141 if (!wwin->flags.icon_moved)
1142 PlaceIcon(wwin->screen_ptr, &wwin->icon_x, &wwin->icon_y, wGetHeadForWindow(wwin));
1144 wwin->icon = icon_create_for_wwindow(wwin);
1145 wwin->icon->mapped = 1;
1147 /* extract the window screenshot every time, as the option can be enable anytime */
1148 if (wwin->client_win && wwin->flags.mapped) {
1149 RImage *mini_preview;
1150 XImage *pimg;
1151 unsigned int w, h;
1152 int x, y;
1153 Window baz;
1155 XRaiseWindow(dpy, wwin->frame->core->window);
1156 XTranslateCoordinates(dpy, wwin->client_win, wwin->screen_ptr->root_win, 0, 0, &x, &y, &baz);
1158 w = attribs.width;
1159 h = attribs.height;
1161 if (x - attribs.x + attribs.width > wwin->screen_ptr->scr_width)
1162 w = wwin->screen_ptr->scr_width - x + attribs.x;
1164 if (y - attribs.y + attribs.height > wwin->screen_ptr->scr_height)
1165 h = wwin->screen_ptr->scr_height - y + attribs.y;
1167 pimg = XGetImage(dpy, wwin->client_win, 0, 0, w, h, AllPlanes, ZPixmap);
1168 if (pimg) {
1169 mini_preview = RCreateImageFromXImage(wwin->screen_ptr->rcontext, pimg, NULL);
1170 XDestroyImage(pimg);
1172 if (mini_preview) {
1173 set_icon_minipreview(wwin->icon, mini_preview);
1174 RReleaseImage(mini_preview);
1175 } else {
1176 const char *title;
1177 char title_buf[32];
1179 if (wwin->frame->title) {
1180 title = wwin->frame->title;
1181 } else {
1182 snprintf(title_buf, sizeof(title_buf), "(id=0x%lx)", wwin->client_win);
1183 title = title_buf;
1185 wwarning(_("creation of mini-preview failed for window \"%s\""), title);
1191 wwin->flags.miniaturized = 1;
1192 wwin->flags.mapped = 0;
1194 /* unmap transients */
1195 unmapTransientsFor(wwin);
1197 if (present) {
1198 #ifdef USE_ANIMATIONS
1199 int ix, iy, iw, ih;
1200 #endif
1201 XUngrabPointer(dpy, CurrentTime);
1202 wWindowUnmap(wwin);
1203 /* let all Expose events arrive so that we can repaint
1204 * something before the animation starts (and the server is grabbed) */
1205 XSync(dpy, 0);
1207 if (wPreferences.disable_miniwindows || wwin->flags.net_handle_icon)
1208 wClientSetState(wwin, IconicState, None);
1209 else
1210 wClientSetState(wwin, IconicState, wwin->icon->icon_win);
1212 flushExpose();
1213 #ifdef USE_ANIMATIONS
1214 if (getAnimationGeometry(wwin, &ix, &iy, &iw, &ih))
1215 animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
1216 wwin->frame->core->width, wwin->frame->core->height, ix, iy, iw, ih);
1217 #endif
1220 wwin->flags.skip_next_animation = 0;
1222 if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon) {
1223 if (wwin->screen_ptr->current_workspace == wwin->frame->workspace ||
1224 IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)
1225 XMapWindow(dpy, wwin->icon->core->window);
1227 AddToStackList(wwin->icon->core);
1228 wLowerFrame(wwin->icon->core);
1231 if (present) {
1232 WWindow *owner = recursiveTransientFor(wwin->screen_ptr->focused_window);
1235 * It doesn't seem to be working and causes button event hangup
1236 * when deiconifying a transient window.
1237 setupIconGrabs(wwin->icon);
1239 if ((wwin->flags.focused || (owner && wwin->client_win == owner->client_win))
1240 && wPreferences.focus_mode == WKF_CLICK) {
1241 WWindow *tmp;
1243 tmp = wwin->prev;
1244 while (tmp) {
1245 if (!WFLAGP(tmp, no_focusable)
1246 && !(tmp->flags.hidden || tmp->flags.miniaturized)
1247 && (wwin->frame->workspace == tmp->frame->workspace))
1248 break;
1249 tmp = tmp->prev;
1251 wSetFocusTo(wwin->screen_ptr, tmp);
1252 } else if (wPreferences.focus_mode != WKF_CLICK) {
1253 wSetFocusTo(wwin->screen_ptr, NULL);
1255 #ifdef USE_ANIMATIONS
1256 if (!wwin->screen_ptr->flags.startup) {
1257 /* Catch up with events not processed while animation was running */
1258 Window clientwin = wwin->client_win;
1260 ProcessPendingEvents();
1262 /* the window can disappear while ProcessPendingEvents() runs */
1263 if (!wWindowFor(clientwin))
1264 return;
1266 #endif
1269 /* maybe we want to do this regardless of net_handle_icon
1270 * it seems to me we might break behaviour this way.
1272 if (wwin->flags.selected && !wPreferences.disable_miniwindows
1273 && !wwin->flags.net_handle_icon)
1274 wIconSelect(wwin->icon);
1276 WMPostNotificationName(WMNChangedState, wwin, "iconify");
1278 if (wPreferences.auto_arrange_icons)
1279 wArrangeIcons(wwin->screen_ptr, True);
1282 void wDeiconifyWindow(WWindow *wwin)
1284 /* Let's avoid changing workspace while deiconifying */
1285 w_global.ignore_workspace_change = True;
1287 /* we're hiding for show_desktop */
1288 int netwm_hidden = wwin->flags.net_show_desktop &&
1289 wwin->frame->workspace != wwin->screen_ptr->current_workspace;
1291 if (!netwm_hidden)
1292 wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace);
1294 if (!wwin->flags.miniaturized) {
1295 w_global.ignore_workspace_change = False;
1296 return;
1299 if (wwin->transient_for != None && wwin->transient_for != wwin->screen_ptr->root_win) {
1300 WWindow *owner = recursiveTransientFor(wwin);
1302 if (owner && owner->flags.miniaturized) {
1303 wDeiconifyWindow(owner);
1304 wSetFocusTo(wwin->screen_ptr, wwin);
1305 wRaiseFrame(wwin->frame->core);
1306 w_global.ignore_workspace_change = False;
1307 return;
1311 wwin->flags.miniaturized = 0;
1313 if (!netwm_hidden && !wwin->flags.shaded)
1314 wwin->flags.mapped = 1;
1316 if (!netwm_hidden || wPreferences.sticky_icons) {
1317 /* maybe we want to do this regardless of net_handle_icon
1318 * it seems to me we might break behaviour this way.
1320 if (!wPreferences.disable_miniwindows && !wwin->flags.net_handle_icon
1321 && wwin->icon != NULL) {
1322 if (wwin->icon->selected)
1323 wIconSelect(wwin->icon);
1325 XUnmapWindow(dpy, wwin->icon->core->window);
1329 /* if the window is in another workspace, do it silently */
1330 if (!netwm_hidden) {
1331 #ifdef USE_ANIMATIONS
1332 int ix, iy, iw, ih;
1333 if (getAnimationGeometry(wwin, &ix, &iy, &iw, &ih))
1334 animateResize(wwin->screen_ptr, ix, iy, iw, ih,
1335 wwin->frame_x, wwin->frame_y,
1336 wwin->frame->core->width, wwin->frame->core->height);
1337 #endif
1338 wwin->flags.skip_next_animation = 0;
1339 XGrabServer(dpy);
1340 if (!wwin->flags.shaded)
1341 XMapWindow(dpy, wwin->client_win);
1343 XMapWindow(dpy, wwin->frame->core->window);
1344 wRaiseFrame(wwin->frame->core);
1345 if (!wwin->flags.shaded)
1346 wClientSetState(wwin, NormalState, None);
1348 mapTransientsFor(wwin);
1351 if (!wPreferences.disable_miniwindows && wwin->icon != NULL
1352 && !wwin->flags.net_handle_icon) {
1353 RemoveFromStackList(wwin->icon->core);
1354 wSetFocusTo(wwin->screen_ptr, wwin);
1355 wIconDestroy(wwin->icon);
1356 wwin->icon = NULL;
1359 if (!netwm_hidden) {
1360 XUngrabServer(dpy);
1362 wSetFocusTo(wwin->screen_ptr, wwin);
1364 #ifdef USE_ANIMATIONS
1365 if (!wwin->screen_ptr->flags.startup) {
1366 /* Catch up with events not processed while animation was running */
1367 Window clientwin = wwin->client_win;
1369 ProcessPendingEvents();
1371 /* the window can disappear while ProcessPendingEvents() runs */
1372 if (!wWindowFor(clientwin)) {
1373 w_global.ignore_workspace_change = False;
1374 return;
1377 #endif
1380 if (wPreferences.auto_arrange_icons)
1381 wArrangeIcons(wwin->screen_ptr, True);
1383 WMPostNotificationName(WMNChangedState, wwin, "iconify");
1385 /* In case we were shaded and iconified, also unshade */
1386 if (!netwm_hidden)
1387 wUnshadeWindow(wwin);
1389 w_global.ignore_workspace_change = False;
1392 static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate)
1394 if (wwin->flags.miniaturized) {
1395 if (wwin->icon) {
1396 XUnmapWindow(dpy, wwin->icon->core->window);
1397 wwin->icon->mapped = 0;
1399 wwin->flags.hidden = 1;
1401 WMPostNotificationName(WMNChangedState, wwin, "hide");
1402 return;
1405 if (wwin->flags.inspector_open)
1406 wHideInspectorForWindow(wwin);
1408 wwin->flags.hidden = 1;
1409 wWindowUnmap(wwin);
1411 wClientSetState(wwin, IconicState, icon->icon_win);
1412 flushExpose();
1414 #ifdef USE_ANIMATIONS
1415 if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations &&
1416 !wwin->flags.skip_next_animation && animate) {
1417 animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
1418 wwin->frame->core->width, wwin->frame->core->height,
1419 icon_x, icon_y, icon->core->width, icon->core->height);
1421 #else
1422 /* Tell the compiler it is normal that those parameters are not used in this case */
1423 (void) icon_x;
1424 (void) icon_y;
1425 (void) animate;
1426 #endif
1427 wwin->flags.skip_next_animation = 0;
1429 WMPostNotificationName(WMNChangedState, wwin, "hide");
1432 void wHideAll(WScreen *scr)
1434 WWindow *wwin;
1435 WWindow **windows;
1436 WMenu *menu;
1437 unsigned int wcount = 0;
1438 int i;
1440 if (!scr)
1441 return;
1443 menu = scr->switch_menu;
1445 windows = wmalloc(sizeof(WWindow *));
1447 if (menu != NULL) {
1448 for (i = 0; i < menu->entry_no; i++) {
1449 windows[wcount] = (WWindow *) menu->entries[i]->clientdata;
1450 wcount++;
1451 windows = wrealloc(windows, sizeof(WWindow *) * (wcount + 1));
1453 } else {
1454 wwin = scr->focused_window;
1456 while (wwin) {
1457 windows[wcount] = wwin;
1458 wcount++;
1459 windows = wrealloc(windows, sizeof(WWindow *) * (wcount + 1));
1460 wwin = wwin->prev;
1465 for (i = 0; i < wcount; i++) {
1466 wwin = windows[i];
1467 if (wwin->frame->workspace == scr->current_workspace
1468 && !(wwin->flags.miniaturized || wwin->flags.hidden)
1469 && !wwin->flags.internal_window
1470 && !WFLAGP(wwin, no_miniaturizable)
1472 wwin->flags.skip_next_animation = 1;
1473 wIconifyWindow(wwin);
1477 wfree(windows);
1480 void wHideOtherApplications(WWindow *awin)
1482 WWindow *wwin;
1483 WApplication *tapp;
1485 if (!awin)
1486 return;
1487 wwin = awin->screen_ptr->focused_window;
1489 while (wwin) {
1490 if (wwin != awin
1491 && wwin->frame->workspace == awin->screen_ptr->current_workspace
1492 && !(wwin->flags.miniaturized || wwin->flags.hidden)
1493 && !wwin->flags.internal_window
1494 && wGetWindowOfInspectorForWindow(wwin) != awin && !WFLAGP(wwin, no_hide_others)) {
1496 if (wwin->main_window == None || WFLAGP(wwin, no_appicon)) {
1497 if (!WFLAGP(wwin, no_miniaturizable)) {
1498 wwin->flags.skip_next_animation = 1;
1499 wIconifyWindow(wwin);
1501 } else if (wwin->main_window != None && awin->main_window != wwin->main_window) {
1502 tapp = wApplicationOf(wwin->main_window);
1503 if (tapp) {
1504 tapp->flags.skip_next_animation = 1;
1505 wHideApplication(tapp);
1506 } else {
1507 if (!WFLAGP(wwin, no_miniaturizable)) {
1508 wwin->flags.skip_next_animation = 1;
1509 wIconifyWindow(wwin);
1514 wwin = wwin->prev;
1517 wSetFocusTo(awin->screen_ptr, awin);
1521 void wHideApplication(WApplication *wapp)
1523 WScreen *scr;
1524 WWindow *wlist;
1525 int hadfocus;
1526 int animate;
1528 if (!wapp) {
1529 wwarning("trying to hide a non grouped window");
1530 return;
1532 if (!wapp->main_window_desc) {
1533 wwarning("group leader not found for window group");
1534 return;
1536 scr = wapp->main_window_desc->screen_ptr;
1537 hadfocus = 0;
1538 wlist = scr->focused_window;
1539 if (!wlist)
1540 return;
1542 if (wlist->main_window == wapp->main_window)
1543 wapp->last_focused = wlist;
1544 else
1545 wapp->last_focused = NULL;
1547 animate = !wapp->flags.skip_next_animation;
1549 while (wlist) {
1550 if (wlist->main_window == wapp->main_window) {
1551 if (wlist->flags.focused)
1552 hadfocus = 1;
1553 if (wapp->app_icon) {
1554 hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
1555 wapp->app_icon->y_pos, wlist, animate);
1556 animate = False;
1559 wlist = wlist->prev;
1562 wapp->flags.skip_next_animation = 0;
1564 if (hadfocus) {
1565 if (wPreferences.focus_mode == WKF_CLICK) {
1566 wlist = scr->focused_window;
1567 while (wlist) {
1568 if (!WFLAGP(wlist, no_focusable) && !wlist->flags.hidden
1569 && (wlist->flags.mapped || wlist->flags.shaded))
1570 break;
1571 wlist = wlist->prev;
1573 wSetFocusTo(scr, wlist);
1574 } else {
1575 wSetFocusTo(scr, NULL);
1579 wapp->flags.hidden = 1;
1581 if (wPreferences.auto_arrange_icons)
1582 wArrangeIcons(scr, True);
1584 #ifdef HIDDENDOT
1585 if (wapp->app_icon)
1586 wAppIconPaint(wapp->app_icon);
1587 #endif
1590 static void unhideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate, int bringToCurrentWS)
1592 if (bringToCurrentWS)
1593 wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace);
1595 wwin->flags.hidden = 0;
1597 #ifdef USE_ANIMATIONS
1598 if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations && animate) {
1599 animateResize(wwin->screen_ptr, icon_x, icon_y,
1600 icon->core->width, icon->core->height,
1601 wwin->frame_x, wwin->frame_y,
1602 wwin->frame->core->width, wwin->frame->core->height);
1604 #else
1605 /* Tell the compiler it is normal that those parameters are not used in this case */
1606 (void) icon;
1607 (void) icon_x;
1608 (void) icon_y;
1609 (void) animate;
1610 #endif
1611 wwin->flags.skip_next_animation = 0;
1612 if (wwin->screen_ptr->current_workspace == wwin->frame->workspace) {
1613 XMapWindow(dpy, wwin->client_win);
1614 XMapWindow(dpy, wwin->frame->core->window);
1615 wClientSetState(wwin, NormalState, None);
1616 wwin->flags.mapped = 1;
1617 wRaiseFrame(wwin->frame->core);
1619 if (wwin->flags.inspector_open)
1620 wUnhideInspectorForWindow(wwin);
1622 WMPostNotificationName(WMNChangedState, wwin, "hide");
1625 void wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS)
1627 WScreen *scr;
1628 WWindow *wlist, *next;
1629 WWindow *focused = NULL;
1630 int animate;
1632 if (!wapp)
1633 return;
1635 scr = wapp->main_window_desc->screen_ptr;
1636 wlist = scr->focused_window;
1637 if (!wlist)
1638 return;
1640 /* goto beginning of list */
1641 while (wlist->prev)
1642 wlist = wlist->prev;
1644 animate = !wapp->flags.skip_next_animation;
1646 while (wlist) {
1647 next = wlist->next;
1649 if (wlist->main_window == wapp->main_window) {
1650 if (wlist->flags.focused)
1651 focused = wlist;
1652 else if (!focused || !focused->flags.focused)
1653 focused = wlist;
1655 if (wlist->flags.miniaturized) {
1656 if ((bringToCurrentWS || wPreferences.sticky_icons ||
1657 wlist->frame->workspace == scr->current_workspace) && wlist->icon) {
1658 if (!wlist->icon->mapped) {
1659 int x, y;
1661 PlaceIcon(scr, &x, &y, wGetHeadForWindow(wlist));
1662 if (wlist->icon_x != x || wlist->icon_y != y)
1663 XMoveWindow(dpy, wlist->icon->core->window, x, y);
1664 wlist->icon_x = x;
1665 wlist->icon_y = y;
1666 XMapWindow(dpy, wlist->icon->core->window);
1667 wlist->icon->mapped = 1;
1669 wRaiseFrame(wlist->icon->core);
1671 if (bringToCurrentWS)
1672 wWindowChangeWorkspace(wlist, scr->current_workspace);
1673 wlist->flags.hidden = 0;
1674 if (miniwindows && wlist->frame->workspace == scr->current_workspace)
1675 wDeiconifyWindow(wlist);
1676 WMPostNotificationName(WMNChangedState, wlist, "hide");
1677 } else if (wlist->flags.shaded) {
1678 if (bringToCurrentWS)
1679 wWindowChangeWorkspace(wlist, scr->current_workspace);
1680 wlist->flags.hidden = 0;
1681 wRaiseFrame(wlist->frame->core);
1682 if (wlist->frame->workspace == scr->current_workspace) {
1683 XMapWindow(dpy, wlist->frame->core->window);
1684 if (miniwindows)
1685 wUnshadeWindow(wlist);
1687 WMPostNotificationName(WMNChangedState, wlist, "hide");
1688 } else if (wlist->flags.hidden) {
1689 unhideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
1690 wapp->app_icon->y_pos, wlist, animate, bringToCurrentWS);
1691 animate = False;
1692 } else {
1693 if (bringToCurrentWS && wlist->frame->workspace != scr->current_workspace)
1694 wWindowChangeWorkspace(wlist, scr->current_workspace);
1696 wRaiseFrame(wlist->frame->core);
1699 wlist = next;
1702 wapp->flags.skip_next_animation = 0;
1703 wapp->flags.hidden = 0;
1705 if (wapp->last_focused && wapp->last_focused->flags.mapped) {
1706 wRaiseFrame(wapp->last_focused->frame->core);
1707 wSetFocusTo(scr, wapp->last_focused);
1708 } else if (focused) {
1709 wSetFocusTo(scr, focused);
1711 wapp->last_focused = NULL;
1712 if (wPreferences.auto_arrange_icons)
1713 wArrangeIcons(scr, True);
1715 #ifdef HIDDENDOT
1716 wAppIconPaint(wapp->app_icon);
1717 #endif
1720 void wShowAllWindows(WScreen *scr)
1722 WWindow *wwin, *old_foc;
1723 WApplication *wapp;
1725 old_foc = wwin = scr->focused_window;
1726 while (wwin) {
1727 if (!wwin->flags.internal_window &&
1728 (scr->current_workspace == wwin->frame->workspace || IS_OMNIPRESENT(wwin))) {
1729 if (wwin->flags.miniaturized) {
1730 wwin->flags.skip_next_animation = 1;
1731 wDeiconifyWindow(wwin);
1732 } else if (wwin->flags.hidden) {
1733 wapp = wApplicationOf(wwin->main_window);
1734 if (wapp) {
1735 wUnhideApplication(wapp, False, False);
1736 } else {
1737 wwin->flags.skip_next_animation = 1;
1738 wDeiconifyWindow(wwin);
1742 wwin = wwin->prev;
1744 wSetFocusTo(scr, old_foc);
1745 /*wRaiseFrame(old_foc->frame->core); */
1748 void wRefreshDesktop(WScreen *scr)
1750 Window win;
1751 XSetWindowAttributes attr;
1753 attr.backing_store = NotUseful;
1754 attr.save_under = False;
1755 win = XCreateWindow(dpy, scr->root_win, 0, 0, scr->scr_width,
1756 scr->scr_height, 0, CopyFromParent, CopyFromParent,
1757 (Visual *) CopyFromParent, CWBackingStore | CWSaveUnder, &attr);
1758 XMapRaised(dpy, win);
1759 XDestroyWindow(dpy, win);
1760 XFlush(dpy);
1763 void wArrangeIcons(WScreen *scr, Bool arrangeAll)
1765 WWindow *wwin;
1766 WAppIcon *aicon;
1768 int head;
1769 const int heads = wXineramaHeads(scr);
1771 struct HeadVars {
1772 int pf; /* primary axis */
1773 int sf; /* secondary axis */
1774 int fullW;
1775 int fullH;
1776 int pi, si;
1777 int sx1, sx2, sy1, sy2; /* screen boundary */
1778 int sw, sh;
1779 int xo, yo;
1780 int xs, ys;
1781 } *vars;
1783 int isize = wPreferences.icon_size;
1785 vars = (struct HeadVars *)wmalloc(sizeof(struct HeadVars) * heads);
1787 for (head = 0; head < heads; ++head) {
1788 WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
1789 WMRect rect;
1791 if (scr->dock) {
1792 int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE;
1794 if (scr->dock->on_right_side)
1795 area.x2 -= offset;
1796 else
1797 area.x1 += offset;
1800 rect = wmkrect(area.x1, area.y1, area.x2 - area.x1, area.y2 - area.y1);
1802 vars[head].pi = vars[head].si = 0;
1803 vars[head].sx1 = rect.pos.x;
1804 vars[head].sy1 = rect.pos.y;
1805 vars[head].sw = rect.size.width;
1806 vars[head].sh = rect.size.height;
1807 vars[head].sx2 = vars[head].sx1 + vars[head].sw;
1808 vars[head].sy2 = vars[head].sy1 + vars[head].sh;
1809 vars[head].sw = isize * (vars[head].sw / isize);
1810 vars[head].sh = isize * (vars[head].sh / isize);
1811 vars[head].fullW = (vars[head].sx2 - vars[head].sx1) / isize;
1812 vars[head].fullH = (vars[head].sy2 - vars[head].sy1) / isize;
1814 /* icon yard boundaries */
1815 if (wPreferences.icon_yard & IY_VERT) {
1816 vars[head].pf = vars[head].fullH;
1817 vars[head].sf = vars[head].fullW;
1818 } else {
1819 vars[head].pf = vars[head].fullW;
1820 vars[head].sf = vars[head].fullH;
1822 if (wPreferences.icon_yard & IY_RIGHT) {
1823 vars[head].xo = vars[head].sx2 - isize;
1824 vars[head].xs = -1;
1825 } else {
1826 vars[head].xo = vars[head].sx1;
1827 vars[head].xs = 1;
1829 if (wPreferences.icon_yard & IY_TOP) {
1830 vars[head].yo = vars[head].sy1;
1831 vars[head].ys = 1;
1832 } else {
1833 vars[head].yo = vars[head].sy2 - isize;
1834 vars[head].ys = -1;
1838 #define X ((wPreferences.icon_yard & IY_VERT) \
1839 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1840 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1842 #define Y ((wPreferences.icon_yard & IY_VERT) \
1843 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1844 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1846 /* arrange application icons */
1847 aicon = scr->app_icon_list;
1848 /* reverse them to avoid unnecessarily sliding of icons */
1849 while (aicon && aicon->next)
1850 aicon = aicon->next;
1852 while (aicon) {
1853 if (!aicon->docked) {
1854 /* CHECK: can icon be NULL here ? */
1855 /* The intention here is to place the AppIcon on the head that
1856 * contains most of the applications _main_ window. */
1857 head = wGetHeadForWindow(aicon->icon->owner);
1859 if (aicon->x_pos != X || aicon->y_pos != Y) {
1860 #ifdef USE_ANIMATIONS
1861 if (!wPreferences.no_animations)
1862 slide_window(aicon->icon->core->window, aicon->x_pos, aicon->y_pos, X, Y);
1863 #endif /* USE_ANIMATIONS */
1865 wAppIconMove(aicon, X, Y);
1866 vars[head].pi++;
1867 if (vars[head].pi >= vars[head].pf) {
1868 vars[head].pi = 0;
1869 vars[head].si++;
1872 aicon = aicon->prev;
1875 /* arrange miniwindows */
1876 wwin = scr->focused_window;
1877 /* reverse them to avoid unnecessarily shuffling */
1878 while (wwin && wwin->prev)
1879 wwin = wwin->prev;
1881 while (wwin) {
1882 if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden &&
1883 (wwin->frame->workspace == scr->current_workspace ||
1884 IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) {
1886 head = wGetHeadForWindow(wwin);
1888 if (arrangeAll || !wwin->flags.icon_moved) {
1889 if (wwin->icon_x != X || wwin->icon_y != Y)
1890 move_window(wwin->icon->core->window, wwin->icon_x, wwin->icon_y, X, Y);
1892 wwin->icon_x = X;
1893 wwin->icon_y = Y;
1895 vars[head].pi++;
1896 if (vars[head].pi >= vars[head].pf) {
1897 vars[head].pi = 0;
1898 vars[head].si++;
1902 if (arrangeAll)
1903 wwin->flags.icon_moved = 0;
1904 /* we reversed the order, so we use next */
1905 wwin = wwin->next;
1908 wfree(vars);
1911 void wSelectWindow(WWindow *wwin, Bool flag)
1913 WScreen *scr = wwin->screen_ptr;
1915 if (flag) {
1916 wwin->flags.selected = 1;
1917 if (wwin->frame->selected_border_pixel)
1918 XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->selected_border_pixel);
1919 else
1920 XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel);
1922 if (!HAS_BORDER(wwin))
1923 XSetWindowBorderWidth(dpy, wwin->frame->core->window, wwin->screen_ptr->frame_border_width);
1925 if (!scr->selected_windows)
1926 scr->selected_windows = WMCreateArray(4);
1927 WMAddToArray(scr->selected_windows, wwin);
1928 } else {
1929 wwin->flags.selected = 0;
1930 if (wwin->flags.focused) {
1931 if (wwin->frame->focused_border_pixel)
1932 XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->focused_border_pixel);
1933 else
1934 XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_focused_border_pixel);
1935 } else {
1936 if (wwin->frame->border_pixel)
1937 XSetWindowBorder(dpy, wwin->frame->core->window, *wwin->frame->border_pixel);
1938 else
1939 XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel);
1942 if (!HAS_BORDER(wwin))
1943 XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0);
1945 if (scr->selected_windows)
1946 WMRemoveFromArray(scr->selected_windows, wwin);
1950 void wMakeWindowVisible(WWindow *wwin)
1952 if (wwin->frame->workspace != wwin->screen_ptr->current_workspace)
1953 wWorkspaceChange(wwin->screen_ptr, wwin->frame->workspace);
1955 if (wwin->flags.shaded)
1956 wUnshadeWindow(wwin);
1958 if (wwin->flags.hidden) {
1959 WApplication *app;
1961 app = wApplicationOf(wwin->main_window);
1962 if (app) {
1963 /* trick to get focus to this window */
1964 app->last_focused = wwin;
1965 wUnhideApplication(app, False, False);
1968 if (wwin->flags.miniaturized) {
1969 wDeiconifyWindow(wwin);
1970 } else {
1971 if (!WFLAGP(wwin, no_focusable))
1972 wSetFocusTo(wwin->screen_ptr, wwin);
1973 wRaiseFrame(wwin->frame->core);
1978 * Do the animation while shading (called with what = SHADE)
1979 * or unshading (what = UNSHADE).
1981 #ifdef USE_ANIMATIONS
1982 static void shade_animate(WWindow *wwin, Bool what)
1984 int y, s, w, h;
1985 time_t time0 = time(NULL);
1987 if (wwin->flags.skip_next_animation || wPreferences.no_animations)
1988 return;
1990 switch (what) {
1991 case SHADE:
1992 if (!wwin->screen_ptr->flags.startup) {
1993 /* do the shading animation */
1994 h = wwin->frame->core->height;
1995 s = h / SHADE_STEPS;
1996 if (s < 1)
1997 s = 1;
1998 w = wwin->frame->core->width;
1999 y = wwin->frame->top_width;
2000 while (h > wwin->frame->top_width + 1) {
2001 XMoveWindow(dpy, wwin->client_win, 0, y);
2002 XResizeWindow(dpy, wwin->frame->core->window, w, h);
2003 XFlush(dpy);
2005 if (time(NULL) - time0 > MAX_ANIMATION_TIME)
2006 break;
2008 if (SHADE_DELAY > 0)
2009 wusleep(SHADE_DELAY * 1000L);
2010 else
2011 wusleep(10);
2012 h -= s;
2013 y -= s;
2015 XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
2017 break;
2019 case UNSHADE:
2020 h = wwin->frame->top_width + wwin->frame->bottom_width;
2021 y = wwin->frame->top_width - wwin->client.height;
2022 s = abs(y) / SHADE_STEPS;
2023 if (s < 1)
2024 s = 1;
2025 w = wwin->frame->core->width;
2026 XMoveWindow(dpy, wwin->client_win, 0, y);
2027 if (s > 0) {
2028 while (h < wwin->client.height + wwin->frame->top_width + wwin->frame->bottom_width) {
2029 XResizeWindow(dpy, wwin->frame->core->window, w, h);
2030 XMoveWindow(dpy, wwin->client_win, 0, y);
2031 XFlush(dpy);
2032 if (SHADE_DELAY > 0)
2033 wusleep(SHADE_DELAY * 2000L / 3);
2034 else
2035 wusleep(10);
2036 h += s;
2037 y += s;
2039 if (time(NULL) - time0 > MAX_ANIMATION_TIME)
2040 break;
2043 XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
2044 break;
2047 #endif