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
);
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
) {
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 wWindowFocus(wwin
, focused
);
242 if (napp
&& !wasfocused
) {
244 wUserMenuRefreshInstances(napp
->menu
, wwin
);
245 #endif /* USER_MENU */
247 if (wwin
->flags
.mapped
)
248 wAppMenuMap(napp
->menu
, wwin
);
250 wApplicationActivate(napp
);
254 wKWMUpdateActiveWindowHint(scr
);
255 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
263 wShadeWindow(WWindow
*wwin
)
265 time_t time0
= time(NULL
);
270 if (wwin
->flags
.shaded
)
273 XLowerWindow(dpy
, wwin
->client_win
);
276 wSoundPlay(WMSOUND_SHADE
);
280 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
281 && !wPreferences
.no_animations
) {
282 /* do the shading animation */
283 h
= wwin
->frame
->core
->height
;
286 w
= wwin
->frame
->core
->width
;
287 y
= wwin
->frame
->top_width
;
288 while (h
>wwin
->frame
->top_width
+1) {
289 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
290 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
293 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
297 wusleep(SHADE_DELAY
*1000L);
301 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
303 #endif /* ANIMATIONS */
305 wwin
->flags
.skip_next_animation
= 0;
306 wwin
->flags
.shaded
= 1;
307 wwin
->flags
.mapped
= 0;
308 /* prevent window withdrawal when getting UnmapNotify */
309 XSelectInput(dpy
, wwin
->client_win
,
310 wwin
->event_mask
& ~StructureNotifyMask
);
311 XUnmapWindow(dpy
, wwin
->client_win
);
312 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
314 /* for the client it's just like iconification */
315 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
316 wwin
->frame
->top_width
- 1);
318 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
319 + wwin
->frame
->top_width
;
320 wWindowSynthConfigureNotify(wwin
);
323 wClientSetState(wwin, IconicState, None);
327 wGNOMEUpdateClientStateHint(wwin
, False
);
330 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
331 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
333 /* update window list to reflect shaded state */
334 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
337 if (!wwin
->screen_ptr
->flags
.startup
) {
338 /* Look at processEvents() for reason of this code. */
340 processEvents(XPending(dpy
));
347 wUnshadeWindow(WWindow
*wwin
)
349 time_t time0
= time(NULL
);
352 #endif /* ANIMATIONS */
355 if (!wwin
->flags
.shaded
)
358 wwin
->flags
.shaded
= 0;
359 wwin
->flags
.mapped
= 1;
360 XMapWindow(dpy
, wwin
->client_win
);
363 wSoundPlay(WMSOUND_UNSHADE
);
367 if (!wPreferences
.no_animations
&& !wwin
->flags
.skip_next_animation
) {
368 /* do the shading animation */
369 h
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
370 y
= wwin
->frame
->top_width
- wwin
->client
.height
;
371 s
= abs(y
)/SHADE_STEPS
;
373 w
= wwin
->frame
->core
->width
;
374 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
376 while (h
< wwin
->client
.height
+ wwin
->frame
->top_width
377 + wwin
->frame
->bottom_width
) {
378 XResizeWindow(dpy
, wwin
->frame
->core
->window
, w
, h
);
379 XMoveWindow(dpy
, wwin
->client_win
, 0, y
);
382 wusleep(SHADE_DELAY
*2000L/3);
386 if (time(NULL
)-time0
> MAX_ANIMATION_TIME
)
390 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
392 #endif /* ANIMATIONS */
394 wwin
->flags
.skip_next_animation
= 0;
395 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
396 wwin
->frame
->top_width
+ wwin
->client
.height
397 + wwin
->frame
->bottom_width
);
399 wwin
->client
.y
= wwin
->frame_y
+ wwin
->frame
->top_width
;
400 wWindowSynthConfigureNotify(wwin
);
403 wClientSetState(wwin, NormalState, None);
405 /* if the window is focused, set the focus again as it was disabled during
407 if (wwin
->flags
.focused
)
408 wSetFocusTo(wwin
->screen_ptr
, wwin
);
411 wGNOMEUpdateClientStateHint(wwin
, False
);
414 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
415 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
418 /* update window list to reflect unshaded state */
419 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
425 wMaximizeWindow(WWindow
*wwin
, int directions
)
427 int new_width
, new_height
, new_x
, new_y
;
428 WArea usableArea
= wwin
->screen_ptr
->totalUsableArea
;
431 if (WFLAGP(wwin
, no_resizable
))
435 if (WFLAGP(wwin
, full_maximize
)) {
438 usableArea
.x2
= wwin
->screen_ptr
->scr_width
;
439 usableArea
.y2
= wwin
->screen_ptr
->scr_height
;
442 if (wwin
->flags
.shaded
) {
443 wwin
->flags
.skip_next_animation
= 1;
444 wUnshadeWindow(wwin
);
446 wwin
->flags
.maximized
= directions
;
447 wwin
->old_geometry
.width
= wwin
->client
.width
;
448 wwin
->old_geometry
.height
= wwin
->client
.height
;
449 wwin
->old_geometry
.x
= wwin
->frame_x
;
450 wwin
->old_geometry
.y
= wwin
->frame_y
;
453 wKWMUpdateClientGeometryRestore(wwin
);
456 if (directions
& MAX_HORIZONTAL
) {
458 new_width
= (usableArea
.x2
-usableArea
.x1
)-FRAME_BORDER_WIDTH
*2;
459 new_x
= usableArea
.x1
;
463 new_x
= wwin
->frame_x
;
464 new_width
= wwin
->frame
->core
->width
;
468 if (directions
& MAX_VERTICAL
) {
470 new_height
= (usableArea
.y2
-usableArea
.y1
)-FRAME_BORDER_WIDTH
*2;
471 new_y
= usableArea
.y1
;
472 if (WFLAGP(wwin
, full_maximize
)) {
473 new_y
-= wwin
->frame
->top_width
- 1;
474 new_height
+= wwin
->frame
->bottom_width
- 3;
477 new_y
= wwin
->frame_y
;
478 new_height
= wwin
->frame
->core
->height
;
481 if (!WFLAGP(wwin
, full_maximize
)) {
482 new_height
-= wwin
->frame
->top_width
+wwin
->frame
->bottom_width
;
485 wWindowConstrainSize(wwin
, &new_width
, &new_height
);
486 wWindowConfigure(wwin
, new_x
, new_y
, new_width
, new_height
);
489 wGNOMEUpdateClientStateHint(wwin
, False
);
492 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
493 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
497 wSoundPlay(WMSOUND_MAXIMIZE
);
503 wUnmaximizeWindow(WWindow
*wwin
)
505 int restore_x
, restore_y
;
507 if (!wwin
->flags
.maximized
)
510 if (wwin
->flags
.shaded
) {
511 wwin
->flags
.skip_next_animation
= 1;
512 wUnshadeWindow(wwin
);
514 restore_x
= (wwin
->flags
.maximized
& MAX_HORIZONTAL
) ?
515 wwin
->old_geometry
.x
: wwin
->frame_x
;
516 restore_y
= (wwin
->flags
.maximized
& MAX_VERTICAL
) ?
517 wwin
->old_geometry
.y
: wwin
->frame_y
;
518 wwin
->flags
.maximized
= 0;
519 wWindowConfigure(wwin
, restore_x
, restore_y
,
520 wwin
->old_geometry
.width
, wwin
->old_geometry
.height
);
523 wGNOMEUpdateClientStateHint(wwin
, False
);
526 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
527 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
531 wSoundPlay(WMSOUND_UNMAXIMIZE
);
537 animateResizeFlip(WScreen
*scr
, int x
, int y
, int w
, int h
,
538 int fx
, int fy
, int fw
, int fh
, int steps
)
540 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
541 float cx
, cy
, cw
, ch
;
542 float xstep
, ystep
, wstep
, hstep
;
545 float angle
, final_angle
, delta
;
547 xstep
= (float)(fx
-x
)/steps
;
548 ystep
= (float)(fy
-y
)/steps
;
549 wstep
= (float)(fw
-w
)/steps
;
550 hstep
= (float)(fh
-h
)/steps
;
557 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_F
;
558 delta
= (float)(final_angle
/FRAMES
);
559 for (angle
=0;; angle
+=delta
) {
560 if (angle
> final_angle
)
563 dx
= (cw
/10) - ((cw
/5) * sin(angle
));
564 dch
= (ch
/2) * cos(angle
);
567 points
[0].x
= cx
+ dx
; points
[0].y
= midy
- dch
;
568 points
[1].x
= cx
+ cw
- dx
; points
[1].y
= points
[0].y
;
569 points
[2].x
= cx
+ cw
+ dx
; points
[2].y
= midy
+ dch
;
570 points
[3].x
= cx
- dx
; points
[3].y
= points
[2].y
;
571 points
[4].x
= points
[0].x
; points
[4].y
= points
[0].y
;
574 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
576 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
577 wusleep(MINIATURIZE_ANIMATION_DELAY_F
);
580 XDrawLines(dpy
,scr
->root_win
,scr
->frame_gc
,points
, 5, CoordModeOrigin
);
586 if (angle
>= final_angle
)
596 animateResizeTwist(WScreen
*scr
, int x
, int y
, int w
, int h
,
597 int fx
, int fy
, int fw
, int fh
, int steps
)
599 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
600 float cx
, cy
, cw
, ch
;
601 float xstep
, ystep
, wstep
, hstep
;
603 float angle
, final_angle
, a
, d
, delta
;
610 xstep
= (float)(fx
-x
)/steps
;
611 ystep
= (float)(fy
-y
)/steps
;
612 wstep
= (float)(fw
-w
)/steps
;
613 hstep
= (float)(fh
-h
)/steps
;
620 final_angle
= 2*WM_PI
*MINIATURIZE_ANIMATION_TWIST_T
;
621 delta
= (float)(final_angle
/FRAMES
);
622 for (angle
=0;; angle
+=delta
) {
623 if (angle
> final_angle
)
627 d
= sqrt((cw
/2)*(cw
/2)+(ch
/2)*(ch
/2));
629 points
[0].x
= cx
+cos(angle
-a
)*d
;
630 points
[0].y
= cy
+sin(angle
-a
)*d
;
631 points
[1].x
= cx
+cos(angle
+a
)*d
;
632 points
[1].y
= cy
+sin(angle
+a
)*d
;
633 points
[2].x
= cx
+cos(angle
-a
+WM_PI
)*d
;
634 points
[2].y
= cy
+sin(angle
-a
+WM_PI
)*d
;
635 points
[3].x
= cx
+cos(angle
+a
+WM_PI
)*d
;
636 points
[3].y
= cy
+sin(angle
+a
+WM_PI
)*d
;
637 points
[4].x
= cx
+cos(angle
-a
)*d
;
638 points
[4].y
= cy
+sin(angle
-a
)*d
;
640 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
642 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
643 wusleep(MINIATURIZE_ANIMATION_DELAY_T
);
646 XDrawLines(dpy
, scr
->root_win
, scr
->frame_gc
, points
, 5, CoordModeOrigin
);
652 if (angle
>= final_angle
)
662 animateResizeZoom(WScreen
*scr
, int x
, int y
, int w
, int h
,
663 int fx
, int fy
, int fw
, int fh
, int steps
)
665 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
666 float cx
[FRAMES
], cy
[FRAMES
], cw
[FRAMES
], ch
[FRAMES
];
667 float xstep
, ystep
, wstep
, hstep
;
670 xstep
= (float)(fx
-x
)/steps
;
671 ystep
= (float)(fy
-y
)/steps
;
672 wstep
= (float)(fw
-w
)/steps
;
673 hstep
= (float)(fh
-h
)/steps
;
675 for (j
=0; j
<FRAMES
; j
++) {
682 for (i
=0; i
<steps
; i
++) {
683 for (j
=0; j
<FRAMES
; j
++) {
684 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
685 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
688 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
689 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
691 for (j
=0; j
<FRAMES
; j
++) {
692 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
693 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
708 for (j
=0; j
<FRAMES
; j
++) {
709 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
710 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
713 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
714 wusleep(MINIATURIZE_ANIMATION_DELAY_Z
);
716 for (j
=0; j
<FRAMES
; j
++) {
717 XDrawRectangle(dpy
, scr
->root_win
, scr
->frame_gc
,
718 (int)cx
[j
], (int)cy
[j
], (int)cw
[j
], (int)ch
[j
]);
727 animateResize(WScreen
*scr
, int x
, int y
, int w
, int h
,
728 int fx
, int fy
, int fw
, int fh
, int hiding
)
730 int style
= wPreferences
.iconification_style
; /* Catch the value */
733 if (style
== WIS_NONE
)
736 if (style
== WIS_RANDOM
) {
740 k
= (hiding
? 2 : 3);
743 steps
= (MINIATURIZE_ANIMATION_STEPS_T
* k
)/3;
745 animateResizeTwist(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
748 steps
= (MINIATURIZE_ANIMATION_STEPS_F
* k
)/3;
750 animateResizeFlip(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
754 steps
= (MINIATURIZE_ANIMATION_STEPS_Z
* k
)/3;
756 animateResizeZoom(scr
, x
, y
, w
, h
, fx
, fy
, fw
, fh
, steps
);
760 #endif /* ANIMATIONS */
768 while (XCheckTypedEvent(dpy
, Expose
, &tmpev
))
769 WMHandleEvent(&tmpev
);
774 unmapTransientsFor(WWindow
*wwin
)
779 tmp
= wwin
->screen_ptr
->focused_window
;
781 /* unmap the transients for this transient */
782 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
783 && (tmp
->flags
.mapped
|| wwin
->screen_ptr
->flags
.startup
784 || tmp
->flags
.shaded
)) {
785 unmapTransientsFor(tmp
);
786 tmp
->flags
.miniaturized
= 1;
787 if (!tmp
->flags
.shaded
) {
790 XUnmapWindow(dpy
, tmp
->frame
->core
->window
);
793 if (!tmp->flags.shaded)
795 wClientSetState(tmp
, IconicState
, None
);
797 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
798 wKWMSendEventMessage(tmp
, WKWMRemoveWindow
);
799 tmp
->flags
.kwm_hidden_for_modules
= 1;
802 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
811 mapTransientsFor(WWindow
*wwin
)
815 tmp
= wwin
->screen_ptr
->focused_window
;
817 /* recursively map the transients for this transient */
818 if (tmp
!=wwin
&& tmp
->transient_for
== wwin
->client_win
819 && /*!tmp->flags.mapped*/ tmp
->flags
.miniaturized
820 && tmp
->icon
==NULL
) {
821 mapTransientsFor(tmp
);
822 tmp
->flags
.miniaturized
= 0;
823 if (!tmp
->flags
.shaded
) {
826 XMapWindow(dpy
, tmp
->frame
->core
->window
);
828 tmp
->flags
.semi_focused
= 0;
830 if (!tmp->flags.shaded)
832 wClientSetState(tmp
, NormalState
, None
);
834 wKWMUpdateClientStateHint(tmp
, KWMIconifiedFlag
);
835 if (tmp
->flags
.kwm_hidden_for_modules
) {
836 wKWMSendEventMessage(tmp
, WKWMAddWindow
);
837 tmp
->flags
.kwm_hidden_for_modules
= 0;
841 UpdateSwitchMenu(wwin
->screen_ptr
, tmp
, ACTION_CHANGE_STATE
);
850 setupIconGrabs(WIcon
*icon
)
852 /* setup passive grabs on the icon */
853 XGrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
, True
,
854 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
855 XGrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
, True
,
856 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
857 XGrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
, True
,
858 ButtonPressMask
, GrabModeSync
, GrabModeAsync
, None
, None
);
864 recursiveTransientFor(WWindow
*wwin
)
871 /* hackish way to detect transient_for cycle */
872 i
= wwin
->screen_ptr
->window_count
+1;
874 while (wwin
&& wwin
->transient_for
!= None
&& i
>0) {
875 wwin
= wWindowFor(wwin
->transient_for
);
879 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
889 removeIconGrabs(WIcon
*icon
)
891 /* remove passive grabs on the icon */
892 XUngrabButton(dpy
, Button1
, AnyModifier
, icon
->core
->window
);
893 XUngrabButton(dpy
, Button2
, AnyModifier
, icon
->core
->window
);
894 XUngrabButton(dpy
, Button3
, AnyModifier
, icon
->core
->window
);
901 wIconifyWindow(WWindow
*wwin
)
903 XWindowAttributes attribs
;
907 if (!XGetWindowAttributes(dpy
, wwin
->client_win
, &attribs
)) {
908 /* the window doesn't exist anymore */
912 if (wwin
->flags
.miniaturized
) {
917 if (wwin
->transient_for
!=None
) {
918 WWindow
*owner
= wWindowFor(wwin
->transient_for
);
920 if (owner
&& owner
->flags
.miniaturized
)
924 present
= wwin
->frame
->workspace
==wwin
->screen_ptr
->current_workspace
;
926 /* if the window is in another workspace, simplify process */
928 /* icon creation may take a while */
929 XGrabPointer(dpy
, wwin
->screen_ptr
->root_win
, False
,
930 ButtonMotionMask
|ButtonReleaseMask
, GrabModeAsync
,
931 GrabModeAsync
, None
, None
, CurrentTime
);
934 if (!wPreferences
.disable_miniwindows
) {
935 if (!wwin
->flags
.icon_moved
) {
936 PlaceIcon(wwin
->screen_ptr
, &wwin
->icon_x
, &wwin
->icon_y
);
938 wwin
->icon
= wIconCreate(wwin
);
940 wwin
->icon
->mapped
= 1;
943 wwin
->flags
.miniaturized
= 1;
944 wwin
->flags
.mapped
= 0;
946 /* unmap transients */
948 unmapTransientsFor(wwin
);
952 wSoundPlay(WMSOUND_ICONIFY
);
955 XUngrabPointer(dpy
, CurrentTime
);
957 /* let all Expose events arrive so that we can repaint
958 * something before the animation starts (and the server is grabbed) */
961 if (wPreferences
.disable_miniwindows
)
962 wClientSetState(wwin
, IconicState
, None
);
964 wClientSetState(wwin
, IconicState
, wwin
->icon
->icon_win
);
968 if (!wwin
->screen_ptr
->flags
.startup
&& !wwin
->flags
.skip_next_animation
969 && !wPreferences
.no_animations
) {
972 if (!wPreferences
.disable_miniwindows
) {
975 iw
= wwin
->icon
->core
->width
;
976 ih
= wwin
->icon
->core
->height
;
981 if (wKWMGetIconGeometry(wwin
, &area
)) {
987 #endif /* KWM_HINTS */
991 iw
= wwin
->screen_ptr
->scr_width
;
992 ih
= wwin
->screen_ptr
->scr_height
;
995 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
996 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
997 ix
, iy
, iw
, ih
, False
);
1002 wwin
->flags
.skip_next_animation
= 0;
1004 if (!wPreferences
.disable_miniwindows
) {
1006 if (wwin
->screen_ptr
->current_workspace
==wwin
->frame
->workspace
||
1007 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)
1009 XMapWindow(dpy
, wwin
->icon
->core
->window
);
1011 AddToStackList(wwin
->icon
->core
);
1013 wLowerFrame(wwin
->icon
->core
);
1017 WWindow
*owner
= recursiveTransientFor(wwin
->screen_ptr
->focused_window
);
1020 * It doesn't seem to be working and causes button event hangup
1021 * when deiconifying a transient window.
1022 setupIconGrabs(wwin->icon);
1024 if ((wwin
->flags
.focused
1025 || (owner
&& wwin
->client_win
== owner
->client_win
))
1026 && wPreferences
.focus_mode
==WKF_CLICK
) {
1031 if (!WFLAGP(tmp
, no_focusable
)
1032 && !(tmp
->flags
.hidden
||tmp
->flags
.miniaturized
)
1033 && (wwin
->frame
->workspace
== tmp
->frame
->workspace
))
1037 wSetFocusTo(wwin
->screen_ptr
, tmp
);
1038 } else if (wPreferences
.focus_mode
!=WKF_CLICK
) {
1039 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1043 if (!wwin
->screen_ptr
->flags
.startup
) {
1044 Window clientwin
= wwin
->client_win
;
1047 processEvents(XPending(dpy
));
1049 /* the window can disappear while doing the processEvents() */
1050 if (!wWindowFor(clientwin
))
1057 if (wwin
->flags
.selected
&& !wPreferences
.disable_miniwindows
)
1058 wIconSelect(wwin
->icon
);
1061 wGNOMEUpdateClientStateHint(wwin
, False
);
1064 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1065 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1068 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1075 wDeiconifyWindow(WWindow
*wwin
)
1077 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1079 if (!wwin
->flags
.miniaturized
)
1082 if (wwin
->transient_for
!= None
1083 && wwin
->transient_for
!= wwin
->screen_ptr
->root_win
) {
1084 WWindow
*owner
= recursiveTransientFor(wwin
);
1086 if (owner
&& owner
->flags
.miniaturized
) {
1087 wDeiconifyWindow(owner
);
1088 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1089 wRaiseFrame(wwin
->frame
->core
);
1094 wwin
->flags
.miniaturized
= 0;
1095 if (!wwin
->flags
.shaded
)
1096 wwin
->flags
.mapped
= 1;
1098 if (!wPreferences
.disable_miniwindows
) {
1099 if (wwin
->icon
->selected
)
1100 wIconSelect(wwin
->icon
);
1102 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1106 wSoundPlay(WMSOUND_DEICONIFY
);
1109 /* if the window is in another workspace, do it silently */
1111 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1112 && !wwin
->flags
.skip_next_animation
) {
1115 if (!wPreferences
.disable_miniwindows
) {
1118 iw
= wwin
->icon
->core
->width
;
1119 ih
= wwin
->icon
->core
->height
;
1124 if (wKWMGetIconGeometry(wwin
, &area
)) {
1130 #endif /* KWM_HINTS */
1134 iw
= wwin
->screen_ptr
->scr_width
;
1135 ih
= wwin
->screen_ptr
->scr_height
;
1138 animateResize(wwin
->screen_ptr
, ix
, iy
, iw
, ih
,
1139 wwin
->frame_x
, wwin
->frame_y
,
1140 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1143 #endif /* ANIMATIONS */
1144 wwin
->flags
.skip_next_animation
= 0;
1146 if (!wwin
->flags
.shaded
) {
1147 XMapWindow(dpy
, wwin
->client_win
);
1149 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1150 wRaiseFrame(wwin
->frame
->core
);
1151 if (!wwin
->flags
.shaded
) {
1152 wClientSetState(wwin
, NormalState
, None
);
1154 mapTransientsFor(wwin
);
1156 if (!wPreferences
.disable_miniwindows
) {
1157 RemoveFromStackList(wwin
->icon
->core
);
1158 /* removeIconGrabs(wwin->icon);*/
1159 wIconDestroy(wwin
->icon
);
1164 if (wPreferences
.focus_mode
==WKF_CLICK
)
1165 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1168 if (!wwin
->screen_ptr
->flags
.startup
) {
1169 Window clientwin
= wwin
->client_win
;
1172 processEvents(XPending(dpy
));
1174 if (!wWindowFor(clientwin
))
1179 if (wPreferences
.auto_arrange_icons
) {
1180 wArrangeIcons(wwin
->screen_ptr
, True
);
1184 wGNOMEUpdateClientStateHint(wwin
, False
);
1187 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1188 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1191 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1197 hideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
)
1199 if (wwin
->flags
.miniaturized
) {
1201 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
1202 wwin
->icon
->mapped
= 0;
1204 wwin
->flags
.hidden
= 1;
1206 wGNOMEUpdateClientStateHint(wwin
, False
);
1209 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1214 if (wwin
->flags
.inspector_open
) {
1215 wHideInspectorForWindow(wwin
);
1218 wwin
->flags
.hidden
= 1;
1221 wClientSetState(wwin
, IconicState
, icon
->icon_win
);
1224 wSoundPlay(WMSOUND_HIDE
);
1227 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
&&
1228 !wwin
->flags
.skip_next_animation
&& animate
) {
1229 animateResize(wwin
->screen_ptr
, wwin
->frame_x
, wwin
->frame_y
,
1230 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1231 icon_x
, icon_y
, icon
->core
->width
, icon
->core
->height
,
1235 wwin
->flags
.skip_next_animation
= 0;
1238 wGNOMEUpdateClientStateHint(wwin
, False
);
1241 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1247 wHideOtherApplications(WWindow
*awin
)
1251 #ifdef REDUCE_APPICONS
1252 char *tinstance
, *tclass
;
1253 unsigned int brokenwin
= 0, match
= 0;
1258 wwin
= awin
->screen_ptr
->focused_window
;
1260 #ifdef REDUCE_APPICONS
1261 if (awin
->wm_instance
== NULL
|| awin
->wm_class
== NULL
)
1267 && wwin
->frame
->workspace
== awin
->screen_ptr
->current_workspace
1268 && !(wwin
->flags
.miniaturized
||wwin
->flags
.hidden
)
1269 && !wwin
->flags
.internal_window
1270 && wGetWindowOfInspectorForWindow(wwin
) != awin
1271 && !WFLAGP(wwin
, no_hide_others
)) {
1273 #ifdef REDUCE_APPICONS
1276 if ((tinstance
= wwin
->wm_instance
) == NULL
)
1278 if ((tclass
= wwin
->wm_class
) == NULL
)
1280 if ((strcmp(awin
->wm_instance
, tinstance
) == 0) &&
1281 (strcmp(awin
->wm_class
, tclass
) == 0) )
1286 if (wwin
->main_window
==None
|| WFLAGP(wwin
, no_appicon
)) {
1287 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1288 wwin
->flags
.skip_next_animation
= 1;
1289 wIconifyWindow(wwin
);
1291 } else if (wwin
->main_window
!=None
1292 #ifndef REDUCE_APPICONS
1293 && awin
->main_window
!= wwin
->main_window
) {
1295 && (awin
->main_window
!= wwin
->main_window
&& !match
)) {
1297 tapp
= wApplicationOf(wwin
->main_window
);
1299 tapp
->flags
.skip_next_animation
= 1;
1300 wHideApplication(tapp
);
1302 if (!WFLAGP(wwin
, no_miniaturizable
)) {
1303 wwin
->flags
.skip_next_animation
= 1;
1304 wIconifyWindow(wwin
);
1312 wSetFocusTo(awin->screen_ptr, awin);
1319 wHideApplication(WApplication
*wapp
)
1321 #ifdef REDUCE_APPICONS
1323 char *tinstance
, *tclass
;
1324 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1331 wwarning("trying to hide a non grouped window");
1334 if (!wapp
->main_window_desc
) {
1335 wwarning("group leader not found for window group");
1338 #ifdef REDUCE_APPICONS
1339 if ((wapp
->main_window_desc
->wm_instance
== NULL
) ||
1340 (wapp
->main_window_desc
->wm_class
== NULL
))
1343 scr
= wapp
->main_window_desc
->screen_ptr
;
1345 wlist
= scr
->focused_window
;
1349 if (wlist
->main_window
== wapp
->main_window
)
1350 wapp
->last_focused
= wlist
;
1352 wapp
->last_focused
= NULL
;
1354 #ifdef REDUCE_APPICONS
1355 matchwmhints
= matchworkspace
= 0;
1357 tapp
= wApplicationOf(wlist
->main_window
);
1358 tinstance
= tclass
= NULL
;
1360 if (tapp
->main_window_desc
) {
1361 tinstance
= tapp
->main_window_desc
->wm_instance
;
1362 tclass
= tapp
->main_window_desc
->wm_class
;
1365 if (tapp
== NULL
|| tinstance
== NULL
|| tclass
== NULL
) {
1366 /* Should never reach here */
1370 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0) &&
1371 (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1375 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1378 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1384 if (wlist
->main_window
== wapp
->main_window
) {
1386 if (wlist
->flags
.focused
) {
1390 hideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1391 wapp
->app_icon
->y_pos
, wlist
,
1392 !wapp
->flags
.skip_next_animation
);
1394 wlist
= wlist
->prev
;
1397 wapp
->flags
.skip_next_animation
= 0;
1400 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1401 wlist
= scr
->focused_window
;
1403 if (!WFLAGP(wlist
, no_focusable
) && !wlist
->flags
.hidden
1404 && (wlist
->flags
.mapped
|| wlist
->flags
.shaded
))
1406 wlist
= wlist
->prev
;
1408 wSetFocusTo(scr
, wlist
);
1410 wSetFocusTo(scr
, NULL
);
1414 wapp
->flags
.hidden
= 1;
1416 if(wPreferences
.auto_arrange_icons
) {
1417 wArrangeIcons(scr
, True
);
1421 wAppIconPaint(wapp
->app_icon
);
1429 unhideWindow(WIcon
*icon
, int icon_x
, int icon_y
, WWindow
*wwin
, int animate
,
1430 int bringToCurrentWS
)
1432 if (bringToCurrentWS
)
1433 wWindowChangeWorkspace(wwin
, wwin
->screen_ptr
->current_workspace
);
1435 wwin
->flags
.hidden
=0;
1436 wwin
->flags
.mapped
=1;
1439 wSoundPlay(WMSOUND_UNHIDE
);
1442 if (!wwin
->screen_ptr
->flags
.startup
&& !wPreferences
.no_animations
1444 animateResize(wwin
->screen_ptr
, icon_x
, icon_y
,
1445 icon
->core
->width
, icon
->core
->height
,
1446 wwin
->frame_x
, wwin
->frame_y
,
1447 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
,
1451 wwin
->flags
.skip_next_animation
= 0;
1452 XMapWindow(dpy
, wwin
->client_win
);
1453 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1454 wClientSetState(wwin
, NormalState
, None
);
1455 wRaiseFrame(wwin
->frame
->core
);
1456 if (wwin
->flags
.inspector_open
) {
1457 wUnhideInspectorForWindow(wwin
);
1461 wGNOMEUpdateClientStateHint(wwin
, False
);
1464 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1470 wUnhideApplication(WApplication
*wapp
, Bool miniwindows
, Bool bringToCurrentWS
)
1473 WWindow
*wlist
, *next
;
1474 WWindow
*focused
=NULL
;
1475 #ifdef REDUCE_APPICONS
1476 char *tinstance
, *tclass
;
1477 unsigned int nowmhints
= 0, matchwmhints
= 0, matchworkspace
= 0;
1484 #ifdef REDUCE_APPICONS
1485 if ((wapp
->main_window_desc
->wm_class
== NULL
) ||
1486 (wapp
->main_window_desc
->wm_instance
== NULL
))
1490 scr
= wapp
->main_window_desc
->screen_ptr
;
1491 wlist
= scr
->focused_window
;
1493 /* goto beginning of list */
1495 wlist
= wlist
->prev
;
1500 #ifndef REDUCE_APPICONS
1501 if (wlist
->main_window
== wapp
->main_window
) {
1503 matchwmhints
= matchworkspace
= 0;
1505 if ((tinstance
= wlist
->wm_instance
) == NULL
)
1507 if ((tclass
= wlist
->wm_class
) == NULL
)
1509 if ((strcmp(tinstance
, wapp
->main_window_desc
->wm_instance
) == 0)
1510 && (strcmp(tclass
, wapp
->main_window_desc
->wm_class
) == 0) )
1514 if (wlist
->frame
->workspace
== wapp
->main_window_desc
->screen_ptr
->current_workspace
)
1518 if ((wlist
->main_window
== wapp
->main_window
|| matchwmhints
) &&
1521 if (wlist
->flags
.focused
)
1523 else if (!focused
|| !focused
->flags
.focused
)
1526 if (wlist
->flags
.miniaturized
&& wlist
->icon
) {
1527 if (bringToCurrentWS
|| wPreferences
.sticky_icons
1528 || wlist
->frame
->workspace
== scr
->current_workspace
) {
1529 if (!wlist
->icon
->mapped
) {
1530 XMapWindow(dpy
, wlist
->icon
->core
->window
);
1531 wlist
->icon
->mapped
= 1;
1533 wlist
->flags
.hidden
= 0;
1535 UpdateSwitchMenu(scr
, wlist
, ACTION_CHANGE_STATE
);
1537 if (wlist
->frame
->workspace
!= scr
->current_workspace
)
1538 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1541 wDeiconifyWindow(wlist
);
1543 } else if (wlist
->flags
.hidden
) {
1544 unhideWindow(wapp
->app_icon
->icon
, wapp
->app_icon
->x_pos
,
1545 wapp
->app_icon
->y_pos
, wlist
,
1546 !wapp
->flags
.skip_next_animation
,
1549 if (bringToCurrentWS
1550 && wlist
->frame
->workspace
!= scr
->current_workspace
) {
1551 wWindowChangeWorkspace(wlist
, scr
->current_workspace
);
1553 wRaiseFrame(wlist
->frame
->core
);
1559 wapp
->flags
.skip_next_animation
= 0;
1560 wapp
->flags
.hidden
= 0;
1563 wSetFocusTo(scr
, focused
);
1564 else if (wapp
->last_focused
&& wapp
->last_focused
->flags
.mapped
)
1565 wSetFocusTo(scr
, wapp
->last_focused
);
1566 wapp
->last_focused
= NULL
;
1567 if (wPreferences
.auto_arrange_icons
) {
1568 wArrangeIcons(scr
, True
);
1571 wAppIconPaint(wapp
->app_icon
);
1578 wShowAllWindows(WScreen
*scr
)
1580 WWindow
*wwin
, *old_foc
;
1583 old_foc
= wwin
= scr
->focused_window
;
1585 if (!wwin
->flags
.internal_window
&&
1586 (scr
->current_workspace
== wwin
->frame
->workspace
1587 || IS_OMNIPRESENT(wwin
))) {
1588 if (wwin
->flags
.miniaturized
) {
1589 wwin
->flags
.skip_next_animation
= 1;
1590 wDeiconifyWindow(wwin
);
1591 } else if (wwin
->flags
.hidden
) {
1592 wapp
= wApplicationOf(wwin
->main_window
);
1594 wUnhideApplication(wapp
, False
, False
);
1596 wwin
->flags
.skip_next_animation
= 1;
1597 wDeiconifyWindow(wwin
);
1603 wSetFocusTo(scr
, old_foc
);
1604 /*wRaiseFrame(old_foc->frame->core);*/
1609 wRefreshDesktop(WScreen
*scr
)
1612 XSetWindowAttributes attr
;
1614 attr
.backing_store
= NotUseful
;
1615 attr
.save_under
= False
;
1616 win
= XCreateWindow(dpy
, scr
->root_win
, 0, 0, scr
->scr_width
,
1617 scr
->scr_height
, 0, CopyFromParent
, CopyFromParent
,
1618 (Visual
*)CopyFromParent
, CWBackingStore
|CWSaveUnder
,
1620 XMapRaised(dpy
, win
);
1621 XDestroyWindow(dpy
, win
);
1627 wArrangeIcons(WScreen
*scr
, Bool arrangeAll
)
1631 int pf
; /* primary axis */
1632 int sf
; /* secondary axis */
1636 int sx1
, sx2
, sy1
, sy2
; /* screen boundary */
1640 int isize
= wPreferences
.icon_size
;
1643 * Find out screen boundaries.
1647 sx2
= scr
->scr_width
;
1648 sy2
= scr
->scr_height
;
1650 if (scr
->dock
->on_right_side
)
1651 sx2
-= isize
+ DOCK_EXTRA_SPACE
;
1653 sx1
+= isize
+ DOCK_EXTRA_SPACE
;
1656 sw
= isize
* (scr
->scr_width
/isize
);
1657 sh
= isize
* (scr
->scr_height
/isize
);
1658 fullW
= (sx2
-sx1
)/isize
;
1659 fullH
= (sy2
-sy1
)/isize
;
1661 /* icon yard boundaries */
1662 if (wPreferences
.icon_yard
& IY_VERT
) {
1669 if (wPreferences
.icon_yard
& IY_RIGHT
) {
1676 if (wPreferences
.icon_yard
& IY_TOP
) {
1684 /* arrange icons putting the most recently focused window
1685 * as the last icon */
1686 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1687 : xo + xs*(pi*isize))
1688 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1689 : yo + ys*(si*isize))
1691 /* arrange application icons */
1692 aicon
= scr
->app_icon_list
;
1693 /* reverse them to avoid unnecessarily sliding of icons */
1694 while (aicon
&& aicon
->next
)
1695 aicon
= aicon
->next
;
1700 if (!aicon
->docked
) {
1701 if (aicon
->x_pos
!= X
|| aicon
->y_pos
!= Y
) {
1703 if (!wPreferences
.no_animations
) {
1704 SlideWindow(aicon
->icon
->core
->window
, aicon
->x_pos
, aicon
->y_pos
,
1707 #endif /* ANIMATIONS */
1709 wAppIconMove(aicon
, X
, Y
);
1712 /* we reversed the order so we use prev */
1713 aicon
= aicon
->prev
;
1720 /* arrange miniwindows */
1722 wwin
= scr
->focused_window
;
1723 /* reverse them to avoid unnecessarily shuffling */
1724 while (wwin
&& wwin
->prev
)
1728 if (wwin
->icon
&& wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
&&
1729 (wwin
->frame
->workspace
==scr
->current_workspace
||
1730 IS_OMNIPRESENT(wwin
) || wPreferences
.sticky_icons
)) {
1732 if (arrangeAll
|| !wwin
->flags
.icon_moved
) {
1733 if (wwin
->icon_x
!= X
|| wwin
->icon_y
!= Y
) {
1735 if (wPreferences
.no_animations
) {
1736 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1738 SlideWindow(wwin
->icon
->core
->window
, wwin
->icon_x
,
1739 wwin
->icon_y
, X
, Y
);
1742 XMoveWindow(dpy
, wwin
->icon
->core
->window
, X
, Y
);
1743 #endif /* ANIMATIONS */
1751 wwin
->flags
.icon_moved
= 0;
1753 /* we reversed the order, so we use next */
1764 wSelectWindow(WWindow
*wwin
, Bool flag
)
1766 WScreen
*scr
= wwin
->screen_ptr
;
1769 wwin
->flags
.selected
= 1;
1770 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
, scr
->white_pixel
);
1772 if (WFLAGP(wwin
, no_border
)) {
1773 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
,
1774 FRAME_BORDER_WIDTH
);
1777 if (!scr
->selected_windows
)
1778 scr
->selected_windows
= WMCreateBag(4);
1779 WMPutInBag(scr
->selected_windows
, wwin
);
1781 wwin
->flags
.selected
= 0;
1782 XSetWindowBorder(dpy
, wwin
->frame
->core
->window
,
1783 scr
->frame_border_pixel
);
1785 if (WFLAGP(wwin
, no_border
)) {
1786 XSetWindowBorderWidth(dpy
, wwin
->frame
->core
->window
, 0);
1789 if (scr
->selected_windows
) {
1790 WMRemoveFromBag(scr
->selected_windows
, wwin
);
1797 wMakeWindowVisible(WWindow
*wwin
)
1799 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
1800 wWorkspaceChange(wwin
->screen_ptr
, wwin
->frame
->workspace
);
1802 if (wwin
->flags
.shaded
) {
1803 wUnshadeWindow(wwin
);
1805 if (wwin
->flags
.hidden
) {
1808 app
= wApplicationOf(wwin
->main_window
);
1810 wUnhideApplication(app
, False
, False
);
1811 } else if (wwin
->flags
.miniaturized
) {
1812 wDeiconifyWindow(wwin
);
1814 if (!WFLAGP(wwin
, no_focusable
))
1815 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1816 wRaiseFrame(wwin
->frame
->core
);