1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
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"
54 /****** Global Variables ******/
55 extern Time LastTimestamp
;
56 extern Time LastFocusChange
;
58 extern Cursor wCursor
[WCUR_LAST
];
60 extern WPreferences wPreferences
;
62 extern Atom _XA_WM_TAKE_FOCUS
;
64 extern void ProcessPendingEvents();
67 /******* Local Variables *******/
72 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
73 {SHADE_STEPS_F
, SHADE_DELAY_F
},
74 {SHADE_STEPS_M
, SHADE_DELAY_M
},
75 {SHADE_STEPS_S
, SHADE_DELAY_S
},
76 {SHADE_STEPS_US
, SHADE_DELAY_US
}};
78 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
79 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
83 *----------------------------------------------------------------------
85 * Changes the window focus to the one passed as argument.
86 * If the window to focus is not already focused, it will be brought
87 * to the head of the list of windows. Previously focused window is
91 * Window list may be reordered and the window focus is changed.
93 *----------------------------------------------------------------------
96 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
98 static WScreen
*old_scr
=NULL
;
100 WWindow
*old_focused
;
101 WWindow
*focused
=scr
->focused_window
;
102 int timestamp
=LastTimestamp
;
103 WApplication
*oapp
=NULL
, *napp
=NULL
;
106 if (scr
->flags
.ignore_focus_events
|| LastFocusChange
> timestamp
)
111 old_focused
=old_scr
->focused_window
;
113 LastFocusChange
= timestamp
;
116 oapp
= wApplicationOf(old_focused
->main_window
);
119 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
121 wWindowUnfocus(old_focused
);
124 wAppMenuUnmap(oapp
->menu
);
126 wApplicationDeactivate(oapp
);
130 WMPostNotificationName(WMNChangedFocus
, NULL
, (void*)True
);
132 } else if (old_scr
!= scr
&& old_focused
) {
133 wWindowUnfocus(old_focused
);
136 wasfocused
= wwin
->flags
.focused
;
137 napp
= wApplicationOf(wwin
->main_window
);
139 /* remember last workspace where the app has been */
141 /*napp->last_workspace = wwin->screen_ptr->current_workspace;*/
142 napp
->last_workspace
= wwin
->frame
->workspace
;
145 if (wwin
->flags
.mapped
&& !WFLAGP(wwin
, no_focusable
)) {
146 /* install colormap if colormap mode is lock mode */
147 if (wPreferences
.colormap_mode
==WCM_CLICK
)
148 wColormapInstallForWindow(scr
, wwin
);
150 /* set input focus */
151 switch (wwin
->focus_mode
) {
153 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
157 case WFM_LOCALLY_ACTIVE
:
158 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, CurrentTime
);
161 case WFM_GLOBALLY_ACTIVE
:
165 if (wwin
->protocols
.TAKE_FOCUS
) {
166 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
170 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
172 if (WFLAGP(wwin
, no_focusable
))
175 /* if this is not the focused window focus it */
177 /* change the focus window list order */
179 wwin
->prev
->next
= wwin
->next
;
182 wwin
->next
->prev
= wwin
->prev
;
184 wwin
->prev
= focused
;
185 focused
->next
= wwin
;
187 scr
->focused_window
= wwin
;
189 if (oapp
&& oapp
!= napp
) {
190 wAppMenuUnmap(oapp
->menu
);
192 wApplicationDeactivate(oapp
);
197 wWindowFocus(wwin
, focused
);
199 if (napp
&& !wasfocused
) {
201 wUserMenuRefreshInstances(napp
->menu
, wwin
);
202 #endif /* USER_MENU */
204 if (wwin
->flags
.mapped
)
205 wAppMenuMap(napp
->menu
, wwin
);
207 wApplicationActivate(napp
);
217 wShadeWindow(WWindow
*wwin
)
224 if (wwin
->flags
.shaded
)
229 XLowerWindow(dpy
, wwin
->client_win
);
231 wSoundPlay(WSOUND_SHADE
);
234 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
235 && !wPreferences
.no_animations
) {
236 /* do the shading animation */
237 h
= wwin
->frame
->core
->height
;
240 w
= wwin
->frame
->core
->width
;
241 y
= wwin
->frame
->top_width
;
242 while (h
>wwin
->frame
->top_width
+1) {
243 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
244 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
247 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
250 if (SHADE_DELAY
> 0) {
251 wusleep(SHADE_DELAY
*1000L);
258 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
260 #endif /* ANIMATIONS */
262 wwin
->flags
.skip_next_animation
= 0;
263 wwin
->flags
.shaded
= 1;
264 wwin
->flags
.mapped
= 0;
265 /* prevent window withdrawal when getting UnmapNotify */
266 XSelectInput(dpy
, wwin
->client_win
,
267 wwin
->event_mask
& ~StructureNotifyMask
);
268 XUnmapWindow(dpy
, wwin
->client_win
);
269 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
271 /* for the client it's just like iconification */
272 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
273 wwin
->frame
->top_width
- 1);
275 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
276 + wwin
->frame
->top_width
;
277 wWindowSynthConfigureNotify(wwin
);
280 wClientSetState(wwin, IconicState, None);
283 WMPostNotificationName(WMNChangedState
, wwin
, "shade");
286 if (!wwin
->screen_ptr
->flags
.startup
) {
287 /* Catch up with events not processed while animation was running */
288 ProcessPendingEvents();
295 wUnshadeWindow(WWindow
*wwin
)
300 #endif /* ANIMATIONS */
303 if (!wwin
->flags
.shaded
)
308 wwin
->flags
.shaded
= 0;
309 wwin
->flags
.mapped
= 1;
310 XMapWindow(dpy
, wwin
->client_win
);
312 wSoundPlay(WSOUND_UNSHADE
);
315 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
316 /* do the shading animation */
317 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
318 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
319 s
= abs(y
)/SHADE_STEPS
;
321 w
= wwin
->frame
->core
->width
;
322 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
324 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
325 + wwin
->frame
->bottom_width
) {
326 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
327 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
329 if (SHADE_DELAY
> 0) {
330 wusleep(SHADE_DELAY
*2000L/3);
337 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
341 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
343 #endif /* ANIMATIONS */
345 wwin
->flags
.skip_next_animation
= 0;
346 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
347 wwin
->frame
->top_width
+ wwin
->client
.height
348 + wwin
->frame
->bottom_width
);
350 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
351 wWindowSynthConfigureNotify(wwin
);
354 wClientSetState(wwin, NormalState, None);
356 /* if the window is focused, set the focus again as it was disabled during
358 if (wwin
->flags
.focused
)
359 wSetFocusTo(wwin
->screen_ptr
, wwin
);
361 WMPostNotificationName(WMNChangedState
, wwin
, "shade");
366 wMaximizeWindow(WWindow
*wwin
, int directions
)
368 int new_width
, new_height
, new_x
, new_y
;
369 int changed_h
, changed_v
, shrink_h
, shrink_v
;
370 WArea usableArea
, totalArea
;
372 if (!IS_RESIZABLE(wwin
))
377 totalArea
.x2
= wwin
->screen_ptr
->scr_width
;
378 totalArea
.y2
= wwin
->screen_ptr
->scr_height
;
379 usableArea
= totalArea
;
381 if (!(directions
& MAX_IGNORE_XINERAMA
)) {
382 WScreen
*scr
= wwin
->screen_ptr
;
385 if (directions
& MAX_KEYBOARD
)
386 head
= wGetHeadForWindow(wwin
);
388 head
= wGetHeadForPointerLocation(scr
);
390 usableArea
= wGetUsableAreaForHead(scr
, head
, &totalArea
, True
);
393 if (WFLAGP(wwin
, full_maximize
)) {
394 usableArea
= totalArea
;
397 if (wwin
->flags
.shaded
) {
398 wwin
->flags
.skip_next_animation
= 1;
399 wUnshadeWindow(wwin
);
401 /* Only save directions, not kbd or xinerama hints */
402 directions
&= (MAX_HORIZONTAL
|MAX_VERTICAL
);
404 changed_h
= ((wwin
->flags
.maximized
^ directions
) & MAX_HORIZONTAL
);
405 changed_v
= ((wwin
->flags
.maximized
^ directions
) & MAX_VERTICAL
);
406 shrink_h
= (changed_h
&& (directions
& MAX_HORIZONTAL
)==0);
407 shrink_v
= (changed_v
&& (directions
& MAX_VERTICAL
)==0);
409 if (wwin
->flags
.maximized
) {
410 /* if already maximized in some direction, we only update the
411 * appropriate old x, old y coordinates. This is necessary to
412 * allow succesive maximizations in different directions without
413 * the need to first do an un-maximize (to avoid flicker).
415 if (!(wwin
->flags
.maximized
& MAX_HORIZONTAL
)) {
416 wwin
->old_geometry
.x
= wwin
->frame_x
;
418 if (!(wwin
->flags
.maximized
& MAX_VERTICAL
)) {
419 wwin
->old_geometry
.y
= wwin
->frame_y
;
422 wwin
->old_geometry
.width
= wwin
->client
.width
;
423 wwin
->old_geometry
.height
= wwin
->client
.height
;
424 wwin
->old_geometry
.x
= wwin
->frame_x
;
425 wwin
->old_geometry
.y
= wwin
->frame_y
;
427 wwin
->flags
.maximized
= directions
;
429 if (directions
& MAX_HORIZONTAL
) {
430 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
431 new_x
= usableArea
.x1
;
432 } else if (shrink_h
) {
433 new_x
= wwin
->old_geometry
.x
;
434 new_width
= wwin
->old_geometry
.width
;
436 new_x
= wwin
->frame_x
;
437 new_width
= wwin
->frame
->core
->width
;
440 if (directions
& MAX_VERTICAL
) {
441 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
442 new_y
= usableArea
.y1
;
443 if (WFLAGP(wwin
, full_maximize
)) {
444 new_y
-= wwin
->frame
->top_width
;
445 new_height
+= wwin
->frame
->bottom_width
- 1;
447 } else if (shrink_v
) {
448 new_y
= wwin
->old_geometry
.y
;
449 new_height
= wwin
->old_geometry
.height
;
451 new_y
= wwin
->frame_y
;
452 new_height
= wwin
->frame
->core
->height
;
455 if (!WFLAGP(wwin
, full_maximize
)) {
456 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
459 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
461 wWindowCropSize(wwin
, usableArea
.x2
-usableArea
.x1
,
462 usableArea
.y2
-usableArea
.y1
,
463 &new_width
, &new_height
);
465 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
468 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
470 wSoundPlay(WSOUND_MAXIMIZE
);
475 wUnmaximizeWindow(WWindow
*wwin
)
479 if (!wwin
->flags
.maximized
)
482 if (wwin
->flags
.shaded
) {
483 wwin
->flags
.skip_next_animation
= 1;
484 wUnshadeWindow(wwin
);
486 x
= ((wwin
->flags
.maximized
& MAX_HORIZONTAL
) && wwin
->old_geometry
.x
) ?
487 wwin
->old_geometry
.x
: wwin
->frame_x
;
488 y
= ((wwin
->flags
.maximized
& MAX_VERTICAL
) && wwin
->old_geometry
.y
) ?
489 wwin
->old_geometry
.y
: wwin
->frame_y
;
490 w
= wwin
->old_geometry
.width
?
491 wwin
->old_geometry
.width
: wwin
->client
.width
;
492 h
= wwin
->old_geometry
.height
?
493 wwin
->old_geometry
.height
: wwin
->client
.height
;
495 wwin
->flags
.maximized
= 0;
496 wWindowConfigure(wwin
, x
, y
, w
, h
);
498 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
500 wSoundPlay(WSOUND_UNMAXIMIZE
);
505 wFullscreenWindow(WWindow
*wwin
)
510 if (wwin
->flags
.fullscreen
)
513 wwin
->flags
.fullscreen
= True
;
515 wWindowConfigureBorders(wwin
);
517 ChangeStackingLevel(wwin
->frame
->core
, WMFullscreenLevel
);
519 wwin
->bfs_geometry
.x
= wwin
->frame_x
;
520 wwin
->bfs_geometry
.y
= wwin
->frame_y
;
521 wwin
->bfs_geometry
.width
= wwin
->frame
->core
->width
;
522 wwin
->bfs_geometry
.height
= wwin
->frame
->core
->height
;
524 head
= wGetHeadForWindow(wwin
);
525 rect
= wGetRectForHead(wwin
->screen_ptr
, head
);
526 wWindowConfigure(wwin
, rect
.pos
.x
, rect
.pos
.y
,
527 rect
.size
.width
, rect
.size
.height
);
529 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
534 wUnfullscreenWindow(WWindow
*wwin
)
536 if (!wwin
->flags
.fullscreen
)
539 wwin
->flags
.fullscreen
= False
;
541 if (wwin
->frame
->core
->stacking
->window_level
== WMFullscreenLevel
) {
542 if (WFLAGP(wwin
, sunken
)) {
543 ChangeStackingLevel(wwin
->frame
->core
, WMSunkenLevel
);
544 } else if (WFLAGP(wwin
, floating
)) {
545 ChangeStackingLevel(wwin
->frame
->core
, WMFloatingLevel
);
547 ChangeStackingLevel(wwin
->frame
->core
, WMNormalLevel
);
551 wWindowConfigure(wwin
, wwin
->bfs_geometry
.x
, wwin
->bfs_geometry
.y
,
552 wwin
->bfs_geometry
.width
, wwin
->bfs_geometry
.height
);
554 wWindowConfigureBorders(wwin
);
556 // seems unnecessary, but also harmless (doesn't generate flicker) -Dan
557 wFrameWindowPaint(wwin->frame);
560 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
566 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
567 int fx
, int fy
, int fw
, int fh
, int steps
)
569 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
570 float cx
, cy
, cw
, ch
;
571 float xstep
, ystep
, wstep
, hstep
;
574 float angle
, final_angle
, delta
;
576 xstep
= (float)(fx
-x
)/steps
;
577 ystep
= (float)(fy
-y
)/steps
;
578 wstep
= (float)(fw
-w
)/steps
;
579 hstep
= (float)(fh
-h
)/steps
;
586 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
587 delta
= (float)(final_angle
/FRAMES
);
588 for (angle
=0;; angle
+=delta
) {
589 if (angle
> final_angle
)
592 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
593 dch
= (ch
/2) * cos(angle
);
596 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
597 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
598 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
599 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
600 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
603 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
605 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
606 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
611 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
617 if (angle
>= final_angle
)
627 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
628 int fx
, int fy
, int fw
, int fh
, int steps
)
630 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
631 float cx
, cy
, cw
, ch
;
632 float xstep
, ystep
, wstep
, hstep
;
634 float angle
, final_angle
, a
, d
, delta
;
641 xstep
= (float)(fx
-x
)/steps
;
642 ystep
= (float)(fy
-y
)/steps
;
643 wstep
= (float)(fw
-w
)/steps
;
644 hstep
= (float)(fh
-h
)/steps
;
651 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
652 delta
= (float)(final_angle
/FRAMES
);
653 for (angle
=0;; angle
+=delta
) {
654 if (angle
> final_angle
)
658 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
660 points
[0].x
= cx
+cos(angle
-a
)*d
;
661 points
[0].y
= cy
+sin(angle
-a
)*d
;
662 points
[1].x
= cx
+cos(angle
+a
)*d
;
663 points
[1].y
= cy
+sin(angle
+a
)*d
;
664 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
665 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
666 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
667 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
668 points
[4].x
= cx
+cos(angle
-a
)*d
;
669 points
[4].y
= cy
+sin(angle
-a
)*d
;
671 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
673 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
674 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
679 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
685 if (angle
>= final_angle
)
695 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
696 int fx
, int fy
, int fw
, int fh
, int steps
)
698 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
699 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
700 float xstep
, ystep
, wstep
, hstep
;
703 xstep
= (float)(fx
-x
)/steps
;
704 ystep
= (float)(fy
-y
)/steps
;
705 wstep
= (float)(fw
-w
)/steps
;
706 hstep
= (float)(fh
-h
)/steps
;
708 for (j
=0; j
<FRAMES
; j
++) {
715 for (i
=0; i
<steps
; i
++) {
716 for (j
=0; j
<FRAMES
; j
++) {
717 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
718 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
721 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
722 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
726 for (j
=0; j
<FRAMES
; j
++) {
727 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
728 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
743 for (j
=0; j
<FRAMES
; j
++) {
744 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
745 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
748 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
749 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
753 for (j
=0; j
<FRAMES
; j
++) {
754 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
755 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
764 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
765 int fx
, int fy
, int fw
, int fh
, int hiding
)
767 int style
= wPreferences
.iconification_style
; /* Catch the value */
770 if (style
== WIS_NONE
)
773 if (style
== WIS_RANDOM
) {
777 k
= (hiding
? 2 : 3);
781 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
783 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
786 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
788 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
792 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
794 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
798 #endif /* ANIMATIONS */
806 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
807 WMHandleEvent(&tmpev
);
812 unmapTransientsFor(WWindow
*wwin
)
817 tmp
= wwin
->screen_ptr
->focused_window
;
819 /* unmap the transients for this transient */
820 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
821 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
822 || tmp
->flags
.shaded
)) {
823 unmapTransientsFor(tmp
);
824 tmp
->flags
.miniaturized
= 1;
825 if (!tmp
->flags
.shaded
) {
828 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
831 if (!tmp->flags.shaded)
833 wClientSetState(tmp
, IconicState
, None
);
835 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
843 mapTransientsFor(WWindow
*wwin
)
847 tmp
= wwin
->screen_ptr
->focused_window
;
849 /* recursively map the transients for this transient */
850 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
851 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
852 && tmp
->icon
==NULL
) {
853 mapTransientsFor(tmp
);
854 tmp
->flags
.miniaturized
= 0;
855 if (!tmp
->flags
.shaded
) {
858 XMapWindow(dpy
, tmp
->frame
->core
->window
);
860 tmp
->flags
.semi_focused
= 0;
862 if (!tmp->flags.shaded)
864 wClientSetState(tmp
, NormalState
, None
);
866 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
874 setupIconGrabs(WIcon
*icon
)
876 /* setup passive grabs on the icon */
877 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
878 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
879 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
880 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
881 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
882 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
888 recursiveTransientFor(WWindow
*wwin
)
895 /* hackish way to detect transient_for cycle */
896 i
= wwin
->screen_ptr
->window_count
+1;
898 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
899 wwin
= wWindowFor(wwin
->transient_for
);
903 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
913 removeIconGrabs(WIcon
*icon
)
915 /* remove passive grabs on the icon */
916 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
917 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
918 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
925 wIconifyWindow(WWindow
*wwin
)
927 XWindowAttributes attribs
;
931 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
932 /* the window doesn't exist anymore */
936 if (wwin
->flags
.miniaturized
) {
940 if (wwin
->transient_for
!=None
&&
941 wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
942 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
944 if (owner
&& owner
->flags
.miniaturized
)
948 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
950 /* if the window is in another workspace, simplify process */
952 /* icon creation may take a while */
953 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
954 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
955 GrabModeAsync
, None
, None
, CurrentTime
);
958 if (!wPreferences
.disable_miniwindows
960 && !wwin
->flags
.net_handle_icon
963 if (!wwin
->flags
.icon_moved
) {
964 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
, wGetHeadForWindow(wwin
));
966 wwin
->icon
= wIconCreate(wwin
);
968 wwin
->icon
->mapped
= 1;
971 wwin
->flags
.miniaturized
= 1;
972 wwin
->flags
.mapped
= 0;
974 /* unmap transients */
976 unmapTransientsFor(wwin
);
979 wSoundPlay(WSOUND_ICONIFY
);
981 XUngrabPointer(dpy
, CurrentTime
);
983 /* let all Expose events arrive so that we can repaint
984 * something before the animation starts (and the server is grabbed) */
987 if (wPreferences
.disable_miniwindows
989 || wwin
->flags
.net_handle_icon
992 wClientSetState(wwin
, IconicState
, None
);
994 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
998 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
999 && !wPreferences
.no_animations
) {
1002 if (!wPreferences
.disable_miniwindows
1004 && !wwin
->flags
.net_handle_icon
1009 iw
= wwin
->icon
->core
->width
;
1010 ih
= wwin
->icon
->core
->height
;
1013 if (wwin
->flags
.net_handle_icon
) {
1023 iw
= wwin
->screen_ptr
->scr_width
;
1024 ih
= wwin
->screen_ptr
->scr_height
;
1027 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1028 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1029 ix
, iy
, iw
, ih
, False
);
1034 wwin
->flags
.skip_next_animation
= 0;
1036 if (!wPreferences
.disable_miniwindows
1038 && !wwin
->flags
.net_handle_icon
1042 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1043 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1045 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1047 AddToStackList(wwin
->icon
->core
);
1049 wLowerFrame(wwin
->icon
->core
);
1053 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1056 * It doesn't seem to be working and causes button event hangup
1057 * when deiconifying a transient window.
1058 setupIconGrabs(wwin->icon);
1060 if ((wwin
->flags
.focused
1061 || (owner
&& wwin
->client_win
== owner
->client_win
))
1062 && wPreferences
.focus_mode
==WKF_CLICK
) {
1067 if (!WFLAGP(tmp
, no_focusable
)
1068 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1069 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1073 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1074 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1075 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1079 if (!wwin
->screen_ptr
->flags
.startup
) {
1080 /* Catch up with events not processed while animation was running */
1081 Window clientwin
= wwin
->client_win
;
1083 ProcessPendingEvents();
1085 /* the window can disappear while ProcessPendingEvents() runs */
1086 if (!wWindowFor(clientwin
)) {
1093 /* maybe we want to do this regardless of net_handle_icon
1094 * it seems to me we might break behaviour this way.
1096 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
1098 && !wwin
->flags
.net_handle_icon
1101 wIconSelect(wwin
->icon
);
1103 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1110 wDeiconifyWindow(WWindow
*wwin
)
1113 /* we're hiding for show_desktop */
1114 int netwm_hidden
= wwin
->flags
.net_show_desktop
&&
1115 wwin
->frame
->workspace
!=wwin
->screen_ptr
->current_workspace
;
1117 int netwm_hidden
= False
;
1121 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1123 if (!wwin
->flags
.miniaturized
)
1126 if (wwin
->transient_for
!= None
1127 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1128 WWindow
*owner
= recursiveTransientFor(wwin
);
1130 if (owner
&& owner
->flags
.miniaturized
) {
1131 wDeiconifyWindow(owner
);
1132 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1133 wRaiseFrame(wwin
->frame
->core
);
1138 wwin
->flags
.miniaturized
= 0;
1140 if (!netwm_hidden
&& !wwin
->flags
.shaded
) {
1141 wwin
->flags
.mapped
= 1;
1144 if (!netwm_hidden
|| wPreferences
.sticky_icons
) {
1145 /* maybe we want to do this regardless of net_handle_icon
1146 * it seems to me we might break behaviour this way.
1148 if (!wPreferences
.disable_miniwindows
1150 && !wwin
->flags
.net_handle_icon
1152 && wwin
->icon
!= NULL
) {
1153 if (wwin
->icon
->selected
)
1154 wIconSelect(wwin
->icon
);
1156 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1161 wSoundPlay(WSOUND_DEICONIFY
);
1163 /* if the window is in another workspace, do it silently */
1164 if (!netwm_hidden
) {
1166 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1167 && !wwin
->flags
.skip_next_animation
&& wwin
->icon
!= NULL
) {
1170 if (!wPreferences
.disable_miniwindows
1172 && !wwin
->flags
.net_handle_icon
1177 iw
= wwin
->icon
->core
->width
;
1178 ih
= wwin
->icon
->core
->height
;
1181 if (wwin
->flags
.net_handle_icon
) {
1191 iw
= wwin
->screen_ptr
->scr_width
;
1192 ih
= wwin
->screen_ptr
->scr_height
;
1195 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1196 wwin
->frame_x
, wwin
->frame_y
,
1197 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1200 #endif /* ANIMATIONS */
1201 wwin
->flags
.skip_next_animation
= 0;
1203 if (!wwin
->flags
.shaded
) {
1204 XMapWindow(dpy
, wwin
->client_win
);
1206 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1207 wRaiseFrame(wwin
->frame
->core
);
1208 if (!wwin
->flags
.shaded
) {
1209 wClientSetState(wwin
, NormalState
, None
);
1211 mapTransientsFor(wwin
);
1214 if (!wPreferences
.disable_miniwindows
&& wwin
->icon
!= NULL
1216 && !wwin
->flags
.net_handle_icon
1219 RemoveFromStackList(wwin
->icon
->core
);
1220 /* removeIconGrabs(wwin->icon);*/
1221 wIconDestroy(wwin
->icon
);
1225 if (!netwm_hidden
) {
1228 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1231 if (!wwin
->screen_ptr
->flags
.startup
) {
1232 /* Catch up with events not processed while animation was running */
1233 Window clientwin
= wwin
->client_win
;
1235 ProcessPendingEvents();
1237 /* the window can disappear while ProcessPendingEvents() runs */
1238 if (!wWindowFor(clientwin
)) {
1245 if (wPreferences
.auto_arrange_icons
) {
1246 wArrangeIcons(wwin
->screen_ptr
, True
);
1249 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1251 /* In case we were shaded and iconified, also unshade */
1253 wUnshadeWindow(wwin
);
1259 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1261 if (wwin
->flags
.miniaturized
) {
1263 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1264 wwin
->icon
->mapped
= 0;
1266 wwin
->flags
.hidden
= 1;
1268 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1272 if (wwin
->flags
.inspector_open
) {
1273 wHideInspectorForWindow(wwin
);
1276 wwin
->flags
.hidden
= 1;
1279 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1281 wSoundPlay(WSOUND_HIDE
);
1283 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1284 !wwin
->flags
.skip_next_animation
&& animate
) {
1285 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1286 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1287 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1291 wwin
->flags
.skip_next_animation
= 0;
1293 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1299 wHideOtherApplications(WWindow
*awin
)
1306 wwin
= awin
->screen_ptr
->focused_window
;
1311 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1312 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1313 && !wwin
->flags
.internal_window
1314 && wGetWindowOfInspectorForWindow(wwin
) != awin
1315 && !WFLAGP(wwin
, no_hide_others
)) {
1317 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1318 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1319 wwin
->flags
.skip_next_animation
= 1;
1320 wIconifyWindow(wwin
);
1322 } else if (wwin
->main_window
!=None
1323 && awin
->main_window
!= wwin
->main_window
) {
1324 tapp
= wApplicationOf(wwin
->main_window
);
1326 tapp
->flags
.skip_next_animation
= 1;
1327 wHideApplication(tapp
);
1329 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1330 wwin
->flags
.skip_next_animation
= 1;
1331 wIconifyWindow(wwin
);
1339 wSetFocusTo(awin->screen_ptr, awin);
1346 wHideApplication(WApplication
*wapp
)
1354 wwarning("trying to hide a non grouped window");
1357 if (!wapp
->main_window_desc
) {
1358 wwarning("group leader not found for window group");
1361 scr
= wapp
->main_window_desc
->screen_ptr
;
1363 wlist
= scr
->focused_window
;
1367 if (wlist
->main_window
== wapp
->main_window
)
1368 wapp
->last_focused
= wlist
;
1370 wapp
->last_focused
= NULL
;
1372 animate
= !wapp
->flags
.skip_next_animation
;
1375 if (wlist
->main_window
== wapp
->main_window
) {
1376 if (wlist
->flags
.focused
) {
1379 if (wapp
->app_icon
) {
1380 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1381 wapp
->app_icon
->y_pos
, wlist
, animate
);
1385 wlist
= wlist
->prev
;
1388 wapp
->flags
.skip_next_animation
= 0;
1391 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1392 wlist
= scr
->focused_window
;
1394 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1395 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1397 wlist
= wlist
->prev
;
1399 wSetFocusTo(scr
, wlist
);
1401 wSetFocusTo(scr
, NULL
);
1405 wapp
->flags
.hidden
= 1;
1407 if(wPreferences
.auto_arrange_icons
) {
1408 wArrangeIcons(scr
, True
);
1412 wAppIconPaint(wapp
->app_icon
);
1420 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1421 int bringToCurrentWS
)
1423 if (bringToCurrentWS
)
1424 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1426 wwin
->flags
.hidden
=0;
1428 wSoundPlay(WSOUND_UNHIDE
);
1430 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1432 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1433 icon
->core
->width
, icon
->core
->height
,
1434 wwin
->frame_x
, wwin
->frame_y
,
1435 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1439 wwin
->flags
.skip_next_animation
= 0;
1440 if (wwin
->screen_ptr
->current_workspace
== wwin
->frame
->workspace
) {
1441 XMapWindow(dpy
, wwin
->client_win
);
1442 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1443 wClientSetState(wwin
, NormalState
, None
);
1444 wwin
->flags
.mapped
=1;
1445 wRaiseFrame(wwin
->frame
->core
);
1447 if (wwin
->flags
.inspector_open
) {
1448 wUnhideInspectorForWindow(wwin
);
1451 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1456 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1459 WWindow
*wlist
, *next
;
1460 WWindow
*focused
=NULL
;
1466 scr
= wapp
->main_window_desc
->screen_ptr
;
1467 wlist
= scr
->focused_window
;
1471 /* goto beginning of list */
1473 wlist
= wlist
->prev
;
1475 animate
= !wapp
->flags
.skip_next_animation
;
1480 if (wlist
->main_window
== wapp
->main_window
) {
1481 if (wlist
->flags
.focused
)
1483 else if (!focused
|| !focused
->flags
.focused
)
1486 if (wlist
->flags
.miniaturized
) {
1487 if (bringToCurrentWS
|| wPreferences
.sticky_icons
||
1488 wlist
->frame
->workspace
== scr
->current_workspace
) {
1489 if (wlist
->icon
&& !wlist
->icon
->mapped
) {
1492 PlaceIcon(scr
, &x
, &y
, wGetHeadForWindow(wlist
));
1493 if (wlist
->icon_x
!=x
|| wlist
->icon_y
!=y
) {
1494 XMoveWindow(dpy
, wlist
->icon
->core
->window
, x
, y
);
1498 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1499 wlist
->icon
->mapped
= 1;
1501 wRaiseFrame(wlist
->icon
->core
);
1503 if (bringToCurrentWS
)
1504 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1505 wlist
->flags
.hidden
= 0;
1507 wlist
->frame
->workspace
== scr
->current_workspace
) {
1508 wDeiconifyWindow(wlist
);
1510 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1511 } else if (wlist
->flags
.shaded
) {
1512 if (bringToCurrentWS
)
1513 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1514 wlist
->flags
.hidden
= 0;
1515 if (wlist
->frame
->workspace
== scr
->current_workspace
) {
1516 XMapWindow(dpy
, wlist
->frame
->core
->window
);
1518 wUnshadeWindow(wlist
);
1519 wRaiseFrame(wlist
->frame
->core
);
1522 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1523 } else if (wlist
->flags
.hidden
) {
1524 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1525 wapp
->app_icon
->y_pos
, wlist
, animate
,
1529 if (bringToCurrentWS
1530 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1531 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1533 wRaiseFrame(wlist
->frame
->core
);
1539 wapp
->flags
.skip_next_animation
= 0;
1540 wapp
->flags
.hidden
= 0;
1542 if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
) {
1543 wRaiseFrame(wapp
->last_focused
->frame
->core
);
1544 wSetFocusTo(scr
, wapp
->last_focused
);
1545 } else if (focused
) {
1546 wSetFocusTo(scr
, focused
);
1548 wapp
->last_focused
= NULL
;
1549 if (wPreferences
.auto_arrange_icons
) {
1550 wArrangeIcons(scr
, True
);
1553 wAppIconPaint(wapp
->app_icon
);
1559 wShowAllWindows(WScreen
*scr
)
1561 WWindow
*wwin
, *old_foc
;
1564 old_foc
= wwin
= scr
->focused_window
;
1566 if (!wwin
->flags
.internal_window
&&
1567 (scr
->current_workspace
== wwin
->frame
->workspace
1568 || IS_OMNIPRESENT(wwin
))) {
1569 if (wwin
->flags
.miniaturized
) {
1570 wwin
->flags
.skip_next_animation
= 1;
1571 wDeiconifyWindow(wwin
);
1572 } else if (wwin
->flags
.hidden
) {
1573 wapp
= wApplicationOf(wwin
->main_window
);
1575 wUnhideApplication(wapp
, False
, False
);
1577 wwin
->flags
.skip_next_animation
= 1;
1578 wDeiconifyWindow(wwin
);
1584 wSetFocusTo(scr
, old_foc
);
1585 /*wRaiseFrame(old_foc->frame->core);*/
1590 wRefreshDesktop(WScreen
*scr
)
1593 XSetWindowAttributes attr
;
1595 attr
.backing_store
= NotUseful
;
1596 attr
.save_under
= False
;
1597 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1598 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1599 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1601 XMapRaised(dpy
, win
);
1602 XDestroyWindow(dpy
, win
);
1608 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1614 const int heads
= wXineramaHeads(scr
);
1617 int pf
; /* primary axis */
1618 int sf
; /* secondary axis */
1622 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1628 int isize
= wPreferences
.icon_size
;
1630 vars
= (struct HeadVars
*)wmalloc(sizeof(struct HeadVars
)*heads
);
1632 for (head
= 0; head
< heads
; ++head
) {
1634 WMRect rect
= wGetRectForHead(scr
, head
);
1636 WArea area
= wGetUsableAreaForHead(scr
, head
, NULL
, False
);
1637 WMRect rect
= wmkrect(area
.x1
, area
.y1
, area
.x2
-area
.x1
, area
.y2
-area
.y1
);
1640 vars
[head
].pi
= vars
[head
].si
= 0;
1641 vars
[head
].sx1
= rect
.pos
.x
;
1642 vars
[head
].sy1
= rect
.pos
.y
;
1643 vars
[head
].sw
= rect
.size
.width
;
1644 vars
[head
].sh
= rect
.size
.height
;
1645 vars
[head
].sx2
= vars
[head
].sx1
+ vars
[head
].sw
;
1646 vars
[head
].sy2
= vars
[head
].sy1
+ vars
[head
].sh
;
1650 if (scr
->dock
->on_right_side
)
1651 vars
[head
].sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1653 vars
[head
].sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1657 vars
[head
].sw
= isize
* (vars
[head
].sw
/isize
);
1658 vars
[head
].sh
= isize
* (vars
[head
].sh
/isize
);
1659 vars
[head
].fullW
= (vars
[head
].sx2
-vars
[head
].sx1
)/isize
;
1660 vars
[head
].fullH
= (vars
[head
].sy2
-vars
[head
].sy1
)/isize
;
1662 /* icon yard boundaries */
1663 if (wPreferences
.icon_yard
& IY_VERT
) {
1664 vars
[head
].pf
= vars
[head
].fullH
;
1665 vars
[head
].sf
= vars
[head
].fullW
;
1667 vars
[head
].pf
= vars
[head
].fullW
;
1668 vars
[head
].sf
= vars
[head
].fullH
;
1670 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1671 vars
[head
].xo
= vars
[head
].sx2
- isize
;
1674 vars
[head
].xo
= vars
[head
].sx1
;
1677 if (wPreferences
.icon_yard
& IY_TOP
) {
1678 vars
[head
].yo
= vars
[head
].sy1
;
1681 vars
[head
].yo
= vars
[head
].sy2
- isize
;
1686 #define X ((wPreferences.icon_yard & IY_VERT) \
1687 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1688 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1690 #define Y ((wPreferences.icon_yard & IY_VERT) \
1691 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1692 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1695 /* arrange application icons */
1696 aicon
= scr
->app_icon_list
;
1697 /* reverse them to avoid unnecessarily sliding of icons */
1698 while (aicon
&& aicon
->next
)
1699 aicon
= aicon
->next
;
1702 if (!aicon
->docked
) {
1703 /* CHECK: can icon be NULL here ? */
1704 /* The intention here is to place the AppIcon on the head that
1705 * contains most of the applications _main_ window. */
1706 head
= wGetHeadForWindow(aicon
->icon
->owner
);
1708 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1710 if (!wPreferences
.no_animations
) {
1711 SlideWindow(aicon
->icon
->core
->window
,
1712 aicon
->x_pos
, aicon
->y_pos
, X
, Y
);
1714 #endif /* ANIMATIONS */
1716 wAppIconMove(aicon
, X
, Y
);
1718 if (vars
[head
].pi
>= vars
[head
].pf
) {
1723 aicon
= aicon
->prev
;
1726 /* arrange miniwindows */
1727 wwin
= scr
->focused_window
;
1728 /* reverse them to avoid unnecessarily shuffling */
1729 while (wwin
&& wwin
->prev
)
1733 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1734 (wwin
->frame
->workspace
==scr
->current_workspace
||
1735 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1737 head
= wGetHeadForWindow(wwin
);
1739 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1740 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1742 if (wPreferences
.no_animations
) {
1743 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1745 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1746 wwin
->icon_y
, X
, Y
);
1749 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1750 #endif /* ANIMATIONS */
1756 if (vars
[head
].pi
>= vars
[head
].pf
) {
1763 wwin
->flags
.icon_moved
= 0;
1765 /* we reversed the order, so we use next */
1774 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1778 int pf
; /* primary axis */
1779 int sf
; /* secondary axis */
1783 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1787 int isize
= wPreferences
.icon_size
;
1790 * Find out screen boundaries.
1794 * Allows each head to have miniwindows
1796 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1800 sw
= rect
.size
.width
;
1801 sh
= rect
.size
.height
;
1805 if (scr
->dock
->on_right_side
)
1806 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1808 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1812 sw
= isize
* (scr
->scr_width
/isize
);
1813 sh
= isize
* (scr
->scr_height
/isize
);
1815 sw
= isize
* (sw
/isize
);
1816 sh
= isize
* (sh
/isize
);
1818 fullW
= (sx2
-sx1
)/isize
;
1819 fullH
= (sy2
-sy1
)/isize
;
1821 /* icon yard boundaries */
1822 if (wPreferences
.icon_yard
& IY_VERT
) {
1829 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1836 if (wPreferences
.icon_yard
& IY_TOP
) {
1844 /* arrange icons putting the most recently focused window
1845 * as the last icon */
1846 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1847 : xo + xs*(pi*isize))
1848 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1849 : yo + ys*(si*isize))
1851 /* arrange application icons */
1852 aicon
= scr
->app_icon_list
;
1853 /* reverse them to avoid unnecessarily sliding of icons */
1854 while (aicon
&& aicon
->next
)
1855 aicon
= aicon
->next
;
1860 if (!aicon
->docked
) {
1861 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1863 if (!wPreferences
.no_animations
) {
1864 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1867 #endif /* ANIMATIONS */
1869 wAppIconMove(aicon
, X
, Y
);
1872 /* we reversed the order so we use prev */
1873 aicon
= aicon
->prev
;
1880 /* arrange miniwindows */
1882 wwin
= scr
->focused_window
;
1883 /* reverse them to avoid unnecessarily shuffling */
1884 while (wwin
&& wwin
->prev
)
1888 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1889 (wwin
->frame
->workspace
==scr
->current_workspace
||
1890 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1892 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1893 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1895 if (wPreferences
.no_animations
) {
1896 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1898 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1899 wwin
->icon_y
, X
, Y
);
1902 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1903 #endif /* ANIMATIONS */
1911 wwin
->flags
.icon_moved
= 0;
1913 /* we reversed the order, so we use next */
1924 wSelectWindow(WWindow
*wwin
, Bool flag
)
1926 WScreen
*scr
= wwin
->screen_ptr
;
1929 wwin
->flags
.selected
= 1;
1930 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1932 if (!HAS_BORDER(wwin
)) {
1933 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1934 FRAME_BORDER_WIDTH
);
1937 if (!scr
->selected_windows
)
1938 scr
->selected_windows
= WMCreateArray(4);
1939 WMAddToArray(scr
->selected_windows
, wwin
);
1941 wwin
->flags
.selected
= 0;
1942 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1943 scr
->frame_border_pixel
);
1945 if (!HAS_BORDER(wwin
)) {
1946 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1949 if (scr
->selected_windows
) {
1950 WMRemoveFromArray(scr
->selected_windows
, wwin
);
1957 wMakeWindowVisible(WWindow
*wwin
)
1959 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1960 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1962 if (wwin
->flags
.shaded
) {
1963 wUnshadeWindow(wwin
);
1965 if (wwin
->flags
.hidden
) {
1968 app
= wApplicationOf(wwin
->main_window
);
1970 /* trick to get focus to this window */
1971 app
->last_focused
= wwin
;
1972 wUnhideApplication(app
, False
, False
);
1975 if (wwin
->flags
.miniaturized
) {
1976 wDeiconifyWindow(wwin
);
1978 if (!WFLAGP(wwin
, no_focusable
))
1979 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1980 wRaiseFrame(wwin
->frame
->core
);