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(WSOUND_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(WSOUND_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
;
432 if (WFLAGP(wwin
, no_resizable
))
437 totalArea
.x2
= wwin
->screen_ptr
->scr_width
;
438 totalArea
.y2
= wwin
->screen_ptr
->scr_height
;
441 if (wwin
->screen_ptr
->xine_count
> 0
442 && !(directions
& MAX_IGNORE_XINERAMA
)) {
443 WScreen
*scr
= wwin
->screen_ptr
;
446 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
447 totalArea
.x1
= rect
.pos
.x
;
448 totalArea
.y1
= rect
.pos
.y
;
449 totalArea
.x2
= totalArea
.x1
+ rect
.size
.width
;
450 totalArea
.y2
= totalArea
.y1
+ rect
.size
.height
;
452 usableArea
.x1
= WMAX(totalArea
.x1
, usableArea
.x1
);
453 usableArea
.y1
= WMAX(totalArea
.y1
, usableArea
.y1
);
454 usableArea
.x2
= WMIN(totalArea
.x2
, usableArea
.x2
);
455 usableArea
.y2
= WMIN(totalArea
.y2
, usableArea
.y2
);
457 #endif /* XINERAMA */
459 if (WFLAGP(wwin
, full_maximize
)) {
460 usableArea
= totalArea
;
463 if (wwin
->flags
.shaded
) {
464 wwin
->flags
.skip_next_animation
= 1;
465 wUnshadeWindow(wwin
);
467 wwin
->flags
.maximized
= directions
;
468 wwin
->old_geometry
.width
= wwin
->client
.width
;
469 wwin
->old_geometry
.height
= wwin
->client
.height
;
470 wwin
->old_geometry
.x
= wwin
->frame_x
;
471 wwin
->old_geometry
.y
= wwin
->frame_y
;
474 wKWMUpdateClientGeometryRestore(wwin
);
477 if (directions
& MAX_HORIZONTAL
) {
479 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
480 new_x
= usableArea
.x1
;
484 new_x
= wwin
->frame_x
;
485 new_width
= wwin
->frame
->core
->width
;
489 if (directions
& MAX_VERTICAL
) {
491 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
492 new_y
= usableArea
.y1
;
493 if (WFLAGP(wwin
, full_maximize
)) {
494 new_y
-= wwin
->frame
->top_width
;
495 new_height
+= wwin
->frame
->bottom_width
- 1;
498 new_y
= wwin
->frame_y
;
499 new_height
= wwin
->frame
->core
->height
;
502 if (!WFLAGP(wwin
, full_maximize
)) {
503 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
506 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
507 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
510 wGNOMEUpdateClientStateHint(wwin
, False
);
513 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
514 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
518 wSoundPlay(WSOUND_MAXIMIZE
);
524 wUnmaximizeWindow(WWindow
*wwin
)
526 int restore_x
, restore_y
;
528 if (!wwin
->flags
.maximized
)
531 if (wwin
->flags
.shaded
) {
532 wwin
->flags
.skip_next_animation
= 1;
533 wUnshadeWindow(wwin
);
535 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
536 wwin
->old_geometry
.x
: wwin
->frame_x
;
537 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
538 wwin
->old_geometry
.y
: wwin
->frame_y
;
539 wwin
->flags
.maximized
= 0;
540 wWindowConfigure(wwin
, restore_x
, restore_y
,
541 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
544 wGNOMEUpdateClientStateHint(wwin
, False
);
547 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
548 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
552 wSoundPlay(WSOUND_UNMAXIMIZE
);
558 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
559 int fx
, int fy
, int fw
, int fh
, int steps
)
561 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
562 float cx
, cy
, cw
, ch
;
563 float xstep
, ystep
, wstep
, hstep
;
566 float angle
, final_angle
, delta
;
568 xstep
= (float)(fx
-x
)/steps
;
569 ystep
= (float)(fy
-y
)/steps
;
570 wstep
= (float)(fw
-w
)/steps
;
571 hstep
= (float)(fh
-h
)/steps
;
578 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
579 delta
= (float)(final_angle
/FRAMES
);
580 for (angle
=0;; angle
+=delta
) {
581 if (angle
> final_angle
)
584 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
585 dch
= (ch
/2) * cos(angle
);
588 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
589 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
590 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
591 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
592 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
595 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
597 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
598 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
601 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
607 if (angle
>= final_angle
)
617 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
618 int fx
, int fy
, int fw
, int fh
, int steps
)
620 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
621 float cx
, cy
, cw
, ch
;
622 float xstep
, ystep
, wstep
, hstep
;
624 float angle
, final_angle
, a
, d
, delta
;
631 xstep
= (float)(fx
-x
)/steps
;
632 ystep
= (float)(fy
-y
)/steps
;
633 wstep
= (float)(fw
-w
)/steps
;
634 hstep
= (float)(fh
-h
)/steps
;
641 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
642 delta
= (float)(final_angle
/FRAMES
);
643 for (angle
=0;; angle
+=delta
) {
644 if (angle
> final_angle
)
648 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
650 points
[0].x
= cx
+cos(angle
-a
)*d
;
651 points
[0].y
= cy
+sin(angle
-a
)*d
;
652 points
[1].x
= cx
+cos(angle
+a
)*d
;
653 points
[1].y
= cy
+sin(angle
+a
)*d
;
654 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
655 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
656 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
657 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
658 points
[4].x
= cx
+cos(angle
-a
)*d
;
659 points
[4].y
= cy
+sin(angle
-a
)*d
;
661 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
663 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
664 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
667 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
673 if (angle
>= final_angle
)
683 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
684 int fx
, int fy
, int fw
, int fh
, int steps
)
686 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
687 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
688 float xstep
, ystep
, wstep
, hstep
;
691 xstep
= (float)(fx
-x
)/steps
;
692 ystep
= (float)(fy
-y
)/steps
;
693 wstep
= (float)(fw
-w
)/steps
;
694 hstep
= (float)(fh
-h
)/steps
;
696 for (j
=0; j
<FRAMES
; j
++) {
703 for (i
=0; i
<steps
; i
++) {
704 for (j
=0; j
<FRAMES
; j
++) {
705 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
706 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
709 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
710 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
712 for (j
=0; j
<FRAMES
; j
++) {
713 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
714 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
729 for (j
=0; j
<FRAMES
; j
++) {
730 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
731 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
734 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
735 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
737 for (j
=0; j
<FRAMES
; j
++) {
738 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
739 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
748 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
749 int fx
, int fy
, int fw
, int fh
, int hiding
)
751 int style
= wPreferences
.iconification_style
; /* Catch the value */
754 if (style
== WIS_NONE
)
757 if (style
== WIS_RANDOM
) {
761 k
= (hiding
? 2 : 3);
764 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
766 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
769 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
771 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
775 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
777 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
781 #endif /* ANIMATIONS */
789 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
790 WMHandleEvent(&tmpev
);
795 unmapTransientsFor(WWindow
*wwin
)
800 tmp
= wwin
->screen_ptr
->focused_window
;
802 /* unmap the transients for this transient */
803 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
804 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
805 || tmp
->flags
.shaded
)) {
806 unmapTransientsFor(tmp
);
807 tmp
->flags
.miniaturized
= 1;
808 if (!tmp
->flags
.shaded
) {
811 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
814 if (!tmp->flags.shaded)
816 wClientSetState(tmp
, IconicState
, None
);
818 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
819 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
820 tmp
->flags
.kwm_hidden_for_modules
= 1;
823 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
832 mapTransientsFor(WWindow
*wwin
)
836 tmp
= wwin
->screen_ptr
->focused_window
;
838 /* recursively map the transients for this transient */
839 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
840 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
841 && tmp
->icon
==NULL
) {
842 mapTransientsFor(tmp
);
843 tmp
->flags
.miniaturized
= 0;
844 if (!tmp
->flags
.shaded
) {
847 XMapWindow(dpy
, tmp
->frame
->core
->window
);
849 tmp
->flags
.semi_focused
= 0;
851 if (!tmp->flags.shaded)
853 wClientSetState(tmp
, NormalState
, None
);
855 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
856 if (tmp
->flags
.kwm_hidden_for_modules
) {
857 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
858 tmp
->flags
.kwm_hidden_for_modules
= 0;
862 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
871 setupIconGrabs(WIcon
*icon
)
873 /* setup passive grabs on the icon */
874 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
875 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
876 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
877 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
878 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
879 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
885 recursiveTransientFor(WWindow
*wwin
)
892 /* hackish way to detect transient_for cycle */
893 i
= wwin
->screen_ptr
->window_count
+1;
895 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
896 wwin
= wWindowFor(wwin
->transient_for
);
900 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
910 removeIconGrabs(WIcon
*icon
)
912 /* remove passive grabs on the icon */
913 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
914 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
915 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
922 wIconifyWindow(WWindow
*wwin
)
924 XWindowAttributes attribs
;
928 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
929 /* the window doesn't exist anymore */
933 if (wwin
->flags
.miniaturized
) {
938 if (wwin
->transient_for
!=None
) {
939 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
941 if (owner
&& owner
->flags
.miniaturized
)
945 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
947 /* if the window is in another workspace, simplify process */
949 /* icon creation may take a while */
950 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
951 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
952 GrabModeAsync
, None
, None
, CurrentTime
);
955 if (!wPreferences
.disable_miniwindows
) {
956 if (!wwin
->flags
.icon_moved
) {
957 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
959 wwin
->icon
= wIconCreate(wwin
);
961 wwin
->icon
->mapped
= 1;
964 wwin
->flags
.miniaturized
= 1;
965 wwin
->flags
.mapped
= 0;
967 /* unmap transients */
969 unmapTransientsFor(wwin
);
973 wSoundPlay(WSOUND_ICONIFY
);
976 XUngrabPointer(dpy
, CurrentTime
);
978 /* let all Expose events arrive so that we can repaint
979 * something before the animation starts (and the server is grabbed) */
982 if (wPreferences
.disable_miniwindows
)
983 wClientSetState(wwin
, IconicState
, None
);
985 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
989 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
990 && !wPreferences
.no_animations
) {
993 if (!wPreferences
.disable_miniwindows
) {
996 iw
= wwin
->icon
->core
->width
;
997 ih
= wwin
->icon
->core
->height
;
1002 if (wKWMGetIconGeometry(wwin
, &area
)) {
1008 #endif /* KWM_HINTS */
1012 iw
= wwin
->screen_ptr
->scr_width
;
1013 ih
= wwin
->screen_ptr
->scr_height
;
1016 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1017 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1018 ix
, iy
, iw
, ih
, False
);
1023 wwin
->flags
.skip_next_animation
= 0;
1025 if (!wPreferences
.disable_miniwindows
) {
1027 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1028 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1030 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1032 AddToStackList(wwin
->icon
->core
);
1034 wLowerFrame(wwin
->icon
->core
);
1038 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1041 * It doesn't seem to be working and causes button event hangup
1042 * when deiconifying a transient window.
1043 setupIconGrabs(wwin->icon);
1045 if ((wwin
->flags
.focused
1046 || (owner
&& wwin
->client_win
== owner
->client_win
))
1047 && wPreferences
.focus_mode
==WKF_CLICK
) {
1052 if (!WFLAGP(tmp
, no_focusable
)
1053 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1054 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1058 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1059 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1060 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1064 if (!wwin
->screen_ptr
->flags
.startup
) {
1065 Window clientwin
= wwin
->client_win
;
1068 processEvents(XPending(dpy
));
1070 /* the window can disappear while doing the processEvents() */
1071 if (!wWindowFor(clientwin
))
1078 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1079 wIconSelect(wwin
->icon
);
1082 wGNOMEUpdateClientStateHint(wwin
, False
);
1085 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1086 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1089 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1096 wDeiconifyWindow(WWindow
*wwin
)
1098 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1100 if (!wwin
->flags
.miniaturized
)
1103 if (wwin
->transient_for
!= None
1104 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1105 WWindow
*owner
= recursiveTransientFor(wwin
);
1107 if (owner
&& owner
->flags
.miniaturized
) {
1108 wDeiconifyWindow(owner
);
1109 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1110 wRaiseFrame(wwin
->frame
->core
);
1115 wwin
->flags
.miniaturized
= 0;
1116 if (!wwin
->flags
.shaded
)
1117 wwin
->flags
.mapped
= 1;
1119 if (!wPreferences
.disable_miniwindows
) {
1120 if (wwin
->icon
->selected
)
1121 wIconSelect(wwin
->icon
);
1123 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1127 wSoundPlay(WSOUND_DEICONIFY
);
1130 /* if the window is in another workspace, do it silently */
1132 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1133 && !wwin
->flags
.skip_next_animation
) {
1136 if (!wPreferences
.disable_miniwindows
) {
1139 iw
= wwin
->icon
->core
->width
;
1140 ih
= wwin
->icon
->core
->height
;
1145 if (wKWMGetIconGeometry(wwin
, &area
)) {
1151 #endif /* KWM_HINTS */
1155 iw
= wwin
->screen_ptr
->scr_width
;
1156 ih
= wwin
->screen_ptr
->scr_height
;
1159 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1160 wwin
->frame_x
, wwin
->frame_y
,
1161 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1164 #endif /* ANIMATIONS */
1165 wwin
->flags
.skip_next_animation
= 0;
1167 if (!wwin
->flags
.shaded
) {
1168 XMapWindow(dpy
, wwin
->client_win
);
1170 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1171 wRaiseFrame(wwin
->frame
->core
);
1172 if (!wwin
->flags
.shaded
) {
1173 wClientSetState(wwin
, NormalState
, None
);
1175 mapTransientsFor(wwin
);
1177 if (!wPreferences
.disable_miniwindows
) {
1178 RemoveFromStackList(wwin
->icon
->core
);
1179 /* removeIconGrabs(wwin->icon);*/
1180 wIconDestroy(wwin
->icon
);
1185 if (wPreferences
.focus_mode
==WKF_CLICK
)
1186 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1189 if (!wwin
->screen_ptr
->flags
.startup
) {
1190 Window clientwin
= wwin
->client_win
;
1193 processEvents(XPending(dpy
));
1195 if (!wWindowFor(clientwin
))
1200 if (wPreferences
.auto_arrange_icons
) {
1201 wArrangeIcons(wwin
->screen_ptr
, True
);
1205 wGNOMEUpdateClientStateHint(wwin
, False
);
1208 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1209 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1212 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1218 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1220 if (wwin
->flags
.miniaturized
) {
1222 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1223 wwin
->icon
->mapped
= 0;
1225 wwin
->flags
.hidden
= 1;
1227 wGNOMEUpdateClientStateHint(wwin
, False
);
1230 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1235 if (wwin
->flags
.inspector_open
) {
1236 wHideInspectorForWindow(wwin
);
1239 wwin
->flags
.hidden
= 1;
1242 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1245 wSoundPlay(WSOUND_HIDE
);
1248 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1249 !wwin
->flags
.skip_next_animation
&& animate
) {
1250 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1251 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1252 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1256 wwin
->flags
.skip_next_animation
= 0;
1259 wGNOMEUpdateClientStateHint(wwin
, False
);
1262 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1268 wHideOtherApplications(WWindow
*awin
)
1272 #ifdef REDUCE_APPICONS
1273 char *tinstance
, *tclass
;
1274 unsigned int brokenwin
= 0, match
= 0;
1279 wwin
= awin
->screen_ptr
->focused_window
;
1281 #ifdef REDUCE_APPICONS
1282 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1288 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1289 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1290 && !wwin
->flags
.internal_window
1291 && wGetWindowOfInspectorForWindow(wwin
) != awin
1292 && !WFLAGP(wwin
, no_hide_others
)) {
1294 #ifdef REDUCE_APPICONS
1297 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1299 if ((tclass
= wwin
->wm_class
) == NULL
)
1301 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1302 (strcmp(awin
->wm_class
, tclass
) == 0) )
1307 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1308 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1309 wwin
->flags
.skip_next_animation
= 1;
1310 wIconifyWindow(wwin
);
1312 } else if (wwin
->main_window
!=None
1313 #ifndef REDUCE_APPICONS
1314 && awin
->main_window
!= wwin
->main_window
) {
1316 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1318 tapp
= wApplicationOf(wwin
->main_window
);
1320 tapp
->flags
.skip_next_animation
= 1;
1321 wHideApplication(tapp
);
1323 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1324 wwin
->flags
.skip_next_animation
= 1;
1325 wIconifyWindow(wwin
);
1333 wSetFocusTo(awin->screen_ptr, awin);
1340 wHideApplication(WApplication
*wapp
)
1342 #ifdef REDUCE_APPICONS
1344 char *tinstance
, *tclass
;
1345 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1352 wwarning("trying to hide a non grouped window");
1355 if (!wapp
->main_window_desc
) {
1356 wwarning("group leader not found for window group");
1359 #ifdef REDUCE_APPICONS
1360 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1361 (wapp
->main_window_desc
->wm_class
== NULL
))
1364 scr
= wapp
->main_window_desc
->screen_ptr
;
1366 wlist
= scr
->focused_window
;
1370 if (wlist
->main_window
== wapp
->main_window
)
1371 wapp
->last_focused
= wlist
;
1373 wapp
->last_focused
= NULL
;
1375 #ifdef REDUCE_APPICONS
1376 matchwmhints
= matchworkspace
= 0;
1378 tapp
= wApplicationOf(wlist
->main_window
);
1379 tinstance
= tclass
= NULL
;
1381 if (tapp
->main_window_desc
) {
1382 tinstance
= tapp
->main_window_desc
->wm_instance
;
1383 tclass
= tapp
->main_window_desc
->wm_class
;
1386 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1387 /* Should never reach here */
1391 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1392 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1396 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1399 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1405 if (wlist
->main_window
== wapp
->main_window
) {
1407 if (wlist
->flags
.focused
) {
1411 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1412 wapp
->app_icon
->y_pos
, wlist
,
1413 !wapp
->flags
.skip_next_animation
);
1415 wlist
= wlist
->prev
;
1418 wapp
->flags
.skip_next_animation
= 0;
1421 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1422 wlist
= scr
->focused_window
;
1424 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1425 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1427 wlist
= wlist
->prev
;
1429 wSetFocusTo(scr
, wlist
);
1431 wSetFocusTo(scr
, NULL
);
1435 wapp
->flags
.hidden
= 1;
1437 if(wPreferences
.auto_arrange_icons
) {
1438 wArrangeIcons(scr
, True
);
1442 wAppIconPaint(wapp
->app_icon
);
1450 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1451 int bringToCurrentWS
)
1453 if (bringToCurrentWS
)
1454 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1456 wwin
->flags
.hidden
=0;
1457 wwin
->flags
.mapped
=1;
1460 wSoundPlay(WSOUND_UNHIDE
);
1463 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1465 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1466 icon
->core
->width
, icon
->core
->height
,
1467 wwin
->frame_x
, wwin
->frame_y
,
1468 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1472 wwin
->flags
.skip_next_animation
= 0;
1473 XMapWindow(dpy
, wwin
->client_win
);
1474 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1475 wClientSetState(wwin
, NormalState
, None
);
1476 wRaiseFrame(wwin
->frame
->core
);
1477 if (wwin
->flags
.inspector_open
) {
1478 wUnhideInspectorForWindow(wwin
);
1482 wGNOMEUpdateClientStateHint(wwin
, False
);
1485 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1491 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1494 WWindow
*wlist
, *next
;
1495 WWindow
*focused
=NULL
;
1496 #ifdef REDUCE_APPICONS
1497 char *tinstance
, *tclass
;
1498 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1505 #ifdef REDUCE_APPICONS
1506 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1507 (wapp
->main_window_desc
->wm_instance
== NULL
))
1511 scr
= wapp
->main_window_desc
->screen_ptr
;
1512 wlist
= scr
->focused_window
;
1514 /* goto beginning of list */
1516 wlist
= wlist
->prev
;
1521 #ifndef REDUCE_APPICONS
1522 if (wlist
->main_window
== wapp
->main_window
) {
1524 matchwmhints
= matchworkspace
= 0;
1526 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1528 if ((tclass
= wlist
->wm_class
) == NULL
)
1530 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1531 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1535 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1539 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1542 if (wlist
->flags
.focused
)
1544 else if (!focused
|| !focused
->flags
.focused
)
1547 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1548 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1549 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1550 if (!wlist
->icon
->mapped
) {
1551 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1552 wlist
->icon
->mapped
= 1;
1554 wlist
->flags
.hidden
= 0;
1556 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1558 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1559 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1562 wDeiconifyWindow(wlist
);
1564 } else if (wlist
->flags
.hidden
) {
1565 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1566 wapp
->app_icon
->y_pos
, wlist
,
1567 !wapp
->flags
.skip_next_animation
,
1570 if (bringToCurrentWS
1571 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1572 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1574 wRaiseFrame(wlist
->frame
->core
);
1580 wapp
->flags
.skip_next_animation
= 0;
1581 wapp
->flags
.hidden
= 0;
1584 wSetFocusTo(scr
, focused
);
1585 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1586 wSetFocusTo(scr
, wapp
->last_focused
);
1587 wapp
->last_focused
= NULL
;
1588 if (wPreferences
.auto_arrange_icons
) {
1589 wArrangeIcons(scr
, True
);
1592 wAppIconPaint(wapp
->app_icon
);
1599 wShowAllWindows(WScreen
*scr
)
1601 WWindow
*wwin
, *old_foc
;
1604 old_foc
= wwin
= scr
->focused_window
;
1606 if (!wwin
->flags
.internal_window
&&
1607 (scr
->current_workspace
== wwin
->frame
->workspace
1608 || IS_OMNIPRESENT(wwin
))) {
1609 if (wwin
->flags
.miniaturized
) {
1610 wwin
->flags
.skip_next_animation
= 1;
1611 wDeiconifyWindow(wwin
);
1612 } else if (wwin
->flags
.hidden
) {
1613 wapp
= wApplicationOf(wwin
->main_window
);
1615 wUnhideApplication(wapp
, False
, False
);
1617 wwin
->flags
.skip_next_animation
= 1;
1618 wDeiconifyWindow(wwin
);
1624 wSetFocusTo(scr
, old_foc
);
1625 /*wRaiseFrame(old_foc->frame->core);*/
1630 wRefreshDesktop(WScreen
*scr
)
1633 XSetWindowAttributes attr
;
1635 attr
.backing_store
= NotUseful
;
1636 attr
.save_under
= False
;
1637 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1638 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1639 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1641 XMapRaised(dpy
, win
);
1642 XDestroyWindow(dpy
, win
);
1648 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1652 int pf
; /* primary axis */
1653 int sf
; /* secondary axis */
1657 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1661 int isize
= wPreferences
.icon_size
;
1664 * Find out screen boundaries.
1668 sx2
= scr
->scr_width
;
1669 sy2
= scr
->scr_height
;
1671 if (scr
->dock
->on_right_side
)
1672 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1674 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1677 sw
= isize
* (scr
->scr_width
/isize
);
1678 sh
= isize
* (scr
->scr_height
/isize
);
1679 fullW
= (sx2
-sx1
)/isize
;
1680 fullH
= (sy2
-sy1
)/isize
;
1682 /* icon yard boundaries */
1683 if (wPreferences
.icon_yard
& IY_VERT
) {
1690 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1697 if (wPreferences
.icon_yard
& IY_TOP
) {
1705 /* arrange icons putting the most recently focused window
1706 * as the last icon */
1707 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1708 : xo + xs*(pi*isize))
1709 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1710 : yo + ys*(si*isize))
1712 /* arrange application icons */
1713 aicon
= scr
->app_icon_list
;
1714 /* reverse them to avoid unnecessarily sliding of icons */
1715 while (aicon
&& aicon
->next
)
1716 aicon
= aicon
->next
;
1721 if (!aicon
->docked
) {
1722 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1724 if (!wPreferences
.no_animations
) {
1725 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1728 #endif /* ANIMATIONS */
1730 wAppIconMove(aicon
, X
, Y
);
1733 /* we reversed the order so we use prev */
1734 aicon
= aicon
->prev
;
1741 /* arrange miniwindows */
1743 wwin
= scr
->focused_window
;
1744 /* reverse them to avoid unnecessarily shuffling */
1745 while (wwin
&& wwin
->prev
)
1749 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1750 (wwin
->frame
->workspace
==scr
->current_workspace
||
1751 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1753 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1754 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1756 if (wPreferences
.no_animations
) {
1757 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1759 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1760 wwin
->icon_y
, X
, Y
);
1763 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1764 #endif /* ANIMATIONS */
1772 wwin
->flags
.icon_moved
= 0;
1774 /* we reversed the order, so we use next */
1785 wSelectWindow(WWindow
*wwin
, Bool flag
)
1787 WScreen
*scr
= wwin
->screen_ptr
;
1790 wwin
->flags
.selected
= 1;
1791 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1793 if (WFLAGP(wwin
, no_border
)) {
1794 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1795 FRAME_BORDER_WIDTH
);
1798 if (!scr
->selected_windows
)
1799 scr
->selected_windows
= WMCreateBag(4);
1800 WMPutInBag(scr
->selected_windows
, wwin
);
1802 wwin
->flags
.selected
= 0;
1803 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1804 scr
->frame_border_pixel
);
1806 if (WFLAGP(wwin
, no_border
)) {
1807 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1810 if (scr
->selected_windows
) {
1811 WMRemoveFromBag(scr
->selected_windows
, wwin
);
1818 wMakeWindowVisible(WWindow
*wwin
)
1820 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1821 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1823 if (wwin
->flags
.shaded
) {
1824 wUnshadeWindow(wwin
);
1826 if (wwin
->flags
.hidden
) {
1829 app
= wApplicationOf(wwin
->main_window
);
1831 wUnhideApplication(app
, False
, False
);
1832 } else if (wwin
->flags
.miniaturized
) {
1833 wDeiconifyWindow(wwin
);
1835 if (!WFLAGP(wwin
, no_focusable
))
1836 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1837 wRaiseFrame(wwin
->frame
->core
);