1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998, 1999 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #include <X11/Xutil.h>
35 #include "WindowMaker.h"
42 #include "application.h"
48 #include "winspector.h"
49 #include "workspace.h"
63 /****** Global Variables ******/
64 extern Time LastTimestamp
;
65 extern Time LastFocusChange
;
67 extern Cursor wCursor
[WCUR_LAST
];
69 extern WPreferences wPreferences
;
71 extern Atom _XA_WM_TAKE_FOCUS
;
74 /******* Local Variables *******/
79 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
80 {SHADE_STEPS_F
, SHADE_DELAY_F
},
81 {SHADE_STEPS_M
, SHADE_DELAY_M
},
82 {SHADE_STEPS_S
, SHADE_DELAY_S
},
83 {SHADE_STEPS_U
, SHADE_DELAY_U
}};
85 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
86 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
89 static int ignoreTimestamp
=0;
94 processEvents(int event_count
)
99 * This is a hack. When animations are enabled, processing of
100 * events ocurred during a animation are delayed until it's end.
101 * Calls that consider the TimeStamp, like XSetInputFocus(), will
102 * fail because the TimeStamp is too old. Then, for example, if
103 * the user changes window focus while a miniaturize animation is
104 * in course, the window will not get focus properly after the end
105 * of the animation. This tries to workaround it by passing CurrentTime
106 * as the TimeStamp for XSetInputFocus() for all events ocurred during
110 while (XPending(dpy
) && event_count
--) {
111 WMNextEvent(dpy
, &event
);
112 WMHandleEvent(&event
);
116 #endif /* ANIMATIONS */
121 *----------------------------------------------------------------------
123 * Changes the window focus to the one passed as argument.
124 * If the window to focus is not already focused, it will be brought
125 * to the head of the list of windows. Previously focused window is
129 * Window list may be reordered and the window focus is changed.
131 *----------------------------------------------------------------------
134 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
136 static WScreen
*old_scr
=NULL
;
138 WWindow
*old_focused
;
139 WWindow
*focused
=scr
->focused_window
;
140 int timestamp
=LastTimestamp
;
141 WApplication
*oapp
=NULL
, *napp
=NULL
;
146 old_focused
=old_scr
->focused_window
;
148 LastFocusChange
= timestamp
;
151 * This is a hack, because XSetInputFocus() should have a proper
152 * timestamp instead of CurrentTime but it seems that some times
153 * clients will not receive focus properly that way.
156 timestamp
= CurrentTime
;
159 oapp
= wApplicationOf(old_focused
->main_window
);
162 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
164 wWindowUnfocus(old_focused
);
167 wAppMenuUnmap(oapp
->menu
);
169 wApplicationDeactivate(oapp
);
173 wKWMUpdateActiveWindowHint(scr
);
174 wKWMSendEventMessage(NULL
, WKWMFocusWindow
);
177 } else if(old_scr
!= scr
&& old_focused
) {
178 wWindowUnfocus(old_focused
);
181 wasfocused
= wwin
->flags
.focused
;
182 napp
= wApplicationOf(wwin
->main_window
);
184 /* remember last workspace where the app has been */
186 napp
->last_workspace
= wwin
->screen_ptr
->current_workspace
;
188 if (wwin
->flags
.mapped
&& !WFLAGP(wwin
, no_focusable
)) {
189 /* install colormap if colormap mode is lock mode */
190 if (wPreferences
.colormap_mode
==WKF_CLICK
)
191 wColormapInstallForWindow(scr
, wwin
);
193 /* set input focus */
194 switch (wwin
->focus_mode
) {
196 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
200 case WFM_LOCALLY_ACTIVE
:
201 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
204 case WFM_GLOBALLY_ACTIVE
:
208 if (wwin
->protocols
.TAKE_FOCUS
) {
209 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
213 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
215 if (WFLAGP(wwin
, no_focusable
))
218 /* if this is not the focused window focus it */
220 /* change the focus window list order */
222 wwin
->prev
->next
= wwin
->next
;
225 wwin
->next
->prev
= wwin
->prev
;
227 wwin
->prev
= focused
;
228 focused
->next
= wwin
;
230 scr
->focused_window
= wwin
;
232 if (oapp
&& oapp
!= napp
) {
233 wAppMenuUnmap(oapp
->menu
);
235 wApplicationDeactivate(oapp
);
240 wWindowFocus(wwin
, focused
);
242 if (napp
&& !wasfocused
) {
244 wUserMenuRefreshInstances(napp
->menu
, wwin
);
245 #endif /* USER_MENU */
247 if (wwin
->flags
.mapped
)
248 wAppMenuMap(napp
->menu
, wwin
);
250 wApplicationActivate(napp
);
254 wKWMUpdateActiveWindowHint(scr
);
255 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
263 wShadeWindow(WWindow
*wwin
)
265 time_t time0
= time(NULL
);
270 if (wwin
->flags
.shaded
)
273 XLowerWindow(dpy
, wwin
->client_win
);
276 wSoundPlay(WMSOUND_SHADE
);
280 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
281 && !wPreferences
.no_animations
) {
282 /* do the shading animation */
283 h
= wwin
->frame
->core
->height
;
286 w
= wwin
->frame
->core
->width
;
287 y
= wwin
->frame
->top_width
;
288 while (h
>wwin
->frame
->top_width
+1) {
289 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
290 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
293 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
297 wusleep(SHADE_DELAY
*1000L);
301 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
303 #endif /* ANIMATIONS */
305 wwin
->flags
.skip_next_animation
= 0;
306 wwin
->flags
.shaded
= 1;
307 wwin
->flags
.mapped
= 0;
308 /* prevent window withdrawal when getting UnmapNotify */
309 XSelectInput(dpy
, wwin
->client_win
,
310 wwin
->event_mask
& ~StructureNotifyMask
);
311 XUnmapWindow(dpy
, wwin
->client_win
);
312 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
314 /* for the client it's just like iconification */
315 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
316 wwin
->frame
->top_width
- 1);
318 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
319 + wwin
->frame
->top_width
;
320 wWindowSynthConfigureNotify(wwin
);
323 wClientSetState(wwin, IconicState, None);
327 wGNOMEUpdateClientStateHint(wwin
, False
);
330 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
331 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
333 /* update window list to reflect shaded state */
334 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
337 if (!wwin
->screen_ptr
->flags
.startup
) {
338 /* Look at processEvents() for reason of this code. */
340 processEvents(XPending(dpy
));
347 wUnshadeWindow(WWindow
*wwin
)
349 time_t time0
= time(NULL
);
352 #endif /* ANIMATIONS */
355 if (!wwin
->flags
.shaded
)
358 wwin
->flags
.shaded
= 0;
359 wwin
->flags
.mapped
= 1;
360 XMapWindow(dpy
, wwin
->client_win
);
363 wSoundPlay(WMSOUND_UNSHADE
);
367 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
368 /* do the shading animation */
369 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
370 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
371 s
= abs(y
)/SHADE_STEPS
;
373 w
= wwin
->frame
->core
->width
;
374 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
376 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
377 + wwin
->frame
->bottom_width
) {
378 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
379 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
382 wusleep(SHADE_DELAY
*2000L/3);
386 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
390 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
392 #endif /* ANIMATIONS */
394 wwin
->flags
.skip_next_animation
= 0;
395 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
396 wwin
->frame
->top_width
+ wwin
->client
.height
397 + wwin
->frame
->bottom_width
);
399 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
400 wWindowSynthConfigureNotify(wwin
);
403 wClientSetState(wwin, NormalState, None);
405 /* if the window is focused, set the focus again as it was disabled during
407 if (wwin
->flags
.focused
)
408 wSetFocusTo(wwin
->screen_ptr
, wwin
);
411 wGNOMEUpdateClientStateHint(wwin
, False
);
414 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
415 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
418 /* update window list to reflect unshaded state */
419 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
425 wMaximizeWindow(WWindow
*wwin
, int directions
)
427 int new_width
, new_height
, new_x
, new_y
;
428 WArea usableArea
= wwin
->screen_ptr
->totalUsableArea
;
431 if (WFLAGP(wwin
, no_resizable
))
435 if (WFLAGP(wwin
, full_maximize
)) {
438 usableArea
.x2
= wwin
->screen_ptr
->scr_width
;
439 usableArea
.y2
= wwin
->screen_ptr
->scr_height
;
442 if (wwin
->flags
.shaded
) {
443 wwin
->flags
.skip_next_animation
= 1;
444 wUnshadeWindow(wwin
);
446 wwin
->flags
.maximized
= directions
;
447 wwin
->old_geometry
.width
= wwin
->client
.width
;
448 wwin
->old_geometry
.height
= wwin
->client
.height
;
449 wwin
->old_geometry
.x
= wwin
->frame_x
;
450 wwin
->old_geometry
.y
= wwin
->frame_y
;
453 wKWMUpdateClientGeometryRestore(wwin
);
456 if (directions
& MAX_HORIZONTAL
) {
458 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
459 new_x
= usableArea
.x1
;
463 new_x
= wwin
->frame_x
;
464 new_width
= wwin
->frame
->core
->width
;
468 if (directions
& MAX_VERTICAL
) {
470 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
471 new_y
= usableArea
.y1
;
472 if (WFLAGP(wwin
, full_maximize
))
473 new_y
-= wwin
->frame
->top_width
;
477 new_y
= wwin
->frame_y
;
478 new_height
= wwin
->frame
->core
->height
;
482 if (!WFLAGP(wwin
, full_maximize
)) {
483 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
486 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
487 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
490 wGNOMEUpdateClientStateHint(wwin
, False
);
493 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
494 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
498 wSoundPlay(WMSOUND_MAXIMIZE
);
504 wUnmaximizeWindow(WWindow
*wwin
)
506 int restore_x
, restore_y
;
508 if (!wwin
->flags
.maximized
)
511 if (wwin
->flags
.shaded
) {
512 wwin
->flags
.skip_next_animation
= 1;
513 wUnshadeWindow(wwin
);
515 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
516 wwin
->old_geometry
.x
: wwin
->frame_x
;
517 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
518 wwin
->old_geometry
.y
: wwin
->frame_y
;
519 wwin
->flags
.maximized
= 0;
520 wWindowConfigure(wwin
, restore_x
, restore_y
,
521 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
524 wGNOMEUpdateClientStateHint(wwin
, False
);
527 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
528 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
532 wSoundPlay(WMSOUND_UNMAXIMIZE
);
538 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
539 int fx
, int fy
, int fw
, int fh
, int steps
)
541 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
542 float cx
, cy
, cw
, ch
;
543 float xstep
, ystep
, wstep
, hstep
;
546 float angle
, final_angle
, delta
;
548 xstep
= (float)(fx
-x
)/steps
;
549 ystep
= (float)(fy
-y
)/steps
;
550 wstep
= (float)(fw
-w
)/steps
;
551 hstep
= (float)(fh
-h
)/steps
;
558 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
559 delta
= (float)(final_angle
/FRAMES
);
560 for (angle
=0;; angle
+=delta
) {
561 if (angle
> final_angle
)
564 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
565 dch
= (ch
/2) * cos(angle
);
568 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
569 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
570 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
571 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
572 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
575 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
577 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
578 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
581 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
587 if (angle
>= final_angle
)
597 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
598 int fx
, int fy
, int fw
, int fh
, int steps
)
600 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
601 float cx
, cy
, cw
, ch
;
602 float xstep
, ystep
, wstep
, hstep
;
604 float angle
, final_angle
, a
, d
, delta
;
611 xstep
= (float)(fx
-x
)/steps
;
612 ystep
= (float)(fy
-y
)/steps
;
613 wstep
= (float)(fw
-w
)/steps
;
614 hstep
= (float)(fh
-h
)/steps
;
621 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
622 delta
= (float)(final_angle
/FRAMES
);
623 for (angle
=0;; angle
+=delta
) {
624 if (angle
> final_angle
)
628 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
630 points
[0].x
= cx
+cos(angle
-a
)*d
;
631 points
[0].y
= cy
+sin(angle
-a
)*d
;
632 points
[1].x
= cx
+cos(angle
+a
)*d
;
633 points
[1].y
= cy
+sin(angle
+a
)*d
;
634 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
635 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
636 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
637 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
638 points
[4].x
= cx
+cos(angle
-a
)*d
;
639 points
[4].y
= cy
+sin(angle
-a
)*d
;
641 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
643 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
644 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
647 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
653 if (angle
>= final_angle
)
663 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
664 int fx
, int fy
, int fw
, int fh
, int steps
)
666 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
667 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
668 float xstep
, ystep
, wstep
, hstep
;
671 xstep
= (float)(fx
-x
)/steps
;
672 ystep
= (float)(fy
-y
)/steps
;
673 wstep
= (float)(fw
-w
)/steps
;
674 hstep
= (float)(fh
-h
)/steps
;
676 for (j
=0; j
<FRAMES
; j
++) {
683 for (i
=0; i
<steps
; i
++) {
684 for (j
=0; j
<FRAMES
; j
++) {
685 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
686 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
689 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
690 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
692 for (j
=0; j
<FRAMES
; j
++) {
693 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
694 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
709 for (j
=0; j
<FRAMES
; j
++) {
710 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
711 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
714 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
715 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
717 for (j
=0; j
<FRAMES
; j
++) {
718 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
719 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
728 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
729 int fx
, int fy
, int fw
, int fh
, int hiding
)
731 int style
= wPreferences
.iconification_style
; /* Catch the value */
734 if (style
== WIS_NONE
)
737 if (style
== WIS_RANDOM
) {
741 k
= (hiding
? 2 : 3);
744 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
746 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
749 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
751 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
755 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
757 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
761 #endif /* ANIMATIONS */
769 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
770 WMHandleEvent(&tmpev
);
775 unmapTransientsFor(WWindow
*wwin
)
780 tmp
= wwin
->screen_ptr
->focused_window
;
782 /* unmap the transients for this transient */
783 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
784 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
785 || tmp
->flags
.shaded
)) {
786 unmapTransientsFor(tmp
);
787 tmp
->flags
.miniaturized
= 1;
788 if (!tmp
->flags
.shaded
) {
791 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
794 if (!tmp->flags.shaded)
796 wClientSetState(tmp
, IconicState
, None
);
798 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
799 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
800 tmp
->flags
.kwm_hidden_for_modules
= 1;
803 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
812 mapTransientsFor(WWindow
*wwin
)
816 tmp
= wwin
->screen_ptr
->focused_window
;
818 /* recursively map the transients for this transient */
819 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
820 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
821 && tmp
->icon
==NULL
) {
822 mapTransientsFor(tmp
);
823 tmp
->flags
.miniaturized
= 0;
824 if (!tmp
->flags
.shaded
) {
827 XMapWindow(dpy
, tmp
->frame
->core
->window
);
829 tmp
->flags
.semi_focused
= 0;
831 if (!tmp->flags.shaded)
833 wClientSetState(tmp
, NormalState
, None
);
835 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
836 if (tmp
->flags
.kwm_hidden_for_modules
) {
837 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
838 tmp
->flags
.kwm_hidden_for_modules
= 0;
842 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
851 setupIconGrabs(WIcon
*icon
)
853 /* setup passive grabs on the icon */
854 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
855 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
856 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
857 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
858 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
859 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
865 recursiveTransientFor(WWindow
*wwin
)
872 /* hackish way to detect transient_for cycle */
873 i
= wwin
->screen_ptr
->window_count
+1;
875 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
876 wwin
= wWindowFor(wwin
->transient_for
);
880 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
890 removeIconGrabs(WIcon
*icon
)
892 /* remove passive grabs on the icon */
893 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
894 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
895 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
902 wIconifyWindow(WWindow
*wwin
)
904 XWindowAttributes attribs
;
908 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
909 /* the window doesn't exist anymore */
913 if (wwin
->flags
.miniaturized
) {
918 if (wwin
->transient_for
!=None
) {
919 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
921 if (owner
&& owner
->flags
.miniaturized
)
925 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
927 /* if the window is in another workspace, simplify process */
929 /* icon creation may take a while */
930 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
931 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
932 GrabModeAsync
, None
, None
, CurrentTime
);
935 if (!wPreferences
.disable_miniwindows
) {
936 if (!wwin
->flags
.icon_moved
) {
937 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
939 wwin
->icon
= wIconCreate(wwin
);
941 wwin
->icon
->mapped
= 1;
944 wwin
->flags
.miniaturized
= 1;
945 wwin
->flags
.mapped
= 0;
947 /* unmap transients */
949 unmapTransientsFor(wwin
);
953 wSoundPlay(WMSOUND_ICONIFY
);
956 XUngrabPointer(dpy
, CurrentTime
);
958 /* let all Expose events arrive so that we can repaint
959 * something before the animation starts (and the server is grabbed) */
962 if (wPreferences
.disable_miniwindows
)
963 wClientSetState(wwin
, IconicState
, None
);
965 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
969 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
970 && !wPreferences
.no_animations
) {
973 if (!wPreferences
.disable_miniwindows
) {
976 iw
= wwin
->icon
->core
->width
;
977 ih
= wwin
->icon
->core
->height
;
982 if (wKWMGetIconGeometry(wwin
, &area
)) {
988 #endif /* KWM_HINTS */
992 iw
= wwin
->screen_ptr
->scr_width
;
993 ih
= wwin
->screen_ptr
->scr_height
;
996 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
997 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
998 ix
, iy
, iw
, ih
, False
);
1003 wwin
->flags
.skip_next_animation
= 0;
1005 if (!wPreferences
.disable_miniwindows
) {
1007 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1008 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1010 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1012 AddToStackList(wwin
->icon
->core
);
1014 wLowerFrame(wwin
->icon
->core
);
1018 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1021 * It doesn't seem to be working and causes button event hangup
1022 * when deiconifying a transient window.
1023 setupIconGrabs(wwin->icon);
1025 if ((wwin
->flags
.focused
1026 || (owner
&& wwin
->client_win
== owner
->client_win
))
1027 && wPreferences
.focus_mode
==WKF_CLICK
) {
1032 if (!WFLAGP(tmp
, no_focusable
)
1033 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1034 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1038 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1039 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1040 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1044 if (!wwin
->screen_ptr
->flags
.startup
) {
1045 Window clientwin
= wwin
->client_win
;
1048 processEvents(XPending(dpy
));
1050 /* the window can disappear while doing the processEvents() */
1051 if (!wWindowFor(clientwin
))
1058 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1059 wIconSelect(wwin
->icon
);
1062 wGNOMEUpdateClientStateHint(wwin
, False
);
1065 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1066 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1069 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1076 wDeiconifyWindow(WWindow
*wwin
)
1078 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1080 if (!wwin
->flags
.miniaturized
)
1083 if (wwin
->transient_for
!= None
1084 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1085 WWindow
*owner
= recursiveTransientFor(wwin
);
1087 if (owner
&& owner
->flags
.miniaturized
) {
1088 wDeiconifyWindow(owner
);
1089 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1090 wRaiseFrame(wwin
->frame
->core
);
1095 wwin
->flags
.miniaturized
= 0;
1096 if (!wwin
->flags
.shaded
)
1097 wwin
->flags
.mapped
= 1;
1099 if (!wPreferences
.disable_miniwindows
) {
1100 if (wwin
->icon
->selected
)
1101 wIconSelect(wwin
->icon
);
1103 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1107 wSoundPlay(WMSOUND_DEICONIFY
);
1110 /* if the window is in another workspace, do it silently */
1112 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1113 && !wwin
->flags
.skip_next_animation
) {
1116 if (!wPreferences
.disable_miniwindows
) {
1119 iw
= wwin
->icon
->core
->width
;
1120 ih
= wwin
->icon
->core
->height
;
1125 if (wKWMGetIconGeometry(wwin
, &area
)) {
1131 #endif /* KWM_HINTS */
1135 iw
= wwin
->screen_ptr
->scr_width
;
1136 ih
= wwin
->screen_ptr
->scr_height
;
1139 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1140 wwin
->frame_x
, wwin
->frame_y
,
1141 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1144 #endif /* ANIMATIONS */
1145 wwin
->flags
.skip_next_animation
= 0;
1147 if (!wwin
->flags
.shaded
) {
1148 XMapWindow(dpy
, wwin
->client_win
);
1150 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1151 wRaiseFrame(wwin
->frame
->core
);
1152 if (!wwin
->flags
.shaded
) {
1153 wClientSetState(wwin
, NormalState
, None
);
1155 mapTransientsFor(wwin
);
1157 if (!wPreferences
.disable_miniwindows
) {
1158 RemoveFromStackList(wwin
->icon
->core
);
1159 /* removeIconGrabs(wwin->icon);*/
1160 wIconDestroy(wwin
->icon
);
1165 if (wPreferences
.focus_mode
==WKF_CLICK
)
1166 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1169 if (!wwin
->screen_ptr
->flags
.startup
) {
1170 Window clientwin
= wwin
->client_win
;
1173 processEvents(XPending(dpy
));
1175 if (!wWindowFor(clientwin
))
1180 if (wPreferences
.auto_arrange_icons
) {
1181 wArrangeIcons(wwin
->screen_ptr
, True
);
1185 wGNOMEUpdateClientStateHint(wwin
, False
);
1188 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1189 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1192 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1198 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1200 if (wwin
->flags
.miniaturized
) {
1202 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1203 wwin
->icon
->mapped
= 0;
1205 wwin
->flags
.hidden
= 1;
1207 wGNOMEUpdateClientStateHint(wwin
, False
);
1210 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1215 if (wwin
->flags
.inspector_open
) {
1216 WWindow
*pwin
= wwin
->inspector
->frame
;
1219 pwin
->flags
.hidden
= 1;
1221 wClientSetState(pwin
, IconicState
, icon
->icon_win
);
1224 wwin
->flags
.hidden
= 1;
1227 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1230 wSoundPlay(WMSOUND_HIDE
);
1233 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1234 !wwin
->flags
.skip_next_animation
&& animate
) {
1235 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1236 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1237 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1241 wwin
->flags
.skip_next_animation
= 0;
1244 wGNOMEUpdateClientStateHint(wwin
, False
);
1247 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1253 wHideOtherApplications(WWindow
*awin
)
1257 #ifdef REDUCE_APPICONS
1258 char *tinstance
, *tclass
;
1259 unsigned int brokenwin
= 0, match
= 0;
1264 wwin
= awin
->screen_ptr
->focused_window
;
1266 #ifdef REDUCE_APPICONS
1267 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1273 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1274 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1275 && !wwin
->flags
.internal_window
1276 && (!wwin
->flags
.inspector_open
|| wwin
->inspector
->frame
!=awin
)
1277 && !WFLAGP(wwin
, no_hide_others
)) {
1279 #ifdef REDUCE_APPICONS
1282 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1284 if ((tclass
= wwin
->wm_class
) == NULL
)
1286 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1287 (strcmp(awin
->wm_class
, tclass
) == 0) )
1292 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1293 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1294 wwin
->flags
.skip_next_animation
= 1;
1295 wIconifyWindow(wwin
);
1297 } else if (wwin
->main_window
!=None
1298 #ifndef REDUCE_APPICONS
1299 && awin
->main_window
!= wwin
->main_window
) {
1301 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1303 tapp
= wApplicationOf(wwin
->main_window
);
1305 tapp
->flags
.skip_next_animation
= 1;
1306 wHideApplication(tapp
);
1308 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1309 wwin
->flags
.skip_next_animation
= 1;
1310 wIconifyWindow(wwin
);
1318 wSetFocusTo(awin->screen_ptr, awin);
1325 wHideApplication(WApplication
*wapp
)
1327 #ifdef REDUCE_APPICONS
1329 char *tinstance
, *tclass
;
1330 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1337 wwarning("trying to hide a non grouped window");
1340 if (!wapp
->main_window_desc
) {
1341 wwarning("group leader not found for window group");
1344 #ifdef REDUCE_APPICONS
1345 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1346 (wapp
->main_window_desc
->wm_class
== NULL
))
1349 scr
= wapp
->main_window_desc
->screen_ptr
;
1351 wlist
= scr
->focused_window
;
1355 if (wlist
->main_window
== wapp
->main_window
)
1356 wapp
->last_focused
= wlist
;
1358 wapp
->last_focused
= NULL
;
1360 #ifdef REDUCE_APPICONS
1361 matchwmhints
= matchworkspace
= 0;
1363 tapp
= wApplicationOf(wlist
->main_window
);
1364 tinstance
= tclass
= NULL
;
1366 if (tapp
->main_window_desc
) {
1367 tinstance
= tapp
->main_window_desc
->wm_instance
;
1368 tclass
= tapp
->main_window_desc
->wm_class
;
1371 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1372 /* Should never reach here */
1376 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1377 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1381 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1384 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1390 if (wlist
->main_window
== wapp
->main_window
) {
1392 if (wlist
->flags
.focused
) {
1396 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1397 wapp
->app_icon
->y_pos
, wlist
,
1398 !wapp
->flags
.skip_next_animation
);
1400 wlist
= wlist
->prev
;
1403 wapp
->flags
.skip_next_animation
= 0;
1406 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1407 wlist
= scr
->focused_window
;
1409 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1410 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1412 wlist
= wlist
->prev
;
1414 wSetFocusTo(scr
, wlist
);
1416 wSetFocusTo(scr
, NULL
);
1420 wapp
->flags
.hidden
= 1;
1422 if(wPreferences
.auto_arrange_icons
) {
1423 wArrangeIcons(scr
, True
);
1427 wAppIconPaint(wapp
->app_icon
);
1435 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1436 int bringToCurrentWS
)
1438 if (bringToCurrentWS
)
1439 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1441 wwin
->flags
.hidden
=0;
1442 wwin
->flags
.mapped
=1;
1445 wSoundPlay(WMSOUND_UNHIDE
);
1448 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1450 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1451 icon
->core
->width
, icon
->core
->height
,
1452 wwin
->frame_x
, wwin
->frame_y
,
1453 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1457 wwin
->flags
.skip_next_animation
= 0;
1458 XMapWindow(dpy
, wwin
->client_win
);
1459 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1460 wClientSetState(wwin
, NormalState
, None
);
1461 wRaiseFrame(wwin
->frame
->core
);
1462 if (wwin
->flags
.inspector_open
) {
1463 WWindow
*pwin
= wwin
->inspector
->frame
;
1465 pwin
->flags
.hidden
= 0;
1466 pwin
->flags
.mapped
= 1;
1467 XMapWindow(dpy
, pwin
->client_win
);
1468 XMapWindow(dpy
, pwin
->frame
->core
->window
);
1469 wClientSetState(pwin
, NormalState
, None
);
1473 wGNOMEUpdateClientStateHint(wwin
, False
);
1476 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1482 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1485 WWindow
*wlist
, *next
;
1486 WWindow
*focused
=NULL
;
1487 #ifdef REDUCE_APPICONS
1488 char *tinstance
, *tclass
;
1489 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1496 #ifdef REDUCE_APPICONS
1497 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1498 (wapp
->main_window_desc
->wm_instance
== NULL
))
1502 scr
= wapp
->main_window_desc
->screen_ptr
;
1503 wlist
= scr
->focused_window
;
1505 /* goto beginning of list */
1507 wlist
= wlist
->prev
;
1512 #ifndef REDUCE_APPICONS
1513 if (wlist
->main_window
== wapp
->main_window
) {
1515 matchwmhints
= matchworkspace
= 0;
1517 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1519 if ((tclass
= wlist
->wm_class
) == NULL
)
1521 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1522 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1526 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1530 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1533 if (wlist
->flags
.focused
)
1535 else if (!focused
|| !focused
->flags
.focused
)
1538 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1539 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1540 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1541 if (!wlist
->icon
->mapped
) {
1542 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1543 wlist
->icon
->mapped
= 1;
1545 wlist
->flags
.hidden
= 0;
1547 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1549 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1550 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1553 wDeiconifyWindow(wlist
);
1555 } else if (wlist
->flags
.hidden
) {
1556 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1557 wapp
->app_icon
->y_pos
, wlist
,
1558 !wapp
->flags
.skip_next_animation
,
1561 if (bringToCurrentWS
1562 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1563 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1565 wRaiseFrame(wlist
->frame
->core
);
1571 wapp
->flags
.skip_next_animation
= 0;
1572 wapp
->flags
.hidden
= 0;
1575 wSetFocusTo(scr
, focused
);
1576 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1577 wSetFocusTo(scr
, wapp
->last_focused
);
1578 wapp
->last_focused
= NULL
;
1579 if (wPreferences
.auto_arrange_icons
) {
1580 wArrangeIcons(scr
, True
);
1583 wAppIconPaint(wapp
->app_icon
);
1590 wShowAllWindows(WScreen
*scr
)
1592 WWindow
*wwin
, *old_foc
;
1595 old_foc
= wwin
= scr
->focused_window
;
1597 if (!wwin
->flags
.internal_window
&&
1598 (scr
->current_workspace
== wwin
->frame
->workspace
1599 || IS_OMNIPRESENT(wwin
))) {
1600 if (wwin
->flags
.miniaturized
) {
1601 wwin
->flags
.skip_next_animation
= 1;
1602 wDeiconifyWindow(wwin
);
1603 } else if (wwin
->flags
.hidden
) {
1604 wapp
= wApplicationOf(wwin
->main_window
);
1606 wUnhideApplication(wapp
, False
, False
);
1608 wwin
->flags
.skip_next_animation
= 1;
1609 wDeiconifyWindow(wwin
);
1615 wSetFocusTo(scr
, old_foc
);
1616 /*wRaiseFrame(old_foc->frame->core);*/
1621 wRefreshDesktop(WScreen
*scr
)
1624 XSetWindowAttributes attr
;
1626 attr
.backing_store
= NotUseful
;
1627 attr
.save_under
= False
;
1628 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1629 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1630 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1632 XMapRaised(dpy
, win
);
1633 XDestroyWindow(dpy
, win
);
1639 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1643 int pf
; /* primary axis */
1644 int sf
; /* secondary axis */
1648 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1652 int isize
= wPreferences
.icon_size
;
1655 * Find out screen boundaries.
1659 sx2
= scr
->scr_width
;
1660 sy2
= scr
->scr_height
;
1662 if (scr
->dock
->on_right_side
)
1663 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1665 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1668 sw
= isize
* (scr
->scr_width
/isize
);
1669 sh
= isize
* (scr
->scr_height
/isize
);
1670 fullW
= (sx2
-sx1
)/isize
;
1671 fullH
= (sy2
-sy1
)/isize
;
1673 /* icon yard boundaries */
1674 if (wPreferences
.icon_yard
& IY_VERT
) {
1681 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1688 if (wPreferences
.icon_yard
& IY_TOP
) {
1696 /* arrange icons putting the most recently focused window
1697 * as the last icon */
1698 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1699 : xo + xs*(pi*isize))
1700 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1701 : yo + ys*(si*isize))
1703 /* arrange application icons */
1704 aicon
= scr
->app_icon_list
;
1705 /* reverse them to avoid unnecessarily sliding of icons */
1706 while (aicon
&& aicon
->next
)
1707 aicon
= aicon
->next
;
1712 if (!aicon
->docked
) {
1713 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1715 if (!wPreferences
.no_animations
) {
1716 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1719 #endif /* ANIMATIONS */
1721 wAppIconMove(aicon
, X
, Y
);
1724 /* we reversed the order so we use prev */
1725 aicon
= aicon
->prev
;
1732 /* arrange miniwindows */
1734 wwin
= scr
->focused_window
;
1735 /* reverse them to avoid unnecessarily shuffling */
1736 while (wwin
&& wwin
->prev
)
1740 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1741 (wwin
->frame
->workspace
==scr
->current_workspace
||
1742 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1744 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1745 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1747 if (wPreferences
.no_animations
) {
1748 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1750 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1751 wwin
->icon_y
, X
, Y
);
1754 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1755 #endif /* ANIMATIONS */
1763 wwin
->flags
.icon_moved
= 0;
1765 /* we reversed the order, so we use next */
1776 wSelectWindow(WWindow
*wwin
, Bool flag
)
1778 WScreen
*scr
= wwin
->screen_ptr
;
1781 wwin
->flags
.selected
= 1;
1782 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1783 if (!scr
->selected_windows
)
1784 scr
->selected_windows
= WMCreateBag(4);
1785 WMPutInBag(scr
->selected_windows
, wwin
);
1787 wwin
->flags
.selected
= 0;
1788 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1789 scr
->frame_border_pixel
);
1790 if (scr
->selected_windows
) {
1791 WMRemoveFromBag(scr
->selected_windows
, wwin
);
1798 wMakeWindowVisible(WWindow
*wwin
)
1800 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1801 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1803 if (wwin
->flags
.shaded
) {
1804 wUnshadeWindow(wwin
);
1806 if (wwin
->flags
.hidden
) {
1809 app
= wApplicationOf(wwin
->main_window
);
1811 wUnhideApplication(app
, False
, False
);
1812 } else if (wwin
->flags
.miniaturized
) {
1813 wDeiconifyWindow(wwin
);
1815 if (!WFLAGP(wwin
, no_focusable
))
1816 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1817 wRaiseFrame(wwin
->frame
->core
);