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"
62 /****** Global Variables ******/
63 extern Time LastTimestamp
;
64 extern Time LastFocusChange
;
66 extern Cursor wCursor
[WCUR_LAST
];
68 extern WPreferences wPreferences
;
70 extern Atom _XA_WM_TAKE_FOCUS
;
73 /******* Local Variables *******/
78 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
79 {SHADE_STEPS_F
, SHADE_DELAY_F
},
80 {SHADE_STEPS_M
, SHADE_DELAY_M
},
81 {SHADE_STEPS_S
, SHADE_DELAY_S
},
82 {SHADE_STEPS_US
, SHADE_DELAY_US
}};
84 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
85 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
88 static int ignoreTimestamp
=0;
93 processEvents(int event_count
)
98 * This is a hack. When animations are enabled, processing of
99 * events ocurred during a animation are delayed until it's end.
100 * Calls that consider the TimeStamp, like XSetInputFocus(), will
101 * fail because the TimeStamp is too old. Then, for example, if
102 * the user changes window focus while a miniaturize animation is
103 * in course, the window will not get focus properly after the end
104 * of the animation. This tries to workaround it by passing CurrentTime
105 * as the TimeStamp for XSetInputFocus() for all events ocurred during
109 while (XPending(dpy
) && event_count
--) {
110 WMNextEvent(dpy
, &event
);
111 WMHandleEvent(&event
);
115 #endif /* ANIMATIONS */
120 *----------------------------------------------------------------------
122 * Changes the window focus to the one passed as argument.
123 * If the window to focus is not already focused, it will be brought
124 * to the head of the list of windows. Previously focused window is
128 * Window list may be reordered and the window focus is changed.
130 *----------------------------------------------------------------------
133 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
135 static WScreen
*old_scr
=NULL
;
137 WWindow
*old_focused
;
138 WWindow
*focused
=scr
->focused_window
;
139 int timestamp
=LastTimestamp
;
140 WApplication
*oapp
=NULL
, *napp
=NULL
;
145 old_focused
=old_scr
->focused_window
;
147 LastFocusChange
= timestamp
;
150 * This is a hack, because XSetInputFocus() should have a proper
151 * timestamp instead of CurrentTime but it seems that some times
152 * clients will not receive focus properly that way.
155 timestamp
= CurrentTime
;
158 oapp
= wApplicationOf(old_focused
->main_window
);
161 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
163 wWindowUnfocus(old_focused
);
166 wAppMenuUnmap(oapp
->menu
);
168 wApplicationDeactivate(oapp
);
172 WMPostNotificationName(WMNChangedFocus
, NULL
, (void*)True
);
174 } else if (old_scr
!= scr
&& old_focused
) {
175 wWindowUnfocus(old_focused
);
178 wasfocused
= wwin
->flags
.focused
;
179 napp
= wApplicationOf(wwin
->main_window
);
181 /* remember last workspace where the app has been */
183 /*napp->last_workspace = wwin->screen_ptr->current_workspace;*/
184 napp
->last_workspace
= wwin
->frame
->workspace
;
187 if (wwin
->flags
.mapped
&& !WFLAGP(wwin
, no_focusable
)) {
188 /* install colormap if colormap mode is lock mode */
189 if (wPreferences
.colormap_mode
==WCM_CLICK
)
190 wColormapInstallForWindow(scr
, wwin
);
192 /* set input focus */
193 switch (wwin
->focus_mode
) {
195 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
199 case WFM_LOCALLY_ACTIVE
:
200 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
203 case WFM_GLOBALLY_ACTIVE
:
207 if (wwin
->protocols
.TAKE_FOCUS
) {
208 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
212 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
214 if (WFLAGP(wwin
, no_focusable
))
217 /* if this is not the focused window focus it */
219 /* change the focus window list order */
221 wwin
->prev
->next
= wwin
->next
;
224 wwin
->next
->prev
= wwin
->prev
;
226 wwin
->prev
= focused
;
227 focused
->next
= wwin
;
229 scr
->focused_window
= wwin
;
231 if (oapp
&& oapp
!= napp
) {
232 wAppMenuUnmap(oapp
->menu
);
234 wApplicationDeactivate(oapp
);
239 wWindowFocus(wwin
, focused
);
241 if (napp
&& !wasfocused
) {
243 wUserMenuRefreshInstances(napp
->menu
, wwin
);
244 #endif /* USER_MENU */
246 if (wwin
->flags
.mapped
)
247 wAppMenuMap(napp
->menu
, wwin
);
249 wApplicationActivate(napp
);
259 wShadeWindow(WWindow
*wwin
)
266 if (wwin
->flags
.shaded
)
271 XLowerWindow(dpy
, wwin
->client_win
);
273 wSoundPlay(WSOUND_SHADE
);
276 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
277 && !wPreferences
.no_animations
) {
278 /* do the shading animation */
279 h
= wwin
->frame
->core
->height
;
282 w
= wwin
->frame
->core
->width
;
283 y
= wwin
->frame
->top_width
;
284 while (h
>wwin
->frame
->top_width
+1) {
285 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
286 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
289 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
292 if (SHADE_DELAY
> 0) {
293 wusleep(SHADE_DELAY
*1000L);
300 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
302 #endif /* ANIMATIONS */
304 wwin
->flags
.skip_next_animation
= 0;
305 wwin
->flags
.shaded
= 1;
306 wwin
->flags
.mapped
= 0;
307 /* prevent window withdrawal when getting UnmapNotify */
308 XSelectInput(dpy
, wwin
->client_win
,
309 wwin
->event_mask
& ~StructureNotifyMask
);
310 XUnmapWindow(dpy
, wwin
->client_win
);
311 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
313 /* for the client it's just like iconification */
314 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
315 wwin
->frame
->top_width
- 1);
317 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
318 + wwin
->frame
->top_width
;
319 wWindowSynthConfigureNotify(wwin
);
322 wClientSetState(wwin, IconicState, None);
325 WMPostNotificationName(WMNChangedState
, wwin
, "shade");
328 if (!wwin
->screen_ptr
->flags
.startup
) {
329 /* Look at processEvents() for reason of this code. */
331 processEvents(XPending(dpy
));
338 wUnshadeWindow(WWindow
*wwin
)
343 #endif /* ANIMATIONS */
346 if (!wwin
->flags
.shaded
)
351 wwin
->flags
.shaded
= 0;
352 wwin
->flags
.mapped
= 1;
353 XMapWindow(dpy
, wwin
->client_win
);
355 wSoundPlay(WSOUND_UNSHADE
);
358 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
359 /* do the shading animation */
360 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
361 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
362 s
= abs(y
)/SHADE_STEPS
;
364 w
= wwin
->frame
->core
->width
;
365 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
367 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
368 + wwin
->frame
->bottom_width
) {
369 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
370 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
372 if (SHADE_DELAY
> 0) {
373 wusleep(SHADE_DELAY
*2000L/3);
380 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
384 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
386 #endif /* ANIMATIONS */
388 wwin
->flags
.skip_next_animation
= 0;
389 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
390 wwin
->frame
->top_width
+ wwin
->client
.height
391 + wwin
->frame
->bottom_width
);
393 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
394 wWindowSynthConfigureNotify(wwin
);
397 wClientSetState(wwin, NormalState, None);
399 /* if the window is focused, set the focus again as it was disabled during
401 if (wwin
->flags
.focused
)
402 wSetFocusTo(wwin
->screen_ptr
, wwin
);
404 WMPostNotificationName(WMNChangedState
, wwin
, "shade");
409 wMaximizeWindow(WWindow
*wwin
, int directions
)
411 int new_width
, new_height
, new_x
, new_y
;
412 WArea usableArea
, totalArea
;
414 if (WFLAGP(wwin
, no_resizable
))
417 usableArea
= totalArea
= (WArea
){
419 wwin
->screen_ptr
->scr_width
,
420 wwin
->screen_ptr
->scr_height
423 if (!(directions
& MAX_IGNORE_XINERAMA
)) {
424 WScreen
*scr
= wwin
->screen_ptr
;
427 if (directions
& MAX_KEYBOARD
)
428 head
= wGetHeadForWindow(wwin
);
430 head
= wGetHeadForPointerLocation(scr
);
432 usableArea
= wGetUsableAreaForHead(scr
, head
, &totalArea
, True
);
435 if (WFLAGP(wwin
, full_maximize
)) {
436 usableArea
= totalArea
;
439 if (wwin
->flags
.shaded
) {
440 wwin
->flags
.skip_next_animation
= 1;
441 wUnshadeWindow(wwin
);
443 wwin
->flags
.maximized
= directions
;
444 wwin
->old_geometry
.width
= wwin
->client
.width
;
445 wwin
->old_geometry
.height
= wwin
->client
.height
;
446 wwin
->old_geometry
.x
= wwin
->frame_x
;
447 wwin
->old_geometry
.y
= wwin
->frame_y
;
450 wKWMUpdateClientGeometryRestore(wwin
);
453 if (directions
& MAX_HORIZONTAL
) {
454 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
455 new_x
= usableArea
.x1
;
457 new_x
= wwin
->frame_x
;
458 new_width
= wwin
->frame
->core
->width
;
461 if (directions
& MAX_VERTICAL
) {
462 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
463 new_y
= usableArea
.y1
;
464 if (WFLAGP(wwin
, full_maximize
)) {
465 new_y
-= wwin
->frame
->top_width
;
466 new_height
+= wwin
->frame
->bottom_width
- 1;
469 new_y
= wwin
->frame_y
;
470 new_height
= wwin
->frame
->core
->height
;
473 if (!WFLAGP(wwin
, full_maximize
)) {
474 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
477 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
479 wWindowCropSize(wwin
, usableArea
.x2
-usableArea
.x1
,
480 usableArea
.y2
-usableArea
.y1
,
481 &new_width
, &new_height
);
483 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
486 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
488 wSoundPlay(WSOUND_MAXIMIZE
);
493 wUnmaximizeWindow(WWindow
*wwin
)
495 int restore_x
, restore_y
;
497 if (!wwin
->flags
.maximized
)
500 if (wwin
->flags
.shaded
) {
501 wwin
->flags
.skip_next_animation
= 1;
502 wUnshadeWindow(wwin
);
504 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
505 wwin
->old_geometry
.x
: wwin
->frame_x
;
506 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
507 wwin
->old_geometry
.y
: wwin
->frame_y
;
508 wwin
->flags
.maximized
= 0;
509 wWindowConfigure(wwin
, restore_x
, restore_y
,
510 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
512 WMPostNotificationName(WMNChangedState
, wwin
, "maximize");
514 wSoundPlay(WSOUND_UNMAXIMIZE
);
519 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
520 int fx
, int fy
, int fw
, int fh
, int steps
)
522 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
523 float cx
, cy
, cw
, ch
;
524 float xstep
, ystep
, wstep
, hstep
;
527 float angle
, final_angle
, delta
;
529 xstep
= (float)(fx
-x
)/steps
;
530 ystep
= (float)(fy
-y
)/steps
;
531 wstep
= (float)(fw
-w
)/steps
;
532 hstep
= (float)(fh
-h
)/steps
;
539 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
540 delta
= (float)(final_angle
/FRAMES
);
541 for (angle
=0;; angle
+=delta
) {
542 if (angle
> final_angle
)
545 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
546 dch
= (ch
/2) * cos(angle
);
549 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
550 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
551 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
552 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
553 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
556 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
558 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
559 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
564 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
570 if (angle
>= final_angle
)
580 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
581 int fx
, int fy
, int fw
, int fh
, int steps
)
583 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
584 float cx
, cy
, cw
, ch
;
585 float xstep
, ystep
, wstep
, hstep
;
587 float angle
, final_angle
, a
, d
, delta
;
594 xstep
= (float)(fx
-x
)/steps
;
595 ystep
= (float)(fy
-y
)/steps
;
596 wstep
= (float)(fw
-w
)/steps
;
597 hstep
= (float)(fh
-h
)/steps
;
604 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
605 delta
= (float)(final_angle
/FRAMES
);
606 for (angle
=0;; angle
+=delta
) {
607 if (angle
> final_angle
)
611 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
613 points
[0].x
= cx
+cos(angle
-a
)*d
;
614 points
[0].y
= cy
+sin(angle
-a
)*d
;
615 points
[1].x
= cx
+cos(angle
+a
)*d
;
616 points
[1].y
= cy
+sin(angle
+a
)*d
;
617 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
618 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
619 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
620 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
621 points
[4].x
= cx
+cos(angle
-a
)*d
;
622 points
[4].y
= cy
+sin(angle
-a
)*d
;
624 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
626 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
627 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
632 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
638 if (angle
>= final_angle
)
648 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
649 int fx
, int fy
, int fw
, int fh
, int steps
)
651 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
652 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
653 float xstep
, ystep
, wstep
, hstep
;
656 xstep
= (float)(fx
-x
)/steps
;
657 ystep
= (float)(fy
-y
)/steps
;
658 wstep
= (float)(fw
-w
)/steps
;
659 hstep
= (float)(fh
-h
)/steps
;
661 for (j
=0; j
<FRAMES
; j
++) {
668 for (i
=0; i
<steps
; i
++) {
669 for (j
=0; j
<FRAMES
; j
++) {
670 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
671 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
674 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
675 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
679 for (j
=0; j
<FRAMES
; j
++) {
680 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
681 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
696 for (j
=0; j
<FRAMES
; j
++) {
697 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
698 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
701 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
702 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
706 for (j
=0; j
<FRAMES
; j
++) {
707 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
708 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
717 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
718 int fx
, int fy
, int fw
, int fh
, int hiding
)
720 int style
= wPreferences
.iconification_style
; /* Catch the value */
723 if (style
== WIS_NONE
)
726 if (style
== WIS_RANDOM
) {
730 k
= (hiding
? 2 : 3);
733 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
735 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
738 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
740 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
744 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
746 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
750 #endif /* ANIMATIONS */
758 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
759 WMHandleEvent(&tmpev
);
764 unmapTransientsFor(WWindow
*wwin
)
769 tmp
= wwin
->screen_ptr
->focused_window
;
771 /* unmap the transients for this transient */
772 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
773 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
774 || tmp
->flags
.shaded
)) {
775 unmapTransientsFor(tmp
);
776 tmp
->flags
.miniaturized
= 1;
777 if (!tmp
->flags
.shaded
) {
780 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
783 if (!tmp->flags.shaded)
785 wClientSetState(tmp
, IconicState
, None
);
787 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
795 mapTransientsFor(WWindow
*wwin
)
799 tmp
= wwin
->screen_ptr
->focused_window
;
801 /* recursively map the transients for this transient */
802 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
803 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
804 && tmp
->icon
==NULL
) {
805 mapTransientsFor(tmp
);
806 tmp
->flags
.miniaturized
= 0;
807 if (!tmp
->flags
.shaded
) {
810 XMapWindow(dpy
, tmp
->frame
->core
->window
);
812 tmp
->flags
.semi_focused
= 0;
814 if (!tmp->flags.shaded)
816 wClientSetState(tmp
, NormalState
, None
);
818 WMPostNotificationName(WMNChangedState
, tmp
, "iconify-transient");
826 setupIconGrabs(WIcon
*icon
)
828 /* setup passive grabs on the icon */
829 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
830 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
831 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
832 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
833 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
834 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
840 recursiveTransientFor(WWindow
*wwin
)
847 /* hackish way to detect transient_for cycle */
848 i
= wwin
->screen_ptr
->window_count
+1;
850 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
851 wwin
= wWindowFor(wwin
->transient_for
);
855 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
865 removeIconGrabs(WIcon
*icon
)
867 /* remove passive grabs on the icon */
868 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
869 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
870 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
877 wIconifyWindow(WWindow
*wwin
)
879 XWindowAttributes attribs
;
883 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
884 /* the window doesn't exist anymore */
888 if (wwin
->flags
.miniaturized
) {
892 if (wwin
->transient_for
!=None
&&
893 wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
894 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
896 if (owner
&& owner
->flags
.miniaturized
)
900 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
902 /* if the window is in another workspace, simplify process */
904 /* icon creation may take a while */
905 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
906 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
907 GrabModeAsync
, None
, None
, CurrentTime
);
910 if (!wPreferences
.disable_miniwindows
) {
911 if (!wwin
->flags
.icon_moved
) {
912 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
, wGetHeadForWindow(wwin
));
914 wwin
->icon
= wIconCreate(wwin
);
916 wwin
->icon
->mapped
= 1;
919 wwin
->flags
.miniaturized
= 1;
920 wwin
->flags
.mapped
= 0;
922 /* unmap transients */
924 unmapTransientsFor(wwin
);
927 wSoundPlay(WSOUND_ICONIFY
);
929 XUngrabPointer(dpy
, CurrentTime
);
931 /* let all Expose events arrive so that we can repaint
932 * something before the animation starts (and the server is grabbed) */
935 if (wPreferences
.disable_miniwindows
)
936 wClientSetState(wwin
, IconicState
, None
);
938 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
942 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
943 && !wPreferences
.no_animations
) {
946 if (!wPreferences
.disable_miniwindows
) {
949 iw
= wwin
->icon
->core
->width
;
950 ih
= wwin
->icon
->core
->height
;
955 if (wKWMGetIconGeometry(wwin
, &area
)) {
961 #endif /* KWM_HINTS */
965 iw
= wwin
->screen_ptr
->scr_width
;
966 ih
= wwin
->screen_ptr
->scr_height
;
969 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
970 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
971 ix
, iy
, iw
, ih
, False
);
976 wwin
->flags
.skip_next_animation
= 0;
978 if (!wPreferences
.disable_miniwindows
) {
980 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
981 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
983 XMapWindow(dpy
, wwin
->icon
->core
->window
);
985 AddToStackList(wwin
->icon
->core
);
987 wLowerFrame(wwin
->icon
->core
);
991 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
994 * It doesn't seem to be working and causes button event hangup
995 * when deiconifying a transient window.
996 setupIconGrabs(wwin->icon);
998 if ((wwin
->flags
.focused
999 || (owner
&& wwin
->client_win
== owner
->client_win
))
1000 && wPreferences
.focus_mode
==WKF_CLICK
) {
1005 if (!WFLAGP(tmp
, no_focusable
)
1006 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1007 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1011 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1012 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1013 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1017 if (!wwin
->screen_ptr
->flags
.startup
) {
1018 Window clientwin
= wwin
->client_win
;
1021 processEvents(XPending(dpy
));
1023 /* the window can disappear while doing the processEvents() */
1024 if (!wWindowFor(clientwin
))
1031 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1032 wIconSelect(wwin
->icon
);
1034 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1041 wDeiconifyWindow(WWindow
*wwin
)
1043 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1045 if (!wwin
->flags
.miniaturized
)
1048 if (wwin
->transient_for
!= None
1049 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1050 WWindow
*owner
= recursiveTransientFor(wwin
);
1052 if (owner
&& owner
->flags
.miniaturized
) {
1053 wDeiconifyWindow(owner
);
1054 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1055 wRaiseFrame(wwin
->frame
->core
);
1060 wwin
->flags
.miniaturized
= 0;
1061 if (!wwin
->flags
.shaded
)
1062 wwin
->flags
.mapped
= 1;
1064 if (!wPreferences
.disable_miniwindows
&& wwin
->icon
!= NULL
) {
1065 if (wwin
->icon
->selected
)
1066 wIconSelect(wwin
->icon
);
1068 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1071 wSoundPlay(WSOUND_DEICONIFY
);
1073 /* if the window is in another workspace, do it silently */
1075 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1076 && !wwin
->flags
.skip_next_animation
&& wwin
->icon
!= NULL
) {
1079 if (!wPreferences
.disable_miniwindows
) {
1082 iw
= wwin
->icon
->core
->width
;
1083 ih
= wwin
->icon
->core
->height
;
1088 if (wKWMGetIconGeometry(wwin
, &area
)) {
1094 #endif /* KWM_HINTS */
1098 iw
= wwin
->screen_ptr
->scr_width
;
1099 ih
= wwin
->screen_ptr
->scr_height
;
1102 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1103 wwin
->frame_x
, wwin
->frame_y
,
1104 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1107 #endif /* ANIMATIONS */
1108 wwin
->flags
.skip_next_animation
= 0;
1110 if (!wwin
->flags
.shaded
) {
1111 XMapWindow(dpy
, wwin
->client_win
);
1113 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1114 wRaiseFrame(wwin
->frame
->core
);
1115 if (!wwin
->flags
.shaded
) {
1116 wClientSetState(wwin
, NormalState
, None
);
1118 mapTransientsFor(wwin
);
1120 if (!wPreferences
.disable_miniwindows
&& wwin
->icon
!= NULL
) {
1121 RemoveFromStackList(wwin
->icon
->core
);
1122 /* removeIconGrabs(wwin->icon);*/
1123 wIconDestroy(wwin
->icon
);
1128 if (wPreferences
.focus_mode
==WKF_CLICK
)
1129 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1132 if (!wwin
->screen_ptr
->flags
.startup
) {
1133 Window clientwin
= wwin
->client_win
;
1136 processEvents(XPending(dpy
));
1138 if (!wWindowFor(clientwin
))
1143 if (wPreferences
.auto_arrange_icons
) {
1144 wArrangeIcons(wwin
->screen_ptr
, True
);
1147 WMPostNotificationName(WMNChangedState
, wwin
, "iconify");
1149 /* In case we were shaded and iconified, also unshade */
1150 wUnshadeWindow(wwin
);
1156 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1158 if (wwin
->flags
.miniaturized
) {
1160 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1161 wwin
->icon
->mapped
= 0;
1163 wwin
->flags
.hidden
= 1;
1165 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1169 if (wwin
->flags
.inspector_open
) {
1170 wHideInspectorForWindow(wwin
);
1173 wwin
->flags
.hidden
= 1;
1176 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1178 wSoundPlay(WSOUND_HIDE
);
1180 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1181 !wwin
->flags
.skip_next_animation
&& animate
) {
1182 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1183 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1184 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1188 wwin
->flags
.skip_next_animation
= 0;
1190 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1196 wHideOtherApplications(WWindow
*awin
)
1203 wwin
= awin
->screen_ptr
->focused_window
;
1208 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1209 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1210 && !wwin
->flags
.internal_window
1211 && wGetWindowOfInspectorForWindow(wwin
) != awin
1212 && !WFLAGP(wwin
, no_hide_others
)) {
1214 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1215 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1216 wwin
->flags
.skip_next_animation
= 1;
1217 wIconifyWindow(wwin
);
1219 } else if (wwin
->main_window
!=None
1220 && awin
->main_window
!= wwin
->main_window
) {
1221 tapp
= wApplicationOf(wwin
->main_window
);
1223 tapp
->flags
.skip_next_animation
= 1;
1224 wHideApplication(tapp
);
1226 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1227 wwin
->flags
.skip_next_animation
= 1;
1228 wIconifyWindow(wwin
);
1236 wSetFocusTo(awin->screen_ptr, awin);
1243 wHideApplication(WApplication
*wapp
)
1250 wwarning("trying to hide a non grouped window");
1253 if (!wapp
->main_window_desc
) {
1254 wwarning("group leader not found for window group");
1257 scr
= wapp
->main_window_desc
->screen_ptr
;
1259 wlist
= scr
->focused_window
;
1263 if (wlist
->main_window
== wapp
->main_window
)
1264 wapp
->last_focused
= wlist
;
1266 wapp
->last_focused
= NULL
;
1268 if (wlist
->main_window
== wapp
->main_window
) {
1269 if (wlist
->flags
.focused
) {
1273 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1274 wapp
->app_icon
->y_pos
, wlist
,
1275 !wapp
->flags
.skip_next_animation
);
1277 wlist
= wlist
->prev
;
1280 wapp
->flags
.skip_next_animation
= 0;
1283 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1284 wlist
= scr
->focused_window
;
1286 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1287 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1289 wlist
= wlist
->prev
;
1291 wSetFocusTo(scr
, wlist
);
1293 wSetFocusTo(scr
, NULL
);
1297 wapp
->flags
.hidden
= 1;
1299 if(wPreferences
.auto_arrange_icons
) {
1300 wArrangeIcons(scr
, True
);
1304 wAppIconPaint(wapp
->app_icon
);
1312 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1313 int bringToCurrentWS
)
1315 if (bringToCurrentWS
)
1316 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1318 wwin
->flags
.hidden
=0;
1320 wSoundPlay(WSOUND_UNHIDE
);
1322 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1324 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1325 icon
->core
->width
, icon
->core
->height
,
1326 wwin
->frame_x
, wwin
->frame_y
,
1327 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1331 wwin
->flags
.skip_next_animation
= 0;
1332 if (wwin
->screen_ptr
->current_workspace
== wwin
->frame
->workspace
) {
1333 XMapWindow(dpy
, wwin
->client_win
);
1334 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1335 wClientSetState(wwin
, NormalState
, None
);
1336 wwin
->flags
.mapped
=1;
1337 wRaiseFrame(wwin
->frame
->core
);
1339 if (wwin
->flags
.inspector_open
) {
1340 wUnhideInspectorForWindow(wwin
);
1343 WMPostNotificationName(WMNChangedState
, wwin
, "hide");
1348 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1351 WWindow
*wlist
, *next
;
1352 WWindow
*focused
=NULL
;
1353 Bool shouldArrangeIcons
= False
;
1358 scr
= wapp
->main_window_desc
->screen_ptr
;
1359 wlist
= scr
->focused_window
;
1363 /* goto beginning of list */
1365 wlist
= wlist
->prev
;
1370 if (wlist
->main_window
== wapp
->main_window
) {
1371 if (wlist
->flags
.focused
)
1373 else if (!focused
|| !focused
->flags
.focused
)
1376 if (wlist
->flags
.miniaturized
) {
1377 if (bringToCurrentWS
|| wPreferences
.sticky_icons
||
1378 wlist
->frame
->workspace
== scr
->current_workspace
) {
1379 if (wlist
->icon
&& !wlist
->icon
->mapped
) {
1380 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1381 wlist
->icon
->mapped
= 1;
1384 if (bringToCurrentWS
)
1385 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1386 wlist
->flags
.hidden
= 0;
1388 wlist
->frame
->workspace
== scr
->current_workspace
) {
1389 wDeiconifyWindow(wlist
);
1391 shouldArrangeIcons
= True
;
1392 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1393 } else if (wlist
->flags
.shaded
) {
1394 if (bringToCurrentWS
)
1395 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1396 wlist
->flags
.hidden
= 0;
1397 if (wlist
->frame
->workspace
== scr
->current_workspace
) {
1398 XMapWindow(dpy
, wlist
->frame
->core
->window
);
1400 wUnshadeWindow(wlist
);
1401 wRaiseFrame(wlist
->frame
->core
);
1404 WMPostNotificationName(WMNChangedState
, wlist
, "hide");
1405 } else if (wlist
->flags
.hidden
) {
1406 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1407 wapp
->app_icon
->y_pos
, wlist
,
1408 !wapp
->flags
.skip_next_animation
,
1411 if (bringToCurrentWS
1412 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1413 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1415 wRaiseFrame(wlist
->frame
->core
);
1421 wapp
->flags
.skip_next_animation
= 0;
1422 wapp
->flags
.hidden
= 0;
1424 if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
) {
1425 wRaiseFrame(wapp
->last_focused
->frame
->core
);
1426 wSetFocusTo(scr
, wapp
->last_focused
);
1427 } else if (focused
) {
1428 wSetFocusTo(scr
, focused
);
1430 wapp
->last_focused
= NULL
;
1431 if (shouldArrangeIcons
|| wPreferences
.auto_arrange_icons
) {
1432 wArrangeIcons(scr
, True
);
1435 wAppIconPaint(wapp
->app_icon
);
1442 wShowAllWindows(WScreen
*scr
)
1444 WWindow
*wwin
, *old_foc
;
1447 old_foc
= wwin
= scr
->focused_window
;
1449 if (!wwin
->flags
.internal_window
&&
1450 (scr
->current_workspace
== wwin
->frame
->workspace
1451 || IS_OMNIPRESENT(wwin
))) {
1452 if (wwin
->flags
.miniaturized
) {
1453 wwin
->flags
.skip_next_animation
= 1;
1454 wDeiconifyWindow(wwin
);
1455 } else if (wwin
->flags
.hidden
) {
1456 wapp
= wApplicationOf(wwin
->main_window
);
1458 wUnhideApplication(wapp
, False
, False
);
1460 wwin
->flags
.skip_next_animation
= 1;
1461 wDeiconifyWindow(wwin
);
1467 wSetFocusTo(scr
, old_foc
);
1468 /*wRaiseFrame(old_foc->frame->core);*/
1473 wRefreshDesktop(WScreen
*scr
)
1476 XSetWindowAttributes attr
;
1478 attr
.backing_store
= NotUseful
;
1479 attr
.save_under
= False
;
1480 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1481 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1482 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1484 XMapRaised(dpy
, win
);
1485 XDestroyWindow(dpy
, win
);
1491 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1497 const int heads
= wXineramaHeads(scr
);
1500 int pf
; /* primary axis */
1501 int sf
; /* secondary axis */
1505 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1511 int isize
= wPreferences
.icon_size
;
1513 for (head
= 0; head
< heads
; ++head
) {
1515 WMRect rect
= wGetRectForHead(scr
, head
);
1517 WArea area
= wGetUsableAreaForHead(scr
, head
, NULL
, False
);
1518 WMRect rect
= (WMRect
){ area
.x1
, area
.y1
, area
.x2
-area
.x1
, area
.y2
-area
.y1
};
1521 vars
[head
].pi
= vars
[head
].si
= 0;
1522 vars
[head
].sx1
= rect
.pos
.x
;
1523 vars
[head
].sy1
= rect
.pos
.y
;
1524 vars
[head
].sw
= rect
.size
.width
;
1525 vars
[head
].sh
= rect
.size
.height
;
1526 vars
[head
].sx2
= vars
[head
].sx1
+ vars
[head
].sw
;
1527 vars
[head
].sy2
= vars
[head
].sy1
+ vars
[head
].sh
;
1531 if (scr
->dock
->on_right_side
)
1532 vars
[head
].sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1534 vars
[head
].sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1538 vars
[head
].sw
= isize
* (vars
[head
].sw
/isize
);
1539 vars
[head
].sh
= isize
* (vars
[head
].sh
/isize
);
1540 vars
[head
].fullW
= (vars
[head
].sx2
-vars
[head
].sx1
)/isize
;
1541 vars
[head
].fullH
= (vars
[head
].sy2
-vars
[head
].sy1
)/isize
;
1543 /* icon yard boundaries */
1544 if (wPreferences
.icon_yard
& IY_VERT
) {
1545 vars
[head
].pf
= vars
[head
].fullH
;
1546 vars
[head
].sf
= vars
[head
].fullW
;
1548 vars
[head
].pf
= vars
[head
].fullW
;
1549 vars
[head
].sf
= vars
[head
].fullH
;
1551 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1552 vars
[head
].xo
= vars
[head
].sx2
- isize
;
1555 vars
[head
].xo
= vars
[head
].sx1
;
1558 if (wPreferences
.icon_yard
& IY_TOP
) {
1559 vars
[head
].yo
= vars
[head
].sy1
;
1562 vars
[head
].yo
= vars
[head
].sy2
- isize
;
1567 #define X ((wPreferences.icon_yard & IY_VERT) \
1568 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1569 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1571 #define Y ((wPreferences.icon_yard & IY_VERT) \
1572 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1573 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1576 /* arrange application icons */
1577 aicon
= scr
->app_icon_list
;
1578 /* reverse them to avoid unnecessarily sliding of icons */
1579 while (aicon
&& aicon
->next
)
1580 aicon
= aicon
->next
;
1583 if (!aicon
->docked
) {
1584 /* XXX: can: icon == NULL ? */
1585 /* The intention here is to place the AppIcon on the head that contains most of the applications _main_ window. */
1586 /* printf( "appicon: %x %x\n", aicon->icon->core->window, aicon->main_window); */
1587 head
= wGetHeadForWindow(aicon
->icon
->owner
);
1589 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1591 if (!wPreferences
.no_animations
) {
1592 SlideWindow(aicon
->icon
->core
->window
,
1593 aicon
->x_pos
, aicon
->y_pos
, X
, Y
);
1595 #endif /* ANIMATIONS */
1597 wAppIconMove(aicon
, X
, Y
);
1599 if (vars
[head
].pi
>= vars
[head
].pf
) {
1604 aicon
= aicon
->prev
;
1607 /* arrange miniwindows */
1608 wwin
= scr
->focused_window
;
1609 /* reverse them to avoid unnecessarily shuffling */
1610 while (wwin
&& wwin
->prev
)
1614 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1615 (wwin
->frame
->workspace
==scr
->current_workspace
||
1616 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1618 head
= wGetHeadForWindow(wwin
);
1620 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1621 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1623 if (wPreferences
.no_animations
) {
1624 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1626 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1627 wwin
->icon_y
, X
, Y
);
1630 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1631 #endif /* ANIMATIONS */
1637 if (vars
[head
].pi
>= vars
[head
].pf
) {
1644 wwin
->flags
.icon_moved
= 0;
1646 /* we reversed the order, so we use next */
1653 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1657 int pf
; /* primary axis */
1658 int sf
; /* secondary axis */
1662 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1666 int isize
= wPreferences
.icon_size
;
1669 * Find out screen boundaries.
1673 * Allows each head to have miniwindows
1675 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1679 sw
= rect
.size
.width
;
1680 sh
= rect
.size
.height
;
1684 if (scr
->dock
->on_right_side
)
1685 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1687 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1691 sw
= isize
* (scr
->scr_width
/isize
);
1692 sh
= isize
* (scr
->scr_height
/isize
);
1694 sw
= isize
* (sw
/isize
);
1695 sh
= isize
* (sh
/isize
);
1697 fullW
= (sx2
-sx1
)/isize
;
1698 fullH
= (sy2
-sy1
)/isize
;
1700 /* icon yard boundaries */
1701 if (wPreferences
.icon_yard
& IY_VERT
) {
1708 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1715 if (wPreferences
.icon_yard
& IY_TOP
) {
1723 /* arrange icons putting the most recently focused window
1724 * as the last icon */
1725 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1726 : xo + xs*(pi*isize))
1727 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1728 : yo + ys*(si*isize))
1730 /* arrange application icons */
1731 aicon
= scr
->app_icon_list
;
1732 /* reverse them to avoid unnecessarily sliding of icons */
1733 while (aicon
&& aicon
->next
)
1734 aicon
= aicon
->next
;
1739 if (!aicon
->docked
) {
1740 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1742 if (!wPreferences
.no_animations
) {
1743 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1746 #endif /* ANIMATIONS */
1748 wAppIconMove(aicon
, X
, Y
);
1751 /* we reversed the order so we use prev */
1752 aicon
= aicon
->prev
;
1759 /* arrange miniwindows */
1761 wwin
= scr
->focused_window
;
1762 /* reverse them to avoid unnecessarily shuffling */
1763 while (wwin
&& wwin
->prev
)
1767 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1768 (wwin
->frame
->workspace
==scr
->current_workspace
||
1769 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1771 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1772 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1774 if (wPreferences
.no_animations
) {
1775 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1777 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1778 wwin
->icon_y
, X
, Y
);
1781 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1782 #endif /* ANIMATIONS */
1790 wwin
->flags
.icon_moved
= 0;
1792 /* we reversed the order, so we use next */
1803 wSelectWindow(WWindow
*wwin
, Bool flag
)
1805 WScreen
*scr
= wwin
->screen_ptr
;
1808 wwin
->flags
.selected
= 1;
1809 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1811 if (WFLAGP(wwin
, no_border
)) {
1812 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1813 FRAME_BORDER_WIDTH
);
1816 if (!scr
->selected_windows
)
1817 scr
->selected_windows
= WMCreateArray(4);
1818 WMAddToArray(scr
->selected_windows
, wwin
);
1820 wwin
->flags
.selected
= 0;
1821 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1822 scr
->frame_border_pixel
);
1824 if (WFLAGP(wwin
, no_border
)) {
1825 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1828 if (scr
->selected_windows
) {
1829 WMRemoveFromArray(scr
->selected_windows
, wwin
);
1836 wMakeWindowVisible(WWindow
*wwin
)
1838 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1839 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1841 if (wwin
->flags
.shaded
) {
1842 wUnshadeWindow(wwin
);
1844 if (wwin
->flags
.hidden
) {
1847 app
= wApplicationOf(wwin
->main_window
);
1849 /* trick to get focus to this window */
1850 app
->last_focused
= wwin
;
1851 wUnhideApplication(app
, False
, False
);
1854 if (wwin
->flags
.miniaturized
) {
1855 wDeiconifyWindow(wwin
);
1857 if (!WFLAGP(wwin
, no_focusable
))
1858 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1859 wRaiseFrame(wwin
->frame
->core
);