1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 #include <X11/Xutil.h>
32 #include "WindowMaker.h"
39 #include "application.h"
45 #include "winspector.h"
52 /****** Global Variables ******/
53 extern Time LastTimestamp
;
54 extern Time LastFocusChange
;
56 extern Cursor wCursor
[WCUR_LAST
];
58 extern WPreferences wPreferences
;
60 extern Atom _XA_WM_TAKE_FOCUS
;
62 /******* Local Variables *******/
67 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
68 {SHADE_STEPS_F
, SHADE_DELAY_F
},
69 {SHADE_STEPS_M
, SHADE_DELAY_M
},
70 {SHADE_STEPS_S
, SHADE_DELAY_S
},
71 {SHADE_STEPS_U
, SHADE_DELAY_U
}};
73 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
74 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
77 static int ignoreTimestamp
=0;
82 processEvents(int event_count
)
87 * This is a hack. When animations are enabled, processing of
88 * events ocurred during a animation are delayed until it's end.
89 * Calls that consider the TimeStamp, like XSetInputFocus(), will
90 * fail because the TimeStamp is too old. Then, for example, if
91 * the user changes window focus while a miniaturize animation is
92 * in course, the window will not get focus properly after the end
93 * of the animation. This tries to workaround it by passing CurrentTime
94 * as the TimeStamp for XSetInputFocus() for all events ocurred during
98 while (event_count
--) {
99 WMNextEvent(dpy
, &event
);
100 WMHandleEvent(&event
);
104 #endif /* ANIMATIONS */
108 *----------------------------------------------------------------------
110 * Changes the window focus to the one passed as argument.
111 * If the window to focus is not already focused, it will be brought
112 * to the head of the list of windows. Previously focused window is
116 * Window list may be reordered and the window focus is changed.
118 *----------------------------------------------------------------------
121 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
123 WWindow
*focused
=scr
->focused_window
;
124 WWindow
*owner
= NULL
;
125 int timestamp
=LastTimestamp
;
126 WApplication
*oapp
=NULL
, *napp
=NULL
;
129 LastFocusChange
= timestamp
;
132 timestamp
=CurrentTime
;
135 oapp
= wApplicationOf(focused
->main_window
);
138 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
140 wWindowUnfocus(focused
);
143 wAppMenuUnmap(oapp
->menu
);
145 wApplicationDeactivate(oapp
);
150 wasfocused
= wwin
->flags
.focused
;
151 napp
= wApplicationOf(wwin
->main_window
);
153 /* remember last workspace where the app has been */
155 napp
->last_workspace
= wwin
->screen_ptr
->current_workspace
;
157 if (wwin
->window_flags
.no_focusable
)
160 if (wwin
->flags
.mapped
) {
161 /* install colormap if colormap mode is lock mode */
162 if (wPreferences
.colormap_mode
==WKF_CLICK
)
163 wColormapInstallForWindow(scr
, wwin
);
165 /* set input focus */
166 switch (wwin
->focus_mode
) {
168 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
172 case WFM_LOCALLY_ACTIVE
:
173 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
176 case WFM_GLOBALLY_ACTIVE
:
180 if (wwin
->protocols
.TAKE_FOCUS
) {
181 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
185 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
188 /* if this is not the focused window focus it */
192 if (wwin
->client_win
== focused
->transient_for
)
193 wwin
->flags
.semi_focused
= 0;
194 else if (wwin
->transient_for
== focused
->client_win
)
195 focused
->flags
.semi_focused
= 1;
197 if (wwin
->transient_for
198 && wwin
->transient_for
== focused
->transient_for
) {
199 owner
= wWindowFor(wwin
->transient_for
);
200 if (owner
&& owner
->flags
.semi_focused
) {
202 /* this is to override the unfocusing of the mainwindow
203 * in the next wWindowUnfocus() and avoid flickering */
204 owner
->flags
.semi_focused
= 0;
207 /* unfocus previous window */
208 wWindowUnfocus(focused
);
210 owner
->flags
.semi_focused
= 1;
212 /* change the focus window list order */
214 wwin
->prev
->next
=wwin
->next
;
216 wwin
->next
->prev
=wwin
->prev
;
218 wwin
->prev
= focused
;
219 focused
->next
= wwin
;
221 scr
->focused_window
= wwin
;
223 if (oapp
&& oapp
!= napp
) {
224 wAppMenuUnmap(oapp
->menu
);
226 wApplicationDeactivate(oapp
);
230 if ((owner
=wWindowFor(wwin
->transient_for
))
231 && !owner
->flags
.semi_focused
) {
232 owner
->flags
.semi_focused
= 1;
233 wWindowUnfocus(owner
);
236 if (napp
&& !wasfocused
) {
237 wAppMenuMap(napp
->menu
, wwin
);
239 wApplicationActivate(napp
);
247 wShadeWindow(WWindow
*wwin
)
249 XWindowAttributes attribs
;
250 time_t time0
= time(NULL
);
255 if (wwin
->flags
.shaded
)
258 XLowerWindow(dpy
, wwin
->client_win
);
261 wSoundPlay(WMSOUND_SHADE
);
265 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
266 && !wPreferences
.no_animations
) {
267 /* do the shading animation */
268 h
= wwin
->frame
->core
->height
;
271 w
= wwin
->frame
->core
->width
;
272 y
= wwin
->frame
->top_width
;
273 while (h
>wwin
->frame
->top_width
+1) {
274 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
275 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
278 wusleep(SHADE_DELAY
*1000L);
282 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
285 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
287 #endif /* ANIMATIONS */
290 wwin
->flags
.skip_next_animation
= 0;
291 XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
);
292 wwin
->flags
.shaded
=1;
293 wwin
->flags
.mapped
=0;
294 /* prevent window withdrawal when getting UnmapNotify */
295 XSelectInput(dpy
, wwin
->client_win
,
296 attribs
.your_event_mask
& ~StructureNotifyMask
);
297 XUnmapWindow(dpy
, wwin
->client_win
);
298 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
300 /* for the client it's just like iconification */
301 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
302 wwin
->frame
->top_width
-1);
303 wClientSetState(wwin
, IconicState
, None
);
305 /* update window list to reflect shaded state */
306 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
309 if (!wwin
->screen_ptr
->flags
.startup
) {
310 /* Look at processEvents() for reason of this code. */
312 processEvents(XPending(dpy
));
319 wUnshadeWindow(WWindow
*wwin
)
321 time_t time0
= time(NULL
);
324 #endif /* ANIMATIONS */
327 if (!wwin
->flags
.shaded
)
330 wwin
->flags
.shaded
=0;
331 wwin
->flags
.mapped
=1;
332 XMapWindow(dpy
, wwin
->client_win
);
335 wSoundPlay(WMSOUND_UNSHADE
);
339 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
340 /* do the shading animation */
341 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
342 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
343 s
= abs(y
)/SHADE_STEPS
;
345 w
= wwin
->frame
->core
->width
;
346 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
348 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
349 + wwin
->frame
->bottom_width
) {
350 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
351 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
354 wusleep(SHADE_DELAY
*2000L/3);
358 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
362 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
364 #endif /* ANIMATIONS */
367 wwin
->flags
.skip_next_animation
= 0;
368 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
369 wwin
->frame
->top_width
+ wwin
->client
.height
370 + wwin
->frame
->bottom_width
);
372 wClientSetState(wwin
, NormalState
, None
);
373 /* if the window is focused, set the focus again as it was disabled during
375 if (wwin
->flags
.focused
)
376 wSetFocusTo(wwin
->screen_ptr
, wwin
);
378 /* update window list to reflect unshaded state */
379 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
384 wMaximizeWindow(WWindow
*wwin
, int directions
)
386 int new_width
, new_height
, new_x
, new_y
;
388 if (wwin
->flags
.shaded
) {
389 wwin
->flags
.skip_next_animation
= 1;
390 wUnshadeWindow(wwin
);
392 wwin
->flags
.maximized
= directions
;
393 wwin
->old_geometry
.width
= wwin
->client
.width
;
394 wwin
->old_geometry
.height
= wwin
->client
.height
;
395 wwin
->old_geometry
.x
= wwin
->frame_x
;
396 wwin
->old_geometry
.y
= wwin
->frame_y
;
397 if (directions
& MAX_HORIZONTAL
) {
398 new_width
= wwin
->screen_ptr
->scr_width
-FRAME_BORDER_WIDTH
*2;
401 if ((wPreferences
.icon_yard
& IY_VERT
)
402 && wPreferences
.no_window_over_icons
) {
404 new_width
-= wPreferences
.icon_size
;
405 if (!(wPreferences
.icon_yard
& IY_RIGHT
))
406 new_x
+= wPreferences
.icon_size
;
409 if (wPreferences
.no_window_under_dock
410 && wwin
->screen_ptr
->dock
) {
411 new_width
-= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
412 if (!wwin
->screen_ptr
->dock
->on_right_side
)
413 new_x
+= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
416 if (wwin
->screen_ptr
->dock
&& !wwin
->screen_ptr
->dock
->lowered
) {
417 new_width
-= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
418 if (!wwin
->screen_ptr
->dock
->on_right_side
)
419 new_x
+= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
422 new_x
= wwin
->frame_x
;
423 new_width
= wwin
->frame
->core
->width
;
426 if (directions
& MAX_VERTICAL
) {
427 new_height
= wwin
->screen_ptr
->scr_height
-FRAME_BORDER_WIDTH
*2;
429 if (!(wPreferences
.icon_yard
& IY_VERT
)
430 && wPreferences
.no_window_over_icons
) {
432 new_height
-= wPreferences
.icon_size
;
434 if (wPreferences
.icon_yard
& IY_TOP
)
435 new_y
+= wPreferences
.icon_size
;
438 new_y
= wwin
->frame_y
;
439 new_height
= wwin
->frame
->core
->height
;
441 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
443 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
444 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
447 wSoundPlay(WMSOUND_MAXIMIZE
);
453 wUnmaximizeWindow(WWindow
*wwin
)
455 int restore_x
, restore_y
;
457 if (wwin
->flags
.shaded
) {
458 wwin
->flags
.skip_next_animation
= 1;
459 wUnshadeWindow(wwin
);
461 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
462 wwin
->old_geometry
.x
: wwin
->frame_x
;
463 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
464 wwin
->old_geometry
.y
: wwin
->frame_y
;
465 wwin
->flags
.maximized
= 0;
466 wWindowConfigure(wwin
, restore_x
, restore_y
,
467 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
470 wSoundPlay(WMSOUND_UNMAXIMIZE
);
476 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
477 int fx
, int fy
, int fw
, int fh
, int steps
)
479 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
480 float cx
, cy
, cw
, ch
;
481 float xstep
, ystep
, wstep
, hstep
;
484 float angle
, final_angle
, delta
;
486 xstep
= (float)(fx
-x
)/steps
;
487 ystep
= (float)(fy
-y
)/steps
;
488 wstep
= (float)(fw
-w
)/steps
;
489 hstep
= (float)(fh
-h
)/steps
;
496 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
497 delta
= (float)(final_angle
/FRAMES
);
498 for (angle
=0;; angle
+=delta
) {
499 if (angle
> final_angle
)
502 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
503 dch
= (ch
/2) * cos(angle
);
506 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
507 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
508 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
509 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
510 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
513 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
515 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
516 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
519 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
525 if (angle
>= final_angle
)
535 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
536 int fx
, int fy
, int fw
, int fh
, int steps
)
538 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
539 float cx
, cy
, cw
, ch
;
540 float xstep
, ystep
, wstep
, hstep
;
542 float angle
, final_angle
, a
, d
, delta
;
549 xstep
= (float)(fx
-x
)/steps
;
550 ystep
= (float)(fy
-y
)/steps
;
551 wstep
= (float)(fw
-w
)/steps
;
552 hstep
= (float)(fh
-h
)/steps
;
559 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
560 delta
= (float)(final_angle
/FRAMES
);
561 for (angle
=0;; angle
+=delta
) {
562 if (angle
> final_angle
)
566 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
568 points
[0].x
= cx
+cos(angle
-a
)*d
;
569 points
[0].y
= cy
+sin(angle
-a
)*d
;
570 points
[1].x
= cx
+cos(angle
+a
)*d
;
571 points
[1].y
= cy
+sin(angle
+a
)*d
;
572 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
573 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
574 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
575 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
576 points
[4].x
= cx
+cos(angle
-a
)*d
;
577 points
[4].y
= cy
+sin(angle
-a
)*d
;
579 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
581 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
582 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
585 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
591 if (angle
>= final_angle
)
601 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
602 int fx
, int fy
, int fw
, int fh
, int steps
)
604 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
605 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
606 float xstep
, ystep
, wstep
, hstep
;
609 xstep
= (float)(fx
-x
)/steps
;
610 ystep
= (float)(fy
-y
)/steps
;
611 wstep
= (float)(fw
-w
)/steps
;
612 hstep
= (float)(fh
-h
)/steps
;
614 for (j
=0; j
<FRAMES
; j
++) {
621 for (i
=0; i
<steps
; i
++) {
622 for (j
=0; j
<FRAMES
; j
++) {
623 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
624 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
627 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
628 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
630 for (j
=0; j
<FRAMES
; j
++) {
631 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
632 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
647 for (j
=0; j
<FRAMES
; j
++) {
648 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
649 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
652 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
653 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
655 for (j
=0; j
<FRAMES
; j
++) {
656 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
657 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
666 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
667 int fx
, int fy
, int fw
, int fh
, int hiding
)
669 int style
= wPreferences
.iconification_style
; /* Catch the value */
672 if (style
== WIS_NONE
)
675 k
= (hiding
? 2 : 3);
678 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
680 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
683 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
685 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
689 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
691 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
695 #endif /* ANIMATIONS */
703 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
704 WMHandleEvent(&tmpev
);
709 unmapTransientsFor(WWindow
*wwin
)
712 XWindowAttributes attribs
;
715 tmp
= wwin
->screen_ptr
->focused_window
;
717 /* unmap the transients for this transient */
718 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
719 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
720 || tmp
->flags
.shaded
)) {
721 unmapTransientsFor(tmp
);
722 XGetWindowAttributes(dpy
, tmp
->client_win
, &attribs
);
723 tmp
->flags
.miniaturized
=1;
724 if (!tmp
->flags
.shaded
) {
726 XSelectInput(dpy
, tmp
->client_win
,
727 attribs
.your_event_mask
& ~StructureNotifyMask
);
728 XUnmapWindow(dpy
, tmp
->client_win
);
729 XSelectInput(dpy
, tmp
->client_win
, attribs
.your_event_mask
);
731 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
732 if (!tmp
->flags
.shaded
)
733 wClientSetState(tmp
, IconicState
, None
);
734 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
742 mapTransientsFor(WWindow
*wwin
)
746 tmp
= wwin
->screen_ptr
->focused_window
;
748 /* recursively map the transients for this transient */
749 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
750 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
751 && tmp
->icon
==NULL
) {
752 mapTransientsFor(tmp
);
753 tmp
->flags
.miniaturized
=0;
754 if (!tmp
->flags
.shaded
) {
756 XMapWindow(dpy
, tmp
->client_win
);
758 XMapWindow(dpy
, tmp
->frame
->core
->window
);
759 tmp
->flags
.semi_focused
= 0;
760 if (!tmp
->flags
.shaded
)
761 wClientSetState(tmp
, NormalState
, None
);
762 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
770 setupIconGrabs(WIcon
*icon
)
772 /* setup passive grabs on the icon */
773 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
774 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
775 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
776 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
777 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
778 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
784 recursiveTransientFor(WWindow
*wwin
)
791 /* hackish way to detect transient_for cycle */
792 i
= wwin
->screen_ptr
->window_count
+1;
794 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
795 wwin
= wWindowFor(wwin
->transient_for
);
799 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
809 removeIconGrabs(WIcon
*icon
)
811 /* remove passive grabs on the icon */
812 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
813 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
814 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
820 wIconifyWindow(WWindow
*wwin
)
822 XWindowAttributes attribs
;
826 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
827 /* the window doesn't exist anymore */
831 if (wwin
->flags
.miniaturized
)
834 if (wwin
->transient_for
!=None
) {
835 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
837 if (owner
&& owner
->flags
.miniaturized
)
841 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
843 /* if the window is in another workspace, simplify process */
845 /* icon creation may take a while */
846 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
847 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
848 GrabModeAsync
, None
, None
, CurrentTime
);
851 if (!wwin
->flags
.icon_moved
) {
852 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
854 wwin
->icon
= wIconCreate(wwin
);
856 wwin
->flags
.miniaturized
=1;
857 wwin
->flags
.mapped
=0;
859 /* unmap transients */
861 unmapTransientsFor(wwin
);
865 wSoundPlay(WMSOUND_ICONIFY
);
868 XUngrabPointer(dpy
, CurrentTime
);
869 /* prevent window withdrawal when getting UnmapNotify */
870 XSelectInput(dpy
, wwin
->client_win
,
871 attribs
.your_event_mask
& ~StructureNotifyMask
);
872 XUnmapWindow(dpy
, wwin
->client_win
);
873 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
874 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
875 /* let all Expose events arrive so that we can repaint
876 * something before the animation starts (and the server is grabbed) */
878 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
881 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
882 && !wPreferences
.no_animations
) {
883 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
884 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
885 wwin
->icon_x
, wwin
->icon_y
,
886 wwin
->icon
->core
->width
, wwin
->icon
->core
->height
,
892 wwin
->flags
.skip_next_animation
= 0;
893 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
894 wwin
->window_flags
.omnipresent
|| wPreferences
.sticky_icons
)
895 XMapWindow(dpy
, wwin
->icon
->core
->window
);
896 AddToStackList(wwin
->icon
->core
);
898 wLowerFrame(wwin
->icon
->core
);
902 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
903 setupIconGrabs(wwin
->icon
);
904 if ((wwin
->flags
.focused
905 || (owner
&& wwin
->client_win
== owner
->client_win
))
906 && wPreferences
.focus_mode
==WKF_CLICK
) {
911 if (!tmp
->window_flags
.no_focusable
912 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
))
916 wSetFocusTo(wwin
->screen_ptr
, tmp
);
917 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
918 wSetFocusTo(wwin
->screen_ptr
, NULL
);
922 if (!wwin
->screen_ptr
->flags
.startup
) {
923 Window clientwin
= wwin
->client_win
;
926 processEvents(XPending(dpy
));
928 /* the window can disappear while doing the processEvents() */
929 if (!wWindowFor(clientwin
))
936 if (wwin
->flags
.selected
)
937 wIconSelect(wwin
->icon
);
939 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
946 wDeiconifyWindow(WWindow
*wwin
)
948 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
950 if (!wwin
->flags
.miniaturized
)
953 if (wwin
->transient_for
!= None
) {
954 WWindow
*owner
= recursiveTransientFor(wwin
);
955 wDeiconifyWindow(owner
);
956 wSetFocusTo(wwin
->screen_ptr
, wwin
);
957 wRaiseFrame(wwin
->frame
->core
);
961 wwin
->flags
.miniaturized
=0;
962 if (!wwin
->flags
.shaded
)
963 wwin
->flags
.mapped
=1;
965 if (wwin
->icon
->selected
)
966 wIconSelect(wwin
->icon
);
968 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
971 wSoundPlay(WMSOUND_DEICONIFY
);
974 /* if the window is in another workspace, do it silently */
976 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
977 && !wwin
->flags
.skip_next_animation
) {
978 animateResize(wwin
->screen_ptr
, wwin
->icon_x
, wwin
->icon_y
,
979 wwin
->icon
->core
->width
, wwin
->icon
->core
->height
,
980 wwin
->frame_x
, wwin
->frame_y
,
981 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
984 #endif /* ANIMATIONS */
985 wwin
->flags
.skip_next_animation
= 0;
987 if (!wwin
->flags
.shaded
) {
988 XMapWindow(dpy
, wwin
->client_win
);
990 XMapWindow(dpy
, wwin
->frame
->core
->window
);
991 wRaiseFrame(wwin
->frame
->core
);
992 if (!wwin
->flags
.shaded
) {
993 wClientSetState(wwin
, NormalState
, None
);
995 mapTransientsFor(wwin
);
996 RemoveFromStackList(wwin
->icon
->core
);
997 removeIconGrabs(wwin
->icon
);
998 wIconDestroy(wwin
->icon
);
1002 if (wPreferences
.focus_mode
==WKF_CLICK
1003 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1004 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1007 if (!wwin
->screen_ptr
->flags
.startup
) {
1008 Window clientwin
= wwin
->client_win
;
1011 processEvents(XPending(dpy
));
1013 if (!wWindowFor(clientwin
))
1018 if (wPreferences
.auto_arrange_icons
) {
1019 wArrangeIcons(wwin
->screen_ptr
, True
);
1022 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1029 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1031 XWindowAttributes attribs
;
1034 if (wwin
->flags
.miniaturized
) {
1035 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1036 wwin
->flags
.hidden
= 1;
1037 wwin
->icon
->mapped
= 0;
1038 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1042 if (wwin
->flags
.inspector_open
) {
1043 WWindow
*pwin
= wwin
->inspector
->frame
;
1045 XGetWindowAttributes(dpy
, pwin
->client_win
, &attribs
);
1046 pwin
->flags
.hidden
= 1;
1047 pwin
->flags
.mapped
= 0;
1048 /* prevent window withdrawal when getting UnmapNotify */
1049 XSelectInput(dpy
, pwin
->client_win
,
1050 attribs
.your_event_mask
& ~StructureNotifyMask
);
1051 XUnmapWindow(dpy
, pwin
->client_win
);
1052 XSelectInput(dpy
, pwin
->client_win
, attribs
.your_event_mask
);
1054 XUnmapWindow(dpy
, pwin
->frame
->core
->window
);
1055 wClientSetState(pwin
, IconicState
, icon
->icon_win
);
1058 XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
);
1060 wwin
->flags
.hidden
= 1;
1061 wwin
->flags
.mapped
= 0;
1063 /* prevent window withdrawal when getting UnmapNotify */
1064 XSelectInput(dpy
, wwin
->client_win
,
1065 attribs
.your_event_mask
& ~StructureNotifyMask
);
1066 XUnmapWindow(dpy
, wwin
->client_win
);
1067 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
1069 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
1070 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1073 wSoundPlay(WMSOUND_HIDE
);
1076 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1077 !wwin
->flags
.skip_next_animation
&& animate
) {
1078 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1079 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1080 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1084 wwin
->flags
.skip_next_animation
= 0;
1086 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1092 wHideOtherApplications(WWindow
*awin
)
1096 #ifdef REDUCE_APPICONS
1097 char *tinstance
, *tclass
;
1098 unsigned int brokenwin
= 0, match
= 0;
1103 wwin
= awin
->screen_ptr
->focused_window
;
1105 #ifdef REDUCE_APPICONS
1106 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1112 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1113 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1114 && !wwin
->flags
.internal_window
1115 && (!wwin
->flags
.inspector_open
|| wwin
->inspector
->frame
!=awin
)
1116 && !wwin
->window_flags
.no_hide_others
) {
1118 #ifdef REDUCE_APPICONS
1121 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1123 if ((tclass
= wwin
->wm_class
) == NULL
)
1125 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1126 (strcmp(awin
->wm_class
, tclass
) == 0) )
1131 if (wwin
->main_window
==None
|| wwin
->window_flags
.no_appicon
) {
1132 if (!wwin
->window_flags
.no_miniaturizable
) {
1133 wwin
->flags
.skip_next_animation
= 1;
1134 wIconifyWindow(wwin
);
1136 } else if (wwin
->main_window
!=None
1137 #ifndef REDUCE_APPICONS
1138 && awin
->main_window
!= wwin
->main_window
) {
1140 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1142 tapp
= wApplicationOf(wwin
->main_window
);
1144 tapp
->flags
.skip_next_animation
= 1;
1145 wHideApplication(tapp
);
1147 if (!wwin
->window_flags
.no_miniaturizable
) {
1148 wwin
->flags
.skip_next_animation
= 1;
1149 wIconifyWindow(wwin
);
1157 wSetFocusTo(awin->screen_ptr, awin);
1164 wHideApplication(WApplication
*wapp
)
1166 #ifdef REDUCE_APPICONS
1168 char *tinstance
, *tclass
;
1169 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1176 wwarning("trying to hide a non grouped window");
1179 if (!wapp
->main_window_desc
) {
1180 wwarning("group leader not found for window group");
1183 #ifdef REDUCE_APPICONS
1184 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1185 (wapp
->main_window_desc
->wm_class
== NULL
))
1188 scr
= wapp
->main_window_desc
->screen_ptr
;
1190 wlist
= scr
->focused_window
;
1194 if (wlist
->main_window
== wapp
->main_window
)
1195 wapp
->last_focused
= wlist
;
1197 wapp
->last_focused
= NULL
;
1199 #ifdef REDUCE_APPICONS
1200 matchwmhints
= matchworkspace
= 0;
1202 tapp
= wApplicationOf(wlist
->main_window
);
1203 tinstance
= tclass
= NULL
;
1205 if (tapp
->main_window_desc
) {
1206 tinstance
= tapp
->main_window_desc
->wm_instance
;
1207 tclass
= tapp
->main_window_desc
->wm_class
;
1210 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1211 /* Should never reach here */
1215 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1216 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1220 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1223 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1229 if (wlist
->main_window
== wapp
->main_window
) {
1231 if (wlist
->flags
.focused
) {
1235 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1236 wapp
->app_icon
->y_pos
, wlist
,
1237 !wapp
->flags
.skip_next_animation
);
1239 wlist
= wlist
->prev
;
1242 wapp
->flags
.skip_next_animation
= 0;
1245 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1246 wlist
= scr
->focused_window
;
1248 if (!wlist
->window_flags
.no_focusable
&& !wlist
->flags
.hidden
1249 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1251 wlist
= wlist
->prev
;
1253 wSetFocusTo(scr
, wlist
);
1255 wSetFocusTo(scr
, NULL
);
1259 wapp
->flags
.hidden
= 1;
1266 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1267 int bringToCurrentWS
)
1269 if (bringToCurrentWS
)
1270 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1272 wwin
->flags
.hidden
=0;
1273 wwin
->flags
.mapped
=1;
1276 wSoundPlay(WMSOUND_UNHIDE
);
1279 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1281 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1282 icon
->core
->width
, icon
->core
->height
,
1283 wwin
->frame_x
, wwin
->frame_y
,
1284 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1288 wwin
->flags
.skip_next_animation
= 0;
1289 XMapWindow(dpy
, wwin
->client_win
);
1290 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1291 wClientSetState(wwin
, NormalState
, None
);
1292 wRaiseFrame(wwin
->frame
->core
);
1293 if (wwin
->flags
.inspector_open
) {
1294 WWindow
*pwin
= wwin
->inspector
->frame
;
1296 pwin
->flags
.hidden
= 0;
1297 pwin
->flags
.mapped
= 1;
1298 XMapWindow(dpy
, pwin
->client_win
);
1299 XMapWindow(dpy
, pwin
->frame
->core
->window
);
1300 wClientSetState(pwin
, NormalState
, None
);
1303 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1308 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1311 WWindow
*wlist
, *next
;
1312 WWindow
*focused
=NULL
;
1313 #ifdef REDUCE_APPICONS
1314 char *tinstance
, *tclass
;
1315 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1322 #ifdef REDUCE_APPICONS
1323 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1324 (wapp
->main_window_desc
->wm_instance
== NULL
))
1328 scr
= wapp
->main_window_desc
->screen_ptr
;
1329 wlist
= scr
->focused_window
;
1331 /* goto beginning of list */
1333 wlist
= wlist
->prev
;
1338 #ifndef REDUCE_APPICONS
1339 if (wlist
->main_window
== wapp
->main_window
) {
1341 matchwmhints
= matchworkspace
= 0;
1343 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1345 if ((tclass
= wlist
->wm_class
) == NULL
)
1347 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1348 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1352 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1356 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1359 if (wlist
->flags
.focused
)
1361 else if (!focused
|| !focused
->flags
.focused
)
1364 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1365 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1366 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1367 if (!wlist
->icon
->mapped
) {
1368 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1369 wlist
->icon
->mapped
= 1;
1371 wlist
->flags
.hidden
= 0;
1372 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1373 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1374 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1377 wDeiconifyWindow(wlist
);
1379 } else if (wlist
->flags
.hidden
) {
1380 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1381 wapp
->app_icon
->y_pos
, wlist
,
1382 !wapp
->flags
.skip_next_animation
,
1385 if (bringToCurrentWS
1386 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1387 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1389 wRaiseFrame(wlist
->frame
->core
);
1395 wapp
->flags
.skip_next_animation
= 0;
1396 wapp
->flags
.hidden
= 0;
1399 wSetFocusTo(scr
, focused
);
1400 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1401 wSetFocusTo(scr
, wapp
->last_focused
);
1402 wapp
->last_focused
= NULL
;
1403 if (wPreferences
.auto_arrange_icons
) {
1404 wArrangeIcons(scr
, True
);
1411 wShowAllWindows(WScreen
*scr
)
1413 WWindow
*wwin
, *old_foc
;
1416 old_foc
= wwin
= scr
->focused_window
;
1418 if (!wwin
->flags
.internal_window
&&
1419 (scr
->current_workspace
== wwin
->frame
->workspace
1420 || wwin
->window_flags
.omnipresent
)) {
1421 if (wwin
->flags
.miniaturized
) {
1422 wwin
->flags
.skip_next_animation
= 1;
1423 wDeiconifyWindow(wwin
);
1424 } else if (wwin
->flags
.hidden
) {
1425 wapp
= wApplicationOf(wwin
->main_window
);
1427 wUnhideApplication(wapp
, False
, False
);
1429 wwin
->flags
.skip_next_animation
= 1;
1430 wDeiconifyWindow(wwin
);
1436 wSetFocusTo(scr
, old_foc
);
1437 /*wRaiseFrame(old_foc->frame->core);*/
1442 wRefreshDesktop(WScreen
*scr
)
1445 XSetWindowAttributes attr
;
1447 attr
.backing_store
= NotUseful
;
1448 attr
.save_under
= False
;
1449 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1450 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1451 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1453 XMapRaised(dpy
, win
);
1454 XDestroyWindow(dpy
, win
);
1460 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1464 int pf
; /* primary axis */
1465 int sf
; /* secondary axis */
1469 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1473 int isize
= wPreferences
.icon_size
;
1476 * Find out screen boundaries.
1480 sx2
= scr
->scr_width
;
1481 sy2
= scr
->scr_height
;
1483 if (scr
->dock
->on_right_side
)
1484 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1486 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1489 sw
= isize
* (scr
->scr_width
/isize
);
1490 sh
= isize
* (scr
->scr_height
/isize
);
1491 fullW
= (sx2
-sx1
)/isize
;
1492 fullH
= (sy2
-sy1
)/isize
;
1494 /* icon yard boundaries */
1495 if (wPreferences
.icon_yard
& IY_VERT
) {
1502 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1509 if (wPreferences
.icon_yard
& IY_TOP
) {
1517 /* arrange icons putting the most recently focused window
1518 * as the last icon */
1519 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1520 : xo + xs*(pi*isize))
1521 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1522 : yo + ys*(si*isize))
1524 /* arrange application icons */
1525 aicon
= scr
->app_icon_list
;
1526 /* reverse them to avoid unnecessarily sliding of icons */
1527 while (aicon
&& aicon
->next
)
1528 aicon
= aicon
->next
;
1533 if (!aicon
->docked
) {
1534 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1536 if (!wPreferences
.no_animations
) {
1537 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1540 #endif /* ANIMATIONS */
1542 wAppIconMove(aicon
, X
, Y
);
1545 /* we reversed the order so we use prev */
1546 aicon
= aicon
->prev
;
1553 /* arrange miniwindows */
1555 wwin
= scr
->focused_window
;
1556 /* reverse them to avoid unnecessarily shuffling */
1557 while (wwin
&& wwin
->prev
)
1561 if (wwin
->icon
&& wwin
->flags
.miniaturized
&&
1562 (wwin
->frame
->workspace
==scr
->current_workspace
||
1563 wwin
->window_flags
.omnipresent
||
1564 wPreferences
.sticky_icons
)) {
1566 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1567 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1569 if (wPreferences
.no_animations
) {
1570 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1572 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1573 wwin
->icon_y
, X
, Y
);
1576 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1577 #endif /* ANIMATIONS */
1581 wwin
->flags
.icon_moved
= 0;
1585 /* we reversed the order, so we use next */