static Bool zoomIn(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) { float w, h, x0, y0; int output; ZoomBox box; ZOOM_SCREEN(s); output = outputDeviceForPoint(s, pointerX, pointerY); if (!zs->grabIndex) zs->grabIndex = pushScreenGrab(s, None, "zoom"); if (zs->zoomed & (1 << output)) { zoomGetCurrentZoom(s, output, &box); } else { box.x1 = s->outputDev[output].region.extents.x1; box.y1 = s->outputDev[output].region.extents.y1; box.x2 = s->outputDev[output].region.extents.x2; box.y2 = s->outputDev[output].region.extents.y2; } w = (box.x2 - box.x1) / zs->opt[ZOOM_SCREEN_OPTION_ZOOM_FACTOR].value.f; h = (box.y2 - box.y1) / zs->opt[ZOOM_SCREEN_OPTION_ZOOM_FACTOR].value.f; x0 = (pointerX - s->outputDev[output].region.extents.x1) / (float) s->outputDev[output].width; y0 = (pointerY - s->outputDev[output].region.extents.y1) / (float) s->outputDev[output].height; zs->x1 = box.x1 + (x0 * (box.x2 - box.x1) - x0 * w + 0.5f); zs->y1 = box.y1 + (y0 * (box.y2 - box.y1) - y0 * h + 0.5f); zs->x2 = zs->x1 + w; zs->y2 = zs->y1 + h; zoomInitiateForSelection(s, output); return TRUE; } return FALSE; }
static Bool cloneTerminate(CompDisplay * d, CompAction * action, CompActionState state, CompOption * option, int nOption) { CompScreen *s; Window xid; xid = getIntOptionNamed(option, nOption, "root", 0); for (s = d->screens; s; s = s->next) { CLONE_SCREEN(s); if (xid && s->root != xid) continue; if (cs->grabIndex) { int x, y; removeScreenGrab(s, cs->grabIndex, NULL); cs->grabIndex = 0; x = getIntOptionNamed(option, nOption, "x", 0); y = getIntOptionNamed(option, nOption, "y", 0); cs->dst = outputDeviceForPoint(s, x, y); damageScreen(s); } } action->state &= ~(CompActionStateTermKey | CompActionStateTermButton); return FALSE; }
static Bool zoomTerminate(CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption) { CompScreen *s; Window xid; xid = getIntOptionNamed(option, nOption, "root", 0); for (s = d->screens; s; s = s->next) { ZOOM_SCREEN(s); if (xid && s->root != xid) continue; if (zs->grab) { int output; output = outputDeviceForPoint(s, zs->x1, zs->y1); if (zs->x2 > s->outputDev[output].region.extents.x2) zs->x2 = s->outputDev[output].region.extents.x2; if (zs->y2 > s->outputDev[output].region.extents.y2) zs->y2 = s->outputDev[output].region.extents.y2; zoomInitiateForSelection(s, output); zs->grab = FALSE; } else { CompOption o; o.type = CompOptionTypeInt; o.name = "root"; o.value.i = s->root; zoomOut(d, action, state, &o, 1); } } action->state &= ~(CompActionStateTermKey | CompActionStateTermButton); return FALSE; }
static Bool cloneInitiate(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) { int i; CLONE_SCREEN(s); if (cs->grab || otherScreenGrabExist(s, "clone", NULL)) return FALSE; if (!cs->grabIndex) cs->grabIndex = pushScreenGrab(s, None, "clone"); cs->grab = TRUE; cs->x = getIntOptionNamed(option, nOption, "x", 0); cs->y = getIntOptionNamed(option, nOption, "y", 0); cs->src = cs->grabbedOutput = outputDeviceForPoint(s, cs->x, cs->y); /* trace source */ i = 0; while (i < cs->nClone) { if (cs->clone[i].dst == cs->src) { cs->src = cs->clone[i].src; i = 0; } else { i++; } } if (state & CompActionStateInitButton) action->state |= CompActionStateTermButton; } return FALSE; }
static Bool zoomOut(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) { int output; ZOOM_SCREEN(s); output = outputDeviceForPoint(s, pointerX, pointerY); zoomGetCurrentZoom(s, output, &zs->last[output]); zs->current[output].x1 = s->outputDev[output].region.extents.x1; zs->current[output].y1 = s->outputDev[output].region.extents.y1; zs->current[output].x2 = s->outputDev[output].region.extents.x2; zs->current[output].y2 = s->outputDev[output].region.extents.y2; zs->zoomOutput = output; zs->scale = 0.0f; zs->adjust = TRUE; zs->grab = FALSE; if (zs->grabIndex) { removeScreenGrab(s, zs->grabIndex, NULL); zs->grabIndex = 0; } damageScreen(s); return TRUE; } return FALSE; }
static Bool zoomInitiatePan(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) { int output; ZOOM_SCREEN(s); output = outputDeviceForPoint(s, pointerX, pointerY); if (!(zs->zoomed & (1 << output))) return FALSE; if (otherScreenGrabExist(s, "zoom", NULL)) return FALSE; if (state & CompActionStateInitButton) action->state |= CompActionStateTermButton; if (!zs->panGrabIndex) zs->panGrabIndex = pushScreenGrab(s, zs->panCursor, "zoom-pan"); zs->zoomOutput = output; return TRUE; } return FALSE; }
static Bool scaleaddonZoomWindow(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) { SCALE_WINDOW(w); ADDON_WINDOW(w); XRectangle outputRect; BOX outputBox; int head; if (!sw->slot) return FALSE; head = outputDeviceForPoint(s, sw->slot->x1, sw->slot->y1); outputBox = w->screen->outputDev[head].region.extents; outputRect.x = outputBox.x1; outputRect.y = outputBox.y1; outputRect.width = outputBox.x2 - outputBox.x1; outputRect.height = outputBox.y2 - outputBox.y1; /* damage old rect */ addWindowDamage(w); if (!aw->rescaled) { aw->oldAbove = w->next; raiseWindow(w); /* backup old values */ aw->origSlot = *sw->slot; aw->rescaled = TRUE; sw->slot->x1 = (outputRect.width / 2) - (WIN_W(w) / 2) + w->input.left + outputRect.x; sw->slot->y1 = (outputRect.height / 2) - (WIN_H(w) / 2) + w->input.top + outputRect.y; sw->slot->x2 = sw->slot->x1 + WIN_W(w); sw->slot->y2 = sw->slot->y1 + WIN_H(w); sw->slot->scale = 1.0f; } else { if (aw->oldAbove) restackWindowBelow(w, aw->oldAbove); aw->rescaled = FALSE; *(sw->slot) = aw->origSlot; } sw->adjust = TRUE; ss->state = SCALE_STATE_OUT; /* slot size may have changed, so * update window title */ scaleaddonRenderWindowTitle(w); addWindowDamage(w); return TRUE; } } return FALSE; }
static Bool zoomInitiate(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) { int output, x1, y1; float scale; ZOOM_SCREEN(s); if (otherScreenGrabExist(s, "zoom", NULL)) return FALSE; if (!zs->grabIndex) zs->grabIndex = pushScreenGrab(s, None, "zoom"); if (state & CompActionStateInitButton) action->state |= CompActionStateTermButton; /* start selection zoom rectangle */ output = outputDeviceForPoint(s, pointerX, pointerY); if (zs->zoomed & (1 << output)) { ZoomBox box; float oWidth; zoomGetCurrentZoom(s, output, &box); oWidth = s->outputDev[output].width; scale = oWidth / (box.x2 - box.x1); x1 = box.x1; y1 = box.y1; } else { scale = 1.0f; x1 = s->outputDev[output].region.extents.x1; y1 = s->outputDev[output].region.extents.y1; } zs->x1 = zs->x2 = x1 + ((pointerX - s->outputDev[output].region.extents.x1) / scale + 0.5f); zs->y1 = zs->y2 = y1 + ((pointerY - s->outputDev[output].region.extents.y1) / scale + 0.5f); zs->zoomOutput = output; zs->grab = TRUE; damageScreen(s); return TRUE; } return FALSE; }
static void thumbUpdateThumbnail (CompScreen *s) { int igMidPoint[2], tMidPoint[2]; int tPos[2], tmpPos[2]; float distance = 1000000; int off, oDev, tHeight; int ox1, oy1, ox2, oy2, ow, oh; const BananaValue * option_thumb_size = bananaGetOption (bananaIndex, "thumb_size", s->screenNum); float maxSize = option_thumb_size->i; double scale = 1.0; CompWindow *w; THUMB_SCREEN (s); if (ts->thumb.win == ts->pointedWin) return; if (ts->thumb.opacity > 0.0 && ts->oldThumb.opacity > 0.0) return; if (ts->thumb.win) damageThumbRegion (s, &ts->thumb); freeThumbText (s, &ts->oldThumb); ts->oldThumb = ts->thumb; ts->thumb.textData = NULL; ts->thumb.win = ts->pointedWin; ts->thumb.dock = ts->dock; if (!ts->thumb.win || !ts->dock) { ts->thumb.win = NULL; ts->thumb.dock = NULL; return; } w = ts->thumb.win; /* do we nee to scale the window down? */ if (WIN_W (w) > maxSize || WIN_H (w) > maxSize) { if (WIN_W (w) >= WIN_H (w)) scale = maxSize / WIN_W (w); else scale = maxSize / WIN_H (w); } ts->thumb.width = WIN_W (w)* scale; ts->thumb.height = WIN_H (w) * scale; ts->thumb.scale = scale; const BananaValue * option_title_enabled = bananaGetOption (bananaIndex, "title_enabled", s->screenNum); if (option_title_enabled->b) renderThumbText (s, &ts->thumb, FALSE); else freeThumbText (s, &ts->thumb); igMidPoint[0] = w->iconGeometry.x + (w->iconGeometry.width / 2); igMidPoint[1] = w->iconGeometry.y + (w->iconGeometry.height / 2); const BananaValue * option_border = bananaGetOption (bananaIndex, "border", s->screenNum); off = option_border->i; oDev = outputDeviceForPoint (s, w->iconGeometry.x + (w->iconGeometry.width / 2), w->iconGeometry.y + (w->iconGeometry.height / 2)); if (s->nOutputDev == 1 || oDev > s->nOutputDev) { ox1 = 0; oy1 = 0; ox2 = s->width; oy2 = s->height; ow = s->width; oh = s->height; } else { ox1 = s->outputDev[oDev].region.extents.x1; ox2 = s->outputDev[oDev].region.extents.x2; oy1 = s->outputDev[oDev].region.extents.y1; oy2 = s->outputDev[oDev].region.extents.y2; ow = ox2 - ox1; oh = oy2 - oy1; } tHeight = ts->thumb.height; if (ts->thumb.textData) tHeight += ts->thumb.textData->height + TEXT_DISTANCE; // failsave position tPos[0] = igMidPoint[0] - (ts->thumb.width / 2.0); if (w->iconGeometry.y - tHeight >= 0) tPos[1] = w->iconGeometry.y - tHeight; else tPos[1] = w->iconGeometry.y + w->iconGeometry.height; // above tmpPos[0] = igMidPoint[0] - (ts->thumb.width / 2.0); if (tmpPos[0] - off < ox1) tmpPos[0] = ox1 + off; if (tmpPos[0] + off + ts->thumb.width > ox2) { if (ts->thumb.width + (2 * off) <= ow) tmpPos[0] = ox2 - ts->thumb.width - off; else tmpPos[0] = ox1 + off; } tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); tmpPos[1] = WIN_Y (ts->dock) - tHeight - off; tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); if (tmpPos[1] > oy1) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // below tmpPos[1] = WIN_Y (ts->dock) + WIN_H (ts->dock) + off; tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); if (tmpPos[1] + tHeight + off < oy2 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // left tmpPos[1] = igMidPoint[1] - (tHeight / 2.0); if (tmpPos[1] - off < oy1) tmpPos[1] = oy1 + off; if (tmpPos[1] + off + tHeight > oy2) { if (tHeight + (2 * off) <= oh) tmpPos[1] = oy2 - ts->thumb.height - off; else tmpPos[1] = oy1 + off; } tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); tmpPos[0] = WIN_X (ts->dock) - ts->thumb.width - off; tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); if (tmpPos[0] > ox1 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // right tmpPos[0] = WIN_X (ts->dock) + WIN_W (ts->dock) + off; tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); if (tmpPos[0] + ts->thumb.width + off < ox2 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } ts->thumb.x = tPos[0]; ts->thumb.y = tPos[1]; ts->thumb.offset = off; ts->thumb.opacity = 0.0; damageThumbRegion (s, &ts->thumb); }