static void getTargetRect (CompWindow *cw, GridType where) { GRID_SCREEN (cw->screen); gs->props = gridProps[where]; DEBUG_PRINT ((gridOut, "\nPressed KP_%i\n", where)); /* get current available area */ getWorkareaForOutput (cw->screen, outputDeviceForWindow(cw), &gs->workarea); DEBUG_RECT (workarea); /* Convention: * xxxSlot include decorations (it's the screen area occupied) * xxxRect are undecorated (it's the constrained position of the contents) */ /* slice and dice to get desired slot - including decorations */ gs->desiredSlot.y = gs->workarea.y + gs->props.gravityDown * (gs->workarea.height / gs->props.numCellsY); gs->desiredSlot.height = gs->workarea.height / gs->props.numCellsY; gs->desiredSlot.x = gs->workarea.x + gs->props.gravityRight * (gs->workarea.width / gs->props.numCellsX); gs->desiredSlot.width = gs->workarea.width / gs->props.numCellsX; DEBUG_RECT (desiredSlot); /* Adjust for constraints and decorations */ constrainSize (cw, &gs->desiredSlot, &gs->desiredRect); DEBUG_RECT (gs->desiredRect); }
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; }
Bool fxShatterInit(CompWindow * w) { CompScreen *s = w->screen; ANIMPLUS_DISPLAY (s->display); ANIMPLUS_WINDOW (w); if (!ad->animAddonFunc->polygonsAnimInit(w)) return FALSE; // CompScreen *s = w->screen; int i,static_polygon; int screen_height = s->outputDev[outputDeviceForWindow(w)].height; ad->animAddonFunc->tessellateIntoGlass( w, animGetI( w, ANIMPLUS_SCREEN_OPTION_SHATTER_NUM_SPOKES), animGetI( w, ANIMPLUS_SCREEN_OPTION_SHATTER_NUM_TIERS), 1); //can't really see how thick it is... PolygonSet *pset = aw->eng->polygonSet; PolygonObject *p = pset->polygons; for (i = 0; i < pset->nPolygons; i++, p++) { p->rotAxis.x = 0; p->rotAxis.y = 0; p->rotAxis.z = 1; static_polygon = 1; p->finalRelPos.x = 0; p->finalRelPos.y = static_polygon * (-p->centerPosStart.y + screen_height); p->finalRelPos.z = 0; if (p->finalRelPos.y) p->finalRotAng = RAND_FLOAT() * 120 * ( RAND_FLOAT() < 0.5 ? -1 : 1 ); } pset->allFadeDuration = 0.4f; pset->backAndSidesFadeDur = 0.2f; pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectivePolygon; aw->com->animTotalTime /= EXPLODE_PERCEIVED_T; aw->com->animRemainingTime = aw->com->animTotalTime; return TRUE; }
static Bool isScaleWin (CompWindow *w) { SCALE_SCREEN (w->screen); if (isNeverScaleWin (w)) return FALSE; if (!ss->type || ss->type == ScaleTypeOutput) { if (!(*w->screen->focusWindow) (w)) return FALSE; } if (w->state & CompWindowStateSkipPagerMask) return FALSE; if (w->state & CompWindowStateShadedMask) return FALSE; if (!w->mapNum || w->attrib.map_state != IsViewable) return FALSE; switch (ss->type) { case ScaleTypeGroup: if (ss->clientLeader != w->clientLeader && ss->clientLeader != w->id) return FALSE; break; case ScaleTypeOutput: if (outputDeviceForWindow(w) != w->screen->currentOutputDev) return FALSE; default: break; } if (!matchEval (ss->currentMatch, w)) return FALSE; return TRUE; }
/* * Calls out to compute the resize. */ static unsigned int smartputComputeResize (CompWindow *w, XWindowChanges *xwc) { CompOutput *output; CompDisplay *d; Region region; unsigned int mask = 0; BOX box; output = &w->screen->outputDev[outputDeviceForWindow (w)]; region = smartputEmptyRegion (w, &output->region); d = w->screen->display; if (!region) return mask; box = smartputFindRect (w, region); /* Find out if the box which is given back by smartputFindRect * has other dimensions than the current window * If it has not, the window will not move and if the users * set it in the options we will try to stack it onto an * underlying window */ if (box.x1 == w->serverX && box.y1 == w->serverY && (box.x2 - box.x1) == w->serverWidth && (box.y2 - box.y1) == w->serverHeight && smartputGetAllowWindowsStack (d)) { box = smartputFindStapleRect(w, region); } else { /* The margin stuff which is set up in the options */ int margin = smartputGetWindowMargin (d); box.x1 = box.x1 + margin; box.x2 = box.x2 - margin; box.y1 = box.y1 + margin; box.y2 = box.y2 - margin; } XDestroyRegion (region); if (box.x1 != w->serverX) mask |= CWX; if (box.y1 != w->serverY) mask |= CWY; if ((box.x2 - box.x1) != w->serverWidth) mask |= CWWidth; if ((box.y2 - box.y1) != w->serverHeight) mask |= CWHeight; xwc->x = box.x1; xwc->y = box.y1; xwc->width = box.x2 - box.x1; xwc->height = box.y2 - box.y1; return mask; }
static Bool scaleaddonPullWindow(CompDisplay * d, CompAction * action, CompActionState state, CompOption * option, int nOption) { CompScreen *s; Window xid; xid = getIntOptionNamed(option, nOption, "root", 0); s = findScreenAtDisplay(d, xid); if (s) { CompWindow *w; SCALE_SCREEN(s); ADDON_DISPLAY(d); if (!ss->grabIndex) return FALSE; w = findWindowAtDisplay(d, ad->highlightedWindow); if (w) { int x, y, vx, vy; defaultViewportForWindow(w, &vx, &vy); x = w->attrib.x + (s->x - vx) * s->width; y = w->attrib.y + (s->y - vy) * s->height; if (scaleaddonGetConstrainPullToScreen(s)) { XRectangle workArea; CompWindowExtents extents; getWorkareaForOutput(s, outputDeviceForWindow(w), &workArea); extents.left = x - w->input.left; extents.right = x + w->width + w->input.right; extents.top = y - w->input.top; extents.bottom = y + w->height + w->input.bottom; if (extents.left < workArea.x) x += workArea.x - extents.left; else if (extents.right > workArea.x + workArea.width) x += workArea.x + workArea.width - extents.right; if (extents.top < workArea.y) y += workArea.y - extents.top; else if (extents.bottom > workArea.y + workArea.height) y += workArea.y + workArea.height - extents.bottom; } if (x != w->attrib.x || y != w->attrib.y) { SCALE_WINDOW(w); moveWindowToViewportPosition(w, x, y, TRUE); /* Select this window when ending scale */ (*ss->selectWindow) (w); /* stop scaled window dissapearing */ sw->tx -= (s->x - vx) * s->width; sw->ty -= (s->y - vy) * s->height; if (scaleaddonGetExitAfterPull(s)) { int opt; CompAction *action2; CompOption o[1]; SCALE_DISPLAY(d); opt = SCALE_DISPLAY_OPTION_INITIATE_KEY; action2 = &sd->opt[opt].value.action; o[0].type = CompOptionTypeInt; o[0].name = "root"; o[0].value.i = s->root; if (action2->terminate) (*action2->terminate) (d, action, 0, o, 1); } else { /* provide a simple animation */ addWindowDamage(w); sw->tx -= (sw->slot->x2 - sw->slot->x1) / 20; sw->ty -= (sw->slot->y2 - sw->slot->y1) / 20; sw->scale *= 1.1f; sw->adjust = TRUE; ss->state = SCALE_STATE_OUT; addWindowDamage(w); } return TRUE; } } } return FALSE; }
static Bool gridPlaceWindow (Window xid, GridType where) { CompWindow *w; w = findWindowAtDisplay (xid); if (w) { XRectangle workarea; XRectangle desiredSlot; XRectangle desiredRect; XRectangle currentRect; GridProps props = gridProps[where]; XWindowChanges xwc; /* get current available area */ getWorkareaForOutput (w->screen, outputDeviceForWindow(w), &workarea); /* Convention: * xxxSlot include decorations (it's the screen area occupied) * xxxRect are undecorated (it's the constrained position of the contents) */ /* slice and dice to get desired slot - including decorations */ desiredSlot.y = workarea.y + props.gravityDown * (workarea.height / props.numCellsY); desiredSlot.height = workarea.height / props.numCellsY; desiredSlot.x = workarea.x + props.gravityRight * (workarea.width / props.numCellsX); desiredSlot.width = workarea.width / props.numCellsX; /* Adjust for constraints and decorations */ constrainSize (w, &desiredSlot, &desiredRect); /* Get current rect not including decorations */ currentRect.x = w->serverX; currentRect.y = w->serverY; currentRect.width = w->serverWidth; currentRect.height = w->serverHeight; if (desiredRect.y == currentRect.y && desiredRect.height == currentRect.height) { int slotWidth33 = workarea.width / 3; int slotWidth66 = workarea.width - slotWidth33; if (props.numCellsX == 2) /* keys (1, 4, 7, 3, 6, 9) */ { if (currentRect.width == desiredRect.width && currentRect.x == desiredRect.x) { desiredSlot.width = slotWidth66; desiredSlot.x = workarea.x + props.gravityRight * slotWidth33; } else { /* tricky, have to allow for window constraints when * computing what the 33% and 66% offsets would be */ XRectangle rect33, rect66, slot33, slot66; slot33 = desiredSlot; slot33.x = workarea.x + props.gravityRight * slotWidth66; slot33.width = slotWidth33; constrainSize (w, &slot33, &rect33); slot66 = desiredSlot; slot66.x = workarea.x + props.gravityRight * slotWidth33; slot66.width = slotWidth66; constrainSize (w, &slot66, &rect66); if (currentRect.width == rect66.width && currentRect.x == rect66.x) { desiredSlot.width = slotWidth33; desiredSlot.x = workarea.x + props.gravityRight * slotWidth66; } } } else /* keys (2, 5, 8) */ { if (currentRect.width == desiredRect.width && currentRect.x == desiredRect.x) { desiredSlot.width = slotWidth33; desiredSlot.x = workarea.x + slotWidth33; } } constrainSize (w, &desiredSlot, &desiredRect); } xwc.x = desiredRect.x; xwc.y = desiredRect.y; xwc.width = desiredRect.width; xwc.height = desiredRect.height; if (w->mapNum) sendSyncRequest (w); if (w->state & MAXIMIZE_STATE) { /* maximized state interferes with us, clear it */ maximizeWindow (w, 0); } /* TODO: animate move+resize */ configureXWindow (w, CWX | CWY | CWWidth | CWHeight, &xwc); } return TRUE; }