static void constrainSize (CompWindow *w, XRectangle *slot, XRectangle *rect) { XRectangle workarea; XRectangle r; int cw, ch; getWorkareaForOutput (w->screen, outputDeviceForWindow (w), &workarea); slotToRect (w, slot, &r); if (constrainNewWindowSize (w, r.width, r.height, &cw, &ch)) { /* constrained size may put window offscreen, adjust for that case */ int dx = r.x + cw - workarea.width - workarea.x + w->input.right; int dy = r.y + ch - workarea.height - workarea.y + w->input.bottom; if ( dx > 0 ) r.x -= dx; if ( dy > 0 ) r.y -= dy; r.width = cw; r.height = ch; } *rect = r; }
/* * Buggy */ static Bool smartputAllTrigger (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption) { Window xid; CompWindow *w; CompScreen *s; int grabIndex = 0; xid = getIntOptionNamed (option, nOption, "window", 0); w = findWindowAtDisplay (d, xid); if (w) { s = w->screen; if(otherScreenGrabExist (s, "smartput", 0)) return FALSE; /* * Grab the screen */ grabIndex = pushScreenGrab (s, s->invisibleCursor, "smartput"); if(!grabIndex) return FALSE; CompWindow *window; for (window = s->windows; window; window = window->next) { if(!smartputSameViewport (window,w) ) continue; int width, height; unsigned int mask; XWindowChanges xwc; mask = smartputComputeResize (window, &xwc); if (mask) { if (constrainNewWindowSize (window, xwc.width, xwc.height, &width, &height)) { mask |= CWWidth | CWHeight; xwc.width = width; xwc.height = height; } if (window->mapNum && (mask & (CWWidth | CWHeight))) sendSyncRequest (window); configureXWindow (window, mask, &xwc); } } } if(grabIndex) removeScreenGrab (s,grabIndex, NULL); return TRUE; }
static Bool smartputInitiate (CompWindow *w, CompAction *action, CompActionState state, CompOption *option, int nOption, Bool undo) { CompDisplay *d; if (w) { CompScreen* s = w->screen; SMARTPUT_SCREEN (s); if(otherScreenGrabExist (s, "smartput", 0)) return FALSE; /* * Grab the screen */ if(!sps->grabIndex) sps->grabIndex = pushScreenGrab (s, s->invisibleCursor, "smartput"); if(!sps->grabIndex) return FALSE; int width, height; unsigned int mask; XWindowChanges *xwc; d = s->display; SMARTPUT_WINDOW (w); if(spw->xwc) free(spw->xwc); xwc = malloc(sizeof(XWindowChanges)); if(undo) { if(!(w->id == sps->undoInfo.window) || sps->undoInfo.window == None) return FALSE; mask = smartputUndoResize (s,xwc); } else if(w->id == sps->undoInfo.window && !(sps->undoInfo.window == None) && sps->undoInfo.newX == w->serverX && sps->undoInfo.newY == w->serverY && sps->undoInfo.newWidth == w->serverWidth && sps->undoInfo.newHeight == w->serverHeight && smartputGetUseTriggerkeyForundo (d)) { mask = smartputUndoResize (s,xwc); undo = TRUE; } else { mask = smartputComputeResize (w, xwc); } if (mask) { if (constrainNewWindowSize (w, xwc->width, xwc->height, &width, &height)) { mask |= CWWidth | CWHeight; xwc->width = width; xwc->height = height; } spw->lastX = w->serverX; spw->lastY = w->serverY; spw->targetX = xwc->x; spw->targetY = xwc->y; spw->xwc = xwc; spw->mask = mask; sps->lastWindow = w->id; smartputUpdateUndoInfo (s, w, xwc, undo); spw->animation = TRUE; sps->animation = TRUE; addWindowDamage (w); } } return TRUE; }
static unsigned int groupUpdateResizeRectangle (CompWindow *w, XRectangle *masterGeometry, Bool damage) { XRectangle newGeometry; unsigned int mask = 0; int newWidth, newHeight; int widthDiff, heightDiff; GROUP_WINDOW (w); GROUP_DISPLAY (&display); if (!gw->resizeGeometry || !gd->resizeInfo) return 0; newGeometry.x = WIN_X (w) + (masterGeometry->x - gd->resizeInfo->origGeometry.x); newGeometry.y = WIN_Y (w) + (masterGeometry->y - gd->resizeInfo->origGeometry.y); widthDiff = masterGeometry->width - gd->resizeInfo->origGeometry.width; newGeometry.width = MAX (1, WIN_WIDTH (w) + widthDiff); heightDiff = masterGeometry->height - gd->resizeInfo->origGeometry.height; newGeometry.height = MAX (1, WIN_HEIGHT (w) + heightDiff); if (constrainNewWindowSize (w, newGeometry.width, newGeometry.height, &newWidth, &newHeight)) { newGeometry.width = newWidth; newGeometry.height = newHeight; } if (damage) { if (memcmp (&newGeometry, gw->resizeGeometry, sizeof (newGeometry)) != 0) { addWindowDamage (w); } } if (newGeometry.x != gw->resizeGeometry->x) { gw->resizeGeometry->x = newGeometry.x; mask |= CWX; } if (newGeometry.y != gw->resizeGeometry->y) { gw->resizeGeometry->y = newGeometry.y; mask |= CWY; } if (newGeometry.width != gw->resizeGeometry->width) { gw->resizeGeometry->width = newGeometry.width; mask |= CWWidth; } if (newGeometry.height != gw->resizeGeometry->height) { gw->resizeGeometry->height = newGeometry.height; mask |= CWHeight; } return mask; }