Ejemplo n.º 1
0
Archivo: zoom.c Proyecto: zmike/compiz
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;
}
Ejemplo n.º 2
0
static Bool
shotInitiate (BananaArgument     *arg,
              int                nArg)
{
	CompScreen *s;
	Window     xid;

	BananaValue *root = getArgNamed ("root", arg, nArg);

	if (root != NULL)
		xid = root->i;
	else
		xid = 0;

	s = findScreenAtDisplay (xid);
	if (s)
	{
		SHOT_SCREEN (s);

		if (otherScreenGrabExist (s, "screenshot", NULL))
			return FALSE;

		if (!ss->grabIndex)
			ss->grabIndex = pushScreenGrab (s, None, "screenshot");

		/* start selection screenshot rectangle */

		ss->x1 = ss->x2 = pointerX;
		ss->y1 = ss->y2 = pointerY;

		ss->grab = TRUE;
	}

	return TRUE;
}
Ejemplo n.º 3
0
static Bool
moveInitiate(CompDisplay    *d,
             CompAction     *action,
             CompActionState state,
             CompOption     *option,
             int             nOption)
{
   CompWindow *w;
   Window xid;
   int i, x, y;
   unsigned int ui;
   unsigned int mods = 0;

   MOVE_DISPLAY (d);
   xid = getIntOptionNamed (option, nOption, "window", 0);

   w = findWindowAtDisplay (d, xid);
   if (!w) return FALSE;

   if (otherScreenGrabExist (w->screen, "move", 0))
     return FALSE;

   MOVE_SCREEN (w->screen);

   XQueryPointer (d->display, w->screen->root,
                  &xid, &xid, &x, &y, &i, &i, &ui);

   if (md->w)
     return FALSE;

   lastPointerX = x;
   lastPointerY = y;

   ms->origState = w->state;

   if (!ms->grabIndex)
     ms->grabIndex = pushScreenGrab (w->screen, 0, "move");

   if (ms->grabIndex)
     {
        md->w = w;

        (w->screen->windowGrabNotify)(w, x, y, mods,
                                      CompWindowGrabMoveMask |
                                      CompWindowGrabButtonMask);

        if (md->moveOpacity != OPAQUE)
          addWindowDamage (w);
     }

   return FALSE;
}
Ejemplo n.º 4
0
/*
 * groupGrabScreen
 *
 */
void
groupGrabScreen (CompScreen           *s,
                 GroupScreenGrabState newState)
{
	GROUP_SCREEN (s);

	if ((gs->grabState != newState) && gs->grabIndex)
	{
		removeScreenGrab (s, gs->grabIndex, NULL);
		gs->grabIndex = 0;
	}

	if (newState == ScreenGrabSelect)
	{
		gs->grabIndex = pushScreenGrab (s, None, "group");
	}
	else if (newState == ScreenGrabTabDrag)
	{
		gs->grabIndex = pushScreenGrab (s, None, "group-drag");
	}

	gs->grabState = newState;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
static Bool
waterInitiate (CompDisplay     *d,
	       CompAction      *action,
	       CompActionState state,
	       CompOption      *option,
	       int	       nOption)
{
    CompScreen   *s;
    unsigned int ui;
    Window	 root, child;
    int	         xRoot, yRoot, i;

    for (s = d->screens; s; s = s->next)
    {
	WATER_SCREEN (s);

	if (otherScreenGrabExist (s, "water", NULL))
	    continue;

	if (!ws->grabIndex)
	    ws->grabIndex = pushScreenGrab (s, None, "water");

	if (XQueryPointer (d->display, s->root, &root, &child, &xRoot, &yRoot,
			   &i, &i, &ui))
	{
	    XPoint p;

	    p.x = waterLastPointerX = xRoot;
	    p.y = waterLastPointerY = yRoot;

	    waterVertices (s, GL_POINTS, &p, 1, 0.8f);

	    damageScreen (s);
	}
    }

    if (state & CompActionStateInitButton)
	action->state |= CompActionStateTermButton;

    if (state & CompActionStateInitKey)
	action->state |= CompActionStateTermKey;

    return FALSE;
}
Ejemplo n.º 7
0
Archivo: zoom.c Proyecto: zmike/compiz
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;
}
Ejemplo n.º 8
0
static void
FWHandleIPWMoveInitiate (CompWindow *w)
{
    FREEWINS_WINDOW (w);
    FREEWINS_SCREEN (w->screen);
    FREEWINS_DISPLAY (w->screen->display);

    (*w->screen->activateWindow) (w);
    fww->grab = grabMove;
    fws->rotateCursor = XCreateFontCursor (w->screen->display->display, XC_fleur);
	if(!otherScreenGrabExist(w->screen, "freewins", "move", 0))
	    if(!fws->grabIndex)
        {
        unsigned int mods = 0;
        mods &= CompNoMask;
		fws->grabIndex = pushScreenGrab(w->screen, fws->rotateCursor, "move");
	    (w->screen->windowGrabNotify) (w,  w->attrib.x + (w->width / 2),
                                           w->attrib.y + (w->height / 2), mods,
					                       CompWindowGrabMoveMask |
					                       CompWindowGrabButtonMask);
        }
    fwd->grabWindow = w;
}
Ejemplo n.º 9
0
/*
 * 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;
}
Ejemplo n.º 10
0
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;

}
/* Applies tiling/restoring */
static Bool
applyTiling (CompScreen *s)
{
    CompWindow *w;
    int        count = 0;

    TILE_SCREEN (s);

    if (ts->grabIndex)
	return FALSE;

    for (w = s->windows; w; w = w->next)
    {
	if (isTileWindow (w))
	    count++;
    }

    ts->oneDuration = tileGetAnimationDuration (s->display) / MAX (count, 1);

    if (count > 1)
    {
	int               countX = 0, countY = 0;
	int               currentX = 0, currentY = 0;
	int               winWidth = 0, winHeight = 0;
	int               x = 0, y = 0;
	int               height = 0, occupancy = 0, delta = 0;
	Bool              first = TRUE;
	int               i = 0;
	XRectangle        workArea;
	CompWindowExtents border;

	memset (&border, 0, sizeof (CompWindowExtents));
	/* first get the largest border of the windows on this
	   screen - some of the windows in our list might be
	   maximized now and not be maximized later, so
	   their border information may be inaccurate */
	for (w = s->windows; w; w = w->next)
	{
	    if (w->input.left > border.left)
		border.left = w->input.left;
	    if (w->input.right > border.right)
		border.right = w->input.right;
	    if (w->input.top > border.top)
		border.top = w->input.top;
	    if (w->input.bottom > border.bottom)
		border.bottom = w->input.bottom;
	}

	workArea = s->workArea;

	switch (ts->tileType)
	{
	case TileToggleTypeTile:
	    countX = ceil (sqrt (count));
	    countY = ceil ((float)count / countX);
	    currentX = workArea.x;
	    currentY = workArea.y;
	    winWidth = workArea.width / countX;
	    winHeight = workArea.height / countY;
	    break;
	case TileToggleTypeLeft:
	    height = workArea.height / (count - 1);
	    occupancy = tileGetTileLeftOccupancy (s->display);
	    break;
	case TileToggleTypeTileVertically:
	    winWidth = workArea.width / count;
	    winHeight = workArea.height;
	    y = workArea.y;
	    break;
	case TileToggleTypeTileHorizontally:
	    winWidth = workArea.width;
	    winHeight = workArea.height / count;
	    x = workArea.x;
	    break;
	case TileToggleTypeCascade:
	    delta = tileGetTileDelta (s->display);
	    currentX = workArea.x;
	    currentY = workArea.y;
	    winHeight = workArea.height - delta * (count - 1);
	    winWidth = workArea.width - delta * (count - 1);
	    break;
	default:
	    break;
	}

	for (w = s->windows; w; w = w->next)
	{
	    if (!isTileWindow (w))
		continue;

	    TILE_WINDOW (w);

	    if (!tw->savedValid)
		saveCoords (w);

	    switch (ts->tileType)
	    {
	    case TileToggleTypeTile:
		placeWin(w,
			 currentX + border.left, currentY + border.top,
			 winWidth - (border.left + border.right),
			 winHeight - (border.top + border.bottom));
		tw->isTiled = TRUE;
		break;
	    case TileToggleTypeLeft:
		if (first)
		{
		    x = workArea.x;
		    y = workArea.y;
		    winWidth = workArea.width * occupancy / 100;
		    winHeight = workArea.height;
		    first = FALSE;
		}
		else
		{
		    x = workArea.x + (workArea.width * occupancy / 100);
		    y = workArea.y + (i * height);
		    winWidth = (workArea.width * (100 - occupancy) / 100);
		    winHeight = height;
		}

		placeWin(w,
			 x + border.left, y + border.top,
			 winWidth - (border.left + border.right),
			 winHeight - (border.top + border.bottom));
		tw->isTiled = TRUE;
		break;
	    case TileToggleTypeTileVertically:
		x = workArea.x + (winWidth * i);
		placeWin(w,
			 x + border.left, y + border.top,
			 winWidth - (border.left + border.right),
			 winHeight - (border.top + border.bottom));
		tw->isTiled = TRUE;
		break;
	    case TileToggleTypeTileHorizontally:
		y = workArea.y + (winHeight * i);
		placeWin (w, x + border.left, y + border.top,
			  winWidth - (border.left + border.right),
			  winHeight - (border.top + border.bottom));
		tw->isTiled = TRUE;
		break;
	    case TileToggleTypeCascade:
		placeWin (w,
			  currentX + border.left, currentY + border.top,
			  winWidth - (border.left + border.right),
			  winHeight - (border.top + border.bottom));
		tw->isTiled = TRUE;
		break;
	    default:
		break;
	    }

	    if (ts->tileType == -1 && tw->isTiled)
		{
		    placeWin (w,
			      tw->savedCoords.x, tw->savedCoords.y,
			      tw->savedCoords.width, tw->savedCoords.height);
		    tw->savedValid = FALSE;
		    tw->isTiled = FALSE;
		}

	    i++;
	    tw->animationNum = i;

	    switch (ts->tileType)
	    {
	    case TileToggleTypeTile:
		if (!(i % countX))
		{
		    currentX = workArea.x;
		    currentY += winHeight;
		}
		else
		    currentX += winWidth;
		break;
	    case TileToggleTypeCascade:
		currentX += delta;
		currentY += delta;
	    default:
		break;
	    }
	}

	if (!ts->grabIndex)
	    ts->grabIndex = pushScreenGrab (s, s->invisibleCursor, "tile");

	ts->msResizing = 0;
    }

    return TRUE;
}
Ejemplo n.º 12
0
Archivo: zoom.c Proyecto: zmike/compiz
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 Bool
ringInitiate (CompScreen      *s,
 	      CompAction      *action,
	      CompActionState state,
	      CompOption      *option,
	      int	      nOption)
{
    CompMatch *match;
    int       count; 

    RING_SCREEN (s);

    if (otherScreenGrabExist (s, "ring", NULL))
	return FALSE;
	   
    rs->currentMatch = ringGetWindowMatch (s);

    match = getMatchOptionNamed (option, nOption, "match", NULL);
    if (match)
    {
	matchFini (&rs->match);
	matchInit (&rs->match);
	if (matchCopy (&rs->match, match))
	{
	    matchUpdate (s->display, &rs->match);
	    rs->currentMatch = &rs->match;
	}
    }

    count = ringCountWindows (s);

    if (count < 1)
	return FALSE;

    if (!rs->grabIndex)
    {
	if (ringGetSelectWithMouse (s))
	    rs->grabIndex = pushScreenGrab (s, s->normalCursor, "ring");
	else
	    rs->grabIndex = pushScreenGrab (s, s->invisibleCursor, "ring");
    }

    if (rs->grabIndex)
    {
	rs->state = RingStateOut;

	if (!ringCreateWindowList (s))
	    return FALSE;

	rs->selectedWindow = rs->windows[0];
	ringRenderWindowTitle (s);
	rs->rotTarget = 0;

    	rs->moreAdjust = TRUE;
	damageScreen (s);

	switchActivateEvent (s, TRUE);
    }

    return TRUE;
}