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
)
369 unsigned int new_width
, new_height
;
370 int changed_h
, changed_v
, shrink_h
, shrink_v
;
371 WArea usableArea
, totalArea
;
373 if (!IS_RESIZABLE(wwin
))
378 totalArea
.x2
= wwin
->screen_ptr
->scr_width
;
379 totalArea
.y2
= wwin
->screen_ptr
->scr_height
;
380 usableArea
= totalArea
;
382 if (!(directions
& MAX_IGNORE_XINERAMA
)) {
383 WScreen
*scr
= wwin
->screen_ptr
;
386 if (directions
& MAX_KEYBOARD
)
387 head
= wGetHeadForWindow(wwin
);
389 head
= wGetHeadForPointerLocation(scr
);
391 usableArea
= wGetUsableAreaForHead(scr
, head
, &totalArea
, True
);
394 if (WFLAGP(wwin
, full_maximize
)) {
395 usableArea
= totalArea
;
398 if (wwin
->flags
.shaded
) {
399 wwin
->flags
.skip_next_animation
= 1;
400 wUnshadeWindow(wwin
);
402 /* Only save directions, not kbd or xinerama hints */
403 directions
&= (MAX_HORIZONTAL
|MAX_VERTICAL
);
405 changed_h
= ((wwin
->flags
.maximized
^ directions
) & MAX_HORIZONTAL
);
406 changed_v
= ((wwin
->flags
.maximized
^ directions
) & MAX_VERTICAL
);
407 shrink_h
= (changed_h
&& (directions
& MAX_HORIZONTAL
)==0);
408 shrink_v
= (changed_v
&& (directions
& MAX_VERTICAL
)==0);
410 if (wwin
->flags
.maximized
) {
411 /* if already maximized in some direction, we only update the
412 * appropriate old x, old y coordinates. This is necessary to
413 * allow succesive maximizations in different directions without
414 * the need to first do an un-maximize (to avoid flicker).
416 if (!(wwin
->flags
.maximized
& MAX_HORIZONTAL
)) {
417 wwin
->old_geometry
.x
= wwin
->frame_x
;
419 if (!(wwin
->flags
.maximized
& MAX_VERTICAL
)) {
420 wwin
->old_geometry
.y
= wwin
->frame_y
;
423 wwin
->old_geometry
.width
= wwin
->client
.width
;
424 wwin
->old_geometry
.height
= wwin
->client
.height
;
425 wwin
->old_geometry
.x
= wwin
->frame_x
;
426 wwin
->old_geometry
.y
= wwin
->frame_y
;
428 wwin
->flags
.maximized
= directions
;
430 if (directions
& MAX_HORIZONTAL
) {
431 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
432 new_x
= usableArea
.x1
;
433 } else if (shrink_h
) {
434 new_x
= wwin
->old_geometry
.x
;
435 new_width
= wwin
->old_geometry
.width
;
437 new_x
= wwin
->frame_x
;
438 new_width
= wwin
->frame
->core
->width
;
441 if (directions
& MAX_VERTICAL
) {
442 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
443 new_y
= usableArea
.y1
;
444 if (WFLAGP(wwin
, full_maximize
)) {
445 new_y
-= wwin
->frame
->top_width
;
446 new_height
+= wwin
->frame
->bottom_width
- 1;
448 } else if (shrink_v
) {
449 new_y
= wwin
->old_geometry
.y
;
450 new_height
= wwin
->old_geometry
.height
;
452 new_y
= wwin
->frame_y
;
453 new_height
= wwin
->frame
->core
->height
;
456 if (!WFLAGP(wwin
, full_maximize
)) {
457 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
460 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
462 wWindowCropSize(wwin
, usableArea
.x2
-usableArea
.x1
,
463 usableArea
.y2
-usableArea
.y1
,
464 &new_width
, &new_height
);
466 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
469 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
471 wSoundPlay(WSOUND_MAXIMIZE
);
476 wUnmaximizeWindow(WWindow
*wwin
)
480 if (!wwin
->flags
.maximized
)
483 if (wwin
->flags
.shaded
) {
484 wwin
->flags
.skip_next_animation
= 1;
485 wUnshadeWindow(wwin
);
487 x
= ((wwin
->flags
.maximized
& MAX_HORIZONTAL
) && wwin
->old_geometry
.x
) ?
488 wwin
->old_geometry
.x
: wwin
->frame_x
;
489 y
= ((wwin
->flags
.maximized
& MAX_VERTICAL
) && wwin
->old_geometry
.y
) ?
490 wwin
->old_geometry
.y
: wwin
->frame_y
;
491 w
= wwin
->old_geometry
.width
?
492 wwin
->old_geometry
.width
: wwin
->client
.width
;
493 h
= wwin
->old_geometry
.height
?
494 wwin
->old_geometry
.height
: wwin
->client
.height
;
496 wwin
->flags
.maximized
= 0;
497 wWindowConfigure(wwin
, x
, y
, w
, h
);
499 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
501 wSoundPlay(WSOUND_UNMAXIMIZE
);
506 wFullscreenWindow(WWindow
*wwin
)
511 if (wwin
->flags
.fullscreen
)
514 wwin
->flags
.fullscreen
= True
;
516 wWindowConfigureBorders(wwin
);
518 ChangeStackingLevel(wwin
->frame
->core
, WMFullscreenLevel
);
520 wwin
->bfs_geometry
.x
= wwin
->frame_x
;
521 wwin
->bfs_geometry
.y
= wwin
->frame_y
;
522 wwin
->bfs_geometry
.width
= wwin
->frame
->core
->width
;
523 wwin
->bfs_geometry
.height
= wwin
->frame
->core
->height
;
525 head
= wGetHeadForWindow(wwin
);
526 rect
= wGetRectForHead(wwin
->screen_ptr
, head
);
527 wWindowConfigure(wwin
, rect
.pos
.x
, rect
.pos
.y
,
528 rect
.size
.width
, rect
.size
.height
);
530 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
535 wUnfullscreenWindow(WWindow
*wwin
)
537 if (!wwin
->flags
.fullscreen
)
540 wwin
->flags
.fullscreen
= False
;
542 if (wwin
->frame
->core
->stacking
->window_level
== WMFullscreenLevel
) {
543 if (WFLAGP(wwin
, sunken
)) {
544 ChangeStackingLevel(wwin
->frame
->core
, WMSunkenLevel
);
545 } else if (WFLAGP(wwin
, floating
)) {
546 ChangeStackingLevel(wwin
->frame
->core
, WMFloatingLevel
);
548 ChangeStackingLevel(wwin
->frame
->core
, WMNormalLevel
);
552 wWindowConfigure(wwin
, wwin
->bfs_geometry
.x
, wwin
->bfs_geometry
.y
,
553 wwin
->bfs_geometry
.width
, wwin
->bfs_geometry
.height
);
555 wWindowConfigureBorders(wwin
);
557 // seems unnecessary, but also harmless (doesn't generate flicker) -Dan
558 wFrameWindowPaint(wwin->frame);
561 WMPostNotificationName(WMNChangedState
, wwin
, "fullscreen");
567 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
568 int fx
, int fy
, int fw
, int fh
, int steps
)
570 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
571 float cx
, cy
, cw
, ch
;
572 float xstep
, ystep
, wstep
, hstep
;
575 float angle
, final_angle
, delta
;
577 xstep
= (float)(fx
-x
)/steps
;
578 ystep
= (float)(fy
-y
)/steps
;
579 wstep
= (float)(fw
-w
)/steps
;
580 hstep
= (float)(fh
-h
)/steps
;
587 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
588 delta
= (float)(final_angle
/FRAMES
);
589 for (angle
=0;; angle
+=delta
) {
590 if (angle
> final_angle
)
593 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
594 dch
= (ch
/2) * cos(angle
);
597 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
598 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
599 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
600 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
601 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
604 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
606 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
607 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
612 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
618 if (angle
>= final_angle
)
628 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
629 int fx
, int fy
, int fw
, int fh
, int steps
)
631 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
632 float cx
, cy
, cw
, ch
;
633 float xstep
, ystep
, wstep
, hstep
;
635 float angle
, final_angle
, a
, d
, delta
;
642 xstep
= (float)(fx
-x
)/steps
;
643 ystep
= (float)(fy
-y
)/steps
;
644 wstep
= (float)(fw
-w
)/steps
;
645 hstep
= (float)(fh
-h
)/steps
;
652 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
653 delta
= (float)(final_angle
/FRAMES
);
654 for (angle
=0;; angle
+=delta
) {
655 if (angle
> final_angle
)
659 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
661 points
[0].x
= cx
+cos(angle
-a
)*d
;
662 points
[0].y
= cy
+sin(angle
-a
)*d
;
663 points
[1].x
= cx
+cos(angle
+a
)*d
;
664 points
[1].y
= cy
+sin(angle
+a
)*d
;
665 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
666 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
667 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
668 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
669 points
[4].x
= cx
+cos(angle
-a
)*d
;
670 points
[4].y
= cy
+sin(angle
-a
)*d
;
672 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
674 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
675 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
680 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
686 if (angle
>= final_angle
)
696 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
697 int fx
, int fy
, int fw
, int fh
, int steps
)
699 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
700 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
701 float xstep
, ystep
, wstep
, hstep
;
704 xstep
= (float)(fx
-x
)/steps
;
705 ystep
= (float)(fy
-y
)/steps
;
706 wstep
= (float)(fw
-w
)/steps
;
707 hstep
= (float)(fh
-h
)/steps
;
709 for (j
=0; j
<FRAMES
; j
++) {
716 for (i
=0; i
<steps
; i
++) {
717 for (j
=0; j
<FRAMES
; j
++) {
718 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
719 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
722 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
723 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
727 for (j
=0; j
<FRAMES
; j
++) {
728 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
729 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
744 for (j
=0; j
<FRAMES
; j
++) {
745 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
746 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
749 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
750 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
754 for (j
=0; j
<FRAMES
; j
++) {
755 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
756 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
765 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
766 int fx
, int fy
, int fw
, int fh
, int hiding
)
768 int style
= wPreferences
.iconification_style
; /* Catch the value */
771 if (style
== WIS_NONE
)
774 if (style
== WIS_RANDOM
) {
778 k
= (hiding
? 2 : 3);
782 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
784 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
787 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
789 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
793 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
795 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
799 #endif /* ANIMATIONS */
807 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
808 WMHandleEvent(&tmpev
);
813 unmapTransientsFor(WWindow
*wwin
)
818 tmp
= wwin
->screen_ptr
->focused_window
;
820 /* unmap the transients for this transient */
821 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
822 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
823 || tmp
->flags
.shaded
)) {
824 unmapTransientsFor(tmp
);
825 tmp
->flags
.miniaturized
= 1;
826 if (!tmp
->flags
.shaded
) {
829 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
832 if (!tmp->flags.shaded)
834 wClientSetState(tmp
, IconicState
, None
);
836 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
844 mapTransientsFor(WWindow
*wwin
)
848 tmp
= wwin
->screen_ptr
->focused_window
;
850 /* recursively map the transients for this transient */
851 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
852 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
853 && tmp
->icon
==NULL
) {
854 mapTransientsFor(tmp
);
855 tmp
->flags
.miniaturized
= 0;
856 if (!tmp
->flags
.shaded
) {
859 XMapWindow(dpy
, tmp
->frame
->core
->window
);
861 tmp
->flags
.semi_focused
= 0;
863 if (!tmp->flags.shaded)
865 wClientSetState(tmp
, NormalState
, None
);
867 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
875 setupIconGrabs(WIcon
*icon
)
877 /* setup passive grabs on the icon */
878 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
879 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
880 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
881 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
882 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
883 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
889 recursiveTransientFor(WWindow
*wwin
)
896 /* hackish way to detect transient_for cycle */
897 i
= wwin
->screen_ptr
->window_count
+1;
899 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
900 wwin
= wWindowFor(wwin
->transient_for
);
904 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
914 removeIconGrabs(WIcon
*icon
)
916 /* remove passive grabs on the icon */
917 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
918 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
919 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
926 wIconifyWindow(WWindow
*wwin
)
928 XWindowAttributes attribs
;
932 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
933 /* the window doesn't exist anymore */
937 if (wwin
->flags
.miniaturized
) {
941 if (wwin
->transient_for
!=None
&&
942 wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
943 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
945 if (owner
&& owner
->flags
.miniaturized
)
949 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
951 /* if the window is in another workspace, simplify process */
953 /* icon creation may take a while */
954 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
955 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
956 GrabModeAsync
, None
, None
, CurrentTime
);
959 if (!wPreferences
.disable_miniwindows
961 && !wwin
->flags
.net_handle_icon
964 if (!wwin
->flags
.icon_moved
) {
965 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
, wGetHeadForWindow(wwin
));
967 wwin
->icon
= wIconCreate(wwin
);
969 wwin
->icon
->mapped
= 1;
972 wwin
->flags
.miniaturized
= 1;
973 wwin
->flags
.mapped
= 0;
975 /* unmap transients */
977 unmapTransientsFor(wwin
);
980 wSoundPlay(WSOUND_ICONIFY
);
982 XUngrabPointer(dpy
, CurrentTime
);
984 /* let all Expose events arrive so that we can repaint
985 * something before the animation starts (and the server is grabbed) */
988 if (wPreferences
.disable_miniwindows
990 || wwin
->flags
.net_handle_icon
993 wClientSetState(wwin
, IconicState
, None
);
995 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
999 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
1000 && !wPreferences
.no_animations
) {
1003 if (!wPreferences
.disable_miniwindows
1005 && !wwin
->flags
.net_handle_icon
1010 iw
= wwin
->icon
->core
->width
;
1011 ih
= wwin
->icon
->core
->height
;
1014 if (wwin
->flags
.net_handle_icon
) {
1024 iw
= wwin
->screen_ptr
->scr_width
;
1025 ih
= wwin
->screen_ptr
->scr_height
;
1028 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1029 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1030 ix
, iy
, iw
, ih
, False
);
1035 wwin
->flags
.skip_next_animation
= 0;
1037 if (!wPreferences
.disable_miniwindows
1039 && !wwin
->flags
.net_handle_icon
1043 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1044 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1046 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1048 AddToStackList(wwin
->icon
->core
);
1050 wLowerFrame(wwin
->icon
->core
);
1054 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1057 * It doesn't seem to be working and causes button event hangup
1058 * when deiconifying a transient window.
1059 setupIconGrabs(wwin->icon);
1061 if ((wwin
->flags
.focused
1062 || (owner
&& wwin
->client_win
== owner
->client_win
))
1063 && wPreferences
.focus_mode
==WKF_CLICK
) {
1068 if (!WFLAGP(tmp
, no_focusable
)
1069 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1070 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1074 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1075 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1076 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1080 if (!wwin
->screen_ptr
->flags
.startup
) {
1081 /* Catch up with events not processed while animation was running */
1082 Window clientwin
= wwin
->client_win
;
1084 ProcessPendingEvents();
1086 /* the window can disappear while ProcessPendingEvents() runs */
1087 if (!wWindowFor(clientwin
)) {
1094 /* maybe we want to do this regardless of net_handle_icon
1095 * it seems to me we might break behaviour this way.
1097 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
1099 && !wwin
->flags
.net_handle_icon
1102 wIconSelect(wwin
->icon
);
1104 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1111 wDeiconifyWindow(WWindow
*wwin
)
1114 /* we're hiding for show_desktop */
1115 int netwm_hidden
= wwin
->flags
.net_show_desktop
&&
1116 wwin
->frame
->workspace
!=wwin
->screen_ptr
->current_workspace
;
1118 int netwm_hidden
= False
;
1122 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1124 if (!wwin
->flags
.miniaturized
)
1127 if (wwin
->transient_for
!= None
1128 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1129 WWindow
*owner
= recursiveTransientFor(wwin
);
1131 if (owner
&& owner
->flags
.miniaturized
) {
1132 wDeiconifyWindow(owner
);
1133 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1134 wRaiseFrame(wwin
->frame
->core
);
1139 wwin
->flags
.miniaturized
= 0;
1141 if (!netwm_hidden
&& !wwin
->flags
.shaded
) {
1142 wwin
->flags
.mapped
= 1;
1145 if (!netwm_hidden
|| wPreferences
.sticky_icons
) {
1146 /* maybe we want to do this regardless of net_handle_icon
1147 * it seems to me we might break behaviour this way.
1149 if (!wPreferences
.disable_miniwindows
1151 && !wwin
->flags
.net_handle_icon
1153 && wwin
->icon
!= NULL
) {
1154 if (wwin
->icon
->selected
)
1155 wIconSelect(wwin
->icon
);
1157 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1162 wSoundPlay(WSOUND_DEICONIFY
);
1164 /* if the window is in another workspace, do it silently */
1165 if (!netwm_hidden
) {
1167 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1168 && !wwin
->flags
.skip_next_animation
&& wwin
->icon
!= NULL
) {
1171 if (!wPreferences
.disable_miniwindows
1173 && !wwin
->flags
.net_handle_icon
1178 iw
= wwin
->icon
->core
->width
;
1179 ih
= wwin
->icon
->core
->height
;
1182 if (wwin
->flags
.net_handle_icon
) {
1192 iw
= wwin
->screen_ptr
->scr_width
;
1193 ih
= wwin
->screen_ptr
->scr_height
;
1196 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1197 wwin
->frame_x
, wwin
->frame_y
,
1198 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1201 #endif /* ANIMATIONS */
1202 wwin
->flags
.skip_next_animation
= 0;
1204 if (!wwin
->flags
.shaded
) {
1205 XMapWindow(dpy
, wwin
->client_win
);
1207 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1208 wRaiseFrame(wwin
->frame
->core
);
1209 if (!wwin
->flags
.shaded
) {
1210 wClientSetState(wwin
, NormalState
, None
);
1212 mapTransientsFor(wwin
);
1215 if (!wPreferences
.disable_miniwindows
&& wwin
->icon
!= NULL
1217 && !wwin
->flags
.net_handle_icon
1220 RemoveFromStackList(wwin
->icon
->core
);
1221 /* removeIconGrabs(wwin->icon);*/
1222 wIconDestroy(wwin
->icon
);
1226 if (!netwm_hidden
) {
1229 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1232 if (!wwin
->screen_ptr
->flags
.startup
) {
1233 /* Catch up with events not processed while animation was running */
1234 Window clientwin
= wwin
->client_win
;
1236 ProcessPendingEvents();
1238 /* the window can disappear while ProcessPendingEvents() runs */
1239 if (!wWindowFor(clientwin
)) {
1246 if (wPreferences
.auto_arrange_icons
) {
1247 wArrangeIcons(wwin
->screen_ptr
, True
);
1250 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1252 /* In case we were shaded and iconified, also unshade */
1254 wUnshadeWindow(wwin
);
1260 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1262 if (wwin
->flags
.miniaturized
) {
1264 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1265 wwin
->icon
->mapped
= 0;
1267 wwin
->flags
.hidden
= 1;
1269 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1273 if (wwin
->flags
.inspector_open
) {
1274 wHideInspectorForWindow(wwin
);
1277 wwin
->flags
.hidden
= 1;
1280 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1282 wSoundPlay(WSOUND_HIDE
);
1284 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1285 !wwin
->flags
.skip_next_animation
&& animate
) {
1286 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1287 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1288 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1292 wwin
->flags
.skip_next_animation
= 0;
1294 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1300 wHideOtherApplications(WWindow
*awin
)
1307 wwin
= awin
->screen_ptr
->focused_window
;
1312 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1313 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1314 && !wwin
->flags
.internal_window
1315 && wGetWindowOfInspectorForWindow(wwin
) != awin
1316 && !WFLAGP(wwin
, no_hide_others
)) {
1318 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1319 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1320 wwin
->flags
.skip_next_animation
= 1;
1321 wIconifyWindow(wwin
);
1323 } else if (wwin
->main_window
!=None
1324 && awin
->main_window
!= wwin
->main_window
) {
1325 tapp
= wApplicationOf(wwin
->main_window
);
1327 tapp
->flags
.skip_next_animation
= 1;
1328 wHideApplication(tapp
);
1330 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1331 wwin
->flags
.skip_next_animation
= 1;
1332 wIconifyWindow(wwin
);
1340 wSetFocusTo(awin->screen_ptr, awin);
1347 wHideApplication(WApplication
*wapp
)
1355 wwarning("trying to hide a non grouped window");
1358 if (!wapp
->main_window_desc
) {
1359 wwarning("group leader not found for window group");
1362 scr
= wapp
->main_window_desc
->screen_ptr
;
1364 wlist
= scr
->focused_window
;
1368 if (wlist
->main_window
== wapp
->main_window
)
1369 wapp
->last_focused
= wlist
;
1371 wapp
->last_focused
= NULL
;
1373 animate
= !wapp
->flags
.skip_next_animation
;
1376 if (wlist
->main_window
== wapp
->main_window
) {
1377 if (wlist
->flags
.focused
) {
1380 if (wapp
->app_icon
) {
1381 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1382 wapp
->app_icon
->y_pos
, wlist
, animate
);
1386 wlist
= wlist
->prev
;
1389 wapp
->flags
.skip_next_animation
= 0;
1392 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1393 wlist
= scr
->focused_window
;
1395 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1396 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1398 wlist
= wlist
->prev
;
1400 wSetFocusTo(scr
, wlist
);
1402 wSetFocusTo(scr
, NULL
);
1406 wapp
->flags
.hidden
= 1;
1408 if(wPreferences
.auto_arrange_icons
) {
1409 wArrangeIcons(scr
, True
);
1413 wAppIconPaint(wapp
->app_icon
);
1421 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1422 int bringToCurrentWS
)
1424 if (bringToCurrentWS
)
1425 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1427 wwin
->flags
.hidden
=0;
1429 wSoundPlay(WSOUND_UNHIDE
);
1431 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1433 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1434 icon
->core
->width
, icon
->core
->height
,
1435 wwin
->frame_x
, wwin
->frame_y
,
1436 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1440 wwin
->flags
.skip_next_animation
= 0;
1441 if (wwin
->screen_ptr
->current_workspace
== wwin
->frame
->workspace
) {
1442 XMapWindow(dpy
, wwin
->client_win
);
1443 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1444 wClientSetState(wwin
, NormalState
, None
);
1445 wwin
->flags
.mapped
=1;
1446 wRaiseFrame(wwin
->frame
->core
);
1448 if (wwin
->flags
.inspector_open
) {
1449 wUnhideInspectorForWindow(wwin
);
1452 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1457 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1460 WWindow
*wlist
, *next
;
1461 WWindow
*focused
=NULL
;
1467 scr
= wapp
->main_window_desc
->screen_ptr
;
1468 wlist
= scr
->focused_window
;
1472 /* goto beginning of list */
1474 wlist
= wlist
->prev
;
1476 animate
= !wapp
->flags
.skip_next_animation
;
1481 if (wlist
->main_window
== wapp
->main_window
) {
1482 if (wlist
->flags
.focused
)
1484 else if (!focused
|| !focused
->flags
.focused
)
1487 if (wlist
->flags
.miniaturized
) {
1488 if (bringToCurrentWS
|| wPreferences
.sticky_icons
||
1489 wlist
->frame
->workspace
== scr
->current_workspace
) {
1490 if (wlist
->icon
&& !wlist
->icon
->mapped
) {
1493 PlaceIcon(scr
, &x
, &y
, wGetHeadForWindow(wlist
));
1494 if (wlist
->icon_x
!=x
|| wlist
->icon_y
!=y
) {
1495 XMoveWindow(dpy
, wlist
->icon
->core
->window
, x
, y
);
1499 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1500 wlist
->icon
->mapped
= 1;
1502 wRaiseFrame(wlist
->icon
->core
);
1504 if (bringToCurrentWS
)
1505 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1506 wlist
->flags
.hidden
= 0;
1508 wlist
->frame
->workspace
== scr
->current_workspace
) {
1509 wDeiconifyWindow(wlist
);
1511 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1512 } else if (wlist
->flags
.shaded
) {
1513 if (bringToCurrentWS
)
1514 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1515 wlist
->flags
.hidden
= 0;
1516 if (wlist
->frame
->workspace
== scr
->current_workspace
) {
1517 XMapWindow(dpy
, wlist
->frame
->core
->window
);
1519 wUnshadeWindow(wlist
);
1520 wRaiseFrame(wlist
->frame
->core
);
1523 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1524 } else if (wlist
->flags
.hidden
) {
1525 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1526 wapp
->app_icon
->y_pos
, wlist
, animate
,
1530 if (bringToCurrentWS
1531 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1532 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1534 wRaiseFrame(wlist
->frame
->core
);
1540 wapp
->flags
.skip_next_animation
= 0;
1541 wapp
->flags
.hidden
= 0;
1543 if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
) {
1544 wRaiseFrame(wapp
->last_focused
->frame
->core
);
1545 wSetFocusTo(scr
, wapp
->last_focused
);
1546 } else if (focused
) {
1547 wSetFocusTo(scr
, focused
);
1549 wapp
->last_focused
= NULL
;
1550 if (wPreferences
.auto_arrange_icons
) {
1551 wArrangeIcons(scr
, True
);
1554 wAppIconPaint(wapp
->app_icon
);
1560 wShowAllWindows(WScreen
*scr
)
1562 WWindow
*wwin
, *old_foc
;
1565 old_foc
= wwin
= scr
->focused_window
;
1567 if (!wwin
->flags
.internal_window
&&
1568 (scr
->current_workspace
== wwin
->frame
->workspace
1569 || IS_OMNIPRESENT(wwin
))) {
1570 if (wwin
->flags
.miniaturized
) {
1571 wwin
->flags
.skip_next_animation
= 1;
1572 wDeiconifyWindow(wwin
);
1573 } else if (wwin
->flags
.hidden
) {
1574 wapp
= wApplicationOf(wwin
->main_window
);
1576 wUnhideApplication(wapp
, False
, False
);
1578 wwin
->flags
.skip_next_animation
= 1;
1579 wDeiconifyWindow(wwin
);
1585 wSetFocusTo(scr
, old_foc
);
1586 /*wRaiseFrame(old_foc->frame->core);*/
1591 wRefreshDesktop(WScreen
*scr
)
1594 XSetWindowAttributes attr
;
1596 attr
.backing_store
= NotUseful
;
1597 attr
.save_under
= False
;
1598 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1599 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1600 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1602 XMapRaised(dpy
, win
);
1603 XDestroyWindow(dpy
, win
);
1609 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1615 const int heads
= wXineramaHeads(scr
);
1618 int pf
; /* primary axis */
1619 int sf
; /* secondary axis */
1623 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1629 int isize
= wPreferences
.icon_size
;
1631 vars
= (struct HeadVars
*)wmalloc(sizeof(struct HeadVars
)*heads
);
1633 for (head
= 0; head
< heads
; ++head
) {
1635 WMRect rect
= wGetRectForHead(scr
, head
);
1637 WArea area
= wGetUsableAreaForHead(scr
, head
, NULL
, False
);
1638 WMRect rect
= wmkrect(area
.x1
, area
.y1
, area
.x2
-area
.x1
, area
.y2
-area
.y1
);
1641 vars
[head
].pi
= vars
[head
].si
= 0;
1642 vars
[head
].sx1
= rect
.pos
.x
;
1643 vars
[head
].sy1
= rect
.pos
.y
;
1644 vars
[head
].sw
= rect
.size
.width
;
1645 vars
[head
].sh
= rect
.size
.height
;
1646 vars
[head
].sx2
= vars
[head
].sx1
+ vars
[head
].sw
;
1647 vars
[head
].sy2
= vars
[head
].sy1
+ vars
[head
].sh
;
1651 if (scr
->dock
->on_right_side
)
1652 vars
[head
].sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1654 vars
[head
].sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1658 vars
[head
].sw
= isize
* (vars
[head
].sw
/isize
);
1659 vars
[head
].sh
= isize
* (vars
[head
].sh
/isize
);
1660 vars
[head
].fullW
= (vars
[head
].sx2
-vars
[head
].sx1
)/isize
;
1661 vars
[head
].fullH
= (vars
[head
].sy2
-vars
[head
].sy1
)/isize
;
1663 /* icon yard boundaries */
1664 if (wPreferences
.icon_yard
& IY_VERT
) {
1665 vars
[head
].pf
= vars
[head
].fullH
;
1666 vars
[head
].sf
= vars
[head
].fullW
;
1668 vars
[head
].pf
= vars
[head
].fullW
;
1669 vars
[head
].sf
= vars
[head
].fullH
;
1671 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1672 vars
[head
].xo
= vars
[head
].sx2
- isize
;
1675 vars
[head
].xo
= vars
[head
].sx1
;
1678 if (wPreferences
.icon_yard
& IY_TOP
) {
1679 vars
[head
].yo
= vars
[head
].sy1
;
1682 vars
[head
].yo
= vars
[head
].sy2
- isize
;
1687 #define X ((wPreferences.icon_yard & IY_VERT) \
1688 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1689 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1691 #define Y ((wPreferences.icon_yard & IY_VERT) \
1692 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1693 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1696 /* arrange application icons */
1697 aicon
= scr
->app_icon_list
;
1698 /* reverse them to avoid unnecessarily sliding of icons */
1699 while (aicon
&& aicon
->next
)
1700 aicon
= aicon
->next
;
1703 if (!aicon
->docked
) {
1704 /* CHECK: can icon be NULL here ? */
1705 /* The intention here is to place the AppIcon on the head that
1706 * contains most of the applications _main_ window. */
1707 head
= wGetHeadForWindow(aicon
->icon
->owner
);
1709 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1711 if (!wPreferences
.no_animations
) {
1712 SlideWindow(aicon
->icon
->core
->window
,
1713 aicon
->x_pos
, aicon
->y_pos
, X
, Y
);
1715 #endif /* ANIMATIONS */
1717 wAppIconMove(aicon
, X
, Y
);
1719 if (vars
[head
].pi
>= vars
[head
].pf
) {
1724 aicon
= aicon
->prev
;
1727 /* arrange miniwindows */
1728 wwin
= scr
->focused_window
;
1729 /* reverse them to avoid unnecessarily shuffling */
1730 while (wwin
&& wwin
->prev
)
1734 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1735 (wwin
->frame
->workspace
==scr
->current_workspace
||
1736 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1738 head
= wGetHeadForWindow(wwin
);
1740 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1741 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1743 if (wPreferences
.no_animations
) {
1744 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1746 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1747 wwin
->icon_y
, X
, Y
);
1750 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1751 #endif /* ANIMATIONS */
1757 if (vars
[head
].pi
>= vars
[head
].pf
) {
1764 wwin
->flags
.icon_moved
= 0;
1766 /* we reversed the order, so we use next */
1775 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1779 int pf
; /* primary axis */
1780 int sf
; /* secondary axis */
1784 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1788 int isize
= wPreferences
.icon_size
;
1791 * Find out screen boundaries.
1795 * Allows each head to have miniwindows
1797 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1801 sw
= rect
.size
.width
;
1802 sh
= rect
.size
.height
;
1806 if (scr
->dock
->on_right_side
)
1807 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1809 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1813 sw
= isize
* (scr
->scr_width
/isize
);
1814 sh
= isize
* (scr
->scr_height
/isize
);
1816 sw
= isize
* (sw
/isize
);
1817 sh
= isize
* (sh
/isize
);
1819 fullW
= (sx2
-sx1
)/isize
;
1820 fullH
= (sy2
-sy1
)/isize
;
1822 /* icon yard boundaries */
1823 if (wPreferences
.icon_yard
& IY_VERT
) {
1830 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1837 if (wPreferences
.icon_yard
& IY_TOP
) {
1845 /* arrange icons putting the most recently focused window
1846 * as the last icon */
1847 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1848 : xo + xs*(pi*isize))
1849 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1850 : yo + ys*(si*isize))
1852 /* arrange application icons */
1853 aicon
= scr
->app_icon_list
;
1854 /* reverse them to avoid unnecessarily sliding of icons */
1855 while (aicon
&& aicon
->next
)
1856 aicon
= aicon
->next
;
1861 if (!aicon
->docked
) {
1862 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1864 if (!wPreferences
.no_animations
) {
1865 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1868 #endif /* ANIMATIONS */
1870 wAppIconMove(aicon
, X
, Y
);
1873 /* we reversed the order so we use prev */
1874 aicon
= aicon
->prev
;
1881 /* arrange miniwindows */
1883 wwin
= scr
->focused_window
;
1884 /* reverse them to avoid unnecessarily shuffling */
1885 while (wwin
&& wwin
->prev
)
1889 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1890 (wwin
->frame
->workspace
==scr
->current_workspace
||
1891 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1893 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1894 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1896 if (wPreferences
.no_animations
) {
1897 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1899 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1900 wwin
->icon_y
, X
, Y
);
1903 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1904 #endif /* ANIMATIONS */
1912 wwin
->flags
.icon_moved
= 0;
1914 /* we reversed the order, so we use next */
1925 wSelectWindow(WWindow
*wwin
, Bool flag
)
1927 WScreen
*scr
= wwin
->screen_ptr
;
1930 wwin
->flags
.selected
= 1;
1931 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1933 if (!HAS_BORDER(wwin
)) {
1934 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1935 FRAME_BORDER_WIDTH
);
1938 if (!scr
->selected_windows
)
1939 scr
->selected_windows
= WMCreateArray(4);
1940 WMAddToArray(scr
->selected_windows
, wwin
);
1942 wwin
->flags
.selected
= 0;
1943 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1944 scr
->frame_border_pixel
);
1946 if (!HAS_BORDER(wwin
)) {
1947 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1950 if (scr
->selected_windows
) {
1951 WMRemoveFromArray(scr
->selected_windows
, wwin
);
1958 wMakeWindowVisible(WWindow
*wwin
)
1960 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1961 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1963 if (wwin
->flags
.shaded
) {
1964 wUnshadeWindow(wwin
);
1966 if (wwin
->flags
.hidden
) {
1969 app
= wApplicationOf(wwin
->main_window
);
1971 /* trick to get focus to this window */
1972 app
->last_focused
= wwin
;
1973 wUnhideApplication(app
, False
, False
);
1976 if (wwin
->flags
.miniaturized
) {
1977 wDeiconifyWindow(wwin
);
1979 if (!WFLAGP(wwin
, no_focusable
))
1980 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1981 wRaiseFrame(wwin
->frame
->core
);