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.
27 #include <X11/Xutil.h>
34 #include "WindowMaker.h"
40 #include "application.h"
46 #include "winspector.h"
47 #include "workspace.h"
50 #include "placement.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)))
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 *******/
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
86 static int compareTimes(Time t1
, Time t2
)
92 return (diff
< 60000) ? 1 : -1;
96 static void shade_animate(WWindow
*wwin
, Bool what
);
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
110 *----------------------------------------------------------------------
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
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
;
132 if (scr
->flags
.ignore_focus_events
|| compareTimes(w_global
.timestamp
.focus_change
, timestamp
) > 0)
138 old_focused
= old_scr
->focused_window
;
140 w_global
.timestamp
.focus_change
= timestamp
;
143 oapp
= wApplicationOf(old_focused
->main_window
);
146 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
148 wWindowUnfocus(old_focused
);
151 wAppMenuUnmap(oapp
->menu
);
152 if (wPreferences
.highlight_active_app
)
153 wApplicationDeactivate(oapp
);
156 WMPostNotificationName(WMNChangedFocus
, NULL
, (void *)True
);
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 */
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
) {
178 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
181 case WFM_LOCALLY_ACTIVE
:
182 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, CurrentTime
);
184 case WFM_GLOBALLY_ACTIVE
:
189 if (wwin
->protocols
.TAKE_FOCUS
)
190 wClientSendProtocol(wwin
, w_global
.atom
.wm
.take_focus
, timestamp
);
194 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
197 if (WFLAGP(wwin
, no_focusable
))
200 /* if this is not the focused window focus it */
201 if (focused
!= wwin
) {
202 /* change the focus window list order */
204 wwin
->prev
->next
= wwin
->next
;
207 wwin
->next
->prev
= wwin
->prev
;
209 wwin
->prev
= focused
;
210 focused
->next
= wwin
;
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
) {
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
);
243 void wShadeWindow(WWindow
*wwin
)
246 if (wwin
->flags
.shaded
)
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();
280 void wUnshadeWindow(WWindow
*wwin
)
283 if (!wwin
->flags
.shaded
)
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
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
;
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
)
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
)))
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
, int head
)
364 unsigned int new_width
, new_height
, half_scr_width
, half_scr_height
;
369 unsigned int maximus_width
= 0;
370 unsigned int maximus_height
= 0;
371 WArea usableArea
, totalArea
;
374 WScreen
*scr
= wwin
->screen_ptr
;
376 if (!IS_RESIZABLE(wwin
))
379 if (!HAS_BORDER(wwin
))
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
;
397 /* In case of mouse initiated maximize, use the head in which pointer is
398 located, rather than window position, which is passed to the function */
399 if (!(directions
& MAX_IGNORE_XINERAMA
) && !(directions
& MAX_KEYBOARD
)) {
400 WScreen
*scr
= wwin
->screen_ptr
;
401 head
= wGetHeadForPointerLocation(scr
);
404 usableArea
= wGetUsableAreaForHead(scr
, head
, &totalArea
, True
);
406 /* Only save directions, not kbd or xinerama hints */
407 directions
&= (MAX_HORIZONTAL
| MAX_VERTICAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_TOPHALF
| MAX_BOTTOMHALF
| MAX_MAXIMUS
);
409 if (WFLAGP(wwin
, full_maximize
))
410 usableArea
= totalArea
;
411 half_scr_width
= (usableArea
.x2
- usableArea
.x1
)/2;
412 half_scr_height
= (usableArea
.y2
- usableArea
.y1
)/2;
414 if (wwin
->flags
.shaded
) {
415 wwin
->flags
.skip_next_animation
= 1;
416 wUnshadeWindow(wwin
);
419 if (directions
& MAX_MAXIMUS
) {
420 find_Maximus_geometry(wwin
, usableArea
, &maximus_x
, &maximus_y
, &maximus_width
, &maximus_height
);
421 new_width
= maximus_width
- adj_size
;
422 new_height
= maximus_height
- adj_size
;
425 if (WFLAGP(wwin
, full_maximize
) && (new_y
== 0)) {
426 new_height
+= wwin
->frame
->bottom_width
- 1;
427 new_y
-= wwin
->frame
->top_width
;
430 wwin
->maximus_x
= new_x
;
431 wwin
->maximus_y
= new_y
;
432 wwin
->flags
.old_maximized
|= MAX_MAXIMUS
;
434 /* set default values if no option set then */
435 if (!(directions
& (MAX_HORIZONTAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_MAXIMUS
))) {
436 new_width
= (wwin
->old_geometry
.width
) ? wwin
->old_geometry
.width
: wwin
->frame
->core
->width
;
437 new_x
= (wwin
->old_geometry
.x
) ? wwin
->old_geometry
.x
: wwin
->frame_x
;
439 if (!(directions
& (MAX_VERTICAL
| MAX_TOPHALF
| MAX_BOTTOMHALF
| MAX_MAXIMUS
))) {
440 new_height
= (wwin
->old_geometry
.height
) ? wwin
->old_geometry
.height
: wwin
->frame
->core
->height
;
441 new_y
= (wwin
->old_geometry
.y
) ? wwin
->old_geometry
.y
: wwin
->frame_y
;
444 /* left|right position */
445 if (directions
& MAX_LEFTHALF
) {
446 new_width
= half_scr_width
- adj_size
;
447 new_x
= usableArea
.x1
;
448 } else if (directions
& MAX_RIGHTHALF
) {
449 new_width
= half_scr_width
- adj_size
;
450 new_x
= usableArea
.x1
+ half_scr_width
;
452 /* top|bottom position */
453 if (directions
& MAX_TOPHALF
) {
454 new_height
= half_scr_height
- adj_size
;
455 new_y
= usableArea
.y1
;
456 } else if (directions
& MAX_BOTTOMHALF
) {
457 new_height
= half_scr_height
- adj_size
;
458 new_y
= usableArea
.y1
+ half_scr_height
;
461 /* vertical|horizontal position */
462 if (directions
& MAX_HORIZONTAL
) {
463 new_width
= usableArea
.x2
- usableArea
.x1
- adj_size
;
464 new_x
= usableArea
.x1
;
466 if (directions
& MAX_VERTICAL
) {
467 new_height
= usableArea
.y2
- usableArea
.y1
- adj_size
;
468 new_y
= usableArea
.y1
;
469 if (WFLAGP(wwin
, full_maximize
) && (new_y
== 0))
470 new_y
-= wwin
->frame
->top_width
;
474 if (!WFLAGP(wwin
, full_maximize
) && !(directions
== MAX_MAXIMUS
|| directions
== MAX_HORIZONTAL
))
475 new_height
-= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
477 /* set maximization state */
478 wwin
->flags
.maximized
= directions
;
479 if ((wwin
->flags
.old_maximized
& MAX_MAXIMUS
) && !wwin
->flags
.maximized
)
480 wwin
->flags
.maximized
= MAX_MAXIMUS
;
482 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
484 wWindowCropSize(wwin
, usableArea
.x2
- usableArea
.x1
,
485 usableArea
.y2
- usableArea
.y1
, &new_width
, &new_height
);
487 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
488 wWindowSynthConfigureNotify(wwin
);
490 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
493 /* generic (un)maximizer */
494 void handleMaximize(WWindow
*wwin
, int directions
)
496 int current
= wwin
->flags
.maximized
;
497 int requested
= directions
& (MAX_HORIZONTAL
| MAX_VERTICAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_TOPHALF
| MAX_BOTTOMHALF
| MAX_MAXIMUS
);
498 int effective
= requested
^ current
;
499 int flags
= directions
& ~requested
;
500 int head
= wGetHeadForWindow(wwin
);
504 /* allow wMaximizeWindow to restore the Maximusized size */
505 if ((wwin
->flags
.old_maximized
& MAX_MAXIMUS
) &&
506 !(requested
& MAX_MAXIMUS
))
507 wMaximizeWindow(wwin
, MAX_MAXIMUS
| flags
, head
);
509 else if (wPreferences
.move_half_max_between_heads
) {
510 /* Select windows, which are only horizontally or vertically
511 * maximized. Quarters cannot be handled here, since there is not
512 * clear on which direction user intend to move such window. */
513 if (current
& (MAX_VERTICAL
| MAX_HORIZONTAL
)) {
514 if (requested
& MAX_LEFTHALF
&& current
& MAX_LEFTHALF
) {
515 dest_head
= wGetHeadRelativeToCurrentHead(wwin
->screen_ptr
,
516 head
, DIRECTION_LEFT
);
517 if (dest_head
!= -1) {
518 effective
|= MAX_RIGHTHALF
;
519 effective
|= MAX_VERTICAL
;
520 effective
&= ~(MAX_HORIZONTAL
| MAX_LEFTHALF
);
522 } else if (requested
& MAX_RIGHTHALF
&&
523 current
& MAX_RIGHTHALF
) {
524 dest_head
= wGetHeadRelativeToCurrentHead(wwin
->screen_ptr
,
525 head
, DIRECTION_RIGHT
);
526 if (dest_head
!= -1) {
527 effective
|= MAX_LEFTHALF
;
528 effective
|= MAX_VERTICAL
;
529 effective
&= ~(MAX_HORIZONTAL
| MAX_RIGHTHALF
);
531 } else if (requested
& MAX_TOPHALF
&& current
& MAX_TOPHALF
) {
532 dest_head
= wGetHeadRelativeToCurrentHead(wwin
->screen_ptr
,
534 if (dest_head
!= -1) {
535 effective
|= MAX_BOTTOMHALF
;
536 effective
|= MAX_HORIZONTAL
;
537 effective
&= ~(MAX_VERTICAL
| MAX_TOPHALF
);
539 } else if (requested
& MAX_BOTTOMHALF
&&
540 current
& MAX_BOTTOMHALF
) {
541 dest_head
= wGetHeadRelativeToCurrentHead(wwin
->screen_ptr
,
542 head
, DIRECTION_DOWN
);
543 if (dest_head
!= -1) {
544 effective
|= MAX_TOPHALF
;
545 effective
|= MAX_HORIZONTAL
;
546 effective
&= ~(MAX_VERTICAL
| MAX_BOTTOMHALF
);
548 } if (dest_head
!= -1)
549 /* tell wMaximizeWindow that we were using keyboard, not
550 * mouse, so that it will use calculated head as
551 * destination for move_half_max_between_heads feature,
552 * not from mouse pointer */
553 wMaximizeWindow(wwin
, (effective
| flags
| MAX_KEYBOARD
),
556 wUnmaximizeWindow(wwin
);
558 wUnmaximizeWindow(wwin
);
560 wUnmaximizeWindow(wwin
);
561 /* these alone mean vertical|horizontal toggle */
562 } else if ((effective
== MAX_LEFTHALF
) ||
563 (effective
== MAX_RIGHTHALF
) ||
564 (effective
== MAX_TOPHALF
) ||
565 (effective
== MAX_BOTTOMHALF
))
566 wUnmaximizeWindow(wwin
);
568 if ((requested
== (MAX_HORIZONTAL
| MAX_VERTICAL
)) ||
569 (requested
== MAX_MAXIMUS
))
570 effective
= requested
;
572 if (requested
& MAX_LEFTHALF
) {
573 if (!(requested
& (MAX_TOPHALF
| MAX_BOTTOMHALF
)))
574 effective
|= MAX_VERTICAL
;
576 effective
|= requested
& (MAX_TOPHALF
| MAX_BOTTOMHALF
);
577 effective
|= MAX_LEFTHALF
;
578 effective
&= ~(MAX_HORIZONTAL
| MAX_RIGHTHALF
);
579 } else if (requested
& MAX_RIGHTHALF
) {
580 if (!(requested
& (MAX_TOPHALF
| MAX_BOTTOMHALF
)))
581 effective
|= MAX_VERTICAL
;
583 effective
|= requested
& (MAX_TOPHALF
| MAX_BOTTOMHALF
);
584 effective
|= MAX_RIGHTHALF
;
585 effective
&= ~(MAX_HORIZONTAL
| MAX_LEFTHALF
);
587 if (requested
& MAX_TOPHALF
) {
588 if (!(requested
& (MAX_LEFTHALF
| MAX_RIGHTHALF
)))
589 effective
|= MAX_HORIZONTAL
;
591 effective
|= requested
& (MAX_LEFTHALF
| MAX_RIGHTHALF
);
592 effective
|= MAX_TOPHALF
;
593 effective
&= ~(MAX_VERTICAL
| MAX_BOTTOMHALF
);
594 } else if (requested
& MAX_BOTTOMHALF
) {
595 if (!(requested
& (MAX_LEFTHALF
| MAX_RIGHTHALF
)))
596 effective
|= MAX_HORIZONTAL
;
598 effective
|= requested
& (MAX_LEFTHALF
| MAX_RIGHTHALF
);
599 effective
|= MAX_BOTTOMHALF
;
600 effective
&= ~(MAX_VERTICAL
| MAX_TOPHALF
);
602 if (requested
& MAX_HORIZONTAL
)
603 effective
&= ~(MAX_LEFTHALF
| MAX_RIGHTHALF
);
604 if (requested
& MAX_VERTICAL
)
605 effective
&= ~(MAX_TOPHALF
| MAX_BOTTOMHALF
);
606 effective
&= ~MAX_MAXIMUS
;
608 wMaximizeWindow(wwin
, effective
| flags
, head
);
612 /* the window boundary coordinates */
622 static void set_window_coords(WWindow
*wwin
, win_coords
*obs
)
624 obs
->left
= wwin
->frame_x
;
625 obs
->top
= wwin
->frame_y
;
626 obs
->width
= wwin
->frame
->core
->width
;
627 obs
->height
= wwin
->frame
->core
->height
;
628 obs
->bottom
= obs
->top
+ obs
->height
;
629 obs
->right
= obs
->left
+ obs
->width
;
633 * Maximus: tiled maximization (maximize without overlapping other windows)
635 * The original window 'orig' will be maximized to new coordinates 'new'.
636 * The windows obstructing the maximization of 'orig' are denoted 'obs'.
638 static void find_Maximus_geometry(WWindow
*wwin
, WArea usableArea
, int *new_x
, int *new_y
,
639 unsigned int *new_width
, unsigned int *new_height
)
642 short int tbar_height_0
= 0, rbar_height_0
= 0, bd_width_0
= 0;
643 short int adjust_height
;
644 int x_intsect
, y_intsect
;
645 /* the obstructing, original and new windows */
646 win_coords obs
, orig
, new;
648 /* set the original coordinate positions of the window to be Maximumized */
649 if (wwin
->flags
.maximized
) {
650 /* window is already maximized; consider original geometry */
651 remember_geometry(wwin
, &orig
.left
, &orig
.top
, &orig
.width
, &orig
.height
);
652 orig
.bottom
= orig
.top
+ orig
.height
;
653 orig
.right
= orig
.left
+ orig
.width
;
655 set_window_coords(wwin
, &orig
);
657 /* Try to fully maximize first, then readjust later */
658 new.left
= usableArea
.x1
;
659 new.right
= usableArea
.x2
;
660 new.top
= usableArea
.y1
;
661 new.bottom
= usableArea
.y2
;
663 if (HAS_TITLEBAR(wwin
))
664 tbar_height_0
= TITLEBAR_HEIGHT
;
665 if (HAS_RESIZEBAR(wwin
))
666 rbar_height_0
= RESIZEBAR_HEIGHT
;
667 if (HAS_BORDER(wwin
))
668 bd_width_0
= wwin
->screen_ptr
->frame_border_width
;
670 /* the length to be subtracted if the window has titlebar, etc */
671 adjust_height
= tbar_height_0
+ 2 * bd_width_0
+ rbar_height_0
;
674 /* The focused window is always the last in the list */
676 /* ignore windows in other workspaces etc */
677 if (tmp
->prev
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
678 || tmp
->prev
->flags
.miniaturized
|| tmp
->prev
->flags
.hidden
) {
684 /* Set the coordinates of obstructing window */
685 set_window_coords(tmp
, &obs
);
687 /* Try to maximize in the y direction first */
688 x_intsect
= calcIntersectionLength(orig
.left
, orig
.width
, obs
.left
, obs
.width
);
689 if (x_intsect
!= 0) {
690 /* TODO: Consider the case when coords are equal */
691 if (obs
.bottom
< orig
.top
&& obs
.bottom
> new.top
) {
692 /* w_0 is below the bottom of w_j */
693 new.top
= obs
.bottom
+ 1;
695 if (orig
.bottom
< obs
.top
&& obs
.top
< new.bottom
) {
696 /* The bottom of w_0 is above the top of w_j */
697 new.bottom
= obs
.top
- 1;
704 if (tmp
->prev
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
705 || tmp
->prev
->flags
.miniaturized
|| tmp
->prev
->flags
.hidden
) {
711 set_window_coords(tmp
, &obs
);
714 * Use the new.top and new.height instead of original values
715 * as they may have different intersections with the obstructing windows
717 new.height
= new.bottom
- new.top
- adjust_height
;
718 y_intsect
= calcIntersectionLength(new.top
, new.height
, obs
.top
, obs
.height
);
719 if (y_intsect
!= 0) {
720 if (obs
.right
< orig
.left
&& obs
.right
> new.left
) {
721 /* w_0 is completely to the right of w_j */
722 new.left
= obs
.right
+ 1;
724 if (orig
.right
< obs
.left
&& obs
.left
< new.right
) {
725 /* w_0 is completely to the left of w_j */
726 new.right
= obs
.left
- 1;
733 /* xcalc needs -7 here, but other apps don't */
734 *new_height
= new.bottom
- new.top
- adjust_height
- 1;
735 *new_width
= new.right
- new.left
;
738 void wUnmaximizeWindow(WWindow
*wwin
)
742 if (!wwin
->flags
.maximized
)
745 if (wwin
->flags
.shaded
) {
746 wwin
->flags
.skip_next_animation
= 1;
747 wUnshadeWindow(wwin
);
750 if (wPreferences
.drag_maximized_window
== DRAGMAX_NOMOVE
)
751 wwin
->client_flags
.no_movable
= 0;
753 /* Use old coordinates if they are set, current values otherwise */
754 remember_geometry(wwin
, &x
, &y
, &w
, &h
);
756 /* unMaximusize relative to original position */
757 if (wwin
->flags
.maximized
& MAX_MAXIMUS
) {
758 x
+= wwin
->frame_x
- wwin
->maximus_x
;
759 y
+= wwin
->frame_y
- wwin
->maximus_y
;
762 wwin
->flags
.maximized
= 0;
763 wwin
->flags
.old_maximized
= 0;
764 wWindowConfigure(wwin
, x
, y
, w
, h
);
765 wWindowSynthConfigureNotify(wwin
);
767 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
770 void wFullscreenWindow(WWindow
*wwin
)
775 if (wwin
->flags
.fullscreen
)
778 wwin
->flags
.fullscreen
= True
;
780 wWindowConfigureBorders(wwin
);
782 ChangeStackingLevel(wwin
->frame
->core
, WMFullscreenLevel
);
784 wwin
->bfs_geometry
.x
= wwin
->frame_x
;
785 wwin
->bfs_geometry
.y
= wwin
->frame_y
;
786 wwin
->bfs_geometry
.width
= wwin
->frame
->core
->width
;
787 wwin
->bfs_geometry
.height
= wwin
->frame
->core
->height
;
789 head
= wGetHeadForWindow(wwin
);
790 rect
= wGetRectForHead(wwin
->screen_ptr
, head
);
791 wWindowConfigure(wwin
, rect
.pos
.x
, rect
.pos
.y
, rect
.size
.width
, rect
.size
.height
);
793 wwin
->screen_ptr
->bfs_focused_window
= wwin
->screen_ptr
->focused_window
;
794 wSetFocusTo(wwin
->screen_ptr
, wwin
);
796 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
799 void wUnfullscreenWindow(WWindow
*wwin
)
801 if (!wwin
->flags
.fullscreen
)
804 wwin
->flags
.fullscreen
= False
;
806 if (wwin
->frame
->core
->stacking
->window_level
== WMFullscreenLevel
) {
807 if (WFLAGP(wwin
, sunken
)) {
808 ChangeStackingLevel(wwin
->frame
->core
, WMSunkenLevel
);
809 } else if (WFLAGP(wwin
, floating
)) {
810 ChangeStackingLevel(wwin
->frame
->core
, WMFloatingLevel
);
812 ChangeStackingLevel(wwin
->frame
->core
, WMNormalLevel
);
816 wWindowConfigure(wwin
, wwin
->bfs_geometry
.x
, wwin
->bfs_geometry
.y
,
817 wwin
->bfs_geometry
.width
, wwin
->bfs_geometry
.height
);
819 wWindowConfigureBorders(wwin
);
821 // seems unnecessary, but also harmless (doesn't generate flicker) -Dan
822 wFrameWindowPaint(wwin->frame);
825 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
827 if (wwin
->screen_ptr
->bfs_focused_window
) {
828 wSetFocusTo(wwin
->screen_ptr
, wwin
->screen_ptr
->bfs_focused_window
);
829 wwin
->screen_ptr
->bfs_focused_window
= NULL
;
833 #ifdef USE_ANIMATIONS
834 static void animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
, int fx
, int fy
, int fw
, int fh
, int steps
)
836 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
837 float cx
, cy
, cw
, ch
;
838 float xstep
, ystep
, wstep
, hstep
;
841 float angle
, final_angle
, delta
;
843 xstep
= (float)(fx
- x
) / steps
;
844 ystep
= (float)(fy
- y
) / steps
;
845 wstep
= (float)(fw
- w
) / steps
;
846 hstep
= (float)(fh
- h
) / steps
;
853 final_angle
= 2 * WM_PI
* MINIATURIZE_ANIMATION_TWIST_F
;
854 delta
= (float)(final_angle
/ FRAMES
);
855 for (angle
= 0;; angle
+= delta
) {
856 if (angle
> final_angle
)
859 dx
= (cw
/ 10) - ((cw
/ 5) * sinf(angle
));
860 dch
= (ch
/ 2) * cosf(angle
);
861 midy
= cy
+ (ch
/ 2);
863 points
[0].x
= cx
+ dx
;
864 points
[0].y
= midy
- dch
;
865 points
[1].x
= cx
+ cw
- dx
;
866 points
[1].y
= points
[0].y
;
867 points
[2].x
= cx
+ cw
+ dx
;
868 points
[2].y
= midy
+ dch
;
869 points
[3].x
= cx
- dx
;
870 points
[3].y
= points
[2].y
;
871 points
[4].x
= points
[0].x
;
872 points
[4].y
= points
[0].y
;
875 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
877 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
879 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
885 if (angle
>= final_angle
)
895 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
, int fx
, int fy
, int fw
, int fh
, int steps
)
897 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
898 float cx
, cy
, cw
, ch
;
899 float xstep
, ystep
, wstep
, hstep
;
901 float angle
, final_angle
, a
, d
, delta
;
908 xstep
= (float)(fx
- x
) / steps
;
909 ystep
= (float)(fy
- y
) / steps
;
910 wstep
= (float)(fw
- w
) / steps
;
911 hstep
= (float)(fh
- h
) / steps
;
918 final_angle
= 2 * WM_PI
* MINIATURIZE_ANIMATION_TWIST_T
;
919 delta
= (float)(final_angle
/ FRAMES
);
920 for (angle
= 0;; angle
+= delta
) {
921 if (angle
> final_angle
)
925 d
= sqrtf((cw
/ 2) * (cw
/ 2) + (ch
/ 2) * (ch
/ 2));
927 points
[0].x
= cx
+ cosf(angle
- a
) * d
;
928 points
[0].y
= cy
+ sinf(angle
- a
) * d
;
929 points
[1].x
= cx
+ cosf(angle
+ a
) * d
;
930 points
[1].y
= cy
+ sinf(angle
+ a
) * d
;
931 points
[2].x
= cx
+ cosf(angle
- a
+ (float)WM_PI
) * d
;
932 points
[2].y
= cy
+ sinf(angle
- a
+ (float)WM_PI
) * d
;
933 points
[3].x
= cx
+ cosf(angle
+ a
+ (float)WM_PI
) * d
;
934 points
[3].y
= cy
+ sinf(angle
+ a
+ (float)WM_PI
) * d
;
935 points
[4].x
= cx
+ cosf(angle
- a
) * d
;
936 points
[4].y
= cy
+ sinf(angle
- a
) * d
;
938 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
940 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
942 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
948 if (angle
>= final_angle
)
957 static void animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
, int fx
, int fy
, int fw
, int fh
, int steps
)
959 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
960 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
961 float xstep
, ystep
, wstep
, hstep
;
964 xstep
= (float)(fx
- x
) / steps
;
965 ystep
= (float)(fy
- y
) / steps
;
966 wstep
= (float)(fw
- w
) / steps
;
967 hstep
= (float)(fh
- h
) / steps
;
969 for (j
= 0; j
< FRAMES
; j
++) {
976 for (i
= 0; i
< steps
; i
++) {
977 for (j
= 0; j
< FRAMES
; j
++) {
978 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
979 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
982 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
984 for (j
= 0; j
< FRAMES
; j
++) {
985 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
986 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
987 if (j
< FRAMES
- 1) {
1001 for (j
= 0; j
< FRAMES
; j
++)
1002 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
, (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
1004 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
1006 for (j
= 0; j
< FRAMES
; j
++)
1007 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
, (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
1014 void animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
, int fx
, int fy
, int fw
, int fh
)
1016 int style
= wPreferences
.iconification_style
; /* Catch the value */
1019 if (style
== WIS_NONE
)
1022 if (style
== WIS_RANDOM
)
1027 steps
= MINIATURIZE_ANIMATION_STEPS_T
;
1029 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
1032 steps
= MINIATURIZE_ANIMATION_STEPS_F
;
1034 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
1038 steps
= MINIATURIZE_ANIMATION_STEPS_Z
;
1040 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
1044 #endif /* USE_ANIMATIONS */
1046 static void flushExpose(void)
1050 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
1051 WMHandleEvent(&tmpev
);
1055 static void unmapTransientsFor(WWindow
*wwin
)
1059 tmp
= wwin
->screen_ptr
->focused_window
;
1061 /* unmap the transients for this transient */
1062 if (tmp
!= wwin
&& tmp
->transient_for
== wwin
->client_win
1063 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
|| tmp
->flags
.shaded
)) {
1064 unmapTransientsFor(tmp
);
1065 tmp
->flags
.miniaturized
= 1;
1066 if (!tmp
->flags
.shaded
)
1069 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
1071 if (!tmp->flags.shaded)
1073 wClientSetState(tmp
, IconicState
, None
);
1075 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
1081 static void mapTransientsFor(WWindow
*wwin
)
1085 tmp
= wwin
->screen_ptr
->focused_window
;
1087 /* recursively map the transients for this transient */
1088 if (tmp
!= wwin
&& tmp
->transient_for
== wwin
->client_win
&& /*!tmp->flags.mapped */ tmp
->flags
.miniaturized
1089 && tmp
->icon
== NULL
) {
1090 mapTransientsFor(tmp
);
1091 tmp
->flags
.miniaturized
= 0;
1092 if (!tmp
->flags
.shaded
)
1095 XMapWindow(dpy
, tmp
->frame
->core
->window
);
1096 tmp
->flags
.semi_focused
= 0;
1098 if (!tmp->flags.shaded)
1100 wClientSetState(tmp
, NormalState
, None
);
1102 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
1108 static WWindow
*recursiveTransientFor(WWindow
*wwin
)
1115 /* hackish way to detect transient_for cycle */
1116 i
= wwin
->screen_ptr
->window_count
+ 1;
1118 while (wwin
&& wwin
->transient_for
!= None
&& i
> 0) {
1119 wwin
= wWindowFor(wwin
->transient_for
);
1122 if (i
== 0 && wwin
) {
1123 wwarning(_("window \"%s\" has a severely broken WM_TRANSIENT_FOR hint"),
1124 wwin
->frame
->title
);
1131 #ifdef USE_ANIMATIONS
1132 static int getAnimationGeometry(WWindow
*wwin
, int *ix
, int *iy
, int *iw
, int *ih
)
1134 if (wwin
->screen_ptr
->flags
.startup
|| wPreferences
.no_animations
1135 || wwin
->flags
.skip_next_animation
|| wwin
->icon
== NULL
)
1138 if (!wPreferences
.disable_miniwindows
&& !wwin
->flags
.net_handle_icon
) {
1141 *iw
= wwin
->icon
->core
->width
;
1142 *ih
= wwin
->icon
->core
->height
;
1144 if (wwin
->flags
.net_handle_icon
) {
1152 *iw
= wwin
->screen_ptr
->scr_width
;
1153 *ih
= wwin
->screen_ptr
->scr_height
;
1158 #endif /* USE_ANIMATIONS */
1160 void wIconifyWindow(WWindow
*wwin
)
1162 XWindowAttributes attribs
;
1165 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
))
1166 return; /* the window doesn't exist anymore */
1168 if (wwin
->flags
.miniaturized
)
1169 return; /* already miniaturized */
1171 if (wwin
->transient_for
!= None
&& wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1172 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
1174 if (owner
&& owner
->flags
.miniaturized
)
1178 present
= wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
;
1180 /* if the window is in another workspace, simplify process */
1182 /* icon creation may take a while */
1183 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
1184 ButtonMotionMask
| ButtonReleaseMask
, GrabModeAsync
,
1185 GrabModeAsync
, None
, None
, CurrentTime
);
1188 if (!wPreferences
.disable_miniwindows
&& !wwin
->flags
.net_handle_icon
) {
1189 if (!wwin
->flags
.icon_moved
)
1190 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
, wGetHeadForWindow(wwin
));
1192 wwin
->icon
= icon_create_for_wwindow(wwin
);
1193 wwin
->icon
->mapped
= 1;
1195 /* extract the window screenshot every time, as the option can be enable anytime */
1196 if (wwin
->client_win
&& wwin
->flags
.mapped
) {
1197 RImage
*mini_preview
;
1203 XRaiseWindow(dpy
, wwin
->frame
->core
->window
);
1204 XTranslateCoordinates(dpy
, wwin
->client_win
, wwin
->screen_ptr
->root_win
, 0, 0, &x
, &y
, &baz
);
1209 if (x
- attribs
.x
+ attribs
.width
> wwin
->screen_ptr
->scr_width
)
1210 w
= wwin
->screen_ptr
->scr_width
- x
+ attribs
.x
;
1212 if (y
- attribs
.y
+ attribs
.height
> wwin
->screen_ptr
->scr_height
)
1213 h
= wwin
->screen_ptr
->scr_height
- y
+ attribs
.y
;
1215 pimg
= XGetImage(dpy
, wwin
->client_win
, 0, 0, w
, h
, AllPlanes
, ZPixmap
);
1217 mini_preview
= RCreateImageFromXImage(wwin
->screen_ptr
->rcontext
, pimg
, NULL
);
1218 XDestroyImage(pimg
);
1221 set_icon_minipreview(wwin
->icon
, mini_preview
);
1222 RReleaseImage(mini_preview
);
1227 if (wwin
->frame
->title
) {
1228 title
= wwin
->frame
->title
;
1230 snprintf(title_buf
, sizeof(title_buf
), "(id=0x%lx)", wwin
->client_win
);
1233 wwarning(_("creation of mini-preview failed for window \"%s\""), title
);
1239 wwin
->flags
.miniaturized
= 1;
1240 wwin
->flags
.mapped
= 0;
1242 /* unmap transients */
1243 unmapTransientsFor(wwin
);
1246 #ifdef USE_ANIMATIONS
1249 XUngrabPointer(dpy
, CurrentTime
);
1251 /* let all Expose events arrive so that we can repaint
1252 * something before the animation starts (and the server is grabbed) */
1255 if (wPreferences
.disable_miniwindows
|| wwin
->flags
.net_handle_icon
)
1256 wClientSetState(wwin
, IconicState
, None
);
1258 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
1261 #ifdef USE_ANIMATIONS
1262 if (getAnimationGeometry(wwin
, &ix
, &iy
, &iw
, &ih
))
1263 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1264 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
, ix
, iy
, iw
, ih
);
1268 wwin
->flags
.skip_next_animation
= 0;
1270 if (!wPreferences
.disable_miniwindows
&& !wwin
->flags
.net_handle_icon
) {
1271 if (wwin
->screen_ptr
->current_workspace
== wwin
->frame
->workspace
||
1272 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1273 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1275 AddToStackList(wwin
->icon
->core
);
1276 wLowerFrame(wwin
->icon
->core
);
1280 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1283 * It doesn't seem to be working and causes button event hangup
1284 * when deiconifying a transient window.
1285 setupIconGrabs(wwin->icon);
1287 if ((wwin
->flags
.focused
|| (owner
&& wwin
->client_win
== owner
->client_win
))
1288 && wPreferences
.focus_mode
== WKF_CLICK
) {
1293 if (!WFLAGP(tmp
, no_focusable
)
1294 && !(tmp
->flags
.hidden
|| tmp
->flags
.miniaturized
)
1295 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1299 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1300 } else if (wPreferences
.focus_mode
!= WKF_CLICK
) {
1301 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1303 #ifdef USE_ANIMATIONS
1304 if (!wwin
->screen_ptr
->flags
.startup
) {
1305 /* Catch up with events not processed while animation was running */
1306 Window clientwin
= wwin
->client_win
;
1308 ProcessPendingEvents();
1310 /* the window can disappear while ProcessPendingEvents() runs */
1311 if (!wWindowFor(clientwin
))
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 (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
1321 && !wwin
->flags
.net_handle_icon
)
1322 wIconSelect(wwin
->icon
);
1324 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1326 if (wPreferences
.auto_arrange_icons
)
1327 wArrangeIcons(wwin
->screen_ptr
, True
);
1330 void wDeiconifyWindow(WWindow
*wwin
)
1332 /* Let's avoid changing workspace while deiconifying */
1333 w_global
.ignore_workspace_change
= True
;
1335 /* we're hiding for show_desktop */
1336 int netwm_hidden
= wwin
->flags
.net_show_desktop
&&
1337 wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
;
1340 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1342 if (!wwin
->flags
.miniaturized
) {
1343 w_global
.ignore_workspace_change
= False
;
1347 if (wwin
->transient_for
!= None
&& wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1348 WWindow
*owner
= recursiveTransientFor(wwin
);
1350 if (owner
&& owner
->flags
.miniaturized
) {
1351 wDeiconifyWindow(owner
);
1352 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1353 wRaiseFrame(wwin
->frame
->core
);
1354 w_global
.ignore_workspace_change
= False
;
1359 wwin
->flags
.miniaturized
= 0;
1361 if (!netwm_hidden
&& !wwin
->flags
.shaded
)
1362 wwin
->flags
.mapped
= 1;
1364 if (!netwm_hidden
|| wPreferences
.sticky_icons
) {
1365 /* maybe we want to do this regardless of net_handle_icon
1366 * it seems to me we might break behaviour this way.
1368 if (!wPreferences
.disable_miniwindows
&& !wwin
->flags
.net_handle_icon
1369 && wwin
->icon
!= NULL
) {
1370 if (wwin
->icon
->selected
)
1371 wIconSelect(wwin
->icon
);
1373 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1377 /* if the window is in another workspace, do it silently */
1378 if (!netwm_hidden
) {
1379 #ifdef USE_ANIMATIONS
1381 if (getAnimationGeometry(wwin
, &ix
, &iy
, &iw
, &ih
))
1382 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1383 wwin
->frame_x
, wwin
->frame_y
,
1384 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
1386 wwin
->flags
.skip_next_animation
= 0;
1388 if (!wwin
->flags
.shaded
)
1389 XMapWindow(dpy
, wwin
->client_win
);
1391 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1392 wRaiseFrame(wwin
->frame
->core
);
1393 if (!wwin
->flags
.shaded
)
1394 wClientSetState(wwin
, NormalState
, None
);
1396 mapTransientsFor(wwin
);
1399 if (!wPreferences
.disable_miniwindows
&& wwin
->icon
!= NULL
1400 && !wwin
->flags
.net_handle_icon
) {
1401 RemoveFromStackList(wwin
->icon
->core
);
1402 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1403 wIconDestroy(wwin
->icon
);
1407 if (!netwm_hidden
) {
1410 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1412 #ifdef USE_ANIMATIONS
1413 if (!wwin
->screen_ptr
->flags
.startup
) {
1414 /* Catch up with events not processed while animation was running */
1415 Window clientwin
= wwin
->client_win
;
1417 ProcessPendingEvents();
1419 /* the window can disappear while ProcessPendingEvents() runs */
1420 if (!wWindowFor(clientwin
)) {
1421 w_global
.ignore_workspace_change
= False
;
1428 if (wPreferences
.auto_arrange_icons
)
1429 wArrangeIcons(wwin
->screen_ptr
, True
);
1431 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1433 /* In case we were shaded and iconified, also unshade */
1435 wUnshadeWindow(wwin
);
1437 w_global
.ignore_workspace_change
= False
;
1440 static void hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1442 if (wwin
->flags
.miniaturized
) {
1444 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1445 wwin
->icon
->mapped
= 0;
1447 wwin
->flags
.hidden
= 1;
1449 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1453 if (wwin
->flags
.inspector_open
)
1454 wHideInspectorForWindow(wwin
);
1456 wwin
->flags
.hidden
= 1;
1459 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1462 #ifdef USE_ANIMATIONS
1463 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1464 !wwin
->flags
.skip_next_animation
&& animate
) {
1465 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1466 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1467 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
);
1470 /* Tell the compiler it is normal that those parameters are not used in this case */
1475 wwin
->flags
.skip_next_animation
= 0;
1477 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1480 void wHideAll(WScreen
*scr
)
1485 unsigned int wcount
= 0;
1491 menu
= scr
->switch_menu
;
1493 windows
= wmalloc(sizeof(WWindow
*));
1496 for (i
= 0; i
< menu
->entry_no
; i
++) {
1497 windows
[wcount
] = (WWindow
*) menu
->entries
[i
]->clientdata
;
1499 windows
= wrealloc(windows
, sizeof(WWindow
*) * (wcount
+ 1));
1502 wwin
= scr
->focused_window
;
1505 windows
[wcount
] = wwin
;
1507 windows
= wrealloc(windows
, sizeof(WWindow
*) * (wcount
+ 1));
1513 for (i
= 0; i
< wcount
; i
++) {
1515 if (wwin
->frame
->workspace
== scr
->current_workspace
1516 && !(wwin
->flags
.miniaturized
|| wwin
->flags
.hidden
)
1517 && !wwin
->flags
.internal_window
1518 && !WFLAGP(wwin
, no_miniaturizable
)
1520 wwin
->flags
.skip_next_animation
= 1;
1521 wIconifyWindow(wwin
);
1528 void wHideOtherApplications(WWindow
*awin
)
1535 wwin
= awin
->screen_ptr
->focused_window
;
1539 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1540 && !(wwin
->flags
.miniaturized
|| wwin
->flags
.hidden
)
1541 && !wwin
->flags
.internal_window
1542 && wGetWindowOfInspectorForWindow(wwin
) != awin
&& !WFLAGP(wwin
, no_hide_others
)) {
1544 if (wwin
->main_window
== None
|| WFLAGP(wwin
, no_appicon
)) {
1545 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1546 wwin
->flags
.skip_next_animation
= 1;
1547 wIconifyWindow(wwin
);
1549 } else if (wwin
->main_window
!= None
&& awin
->main_window
!= wwin
->main_window
) {
1550 tapp
= wApplicationOf(wwin
->main_window
);
1552 tapp
->flags
.skip_next_animation
= 1;
1553 wHideApplication(tapp
);
1555 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1556 wwin
->flags
.skip_next_animation
= 1;
1557 wIconifyWindow(wwin
);
1565 wSetFocusTo(awin->screen_ptr, awin);
1569 void wHideApplication(WApplication
*wapp
)
1577 wwarning("trying to hide a non grouped window");
1580 if (!wapp
->main_window_desc
) {
1581 wwarning("group leader not found for window group");
1584 scr
= wapp
->main_window_desc
->screen_ptr
;
1586 wlist
= scr
->focused_window
;
1590 if (wlist
->main_window
== wapp
->main_window
)
1591 wapp
->last_focused
= wlist
;
1593 wapp
->last_focused
= NULL
;
1595 animate
= !wapp
->flags
.skip_next_animation
;
1598 if (wlist
->main_window
== wapp
->main_window
) {
1599 if (wlist
->flags
.focused
)
1601 if (wapp
->app_icon
) {
1602 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1603 wapp
->app_icon
->y_pos
, wlist
, animate
);
1607 wlist
= wlist
->prev
;
1610 wapp
->flags
.skip_next_animation
= 0;
1613 if (wPreferences
.focus_mode
== WKF_CLICK
) {
1614 wlist
= scr
->focused_window
;
1616 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1617 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1619 wlist
= wlist
->prev
;
1621 wSetFocusTo(scr
, wlist
);
1623 wSetFocusTo(scr
, NULL
);
1627 wapp
->flags
.hidden
= 1;
1629 if (wPreferences
.auto_arrange_icons
)
1630 wArrangeIcons(scr
, True
);
1634 wAppIconPaint(wapp
->app_icon
);
1638 static void unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
, int bringToCurrentWS
)
1640 if (bringToCurrentWS
)
1641 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1643 wwin
->flags
.hidden
= 0;
1645 #ifdef USE_ANIMATIONS
1646 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&& animate
) {
1647 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1648 icon
->core
->width
, icon
->core
->height
,
1649 wwin
->frame_x
, wwin
->frame_y
,
1650 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
1653 /* Tell the compiler it is normal that those parameters are not used in this case */
1659 wwin
->flags
.skip_next_animation
= 0;
1660 if (wwin
->screen_ptr
->current_workspace
== wwin
->frame
->workspace
) {
1661 XMapWindow(dpy
, wwin
->client_win
);
1662 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1663 wClientSetState(wwin
, NormalState
, None
);
1664 wwin
->flags
.mapped
= 1;
1665 wRaiseFrame(wwin
->frame
->core
);
1667 if (wwin
->flags
.inspector_open
)
1668 wUnhideInspectorForWindow(wwin
);
1670 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1673 void wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1676 WWindow
*wlist
, *next
;
1677 WWindow
*focused
= NULL
;
1683 scr
= wapp
->main_window_desc
->screen_ptr
;
1684 wlist
= scr
->focused_window
;
1688 /* goto beginning of list */
1690 wlist
= wlist
->prev
;
1692 animate
= !wapp
->flags
.skip_next_animation
;
1697 if (wlist
->main_window
== wapp
->main_window
) {
1698 if (wlist
->flags
.focused
)
1700 else if (!focused
|| !focused
->flags
.focused
)
1703 if (wlist
->flags
.miniaturized
) {
1704 if ((bringToCurrentWS
|| wPreferences
.sticky_icons
||
1705 wlist
->frame
->workspace
== scr
->current_workspace
) && wlist
->icon
) {
1706 if (!wlist
->icon
->mapped
) {
1709 PlaceIcon(scr
, &x
, &y
, wGetHeadForWindow(wlist
));
1710 if (wlist
->icon_x
!= x
|| wlist
->icon_y
!= y
)
1711 XMoveWindow(dpy
, wlist
->icon
->core
->window
, x
, y
);
1714 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1715 wlist
->icon
->mapped
= 1;
1717 wRaiseFrame(wlist
->icon
->core
);
1719 if (bringToCurrentWS
)
1720 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1721 wlist
->flags
.hidden
= 0;
1722 if (miniwindows
&& wlist
->frame
->workspace
== scr
->current_workspace
)
1723 wDeiconifyWindow(wlist
);
1724 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1725 } else if (wlist
->flags
.shaded
) {
1726 if (bringToCurrentWS
)
1727 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1728 wlist
->flags
.hidden
= 0;
1729 wRaiseFrame(wlist
->frame
->core
);
1730 if (wlist
->frame
->workspace
== scr
->current_workspace
) {
1731 XMapWindow(dpy
, wlist
->frame
->core
->window
);
1733 wUnshadeWindow(wlist
);
1735 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1736 } else if (wlist
->flags
.hidden
) {
1737 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1738 wapp
->app_icon
->y_pos
, wlist
, animate
, bringToCurrentWS
);
1741 if (bringToCurrentWS
&& wlist
->frame
->workspace
!= scr
->current_workspace
)
1742 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1744 wRaiseFrame(wlist
->frame
->core
);
1750 wapp
->flags
.skip_next_animation
= 0;
1751 wapp
->flags
.hidden
= 0;
1753 if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
) {
1754 wRaiseFrame(wapp
->last_focused
->frame
->core
);
1755 wSetFocusTo(scr
, wapp
->last_focused
);
1756 } else if (focused
) {
1757 wSetFocusTo(scr
, focused
);
1759 wapp
->last_focused
= NULL
;
1760 if (wPreferences
.auto_arrange_icons
)
1761 wArrangeIcons(scr
, True
);
1764 wAppIconPaint(wapp
->app_icon
);
1768 void wShowAllWindows(WScreen
*scr
)
1770 WWindow
*wwin
, *old_foc
;
1773 old_foc
= wwin
= scr
->focused_window
;
1775 if (!wwin
->flags
.internal_window
&&
1776 (scr
->current_workspace
== wwin
->frame
->workspace
|| IS_OMNIPRESENT(wwin
))) {
1777 if (wwin
->flags
.miniaturized
) {
1778 wwin
->flags
.skip_next_animation
= 1;
1779 wDeiconifyWindow(wwin
);
1780 } else if (wwin
->flags
.hidden
) {
1781 wapp
= wApplicationOf(wwin
->main_window
);
1783 wUnhideApplication(wapp
, False
, False
);
1785 wwin
->flags
.skip_next_animation
= 1;
1786 wDeiconifyWindow(wwin
);
1792 wSetFocusTo(scr
, old_foc
);
1793 /*wRaiseFrame(old_foc->frame->core); */
1796 void wRefreshDesktop(WScreen
*scr
)
1799 XSetWindowAttributes attr
;
1801 attr
.backing_store
= NotUseful
;
1802 attr
.save_under
= False
;
1803 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1804 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1805 (Visual
*) CopyFromParent
, CWBackingStore
| CWSaveUnder
, &attr
);
1806 XMapRaised(dpy
, win
);
1807 XDestroyWindow(dpy
, win
);
1811 void wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1817 const int heads
= wXineramaHeads(scr
);
1820 int pf
; /* primary axis */
1821 int sf
; /* secondary axis */
1825 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1831 int isize
= wPreferences
.icon_size
;
1833 vars
= (struct HeadVars
*)wmalloc(sizeof(struct HeadVars
) * heads
);
1835 for (head
= 0; head
< heads
; ++head
) {
1836 WArea area
= wGetUsableAreaForHead(scr
, head
, NULL
, False
);
1840 int offset
= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
1842 if (scr
->dock
->on_right_side
)
1848 rect
= wmkrect(area
.x1
, area
.y1
, area
.x2
- area
.x1
, area
.y2
- area
.y1
);
1850 vars
[head
].pi
= vars
[head
].si
= 0;
1851 vars
[head
].sx1
= rect
.pos
.x
;
1852 vars
[head
].sy1
= rect
.pos
.y
;
1853 vars
[head
].sw
= rect
.size
.width
;
1854 vars
[head
].sh
= rect
.size
.height
;
1855 vars
[head
].sx2
= vars
[head
].sx1
+ vars
[head
].sw
;
1856 vars
[head
].sy2
= vars
[head
].sy1
+ vars
[head
].sh
;
1857 vars
[head
].sw
= isize
* (vars
[head
].sw
/ isize
);
1858 vars
[head
].sh
= isize
* (vars
[head
].sh
/ isize
);
1859 vars
[head
].fullW
= (vars
[head
].sx2
- vars
[head
].sx1
) / isize
;
1860 vars
[head
].fullH
= (vars
[head
].sy2
- vars
[head
].sy1
) / isize
;
1862 /* icon yard boundaries */
1863 if (wPreferences
.icon_yard
& IY_VERT
) {
1864 vars
[head
].pf
= vars
[head
].fullH
;
1865 vars
[head
].sf
= vars
[head
].fullW
;
1867 vars
[head
].pf
= vars
[head
].fullW
;
1868 vars
[head
].sf
= vars
[head
].fullH
;
1870 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1871 vars
[head
].xo
= vars
[head
].sx2
- isize
;
1874 vars
[head
].xo
= vars
[head
].sx1
;
1877 if (wPreferences
.icon_yard
& IY_TOP
) {
1878 vars
[head
].yo
= vars
[head
].sy1
;
1881 vars
[head
].yo
= vars
[head
].sy2
- isize
;
1886 #define X ((wPreferences.icon_yard & IY_VERT) \
1887 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1888 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1890 #define Y ((wPreferences.icon_yard & IY_VERT) \
1891 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1892 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1894 /* arrange application icons */
1895 aicon
= scr
->app_icon_list
;
1896 /* reverse them to avoid unnecessarily sliding of icons */
1897 while (aicon
&& aicon
->next
)
1898 aicon
= aicon
->next
;
1901 if (!aicon
->docked
) {
1902 /* CHECK: can icon be NULL here ? */
1903 /* The intention here is to place the AppIcon on the head that
1904 * contains most of the applications _main_ window. */
1905 head
= wGetHeadForWindow(aicon
->icon
->owner
);
1907 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1908 #ifdef USE_ANIMATIONS
1909 if (!wPreferences
.no_animations
)
1910 slide_window(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
, X
, Y
);
1911 #endif /* USE_ANIMATIONS */
1913 wAppIconMove(aicon
, X
, Y
);
1915 if (vars
[head
].pi
>= vars
[head
].pf
) {
1920 aicon
= aicon
->prev
;
1923 /* arrange miniwindows */
1924 wwin
= scr
->focused_window
;
1925 /* reverse them to avoid unnecessarily shuffling */
1926 while (wwin
&& wwin
->prev
)
1930 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1931 (wwin
->frame
->workspace
== scr
->current_workspace
||
1932 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1934 head
= wGetHeadForWindow(wwin
);
1936 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1937 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
)
1938 move_window(wwin
->icon
->core
->window
, wwin
->icon_x
, wwin
->icon_y
, X
, Y
);
1944 if (vars
[head
].pi
>= vars
[head
].pf
) {
1951 wwin
->flags
.icon_moved
= 0;
1952 /* we reversed the order, so we use next */
1959 void wSelectWindow(WWindow
*wwin
, Bool flag
)
1961 WScreen
*scr
= wwin
->screen_ptr
;
1964 wwin
->flags
.selected
= 1;
1965 if (wwin
->frame
->selected_border_pixel
)
1966 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, *wwin
->frame
->selected_border_pixel
);
1968 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1970 if (!HAS_BORDER(wwin
))
1971 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, wwin
->screen_ptr
->frame_border_width
);
1973 if (!scr
->selected_windows
)
1974 scr
->selected_windows
= WMCreateArray(4);
1975 WMAddToArray(scr
->selected_windows
, wwin
);
1977 wwin
->flags
.selected
= 0;
1978 if (wwin
->flags
.focused
) {
1979 if (wwin
->frame
->focused_border_pixel
)
1980 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, *wwin
->frame
->focused_border_pixel
);
1982 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->frame_focused_border_pixel
);
1984 if (wwin
->frame
->border_pixel
)
1985 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, *wwin
->frame
->border_pixel
);
1987 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->frame_border_pixel
);
1990 if (!HAS_BORDER(wwin
))
1991 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1993 if (scr
->selected_windows
)
1994 WMRemoveFromArray(scr
->selected_windows
, wwin
);
1998 void wMakeWindowVisible(WWindow
*wwin
)
2000 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
2001 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
2003 if (wwin
->flags
.shaded
)
2004 wUnshadeWindow(wwin
);
2006 if (wwin
->flags
.hidden
) {
2009 app
= wApplicationOf(wwin
->main_window
);
2011 /* trick to get focus to this window */
2012 app
->last_focused
= wwin
;
2013 wUnhideApplication(app
, False
, False
);
2016 if (wwin
->flags
.miniaturized
) {
2017 wDeiconifyWindow(wwin
);
2019 if (!WFLAGP(wwin
, no_focusable
))
2020 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2021 wRaiseFrame(wwin
->frame
->core
);
2026 * Do the animation while shading (called with what = SHADE)
2027 * or unshading (what = UNSHADE).
2029 #ifdef USE_ANIMATIONS
2030 static void shade_animate(WWindow
*wwin
, Bool what
)
2033 time_t time0
= time(NULL
);
2035 if (wwin
->flags
.skip_next_animation
|| wPreferences
.no_animations
)
2040 if (!wwin
->screen_ptr
->flags
.startup
) {
2041 /* do the shading animation */
2042 h
= wwin
->frame
->core
->height
;
2043 s
= h
/ SHADE_STEPS
;
2046 w
= wwin
->frame
->core
->width
;
2047 y
= wwin
->frame
->top_width
;
2048 while (h
> wwin
->frame
->top_width
+ 1) {
2049 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
2050 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
2053 if (time(NULL
) - time0
> MAX_ANIMATION_TIME
)
2056 if (SHADE_DELAY
> 0)
2057 wusleep(SHADE_DELAY
* 1000L);
2063 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
2068 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
2069 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
2070 s
= abs(y
) / SHADE_STEPS
;
2073 w
= wwin
->frame
->core
->width
;
2074 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
2076 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
) {
2077 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
2078 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
2080 if (SHADE_DELAY
> 0)
2081 wusleep(SHADE_DELAY
* 2000L / 3);
2087 if (time(NULL
) - time0
> MAX_ANIMATION_TIME
)
2091 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);