1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 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"
50 #include "workspace.h"
64 /****** Global Variables ******/
65 extern Time LastTimestamp
;
66 extern Time LastFocusChange
;
68 extern Cursor wCursor
[WCUR_LAST
];
70 extern WPreferences wPreferences
;
72 extern Atom _XA_WM_TAKE_FOCUS
;
75 /******* Local Variables *******/
80 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
81 {SHADE_STEPS_F
, SHADE_DELAY_F
},
82 {SHADE_STEPS_M
, SHADE_DELAY_M
},
83 {SHADE_STEPS_S
, SHADE_DELAY_S
},
84 {SHADE_STEPS_U
, SHADE_DELAY_U
}};
86 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
87 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
90 static int ignoreTimestamp
=0;
95 processEvents(int event_count
)
100 * This is a hack. When animations are enabled, processing of
101 * events ocurred during a animation are delayed until it's end.
102 * Calls that consider the TimeStamp, like XSetInputFocus(), will
103 * fail because the TimeStamp is too old. Then, for example, if
104 * the user changes window focus while a miniaturize animation is
105 * in course, the window will not get focus properly after the end
106 * of the animation. This tries to workaround it by passing CurrentTime
107 * as the TimeStamp for XSetInputFocus() for all events ocurred during
111 while (XPending(dpy
) && event_count
--) {
112 WMNextEvent(dpy
, &event
);
113 WMHandleEvent(&event
);
117 #endif /* ANIMATIONS */
122 *----------------------------------------------------------------------
124 * Changes the window focus to the one passed as argument.
125 * If the window to focus is not already focused, it will be brought
126 * to the head of the list of windows. Previously focused window is
130 * Window list may be reordered and the window focus is changed.
132 *----------------------------------------------------------------------
135 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
137 WWindow
*focused
=scr
->focused_window
;
138 int timestamp
=LastTimestamp
;
139 WApplication
*oapp
=NULL
, *napp
=NULL
;
142 LastFocusChange
= timestamp
;
145 * This is a hack, because XSetInputFocus() should have a proper
146 * timestamp instead of CurrentTime but it seems that some times
147 * clients will not receive focus properly that way.
150 timestamp
= CurrentTime
;
153 oapp
= wApplicationOf(focused
->main_window
);
156 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
158 wWindowUnfocus(focused
);
161 wAppMenuUnmap(oapp
->menu
);
163 wApplicationDeactivate(oapp
);
167 wKWMUpdateActiveWindowHint(scr
);
168 wKWMSendEventMessage(NULL
, WKWMFocusWindow
);
172 wasfocused
= wwin
->flags
.focused
;
173 napp
= wApplicationOf(wwin
->main_window
);
175 /* remember last workspace where the app has been */
177 napp
->last_workspace
= wwin
->screen_ptr
->current_workspace
;
179 if (wwin
->flags
.mapped
&& !WFLAGP(wwin
, no_focusable
)) {
180 /* install colormap if colormap mode is lock mode */
181 if (wPreferences
.colormap_mode
==WKF_CLICK
)
182 wColormapInstallForWindow(scr
, wwin
);
184 /* set input focus */
185 switch (wwin
->focus_mode
) {
187 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
191 case WFM_LOCALLY_ACTIVE
:
192 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
195 case WFM_GLOBALLY_ACTIVE
:
199 if (wwin
->protocols
.TAKE_FOCUS
) {
200 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
204 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
206 if (WFLAGP(wwin
, no_focusable
))
209 /* if this is not the focused window focus it */
211 /* change the focus window list order */
213 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
);
231 wWindowFocus(wwin
, focused
);
233 if (napp
&& !wasfocused
) {
235 wUserMenuRefreshInstances(napp
->menu
, wwin
);
236 #endif /* USER_MENU */
238 wAppMenuMap(napp
->menu
, wwin
);
240 wApplicationActivate(napp
);
244 wKWMUpdateActiveWindowHint(scr
);
245 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
252 wShadeWindow(WWindow
*wwin
)
254 time_t time0
= time(NULL
);
259 if (wwin
->flags
.shaded
)
262 XLowerWindow(dpy
, wwin
->client_win
);
265 wSoundPlay(WMSOUND_SHADE
);
269 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
270 && !wPreferences
.no_animations
) {
271 /* do the shading animation */
272 h
= wwin
->frame
->core
->height
;
275 w
= wwin
->frame
->core
->width
;
276 y
= wwin
->frame
->top_width
;
277 while (h
>wwin
->frame
->top_width
+1) {
278 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
279 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
282 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
286 wusleep(SHADE_DELAY
*1000L);
290 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
292 #endif /* ANIMATIONS */
294 wwin
->flags
.skip_next_animation
= 0;
295 wwin
->flags
.shaded
= 1;
296 wwin
->flags
.mapped
= 0;
297 /* prevent window withdrawal when getting UnmapNotify */
298 XSelectInput(dpy
, wwin
->client_win
,
299 wwin
->event_mask
& ~StructureNotifyMask
);
300 XUnmapWindow(dpy
, wwin
->client_win
);
301 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
303 /* for the client it's just like iconification */
304 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
305 wwin
->frame
->top_width
- 1);
307 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
308 + wwin
->frame
->top_width
;
309 wWindowSynthConfigureNotify(wwin
);
312 wClientSetState(wwin, IconicState, None);
316 wGNOMEUpdateClientStateHint(wwin
, False
);
319 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
320 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
322 /* update window list to reflect shaded state */
323 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
326 if (!wwin
->screen_ptr
->flags
.startup
) {
327 /* Look at processEvents() for reason of this code. */
329 processEvents(XPending(dpy
));
336 wUnshadeWindow(WWindow
*wwin
)
338 time_t time0
= time(NULL
);
341 #endif /* ANIMATIONS */
344 if (!wwin
->flags
.shaded
)
347 wwin
->flags
.shaded
= 0;
348 wwin
->flags
.mapped
= 1;
349 XMapWindow(dpy
, wwin
->client_win
);
352 wSoundPlay(WMSOUND_UNSHADE
);
356 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
357 /* do the shading animation */
358 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
359 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
360 s
= abs(y
)/SHADE_STEPS
;
362 w
= wwin
->frame
->core
->width
;
363 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
365 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
366 + wwin
->frame
->bottom_width
) {
367 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
368 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
371 wusleep(SHADE_DELAY
*2000L/3);
375 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
379 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
381 #endif /* ANIMATIONS */
383 wwin
->flags
.skip_next_animation
= 0;
384 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
385 wwin
->frame
->top_width
+ wwin
->client
.height
386 + wwin
->frame
->bottom_width
);
388 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
389 wWindowSynthConfigureNotify(wwin
);
392 wClientSetState(wwin, NormalState, None);
394 /* if the window is focused, set the focus again as it was disabled during
396 if (wwin
->flags
.focused
)
397 wSetFocusTo(wwin
->screen_ptr
, wwin
);
400 wGNOMEUpdateClientStateHint(wwin
, False
);
403 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
404 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
407 /* update window list to reflect unshaded state */
408 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
414 wMaximizeWindow(WWindow
*wwin
, int directions
)
416 int new_width
, new_height
, new_x
, new_y
;
417 WArea usableArea
= wwin
->screen_ptr
->totalUsableArea
;
420 if (WFLAGP(wwin
, no_resizable
))
424 if (WFLAGP(wwin
, full_maximize
)) {
427 usableArea
.x2
= wwin
->screen_ptr
->scr_width
;
428 usableArea
.y2
= wwin
->screen_ptr
->scr_height
;
431 if (wwin
->flags
.shaded
) {
432 wwin
->flags
.skip_next_animation
= 1;
433 wUnshadeWindow(wwin
);
435 wwin
->flags
.maximized
= directions
;
436 wwin
->old_geometry
.width
= wwin
->client
.width
;
437 wwin
->old_geometry
.height
= wwin
->client
.height
;
438 wwin
->old_geometry
.x
= wwin
->frame_x
;
439 wwin
->old_geometry
.y
= wwin
->frame_y
;
442 wKWMUpdateClientGeometryRestore(wwin
);
445 if (directions
& MAX_HORIZONTAL
) {
447 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
448 new_x
= usableArea
.x1
;
452 new_x
= wwin
->frame_x
;
453 new_width
= wwin
->frame
->core
->width
;
457 if (directions
& MAX_VERTICAL
) {
459 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
460 new_y
= usableArea
.y1
;
461 if (WFLAGP(wwin
, full_maximize
))
462 new_y
-= wwin
->frame
->top_width
;
466 new_y
= wwin
->frame_y
;
467 new_height
= wwin
->frame
->core
->height
;
471 if (!WFLAGP(wwin
, full_maximize
)) {
472 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
475 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
476 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
479 wGNOMEUpdateClientStateHint(wwin
, False
);
482 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
483 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
487 wSoundPlay(WMSOUND_MAXIMIZE
);
493 wUnmaximizeWindow(WWindow
*wwin
)
495 int restore_x
, restore_y
;
497 if (!wwin
->flags
.maximized
)
500 if (wwin
->flags
.shaded
) {
501 wwin
->flags
.skip_next_animation
= 1;
502 wUnshadeWindow(wwin
);
504 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
505 wwin
->old_geometry
.x
: wwin
->frame_x
;
506 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
507 wwin
->old_geometry
.y
: wwin
->frame_y
;
508 wwin
->flags
.maximized
= 0;
509 wWindowConfigure(wwin
, restore_x
, restore_y
,
510 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
513 wGNOMEUpdateClientStateHint(wwin
, False
);
516 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
517 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
521 wSoundPlay(WMSOUND_UNMAXIMIZE
);
527 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
528 int fx
, int fy
, int fw
, int fh
, int steps
)
530 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
531 float cx
, cy
, cw
, ch
;
532 float xstep
, ystep
, wstep
, hstep
;
535 float angle
, final_angle
, delta
;
537 xstep
= (float)(fx
-x
)/steps
;
538 ystep
= (float)(fy
-y
)/steps
;
539 wstep
= (float)(fw
-w
)/steps
;
540 hstep
= (float)(fh
-h
)/steps
;
547 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
548 delta
= (float)(final_angle
/FRAMES
);
549 for (angle
=0;; angle
+=delta
) {
550 if (angle
> final_angle
)
553 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
554 dch
= (ch
/2) * cos(angle
);
557 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
558 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
559 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
560 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
561 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
564 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
566 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
567 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
570 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
576 if (angle
>= final_angle
)
586 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
587 int fx
, int fy
, int fw
, int fh
, int steps
)
589 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
590 float cx
, cy
, cw
, ch
;
591 float xstep
, ystep
, wstep
, hstep
;
593 float angle
, final_angle
, a
, d
, delta
;
600 xstep
= (float)(fx
-x
)/steps
;
601 ystep
= (float)(fy
-y
)/steps
;
602 wstep
= (float)(fw
-w
)/steps
;
603 hstep
= (float)(fh
-h
)/steps
;
610 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
611 delta
= (float)(final_angle
/FRAMES
);
612 for (angle
=0;; angle
+=delta
) {
613 if (angle
> final_angle
)
617 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
619 points
[0].x
= cx
+cos(angle
-a
)*d
;
620 points
[0].y
= cy
+sin(angle
-a
)*d
;
621 points
[1].x
= cx
+cos(angle
+a
)*d
;
622 points
[1].y
= cy
+sin(angle
+a
)*d
;
623 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
624 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
625 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
626 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
627 points
[4].x
= cx
+cos(angle
-a
)*d
;
628 points
[4].y
= cy
+sin(angle
-a
)*d
;
630 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
632 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
633 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
636 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
642 if (angle
>= final_angle
)
652 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
653 int fx
, int fy
, int fw
, int fh
, int steps
)
655 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
656 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
657 float xstep
, ystep
, wstep
, hstep
;
660 xstep
= (float)(fx
-x
)/steps
;
661 ystep
= (float)(fy
-y
)/steps
;
662 wstep
= (float)(fw
-w
)/steps
;
663 hstep
= (float)(fh
-h
)/steps
;
665 for (j
=0; j
<FRAMES
; j
++) {
672 for (i
=0; i
<steps
; i
++) {
673 for (j
=0; j
<FRAMES
; j
++) {
674 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
675 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
678 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
679 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
681 for (j
=0; j
<FRAMES
; j
++) {
682 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
683 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
698 for (j
=0; j
<FRAMES
; j
++) {
699 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
700 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
703 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
704 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
706 for (j
=0; j
<FRAMES
; j
++) {
707 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
708 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
717 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
718 int fx
, int fy
, int fw
, int fh
, int hiding
)
720 int style
= wPreferences
.iconification_style
; /* Catch the value */
723 if (style
== WIS_NONE
)
726 if (style
== WIS_RANDOM
) {
730 k
= (hiding
? 2 : 3);
733 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
735 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
738 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
740 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
744 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
746 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
750 #endif /* ANIMATIONS */
758 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
759 WMHandleEvent(&tmpev
);
764 unmapTransientsFor(WWindow
*wwin
)
769 tmp
= wwin
->screen_ptr
->focused_window
;
771 /* unmap the transients for this transient */
772 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
773 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
774 || tmp
->flags
.shaded
)) {
775 unmapTransientsFor(tmp
);
776 tmp
->flags
.miniaturized
= 1;
777 if (!tmp
->flags
.shaded
) {
780 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
783 if (!tmp->flags.shaded)
785 wClientSetState(tmp
, IconicState
, None
);
787 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
788 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
789 tmp
->flags
.kwm_hidden_for_modules
= 1;
792 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
801 mapTransientsFor(WWindow
*wwin
)
805 tmp
= wwin
->screen_ptr
->focused_window
;
807 /* recursively map the transients for this transient */
808 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
809 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
810 && tmp
->icon
==NULL
) {
811 mapTransientsFor(tmp
);
812 tmp
->flags
.miniaturized
= 0;
813 if (!tmp
->flags
.shaded
) {
816 XMapWindow(dpy
, tmp
->frame
->core
->window
);
818 tmp
->flags
.semi_focused
= 0;
820 if (!tmp->flags.shaded)
822 wClientSetState(tmp
, NormalState
, None
);
824 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
825 if (tmp
->flags
.kwm_hidden_for_modules
) {
826 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
827 tmp
->flags
.kwm_hidden_for_modules
= 0;
831 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
840 setupIconGrabs(WIcon
*icon
)
842 /* setup passive grabs on the icon */
843 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
844 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
845 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
846 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
847 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
848 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
854 recursiveTransientFor(WWindow
*wwin
)
861 /* hackish way to detect transient_for cycle */
862 i
= wwin
->screen_ptr
->window_count
+1;
864 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
865 wwin
= wWindowFor(wwin
->transient_for
);
869 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
879 removeIconGrabs(WIcon
*icon
)
881 /* remove passive grabs on the icon */
882 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
883 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
884 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
891 wIconifyWindow(WWindow
*wwin
)
893 XWindowAttributes attribs
;
897 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
898 /* the window doesn't exist anymore */
902 if (wwin
->flags
.miniaturized
) {
907 if (wwin
->transient_for
!=None
) {
908 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
910 if (owner
&& owner
->flags
.miniaturized
)
914 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
916 /* if the window is in another workspace, simplify process */
918 /* icon creation may take a while */
919 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
920 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
921 GrabModeAsync
, None
, None
, CurrentTime
);
924 if (!wPreferences
.disable_miniwindows
) {
925 if (!wwin
->flags
.icon_moved
) {
926 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
928 wwin
->icon
= wIconCreate(wwin
);
931 wwin
->flags
.miniaturized
= 1;
932 wwin
->flags
.mapped
= 0;
934 /* unmap transients */
936 unmapTransientsFor(wwin
);
940 wSoundPlay(WMSOUND_ICONIFY
);
943 XUngrabPointer(dpy
, CurrentTime
);
945 /* let all Expose events arrive so that we can repaint
946 * something before the animation starts (and the server is grabbed) */
949 if (wPreferences
.disable_miniwindows
)
950 wClientSetState(wwin
, IconicState
, None
);
952 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
956 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
957 && !wPreferences
.no_animations
) {
960 if (!wPreferences
.disable_miniwindows
) {
963 iw
= wwin
->icon
->core
->width
;
964 ih
= wwin
->icon
->core
->height
;
969 if (wKWMGetIconGeometry(wwin
, &area
)) {
975 #endif /* KWM_HINTS */
979 iw
= wwin
->screen_ptr
->scr_width
;
980 ih
= wwin
->screen_ptr
->scr_height
;
983 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
984 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
985 ix
, iy
, iw
, ih
, False
);
990 wwin
->flags
.skip_next_animation
= 0;
992 if (!wPreferences
.disable_miniwindows
) {
994 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
995 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
997 XMapWindow(dpy
, wwin
->icon
->core
->window
);
999 AddToStackList(wwin
->icon
->core
);
1001 wLowerFrame(wwin
->icon
->core
);
1005 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1008 * It doesn't seem to be working and causes button event hangup
1009 * when deiconifying a transient window.
1010 setupIconGrabs(wwin->icon);
1012 if ((wwin
->flags
.focused
1013 || (owner
&& wwin
->client_win
== owner
->client_win
))
1014 && wPreferences
.focus_mode
==WKF_CLICK
) {
1019 if (!WFLAGP(tmp
, no_focusable
)
1020 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1021 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1025 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1026 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1027 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1031 if (!wwin
->screen_ptr
->flags
.startup
) {
1032 Window clientwin
= wwin
->client_win
;
1035 processEvents(XPending(dpy
));
1037 /* the window can disappear while doing the processEvents() */
1038 if (!wWindowFor(clientwin
))
1045 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1046 wIconSelect(wwin
->icon
);
1049 wGNOMEUpdateClientStateHint(wwin
, False
);
1052 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1053 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1056 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1063 wDeiconifyWindow(WWindow
*wwin
)
1065 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1067 if (!wwin
->flags
.miniaturized
)
1070 if (wwin
->transient_for
!= None
1071 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1072 WWindow
*owner
= recursiveTransientFor(wwin
);
1074 if (owner
&& owner
->flags
.miniaturized
) {
1075 wDeiconifyWindow(owner
);
1076 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1077 wRaiseFrame(wwin
->frame
->core
);
1082 wwin
->flags
.miniaturized
= 0;
1083 if (!wwin
->flags
.shaded
)
1084 wwin
->flags
.mapped
= 1;
1086 if (!wPreferences
.disable_miniwindows
) {
1087 if (wwin
->icon
->selected
)
1088 wIconSelect(wwin
->icon
);
1090 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1094 wSoundPlay(WMSOUND_DEICONIFY
);
1097 /* if the window is in another workspace, do it silently */
1099 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1100 && !wwin
->flags
.skip_next_animation
) {
1103 if (!wPreferences
.disable_miniwindows
) {
1106 iw
= wwin
->icon
->core
->width
;
1107 ih
= wwin
->icon
->core
->height
;
1112 if (wKWMGetIconGeometry(wwin
, &area
)) {
1118 #endif /* KWM_HINTS */
1122 iw
= wwin
->screen_ptr
->scr_width
;
1123 ih
= wwin
->screen_ptr
->scr_height
;
1126 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1127 wwin
->frame_x
, wwin
->frame_y
,
1128 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1131 #endif /* ANIMATIONS */
1132 wwin
->flags
.skip_next_animation
= 0;
1134 if (!wwin
->flags
.shaded
) {
1135 XMapWindow(dpy
, wwin
->client_win
);
1137 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1138 wRaiseFrame(wwin
->frame
->core
);
1139 if (!wwin
->flags
.shaded
) {
1140 wClientSetState(wwin
, NormalState
, None
);
1142 mapTransientsFor(wwin
);
1144 if (!wPreferences
.disable_miniwindows
) {
1145 RemoveFromStackList(wwin
->icon
->core
);
1146 /* removeIconGrabs(wwin->icon);*/
1147 wIconDestroy(wwin
->icon
);
1151 if (wPreferences
.focus_mode
==WKF_CLICK
1152 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1153 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1156 if (!wwin
->screen_ptr
->flags
.startup
) {
1157 Window clientwin
= wwin
->client_win
;
1160 processEvents(XPending(dpy
));
1162 if (!wWindowFor(clientwin
))
1167 if (wPreferences
.auto_arrange_icons
) {
1168 wArrangeIcons(wwin
->screen_ptr
, True
);
1172 wGNOMEUpdateClientStateHint(wwin
, False
);
1175 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1176 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1179 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1185 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1187 if (wwin
->flags
.miniaturized
) {
1189 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1190 wwin
->icon
->mapped
= 0;
1192 wwin
->flags
.hidden
= 1;
1194 wGNOMEUpdateClientStateHint(wwin
, False
);
1197 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1202 if (wwin
->flags
.inspector_open
) {
1203 WWindow
*pwin
= wwin
->inspector
->frame
;
1206 pwin
->flags
.hidden
= 1;
1208 wClientSetState(pwin
, IconicState
, icon
->icon_win
);
1211 wwin
->flags
.hidden
= 1;
1214 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1217 wSoundPlay(WMSOUND_HIDE
);
1220 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1221 !wwin
->flags
.skip_next_animation
&& animate
) {
1222 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1223 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1224 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1228 wwin
->flags
.skip_next_animation
= 0;
1231 wGNOMEUpdateClientStateHint(wwin
, False
);
1234 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1240 wHideOtherApplications(WWindow
*awin
)
1244 #ifdef REDUCE_APPICONS
1245 char *tinstance
, *tclass
;
1246 unsigned int brokenwin
= 0, match
= 0;
1251 wwin
= awin
->screen_ptr
->focused_window
;
1253 #ifdef REDUCE_APPICONS
1254 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1260 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1261 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1262 && !wwin
->flags
.internal_window
1263 && (!wwin
->flags
.inspector_open
|| wwin
->inspector
->frame
!=awin
)
1264 && !WFLAGP(wwin
, no_hide_others
)) {
1266 #ifdef REDUCE_APPICONS
1269 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1271 if ((tclass
= wwin
->wm_class
) == NULL
)
1273 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1274 (strcmp(awin
->wm_class
, tclass
) == 0) )
1279 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1280 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1281 wwin
->flags
.skip_next_animation
= 1;
1282 wIconifyWindow(wwin
);
1284 } else if (wwin
->main_window
!=None
1285 #ifndef REDUCE_APPICONS
1286 && awin
->main_window
!= wwin
->main_window
) {
1288 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1290 tapp
= wApplicationOf(wwin
->main_window
);
1292 tapp
->flags
.skip_next_animation
= 1;
1293 wHideApplication(tapp
);
1295 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1296 wwin
->flags
.skip_next_animation
= 1;
1297 wIconifyWindow(wwin
);
1305 wSetFocusTo(awin->screen_ptr, awin);
1312 wHideApplication(WApplication
*wapp
)
1314 #ifdef REDUCE_APPICONS
1316 char *tinstance
, *tclass
;
1317 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1324 wwarning("trying to hide a non grouped window");
1327 if (!wapp
->main_window_desc
) {
1328 wwarning("group leader not found for window group");
1331 #ifdef REDUCE_APPICONS
1332 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1333 (wapp
->main_window_desc
->wm_class
== NULL
))
1336 scr
= wapp
->main_window_desc
->screen_ptr
;
1338 wlist
= scr
->focused_window
;
1342 if (wlist
->main_window
== wapp
->main_window
)
1343 wapp
->last_focused
= wlist
;
1345 wapp
->last_focused
= NULL
;
1347 #ifdef REDUCE_APPICONS
1348 matchwmhints
= matchworkspace
= 0;
1350 tapp
= wApplicationOf(wlist
->main_window
);
1351 tinstance
= tclass
= NULL
;
1353 if (tapp
->main_window_desc
) {
1354 tinstance
= tapp
->main_window_desc
->wm_instance
;
1355 tclass
= tapp
->main_window_desc
->wm_class
;
1358 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1359 /* Should never reach here */
1363 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1364 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1368 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1371 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1377 if (wlist
->main_window
== wapp
->main_window
) {
1379 if (wlist
->flags
.focused
) {
1383 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1384 wapp
->app_icon
->y_pos
, wlist
,
1385 !wapp
->flags
.skip_next_animation
);
1387 wlist
= wlist
->prev
;
1390 wapp
->flags
.skip_next_animation
= 0;
1393 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1394 wlist
= scr
->focused_window
;
1396 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1397 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1399 wlist
= wlist
->prev
;
1401 wSetFocusTo(scr
, wlist
);
1403 wSetFocusTo(scr
, NULL
);
1407 wapp
->flags
.hidden
= 1;
1409 if(wPreferences
.auto_arrange_icons
) {
1410 wArrangeIcons(scr
, True
);
1414 wAppIconPaint(wapp
->app_icon
);
1422 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1423 int bringToCurrentWS
)
1425 if (bringToCurrentWS
)
1426 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1428 wwin
->flags
.hidden
=0;
1429 wwin
->flags
.mapped
=1;
1432 wSoundPlay(WMSOUND_UNHIDE
);
1435 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1437 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1438 icon
->core
->width
, icon
->core
->height
,
1439 wwin
->frame_x
, wwin
->frame_y
,
1440 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1444 wwin
->flags
.skip_next_animation
= 0;
1445 XMapWindow(dpy
, wwin
->client_win
);
1446 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1447 wClientSetState(wwin
, NormalState
, None
);
1448 wRaiseFrame(wwin
->frame
->core
);
1449 if (wwin
->flags
.inspector_open
) {
1450 WWindow
*pwin
= wwin
->inspector
->frame
;
1452 pwin
->flags
.hidden
= 0;
1453 pwin
->flags
.mapped
= 1;
1454 XMapWindow(dpy
, pwin
->client_win
);
1455 XMapWindow(dpy
, pwin
->frame
->core
->window
);
1456 wClientSetState(pwin
, NormalState
, None
);
1460 wGNOMEUpdateClientStateHint(wwin
, False
);
1463 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1469 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1472 WWindow
*wlist
, *next
;
1473 WWindow
*focused
=NULL
;
1474 #ifdef REDUCE_APPICONS
1475 char *tinstance
, *tclass
;
1476 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1483 #ifdef REDUCE_APPICONS
1484 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1485 (wapp
->main_window_desc
->wm_instance
== NULL
))
1489 scr
= wapp
->main_window_desc
->screen_ptr
;
1490 wlist
= scr
->focused_window
;
1492 /* goto beginning of list */
1494 wlist
= wlist
->prev
;
1499 #ifndef REDUCE_APPICONS
1500 if (wlist
->main_window
== wapp
->main_window
) {
1502 matchwmhints
= matchworkspace
= 0;
1504 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1506 if ((tclass
= wlist
->wm_class
) == NULL
)
1508 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1509 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1513 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1517 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1520 if (wlist
->flags
.focused
)
1522 else if (!focused
|| !focused
->flags
.focused
)
1525 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1526 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1527 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1528 if (!wlist
->icon
->mapped
) {
1529 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1530 wlist
->icon
->mapped
= 1;
1532 wlist
->flags
.hidden
= 0;
1534 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1536 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1537 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1540 wDeiconifyWindow(wlist
);
1542 } else if (wlist
->flags
.hidden
) {
1543 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1544 wapp
->app_icon
->y_pos
, wlist
,
1545 !wapp
->flags
.skip_next_animation
,
1548 if (bringToCurrentWS
1549 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1550 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1552 wRaiseFrame(wlist
->frame
->core
);
1558 wapp
->flags
.skip_next_animation
= 0;
1559 wapp
->flags
.hidden
= 0;
1562 wSetFocusTo(scr
, focused
);
1563 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1564 wSetFocusTo(scr
, wapp
->last_focused
);
1565 wapp
->last_focused
= NULL
;
1566 if (wPreferences
.auto_arrange_icons
) {
1567 wArrangeIcons(scr
, True
);
1570 wAppIconPaint(wapp
->app_icon
);
1577 wShowAllWindows(WScreen
*scr
)
1579 WWindow
*wwin
, *old_foc
;
1582 old_foc
= wwin
= scr
->focused_window
;
1584 if (!wwin
->flags
.internal_window
&&
1585 (scr
->current_workspace
== wwin
->frame
->workspace
1586 || IS_OMNIPRESENT(wwin
))) {
1587 if (wwin
->flags
.miniaturized
) {
1588 wwin
->flags
.skip_next_animation
= 1;
1589 wDeiconifyWindow(wwin
);
1590 } else if (wwin
->flags
.hidden
) {
1591 wapp
= wApplicationOf(wwin
->main_window
);
1593 wUnhideApplication(wapp
, False
, False
);
1595 wwin
->flags
.skip_next_animation
= 1;
1596 wDeiconifyWindow(wwin
);
1602 wSetFocusTo(scr
, old_foc
);
1603 /*wRaiseFrame(old_foc->frame->core);*/
1608 wRefreshDesktop(WScreen
*scr
)
1611 XSetWindowAttributes attr
;
1613 attr
.backing_store
= NotUseful
;
1614 attr
.save_under
= False
;
1615 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1616 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1617 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1619 XMapRaised(dpy
, win
);
1620 XDestroyWindow(dpy
, win
);
1626 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1630 int pf
; /* primary axis */
1631 int sf
; /* secondary axis */
1635 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1639 int isize
= wPreferences
.icon_size
;
1642 * Find out screen boundaries.
1646 sx2
= scr
->scr_width
;
1647 sy2
= scr
->scr_height
;
1649 if (scr
->dock
->on_right_side
)
1650 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1652 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1655 sw
= isize
* (scr
->scr_width
/isize
);
1656 sh
= isize
* (scr
->scr_height
/isize
);
1657 fullW
= (sx2
-sx1
)/isize
;
1658 fullH
= (sy2
-sy1
)/isize
;
1660 /* icon yard boundaries */
1661 if (wPreferences
.icon_yard
& IY_VERT
) {
1668 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1675 if (wPreferences
.icon_yard
& IY_TOP
) {
1683 /* arrange icons putting the most recently focused window
1684 * as the last icon */
1685 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1686 : xo + xs*(pi*isize))
1687 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1688 : yo + ys*(si*isize))
1690 /* arrange application icons */
1691 aicon
= scr
->app_icon_list
;
1692 /* reverse them to avoid unnecessarily sliding of icons */
1693 while (aicon
&& aicon
->next
)
1694 aicon
= aicon
->next
;
1699 if (!aicon
->docked
) {
1700 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1702 if (!wPreferences
.no_animations
) {
1703 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1706 #endif /* ANIMATIONS */
1708 wAppIconMove(aicon
, X
, Y
);
1711 /* we reversed the order so we use prev */
1712 aicon
= aicon
->prev
;
1719 /* arrange miniwindows */
1721 wwin
= scr
->focused_window
;
1722 /* reverse them to avoid unnecessarily shuffling */
1723 while (wwin
&& wwin
->prev
)
1727 if (wwin
->icon
&& wwin
->flags
.miniaturized
&&/*!wwin->flags.hidden &&*/
1728 (wwin
->frame
->workspace
==scr
->current_workspace
||
1729 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1731 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1732 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1734 if (wPreferences
.no_animations
) {
1735 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1737 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1738 wwin
->icon_y
, X
, Y
);
1741 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1742 #endif /* ANIMATIONS */
1750 wwin
->flags
.icon_moved
= 0;
1752 /* we reversed the order, so we use next */
1763 wSelectWindow(WWindow
*wwin
, Bool flag
)
1765 WScreen
*scr
= wwin
->screen_ptr
;
1767 wwin
->flags
.selected
= 1;
1768 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1769 scr
->selected_windows
= list_cons(wwin
, scr
->selected_windows
);
1771 wwin
->flags
.selected
= 0;
1772 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1773 scr
->frame_border_pixel
);
1774 scr
->selected_windows
= list_remove_elem(scr
->selected_windows
, wwin
);
1780 wMakeWindowVisible(WWindow
*wwin
)
1782 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1784 if (wwin
->flags
.shaded
) {
1785 wUnshadeWindow(wwin
);
1787 if (wwin
->flags
.hidden
) {
1790 app
= wApplicationOf(wwin
->main_window
);
1792 wUnhideApplication(app
, False
, False
);
1793 } else if (wwin
->flags
.miniaturized
) {
1794 wDeiconifyWindow(wwin
);
1796 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1797 wRaiseFrame(wwin
->frame
->core
);