1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998, 1999 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #include <X11/Xutil.h>
35 #include "WindowMaker.h"
42 #include "application.h"
48 #include "winspector.h"
49 #include "workspace.h"
63 /****** Global Variables ******/
64 extern Time LastTimestamp
;
65 extern Time LastFocusChange
;
67 extern Cursor wCursor
[WCUR_LAST
];
69 extern WPreferences wPreferences
;
71 extern Atom _XA_WM_TAKE_FOCUS
;
74 /******* Local Variables *******/
79 {SHADE_STEPS_UF
, SHADE_DELAY_UF
},
80 {SHADE_STEPS_F
, SHADE_DELAY_F
},
81 {SHADE_STEPS_M
, SHADE_DELAY_M
},
82 {SHADE_STEPS_S
, SHADE_DELAY_S
},
83 {SHADE_STEPS_U
, SHADE_DELAY_U
}};
85 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
86 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
89 static int ignoreTimestamp
=0;
94 processEvents(int event_count
)
99 * This is a hack. When animations are enabled, processing of
100 * events ocurred during a animation are delayed until it's end.
101 * Calls that consider the TimeStamp, like XSetInputFocus(), will
102 * fail because the TimeStamp is too old. Then, for example, if
103 * the user changes window focus while a miniaturize animation is
104 * in course, the window will not get focus properly after the end
105 * of the animation. This tries to workaround it by passing CurrentTime
106 * as the TimeStamp for XSetInputFocus() for all events ocurred during
110 while (XPending(dpy
) && event_count
--) {
111 WMNextEvent(dpy
, &event
);
112 WMHandleEvent(&event
);
116 #endif /* ANIMATIONS */
121 *----------------------------------------------------------------------
123 * Changes the window focus to the one passed as argument.
124 * If the window to focus is not already focused, it will be brought
125 * to the head of the list of windows. Previously focused window is
129 * Window list may be reordered and the window focus is changed.
131 *----------------------------------------------------------------------
134 wSetFocusTo(WScreen
*scr
, WWindow
*wwin
)
136 static WScreen
*old_scr
=NULL
;
138 WWindow
*old_focused
;
139 WWindow
*focused
=scr
->focused_window
;
140 int timestamp
=LastTimestamp
;
141 WApplication
*oapp
=NULL
, *napp
=NULL
;
146 old_focused
=old_scr
->focused_window
;
148 LastFocusChange
= timestamp
;
151 * This is a hack, because XSetInputFocus() should have a proper
152 * timestamp instead of CurrentTime but it seems that some times
153 * clients will not receive focus properly that way.
156 timestamp
= CurrentTime
;
159 oapp
= wApplicationOf(old_focused
->main_window
);
162 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
163 if (old_focused
&& !old_focused
->flags
.is_gnustep
) {
164 wWindowUnfocus(old_focused
);
167 wAppMenuUnmap(oapp
->menu
);
169 wApplicationDeactivate(oapp
);
173 wKWMUpdateActiveWindowHint(scr
);
174 wKWMSendEventMessage(NULL
, WKWMFocusWindow
);
177 } else if (old_scr
!= scr
&& old_focused
&& !old_focused
->flags
.is_gnustep
) {
178 wWindowUnfocus(old_focused
);
181 wasfocused
= wwin
->flags
.focused
;
182 napp
= wApplicationOf(wwin
->main_window
);
184 /* remember last workspace where the app has been */
186 napp
->last_workspace
= wwin
->screen_ptr
->current_workspace
;
188 if (wwin
->flags
.mapped
&& !WFLAGP(wwin
, no_focusable
)) {
189 /* install colormap if colormap mode is lock mode */
190 if (wPreferences
.colormap_mode
==WKF_CLICK
)
191 wColormapInstallForWindow(scr
, wwin
);
193 /* set input focus */
194 switch (wwin
->focus_mode
) {
196 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
200 case WFM_LOCALLY_ACTIVE
:
201 XSetInputFocus(dpy
, wwin
->client_win
, RevertToParent
, timestamp
);
204 case WFM_GLOBALLY_ACTIVE
:
208 if (wwin
->protocols
.TAKE_FOCUS
) {
209 wClientSendProtocol(wwin
, _XA_WM_TAKE_FOCUS
, timestamp
);
213 XSetInputFocus(dpy
, scr
->no_focus_win
, RevertToParent
, timestamp
);
215 if (WFLAGP(wwin
, no_focusable
))
218 /* if this is not the focused window focus it */
220 /* change the focus window list order */
222 wwin
->prev
->next
= wwin
->next
;
225 wwin
->next
->prev
= wwin
->prev
;
227 wwin
->prev
= focused
;
228 focused
->next
= wwin
;
230 scr
->focused_window
= wwin
;
232 if (oapp
&& oapp
!= napp
) {
233 wAppMenuUnmap(oapp
->menu
);
235 wApplicationDeactivate(oapp
);
240 if (!wwin
->flags
.is_gnustep
)
241 wWindowFocus(wwin
, focused
);
243 if (napp
&& !wasfocused
) {
245 wUserMenuRefreshInstances(napp
->menu
, wwin
);
246 #endif /* USER_MENU */
248 if (wwin
->flags
.mapped
)
249 wAppMenuMap(napp
->menu
, wwin
);
251 wApplicationActivate(napp
);
255 wKWMUpdateActiveWindowHint(scr
);
256 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
264 wShadeWindow(WWindow
*wwin
)
266 time_t time0
= time(NULL
);
271 if (wwin
->flags
.shaded
)
274 XLowerWindow(dpy
, wwin
->client_win
);
277 wSoundPlay(WMSOUND_SHADE
);
281 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
282 && !wPreferences
.no_animations
) {
283 /* do the shading animation */
284 h
= wwin
->frame
->core
->height
;
287 w
= wwin
->frame
->core
->width
;
288 y
= wwin
->frame
->top_width
;
289 while (h
>wwin
->frame
->top_width
+1) {
290 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
291 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
294 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
298 wusleep(SHADE_DELAY
*1000L);
302 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
304 #endif /* ANIMATIONS */
306 wwin
->flags
.skip_next_animation
= 0;
307 wwin
->flags
.shaded
= 1;
308 wwin
->flags
.mapped
= 0;
309 /* prevent window withdrawal when getting UnmapNotify */
310 XSelectInput(dpy
, wwin
->client_win
,
311 wwin
->event_mask
& ~StructureNotifyMask
);
312 XUnmapWindow(dpy
, wwin
->client_win
);
313 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
315 /* for the client it's just like iconification */
316 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
317 wwin
->frame
->top_width
- 1);
319 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
320 + wwin
->frame
->top_width
;
321 wWindowSynthConfigureNotify(wwin
);
324 wClientSetState(wwin, IconicState, None);
328 wGNOMEUpdateClientStateHint(wwin
, False
);
331 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
332 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
334 /* update window list to reflect shaded state */
335 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
338 if (!wwin
->screen_ptr
->flags
.startup
) {
339 /* Look at processEvents() for reason of this code. */
341 processEvents(XPending(dpy
));
348 wUnshadeWindow(WWindow
*wwin
)
350 time_t time0
= time(NULL
);
353 #endif /* ANIMATIONS */
356 if (!wwin
->flags
.shaded
)
359 wwin
->flags
.shaded
= 0;
360 wwin
->flags
.mapped
= 1;
361 XMapWindow(dpy
, wwin
->client_win
);
364 wSoundPlay(WMSOUND_UNSHADE
);
368 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
369 /* do the shading animation */
370 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
371 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
372 s
= abs(y
)/SHADE_STEPS
;
374 w
= wwin
->frame
->core
->width
;
375 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
377 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
378 + wwin
->frame
->bottom_width
) {
379 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
380 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
383 wusleep(SHADE_DELAY
*2000L/3);
387 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
391 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
393 #endif /* ANIMATIONS */
395 wwin
->flags
.skip_next_animation
= 0;
396 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
397 wwin
->frame
->top_width
+ wwin
->client
.height
398 + wwin
->frame
->bottom_width
);
400 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
401 wWindowSynthConfigureNotify(wwin
);
404 wClientSetState(wwin, NormalState, None);
406 /* if the window is focused, set the focus again as it was disabled during
408 if (wwin
->flags
.focused
)
409 wSetFocusTo(wwin
->screen_ptr
, wwin
);
412 wGNOMEUpdateClientStateHint(wwin
, False
);
415 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
416 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
419 /* update window list to reflect unshaded state */
420 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
426 wMaximizeWindow(WWindow
*wwin
, int directions
)
428 int new_width
, new_height
, new_x
, new_y
;
429 WArea usableArea
= wwin
->screen_ptr
->totalUsableArea
;
432 if (WFLAGP(wwin
, no_resizable
))
436 if (WFLAGP(wwin
, full_maximize
)) {
439 usableArea
.x2
= wwin
->screen_ptr
->scr_width
;
440 usableArea
.y2
= wwin
->screen_ptr
->scr_height
;
443 if (wwin
->flags
.shaded
) {
444 wwin
->flags
.skip_next_animation
= 1;
445 wUnshadeWindow(wwin
);
447 wwin
->flags
.maximized
= directions
;
448 wwin
->old_geometry
.width
= wwin
->client
.width
;
449 wwin
->old_geometry
.height
= wwin
->client
.height
;
450 wwin
->old_geometry
.x
= wwin
->frame_x
;
451 wwin
->old_geometry
.y
= wwin
->frame_y
;
454 wKWMUpdateClientGeometryRestore(wwin
);
457 if (directions
& MAX_HORIZONTAL
) {
459 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
460 new_x
= usableArea
.x1
;
464 new_x
= wwin
->frame_x
;
465 new_width
= wwin
->frame
->core
->width
;
469 if (directions
& MAX_VERTICAL
) {
471 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
472 new_y
= usableArea
.y1
;
473 if (WFLAGP(wwin
, full_maximize
)) {
474 new_y
-= wwin
->frame
->top_width
- 1;
475 new_height
+= wwin
->frame
->bottom_width
- 3;
478 new_y
= wwin
->frame_y
;
479 new_height
= wwin
->frame
->core
->height
;
482 if (!WFLAGP(wwin
, full_maximize
)) {
483 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
486 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
487 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
490 wGNOMEUpdateClientStateHint(wwin
, False
);
493 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
494 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
498 wSoundPlay(WMSOUND_MAXIMIZE
);
504 wUnmaximizeWindow(WWindow
*wwin
)
506 int restore_x
, restore_y
;
508 if (!wwin
->flags
.maximized
)
511 if (wwin
->flags
.shaded
) {
512 wwin
->flags
.skip_next_animation
= 1;
513 wUnshadeWindow(wwin
);
515 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
516 wwin
->old_geometry
.x
: wwin
->frame_x
;
517 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
518 wwin
->old_geometry
.y
: wwin
->frame_y
;
519 wwin
->flags
.maximized
= 0;
520 wWindowConfigure(wwin
, restore_x
, restore_y
,
521 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
524 wGNOMEUpdateClientStateHint(wwin
, False
);
527 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
528 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
532 wSoundPlay(WMSOUND_UNMAXIMIZE
);
538 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
539 int fx
, int fy
, int fw
, int fh
, int steps
)
541 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
542 float cx
, cy
, cw
, ch
;
543 float xstep
, ystep
, wstep
, hstep
;
546 float angle
, final_angle
, delta
;
548 xstep
= (float)(fx
-x
)/steps
;
549 ystep
= (float)(fy
-y
)/steps
;
550 wstep
= (float)(fw
-w
)/steps
;
551 hstep
= (float)(fh
-h
)/steps
;
558 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
559 delta
= (float)(final_angle
/FRAMES
);
560 for (angle
=0;; angle
+=delta
) {
561 if (angle
> final_angle
)
564 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
565 dch
= (ch
/2) * cos(angle
);
568 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
569 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
570 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
571 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
572 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
575 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
577 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
578 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
581 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
587 if (angle
>= final_angle
)
597 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
598 int fx
, int fy
, int fw
, int fh
, int steps
)
600 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
601 float cx
, cy
, cw
, ch
;
602 float xstep
, ystep
, wstep
, hstep
;
604 float angle
, final_angle
, a
, d
, delta
;
611 xstep
= (float)(fx
-x
)/steps
;
612 ystep
= (float)(fy
-y
)/steps
;
613 wstep
= (float)(fw
-w
)/steps
;
614 hstep
= (float)(fh
-h
)/steps
;
621 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
622 delta
= (float)(final_angle
/FRAMES
);
623 for (angle
=0;; angle
+=delta
) {
624 if (angle
> final_angle
)
628 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
630 points
[0].x
= cx
+cos(angle
-a
)*d
;
631 points
[0].y
= cy
+sin(angle
-a
)*d
;
632 points
[1].x
= cx
+cos(angle
+a
)*d
;
633 points
[1].y
= cy
+sin(angle
+a
)*d
;
634 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
635 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
636 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
637 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
638 points
[4].x
= cx
+cos(angle
-a
)*d
;
639 points
[4].y
= cy
+sin(angle
-a
)*d
;
641 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
643 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
644 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
647 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
653 if (angle
>= final_angle
)
663 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
664 int fx
, int fy
, int fw
, int fh
, int steps
)
666 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
667 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
668 float xstep
, ystep
, wstep
, hstep
;
671 xstep
= (float)(fx
-x
)/steps
;
672 ystep
= (float)(fy
-y
)/steps
;
673 wstep
= (float)(fw
-w
)/steps
;
674 hstep
= (float)(fh
-h
)/steps
;
676 for (j
=0; j
<FRAMES
; j
++) {
683 for (i
=0; i
<steps
; i
++) {
684 for (j
=0; j
<FRAMES
; j
++) {
685 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
686 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
689 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
690 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
692 for (j
=0; j
<FRAMES
; j
++) {
693 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
694 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
709 for (j
=0; j
<FRAMES
; j
++) {
710 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
711 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
714 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
715 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
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
]);
728 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
729 int fx
, int fy
, int fw
, int fh
, int hiding
)
731 int style
= wPreferences
.iconification_style
; /* Catch the value */
734 if (style
== WIS_NONE
)
737 if (style
== WIS_RANDOM
) {
741 k
= (hiding
? 2 : 3);
744 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
746 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
749 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
751 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
755 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
757 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
761 #endif /* ANIMATIONS */
769 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
770 WMHandleEvent(&tmpev
);
775 unmapTransientsFor(WWindow
*wwin
)
780 tmp
= wwin
->screen_ptr
->focused_window
;
782 /* unmap the transients for this transient */
783 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
784 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
785 || tmp
->flags
.shaded
)) {
786 unmapTransientsFor(tmp
);
787 tmp
->flags
.miniaturized
= 1;
788 if (!tmp
->flags
.shaded
) {
791 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
794 if (!tmp->flags.shaded)
796 wClientSetState(tmp
, IconicState
, None
);
798 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
799 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
800 tmp
->flags
.kwm_hidden_for_modules
= 1;
803 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
812 mapTransientsFor(WWindow
*wwin
)
816 tmp
= wwin
->screen_ptr
->focused_window
;
818 /* recursively map the transients for this transient */
819 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
820 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
821 && tmp
->icon
==NULL
) {
822 mapTransientsFor(tmp
);
823 tmp
->flags
.miniaturized
= 0;
824 if (!tmp
->flags
.shaded
) {
827 XMapWindow(dpy
, tmp
->frame
->core
->window
);
829 tmp
->flags
.semi_focused
= 0;
831 if (!tmp->flags.shaded)
833 wClientSetState(tmp
, NormalState
, None
);
835 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
836 if (tmp
->flags
.kwm_hidden_for_modules
) {
837 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
838 tmp
->flags
.kwm_hidden_for_modules
= 0;
842 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
851 setupIconGrabs(WIcon
*icon
)
853 /* setup passive grabs on the icon */
854 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
855 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
856 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
857 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
858 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
859 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
865 recursiveTransientFor(WWindow
*wwin
)
872 /* hackish way to detect transient_for cycle */
873 i
= wwin
->screen_ptr
->window_count
+1;
875 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
876 wwin
= wWindowFor(wwin
->transient_for
);
880 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
890 removeIconGrabs(WIcon
*icon
)
892 /* remove passive grabs on the icon */
893 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
894 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
895 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
902 wIconifyWindow(WWindow
*wwin
)
904 XWindowAttributes attribs
;
908 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
909 /* the window doesn't exist anymore */
913 if (wwin
->flags
.miniaturized
) {
918 if (wwin
->transient_for
!=None
) {
919 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
921 if (owner
&& owner
->flags
.miniaturized
)
925 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
927 /* if the window is in another workspace, simplify process */
929 /* icon creation may take a while */
930 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
931 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
932 GrabModeAsync
, None
, None
, CurrentTime
);
935 if (!wPreferences
.disable_miniwindows
) {
936 if (!wwin
->flags
.icon_moved
) {
937 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
939 wwin
->icon
= wIconCreate(wwin
);
941 wwin
->icon
->mapped
= 1;
944 wwin
->flags
.miniaturized
= 1;
945 wwin
->flags
.mapped
= 0;
947 /* unmap transients */
949 unmapTransientsFor(wwin
);
953 wSoundPlay(WMSOUND_ICONIFY
);
956 XUngrabPointer(dpy
, CurrentTime
);
958 /* let all Expose events arrive so that we can repaint
959 * something before the animation starts (and the server is grabbed) */
962 if (wPreferences
.disable_miniwindows
)
963 wClientSetState(wwin
, IconicState
, None
);
965 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
969 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
970 && !wPreferences
.no_animations
) {
973 if (!wPreferences
.disable_miniwindows
) {
976 iw
= wwin
->icon
->core
->width
;
977 ih
= wwin
->icon
->core
->height
;
982 if (wKWMGetIconGeometry(wwin
, &area
)) {
988 #endif /* KWM_HINTS */
992 iw
= wwin
->screen_ptr
->scr_width
;
993 ih
= wwin
->screen_ptr
->scr_height
;
996 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
997 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
998 ix
, iy
, iw
, ih
, False
);
1003 wwin
->flags
.skip_next_animation
= 0;
1005 if (!wPreferences
.disable_miniwindows
) {
1007 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1008 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1010 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1012 AddToStackList(wwin
->icon
->core
);
1014 wLowerFrame(wwin
->icon
->core
);
1018 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1021 * It doesn't seem to be working and causes button event hangup
1022 * when deiconifying a transient window.
1023 setupIconGrabs(wwin->icon);
1025 if ((wwin
->flags
.focused
1026 || (owner
&& wwin
->client_win
== owner
->client_win
))
1027 && wPreferences
.focus_mode
==WKF_CLICK
) {
1032 if (!WFLAGP(tmp
, no_focusable
)
1033 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1034 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1038 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1039 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1040 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1044 if (!wwin
->screen_ptr
->flags
.startup
) {
1045 Window clientwin
= wwin
->client_win
;
1048 processEvents(XPending(dpy
));
1050 /* the window can disappear while doing the processEvents() */
1051 if (!wWindowFor(clientwin
))
1058 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1059 wIconSelect(wwin
->icon
);
1062 wGNOMEUpdateClientStateHint(wwin
, False
);
1065 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1066 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1069 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1076 wDeiconifyWindow(WWindow
*wwin
)
1078 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1080 if (!wwin
->flags
.miniaturized
)
1083 if (wwin
->transient_for
!= None
1084 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1085 WWindow
*owner
= recursiveTransientFor(wwin
);
1087 if (owner
&& owner
->flags
.miniaturized
) {
1088 wDeiconifyWindow(owner
);
1089 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1090 wRaiseFrame(wwin
->frame
->core
);
1095 wwin
->flags
.miniaturized
= 0;
1096 if (!wwin
->flags
.shaded
)
1097 wwin
->flags
.mapped
= 1;
1099 if (!wPreferences
.disable_miniwindows
) {
1100 if (wwin
->icon
->selected
)
1101 wIconSelect(wwin
->icon
);
1103 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1107 wSoundPlay(WMSOUND_DEICONIFY
);
1110 /* if the window is in another workspace, do it silently */
1112 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1113 && !wwin
->flags
.skip_next_animation
) {
1116 if (!wPreferences
.disable_miniwindows
) {
1119 iw
= wwin
->icon
->core
->width
;
1120 ih
= wwin
->icon
->core
->height
;
1125 if (wKWMGetIconGeometry(wwin
, &area
)) {
1131 #endif /* KWM_HINTS */
1135 iw
= wwin
->screen_ptr
->scr_width
;
1136 ih
= wwin
->screen_ptr
->scr_height
;
1139 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1140 wwin
->frame_x
, wwin
->frame_y
,
1141 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1144 #endif /* ANIMATIONS */
1145 wwin
->flags
.skip_next_animation
= 0;
1147 if (!wwin
->flags
.shaded
) {
1148 XMapWindow(dpy
, wwin
->client_win
);
1150 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1151 wRaiseFrame(wwin
->frame
->core
);
1152 if (!wwin
->flags
.shaded
) {
1153 wClientSetState(wwin
, NormalState
, None
);
1155 mapTransientsFor(wwin
);
1157 if (!wPreferences
.disable_miniwindows
) {
1158 RemoveFromStackList(wwin
->icon
->core
);
1159 /* removeIconGrabs(wwin->icon);*/
1160 wIconDestroy(wwin
->icon
);
1165 if (wPreferences
.focus_mode
==WKF_CLICK
)
1166 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1169 if (!wwin
->screen_ptr
->flags
.startup
) {
1170 Window clientwin
= wwin
->client_win
;
1173 processEvents(XPending(dpy
));
1175 if (!wWindowFor(clientwin
))
1180 if (wPreferences
.auto_arrange_icons
) {
1181 wArrangeIcons(wwin
->screen_ptr
, True
);
1185 wGNOMEUpdateClientStateHint(wwin
, False
);
1188 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1189 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1192 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1198 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1200 if (wwin
->flags
.miniaturized
) {
1202 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1203 wwin
->icon
->mapped
= 0;
1205 wwin
->flags
.hidden
= 1;
1207 wGNOMEUpdateClientStateHint(wwin
, False
);
1210 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1215 if (wwin
->flags
.inspector_open
) {
1216 wHideInspectorForWindow(wwin
);
1219 wwin
->flags
.hidden
= 1;
1222 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1225 wSoundPlay(WMSOUND_HIDE
);
1228 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1229 !wwin
->flags
.skip_next_animation
&& animate
) {
1230 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1231 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1232 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1236 wwin
->flags
.skip_next_animation
= 0;
1239 wGNOMEUpdateClientStateHint(wwin
, False
);
1242 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1248 wHideOtherApplications(WWindow
*awin
)
1252 #ifdef REDUCE_APPICONS
1253 char *tinstance
, *tclass
;
1254 unsigned int brokenwin
= 0, match
= 0;
1259 wwin
= awin
->screen_ptr
->focused_window
;
1261 #ifdef REDUCE_APPICONS
1262 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1268 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1269 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1270 && !wwin
->flags
.internal_window
1271 && wGetWindowOfInspectorForWindow(wwin
) != awin
1272 && !WFLAGP(wwin
, no_hide_others
)) {
1274 #ifdef REDUCE_APPICONS
1277 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1279 if ((tclass
= wwin
->wm_class
) == NULL
)
1281 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1282 (strcmp(awin
->wm_class
, tclass
) == 0) )
1287 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1288 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1289 wwin
->flags
.skip_next_animation
= 1;
1290 wIconifyWindow(wwin
);
1292 } else if (wwin
->main_window
!=None
1293 #ifndef REDUCE_APPICONS
1294 && awin
->main_window
!= wwin
->main_window
) {
1296 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1298 tapp
= wApplicationOf(wwin
->main_window
);
1300 tapp
->flags
.skip_next_animation
= 1;
1301 wHideApplication(tapp
);
1303 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1304 wwin
->flags
.skip_next_animation
= 1;
1305 wIconifyWindow(wwin
);
1313 wSetFocusTo(awin->screen_ptr, awin);
1320 wHideApplication(WApplication
*wapp
)
1322 #ifdef REDUCE_APPICONS
1324 char *tinstance
, *tclass
;
1325 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1332 wwarning("trying to hide a non grouped window");
1335 if (!wapp
->main_window_desc
) {
1336 wwarning("group leader not found for window group");
1339 #ifdef REDUCE_APPICONS
1340 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1341 (wapp
->main_window_desc
->wm_class
== NULL
))
1344 scr
= wapp
->main_window_desc
->screen_ptr
;
1346 wlist
= scr
->focused_window
;
1350 if (wlist
->main_window
== wapp
->main_window
)
1351 wapp
->last_focused
= wlist
;
1353 wapp
->last_focused
= NULL
;
1355 #ifdef REDUCE_APPICONS
1356 matchwmhints
= matchworkspace
= 0;
1358 tapp
= wApplicationOf(wlist
->main_window
);
1359 tinstance
= tclass
= NULL
;
1361 if (tapp
->main_window_desc
) {
1362 tinstance
= tapp
->main_window_desc
->wm_instance
;
1363 tclass
= tapp
->main_window_desc
->wm_class
;
1366 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1367 /* Should never reach here */
1371 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1372 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1376 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1379 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1385 if (wlist
->main_window
== wapp
->main_window
) {
1387 if (wlist
->flags
.focused
) {
1391 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1392 wapp
->app_icon
->y_pos
, wlist
,
1393 !wapp
->flags
.skip_next_animation
);
1395 wlist
= wlist
->prev
;
1398 wapp
->flags
.skip_next_animation
= 0;
1401 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1402 wlist
= scr
->focused_window
;
1404 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1405 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1407 wlist
= wlist
->prev
;
1409 wSetFocusTo(scr
, wlist
);
1411 wSetFocusTo(scr
, NULL
);
1415 wapp
->flags
.hidden
= 1;
1417 if(wPreferences
.auto_arrange_icons
) {
1418 wArrangeIcons(scr
, True
);
1422 wAppIconPaint(wapp
->app_icon
);
1430 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1431 int bringToCurrentWS
)
1433 if (bringToCurrentWS
)
1434 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1436 wwin
->flags
.hidden
=0;
1437 wwin
->flags
.mapped
=1;
1440 wSoundPlay(WMSOUND_UNHIDE
);
1443 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1445 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1446 icon
->core
->width
, icon
->core
->height
,
1447 wwin
->frame_x
, wwin
->frame_y
,
1448 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1452 wwin
->flags
.skip_next_animation
= 0;
1453 XMapWindow(dpy
, wwin
->client_win
);
1454 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1455 wClientSetState(wwin
, NormalState
, None
);
1456 wRaiseFrame(wwin
->frame
->core
);
1457 if (wwin
->flags
.inspector_open
) {
1458 wUnhideInspectorForWindow(wwin
);
1462 wGNOMEUpdateClientStateHint(wwin
, False
);
1465 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1471 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1474 WWindow
*wlist
, *next
;
1475 WWindow
*focused
=NULL
;
1476 #ifdef REDUCE_APPICONS
1477 char *tinstance
, *tclass
;
1478 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1485 #ifdef REDUCE_APPICONS
1486 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1487 (wapp
->main_window_desc
->wm_instance
== NULL
))
1491 scr
= wapp
->main_window_desc
->screen_ptr
;
1492 wlist
= scr
->focused_window
;
1494 /* goto beginning of list */
1496 wlist
= wlist
->prev
;
1501 #ifndef REDUCE_APPICONS
1502 if (wlist
->main_window
== wapp
->main_window
) {
1504 matchwmhints
= matchworkspace
= 0;
1506 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1508 if ((tclass
= wlist
->wm_class
) == NULL
)
1510 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1511 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1515 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1519 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1522 if (wlist
->flags
.focused
)
1524 else if (!focused
|| !focused
->flags
.focused
)
1527 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1528 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1529 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1530 if (!wlist
->icon
->mapped
) {
1531 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1532 wlist
->icon
->mapped
= 1;
1534 wlist
->flags
.hidden
= 0;
1536 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1538 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1539 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1542 wDeiconifyWindow(wlist
);
1544 } else if (wlist
->flags
.hidden
) {
1545 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1546 wapp
->app_icon
->y_pos
, wlist
,
1547 !wapp
->flags
.skip_next_animation
,
1550 if (bringToCurrentWS
1551 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1552 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1554 wRaiseFrame(wlist
->frame
->core
);
1560 wapp
->flags
.skip_next_animation
= 0;
1561 wapp
->flags
.hidden
= 0;
1564 wSetFocusTo(scr
, focused
);
1565 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1566 wSetFocusTo(scr
, wapp
->last_focused
);
1567 wapp
->last_focused
= NULL
;
1568 if (wPreferences
.auto_arrange_icons
) {
1569 wArrangeIcons(scr
, True
);
1572 wAppIconPaint(wapp
->app_icon
);
1579 wShowAllWindows(WScreen
*scr
)
1581 WWindow
*wwin
, *old_foc
;
1584 old_foc
= wwin
= scr
->focused_window
;
1586 if (!wwin
->flags
.internal_window
&&
1587 (scr
->current_workspace
== wwin
->frame
->workspace
1588 || IS_OMNIPRESENT(wwin
))) {
1589 if (wwin
->flags
.miniaturized
) {
1590 wwin
->flags
.skip_next_animation
= 1;
1591 wDeiconifyWindow(wwin
);
1592 } else if (wwin
->flags
.hidden
) {
1593 wapp
= wApplicationOf(wwin
->main_window
);
1595 wUnhideApplication(wapp
, False
, False
);
1597 wwin
->flags
.skip_next_animation
= 1;
1598 wDeiconifyWindow(wwin
);
1604 wSetFocusTo(scr
, old_foc
);
1605 /*wRaiseFrame(old_foc->frame->core);*/
1610 wRefreshDesktop(WScreen
*scr
)
1613 XSetWindowAttributes attr
;
1615 attr
.backing_store
= NotUseful
;
1616 attr
.save_under
= False
;
1617 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1618 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1619 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1621 XMapRaised(dpy
, win
);
1622 XDestroyWindow(dpy
, win
);
1628 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1632 int pf
; /* primary axis */
1633 int sf
; /* secondary axis */
1637 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1641 int isize
= wPreferences
.icon_size
;
1644 * Find out screen boundaries.
1648 sx2
= scr
->scr_width
;
1649 sy2
= scr
->scr_height
;
1651 if (scr
->dock
->on_right_side
)
1652 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1654 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1657 sw
= isize
* (scr
->scr_width
/isize
);
1658 sh
= isize
* (scr
->scr_height
/isize
);
1659 fullW
= (sx2
-sx1
)/isize
;
1660 fullH
= (sy2
-sy1
)/isize
;
1662 /* icon yard boundaries */
1663 if (wPreferences
.icon_yard
& IY_VERT
) {
1670 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1677 if (wPreferences
.icon_yard
& IY_TOP
) {
1685 /* arrange icons putting the most recently focused window
1686 * as the last icon */
1687 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1688 : xo + xs*(pi*isize))
1689 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1690 : yo + ys*(si*isize))
1692 /* arrange application icons */
1693 aicon
= scr
->app_icon_list
;
1694 /* reverse them to avoid unnecessarily sliding of icons */
1695 while (aicon
&& aicon
->next
)
1696 aicon
= aicon
->next
;
1701 if (!aicon
->docked
) {
1702 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1704 if (!wPreferences
.no_animations
) {
1705 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1708 #endif /* ANIMATIONS */
1710 wAppIconMove(aicon
, X
, Y
);
1713 /* we reversed the order so we use prev */
1714 aicon
= aicon
->prev
;
1721 /* arrange miniwindows */
1723 wwin
= scr
->focused_window
;
1724 /* reverse them to avoid unnecessarily shuffling */
1725 while (wwin
&& wwin
->prev
)
1729 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1730 (wwin
->frame
->workspace
==scr
->current_workspace
||
1731 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1733 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1734 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1736 if (wPreferences
.no_animations
) {
1737 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1739 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1740 wwin
->icon_y
, X
, Y
);
1743 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1744 #endif /* ANIMATIONS */
1752 wwin
->flags
.icon_moved
= 0;
1754 /* we reversed the order, so we use next */
1765 wSelectWindow(WWindow
*wwin
, Bool flag
)
1767 WScreen
*scr
= wwin
->screen_ptr
;
1770 wwin
->flags
.selected
= 1;
1771 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1773 if (WFLAGP(wwin
, no_border
)) {
1774 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1775 FRAME_BORDER_WIDTH
);
1778 if (!scr
->selected_windows
)
1779 scr
->selected_windows
= WMCreateBag(4);
1780 WMPutInBag(scr
->selected_windows
, wwin
);
1782 wwin
->flags
.selected
= 0;
1783 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1784 scr
->frame_border_pixel
);
1786 if (WFLAGP(wwin
, no_border
)) {
1787 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1790 if (scr
->selected_windows
) {
1791 WMRemoveFromBag(scr
->selected_windows
, wwin
);
1798 wMakeWindowVisible(WWindow
*wwin
)
1800 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1801 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1803 if (wwin
->flags
.shaded
) {
1804 wUnshadeWindow(wwin
);
1806 if (wwin
->flags
.hidden
) {
1809 app
= wApplicationOf(wwin
->main_window
);
1811 wUnhideApplication(app
, False
, False
);
1812 } else if (wwin
->flags
.miniaturized
) {
1813 wDeiconifyWindow(wwin
);
1815 if (!WFLAGP(wwin
, no_focusable
))
1816 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1817 wRaiseFrame(wwin
->frame
->core
);