diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index 74cb39a9..78fe3618 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -625,6 +625,8 @@ WMPoint wmkpoint(int x, int y); WMSize wmksize(unsigned int width, unsigned int height); +WMRect wmkrect(int x, int y, unsigned int width, unsigned int height); + #ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY #define wmksize(width, height) (WMSize){(width), (height)} #define wmkpoint(x, y) (WMPoint){(x), (y)} diff --git a/WINGs/proplist.c b/WINGs/proplist.c index c26ebe91..fa167dc4 100644 --- a/WINGs/proplist.c +++ b/WINGs/proplist.c @@ -1615,7 +1615,9 @@ WMReadPropListFromFile(char *file) pldata->lineNumber = 1; if (fread(pldata->ptr, length, 1, f) != 1) { - wsyserror(_("error reading from file '%s'"), file); + if (ferror(f)) { + wsyserror(_("error reading from file '%s'"), file); + } plist = NULL; goto cleanup; } diff --git a/WINGs/wmisc.c b/WINGs/wmisc.c index 4db36a1a..f8bfdb47 100644 --- a/WINGs/wmisc.c +++ b/WINGs/wmisc.c @@ -338,7 +338,18 @@ wmksize(unsigned int width, unsigned int height) } - +WMRect +wmkrect(int x, int y, unsigned int width, unsigned int height) +{ + WMRect rect; + + rect.pos.x = x; + rect.pos.y = y; + rect.size.width = width; + rect.size.height = height; + + return rect; +} diff --git a/src/actions.c b/src/actions.c index 5bd83623..2dc0de97 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1,10 +1,10 @@ /* action.c- misc. window commands (miniaturize, hide etc.) - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 Dan Pascu - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ @@ -95,7 +95,7 @@ processEvents(int event_count) XEvent event; /* - * This is a hack. When animations are enabled, processing of + * This is a hack. When animations are enabled, processing of * events ocurred during a animation are delayed until it's end. * Calls that consider the TimeStamp, like XSetInputFocus(), will * fail because the TimeStamp is too old. Then, for example, if @@ -107,8 +107,8 @@ processEvents(int event_count) */ ignoreTimestamp=1; while (XPending(dpy) && event_count--) { - WMNextEvent(dpy, &event); - WMHandleEvent(&event); + WMNextEvent(dpy, &event); + WMHandleEvent(&event); } ignoreTimestamp=0; } @@ -117,17 +117,17 @@ processEvents(int event_count) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wSetFocusTo-- * Changes the window focus to the one passed as argument. * If the window to focus is not already focused, it will be brought * to the head of the list of windows. Previously focused window is - * unfocused. - * + * unfocused. + * * Side effects: * Window list may be reordered and the window focus is changed. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ void wSetFocusTo(WScreen *scr, WWindow *wwin) @@ -141,36 +141,36 @@ wSetFocusTo(WScreen *scr, WWindow *wwin) int wasfocused; if (!old_scr) - old_scr=scr; + old_scr=scr; old_focused=old_scr->focused_window; LastFocusChange = timestamp; -/* - * This is a hack, because XSetInputFocus() should have a proper - * timestamp instead of CurrentTime but it seems that some times - * clients will not receive focus properly that way. - if (ignoreTimestamp) -*/ - timestamp = CurrentTime; + /* + * This is a hack, because XSetInputFocus() should have a proper + * timestamp instead of CurrentTime but it seems that some times + * clients will not receive focus properly that way. + if (ignoreTimestamp) + */ + timestamp = CurrentTime; if (old_focused) - oapp = wApplicationOf(old_focused->main_window); + oapp = wApplicationOf(old_focused->main_window); if (wwin == NULL) { - XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); - if (old_focused) { - wWindowUnfocus(old_focused); - } - if (oapp) { - wAppMenuUnmap(oapp->menu); + XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); + if (old_focused) { + wWindowUnfocus(old_focused); + } + if (oapp) { + wAppMenuUnmap(oapp->menu); #ifdef NEWAPPICON - wApplicationDeactivate(oapp); + wApplicationDeactivate(oapp); #endif - } - - WMPostNotificationName(WMNChangedFocus, NULL, (void*)True); - return; + } + + WMPostNotificationName(WMNChangedFocus, NULL, (void*)True); + return; } else if (old_scr != scr && old_focused) { wWindowUnfocus(old_focused); } @@ -185,71 +185,71 @@ wSetFocusTo(WScreen *scr, WWindow *wwin) } if (wwin->flags.mapped && !WFLAGP(wwin, no_focusable)) { - /* install colormap if colormap mode is lock mode */ - if (wPreferences.colormap_mode==WCM_CLICK) - wColormapInstallForWindow(scr, wwin); + /* install colormap if colormap mode is lock mode */ + if (wPreferences.colormap_mode==WCM_CLICK) + wColormapInstallForWindow(scr, wwin); - /* set input focus */ - switch (wwin->focus_mode) { - case WFM_NO_INPUT: - XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); - break; + /* set input focus */ + switch (wwin->focus_mode) { + case WFM_NO_INPUT: + XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); + break; - case WFM_PASSIVE: - case WFM_LOCALLY_ACTIVE: - XSetInputFocus(dpy, wwin->client_win, RevertToParent, timestamp); - break; + case WFM_PASSIVE: + case WFM_LOCALLY_ACTIVE: + XSetInputFocus(dpy, wwin->client_win, RevertToParent, timestamp); + break; - case WFM_GLOBALLY_ACTIVE: - break; - } - XFlush(dpy); - if (wwin->protocols.TAKE_FOCUS) { - wClientSendProtocol(wwin, _XA_WM_TAKE_FOCUS, timestamp); - } - XSync(dpy, False); + case WFM_GLOBALLY_ACTIVE: + break; + } + XFlush(dpy); + if (wwin->protocols.TAKE_FOCUS) { + wClientSendProtocol(wwin, _XA_WM_TAKE_FOCUS, timestamp); + } + XSync(dpy, False); } else { - XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); + XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, timestamp); } if (WFLAGP(wwin, no_focusable)) - return; + return; /* if this is not the focused window focus it */ if (focused!=wwin) { - /* change the focus window list order */ - if (wwin->prev) - wwin->prev->next = wwin->next; + /* change the focus window list order */ + if (wwin->prev) + wwin->prev->next = wwin->next; - if (wwin->next) - wwin->next->prev = wwin->prev; + if (wwin->next) + wwin->next->prev = wwin->prev; - wwin->prev = focused; - focused->next = wwin; - wwin->next = NULL; - scr->focused_window = wwin; + wwin->prev = focused; + focused->next = wwin; + wwin->next = NULL; + scr->focused_window = wwin; - if (oapp && oapp != napp) { - wAppMenuUnmap(oapp->menu); + if (oapp && oapp != napp) { + wAppMenuUnmap(oapp->menu); #ifdef NEWAPPICON - wApplicationDeactivate(oapp); + wApplicationDeactivate(oapp); #endif - } + } } wWindowFocus(wwin, focused); if (napp && !wasfocused) { #ifdef USER_MENU - wUserMenuRefreshInstances(napp->menu, wwin); + wUserMenuRefreshInstances(napp->menu, wwin); #endif /* USER_MENU */ - if (wwin->flags.mapped) - wAppMenuMap(napp->menu, wwin); + if (wwin->flags.mapped) + wAppMenuMap(napp->menu, wwin); #ifdef NEWAPPICON - wApplicationActivate(napp); + wApplicationActivate(napp); #endif } - + XFlush(dpy); old_scr=scr; } @@ -264,40 +264,40 @@ wShadeWindow(WWindow *wwin) #endif if (wwin->flags.shaded) - return; + return; time0 = time(NULL); - XLowerWindow(dpy, wwin->client_win); + XLowerWindow(dpy, wwin->client_win); wSoundPlay(WSOUND_SHADE); #ifdef ANIMATIONS if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation - && !wPreferences.no_animations) { - /* do the shading animation */ - h = wwin->frame->core->height; + && !wPreferences.no_animations) { + /* do the shading animation */ + h = wwin->frame->core->height; s = h/SHADE_STEPS; if (s < 1) s=1; - w = wwin->frame->core->width; - y = wwin->frame->top_width; - while (h>wwin->frame->top_width+1) { - XMoveWindow(dpy, wwin->client_win, 0, y); - XResizeWindow(dpy, wwin->frame->core->window, w, h); - XFlush(dpy); + w = wwin->frame->core->width; + y = wwin->frame->top_width; + while (h>wwin->frame->top_width+1) { + XMoveWindow(dpy, wwin->client_win, 0, y); + XResizeWindow(dpy, wwin->frame->core->window, w, h); + XFlush(dpy); - if (time(NULL)-time0 > MAX_ANIMATION_TIME) - break; + if (time(NULL)-time0 > MAX_ANIMATION_TIME) + break; if (SHADE_DELAY > 0) { wusleep(SHADE_DELAY*1000L); } else { wusleep(10); } - h-=s; - y-=s; - } - XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); + h-=s; + y-=s; + } + XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); } #endif /* ANIMATIONS */ @@ -305,30 +305,30 @@ wShadeWindow(WWindow *wwin) wwin->flags.shaded = 1; wwin->flags.mapped = 0; /* prevent window withdrawal when getting UnmapNotify */ - XSelectInput(dpy, wwin->client_win, + XSelectInput(dpy, wwin->client_win, wwin->event_mask & ~StructureNotifyMask); XUnmapWindow(dpy, wwin->client_win); XSelectInput(dpy, wwin->client_win, wwin->event_mask); /* for the client it's just like iconification */ wFrameWindowResize(wwin->frame, wwin->frame->core->width, - wwin->frame->top_width - 1); - - wwin->client.y = wwin->frame_y - wwin->client.height - + wwin->frame->top_width; + wwin->frame->top_width - 1); + + wwin->client.y = wwin->frame_y - wwin->client.height + + wwin->frame->top_width; wWindowSynthConfigureNotify(wwin); /* - wClientSetState(wwin, IconicState, None); + wClientSetState(wwin, IconicState, None); */ WMPostNotificationName(WMNChangedState, wwin, "shade"); #ifdef ANIMATIONS if (!wwin->screen_ptr->flags.startup) { - /* Look at processEvents() for reason of this code. */ - XSync(dpy, 0); - processEvents(XPending(dpy)); + /* Look at processEvents() for reason of this code. */ + XSync(dpy, 0); + processEvents(XPending(dpy)); } #endif } @@ -339,12 +339,12 @@ wUnshadeWindow(WWindow *wwin) { time_t time0; #ifdef ANIMATIONS - int y, s, w, h; + int y, s, w, h; #endif /* ANIMATIONS */ if (!wwin->flags.shaded) - return; + return; time0 = time(NULL); @@ -356,50 +356,50 @@ wUnshadeWindow(WWindow *wwin) #ifdef ANIMATIONS if (!wPreferences.no_animations && !wwin->flags.skip_next_animation) { - /* do the shading animation */ - h = wwin->frame->top_width + wwin->frame->bottom_width; - y = wwin->frame->top_width - wwin->client.height; + /* do the shading animation */ + h = wwin->frame->top_width + wwin->frame->bottom_width; + y = wwin->frame->top_width - wwin->client.height; s = abs(y)/SHADE_STEPS; if (s<1) s=1; - w = wwin->frame->core->width; - XMoveWindow(dpy, wwin->client_win, 0, y); - if (s>0) { - while (h < wwin->client.height + wwin->frame->top_width - + wwin->frame->bottom_width) { - XResizeWindow(dpy, wwin->frame->core->window, w, h); - XMoveWindow(dpy, wwin->client_win, 0, y); - XFlush(dpy); + w = wwin->frame->core->width; + XMoveWindow(dpy, wwin->client_win, 0, y); + if (s>0) { + while (h < wwin->client.height + wwin->frame->top_width + + wwin->frame->bottom_width) { + XResizeWindow(dpy, wwin->frame->core->window, w, h); + XMoveWindow(dpy, wwin->client_win, 0, y); + XFlush(dpy); if (SHADE_DELAY > 0) { wusleep(SHADE_DELAY*2000L/3); } else { wusleep(10); } - h+=s; - y+=s; - - if (time(NULL)-time0 > MAX_ANIMATION_TIME) - break; - } - } - XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); + h+=s; + y+=s; + + if (time(NULL)-time0 > MAX_ANIMATION_TIME) + break; + } + } + XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); } #endif /* ANIMATIONS */ wwin->flags.skip_next_animation = 0; - wFrameWindowResize(wwin->frame, wwin->frame->core->width, - wwin->frame->top_width + wwin->client.height - + wwin->frame->bottom_width); + wFrameWindowResize(wwin->frame, wwin->frame->core->width, + wwin->frame->top_width + wwin->client.height + + wwin->frame->bottom_width); wwin->client.y = wwin->frame_y + wwin->frame->top_width; wWindowSynthConfigureNotify(wwin); - + /* - wClientSetState(wwin, NormalState, None); + wClientSetState(wwin, NormalState, None); */ /* if the window is focused, set the focus again as it was disabled during * shading */ if (wwin->flags.focused) - wSetFocusTo(wwin->screen_ptr, wwin); + wSetFocusTo(wwin->screen_ptr, wwin); WMPostNotificationName(WMNChangedState, wwin, "shade"); } @@ -413,33 +413,33 @@ wMaximizeWindow(WWindow *wwin, int directions) WArea usableArea, totalArea; if (WFLAGP(wwin, no_resizable)) - return; - - usableArea = totalArea = (WArea){ - 0, 0, - wwin->screen_ptr->scr_width, - wwin->screen_ptr->scr_height - }; + return; + + totalArea.x1 = 0; + totalArea.y1 = 0; + totalArea.x2 = wwin->screen_ptr->scr_width; + totalArea.y2 = wwin->screen_ptr->scr_height; + usableArea = totalArea; if (!(directions & MAX_IGNORE_XINERAMA)) { - WScreen *scr = wwin->screen_ptr; - int head; + WScreen *scr = wwin->screen_ptr; + int head; - if (directions & MAX_KEYBOARD) - head = wGetHeadForWindow(wwin); - else - head = wGetHeadForPointerLocation(scr); + if (directions & MAX_KEYBOARD) + head = wGetHeadForWindow(wwin); + else + head = wGetHeadForPointerLocation(scr); - usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True); + usableArea = wGetUsableAreaForHead(scr, head, &totalArea, True); } if (WFLAGP(wwin, full_maximize)) { - usableArea = totalArea; + usableArea = totalArea; } if (wwin->flags.shaded) { - wwin->flags.skip_next_animation = 1; - wUnshadeWindow(wwin); + wwin->flags.skip_next_animation = 1; + wUnshadeWindow(wwin); } /* Only save directions, not kbd or xinerama hints */ directions &= (MAX_HORIZONTAL|MAX_VERTICAL); @@ -474,41 +474,41 @@ wMaximizeWindow(WWindow *wwin, int directions) #endif if (directions & MAX_HORIZONTAL) { - new_width = (usableArea.x2-usableArea.x1)-FRAME_BORDER_WIDTH*2; - new_x = usableArea.x1; + new_width = (usableArea.x2-usableArea.x1)-FRAME_BORDER_WIDTH*2; + new_x = usableArea.x1; } else if (shrink_h) { - new_x = wwin->old_geometry.x; - new_width = wwin->old_geometry.width; + new_x = wwin->old_geometry.x; + new_width = wwin->old_geometry.width; } else { - new_x = wwin->frame_x; - new_width = wwin->frame->core->width; + new_x = wwin->frame_x; + new_width = wwin->frame->core->width; } if (directions & MAX_VERTICAL) { - new_height = (usableArea.y2-usableArea.y1)-FRAME_BORDER_WIDTH*2; - new_y = usableArea.y1; - if (WFLAGP(wwin, full_maximize)) { - new_y -= wwin->frame->top_width; - new_height += wwin->frame->bottom_width - 1; - } + new_height = (usableArea.y2-usableArea.y1)-FRAME_BORDER_WIDTH*2; + new_y = usableArea.y1; + if (WFLAGP(wwin, full_maximize)) { + new_y -= wwin->frame->top_width; + new_height += wwin->frame->bottom_width - 1; + } } else if (shrink_v) { - new_y = wwin->old_geometry.y; - new_height = wwin->old_geometry.height; + new_y = wwin->old_geometry.y; + new_height = wwin->old_geometry.height; } else { - new_y = wwin->frame_y; - new_height = wwin->frame->core->height; + new_y = wwin->frame_y; + new_height = wwin->frame->core->height; } if (!WFLAGP(wwin, full_maximize)) { - new_height -= wwin->frame->top_width+wwin->frame->bottom_width; + new_height -= wwin->frame->top_width+wwin->frame->bottom_width; } wWindowConstrainSize(wwin, &new_width, &new_height); - - wWindowCropSize(wwin, usableArea.x2-usableArea.x1, - usableArea.y2-usableArea.y1, - &new_width, &new_height); - + + wWindowCropSize(wwin, usableArea.x2-usableArea.x1, + usableArea.y2-usableArea.y1, + &new_width, &new_height); + wWindowConfigure(wwin, new_x, new_y, new_width, new_height); @@ -524,11 +524,11 @@ wUnmaximizeWindow(WWindow *wwin) int restore_x, restore_y; if (!wwin->flags.maximized) - return; - + return; + if (wwin->flags.shaded) { - wwin->flags.skip_next_animation = 1; - wUnshadeWindow(wwin); + wwin->flags.skip_next_animation = 1; + wUnshadeWindow(wwin); } restore_x = (wwin->flags.maximized & MAX_HORIZONTAL) ? wwin->old_geometry.x : wwin->frame_x; @@ -536,7 +536,7 @@ wUnmaximizeWindow(WWindow *wwin) wwin->old_geometry.y : wwin->frame_y; wwin->flags.maximized = 0; wWindowConfigure(wwin, restore_x, restore_y, - wwin->old_geometry.width, wwin->old_geometry.height); + wwin->old_geometry.width, wwin->old_geometry.height); WMPostNotificationName(WMNChangedState, wwin, "maximize"); @@ -551,7 +551,7 @@ animateResizeFlip(WScreen *scr, int x, int y, int w, int h, #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_F) float cx, cy, cw, ch; float xstep, ystep, wstep, hstep; - XPoint points[5]; + XPoint points[5]; float dx, dch, midy; float angle, final_angle, delta; @@ -559,7 +559,7 @@ animateResizeFlip(WScreen *scr, int x, int y, int w, int h, ystep = (float)(fy-y)/steps; wstep = (float)(fw-w)/steps; hstep = (float)(fh-h)/steps; - + cx = (float)x; cy = (float)y; cw = (float)w; @@ -583,21 +583,21 @@ animateResizeFlip(WScreen *scr, int x, int y, int w, int h, XGrabServer(dpy); XDrawLines(dpy,scr->root_win,scr->frame_gc,points, 5, CoordModeOrigin); - XFlush(dpy); + XFlush(dpy); #if (MINIATURIZE_ANIMATION_DELAY_F > 0) wusleep(MINIATURIZE_ANIMATION_DELAY_F); #else wusleep(10); #endif - XDrawLines(dpy,scr->root_win,scr->frame_gc,points, 5, CoordModeOrigin); - XUngrabServer(dpy); - cx+=xstep; - cy+=ystep; - cw+=wstep; - ch+=hstep; - if (angle >= final_angle) - break; + XDrawLines(dpy,scr->root_win,scr->frame_gc,points, 5, CoordModeOrigin); + XUngrabServer(dpy); + cx+=xstep; + cy+=ystep; + cw+=wstep; + ch+=hstep; + if (angle >= final_angle) + break; } XFlush(dpy); @@ -605,14 +605,14 @@ animateResizeFlip(WScreen *scr, int x, int y, int w, int h, #undef FRAMES -static void +static void animateResizeTwist(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps) { #define FRAMES (MINIATURIZE_ANIMATION_FRAMES_T) float cx, cy, cw, ch; float xstep, ystep, wstep, hstep; - XPoint points[5]; + XPoint points[5]; float angle, final_angle, a, d, delta; x += w/2; @@ -624,7 +624,7 @@ animateResizeTwist(WScreen *scr, int x, int y, int w, int h, ystep = (float)(fy-y)/steps; wstep = (float)(fw-w)/steps; hstep = (float)(fh-h)/steps; - + cx = (float)x; cy = (float)y; cw = (float)w; @@ -651,7 +651,7 @@ animateResizeTwist(WScreen *scr, int x, int y, int w, int h, points[4].y = cy+sin(angle-a)*d; XGrabServer(dpy); XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin); - XFlush(dpy); + XFlush(dpy); #if (MINIATURIZE_ANIMATION_DELAY_T > 0) wusleep(MINIATURIZE_ANIMATION_DELAY_T); #else @@ -659,21 +659,21 @@ animateResizeTwist(WScreen *scr, int x, int y, int w, int h, #endif XDrawLines(dpy, scr->root_win, scr->frame_gc, points, 5, CoordModeOrigin); - XUngrabServer(dpy); - cx+=xstep; - cy+=ystep; - cw+=wstep; - ch+=hstep; - if (angle >= final_angle) - break; - + XUngrabServer(dpy); + cx+=xstep; + cy+=ystep; + cw+=wstep; + ch+=hstep; + if (angle >= final_angle) + break; + } XFlush(dpy); } #undef FRAMES -static void +static void animateResizeZoom(WScreen *scr, int x, int y, int w, int h, int fx, int fy, int fw, int fh, int steps) { @@ -686,45 +686,45 @@ animateResizeZoom(WScreen *scr, int x, int y, int w, int h, ystep = (float)(fy-y)/steps; wstep = (float)(fw-w)/steps; hstep = (float)(fh-h)/steps; - + for (j=0; jroot_win, scr->frame_gc, - (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); - } - XFlush(dpy); + for (j=0; jroot_win, scr->frame_gc, + (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); + } + XFlush(dpy); #if (MINIATURIZE_ANIMATION_DELAY_Z > 0) wusleep(MINIATURIZE_ANIMATION_DELAY_Z); #else wusleep(10); #endif - for (j=0; jroot_win, scr->frame_gc, - (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); - if (jroot_win, scr->frame_gc, + (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); + if (jroot_win, scr->frame_gc, - (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); + XDrawRectangle(dpy, scr->root_win, scr->frame_gc, + (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); } XFlush(dpy); #if (MINIATURIZE_ANIMATION_DELAY_Z > 0) @@ -733,18 +733,18 @@ animateResizeZoom(WScreen *scr, int x, int y, int w, int h, wusleep(10); #endif for (j=0; jroot_win, scr->frame_gc, - (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); + XDrawRectangle(dpy, scr->root_win, scr->frame_gc, + (int)cx[j], (int)cy[j], (int)cw[j], (int)ch[j]); } - + XUngrabServer(dpy); } #undef FRAMES void -animateResize(WScreen *scr, int x, int y, int w, int h, - int fx, int fy, int fw, int fh, int hiding) +animateResize(WScreen *scr, int x, int y, int w, int h, + int fx, int fy, int fw, int fh, int hiding) { int style = wPreferences.iconification_style; /* Catch the value */ int steps, k; @@ -753,7 +753,7 @@ animateResize(WScreen *scr, int x, int y, int w, int h, return; if (style == WIS_RANDOM) { - style = rand()%3; + style = rand()%3; } k = (hiding ? 2 : 3); @@ -783,9 +783,9 @@ static void flushExpose() { XEvent tmpev; - + while (XCheckTypedEvent(dpy, Expose, &tmpev)) - WMHandleEvent(&tmpev); + WMHandleEvent(&tmpev); XSync(dpy, 0); } @@ -793,29 +793,29 @@ static void unmapTransientsFor(WWindow *wwin) { WWindow *tmp; - + tmp = wwin->screen_ptr->focused_window; while (tmp) { - /* unmap the transients for this transient */ - if (tmp!=wwin && tmp->transient_for == wwin->client_win - && (tmp->flags.mapped || wwin->screen_ptr->flags.startup - || tmp->flags.shaded)) { - unmapTransientsFor(tmp); - tmp->flags.miniaturized = 1; - if (!tmp->flags.shaded) { - wWindowUnmap(tmp); - } else { - XUnmapWindow(dpy, tmp->frame->core->window); - } - /* - if (!tmp->flags.shaded) - */ - wClientSetState(tmp, IconicState, None); - - WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); - } - tmp = tmp->prev; + /* unmap the transients for this transient */ + if (tmp!=wwin && tmp->transient_for == wwin->client_win + && (tmp->flags.mapped || wwin->screen_ptr->flags.startup + || tmp->flags.shaded)) { + unmapTransientsFor(tmp); + tmp->flags.miniaturized = 1; + if (!tmp->flags.shaded) { + wWindowUnmap(tmp); + } else { + XUnmapWindow(dpy, tmp->frame->core->window); + } + /* + if (!tmp->flags.shaded) + */ + wClientSetState(tmp, IconicState, None); + + WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); + } + tmp = tmp->prev; } } @@ -827,26 +827,26 @@ mapTransientsFor(WWindow *wwin) tmp = wwin->screen_ptr->focused_window; while (tmp) { - /* recursively map the transients for this transient */ - if (tmp!=wwin && tmp->transient_for == wwin->client_win - && /*!tmp->flags.mapped*/ tmp->flags.miniaturized - && tmp->icon==NULL) { - mapTransientsFor(tmp); - tmp->flags.miniaturized = 0; - if (!tmp->flags.shaded) { - wWindowMap(tmp); - } else { - XMapWindow(dpy, tmp->frame->core->window); - } - tmp->flags.semi_focused = 0; - /* - if (!tmp->flags.shaded) - */ - wClientSetState(tmp, NormalState, None); - - WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); - } - tmp = tmp->prev; + /* recursively map the transients for this transient */ + if (tmp!=wwin && tmp->transient_for == wwin->client_win + && /*!tmp->flags.mapped*/ tmp->flags.miniaturized + && tmp->icon==NULL) { + mapTransientsFor(tmp); + tmp->flags.miniaturized = 0; + if (!tmp->flags.shaded) { + wWindowMap(tmp); + } else { + XMapWindow(dpy, tmp->frame->core->window); + } + tmp->flags.semi_focused = 0; + /* + if (!tmp->flags.shaded) + */ + wClientSetState(tmp, NormalState, None); + + WMPostNotificationName(WMNChangedState, tmp, "iconify-transient"); + } + tmp = tmp->prev; } } @@ -856,11 +856,11 @@ setupIconGrabs(WIcon *icon) { /* setup passive grabs on the icon */ XGrabButton(dpy, Button1, AnyModifier, icon->core->window, True, - ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); + ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); XGrabButton(dpy, Button2, AnyModifier, icon->core->window, True, - ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); + ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); XGrabButton(dpy, Button3, AnyModifier, icon->core->window, True, - ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); + ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); XSync(dpy, 0); } #endif @@ -871,19 +871,19 @@ recursiveTransientFor(WWindow *wwin) int i; if (!wwin) - return None; + return None; - /* hackish way to detect transient_for cycle */ + /* hackish way to detect transient_for cycle */ i = wwin->screen_ptr->window_count+1; while (wwin && wwin->transient_for != None && i>0) { - wwin = wWindowFor(wwin->transient_for); - i--; + wwin = wWindowFor(wwin->transient_for); + i--; } if (i==0 && wwin) { - wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.", - wwin->frame->title); - return NULL; + wwarning("%s has a severely broken WM_TRANSIENT_FOR hint.", + wwin->frame->title); + return NULL; } return wwin; @@ -896,7 +896,7 @@ removeIconGrabs(WIcon *icon) /* remove passive grabs on the icon */ XUngrabButton(dpy, Button1, AnyModifier, icon->core->window); XUngrabButton(dpy, Button2, AnyModifier, icon->core->window); - XUngrabButton(dpy, Button3, AnyModifier, icon->core->window); + XUngrabButton(dpy, Button3, AnyModifier, icon->core->window); XSync(dpy, 0); } #endif @@ -910,149 +910,149 @@ wIconifyWindow(WWindow *wwin) if (!XGetWindowAttributes(dpy, wwin->client_win, &attribs)) { - /* the window doesn't exist anymore */ - return; + /* the window doesn't exist anymore */ + return; } if (wwin->flags.miniaturized) { - return; + return; } if (wwin->transient_for!=None && wwin->transient_for!=wwin->screen_ptr->root_win) { - WWindow *owner = wWindowFor(wwin->transient_for); - - if (owner && owner->flags.miniaturized) - return; + WWindow *owner = wWindowFor(wwin->transient_for); + + if (owner && owner->flags.miniaturized) + return; } - + present = wwin->frame->workspace==wwin->screen_ptr->current_workspace; - + /* if the window is in another workspace, simplify process */ if (present) { - /* icon creation may take a while */ - XGrabPointer(dpy, wwin->screen_ptr->root_win, False, - ButtonMotionMask|ButtonReleaseMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime); + /* icon creation may take a while */ + XGrabPointer(dpy, wwin->screen_ptr->root_win, False, + ButtonMotionMask|ButtonReleaseMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime); } if (!wPreferences.disable_miniwindows) { - if (!wwin->flags.icon_moved) { - PlaceIcon(wwin->screen_ptr, &wwin->icon_x, &wwin->icon_y, wGetHeadForWindow(wwin)); - } - wwin->icon = wIconCreate(wwin); + if (!wwin->flags.icon_moved) { + PlaceIcon(wwin->screen_ptr, &wwin->icon_x, &wwin->icon_y, wGetHeadForWindow(wwin)); + } + wwin->icon = wIconCreate(wwin); - wwin->icon->mapped = 1; + wwin->icon->mapped = 1; } wwin->flags.miniaturized = 1; wwin->flags.mapped = 0; /* unmap transients */ - + unmapTransientsFor(wwin); if (present) { - wSoundPlay(WSOUND_ICONIFY); + wSoundPlay(WSOUND_ICONIFY); - XUngrabPointer(dpy, CurrentTime); - wWindowUnmap(wwin); - /* let all Expose events arrive so that we can repaint - * something before the animation starts (and the server is grabbed) */ - XSync(dpy, 0); + XUngrabPointer(dpy, CurrentTime); + wWindowUnmap(wwin); + /* let all Expose events arrive so that we can repaint + * something before the animation starts (and the server is grabbed) */ + XSync(dpy, 0); - if (wPreferences.disable_miniwindows) - wClientSetState(wwin, IconicState, None); - else - wClientSetState(wwin, IconicState, wwin->icon->icon_win); + if (wPreferences.disable_miniwindows) + wClientSetState(wwin, IconicState, None); + else + wClientSetState(wwin, IconicState, wwin->icon->icon_win); - flushExpose(); + flushExpose(); #ifdef ANIMATIONS - if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation - && !wPreferences.no_animations) { - int ix, iy, iw, ih; + if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation + && !wPreferences.no_animations) { + int ix, iy, iw, ih; - if (!wPreferences.disable_miniwindows) { - ix = wwin->icon_x; - iy = wwin->icon_y; - iw = wwin->icon->core->width; - ih = wwin->icon->core->height; - } else { + if (!wPreferences.disable_miniwindows) { + ix = wwin->icon_x; + iy = wwin->icon_y; + iw = wwin->icon->core->width; + ih = wwin->icon->core->height; + } else { #ifdef KWM_HINTS - WArea area; + WArea area; - if (wKWMGetIconGeometry(wwin, &area)) { - ix = area.x1; - iy = area.y1; - iw = area.x2 - ix; - ih = area.y2 - iy; - } else + if (wKWMGetIconGeometry(wwin, &area)) { + ix = area.x1; + iy = area.y1; + iw = area.x2 - ix; + ih = area.y2 - iy; + } else #endif /* KWM_HINTS */ - { - ix = 0; - iy = 0; - iw = wwin->screen_ptr->scr_width; - ih = wwin->screen_ptr->scr_height; - } - } - animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y, - wwin->frame->core->width, wwin->frame->core->height, - ix, iy, iw, ih, False); - } + { + ix = 0; + iy = 0; + iw = wwin->screen_ptr->scr_width; + ih = wwin->screen_ptr->scr_height; + } + } + animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y, + wwin->frame->core->width, wwin->frame->core->height, + ix, iy, iw, ih, False); + } #endif } - + wwin->flags.skip_next_animation = 0; if (!wPreferences.disable_miniwindows) { - if (wwin->screen_ptr->current_workspace==wwin->frame->workspace || - IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons) + if (wwin->screen_ptr->current_workspace==wwin->frame->workspace || + IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons) - XMapWindow(dpy, wwin->icon->core->window); + XMapWindow(dpy, wwin->icon->core->window); - AddToStackList(wwin->icon->core); + AddToStackList(wwin->icon->core); - wLowerFrame(wwin->icon->core); + wLowerFrame(wwin->icon->core); } if (present) { - WWindow *owner = recursiveTransientFor(wwin->screen_ptr->focused_window); + WWindow *owner = recursiveTransientFor(wwin->screen_ptr->focused_window); -/* - * It doesn't seem to be working and causes button event hangup - * when deiconifying a transient window. - setupIconGrabs(wwin->icon); - */ - if ((wwin->flags.focused - || (owner && wwin->client_win == owner->client_win)) - && wPreferences.focus_mode==WKF_CLICK) { - WWindow *tmp; - - tmp = wwin->prev; - while (tmp) { - if (!WFLAGP(tmp, no_focusable) - && !(tmp->flags.hidden||tmp->flags.miniaturized) - && (wwin->frame->workspace == tmp->frame->workspace)) - break; - tmp = tmp->prev; - } - wSetFocusTo(wwin->screen_ptr, tmp); - } else if (wPreferences.focus_mode!=WKF_CLICK) { - wSetFocusTo(wwin->screen_ptr, NULL); - } + /* + * It doesn't seem to be working and causes button event hangup + * when deiconifying a transient window. + setupIconGrabs(wwin->icon); + */ + if ((wwin->flags.focused + || (owner && wwin->client_win == owner->client_win)) + && wPreferences.focus_mode==WKF_CLICK) { + WWindow *tmp; + + tmp = wwin->prev; + while (tmp) { + if (!WFLAGP(tmp, no_focusable) + && !(tmp->flags.hidden||tmp->flags.miniaturized) + && (wwin->frame->workspace == tmp->frame->workspace)) + break; + tmp = tmp->prev; + } + wSetFocusTo(wwin->screen_ptr, tmp); + } else if (wPreferences.focus_mode!=WKF_CLICK) { + wSetFocusTo(wwin->screen_ptr, NULL); + } #ifdef ANIMATIONS - if (!wwin->screen_ptr->flags.startup) { - Window clientwin = wwin->client_win; + if (!wwin->screen_ptr->flags.startup) { + Window clientwin = wwin->client_win; - XSync(dpy, 0); - processEvents(XPending(dpy)); - - /* the window can disappear while doing the processEvents() */ - if (!wWindowFor(clientwin)) - return; - } + XSync(dpy, 0); + processEvents(XPending(dpy)); + + /* the window can disappear while doing the processEvents() */ + if (!wWindowFor(clientwin)) + return; + } #endif } @@ -1072,29 +1072,29 @@ wDeiconifyWindow(WWindow *wwin) wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace); if (!wwin->flags.miniaturized) - return; + return; - if (wwin->transient_for != None - && wwin->transient_for != wwin->screen_ptr->root_win) { - WWindow *owner = recursiveTransientFor(wwin); + if (wwin->transient_for != None + && wwin->transient_for != wwin->screen_ptr->root_win) { + WWindow *owner = recursiveTransientFor(wwin); - if (owner && owner->flags.miniaturized) { - wDeiconifyWindow(owner); - wSetFocusTo(wwin->screen_ptr, wwin); - wRaiseFrame(wwin->frame->core); - return; - } + if (owner && owner->flags.miniaturized) { + wDeiconifyWindow(owner); + wSetFocusTo(wwin->screen_ptr, wwin); + wRaiseFrame(wwin->frame->core); + return; + } } wwin->flags.miniaturized = 0; if (!wwin->flags.shaded) - wwin->flags.mapped = 1; + wwin->flags.mapped = 1; if (!wPreferences.disable_miniwindows && wwin->icon != NULL) { - if (wwin->icon->selected) - wIconSelect(wwin->icon); + if (wwin->icon->selected) + wIconSelect(wwin->icon); - XUnmapWindow(dpy, wwin->icon->core->window); + XUnmapWindow(dpy, wwin->icon->core->window); } wSoundPlay(WSOUND_DEICONIFY); @@ -1102,55 +1102,55 @@ wDeiconifyWindow(WWindow *wwin) /* if the window is in another workspace, do it silently */ #ifdef ANIMATIONS if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations - && !wwin->flags.skip_next_animation && wwin->icon != NULL) { - int ix, iy, iw, ih; + && !wwin->flags.skip_next_animation && wwin->icon != NULL) { + int ix, iy, iw, ih; - if (!wPreferences.disable_miniwindows) { - ix = wwin->icon_x; - iy = wwin->icon_y; - iw = wwin->icon->core->width; - ih = wwin->icon->core->height; - } else { + if (!wPreferences.disable_miniwindows) { + ix = wwin->icon_x; + iy = wwin->icon_y; + iw = wwin->icon->core->width; + ih = wwin->icon->core->height; + } else { #ifdef KWM_HINTS - WArea area; + WArea area; - if (wKWMGetIconGeometry(wwin, &area)) { - ix = area.x1; - iy = area.y1; - iw = area.x2 - ix; - ih = area.y2 - iy; - } else + if (wKWMGetIconGeometry(wwin, &area)) { + ix = area.x1; + iy = area.y1; + iw = area.x2 - ix; + ih = area.y2 - iy; + } else #endif /* KWM_HINTS */ - { - ix = 0; - iy = 0; - iw = wwin->screen_ptr->scr_width; - ih = wwin->screen_ptr->scr_height; - } - } - animateResize(wwin->screen_ptr, ix, iy, iw, ih, - wwin->frame_x, wwin->frame_y, - wwin->frame->core->width, wwin->frame->core->height, - False); + { + ix = 0; + iy = 0; + iw = wwin->screen_ptr->scr_width; + ih = wwin->screen_ptr->scr_height; + } + } + animateResize(wwin->screen_ptr, ix, iy, iw, ih, + wwin->frame_x, wwin->frame_y, + wwin->frame->core->width, wwin->frame->core->height, + False); } #endif /* ANIMATIONS */ wwin->flags.skip_next_animation = 0; XGrabServer(dpy); if (!wwin->flags.shaded) { - XMapWindow(dpy, wwin->client_win); + XMapWindow(dpy, wwin->client_win); } XMapWindow(dpy, wwin->frame->core->window); wRaiseFrame(wwin->frame->core); if (!wwin->flags.shaded) { - wClientSetState(wwin, NormalState, None); + wClientSetState(wwin, NormalState, None); } mapTransientsFor(wwin); if (!wPreferences.disable_miniwindows && wwin->icon != NULL) { - RemoveFromStackList(wwin->icon->core); - /* removeIconGrabs(wwin->icon);*/ - wIconDestroy(wwin->icon); - wwin->icon = NULL; + RemoveFromStackList(wwin->icon->core); + /* removeIconGrabs(wwin->icon);*/ + wIconDestroy(wwin->icon); + wwin->icon = NULL; } XUngrabServer(dpy); @@ -1158,16 +1158,16 @@ wDeiconifyWindow(WWindow *wwin) #ifdef ANIMATIONS if (!wwin->screen_ptr->flags.startup) { - Window clientwin = wwin->client_win; - - XSync(dpy, 0); - processEvents(XPending(dpy)); - - if (!wWindowFor(clientwin)) - return; + Window clientwin = wwin->client_win; + + XSync(dpy, 0); + processEvents(XPending(dpy)); + + if (!wWindowFor(clientwin)) + return; } #endif - + if (wPreferences.auto_arrange_icons) { wArrangeIcons(wwin->screen_ptr, True); } @@ -1184,18 +1184,18 @@ static void hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate) { if (wwin->flags.miniaturized) { - if (wwin->icon) { - XUnmapWindow(dpy, wwin->icon->core->window); - wwin->icon->mapped = 0; - } - wwin->flags.hidden = 1; - - WMPostNotificationName(WMNChangedState, wwin, "hide"); - return; + if (wwin->icon) { + XUnmapWindow(dpy, wwin->icon->core->window); + wwin->icon->mapped = 0; + } + wwin->flags.hidden = 1; + + WMPostNotificationName(WMNChangedState, wwin, "hide"); + return; } if (wwin->flags.inspector_open) { - wHideInspectorForWindow(wwin); + wHideInspectorForWindow(wwin); } wwin->flags.hidden = 1; @@ -1206,11 +1206,11 @@ hideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate) wSoundPlay(WSOUND_HIDE); #ifdef ANIMATIONS if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations && - !wwin->flags.skip_next_animation && animate) { - animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y, - wwin->frame->core->width, wwin->frame->core->height, - icon_x, icon_y, icon->core->width, icon->core->height, - True); + !wwin->flags.skip_next_animation && animate) { + animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y, + wwin->frame->core->width, wwin->frame->core->height, + icon_x, icon_y, icon->core->width, icon->core->height, + True); } #endif wwin->flags.skip_next_animation = 0; @@ -1227,41 +1227,41 @@ wHideOtherApplications(WWindow *awin) WApplication *tapp; if (!awin) - return; + return; wwin = awin->screen_ptr->focused_window; while (wwin) { - if (wwin!=awin - && wwin->frame->workspace == awin->screen_ptr->current_workspace + if (wwin!=awin + && wwin->frame->workspace == awin->screen_ptr->current_workspace && !(wwin->flags.miniaturized||wwin->flags.hidden) && !wwin->flags.internal_window - && wGetWindowOfInspectorForWindow(wwin) != awin - && !WFLAGP(wwin, no_hide_others)) { - - if (wwin->main_window==None || WFLAGP(wwin, no_appicon)) { - if (!WFLAGP(wwin, no_miniaturizable)) { - wwin->flags.skip_next_animation = 1; - wIconifyWindow(wwin); - } - } else if (wwin->main_window!=None - && awin->main_window != wwin->main_window) { - tapp = wApplicationOf(wwin->main_window); - if (tapp) { - tapp->flags.skip_next_animation = 1; - wHideApplication(tapp); - } else { - if (!WFLAGP(wwin, no_miniaturizable)) { - wwin->flags.skip_next_animation = 1; - wIconifyWindow(wwin); - } - } - } - } - wwin = wwin->prev; + && wGetWindowOfInspectorForWindow(wwin) != awin + && !WFLAGP(wwin, no_hide_others)) { + + if (wwin->main_window==None || WFLAGP(wwin, no_appicon)) { + if (!WFLAGP(wwin, no_miniaturizable)) { + wwin->flags.skip_next_animation = 1; + wIconifyWindow(wwin); + } + } else if (wwin->main_window!=None + && awin->main_window != wwin->main_window) { + tapp = wApplicationOf(wwin->main_window); + if (tapp) { + tapp->flags.skip_next_animation = 1; + wHideApplication(tapp); + } else { + if (!WFLAGP(wwin, no_miniaturizable)) { + wwin->flags.skip_next_animation = 1; + wIconifyWindow(wwin); + } + } + } + } + wwin = wwin->prev; } /* - wSetFocusTo(awin->screen_ptr, awin); + wSetFocusTo(awin->screen_ptr, awin); */ } @@ -1273,63 +1273,63 @@ wHideApplication(WApplication *wapp) WScreen *scr; WWindow *wlist; int hadfocus; - + if (!wapp) { - wwarning("trying to hide a non grouped window"); - return; + wwarning("trying to hide a non grouped window"); + return; } if (!wapp->main_window_desc) { - wwarning("group leader not found for window group"); - return; + wwarning("group leader not found for window group"); + return; } scr = wapp->main_window_desc->screen_ptr; hadfocus = 0; wlist = scr->focused_window; if (!wlist) - return; + return; if (wlist->main_window == wapp->main_window) - wapp->last_focused = wlist; + wapp->last_focused = wlist; else - wapp->last_focused = NULL; + wapp->last_focused = NULL; while (wlist) { - if (wlist->main_window == wapp->main_window) { - if (wlist->flags.focused) { - hadfocus = 1; + if (wlist->main_window == wapp->main_window) { + if (wlist->flags.focused) { + hadfocus = 1; } if (wapp->app_icon) hideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos, wapp->app_icon->y_pos, wlist, !wapp->flags.skip_next_animation); - } - wlist = wlist->prev; + } + wlist = wlist->prev; } - - wapp->flags.skip_next_animation = 0; + + wapp->flags.skip_next_animation = 0; if (hadfocus) { - if (wPreferences.focus_mode==WKF_CLICK) { - wlist = scr->focused_window; - while (wlist) { - if (!WFLAGP(wlist, no_focusable) && !wlist->flags.hidden - && (wlist->flags.mapped || wlist->flags.shaded)) - break; - wlist = wlist->prev; - } - wSetFocusTo(scr, wlist); - } else { - wSetFocusTo(scr, NULL); - } + if (wPreferences.focus_mode==WKF_CLICK) { + wlist = scr->focused_window; + while (wlist) { + if (!WFLAGP(wlist, no_focusable) && !wlist->flags.hidden + && (wlist->flags.mapped || wlist->flags.shaded)) + break; + wlist = wlist->prev; + } + wSetFocusTo(scr, wlist); + } else { + wSetFocusTo(scr, NULL); + } } - + wapp->flags.hidden = 1; - + if(wPreferences.auto_arrange_icons) { - wArrangeIcons(scr, True); + wArrangeIcons(scr, True); } #ifdef HIDDENDOT if (wapp->app_icon) - wAppIconPaint(wapp->app_icon); + wAppIconPaint(wapp->app_icon); #endif } @@ -1338,21 +1338,21 @@ wHideApplication(WApplication *wapp) static void unhideWindow(WIcon *icon, int icon_x, int icon_y, WWindow *wwin, int animate, - int bringToCurrentWS) + int bringToCurrentWS) { if (bringToCurrentWS) - wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace); + wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace); wwin->flags.hidden=0; wSoundPlay(WSOUND_UNHIDE); #ifdef ANIMATIONS - if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations - && animate) { - animateResize(wwin->screen_ptr, icon_x, icon_y, - icon->core->width, icon->core->height, - wwin->frame_x, wwin->frame_y, - wwin->frame->core->width, wwin->frame->core->height, + if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations + && animate) { + animateResize(wwin->screen_ptr, icon_x, icon_y, + icon->core->width, icon->core->height, + wwin->frame_x, wwin->frame_y, + wwin->frame->core->width, wwin->frame->core->height, True); } #endif @@ -1381,7 +1381,7 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS) Bool shouldArrangeIcons = False; if (!wapp) - return; + return; scr = wapp->main_window_desc->screen_ptr; wlist = scr->focused_window; @@ -1390,18 +1390,18 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS) /* goto beginning of list */ while (wlist->prev) - wlist = wlist->prev; + wlist = wlist->prev; while (wlist) { - next = wlist->next; + next = wlist->next; - if (wlist->main_window == wapp->main_window) { - if (wlist->flags.focused) + if (wlist->main_window == wapp->main_window) { + if (wlist->flags.focused) focused = wlist; - else if (!focused || !focused->flags.focused) + else if (!focused || !focused->flags.focused) focused = wlist; - if (wlist->flags.miniaturized) { + if (wlist->flags.miniaturized) { if (bringToCurrentWS || wPreferences.sticky_icons || wlist->frame->workspace == scr->current_workspace) { if (wlist->icon && !wlist->icon->mapped) { @@ -1430,25 +1430,25 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS) } } WMPostNotificationName(WMNChangedState, wlist, "hide"); - } else if (wlist->flags.hidden) { - unhideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos, - wapp->app_icon->y_pos, wlist, - !wapp->flags.skip_next_animation, - bringToCurrentWS); - } else { - if (bringToCurrentWS - && wlist->frame->workspace != scr->current_workspace) { - wWindowChangeWorkspace(wlist, scr->current_workspace); - } - wRaiseFrame(wlist->frame->core); - } - } - wlist = next; + } else if (wlist->flags.hidden) { + unhideWindow(wapp->app_icon->icon, wapp->app_icon->x_pos, + wapp->app_icon->y_pos, wlist, + !wapp->flags.skip_next_animation, + bringToCurrentWS); + } else { + if (bringToCurrentWS + && wlist->frame->workspace != scr->current_workspace) { + wWindowChangeWorkspace(wlist, scr->current_workspace); + } + wRaiseFrame(wlist->frame->core); + } + } + wlist = next; } - + wapp->flags.skip_next_animation = 0; wapp->flags.hidden = 0; - + if (wapp->last_focused && wapp->last_focused->flags.mapped) { wRaiseFrame(wapp->last_focused->frame->core); wSetFocusTo(scr, wapp->last_focused); @@ -1461,7 +1461,7 @@ wUnhideApplication(WApplication *wapp, Bool miniwindows, Bool bringToCurrentWS) } #ifdef HIDDENDOT wAppIconPaint(wapp->app_icon); -#endif +#endif } @@ -1476,21 +1476,21 @@ wShowAllWindows(WScreen *scr) while (wwin) { if (!wwin->flags.internal_window && (scr->current_workspace == wwin->frame->workspace - || IS_OMNIPRESENT(wwin))) { - if (wwin->flags.miniaturized) { - wwin->flags.skip_next_animation = 1; - wDeiconifyWindow(wwin); - } else if (wwin->flags.hidden) { - wapp = wApplicationOf(wwin->main_window); - if (wapp) { - wUnhideApplication(wapp, False, False); - } else { - wwin->flags.skip_next_animation = 1; - wDeiconifyWindow(wwin); - } - } - } - wwin = wwin->prev; + || IS_OMNIPRESENT(wwin))) { + if (wwin->flags.miniaturized) { + wwin->flags.skip_next_animation = 1; + wDeiconifyWindow(wwin); + } else if (wwin->flags.hidden) { + wapp = wApplicationOf(wwin->main_window); + if (wapp) { + wUnhideApplication(wapp, False, False); + } else { + wwin->flags.skip_next_animation = 1; + wDeiconifyWindow(wwin); + } + } + } + wwin = wwin->prev; } wSetFocusTo(scr, old_foc); /*wRaiseFrame(old_foc->frame->core);*/ @@ -1505,10 +1505,10 @@ wRefreshDesktop(WScreen *scr) attr.backing_store = NotUseful; attr.save_under = False; - win = XCreateWindow(dpy, scr->root_win, 0, 0, scr->scr_width, - scr->scr_height, 0, CopyFromParent, CopyFromParent, - (Visual *)CopyFromParent, CWBackingStore|CWSaveUnder, - &attr); + win = XCreateWindow(dpy, scr->root_win, 0, 0, scr->scr_width, + scr->scr_height, 0, CopyFromParent, CopyFromParent, + (Visual *)CopyFromParent, CWBackingStore|CWSaveUnder, + &attr); XMapRaised(dpy, win); XDestroyWindow(dpy, win); XFlush(dpy); @@ -1524,156 +1524,160 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) int head; const int heads = wXineramaHeads(scr); - struct { - int pf; /* primary axis */ - int sf; /* secondary axis */ - int fullW; - int fullH; - int pi, si; - int sx1, sx2, sy1, sy2; /* screen boundary */ - int sw, sh; - int xo, yo; - int xs, ys; - } vars[heads]; + struct HeadVars { + int pf; /* primary axis */ + int sf; /* secondary axis */ + int fullW; + int fullH; + int pi, si; + int sx1, sx2, sy1, sy2; /* screen boundary */ + int sw, sh; + int xo, yo; + int xs, ys; + } *vars; int isize = wPreferences.icon_size; + vars = (struct HeadVars*)wmalloc(sizeof(struct HeadVars)*heads); + for (head = 0; head < heads; ++head) { #if 0 - WMRect rect = wGetRectForHead(scr, head); + WMRect rect = wGetRectForHead(scr, head); #else - WArea area = wGetUsableAreaForHead(scr, head, NULL, False); - WMRect rect = (WMRect){ area.x1, area.y1, area.x2-area.x1, area.y2-area.y1 }; + WArea area = wGetUsableAreaForHead(scr, head, NULL, False); + WMRect rect = wmkrect(area.x1, area.y1, area.x2-area.x1, area.y2-area.y1); #endif - vars[head].pi = vars[head].si = 0; - vars[head].sx1 = rect.pos.x; - vars[head].sy1 = rect.pos.y; - vars[head].sw = rect.size.width; - vars[head].sh = rect.size.height; - vars[head].sx2 = vars[head].sx1 + vars[head].sw; - vars[head].sy2 = vars[head].sy1 + vars[head].sh; + vars[head].pi = vars[head].si = 0; + vars[head].sx1 = rect.pos.x; + vars[head].sy1 = rect.pos.y; + vars[head].sw = rect.size.width; + vars[head].sh = rect.size.height; + vars[head].sx2 = vars[head].sx1 + vars[head].sw; + vars[head].sy2 = vars[head].sy1 + vars[head].sh; #if 0 - if (scr->dock) { - if (scr->dock->on_right_side) - vars[head].sx2 -= isize + DOCK_EXTRA_SPACE; - else - vars[head].sx1 += isize + DOCK_EXTRA_SPACE; - } + if (scr->dock) { + if (scr->dock->on_right_side) + vars[head].sx2 -= isize + DOCK_EXTRA_SPACE; + else + vars[head].sx1 += isize + DOCK_EXTRA_SPACE; + } #endif - vars[head].sw = isize * (vars[head].sw/isize); - vars[head].sh = isize * (vars[head].sh/isize); - vars[head].fullW = (vars[head].sx2-vars[head].sx1)/isize; - vars[head].fullH = (vars[head].sy2-vars[head].sy1)/isize; + vars[head].sw = isize * (vars[head].sw/isize); + vars[head].sh = isize * (vars[head].sh/isize); + vars[head].fullW = (vars[head].sx2-vars[head].sx1)/isize; + vars[head].fullH = (vars[head].sy2-vars[head].sy1)/isize; - /* icon yard boundaries */ - if (wPreferences.icon_yard & IY_VERT) { - vars[head].pf = vars[head].fullH; - vars[head].sf = vars[head].fullW; - } else { - vars[head].pf = vars[head].fullW; - vars[head].sf = vars[head].fullH; - } - if (wPreferences.icon_yard & IY_RIGHT) { - vars[head].xo = vars[head].sx2 - isize; - vars[head].xs = -1; - } else { - vars[head].xo = vars[head].sx1; - vars[head].xs = 1; - } - if (wPreferences.icon_yard & IY_TOP) { - vars[head].yo = vars[head].sy1; - vars[head].ys = 1; - } else { - vars[head].yo = vars[head].sy2 - isize; - vars[head].ys = -1; - } + /* icon yard boundaries */ + if (wPreferences.icon_yard & IY_VERT) { + vars[head].pf = vars[head].fullH; + vars[head].sf = vars[head].fullW; + } else { + vars[head].pf = vars[head].fullW; + vars[head].sf = vars[head].fullH; + } + if (wPreferences.icon_yard & IY_RIGHT) { + vars[head].xo = vars[head].sx2 - isize; + vars[head].xs = -1; + } else { + vars[head].xo = vars[head].sx1; + vars[head].xs = 1; + } + if (wPreferences.icon_yard & IY_TOP) { + vars[head].yo = vars[head].sy1; + vars[head].ys = 1; + } else { + vars[head].yo = vars[head].sy2 - isize; + vars[head].ys = -1; + } } #define X ((wPreferences.icon_yard & IY_VERT) \ - ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \ - : vars[head].xo + vars[head].xs*(vars[head].pi*isize)) + ? vars[head].xo + vars[head].xs*(vars[head].si*isize) \ + : vars[head].xo + vars[head].xs*(vars[head].pi*isize)) #define Y ((wPreferences.icon_yard & IY_VERT) \ - ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \ - : vars[head].yo + vars[head].ys*(vars[head].si*isize)) + ? vars[head].yo + vars[head].ys*(vars[head].pi*isize) \ + : vars[head].yo + vars[head].ys*(vars[head].si*isize)) /* arrange application icons */ aicon = scr->app_icon_list; /* reverse them to avoid unnecessarily sliding of icons */ while (aicon && aicon->next) - aicon = aicon->next; + aicon = aicon->next; while (aicon) { - if (!aicon->docked) { - /* XXX: can: icon == NULL ? */ - /* The intention here is to place the AppIcon on the head that contains most of the applications _main_ window. */ -/* printf( "appicon: %x %x\n", aicon->icon->core->window, aicon->main_window); */ - head = wGetHeadForWindow(aicon->icon->owner); + if (!aicon->docked) { + /* XXX: can: icon == NULL ? */ + /* The intention here is to place the AppIcon on the head that contains most of the applications _main_ window. */ + /* printf("appicon: %x %x\n", aicon->icon->core->window, aicon->main_window); */ + head = wGetHeadForWindow(aicon->icon->owner); - if (aicon->x_pos != X || aicon->y_pos != Y) { + if (aicon->x_pos != X || aicon->y_pos != Y) { #ifdef ANIMATIONS - if (!wPreferences.no_animations) { - SlideWindow(aicon->icon->core->window, - aicon->x_pos, aicon->y_pos, X, Y); - } + if (!wPreferences.no_animations) { + SlideWindow(aicon->icon->core->window, + aicon->x_pos, aicon->y_pos, X, Y); + } #endif /* ANIMATIONS */ - } - wAppIconMove(aicon, X, Y); - vars[head].pi++; - if (vars[head].pi >= vars[head].pf) { - vars[head].pi = 0; - vars[head].si++; - } - } - aicon = aicon->prev; + } + wAppIconMove(aicon, X, Y); + vars[head].pi++; + if (vars[head].pi >= vars[head].pf) { + vars[head].pi = 0; + vars[head].si++; + } + } + aicon = aicon->prev; } /* arrange miniwindows */ wwin = scr->focused_window; /* reverse them to avoid unnecessarily shuffling */ while (wwin && wwin->prev) - wwin = wwin->prev; + wwin = wwin->prev; while (wwin) { if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden && (wwin->frame->workspace==scr->current_workspace || IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) { - head = wGetHeadForWindow(wwin); - - if (arrangeAll || !wwin->flags.icon_moved) { - if (wwin->icon_x != X || wwin->icon_y != Y) { -#ifdef ANIMATIONS - if (wPreferences.no_animations) { - XMoveWindow(dpy, wwin->icon->core->window, X, Y); - } else { - SlideWindow(wwin->icon->core->window, wwin->icon_x, - wwin->icon_y, X, Y); - } -#else - XMoveWindow(dpy, wwin->icon->core->window, X, Y); -#endif /* ANIMATIONS */ - } - wwin->icon_x = X; - wwin->icon_y = Y; + head = wGetHeadForWindow(wwin); - vars[head].pi++; - if (vars[head].pi >= vars[head].pf) { - vars[head].pi = 0; - vars[head].si++; - } - } - } - if (arrangeAll) { - wwin->flags.icon_moved = 0; - } + if (arrangeAll || !wwin->flags.icon_moved) { + if (wwin->icon_x != X || wwin->icon_y != Y) { +#ifdef ANIMATIONS + if (wPreferences.no_animations) { + XMoveWindow(dpy, wwin->icon->core->window, X, Y); + } else { + SlideWindow(wwin->icon->core->window, wwin->icon_x, + wwin->icon_y, X, Y); + } +#else + XMoveWindow(dpy, wwin->icon->core->window, X, Y); +#endif /* ANIMATIONS */ + } + wwin->icon_x = X; + wwin->icon_y = Y; + + vars[head].pi++; + if (vars[head].pi >= vars[head].pf) { + vars[head].pi = 0; + vars[head].si++; + } + } + } + if (arrangeAll) { + wwin->flags.icon_moved = 0; + } /* we reversed the order, so we use next */ wwin = wwin->next; } + + wfree(vars); } #if 0 @@ -1709,10 +1713,10 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) sx2 = sx1 + sw; sy2 = sy1 + sh; if (scr->dock) { - if (scr->dock->on_right_side) - sx2 -= isize + DOCK_EXTRA_SPACE; - else - sx1 += isize + DOCK_EXTRA_SPACE; + if (scr->dock->on_right_side) + sx2 -= isize + DOCK_EXTRA_SPACE; + else + sx1 += isize + DOCK_EXTRA_SPACE; } #if 0 @@ -1725,35 +1729,35 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) fullW = (sx2-sx1)/isize; fullH = (sy2-sy1)/isize; - /* icon yard boundaries */ + /* icon yard boundaries */ if (wPreferences.icon_yard & IY_VERT) { - pf = fullH; - sf = fullW; + pf = fullH; + sf = fullW; } else { - pf = fullW; - sf = fullH; + pf = fullW; + sf = fullH; } if (wPreferences.icon_yard & IY_RIGHT) { - xo = sx2 - isize; - xs = -1; + xo = sx2 - isize; + xs = -1; } else { - xo = sx1; - xs = 1; + xo = sx1; + xs = 1; } if (wPreferences.icon_yard & IY_TOP) { - yo = sy1; - ys = 1; + yo = sy1; + ys = 1; } else { - yo = sy2 - isize; - ys = -1; + yo = sy2 - isize; + ys = -1; } /* arrange icons putting the most recently focused window * as the last icon */ #define X ((wPreferences.icon_yard & IY_VERT) ? xo + xs*(si*isize)\ - : xo + xs*(pi*isize)) + : xo + xs*(pi*isize)) #define Y ((wPreferences.icon_yard & IY_VERT) ? yo + ys*(pi*isize)\ - : yo + ys*(si*isize)) + : yo + ys*(si*isize)) /* arrange application icons */ aicon = scr->app_icon_list; @@ -1763,7 +1767,7 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) pi = 0; si = 0; - while (aicon) { + while (aicon) { if (!aicon->docked) { if (aicon->x_pos != X || aicon->y_pos != Y) { #ifdef ANIMATIONS @@ -1772,8 +1776,8 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) X, Y); } #endif /* ANIMATIONS */ - } - wAppIconMove(aicon, X, Y); + } + wAppIconMove(aicon, X, Y); pi++; } /* we reversed the order so we use prev */ @@ -1783,7 +1787,7 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) si++; } } - + /* arrange miniwindows */ wwin = scr->focused_window; @@ -1795,34 +1799,34 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll) if (wwin->icon && wwin->flags.miniaturized && !wwin->flags.hidden && (wwin->frame->workspace==scr->current_workspace || IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons)) { - - if (arrangeAll || !wwin->flags.icon_moved) { - if (wwin->icon_x != X || wwin->icon_y != Y) { + + if (arrangeAll || !wwin->flags.icon_moved) { + if (wwin->icon_x != X || wwin->icon_y != Y) { #ifdef ANIMATIONS - if (wPreferences.no_animations) { - XMoveWindow(dpy, wwin->icon->core->window, X, Y); - } else { - SlideWindow(wwin->icon->core->window, wwin->icon_x, - wwin->icon_y, X, Y); - } + if (wPreferences.no_animations) { + XMoveWindow(dpy, wwin->icon->core->window, X, Y); + } else { + SlideWindow(wwin->icon->core->window, wwin->icon_x, + wwin->icon_y, X, Y); + } #else - XMoveWindow(dpy, wwin->icon->core->window, X, Y); + XMoveWindow(dpy, wwin->icon->core->window, X, Y); #endif /* ANIMATIONS */ - } - wwin->icon_x = X; - wwin->icon_y = Y; - pi++; - } - } - if (arrangeAll) { - wwin->flags.icon_moved = 0; - } + } + wwin->icon_x = X; + wwin->icon_y = Y; + pi++; + } + } + if (arrangeAll) { + wwin->flags.icon_moved = 0; + } /* we reversed the order, so we use next */ wwin = wwin->next; - if (pi >= pf) { - pi=0; - si++; - } + if (pi >= pf) { + pi=0; + si++; + } } } #endif @@ -1831,31 +1835,31 @@ void wSelectWindow(WWindow *wwin, Bool flag) { WScreen *scr = wwin->screen_ptr; - + if (flag) { - wwin->flags.selected = 1; - XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel); - - if (WFLAGP(wwin, no_border)) { - XSetWindowBorderWidth(dpy, wwin->frame->core->window, - FRAME_BORDER_WIDTH); - } + wwin->flags.selected = 1; + XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel); - if (!scr->selected_windows) - scr->selected_windows = WMCreateArray(4); - WMAddToArray(scr->selected_windows, wwin); + if (WFLAGP(wwin, no_border)) { + XSetWindowBorderWidth(dpy, wwin->frame->core->window, + FRAME_BORDER_WIDTH); + } + + if (!scr->selected_windows) + scr->selected_windows = WMCreateArray(4); + WMAddToArray(scr->selected_windows, wwin); } else { - wwin->flags.selected = 0; - XSetWindowBorder(dpy, wwin->frame->core->window, - scr->frame_border_pixel); + wwin->flags.selected = 0; + XSetWindowBorder(dpy, wwin->frame->core->window, + scr->frame_border_pixel); - if (WFLAGP(wwin, no_border)) { - XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0); - } + if (WFLAGP(wwin, no_border)) { + XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0); + } - if (scr->selected_windows) { - WMRemoveFromArray(scr->selected_windows, wwin); - } + if (scr->selected_windows) { + WMRemoveFromArray(scr->selected_windows, wwin); + } } } @@ -1864,15 +1868,15 @@ void wMakeWindowVisible(WWindow *wwin) { if (wwin->frame->workspace != wwin->screen_ptr->current_workspace) - wWorkspaceChange(wwin->screen_ptr, wwin->frame->workspace); + wWorkspaceChange(wwin->screen_ptr, wwin->frame->workspace); if (wwin->flags.shaded) { wUnshadeWindow(wwin); } if (wwin->flags.hidden) { - WApplication *app; + WApplication *app; - app = wApplicationOf(wwin->main_window); + app = wApplicationOf(wwin->main_window); if (app) { /* trick to get focus to this window */ app->last_focused = wwin; @@ -1880,10 +1884,10 @@ wMakeWindowVisible(WWindow *wwin) } } if (wwin->flags.miniaturized) { - wDeiconifyWindow(wwin); + wDeiconifyWindow(wwin); } else { - if (!WFLAGP(wwin, no_focusable)) - wSetFocusTo(wwin->screen_ptr, wwin); - wRaiseFrame(wwin->frame->core); + if (!WFLAGP(wwin, no_focusable)) + wSetFocusTo(wwin->screen_ptr, wwin); + wRaiseFrame(wwin->frame->core); } } diff --git a/src/application.c b/src/application.c index 62117ce3..fe9b4843 100644 --- a/src/application.c +++ b/src/application.c @@ -88,7 +88,7 @@ makeMainWindow(WScreen *scr, Window window) &wwin->user_flags, &wwin->defined_user_flags, True); XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask - | StructureNotifyMask ); + | StructureNotifyMask); return wwin; } diff --git a/src/appmenu.c b/src/appmenu.c index 6c378adf..6366cdb4 100644 --- a/src/appmenu.c +++ b/src/appmenu.c @@ -300,7 +300,7 @@ wAppMenuMap(WMenu *menu, WWindow *wwin) int x, min; min = 20; /* Keep at least 20 pixels visible */ - if( wwin->frame_x > min ) { + if (wwin->frame_x > min) { x = wwin->frame_x - menu->frame->core->width; } else { diff --git a/src/client.c b/src/client.c index 05ee0604..0cba6a44 100644 --- a/src/client.c +++ b/src/client.c @@ -180,7 +180,7 @@ wClientConfigure(WWindow *wwin, XConfigureRequestEvent *xcre) int nx, ny, nwidth, nheight; int ofs_x, ofs_y; -/* printf( "configure event: %d %d %d %d\n", xcre->x, xcre->y, xcre->width, xcre->height);*/ +/* printf("configure event: %d %d %d %d\n", xcre->x, xcre->y, xcre->width, xcre->height);*/ if (wwin==NULL) { /* diff --git a/src/defaults.c b/src/defaults.c index 67c8c1e3..cb16954f 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -3195,7 +3195,7 @@ setIconTitleBack(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo) if (scr->icon_title_texture) { wTextureDestroy(scr, (WTexture*)scr->icon_title_texture); } - // ?? why is this necessary? color was already parsed and alloc'ed + /* // ?? why is this necessary? color was already parsed and alloc'ed */ XQueryColor (dpy, scr->w_colormap, color); scr->icon_title_texture = wTextureMakeSolid(scr, color); @@ -3464,6 +3464,7 @@ setKeyGrab(WScreen *scr, WDefaultEntry *entry, WShortKey *shortcut, long index) static int setIconPosition(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo) { + wScreenUpdateUsableArea(scr); wArrangeIcons(scr, True); return 0; diff --git a/src/dock.c b/src/dock.c index c2f755a7..f44ea5ad 100644 --- a/src/dock.c +++ b/src/dock.c @@ -2646,7 +2646,7 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, static int onScreen(WScreen *scr, int x, int y, int sx, int ex, int sy, int ey) { - WMRect rect = {x, y, ICON_SIZE, ICON_SIZE}; + WMRect rect = wmkrect(x, y, ICON_SIZE, ICON_SIZE); int flags; wGetRectPlacementInfo(scr, rect, &flags); diff --git a/src/event.c b/src/event.c index 1b2bf1f6..3f1b7b4e 100644 --- a/src/event.c +++ b/src/event.c @@ -1726,8 +1726,8 @@ handleMotionNotify(XEvent *event) WScreen *scr = wScreenForRootWindow(event->xmotion.root); if (wPreferences.scrollable_menus) { - WMPoint p = { event->xmotion.x_root, event->xmotion.y_root }; - WMRect rect = wGetRectForHead(scr, wGetHeadForPoint(scr, p)); + WMPoint p = wmkpoint(event->xmotion.x_root, event->xmotion.y_root); + WMRect rect = wGetRectForHead(scr, wGetHeadForPoint(scr, p)); if (scr->flags.jump_back_pending || p.x <= (rect.pos.x + 1) || diff --git a/src/kwm.c b/src/kwm.c index 01c369be..ec63ea9a 100644 --- a/src/kwm.c +++ b/src/kwm.c @@ -1401,7 +1401,7 @@ wKWMCheckRootHintChange(WScreen *scr, XPropertyEvent *event) } } #else - if ( i == scr->current_workspace % MAX_WORKSPACES) + if (i == scr->current_workspace % MAX_WORKSPACES) wScreenUpdateUsableArea(scr); #endif @@ -1630,13 +1630,13 @@ wKWMGetUsableArea(WScreen *scr, int head, WArea *area) ok = getAreaHint(scr->root_win, _XA_KWM_WINDOW_REGION_[region], area); - if ( ok) { + if (ok) { WMRect rect = wGetRectForHead(scr, head); - area->x1 = WMAX( area->x1, rect.pos.x); - area->x2 = WMIN( area->x2, rect.pos.x + rect.size.width); - area->y1 = WMAX( area->y1, rect.pos.y); - area->y2 = WMIN( area->y2, rect.pos.y + rect.size.height); + area->x1 = WMAX(area->x1, rect.pos.x); + area->x2 = WMIN(area->x2, rect.pos.x + rect.size.width); + area->y1 = WMAX(area->y1, rect.pos.y); + area->y2 = WMIN(area->y2, rect.pos.y + rect.size.height); } return ok; diff --git a/src/menu.c b/src/menu.c index 8d659580..025f60a7 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1746,9 +1746,10 @@ isPointNearBoder(WMenu *menu, int x, int y) int menuX2 = menu->frame_x + MENUW(menu); int menuY2 = menu->frame_y + MENUH(menu); int flag = 0; - /* XXX: handle screen joins proper !! */ - WMRect rect = wGetRectForHead(menu->frame->screen_ptr, - wGetHeadForPoint(menu->frame->screen_ptr, (WMPoint){ x, y})); + int head = wGetHeadForPoint(menu->frame->screen_ptr, wmkpoint(x, y)); + WMRect rect = wGetRectForHead(menu->frame->screen_ptr, head); + + /* XXX: handle screen joins properly !! */ if (x >= menuX1 && x <= menuX2 && (y < rect.pos.y + MENU_SCROLL_BORDER || @@ -1764,17 +1765,16 @@ isPointNearBoder(WMenu *menu, int x, int y) typedef struct _delay { - WWindow *wwin; WMenu *menu; - int ox,oy; + int ox, oy; } _delay; static void -_leaving(_delay *dl) +leaving(_delay *dl) { wMenuMove(dl->menu, dl->ox, dl->oy, True); - dl->menu->jump_back=NULL; + dl->menu->jump_back = NULL; dl->menu->menu->screen_ptr->flags.jump_back_pending = 0; wfree(dl); } @@ -1832,7 +1832,7 @@ wMenuScroll(WMenu *menu, XEvent *event) break; } - rect = wGetRectForHead(scr, wGetHeadForPoint(scr, (WMPoint){ x, y })); + rect = wGetRectForHead(scr, wGetHeadForPoint(scr, wmkpoint(x, y))); on_x_edge = x <= rect.pos.x + 1 || x >= rect.pos.x + rect.size.width - 2; on_y_edge = y <= rect.pos.y + 1 || y >= rect.pos.y + rect.size.height - 2; on_border = on_x_edge || on_y_edge; @@ -1884,15 +1884,15 @@ wMenuScroll(WMenu *menu, XEvent *event) if (jump_back) { _delay *delayer; if (!omenu->jump_back) { - delayer=wmalloc(sizeof(_delay)); + delayer = wmalloc(sizeof(_delay)); delayer->menu=omenu; delayer->ox=old_frame_x; delayer->oy=old_frame_y; - omenu->jump_back=delayer; + omenu->jump_back = delayer; scr->flags.jump_back_pending = 1; } else delayer = omenu->jump_back; - WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)_leaving, delayer); + WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)leaving, delayer); } } diff --git a/src/placement.c b/src/placement.c index 0ac4db6c..f5c0b529 100644 --- a/src/placement.c +++ b/src/placement.c @@ -141,22 +141,18 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head) int isize = wPreferences.icon_size; int done = 0; WMBagIterator iter; - /* - * Find out screen boundaries. - */ - - /* - * Allows each head to have miniwindows - */ WArea area = wGetUsableAreaForHead(scr, head, NULL, False); - WMRect rect = (WMRect){ area.x1, area.y1, area.x2-area.x1, area.y2-area.y1 }; - sx1 = rect.pos.x; - sy1 = rect.pos.y; - sw = rect.size.width; - sh = rect.size.height; - sx2 = sx1 + sw; - sy2 = sy1 + sh; + /* Find out screen boundaries. */ + + /* Allows each head to have miniwindows */ + + sx1 = area.x1; + sy1 = area.y1; + sx2 = area.x2; + sy2 = area.y2; + sw = sx2-sx1; + sh = sy2-sy1; #if 0 if (scr->dock) { @@ -383,7 +379,7 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, sum_isect = calcSumOfCoveredAreas(wwin, test_x, test_y, width, height); - if ( sum_isect < min_isect ) { + if (sum_isect < min_isect) { min_isect = sum_isect; min_isect_x = test_x; min_isect_y = test_y; @@ -411,7 +407,7 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, sum_isect = calcSumOfCoveredAreas(wwin, test_x, test_y, width, height); - if ( sum_isect < min_isect ) { + if (sum_isect < min_isect) { min_isect = sum_isect; min_isect_x = test_x; min_isect_y = test_y; diff --git a/src/screen.c b/src/screen.c index e5056e90..4e1fb377 100644 --- a/src/screen.c +++ b/src/screen.c @@ -624,10 +624,10 @@ wScreenInit(int screen_number) wInitXinerama(scr); - scr->usableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: checl NULL */ - scr->totalUsableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: */ + scr->usableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr)); + scr->totalUsableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr)); - for ( i=0; iusableArea[i].x1 = scr->totalUsableArea[i].x1 = rect.pos.x; scr->usableArea[i].y1 = scr->totalUsableArea[i].y1 = rect.pos.y; @@ -838,8 +838,9 @@ void wScreenUpdateUsableArea(WScreen *scr) { /* - * scr->totalUsableArea[] will become the usableArea used for Windowplacement, - * scr->usableArea[] will be used for iconplacement, hence no iconyard nor border. + * scr->totalUsableArea[] will become the usableArea used for Windowplacement, + * scr->usableArea[] will be used for iconplacement, hence no iconyard nor + * border. */ int i; @@ -847,25 +848,27 @@ wScreenUpdateUsableArea(WScreen *scr) WArea area; int dock_head = scr->xine_info.primary_head; - if ( scr->dock) { - WMRect rect = { scr->dock->x_pos, scr->dock->y_pos, wPreferences.icon_size, wPreferences.icon_size }; + if (scr->dock) { + WMRect rect; + rect.pos.x = scr->dock->x_pos; + rect.pos.y = scr->dock->y_pos; + rect.size.width = wPreferences.icon_size; + rect.size.height = wPreferences.icon_size; dock_head = wGetHeadForRect(scr, rect); } - for ( i=0; itotalUsableArea[i] = (WArea){ - rect.pos.x, - rect.pos.y, - rect.pos.x + rect.size.width, - rect.pos.y + rect.size.height - }; + scr->totalUsableArea[i].x1 = rect.pos.x; + scr->totalUsableArea[i].y1 = rect.pos.y; + scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; + scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; - if ( scr->dock && dock_head==i && - (!scr->dock->lowered || wPreferences.no_window_over_dock)) { + if (scr->dock && dock_head==i && + (!scr->dock->lowered || wPreferences.no_window_over_dock)) { int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE; - if ( scr->dock->on_right_side) { + if (scr->dock->on_right_side) { scr->totalUsableArea[i].x2 -= offset; } else { scr->totalUsableArea[i].x1 += offset; @@ -873,9 +876,9 @@ wScreenUpdateUsableArea(WScreen *scr) } #ifdef NETWM_HINTS - { + { WArea area; - if ( wNETWMGetUsableArea(scr, i, &area)) { + if (wNETWMGetUsableArea(scr, i, &area)) { scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); @@ -887,7 +890,7 @@ wScreenUpdateUsableArea(WScreen *scr) #ifdef GNOME_STUFF { WArea area; - if ( wGNOMEGetUsableArea(scr, i, &area)) { + if (wGNOMEGetUsableArea(scr, i, &area)) { scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); @@ -899,7 +902,7 @@ wScreenUpdateUsableArea(WScreen *scr) #ifdef KWM_HINTS { WArea area; - if ( wKWMGetUsableArea(scr, i, &area)) { + if (wKWMGetUsableArea(scr, i, &area)) { scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); @@ -911,22 +914,20 @@ wScreenUpdateUsableArea(WScreen *scr) scr->usableArea[i] = scr->totalUsableArea[i]; #if 0 - printf( "usableArea[%d]: %d %d %d %d\n", i, - scr->usableArea[i].x1, - scr->usableArea[i].x2, - scr->usableArea[i].y1, - scr->usableArea[i].y2); + printf("usableArea[%d]: %d %d %d %d\n", i, + scr->usableArea[i].x1, scr->usableArea[i].x2, + scr->usableArea[i].y1, scr->usableArea[i].y2); #endif - if ( wPreferences.no_window_over_icons) { - if ( wPreferences.icon_yard & IY_VERT) { - if ( wPreferences.icon_yard & IY_RIGHT) { - scr->totalUsableArea[i].x1 += wPreferences.icon_size; - } else { + if (wPreferences.no_window_over_icons) { + if (wPreferences.icon_yard & IY_VERT) { + if (wPreferences.icon_yard & IY_RIGHT) { scr->totalUsableArea[i].x2 -= wPreferences.icon_size; + } else { + scr->totalUsableArea[i].x1 += wPreferences.icon_size; } } else { - if ( wPreferences.icon_yard & IY_TOP) { + if (wPreferences.icon_yard & IY_TOP) { scr->totalUsableArea[i].y1 += wPreferences.icon_size; } else { scr->totalUsableArea[i].y2 -= wPreferences.icon_size; @@ -937,7 +938,8 @@ wScreenUpdateUsableArea(WScreen *scr) if (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1 < rect.size.width/2) { scr->totalUsableArea[i].x1 = rect.pos.x; scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; - } + } + if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) { scr->totalUsableArea[i].y1 = rect.pos.y; scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; @@ -946,7 +948,7 @@ wScreenUpdateUsableArea(WScreen *scr) tmp_area = (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1) * (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1); - if ( tmp_area > best_area) { + if (tmp_area > best_area) { best_area = tmp_area; area = scr->totalUsableArea[i]; } diff --git a/src/session.c b/src/session.c index f5d4d54b..d9a834ff 100644 --- a/src/session.c +++ b/src/session.c @@ -289,7 +289,7 @@ makeWindowState(WWindow *wwin, WApplication *wapp) for(i=0; iworkspace_count; i++) if(scr->workspaces[i]->clip == wapp->app_icon->dock) break; - assert( i < scr->workspace_count); + assert(i < scr->workspace_count); /*n = i+1;*/ name = scr->workspaces[i]->name; } diff --git a/src/usermenu.c b/src/usermenu.c index 876968db..b3c94263 100644 --- a/src/usermenu.c +++ b/src/usermenu.c @@ -355,7 +355,7 @@ wUserMenuGet(WScreen *scr, WWindow *wwin) char buffer[100]; char *path = NULL; char *tmp; - if ( wwin->wm_instance && wwin->wm_class ) { + if (wwin->wm_instance && wwin->wm_class) { int len = strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7; tmp=wmalloc(len); snprintf(tmp,len,"%s.%s.menu",wwin->wm_instance,wwin->wm_class); diff --git a/src/window.c b/src/window.c index 3eaf09f0..37ec27b5 100644 --- a/src/window.c +++ b/src/window.c @@ -773,7 +773,7 @@ wManageWindow(WScreen *scr, Window window) /* get geometry stuff */ wClientGetNormalHints(wwin, &wattribs, True, &x, &y, &width, &height); -/* printf( "wManageWindow: %d %d %d %d\n", x, y, width, height);*/ +/* printf("wManageWindow: %d %d %d %d\n", x, y, width, height);*/ /* get colormap windows */ GetColormapWindows(wwin); @@ -1152,11 +1152,11 @@ wManageWindow(WScreen *scr, Window window) * them. -alfredo */ #if 0 - printf( "xinerama PPosition: x: %d %d\n", x, (scr->scr_width - width)/2); - printf( "xinerama PPosition: y: %d %d\n", y, (scr->scr_height - height)/2); + printf("xinerama PPosition: x: %d %d\n", x, (scr->scr_width - width)/2); + printf("xinerama PPosition: y: %d %d\n", y, (scr->scr_height - height)/2); - if ( (unsigned)(x + (width - scr->scr_width)/2 + 10) < 20 && - (unsigned)(y + (height - scr->scr_height)/2 + 10) < 20) { + if ((unsigned)(x + (width - scr->scr_width)/2 + 10) < 20 && + (unsigned)(y + (height - scr->scr_height)/2 + 10) < 20) { reposition = 1; @@ -3005,7 +3005,8 @@ wWindowDeleteSavedStatesForPID(pid_t pid) void wWindowSetOmnipresent(WWindow *wwin, Bool flag) { - if ( wwin->flags.omnipresent == flag) return; + if (wwin->flags.omnipresent == flag) + return; wwin->flags.omnipresent = flag; WMPostNotificationName(WMNChangedState, wwin, "omnipresent"); diff --git a/src/xinerama.c b/src/xinerama.c index 208befd5..2877ed42 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -135,17 +135,17 @@ wGetRectPlacementInfo(WScreen *scr, WMRect rect, int *flags) totalArea += a; if (a > area) { - if ( best != -1) + if (best != -1) *flags |= XFLAG_MULTIPLE; area = a; best = i; } } - if ( best == -1) { + if (best == -1) { *flags |= XFLAG_DEAD; best = wGetHeadForPointerLocation(scr); - } else if ( totalArea != rw*rh) + } else if (totalArea != rw*rh) *flags |= XFLAG_PARTIAL; return best; @@ -242,7 +242,7 @@ wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags) int i; // paranoia - if ( flags == NULL) { + if (flags == NULL) { static int tmp; flags = &tmp; } diff --git a/src/xinerama.h b/src/xinerama.h index 59456e0c..29f4e4e8 100644 --- a/src/xinerama.h +++ b/src/xinerama.h @@ -51,6 +51,8 @@ WArea wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool no WMPoint wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height); +Bool wWindowTouchesHead(WWindow *wwin, int head); + #endif