1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 #include <X11/Xutil.h>
36 #include "WindowMaker.h"
43 #include "application.h"
49 #include "winspector.h"
51 #include "workspace.h"
65 /****** Global Variables ******/
66 extern Time LastTimestamp
;
67 extern Time LastFocusChange
;
69 extern Cursor wCursor
[WCUR_LAST
];
71 extern WPreferences wPreferences
;
73 extern Atom _XA_WM_TAKE_FOCUS
;
75 /******* Local Variables *******/
80 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
81 {SHADE_STEPS_F
, SHADE_DELAY_F
},
82 {SHADE_STEPS_M
, SHADE_DELAY_M
},
83 {SHADE_STEPS_S
, SHADE_DELAY_S
},
84 {SHADE_STEPS_U
, SHADE_DELAY_U
}};
86 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
87 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
90 static int ignoreTimestamp
=0;
95 processEvents(int event_count
)
100 * This is a hack. When animations are enabled, processing of
101 * events ocurred during a animation are delayed until it's end.
102 * Calls that consider the TimeStamp, like XSetInputFocus(), will
103 * fail because the TimeStamp is too old. Then, for example, if
104 * the user changes window focus while a miniaturize animation is
105 * in course, the window will not get focus properly after the end
106 * of the animation. This tries to workaround it by passing CurrentTime
107 * as the TimeStamp for XSetInputFocus() for all events ocurred during
111 while (XPending(dpy
) && event_count
--) {
112 WMNextEvent(dpy
, &event
);
113 WMHandleEvent(&event
);
117 #endif /* ANIMATIONS */
121 *----------------------------------------------------------------------
123 * Changes the window focus to the one passed as argument.
124 * If the window to focus is not already focused, it will be brought
125 * to the head of the list of windows. Previously focused window is
129 * Window list may be reordered and the window focus is changed.
131 *----------------------------------------------------------------------
134 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
136 WWindow
*focused
=scr
->focused_window
;
137 WWindow
*owner
= NULL
;
138 int timestamp
=LastTimestamp
;
139 WApplication
*oapp
=NULL
, *napp
=NULL
;
142 LastFocusChange
= timestamp
;
147 timestamp
= CurrentTime
;
150 oapp
= wApplicationOf(focused
->main_window
);
153 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
155 wWindowUnfocus(focused
);
158 wAppMenuUnmap(oapp
->menu
);
160 wApplicationDeactivate(oapp
);
164 wKWMUpdateActiveWindowHint(scr
);
165 wKWMSendEventMessage(NULL
, WKWMFocusWindow
);
169 wasfocused
= wwin
->flags
.focused
;
170 napp
= wApplicationOf(wwin
->main_window
);
172 /* remember last workspace where the app has been */
174 napp
->last_workspace
= wwin
->screen_ptr
->current_workspace
;
176 if (WFLAGP(wwin
, no_focusable
))
179 if (wwin
->flags
.mapped
) {
180 /* install colormap if colormap mode is lock mode */
181 if (wPreferences
.colormap_mode
==WKF_CLICK
)
182 wColormapInstallForWindow(scr
, wwin
);
184 /* set input focus */
185 switch (wwin
->focus_mode
) {
187 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
191 case WFM_LOCALLY_ACTIVE
:
192 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
195 case WFM_GLOBALLY_ACTIVE
:
199 if (wwin
->protocols
.TAKE_FOCUS
) {
200 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
204 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
207 /* if this is not the focused window focus it */
211 if (wwin
->client_win
== focused
->transient_for
)
212 wwin
->flags
.semi_focused
= 0;
213 else if (wwin
->transient_for
== focused
->client_win
)
214 focused
->flags
.semi_focused
= 1;
216 if (wwin
->transient_for
217 && wwin
->transient_for
== focused
->transient_for
) {
218 owner
= wWindowFor(wwin
->transient_for
);
219 if (owner
&& owner
->flags
.semi_focused
) {
221 /* this is to override the unfocusing of the mainwindow
222 * in the next wWindowUnfocus() and avoid flickering */
223 owner
->flags
.semi_focused
= 0;
226 /* unfocus previous window */
227 wWindowUnfocus(focused
);
229 owner
->flags
.semi_focused
= 1;
231 /* change the focus window list order */
233 wwin
->prev
->next
=wwin
->next
;
235 wwin
->next
->prev
=wwin
->prev
;
237 wwin
->prev
= focused
;
238 focused
->next
= wwin
;
240 scr
->focused_window
= wwin
;
242 if (oapp
&& oapp
!= napp
) {
243 wAppMenuUnmap(oapp
->menu
);
245 wApplicationDeactivate(oapp
);
249 if ((owner
=wWindowFor(wwin
->transient_for
))
250 && !owner
->flags
.semi_focused
) {
251 owner
->flags
.semi_focused
= 1;
252 wWindowUnfocus(owner
);
255 if (napp
&& !wasfocused
) {
256 wAppMenuMap(napp
->menu
, wwin
);
258 wApplicationActivate(napp
);
262 wKWMUpdateActiveWindowHint(scr
);
263 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
270 wShadeWindow(WWindow
*wwin
)
272 XWindowAttributes attribs
;
273 time_t time0
= time(NULL
);
278 if (wwin
->flags
.shaded
)
281 XLowerWindow(dpy
, wwin
->client_win
);
284 wSoundPlay(WMSOUND_SHADE
);
288 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
289 && !wPreferences
.no_animations
) {
290 /* do the shading animation */
291 h
= wwin
->frame
->core
->height
;
294 w
= wwin
->frame
->core
->width
;
295 y
= wwin
->frame
->top_width
;
296 while (h
>wwin
->frame
->top_width
+1) {
297 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
298 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
301 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
305 wusleep(SHADE_DELAY
*1000L);
309 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
311 #endif /* ANIMATIONS */
314 wwin
->flags
.skip_next_animation
= 0;
315 XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
);
316 wwin
->flags
.shaded
=1;
317 wwin
->flags
.mapped
=0;
318 /* prevent window withdrawal when getting UnmapNotify */
319 XSelectInput(dpy
, wwin
->client_win
,
320 attribs
.your_event_mask
& ~StructureNotifyMask
);
321 XUnmapWindow(dpy
, wwin
->client_win
);
322 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
324 /* for the client it's just like iconification */
325 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
326 wwin
->frame
->top_width
-1);
328 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
329 + wwin
->frame
->top_width
;
330 wWindowSynthConfigureNotify(wwin
);
333 wClientSetState(wwin, IconicState, None);
337 wGNOMEUpdateClientStateHint(wwin
, False
);
340 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
341 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
343 /* update window list to reflect shaded state */
344 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
347 if (!wwin
->screen_ptr
->flags
.startup
) {
348 /* Look at processEvents() for reason of this code. */
350 processEvents(XPending(dpy
));
357 wUnshadeWindow(WWindow
*wwin
)
359 time_t time0
= time(NULL
);
362 #endif /* ANIMATIONS */
365 if (!wwin
->flags
.shaded
)
368 wwin
->flags
.shaded
=0;
369 wwin
->flags
.mapped
=1;
370 XMapWindow(dpy
, wwin
->client_win
);
373 wSoundPlay(WMSOUND_UNSHADE
);
377 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
378 /* do the shading animation */
379 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
380 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
381 s
= abs(y
)/SHADE_STEPS
;
383 w
= wwin
->frame
->core
->width
;
384 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
386 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
387 + wwin
->frame
->bottom_width
) {
388 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
389 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
392 wusleep(SHADE_DELAY
*2000L/3);
396 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
400 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
402 #endif /* ANIMATIONS */
404 wwin
->flags
.skip_next_animation
= 0;
405 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
406 wwin
->frame
->top_width
+ wwin
->client
.height
407 + wwin
->frame
->bottom_width
);
409 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
410 wWindowSynthConfigureNotify(wwin
);
413 wClientSetState(wwin, NormalState, None);
415 /* if the window is focused, set the focus again as it was disabled during
417 if (wwin
->flags
.focused
)
418 wSetFocusTo(wwin
->screen_ptr
, wwin
);
421 wGNOMEUpdateClientStateHint(wwin
, False
);
424 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
425 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
428 /* update window list to reflect unshaded state */
429 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
435 wMaximizeWindow(WWindow
*wwin
, int directions
)
437 int new_width
, new_height
, new_x
, new_y
;
438 WArea usableArea
= wwin
->screen_ptr
->totalUsableArea
;
440 if (wwin
->flags
.shaded
) {
441 wwin
->flags
.skip_next_animation
= 1;
442 wUnshadeWindow(wwin
);
444 wwin
->flags
.maximized
= directions
;
445 wwin
->old_geometry
.width
= wwin
->client
.width
;
446 wwin
->old_geometry
.height
= wwin
->client
.height
;
447 wwin
->old_geometry
.x
= wwin
->frame_x
;
448 wwin
->old_geometry
.y
= wwin
->frame_y
;
451 wKWMUpdateClientGeometryRestore(wwin
);
454 if (directions
& MAX_HORIZONTAL
) {
456 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
457 new_x
= usableArea
.x1
;
461 new_x
= wwin
->frame_x
;
462 new_width
= wwin
->frame
->core
->width
;
466 if (directions
& MAX_VERTICAL
) {
468 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
469 new_y
= usableArea
.y1
;
473 new_y
= wwin
->frame_y
;
474 new_height
= wwin
->frame
->core
->height
;
477 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
479 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
480 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
483 wGNOMEUpdateClientStateHint(wwin
, False
);
486 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
487 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
491 wSoundPlay(WMSOUND_MAXIMIZE
);
497 wUnmaximizeWindow(WWindow
*wwin
)
499 int restore_x
, restore_y
;
501 if (!wwin
->flags
.maximized
)
504 if (wwin
->flags
.shaded
) {
505 wwin
->flags
.skip_next_animation
= 1;
506 wUnshadeWindow(wwin
);
508 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
509 wwin
->old_geometry
.x
: wwin
->frame_x
;
510 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
511 wwin
->old_geometry
.y
: wwin
->frame_y
;
512 wwin
->flags
.maximized
= 0;
513 wWindowConfigure(wwin
, restore_x
, restore_y
,
514 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
517 wGNOMEUpdateClientStateHint(wwin
, False
);
520 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
521 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
525 wSoundPlay(WMSOUND_UNMAXIMIZE
);
531 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
532 int fx
, int fy
, int fw
, int fh
, int steps
)
534 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
535 float cx
, cy
, cw
, ch
;
536 float xstep
, ystep
, wstep
, hstep
;
539 float angle
, final_angle
, delta
;
541 xstep
= (float)(fx
-x
)/steps
;
542 ystep
= (float)(fy
-y
)/steps
;
543 wstep
= (float)(fw
-w
)/steps
;
544 hstep
= (float)(fh
-h
)/steps
;
551 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
552 delta
= (float)(final_angle
/FRAMES
);
553 for (angle
=0;; angle
+=delta
) {
554 if (angle
> final_angle
)
557 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
558 dch
= (ch
/2) * cos(angle
);
561 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
562 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
563 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
564 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
565 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
568 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
570 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
571 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
574 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
580 if (angle
>= final_angle
)
590 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
591 int fx
, int fy
, int fw
, int fh
, int steps
)
593 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
594 float cx
, cy
, cw
, ch
;
595 float xstep
, ystep
, wstep
, hstep
;
597 float angle
, final_angle
, a
, d
, delta
;
604 xstep
= (float)(fx
-x
)/steps
;
605 ystep
= (float)(fy
-y
)/steps
;
606 wstep
= (float)(fw
-w
)/steps
;
607 hstep
= (float)(fh
-h
)/steps
;
614 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
615 delta
= (float)(final_angle
/FRAMES
);
616 for (angle
=0;; angle
+=delta
) {
617 if (angle
> final_angle
)
621 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
623 points
[0].x
= cx
+cos(angle
-a
)*d
;
624 points
[0].y
= cy
+sin(angle
-a
)*d
;
625 points
[1].x
= cx
+cos(angle
+a
)*d
;
626 points
[1].y
= cy
+sin(angle
+a
)*d
;
627 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
628 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
629 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
630 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
631 points
[4].x
= cx
+cos(angle
-a
)*d
;
632 points
[4].y
= cy
+sin(angle
-a
)*d
;
634 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
636 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
637 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
640 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
646 if (angle
>= final_angle
)
656 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
657 int fx
, int fy
, int fw
, int fh
, int steps
)
659 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
660 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
661 float xstep
, ystep
, wstep
, hstep
;
664 xstep
= (float)(fx
-x
)/steps
;
665 ystep
= (float)(fy
-y
)/steps
;
666 wstep
= (float)(fw
-w
)/steps
;
667 hstep
= (float)(fh
-h
)/steps
;
669 for (j
=0; j
<FRAMES
; j
++) {
676 for (i
=0; i
<steps
; i
++) {
677 for (j
=0; j
<FRAMES
; j
++) {
678 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
679 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
682 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
683 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
685 for (j
=0; j
<FRAMES
; j
++) {
686 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
687 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
702 for (j
=0; j
<FRAMES
; j
++) {
703 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
704 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
707 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
708 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
710 for (j
=0; j
<FRAMES
; j
++) {
711 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
712 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
721 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
722 int fx
, int fy
, int fw
, int fh
, int hiding
)
724 int style
= wPreferences
.iconification_style
; /* Catch the value */
727 if (style
== WIS_NONE
)
730 if (style
== WIS_RANDOM
) {
734 k
= (hiding
? 2 : 3);
737 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
739 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
742 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
744 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
748 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
750 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
754 #endif /* ANIMATIONS */
762 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
763 WMHandleEvent(&tmpev
);
768 unmapTransientsFor(WWindow
*wwin
)
771 XWindowAttributes attribs
;
774 tmp
= wwin
->screen_ptr
->focused_window
;
776 /* unmap the transients for this transient */
777 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
778 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
779 || tmp
->flags
.shaded
)) {
780 unmapTransientsFor(tmp
);
781 XGetWindowAttributes(dpy
, tmp
->client_win
, &attribs
);
782 tmp
->flags
.miniaturized
=1;
783 if (!tmp
->flags
.shaded
) {
785 XSelectInput(dpy
, tmp
->client_win
,
786 attribs
.your_event_mask
& ~StructureNotifyMask
);
787 XUnmapWindow(dpy
, tmp
->client_win
);
788 XSelectInput(dpy
, tmp
->client_win
, attribs
.your_event_mask
);
790 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
791 if (!tmp
->flags
.shaded
)
792 wClientSetState(tmp
, IconicState
, None
);
794 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
795 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
796 tmp
->flags
.kwm_hidden_for_modules
= 1;
799 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
808 mapTransientsFor(WWindow
*wwin
)
812 tmp
= wwin
->screen_ptr
->focused_window
;
814 /* recursively map the transients for this transient */
815 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
816 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
817 && tmp
->icon
==NULL
) {
818 mapTransientsFor(tmp
);
819 tmp
->flags
.miniaturized
=0;
820 if (!tmp
->flags
.shaded
) {
822 XMapWindow(dpy
, tmp
->client_win
);
824 XMapWindow(dpy
, tmp
->frame
->core
->window
);
825 tmp
->flags
.semi_focused
= 0;
826 if (!tmp
->flags
.shaded
)
827 wClientSetState(tmp
, NormalState
, None
);
829 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
830 if (tmp
->flags
.kwm_hidden_for_modules
) {
831 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
832 tmp
->flags
.kwm_hidden_for_modules
= 0;
836 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
845 setupIconGrabs(WIcon
*icon
)
847 /* setup passive grabs on the icon */
848 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
849 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
850 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
851 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
852 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
853 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
859 recursiveTransientFor(WWindow
*wwin
)
866 /* hackish way to detect transient_for cycle */
867 i
= wwin
->screen_ptr
->window_count
+1;
869 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
870 wwin
= wWindowFor(wwin
->transient_for
);
874 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
884 removeIconGrabs(WIcon
*icon
)
886 /* remove passive grabs on the icon */
887 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
888 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
889 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
895 wIconifyWindow(WWindow
*wwin
)
897 XWindowAttributes attribs
;
901 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
902 /* the window doesn't exist anymore */
906 if (wwin
->flags
.miniaturized
)
909 if (wwin
->transient_for
!=None
) {
910 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
912 if (owner
&& owner
->flags
.miniaturized
)
916 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
918 /* if the window is in another workspace, simplify process */
920 /* icon creation may take a while */
921 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
922 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
923 GrabModeAsync
, None
, None
, CurrentTime
);
926 if (!wwin
->flags
.icon_moved
) {
927 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
929 wwin
->icon
= wIconCreate(wwin
);
931 wwin
->flags
.miniaturized
=1;
932 wwin
->flags
.mapped
=0;
934 /* unmap transients */
936 unmapTransientsFor(wwin
);
940 wSoundPlay(WMSOUND_ICONIFY
);
943 XUngrabPointer(dpy
, CurrentTime
);
944 /* prevent window withdrawal when getting UnmapNotify */
945 XSelectInput(dpy
, wwin
->client_win
,
946 attribs
.your_event_mask
& ~StructureNotifyMask
);
947 XUnmapWindow(dpy
, wwin
->client_win
);
948 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
949 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
950 /* let all Expose events arrive so that we can repaint
951 * something before the animation starts (and the server is grabbed) */
953 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
956 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
957 && !wPreferences
.no_animations
) {
958 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
959 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
960 wwin
->icon_x
, wwin
->icon_y
,
961 wwin
->icon
->core
->width
, wwin
->icon
->core
->height
,
967 wwin
->flags
.skip_next_animation
= 0;
968 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
969 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
971 XMapWindow(dpy
, wwin
->icon
->core
->window
);
972 AddToStackList(wwin
->icon
->core
);
974 wLowerFrame(wwin
->icon
->core
);
977 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
978 setupIconGrabs(wwin
->icon
);
979 if ((wwin
->flags
.focused
980 || (owner
&& wwin
->client_win
== owner
->client_win
))
981 && wPreferences
.focus_mode
==WKF_CLICK
) {
986 if (!WFLAGP(tmp
, no_focusable
)
987 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
))
991 wSetFocusTo(wwin
->screen_ptr
, tmp
);
992 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
993 wSetFocusTo(wwin
->screen_ptr
, NULL
);
997 if (!wwin
->screen_ptr
->flags
.startup
) {
998 Window clientwin
= wwin
->client_win
;
1001 processEvents(XPending(dpy
));
1003 /* the window can disappear while doing the processEvents() */
1004 if (!wWindowFor(clientwin
))
1011 if (wwin
->flags
.selected
)
1012 wIconSelect(wwin
->icon
);
1015 wGNOMEUpdateClientStateHint(wwin
, False
);
1018 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1019 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1022 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1028 wDeiconifyWindow(WWindow
*wwin
)
1030 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1032 if (!wwin
->flags
.miniaturized
)
1035 if (wwin
->transient_for
!= None
) {
1036 WWindow
*owner
= recursiveTransientFor(wwin
);
1037 wDeiconifyWindow(owner
);
1038 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1039 wRaiseFrame(wwin
->frame
->core
);
1043 wwin
->flags
.miniaturized
=0;
1044 if (!wwin
->flags
.shaded
)
1045 wwin
->flags
.mapped
=1;
1047 if (wwin
->icon
->selected
)
1048 wIconSelect(wwin
->icon
);
1050 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1053 wSoundPlay(WMSOUND_DEICONIFY
);
1056 /* if the window is in another workspace, do it silently */
1058 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1059 && !wwin
->flags
.skip_next_animation
) {
1060 animateResize(wwin
->screen_ptr
, wwin
->icon_x
, wwin
->icon_y
,
1061 wwin
->icon
->core
->width
, wwin
->icon
->core
->height
,
1062 wwin
->frame_x
, wwin
->frame_y
,
1063 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1066 #endif /* ANIMATIONS */
1067 wwin
->flags
.skip_next_animation
= 0;
1069 if (!wwin
->flags
.shaded
) {
1070 XMapWindow(dpy
, wwin
->client_win
);
1072 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1073 wRaiseFrame(wwin
->frame
->core
);
1074 if (!wwin
->flags
.shaded
) {
1075 wClientSetState(wwin
, NormalState
, None
);
1077 mapTransientsFor(wwin
);
1078 RemoveFromStackList(wwin
->icon
->core
);
1079 removeIconGrabs(wwin
->icon
);
1080 wIconDestroy(wwin
->icon
);
1084 if (wPreferences
.focus_mode
==WKF_CLICK
1085 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1086 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1089 if (!wwin
->screen_ptr
->flags
.startup
) {
1090 Window clientwin
= wwin
->client_win
;
1093 processEvents(XPending(dpy
));
1095 if (!wWindowFor(clientwin
))
1100 if (wPreferences
.auto_arrange_icons
) {
1101 wArrangeIcons(wwin
->screen_ptr
, True
);
1105 wGNOMEUpdateClientStateHint(wwin
, False
);
1108 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1109 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1112 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1118 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1120 XWindowAttributes attribs
;
1123 if (wwin
->flags
.miniaturized
) {
1124 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1125 wwin
->flags
.hidden
= 1;
1126 wwin
->icon
->mapped
= 0;
1128 wGNOMEUpdateClientStateHint(wwin
, False
);
1131 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1136 if (wwin
->flags
.inspector_open
) {
1137 WWindow
*pwin
= wwin
->inspector
->frame
;
1139 XGetWindowAttributes(dpy
, pwin
->client_win
, &attribs
);
1140 pwin
->flags
.hidden
= 1;
1141 pwin
->flags
.mapped
= 0;
1142 /* prevent window withdrawal when getting UnmapNotify */
1143 XSelectInput(dpy
, pwin
->client_win
,
1144 attribs
.your_event_mask
& ~StructureNotifyMask
);
1145 XUnmapWindow(dpy
, pwin
->client_win
);
1146 XSelectInput(dpy
, pwin
->client_win
, attribs
.your_event_mask
);
1148 XUnmapWindow(dpy
, pwin
->frame
->core
->window
);
1149 wClientSetState(pwin
, IconicState
, icon
->icon_win
);
1152 XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
);
1154 wwin
->flags
.hidden
= 1;
1155 wwin
->flags
.mapped
= 0;
1157 /* prevent window withdrawal when getting UnmapNotify */
1158 XSelectInput(dpy
, wwin
->client_win
,
1159 attribs
.your_event_mask
& ~StructureNotifyMask
);
1160 XUnmapWindow(dpy
, wwin
->client_win
);
1161 XSelectInput(dpy
, wwin
->client_win
, attribs
.your_event_mask
);
1163 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
1164 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1167 wSoundPlay(WMSOUND_HIDE
);
1170 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1171 !wwin
->flags
.skip_next_animation
&& animate
) {
1172 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1173 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1174 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1178 wwin
->flags
.skip_next_animation
= 0;
1181 wGNOMEUpdateClientStateHint(wwin
, False
);
1184 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1191 wHideOtherApplications(WWindow
*awin
)
1195 #ifdef REDUCE_APPICONS
1196 char *tinstance
, *tclass
;
1197 unsigned int brokenwin
= 0, match
= 0;
1202 wwin
= awin
->screen_ptr
->focused_window
;
1204 #ifdef REDUCE_APPICONS
1205 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1211 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1212 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1213 && !wwin
->flags
.internal_window
1214 && (!wwin
->flags
.inspector_open
|| wwin
->inspector
->frame
!=awin
)
1215 && !WFLAGP(wwin
, no_hide_others
)) {
1217 #ifdef REDUCE_APPICONS
1220 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1222 if ((tclass
= wwin
->wm_class
) == NULL
)
1224 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1225 (strcmp(awin
->wm_class
, tclass
) == 0) )
1230 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1231 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1232 wwin
->flags
.skip_next_animation
= 1;
1233 wIconifyWindow(wwin
);
1235 } else if (wwin
->main_window
!=None
1236 #ifndef REDUCE_APPICONS
1237 && awin
->main_window
!= wwin
->main_window
) {
1239 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1241 tapp
= wApplicationOf(wwin
->main_window
);
1243 tapp
->flags
.skip_next_animation
= 1;
1244 wHideApplication(tapp
);
1246 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1247 wwin
->flags
.skip_next_animation
= 1;
1248 wIconifyWindow(wwin
);
1256 wSetFocusTo(awin->screen_ptr, awin);
1263 wHideApplication(WApplication
*wapp
)
1265 #ifdef REDUCE_APPICONS
1267 char *tinstance
, *tclass
;
1268 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1275 wwarning("trying to hide a non grouped window");
1278 if (!wapp
->main_window_desc
) {
1279 wwarning("group leader not found for window group");
1282 #ifdef REDUCE_APPICONS
1283 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1284 (wapp
->main_window_desc
->wm_class
== NULL
))
1287 scr
= wapp
->main_window_desc
->screen_ptr
;
1289 wlist
= scr
->focused_window
;
1293 if (wlist
->main_window
== wapp
->main_window
)
1294 wapp
->last_focused
= wlist
;
1296 wapp
->last_focused
= NULL
;
1298 #ifdef REDUCE_APPICONS
1299 matchwmhints
= matchworkspace
= 0;
1301 tapp
= wApplicationOf(wlist
->main_window
);
1302 tinstance
= tclass
= NULL
;
1304 if (tapp
->main_window_desc
) {
1305 tinstance
= tapp
->main_window_desc
->wm_instance
;
1306 tclass
= tapp
->main_window_desc
->wm_class
;
1309 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1310 /* Should never reach here */
1314 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1315 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1319 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1322 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1328 if (wlist
->main_window
== wapp
->main_window
) {
1330 if (wlist
->flags
.focused
) {
1334 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1335 wapp
->app_icon
->y_pos
, wlist
,
1336 !wapp
->flags
.skip_next_animation
);
1338 wlist
= wlist
->prev
;
1341 wapp
->flags
.skip_next_animation
= 0;
1344 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1345 wlist
= scr
->focused_window
;
1347 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1348 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1350 wlist
= wlist
->prev
;
1352 wSetFocusTo(scr
, wlist
);
1354 wSetFocusTo(scr
, NULL
);
1358 wapp
->flags
.hidden
= 1;
1360 if(wPreferences
.auto_arrange_icons
) {
1361 wArrangeIcons(scr
, True
);
1369 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1370 int bringToCurrentWS
)
1372 if (bringToCurrentWS
)
1373 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1375 wwin
->flags
.hidden
=0;
1376 wwin
->flags
.mapped
=1;
1379 wSoundPlay(WMSOUND_UNHIDE
);
1382 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1384 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1385 icon
->core
->width
, icon
->core
->height
,
1386 wwin
->frame_x
, wwin
->frame_y
,
1387 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1391 wwin
->flags
.skip_next_animation
= 0;
1392 XMapWindow(dpy
, wwin
->client_win
);
1393 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1394 wClientSetState(wwin
, NormalState
, None
);
1395 wRaiseFrame(wwin
->frame
->core
);
1396 if (wwin
->flags
.inspector_open
) {
1397 WWindow
*pwin
= wwin
->inspector
->frame
;
1399 pwin
->flags
.hidden
= 0;
1400 pwin
->flags
.mapped
= 1;
1401 XMapWindow(dpy
, pwin
->client_win
);
1402 XMapWindow(dpy
, pwin
->frame
->core
->window
);
1403 wClientSetState(pwin
, NormalState
, None
);
1407 wGNOMEUpdateClientStateHint(wwin
, False
);
1410 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1416 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1419 WWindow
*wlist
, *next
;
1420 WWindow
*focused
=NULL
;
1421 #ifdef REDUCE_APPICONS
1422 char *tinstance
, *tclass
;
1423 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1430 #ifdef REDUCE_APPICONS
1431 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1432 (wapp
->main_window_desc
->wm_instance
== NULL
))
1436 scr
= wapp
->main_window_desc
->screen_ptr
;
1437 wlist
= scr
->focused_window
;
1439 /* goto beginning of list */
1441 wlist
= wlist
->prev
;
1446 #ifndef REDUCE_APPICONS
1447 if (wlist
->main_window
== wapp
->main_window
) {
1449 matchwmhints
= matchworkspace
= 0;
1451 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1453 if ((tclass
= wlist
->wm_class
) == NULL
)
1455 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1456 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1460 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1464 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1467 if (wlist
->flags
.focused
)
1469 else if (!focused
|| !focused
->flags
.focused
)
1472 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1473 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1474 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1475 if (!wlist
->icon
->mapped
) {
1476 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1477 wlist
->icon
->mapped
= 1;
1479 wlist
->flags
.hidden
= 0;
1481 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1483 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1484 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1487 wDeiconifyWindow(wlist
);
1489 } else if (wlist
->flags
.hidden
) {
1490 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1491 wapp
->app_icon
->y_pos
, wlist
,
1492 !wapp
->flags
.skip_next_animation
,
1495 if (bringToCurrentWS
1496 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1497 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1499 wRaiseFrame(wlist
->frame
->core
);
1505 wapp
->flags
.skip_next_animation
= 0;
1506 wapp
->flags
.hidden
= 0;
1509 wSetFocusTo(scr
, focused
);
1510 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1511 wSetFocusTo(scr
, wapp
->last_focused
);
1512 wapp
->last_focused
= NULL
;
1513 if (wPreferences
.auto_arrange_icons
) {
1514 wArrangeIcons(scr
, True
);
1521 wShowAllWindows(WScreen
*scr
)
1523 WWindow
*wwin
, *old_foc
;
1526 old_foc
= wwin
= scr
->focused_window
;
1528 if (!wwin
->flags
.internal_window
&&
1529 (scr
->current_workspace
== wwin
->frame
->workspace
1530 || IS_OMNIPRESENT(wwin
))) {
1531 if (wwin
->flags
.miniaturized
) {
1532 wwin
->flags
.skip_next_animation
= 1;
1533 wDeiconifyWindow(wwin
);
1534 } else if (wwin
->flags
.hidden
) {
1535 wapp
= wApplicationOf(wwin
->main_window
);
1537 wUnhideApplication(wapp
, False
, False
);
1539 wwin
->flags
.skip_next_animation
= 1;
1540 wDeiconifyWindow(wwin
);
1546 wSetFocusTo(scr
, old_foc
);
1547 /*wRaiseFrame(old_foc->frame->core);*/
1552 wRefreshDesktop(WScreen
*scr
)
1555 XSetWindowAttributes attr
;
1557 attr
.backing_store
= NotUseful
;
1558 attr
.save_under
= False
;
1559 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1560 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1561 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1563 XMapRaised(dpy
, win
);
1564 XDestroyWindow(dpy
, win
);
1570 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1574 int pf
; /* primary axis */
1575 int sf
; /* secondary axis */
1579 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1583 int isize
= wPreferences
.icon_size
;
1586 * Find out screen boundaries.
1590 sx2
= scr
->scr_width
;
1591 sy2
= scr
->scr_height
;
1593 if (scr
->dock
->on_right_side
)
1594 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1596 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1599 sw
= isize
* (scr
->scr_width
/isize
);
1600 sh
= isize
* (scr
->scr_height
/isize
);
1601 fullW
= (sx2
-sx1
)/isize
;
1602 fullH
= (sy2
-sy1
)/isize
;
1604 /* icon yard boundaries */
1605 if (wPreferences
.icon_yard
& IY_VERT
) {
1612 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1619 if (wPreferences
.icon_yard
& IY_TOP
) {
1627 /* arrange icons putting the most recently focused window
1628 * as the last icon */
1629 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1630 : xo + xs*(pi*isize))
1631 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1632 : yo + ys*(si*isize))
1634 /* arrange application icons */
1635 aicon
= scr
->app_icon_list
;
1636 /* reverse them to avoid unnecessarily sliding of icons */
1637 while (aicon
&& aicon
->next
)
1638 aicon
= aicon
->next
;
1643 if (!aicon
->docked
) {
1644 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1646 if (!wPreferences
.no_animations
) {
1647 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1650 #endif /* ANIMATIONS */
1652 wAppIconMove(aicon
, X
, Y
);
1655 /* we reversed the order so we use prev */
1656 aicon
= aicon
->prev
;
1663 /* arrange miniwindows */
1665 wwin
= scr
->focused_window
;
1666 /* reverse them to avoid unnecessarily shuffling */
1667 while (wwin
&& wwin
->prev
)
1671 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1672 (wwin
->frame
->workspace
==scr
->current_workspace
||
1673 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1675 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1676 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1678 if (wPreferences
.no_animations
) {
1679 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1681 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1682 wwin
->icon_y
, X
, Y
);
1685 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1686 #endif /* ANIMATIONS */
1690 wwin
->flags
.icon_moved
= 0;
1694 /* we reversed the order, so we use next */
1705 wSelectWindow(WWindow
*wwin
, Bool flag
)
1707 WScreen
*scr
= wwin
->screen_ptr
;
1709 wwin
->flags
.selected
= 1;
1710 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1711 scr
->selected_windows
= list_cons(wwin
, scr
->selected_windows
);
1713 wwin
->flags
.selected
= 0;
1714 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1715 scr
->frame_border_pixel
);
1716 scr
->selected_windows
= list_remove_elem(scr
->selected_windows
, wwin
);
1722 wMakeWindowVisible(WWindow
*wwin
)
1724 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1726 if (wwin
->flags
.shaded
) {
1727 wUnshadeWindow(wwin
);
1729 if (wwin
->flags
.hidden
) {
1730 wUnhideApplication(wApplicationOf(wwin
->main_window
), False
, False
);
1731 } else if (wwin
->flags
.miniaturized
) {
1732 wDeiconifyWindow(wwin
);
1734 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1735 wRaiseFrame(wwin
->frame
->core
);