1 /* action.c- misc. window commands (miniaturize, hide etc.)
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #include <X11/Xutil.h>
35 #include "WindowMaker.h"
42 #include "application.h"
48 #include "winspector.h"
49 #include "workspace.h"
54 /****** Global Variables ******/
55 extern Time LastTimestamp;
56 extern Time LastFocusChange;
58 extern Cursor wCursor[WCUR_LAST];
60 extern WPreferences wPreferences;
62 extern Atom _XA_WM_TAKE_FOCUS;
64 extern void ProcessPendingEvents();
67 /******* Local Variables *******/
72 {SHADE_STEPS_UF, SHADE_DELAY_UF},
73 {SHADE_STEPS_F, SHADE_DELAY_F},
74 {SHADE_STEPS_M, SHADE_DELAY_M},
75 {SHADE_STEPS_S, SHADE_DELAY_S},
76 {SHADE_STEPS_US, SHADE_DELAY_US}};
78 #define SHADE_STEPS shadePars[(int)wPreferences.shade_speed].steps
79 #define SHADE_DELAY shadePars[(int)wPreferences.shade_speed].delay
82 compareTimes(Time t1, Time t2)
88 return (diff < 60000) ? 1 : -1;
92 *----------------------------------------------------------------------
94 * Changes the window focus to the one passed as argument.
95 * If the window to focus is not already focused, it will be brought
96 * to the head of the list of windows. Previously focused window is
100 * Window list may be reordered and the window focus is changed.
102 *----------------------------------------------------------------------
105 wSetFocusTo(WScreen *scr, WWindow *wwin)
107 static WScreen *old_scr=NULL;
109 WWindow *old_focused;
110 WWindow *focused=scr->focused_window;
111 Time timestamp=LastTimestamp;
112 WApplication *oapp=NULL, *napp=NULL;
115 if (scr->flags.ignore_focus_events || compareTimes(LastFocusChange, timestamp) > 0)
120 old_focused=old_scr->focused_window;
122 LastFocusChange = timestamp;
125 oapp = wApplicationOf(old_focused->main_window);
128 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
130 wWindowUnfocus(old_focused);
133 wAppMenuUnmap(oapp->menu);
135 wApplicationDeactivate(oapp);
139 WMPostNotificationName(WMNChangedFocus, NULL, (void*)True);
141 } else if (old_scr != scr && old_focused) {
142 wWindowUnfocus(old_focused);
145 wasfocused = wwin->flags.focused;
146 napp = wApplicationOf(wwin->main_window);
148 /* remember last workspace where the app has been */
150 /*napp->last_workspace = wwin->screen_ptr->current_workspace;*/
151 napp->last_workspace = wwin->frame->workspace;
154 if (wwin->flags.mapped && !WFLAGP(wwin, no_focusable)) {
155 /* install colormap if colormap mode is lock mode */
156 if (wPreferences.colormap_mode==WCM_CLICK)
157 wColormapInstallForWindow(scr, wwin);
159 /* set input focus */
160 switch (wwin->focus_mode) {
162 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
166 case WFM_LOCALLY_ACTIVE:
167 XSetInputFocus(dpy, wwin->client_win, RevertToParent, CurrentTime);
170 case WFM_GLOBALLY_ACTIVE:
174 if (wwin->protocols.TAKE_FOCUS) {
175 wClientSendProtocol(wwin, _XA_WM_TAKE_FOCUS, timestamp);
179 XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime);
181 if (WFLAGP(wwin, no_focusable))
184 /* if this is not the focused window focus it */
186 /* change the focus window list order */
188 wwin->prev->next = wwin->next;
191 wwin->next->prev = wwin->prev;
193 wwin->prev = focused;
194 focused->next = wwin;
196 scr->focused_window = wwin;
198 if (oapp && oapp != napp) {
199 wAppMenuUnmap(oapp->menu);
201 wApplicationDeactivate(oapp);
206 wWindowFocus(wwin, focused);
208 if (napp && !wasfocused) {
210 wUserMenuRefreshInstances(napp->menu, wwin);
211 #endif /* USER_MENU */
213 if (wwin->flags.mapped)
214 wAppMenuMap(napp->menu, wwin);
216 wApplicationActivate(napp);
226 wShadeWindow(WWindow *wwin)
233 if (wwin->flags.shaded)
238 XLowerWindow(dpy, wwin->client_win);
240 wSoundPlay(WSOUND_SHADE);
243 if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation
244 && !wPreferences.no_animations) {
245 /* do the shading animation */
246 h = wwin->frame->core->height;
249 w = wwin->frame->core->width;
250 y = wwin->frame->top_width;
251 while (h>wwin->frame->top_width+1) {
252 XMoveWindow(dpy, wwin->client_win, 0, y);
253 XResizeWindow(dpy, wwin->frame->core->window, w, h);
256 if (time(NULL)-time0 > MAX_ANIMATION_TIME)
259 if (SHADE_DELAY > 0) {
260 wusleep(SHADE_DELAY*1000L);
267 XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
269 #endif /* ANIMATIONS */
271 wwin->flags.skip_next_animation = 0;
272 wwin->flags.shaded = 1;
273 wwin->flags.mapped = 0;
274 /* prevent window withdrawal when getting UnmapNotify */
275 XSelectInput(dpy, wwin->client_win,
276 wwin->event_mask & ~StructureNotifyMask);
277 XUnmapWindow(dpy, wwin->client_win);
278 XSelectInput(dpy, wwin->client_win, wwin->event_mask);
280 /* for the client it's just like iconification */
281 wFrameWindowResize(wwin->frame, wwin->frame->core->width,
282 wwin->frame->top_width - 1);
284 wwin->client.y = wwin->frame_y - wwin->client.height
285 + wwin->frame->top_width;
286 wWindowSynthConfigureNotify(wwin);
289 wClientSetState(wwin, IconicState, None);
292 WMPostNotificationName(WMNChangedState, wwin, "shade");
295 if (!wwin->screen_ptr->flags.startup) {
296 /* Catch up with events not processed while animation was running */
297 ProcessPendingEvents();
304 wUnshadeWindow(WWindow *wwin)
309 #endif /* ANIMATIONS */
312 if (!wwin->flags.shaded)
317 wwin->flags.shaded = 0;
318 wwin->flags.mapped = 1;
319 XMapWindow(dpy, wwin->client_win);
321 wSoundPlay(WSOUND_UNSHADE);
324 if (!wPreferences.no_animations && !wwin->flags.skip_next_animation) {
325 /* do the shading animation */
326 h = wwin->frame->top_width + wwin->frame->bottom_width;
327 y = wwin->frame->top_width - wwin->client.height;
328 s = abs(y)/SHADE_STEPS;
330 w = wwin->frame->core->width;
331 XMoveWindow(dpy, wwin->client_win, 0, y);
333 while (h < wwin->client.height + wwin->frame->top_width
334 + wwin->frame->bottom_width) {
335 XResizeWindow(dpy, wwin->frame->core->window, w, h);
336 XMoveWindow(dpy, wwin->client_win, 0, y);
338 if (SHADE_DELAY > 0) {
339 wusleep(SHADE_DELAY*2000L/3);
346 if (time(NULL)-time0 > MAX_ANIMATION_TIME)
350 XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);
352 #endif /* ANIMATIONS */
354 wwin->flags.skip_next_animation = 0;
355 wFrameWindowResize(wwin->frame, wwin->frame->core->width,
356 wwin->frame->top_width + wwin->client.height
357 + wwin->frame->bottom_width);
359 wwin->client.y = wwin->frame_y + wwin->frame->top_width;
360 wWindowSynthConfigureNotify(wwin);
363 wClientSetState(wwin, NormalState, None);
365 /* if the window is focused, set the focus again as it was disabled during
367 if (wwin->flags.focused)
368 wSetFocusTo(wwin->screen_ptr, wwin);
370 WMPostNotificationName(WMNChangedState, wwin, "shade");
375 wMaximizeWindow(WWindow *wwin, int directions)
378 unsigned int new_width, new_height;
379 int changed_h, changed_v, shrink_h, shrink_v;
380 WArea usableArea, totalArea;
382 if (!IS_RESIZABLE(wwin))
387 totalArea.x2 = wwin->screen_ptr->scr_width;
388 totalArea.y2 = wwin->screen_ptr->scr_height;
389 usableArea = totalArea;
391 if (!(directions & MAX_IGNORE_XINERAMA)) {
392 WScreen *scr = wwin->screen_ptr;
395 if (directions & MAX_KEYBOARD)
396 head = wGetHeadForWindow(wwin);
398 head = wGetHeadForPointerLocation(scr);
400 usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True);
403 if (WFLAGP(wwin, full_maximize)) {
404 usableArea = totalArea;
407 if (wwin->flags.shaded) {
408 wwin->flags.skip_next_animation = 1;
409 wUnshadeWindow(wwin);
411 /* Only save directions, not kbd or xinerama hints */
412 directions &= (MAX_HORIZONTAL|MAX_VERTICAL);
414 changed_h = ((wwin->flags.maximized ^ directions) & MAX_HORIZONTAL);
415 changed_v = ((wwin->flags.maximized ^ directions) & MAX_VERTICAL);
416 shrink_h = (changed_h && (directions & MAX_HORIZONTAL)==0);
417 shrink_v = (changed_v && (directions & MAX_VERTICAL)==0);
419 if (wwin->flags.maximized) {
420 /* if already maximized in some direction, we only update the
421 * appropriate old x, old y coordinates. This is necessary to
422 * allow succesive maximizations in different directions without
423 * the need to first do an un-maximize (to avoid flicker).
425 if (!(wwin->flags.maximized & MAX_HORIZONTAL)) {
426 wwin->old_geometry.x = wwin->frame_x;
428 if (!(wwin->flags.maximized & MAX_VERTICAL)) {
429 wwin->old_geometry.y = wwin->frame_y;
432 wwin->old_geometry.width = wwin->client.width;
433 wwin->old_geometry.height = wwin->client.height;
434 wwin->old_geometry.x = wwin->frame_x;
435 wwin->old_geometry.y = wwin->frame_y;
437 wwin->flags.maximized = directions;
439 if (directions & MAX_HORIZONTAL) {
440 new_width = (usableArea.x2-usableArea.x1)-FRAME_BORDER_WIDTH*2;
441 new_x = usableArea.x1;
442 } else if (shrink_h) {
443 new_x = wwin->old_geometry.x;
444 new_width = wwin->old_geometry.width;
446 new_x = wwin->frame_x;
447 new_width = wwin->frame->core->width;
450 if (directions & MAX_VERTICAL) {
451 new_height = (usableArea.y2-usableArea.y1)-FRAME_BORDER_WIDTH*2;
452 new_y = usableArea.y1;
453 if (WFLAGP(wwin, full_maximize)) {
454 new_y -= wwin->frame->top_width;
455 new_height += wwin->frame->bottom_width - 1;
457 } else if (shrink_v) {
458 new_y = wwin->old_geometry.y;
459 new_height = wwin->old_geometry.height;
461 new_y = wwin->frame_y;
462 new_height = wwin->frame->core->height;
465 if (!WFLAGP(wwin, full_maximize)) {
466 new_height -= wwin->frame->top_width+wwin->frame->bottom_width;
469 wWindowConstrainSize(wwin, &new_width, &new_height);
471 wWindowCropSize(wwin, usableArea.x2-usableArea.x1,
472 usableArea.y2-usableArea.y1,
473 &new_width, &new_height);
475 wWindowConfigure(wwin, new_x, new_y, new_width, new_height);
478 WMPostNotificationName(WMNChangedState, wwin, "maximize");
480 wSoundPlay(WSOUND_MAXIMIZE);
485 wUnmaximizeWindow(WWindow *wwin)
489 if (!wwin->flags.maximized)
492 if (wwin->flags.shaded) {
493 wwin->flags.skip_next_animation = 1;
494 wUnshadeWindow(wwin);
496 x = ((wwin->flags.maximized & MAX_HORIZONTAL) && wwin->old_geometry.x) ?
497 wwin->old_geometry.x : wwin->frame_x;
498 y = ((wwin->flags.maximized & MAX_VERTICAL) && wwin->old_geometry.y) ?
499 wwin->old_geometry.y : wwin->frame_y;
500 w = wwin->old_geometry.width ?
501 wwin->old_geometry.width : wwin->client.width;
502 h = wwin->old_geometry.height ?
503 wwin->old_geometry.height : wwin->client.height;
505 wwin->flags.maximized = 0;
506 wWindowConfigure(wwin, x, y, w, h);
508 WMPostNotificationName(WMNChangedState, wwin, "maximize");
510 wSoundPlay(WSOUND_UNMAXIMIZE);
515 wFullscreenWindow(WWindow *wwin)
520 if (wwin->flags.fullscreen)
523 wwin->flags.fullscreen = True;
525 wWindowConfigureBorders(wwin);
527 ChangeStackingLevel(wwin->frame->core, WMFullscreenLevel);
529 wwin->bfs_geometry.x = wwin->frame_x;
530 wwin->bfs_geometry.y = wwin->frame_y;
531 wwin->bfs_geometry.width = wwin->frame->core->width;
532 wwin->bfs_geometry.height = wwin->frame->core->height;
534 head = wGetHeadForWindow(wwin);
535 rect = wGetRectForHead(wwin->screen_ptr, head);
536 wWindowConfigure(wwin, rect.pos.x, rect.pos.y,
537 rect.size.width, rect.size.height);
539 WMPostNotificationName(WMNChangedState, wwin, "fullscreen");
544 wUnfullscreenWindow(WWindow *wwin)
546 if (!wwin->flags.fullscreen)
549 wwin->flags.fullscreen = False;
551 if (wwin->frame->core->stacking->window_level == WMFullscreenLevel) {
552 if (WFLAGP(wwin, sunken)) {
553 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
554 } else if (WFLAGP(wwin, floating)) {
555 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
557 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
561 wWindowConfigure(wwin, wwin->bfs_geometry.x, wwin->bfs_geometry.y,
562 wwin->bfs_geometry.width, wwin->bfs_geometry.height);
564 wWindowConfigureBorders(wwin);
566 // seems unnecessary, but also harmless (doesn't generate flicker) -Dan
567 wFrameWindowPaint(wwin->frame);
570 WMPostNotificationName(WMNChangedState, wwin, "fullscreen");
576 animateResizeFlip(WScreen *scr, int x, int y, int w, int h,
577 int fx, int fy, int fw, int fh, int steps)
579 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F)
580 float cx, cy, cw, ch;
581 float xstep, ystep, wstep, hstep;
584 float angle, final_angle, delta;
586 xstep = (float)(fx-x)/steps;
587 ystep = (float)(fy-y)/steps;
588 wstep = (float)(fw-w)/steps;
589 hstep = (float)(fh-h)/steps;
596 final_angle = 2*WM_PI*MINIATURIZE_ANIMATION_TWIST_F;
597 delta = (float)(final_angle/FRAMES);
598 for (angle=0;; angle+=delta) {
599 if (angle > final_angle)
602 dx = (cw/10) - ((cw/5) * sin(angle));
603 dch = (ch/2) * cos(angle);
606 points[0].x = cx + dx; points[0].y = midy - dch;
607 points[1].x = cx + cw - dx; points[1].y = points[0].y;
608 points[2].x = cx + cw + dx; points[2].y = midy + dch;
609 points[3].x = cx - dx; points[3].y = points[2].y;
610 points[4].x = points[0].x; points[4].y = points[0].y;
613 XDrawLines(dpy,scr->root_win,scr->frame_gc,points, 5, CoordModeOrigin);
615 #if (MINIATURIZE_ANIMATION_DELAY_F > 0)
616 wusleep(MINIATURIZE_ANIMATION_DELAY_F);
621 XDrawLines(dpy,scr->root_win,scr->frame_gc,points, 5, CoordModeOrigin);
627 if (angle >= final_angle)
637 animateResizeTwist(WScreen *scr, int x, int y, int w, int h,
638 int fx, int fy, int fw, int fh, int steps)
640 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T)
641 float cx, cy, cw, ch;
642 float xstep, ystep, wstep, hstep;
644 float angle, final_angle, a, d, delta;
651 xstep = (float)(fx-x)/steps;
652 ystep = (float)(fy-y)/steps;
653 wstep = (float)(fw-w)/steps;
654 hstep = (float)(fh-h)/steps;
661 final_angle = 2*WM_PI*MINIATURIZE_ANIMATION_TWIST_T;
662 delta = (float)(final_angle/FRAMES);
663 for (angle=0;; angle+=delta) {
664 if (angle > final_angle)
668 d = sqrt((cw/2)*(cw/2)+(ch/2)*(ch/2));
670 points[0].x = cx+cos(angle-a)*d;
671 points[0].y = cy+sin(angle-a)*d;
672 points[1].x = cx+cos(angle+a)*d;
673 points[1].y = cy+sin(angle+a)*d;
674 points[2].x = cx+cos(angle-a+WM_PI)*d;
675 points[2].y = cy+sin(angle-a+WM_PI)*d;
676 points[3].x = cx+cos(angle+a+WM_PI)*d;
677 points[3].y = cy+sin(angle+a+WM_PI)*d;
678 points[4].x = cx+cos(angle-a)*d;
679 points[4].y = cy+sin(angle-a)*d;
681 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
683 #if (MINIATURIZE_ANIMATION_DELAY_T > 0)
684 wusleep(MINIATURIZE_ANIMATION_DELAY_T);
689 XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin);
695 if (angle >= final_angle)
705 animateResizeZoom(WScreen *scr, int x, int y, int w, int h,
706 int fx, int fy, int fw, int fh, int steps)
708 #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_Z)
709 float cx[FRAMES], cy[FRAMES], cw[FRAMES], ch[FRAMES];
710 float xstep, ystep, wstep, hstep;
713 xstep = (float)(fx-x)/steps;
714 ystep = (float)(fy-y)/steps;
715 wstep = (float)(fw-w)/steps;
716 hstep = (float)(fh-h)/steps;
718 for (j=0; j<FRAMES; j++) {
725 for (i=0; i<steps; i++) {
726 for (j=0; j<FRAMES; j++) {
727 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
728 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
731 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
732 wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
736 for (j=0; j<FRAMES; j++) {
737 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
738 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
753 for (j=0; j<FRAMES; j++) {
754 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
755 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
758 #if (MINIATURIZE_ANIMATION_DELAY_Z > 0)
759 wusleep(MINIATURIZE_ANIMATION_DELAY_Z);
763 for (j=0; j<FRAMES; j++) {
764 XDrawRectangle(dpy, scr->root_win, scr->frame_gc,
765 (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]);
774 animateResize(WScreen *scr, int x, int y, int w, int h,
775 int fx, int fy, int fw, int fh, int hiding)
777 int style = wPreferences.iconification_style; /* Catch the value */
780 if (style == WIS_NONE)
783 if (style == WIS_RANDOM) {
787 k = (hiding ? 2 : 3);
791 steps = (MINIATURIZE_ANIMATION_STEPS_T * k)/3;
793 animateResizeTwist(scr, x, y, w, h, fx, fy, fw, fh, steps);
796 steps = (MINIATURIZE_ANIMATION_STEPS_F * k)/3;
798 animateResizeFlip(scr, x, y, w, h, fx, fy, fw, fh, steps);
802 steps = (MINIATURIZE_ANIMATION_STEPS_Z * k)/3;
804 animateResizeZoom(scr, x, y, w, h, fx, fy, fw, fh, steps);
808 #endif /* ANIMATIONS */
816 while (XCheckTypedEvent(dpy, Expose, &tmpev))
817 WMHandleEvent(&tmpev);
822 unmapTransientsFor(WWindow *wwin)
827 tmp = wwin->screen_ptr->focused_window;
829 /* unmap the transients for this transient */
830 if (tmp!=wwin && tmp->transient_for == wwin->client_win
831 && (tmp->flags.mapped || wwin->screen_ptr->flags.startup
832 || tmp->flags.shaded)) {
833 unmapTransientsFor(tmp);
834 tmp->flags.miniaturized = 1;
835 if (!tmp->flags.shaded) {
838 XUnmapWindow(dpy, tmp->frame->core->window);
841 if (!tmp->flags.shaded)
843 wClientSetState(tmp, IconicState, None);
845 WMPostNotificationName(WMNChangedState, tmp, "iconify-transient");
853 mapTransientsFor(WWindow *wwin)
857 tmp = wwin->screen_ptr->focused_window;
859 /* recursively map the transients for this transient */
860 if (tmp!=wwin && tmp->transient_for == wwin->client_win
861 && /*!tmp->flags.mapped*/ tmp->flags.miniaturized
862 && tmp->icon==NULL) {
863 mapTransientsFor(tmp);
864 tmp->flags.miniaturized = 0;
865 if (!tmp->flags.shaded) {
868 XMapWindow(dpy, tmp->frame->core->window);
870 tmp->flags.semi_focused = 0;
872 if (!tmp->flags.shaded)
874 wClientSetState(tmp, NormalState, None);
876 WMPostNotificationName(WMNChangedState, tmp, "iconify-transient");
884 setupIconGrabs(WIcon *icon)
886 /* setup passive grabs on the icon */
887 XGrabButton(dpy, Button1, AnyModifier, icon->core->window, True,
888 ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
889 XGrabButton(dpy, Button2, AnyModifier, icon->core->window, True,
890 ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
891 XGrabButton(dpy, Button3, AnyModifier, icon->core->window, True,
892 ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
898 recursiveTransientFor(WWindow *wwin)
905 /* hackish way to detect transient_for cycle */
906 i = wwin->screen_ptr->window_count+1;
908 while (wwin && wwin->transient_for != None && i>0) {
909 wwin = wWindowFor(wwin->transient_for);
913 wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.",
923 removeIconGrabs(WIcon *icon)
925 /* remove passive grabs on the icon */
926 XUngrabButton(dpy, Button1, AnyModifier, icon->core->window);
927 XUngrabButton(dpy, Button2, AnyModifier, icon->core->window);
928 XUngrabButton(dpy, Button3, AnyModifier, icon->core->window);
935 wIconifyWindow(WWindow *wwin)
937 XWindowAttributes attribs;
941 if (!XGetWindowAttributes(dpy, wwin->client_win, &attribs)) {
942 /* the window doesn't exist anymore */
946 if (wwin->flags.miniaturized) {
950 if (wwin->transient_for!=None &&
951 wwin->transient_for!=wwin->screen_ptr->root_win) {
952 WWindow *owner = wWindowFor(wwin->transient_for);
954 if (owner && owner->flags.miniaturized)
958 present = wwin->frame->workspace==wwin->screen_ptr->current_workspace;
960 /* if the window is in another workspace, simplify process */
962 /* icon creation may take a while */
963 XGrabPointer(dpy, wwin->screen_ptr->root_win, False,
964 ButtonMotionMask|ButtonReleaseMask, GrabModeAsync,
965 GrabModeAsync, None, None, CurrentTime);
968 if (!wPreferences.disable_miniwindows
970 && !wwin->flags.net_handle_icon
973 if (!wwin->flags.icon_moved) {
974 PlaceIcon(wwin->screen_ptr, &wwin->icon_x, &wwin->icon_y, wGetHeadForWindow(wwin));
976 wwin->icon = wIconCreate(wwin);
978 wwin->icon->mapped = 1;
981 wwin->flags.miniaturized = 1;
982 wwin->flags.mapped = 0;
984 /* unmap transients */
986 unmapTransientsFor(wwin);
989 wSoundPlay(WSOUND_ICONIFY);
991 XUngrabPointer(dpy, CurrentTime);
993 /* let all Expose events arrive so that we can repaint
994 * something before the animation starts (and the server is grabbed) */
997 if (wPreferences.disable_miniwindows
999 || wwin->flags.net_handle_icon
1002 wClientSetState(wwin, IconicState, None);
1004 wClientSetState(wwin, IconicState, wwin->icon->icon_win);
1008 if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation
1009 && !wPreferences.no_animations) {
1012 if (!wPreferences.disable_miniwindows
1014 && !wwin->flags.net_handle_icon
1019 iw = wwin->icon->core->width;
1020 ih = wwin->icon->core->height;
1023 if (wwin->flags.net_handle_icon) {
1033 iw = wwin->screen_ptr->scr_width;
1034 ih = wwin->screen_ptr->scr_height;
1037 animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
1038 wwin->frame->core->width, wwin->frame->core->height,
1039 ix, iy, iw, ih, False);
1044 wwin->flags.skip_next_animation = 0;
1046 if (!wPreferences.disable_miniwindows
1048 && !wwin->flags.net_handle_icon
1052 if (wwin->screen_ptr->current_workspace==wwin->frame->workspace ||
1053 IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)
1055 XMapWindow(dpy, wwin->icon->core->window);
1057 AddToStackList(wwin->icon->core);
1059 wLowerFrame(wwin->icon->core);
1063 WWindow *owner = recursiveTransientFor(wwin->screen_ptr->focused_window);
1066 * It doesn't seem to be working and causes button event hangup
1067 * when deiconifying a transient window.
1068 setupIconGrabs(wwin->icon);
1070 if ((wwin->flags.focused
1071 || (owner && wwin->client_win == owner->client_win))
1072 && wPreferences.focus_mode==WKF_CLICK) {
1077 if (!WFLAGP(tmp, no_focusable)
1078 && !(tmp->flags.hidden||tmp->flags.miniaturized)
1079 && (wwin->frame->workspace == tmp->frame->workspace))
1083 wSetFocusTo(wwin->screen_ptr, tmp);
1084 } else if (wPreferences.focus_mode!=WKF_CLICK) {
1085 wSetFocusTo(wwin->screen_ptr, NULL);
1089 if (!wwin->screen_ptr->flags.startup) {
1090 /* Catch up with events not processed while animation was running */
1091 Window clientwin = wwin->client_win;
1093 ProcessPendingEvents();
1095 /* the window can disappear while ProcessPendingEvents() runs */
1096 if (!wWindowFor(clientwin)) {
1103 /* maybe we want to do this regardless of net_handle_icon
1104 * it seems to me we might break behaviour this way.
1106 if (wwin->flags.selected && !wPreferences.disable_miniwindows
1108 && !wwin->flags.net_handle_icon
1111 wIconSelect(wwin->icon);
1113 WMPostNotificationName(WMNChangedState, wwin, "iconify");
1120 wDeiconifyWindow(WWindow *wwin)
1123 /* we're hiding for show_desktop */
1124 int netwm_hidden = wwin->flags.net_show_desktop &&
1125 wwin->frame->workspace!=wwin->screen_ptr->current_workspace;
1127 int netwm_hidden = False;
1131 wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace);
1133 if (!wwin->flags.miniaturized)
1136 if (wwin->transient_for != None
1137 && wwin->transient_for != wwin->screen_ptr->root_win) {
1138 WWindow *owner = recursiveTransientFor(wwin);
1140 if (owner && owner->flags.miniaturized) {
1141 wDeiconifyWindow(owner);
1142 wSetFocusTo(wwin->screen_ptr, wwin);
1143 wRaiseFrame(wwin->frame->core);
1148 wwin->flags.miniaturized = 0;
1150 if (!netwm_hidden && !wwin->flags.shaded) {
1151 wwin->flags.mapped = 1;
1154 if (!netwm_hidden || wPreferences.sticky_icons) {
1155 /* maybe we want to do this regardless of net_handle_icon
1156 * it seems to me we might break behaviour this way.
1158 if (!wPreferences.disable_miniwindows
1160 && !wwin->flags.net_handle_icon
1162 && wwin->icon != NULL) {
1163 if (wwin->icon->selected)
1164 wIconSelect(wwin->icon);
1166 XUnmapWindow(dpy, wwin->icon->core->window);
1171 wSoundPlay(WSOUND_DEICONIFY);
1173 /* if the window is in another workspace, do it silently */
1174 if (!netwm_hidden) {
1176 if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations
1177 && !wwin->flags.skip_next_animation && wwin->icon != NULL) {
1180 if (!wPreferences.disable_miniwindows
1182 && !wwin->flags.net_handle_icon
1187 iw = wwin->icon->core->width;
1188 ih = wwin->icon->core->height;
1191 if (wwin->flags.net_handle_icon) {
1201 iw = wwin->screen_ptr->scr_width;
1202 ih = wwin->screen_ptr->scr_height;
1205 animateResize(wwin->screen_ptr, ix, iy, iw, ih,
1206 wwin->frame_x, wwin->frame_y,
1207 wwin->frame->core->width, wwin->frame->core->height,
1210 #endif /* ANIMATIONS */
1211 wwin->flags.skip_next_animation = 0;
1213 if (!wwin->flags.shaded) {
1214 XMapWindow(dpy, wwin->client_win);
1216 XMapWindow(dpy, wwin->frame->core->window);
1217 wRaiseFrame(wwin->frame->core);
1218 if (!wwin->flags.shaded) {
1219 wClientSetState(wwin, NormalState, None);
1221 mapTransientsFor(wwin);
1224 if (!wPreferences.disable_miniwindows && wwin->icon != NULL
1226 && !wwin->flags.net_handle_icon
1229 RemoveFromStackList(wwin->icon->core);
1230 /* removeIconGrabs(wwin->icon);*/
1231 wIconDestroy(wwin->icon);
1235 if (!netwm_hidden) {
1238 wSetFocusTo(wwin->screen_ptr, wwin);
1241 if (!wwin->screen_ptr->flags.startup) {
1242 /* Catch up with events not processed while animation was running */
1243 Window clientwin = wwin->client_win;
1245 ProcessPendingEvents();
1247 /* the window can disappear while ProcessPendingEvents() runs */
1248 if (!wWindowFor(clientwin)) {
1255 if (wPreferences.auto_arrange_icons) {
1256 wArrangeIcons(wwin->screen_ptr, True);
1259 WMPostNotificationName(WMNChangedState, wwin, "iconify");
1261 /* In case we were shaded and iconified, also unshade */
1263 wUnshadeWindow(wwin);
1269 hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate)
1271 if (wwin->flags.miniaturized) {
1273 XUnmapWindow(dpy, wwin->icon->core->window);
1274 wwin->icon->mapped = 0;
1276 wwin->flags.hidden = 1;
1278 WMPostNotificationName(WMNChangedState, wwin, "hide");
1282 if (wwin->flags.inspector_open) {
1283 wHideInspectorForWindow(wwin);
1286 wwin->flags.hidden = 1;
1289 wClientSetState(wwin, IconicState, icon->icon_win);
1291 wSoundPlay(WSOUND_HIDE);
1293 if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations &&
1294 !wwin->flags.skip_next_animation && animate) {
1295 animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y,
1296 wwin->frame->core->width, wwin->frame->core->height,
1297 icon_x, icon_y, icon->core->width, icon->core->height,
1301 wwin->flags.skip_next_animation = 0;
1303 WMPostNotificationName(WMNChangedState, wwin, "hide");
1309 wHideOtherApplications(WWindow *awin)
1316 wwin = awin->screen_ptr->focused_window;
1321 && wwin->frame->workspace == awin->screen_ptr->current_workspace
1322 && !(wwin->flags.miniaturized||wwin->flags.hidden)
1323 && !wwin->flags.internal_window
1324 && wGetWindowOfInspectorForWindow(wwin) != awin
1325 && !WFLAGP(wwin, no_hide_others)) {
1327 if (wwin->main_window==None || WFLAGP(wwin, no_appicon)) {
1328 if (!WFLAGP(wwin, no_miniaturizable)) {
1329 wwin->flags.skip_next_animation = 1;
1330 wIconifyWindow(wwin);
1332 } else if (wwin->main_window!=None
1333 && awin->main_window != wwin->main_window) {
1334 tapp = wApplicationOf(wwin->main_window);
1336 tapp->flags.skip_next_animation = 1;
1337 wHideApplication(tapp);
1339 if (!WFLAGP(wwin, no_miniaturizable)) {
1340 wwin->flags.skip_next_animation = 1;
1341 wIconifyWindow(wwin);
1349 wSetFocusTo(awin->screen_ptr, awin);
1356 wHideApplication(WApplication *wapp)
1364 wwarning("trying to hide a non grouped window");
1367 if (!wapp->main_window_desc) {
1368 wwarning("group leader not found for window group");
1371 scr = wapp->main_window_desc->screen_ptr;
1373 wlist = scr->focused_window;
1377 if (wlist->main_window == wapp->main_window)
1378 wapp->last_focused = wlist;
1380 wapp->last_focused = NULL;
1382 animate = !wapp->flags.skip_next_animation;
1385 if (wlist->main_window == wapp->main_window) {
1386 if (wlist->flags.focused) {
1389 if (wapp->app_icon) {
1390 hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
1391 wapp->app_icon->y_pos, wlist, animate);
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;
1438 wSoundPlay(WSOUND_UNHIDE);
1440 if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations
1442 animateResize(wwin->screen_ptr, icon_x, icon_y,
1443 icon->core->width, icon->core->height,
1444 wwin->frame_x, wwin->frame_y,
1445 wwin->frame->core->width, wwin->frame->core->height,
1449 wwin->flags.skip_next_animation = 0;
1450 if (wwin->screen_ptr->current_workspace == wwin->frame->workspace) {
1451 XMapWindow(dpy, wwin->client_win);
1452 XMapWindow(dpy, wwin->frame->core->window);
1453 wClientSetState(wwin, NormalState, None);
1454 wwin->flags.mapped=1;
1455 wRaiseFrame(wwin->frame->core);
1457 if (wwin->flags.inspector_open) {
1458 wUnhideInspectorForWindow(wwin);
1461 WMPostNotificationName(WMNChangedState, wwin, "hide");
1466 wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS)
1469 WWindow *wlist, *next;
1470 WWindow *focused=NULL;
1476 scr = wapp->main_window_desc->screen_ptr;
1477 wlist = scr->focused_window;
1481 /* goto beginning of list */
1483 wlist = wlist->prev;
1485 animate = !wapp->flags.skip_next_animation;
1490 if (wlist->main_window == wapp->main_window) {
1491 if (wlist->flags.focused)
1493 else if (!focused || !focused->flags.focused)
1496 if (wlist->flags.miniaturized) {
1497 if ((bringToCurrentWS || wPreferences.sticky_icons ||
1498 wlist->frame->workspace == scr->current_workspace) &&
1500 if (!wlist->icon->mapped) {
1503 PlaceIcon(scr, &x, &y, wGetHeadForWindow(wlist));
1504 if (wlist->icon_x!=x || wlist->icon_y!=y) {
1505 XMoveWindow(dpy, wlist->icon->core->window, x, y);
1509 XMapWindow(dpy, wlist->icon->core->window);
1510 wlist->icon->mapped = 1;
1512 wRaiseFrame(wlist->icon->core);
1514 if (bringToCurrentWS)
1515 wWindowChangeWorkspace(wlist, scr->current_workspace);
1516 wlist->flags.hidden = 0;
1518 wlist->frame->workspace == scr->current_workspace) {
1519 wDeiconifyWindow(wlist);
1521 WMPostNotificationName(WMNChangedState, wlist, "hide");
1522 } else if (wlist->flags.shaded) {
1523 if (bringToCurrentWS)
1524 wWindowChangeWorkspace(wlist, scr->current_workspace);
1525 wlist->flags.hidden = 0;
1526 if (wlist->frame->workspace == scr->current_workspace) {
1527 XMapWindow(dpy, wlist->frame->core->window);
1529 wUnshadeWindow(wlist);
1530 wRaiseFrame(wlist->frame->core);
1533 WMPostNotificationName(WMNChangedState, wlist, "hide");
1534 } else if (wlist->flags.hidden) {
1535 unhideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos,
1536 wapp->app_icon->y_pos, wlist, animate,
1540 if (bringToCurrentWS
1541 && wlist->frame->workspace != scr->current_workspace) {
1542 wWindowChangeWorkspace(wlist, scr->current_workspace);
1544 wRaiseFrame(wlist->frame->core);
1550 wapp->flags.skip_next_animation = 0;
1551 wapp->flags.hidden = 0;
1553 if (wapp->last_focused && wapp->last_focused->flags.mapped) {
1554 wRaiseFrame(wapp->last_focused->frame->core);
1555 wSetFocusTo(scr, wapp->last_focused);
1556 } else if (focused) {
1557 wSetFocusTo(scr, focused);
1559 wapp->last_focused = NULL;
1560 if (wPreferences.auto_arrange_icons) {
1561 wArrangeIcons(scr, True);
1564 wAppIconPaint(wapp->app_icon);
1570 wShowAllWindows(WScreen *scr)
1572 WWindow *wwin, *old_foc;
1575 old_foc = wwin = scr->focused_window;
1577 if (!wwin->flags.internal_window &&
1578 (scr->current_workspace == wwin->frame->workspace
1579 || IS_OMNIPRESENT(wwin))) {
1580 if (wwin->flags.miniaturized) {
1581 wwin->flags.skip_next_animation = 1;
1582 wDeiconifyWindow(wwin);
1583 } else if (wwin->flags.hidden) {
1584 wapp = wApplicationOf(wwin->main_window);
1586 wUnhideApplication(wapp, False, False);
1588 wwin->flags.skip_next_animation = 1;
1589 wDeiconifyWindow(wwin);
1595 wSetFocusTo(scr, old_foc);
1596 /*wRaiseFrame(old_foc->frame->core);*/
1601 wRefreshDesktop(WScreen *scr)
1604 XSetWindowAttributes attr;
1606 attr.backing_store = NotUseful;
1607 attr.save_under = False;
1608 win = XCreateWindow(dpy, scr->root_win, 0, 0, scr->scr_width,
1609 scr->scr_height, 0, CopyFromParent, CopyFromParent,
1610 (Visual *)CopyFromParent, CWBackingStore|CWSaveUnder,
1612 XMapRaised(dpy, win);
1613 XDestroyWindow(dpy, win);
1619 wArrangeIcons(WScreen *scr, Bool arrangeAll)
1625 const int heads = wXineramaHeads(scr);
1628 int pf; /* primary axis */
1629 int sf; /* secondary axis */
1633 int sx1, sx2, sy1, sy2; /* screen boundary */
1639 int isize = wPreferences.icon_size;
1641 vars = (struct HeadVars*)wmalloc(sizeof(struct HeadVars)*heads);
1643 for (head = 0; head < heads; ++head) {
1645 WMRect rect = wGetRectForHead(scr, head);
1647 WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
1648 WMRect rect = wmkrect(area.x1, area.y1, area.x2-area.x1, area.y2-area.y1);
1651 vars[head].pi = vars[head].si = 0;
1652 vars[head].sx1 = rect.pos.x;
1653 vars[head].sy1 = rect.pos.y;
1654 vars[head].sw = rect.size.width;
1655 vars[head].sh = rect.size.height;
1656 vars[head].sx2 = vars[head].sx1 + vars[head].sw;
1657 vars[head].sy2 = vars[head].sy1 + vars[head].sh;
1661 if (scr->dock->on_right_side)
1662 vars[head].sx2 -= isize + DOCK_EXTRA_SPACE;
1664 vars[head].sx1 += isize + DOCK_EXTRA_SPACE;
1668 vars[head].sw = isize * (vars[head].sw/isize);
1669 vars[head].sh = isize * (vars[head].sh/isize);
1670 vars[head].fullW = (vars[head].sx2-vars[head].sx1)/isize;
1671 vars[head].fullH = (vars[head].sy2-vars[head].sy1)/isize;
1673 /* icon yard boundaries */
1674 if (wPreferences.icon_yard & IY_VERT) {
1675 vars[head].pf = vars[head].fullH;
1676 vars[head].sf = vars[head].fullW;
1678 vars[head].pf = vars[head].fullW;
1679 vars[head].sf = vars[head].fullH;
1681 if (wPreferences.icon_yard & IY_RIGHT) {
1682 vars[head].xo = vars[head].sx2 - isize;
1685 vars[head].xo = vars[head].sx1;
1688 if (wPreferences.icon_yard & IY_TOP) {
1689 vars[head].yo = vars[head].sy1;
1692 vars[head].yo = vars[head].sy2 - isize;
1697 #define X ((wPreferences.icon_yard & IY_VERT) \
1698 ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \
1699 : vars[head].xo + vars[head].xs*(vars[head].pi*isize))
1701 #define Y ((wPreferences.icon_yard & IY_VERT) \
1702 ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \
1703 : vars[head].yo + vars[head].ys*(vars[head].si*isize))
1706 /* arrange application icons */
1707 aicon = scr->app_icon_list;
1708 /* reverse them to avoid unnecessarily sliding of icons */
1709 while (aicon && aicon->next)
1710 aicon = aicon->next;
1713 if (!aicon->docked) {
1714 /* CHECK: can icon be NULL here ? */
1715 /* The intention here is to place the AppIcon on the head that
1716 * contains most of the applications _main_ window. */
1717 head = wGetHeadForWindow(aicon->icon->owner);
1719 if (aicon->x_pos != X || aicon->y_pos != Y) {
1721 if (!wPreferences.no_animations) {
1722 SlideWindow(aicon->icon->core->window,
1723 aicon->x_pos, aicon->y_pos, X, Y);
1725 #endif /* ANIMATIONS */
1727 wAppIconMove(aicon, X, Y);
1729 if (vars[head].pi >= vars[head].pf) {
1734 aicon = aicon->prev;
1737 /* arrange miniwindows */
1738 wwin = scr->focused_window;
1739 /* reverse them to avoid unnecessarily shuffling */
1740 while (wwin && wwin->prev)
1744 if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden &&
1745 (wwin->frame->workspace==scr->current_workspace ||
1746 IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) {
1748 head = wGetHeadForWindow(wwin);
1750 if (arrangeAll || !wwin->flags.icon_moved) {
1751 if (wwin->icon_x != X || wwin->icon_y != Y) {
1753 if (wPreferences.no_animations) {
1754 XMoveWindow(dpy, wwin->icon->core->window, X, Y);
1756 SlideWindow(wwin->icon->core->window, wwin->icon_x,
1757 wwin->icon_y, X, Y);
1760 XMoveWindow(dpy, wwin->icon->core->window, X, Y);
1761 #endif /* ANIMATIONS */
1767 if (vars[head].pi >= vars[head].pf) {
1774 wwin->flags.icon_moved = 0;
1776 /* we reversed the order, so we use next */
1785 wArrangeIcons(WScreen *scr, Bool arrangeAll)
1789 int pf; /* primary axis */
1790 int sf; /* secondary axis */
1794 int sx1, sx2, sy1, sy2; /* screen boundary */
1798 int isize = wPreferences.icon_size;
1801 * Find out screen boundaries.
1805 * Allows each head to have miniwindows
1807 WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
1811 sw = rect.size.width;
1812 sh = rect.size.height;
1816 if (scr->dock->on_right_side)
1817 sx2 -= isize + DOCK_EXTRA_SPACE;
1819 sx1 += isize + DOCK_EXTRA_SPACE;
1823 sw = isize * (scr->scr_width/isize);
1824 sh = isize * (scr->scr_height/isize);
1826 sw = isize * (sw/isize);
1827 sh = isize * (sh/isize);
1829 fullW = (sx2-sx1)/isize;
1830 fullH = (sy2-sy1)/isize;
1832 /* icon yard boundaries */
1833 if (wPreferences.icon_yard & IY_VERT) {
1840 if (wPreferences.icon_yard & IY_RIGHT) {
1847 if (wPreferences.icon_yard & IY_TOP) {
1855 /* arrange icons putting the most recently focused window
1856 * as the last icon */
1857 #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\
1858 : xo + xs*(pi*isize))
1859 #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\
1860 : yo + ys*(si*isize))
1862 /* arrange application icons */
1863 aicon = scr->app_icon_list;
1864 /* reverse them to avoid unnecessarily sliding of icons */
1865 while (aicon && aicon->next)
1866 aicon = aicon->next;
1871 if (!aicon->docked) {
1872 if (aicon->x_pos != X || aicon->y_pos != Y) {
1874 if (!wPreferences.no_animations) {
1875 SlideWindow(aicon->icon->core->window, aicon->x_pos, aicon->y_pos,
1878 #endif /* ANIMATIONS */
1880 wAppIconMove(aicon, X, Y);
1883 /* we reversed the order so we use prev */
1884 aicon = aicon->prev;
1891 /* arrange miniwindows */
1893 wwin = scr->focused_window;
1894 /* reverse them to avoid unnecessarily shuffling */
1895 while (wwin && wwin->prev)
1899 if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden &&
1900 (wwin->frame->workspace==scr->current_workspace ||
1901 IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) {
1903 if (arrangeAll || !wwin->flags.icon_moved) {
1904 if (wwin->icon_x != X || wwin->icon_y != Y) {
1906 if (wPreferences.no_animations) {
1907 XMoveWindow(dpy, wwin->icon->core->window, X, Y);
1909 SlideWindow(wwin->icon->core->window, wwin->icon_x,
1910 wwin->icon_y, X, Y);
1913 XMoveWindow(dpy, wwin->icon->core->window, X, Y);
1914 #endif /* ANIMATIONS */
1922 wwin->flags.icon_moved = 0;
1924 /* we reversed the order, so we use next */
1935 wSelectWindow(WWindow *wwin, Bool flag)
1937 WScreen *scr = wwin->screen_ptr;
1940 wwin->flags.selected = 1;
1941 XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel);
1943 if (!HAS_BORDER(wwin)) {
1944 XSetWindowBorderWidth(dpy, wwin->frame->core->window,
1945 FRAME_BORDER_WIDTH);
1948 if (!scr->selected_windows)
1949 scr->selected_windows = WMCreateArray(4);
1950 WMAddToArray(scr->selected_windows, wwin);
1952 wwin->flags.selected = 0;
1953 XSetWindowBorder(dpy, wwin->frame->core->window,
1954 scr->frame_border_pixel);
1956 if (!HAS_BORDER(wwin)) {
1957 XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0);
1960 if (scr->selected_windows) {
1961 WMRemoveFromArray(scr->selected_windows, wwin);
1968 wMakeWindowVisible(WWindow *wwin)
1970 if (wwin->frame->workspace != wwin->screen_ptr->current_workspace)
1971 wWorkspaceChange(wwin->screen_ptr, wwin->frame->workspace);
1973 if (wwin->flags.shaded) {
1974 wUnshadeWindow(wwin);
1976 if (wwin->flags.hidden) {
1979 app = wApplicationOf(wwin->main_window);
1981 /* trick to get focus to this window */
1982 app->last_focused = wwin;
1983 wUnhideApplication(app, False, False);
1986 if (wwin->flags.miniaturized) {
1987 wDeiconifyWindow(wwin);
1989 if (!WFLAGP(wwin, no_focusable))
1990 wSetFocusTo(wwin->screen_ptr, wwin);
1991 wRaiseFrame(wwin->frame->core);