Пример #1
0
static bool
waterTitleWave (CompAction         *action,
		CompAction::State  state,
		CompOption::Vector &options)
{
    CompWindow *w;
    int	       xid;

    WATER_SCREEN (screen);

    xid = CompOption::getIntOptionNamed (options, "window",
					 screen->activeWindow ());

    w = screen->findWindow (xid);
    if (w)
    {
	const CompWindow::Geometry &g = w->geometry ();
	XPoint p[2];

	p[0].x = g.x () - w->border ().left;
	p[0].y = g.y () - w->border ().top / 2;

	p[1].x = g.x () + g.width () + w->border ().right;
	p[1].y = p[0].y;

	ws->waterVertices (GL_LINES, p, 2, 0.15f);

	ws->cScreen->damageScreen ();
    }

    return false;
}
Пример #2
0
void
WallScreen::releaseMoveWindow ()
{
    CompWindow *window;

    window = screen->findWindow (moveWindow);
    if (window)
	window->syncPosition ();

    moveWindow = 0;
}
Пример #3
0
bool
CompText::renderWindowTitle (Window               window,
		             bool                 withViewportNumber,
		             const CompText::Attrib &attrib)
{
    CompString text;

    TEXT_SCREEN (screen);

    if (!ts)
	return false;

    if (withViewportNumber)
    {
	CompString title;
    	CompPoint  winViewport;
	CompSize   viewportSize;

	title = ts->getWindowName (window);
	if (!title.empty ())
	{
	    CompWindow *w;

	    w = screen->findWindow (window);
	    if (w)
	    {
		int viewport;

		winViewport  = w->defaultViewport ();
		viewportSize = screen->vpSize ();
		viewport = winViewport.y () * viewportSize.width () +
		           winViewport.x () + 1;
		text = compPrintf ("%s -[%d]-", title.c_str (), viewport);
	    }
	    else
	    {
		text = title;
	    }
	}
    }
    else
    {
	text = ts->getWindowName (window);
    }

    if (text.empty ())
	return false;

    return renderText (text, attrib);
}
Пример #4
0
bool
KeyboardNavigation::initiate (CompAction         *action,
                              CompAction::State  state,
                              CompOption::Vector &option,
                              FocusDirection     direction)
{
    CompWindow *window = screen->findWindow( screen->activeWindow() );

    if (window) {
        /* Don't allow focus change for certain special windows */
        if (window->overrideRedirect() ||
            (window->type() & (CompWindowTypeDesktopMask |
                               CompWindowTypeDockMask)))
        {
            return false;
        }

        DEBUG_LOG("Initiating search for nearest window: " << direction);

        NearestWindow nearestWindow (window, direction);

        screen->forEachWindow( boost::bind(
                &KeyboardNavigation::NearestWindow::inspectWindow,
                &nearestWindow, _1
                ) );

        CompWindow *focusWindow = nearestWindow.result();

        if (focusWindow != NULL) {
            DEBUG_LOG("Found focusWindow: " << focusWindow->id() << " " <<
                      focusWindow->x() << "x" << focusWindow->y());

            focusWindow->moveInputFocusTo();
            focusWindow->activate();

            return true;
        }
        else {
            DEBUG_LOG("Unable to find focus window!");
        }
    }

    return false;
}
Пример #5
0
bool 
RotateScreen::rotateWithWindow (CompAction         *action,
				CompAction::State  state,
				CompOption::Vector &options,
				int                direction)
{
    if (screen->vpSize ().width () < 2 ||
	!direction)
	return false;

    Window xid = CompOption::getIntOptionNamed (options, "window");

    if (mMoveWindow != xid)
    {
	releaseMoveWindow ();

	if (!mGrabIndex && !mMoving)
	{
	    CompWindow *w = screen->findWindow (xid);

	if (w									    &&
	    !(w->type () & (CompWindowTypeDesktopMask | CompWindowTypeDockMask))    &&
	    !(w->state () & CompWindowStateStickyMask))
	    {
		mMoveWindow  = w->id ();
		mMoveWindowX = w->x ();

		if (optionGetRaiseOnRotate ())
		    w->raise ();
	    }
	}
    }

    if (!mGrabIndex)
    {
	CompOption::Vector o (0);

	o.push_back (CompOption ("root", CompOption::TypeInt));
	o.push_back (CompOption ("x", CompOption::TypeInt));
	o.push_back (CompOption ("y", CompOption::TypeInt));
	
	o[0].value ().set ((int) screen->root ());
	o[1].value ().set (CompOption::getIntOptionNamed (options, "x", 0));
	o[2].value ().set (CompOption::getIntOptionNamed (options, "y", 0));
	
	initiate (NULL, 0, o);
    }

    if (mGrabIndex)
    {
	mMoving  = true;
	mMoveTo += 360.0f / screen->vpSize ().width () * direction;
	mGrabbed = false;

	cScreen->damageScreen ();
    }

    return false;
}
Пример #6
0
bool
StackDebugger::checkSanity (CompWindowList &serverWindows, bool verbose)
{
    int current = 0xffffffff;
    int oldCurrent = current;
    bool err = false;

    if (verbose)
	compLogMessage ("stackdebugger", CompLogLevelDebug, "processing new stack --------");

    /* go backwards down the stack */
    for (CompWindowList::reverse_iterator rit = serverWindows.rbegin ();
	 rit != serverWindows.rend (); ++rit)
    {
	CompWindow *w = (*rit);

	/* Override redirect windows set all kinds
	 * of crazy stuff and are required to stack
	 * themselves so skip those */
	if (w->overrideRedirect ())
	    continue;

	/* ignore non-override redirect unmanaged windows */
	if (!w->managed ())
	    continue;

	/* ignore any windows that just got created */
	if (!w->mapNum ())
	    continue;

	/* determine the current layer */
	if (w->type () == CompWindowTypeDockMask)
	{
	    if ((current & DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			   DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	    {
		bool fullscreenWindow = false;

		/* search down the stack to check if there is a fullscreen
		 * window, otherwise we are not on the fullscreen layer */
		for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		{
		    if (rw->type () & CompWindowTypeFullscreenMask)
		    {
			fullscreenWindow = true;
			break;
		    }
		}

		/* if there is no fullscreen window, change the layer */
		if (!fullscreenWindow)
		    err |= setCurrentLayer (w->id (), DOCKS, current);
		else
		    err |= setCurrentLayer (w->id (), DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN, current);
	    }
	    else if (w->state () & CompWindowStateBelowMask)
		err |= setCurrentLayer (w->id (), DOCKS_BELOW, current);
	    else
		err |= setCurrentLayer (w->id (), DOCKS, current);
	}
	else if (w->type () == CompWindowTypeFullscreenMask)
	{
	    err |= setCurrentLayer (w->id (), FULLSCREEN, current);
	}
	else if (w->type () == CompWindowTypeDesktopMask)
	{
	    err |= setCurrentLayer (w->id (), DESKTOP, current);
	}
	/* everything else that is not a fullscreen window or a desktop */
	else
	{
	    if (w->state () & CompWindowStateAboveMask)
	    {
		if ((current & KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			       KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
		{
		    bool fullscreenWindow = false;

		    /* search down the stack to check if there is a fullscreen
		     * window, otherwise we are not on the fullscreen layer */
		    for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		    {
			if (rw->type () & CompWindowTypeFullscreenMask)
			{
			    fullscreenWindow = true;
			    break;
			}
		    }

		    if (!fullscreenWindow)
			err |= setCurrentLayer (w->id (), KEEP_ABOVE, current);
		    else
			err |= setCurrentLayer (w->id (), KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN, current);
		}
		else
		    err |= setCurrentLayer (w->id (), KEEP_ABOVE, current);
	    }
	    else if (w->state () & CompWindowStateBelowMask)
		err |= setCurrentLayer (w->id (), KEEP_BELOW, current);
	    else
	    {
		if ((current & TOPLEVELS_ABOVE_FULLSCREEN) ==
			       TOPLEVELS_ABOVE_FULLSCREEN)
		{
		    bool fullscreenWindow = false;

		    /* search down the stack to check if there is a fullscreen
		     * window, otherwise we are not on the fullscreen layer */
		    for (CompWindow *rw = w->prev; rw; rw = rw->prev)
		    {
			if (rw->type () & CompWindowTypeFullscreenMask)
			{
			    fullscreenWindow = true;
			    break;
			}
		    }

		    if (!fullscreenWindow)
			err |= setCurrentLayer (w->id (), TOPLEVELS, current);
		    else
			err |= setCurrentLayer (w->id (), TOPLEVELS_ABOVE_FULLSCREEN, current);
		}
		else
		    err |= setCurrentLayer (w->id (), TOPLEVELS, current);
	    }
	}

	if ((current & DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
		       DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN) ==
			    KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_ABOVE_TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & TOPLEVELS_ABOVE_FULLSCREEN) == TOPLEVELS_ABOVE_FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer TOPLEVELS_ABOVE_FULLSCREEN");
	}
	else if ((current & FULLSCREEN) == FULLSCREEN)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer FULLSCREEN");
	}
	else if ((current & DOCKS) == DOCKS)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS");
	}
	else if ((current & KEEP_ABOVE) == KEEP_ABOVE)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_ABOVE");
	}
	else if ((current & TOPLEVELS) == TOPLEVELS)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer TOPLEVELS");
	}
	else if ((current & DOCKS_BELOW) == DOCKS_BELOW)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DOCKS_BELOW");
	}
	else if ((current & KEEP_BELOW) == KEEP_BELOW)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer KEEP_BELOW");
	}
	else if ((current & DESKTOP) == DESKTOP)
	{
	    if (verbose && current != oldCurrent)
		compLogMessage ("stackdebugger", CompLogLevelDebug, "on layer DESKTOP");
	}

	oldCurrent = current;
    }

    return err;
}
Пример #7
0
/* This function currently always performs occlusion detection to
   minimize paint regions. OpenGL precision requirements are no good
   enough to guarantee that the results from using occlusion detection
   is the same as without. It's likely not possible to see any
   difference with most hardware but occlusion detection in the
   transformed screen case should be made optional for those who do
   see a difference. */
void
PrivateGLScreen::paintOutputRegion (const GLMatrix   &transform,
				    const CompRegion &region,
				    CompOutput       *output,
				    unsigned int     mask)
{
    CompRegion    tmpRegion (region);
    CompWindow    *w;
    GLWindow      *gw;
    int           windowMask, odMask;
    bool          status, unredirectFS;
    bool          withOffset = false;
    GLMatrix      vTransform;
    CompPoint     offXY;
    std::set<CompWindow*> unredirected;

    CompWindowList                   pl;
    CompWindowList::reverse_iterator rit;

    unredirectFS = CompositeScreen::get (screen)->
	getOption ("unredirect_fullscreen_windows")->value ().b ();

    const CompMatch &unredirectable = CompositeScreen::get (screen)->
	getOption ("unredirect_match")->value ().match ();

    const CompString &blacklist =
	getOption ("unredirect_driver_blacklist")->value ().s ();

    bool blacklisted = driverIsBlacklisted (blacklist.c_str ());

    if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
    {
	windowMask     = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
    }
    else
    {
	windowMask     = 0;
    }

    /*
     * We need to COPY the PaintList for now because there seem to be some
     * odd cases where the master list might change during the below loops.
     * (LP: #958540)
     */
    pl = cScreen->getWindowPaintList ();

    if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
    {
	FullscreenRegion fs (*output, screen->region ());

	/* detect occlusions */
	for (rit = pl.rbegin (); rit != pl.rend (); ++rit)
	{
	    w = (*rit);
	    gw = GLWindow::get (w);

	    if (w->destroyed ())
		continue;

	    if (!w->shaded ())
	    {
		/* Non-damaged windows don't have valid pixmap
		 * contents and we aren't displaying them yet
		 * so don't factor them into occlusion detection */
		if (!gw->priv->cWindow->damaged ())
		{
		    gw->priv->clip = region;
		    continue;
		}
		if (!w->isViewable ())
		    continue;
	    }

	    /* copy region */
	    gw->priv->clip = tmpRegion;

	    odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;

	    if ((cScreen->windowPaintOffset ().x () != 0 ||
		 cScreen->windowPaintOffset ().y () != 0) &&
		!w->onAllViewports ())
	    {
		withOffset = true;

		offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

		vTransform = transform;
		vTransform.translate (offXY.x (), offXY.y (), 0);

		gw->priv->clip.translate (-offXY.x (), -offXY. y ());

		odMask |= PAINT_WINDOW_WITH_OFFSET_MASK;
		status = gw->glPaint (gw->paintAttrib (), vTransform,
				      tmpRegion, odMask);
	    }
	    else
	    {
		withOffset = false;
		status = gw->glPaint (gw->paintAttrib (), transform, tmpRegion,
				      odMask);
	    }

	    if (status)
	    {
		if (withOffset)
		{
		    tmpRegion -= w->region ().translated (offXY);
		}
		else
		    tmpRegion -= w->region ();
	    }

	    FullscreenRegion::WinFlags flags = 0;
	    if (w->type () & CompWindowTypeDesktopMask)
	        flags |= FullscreenRegion::Desktop;
	    if (w->alpha ())
		flags |= FullscreenRegion::Alpha;
	    
	    /* Anything which was not occlusion detected is not a suitable
	     * candidate for unredirection either */
	    if (!status)
		flags |= FullscreenRegion::NoOcclusionDetection;

	    CompositeWindow *cw = CompositeWindow::get (w);

	    /*
	     * Windows with alpha channels can partially occlude windows
	     * beneath them and so neither should be unredirected in that case.
	     *
	     * Performance note:  unredirectable.evaluate is SLOW because it
	     * involves regex matching. Too slow to do on every window for
	     * every frame. So we only call it if a window is redirected AND
	     * potentially needs unredirecting. This means changes to
	     * unredirect_match while a window is unredirected already may not
	     * take effect until it is un-fullscreened again. But that's better
	     * than the high price of regex matching on every frame.
	     */
	    if (unredirectFS &&
		!blacklisted &&
		!(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
		!(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
		fs.isCoveredBy (w->region (), flags) &&
		(!cw->redirected () || unredirectable.evaluate (w)))
	    {
		unredirected.insert (w);
	    }
	    else
	    {
		if (!cw->redirected ())
		{
		    if (fs.allowRedirection (w->region ()))
		    {
			// 1. GLWindow::release to force gw->priv->needsRebind
			gw->release ();

			// 2. GLWindow::bind, which redirects the window,
			//    rebinds the pixmap, and then rebinds the pixmap
			//    to a texture.
			gw->bind ();

			// 3. Your window is now redirected again with the
			//    latest pixmap contents.
		    }
		    else
		    {
			unredirected.insert (w);
		    }
		}
	    }
	}
    }

    /* Unredirect any redirected fullscreen windows */
    foreach (CompWindow *fullscreenWindow, unredirected)
	CompositeWindow::get (fullscreenWindow)->unredirect ();

    if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
	paintBackground (transform,
	                 tmpRegion,
	                 (mask & PAINT_SCREEN_TRANSFORMED_MASK));

    /* paint all windows from bottom to top */
    foreach (w, pl)
    {
	if (w->destroyed ())
	    continue;

        gw = GLWindow::get (w);

        /* Release any queued ConfigureWindow requests now */
	gw->priv->configureLock->release ();

	if (unredirected.find (w) != unredirected.end ())
	    continue;

	if (!w->shaded ())
	{
	    if (!w->isViewable ())
		continue;
	}

	const CompRegion &clip =
	    (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
	    gw->clip () : region;

	if ((cScreen->windowPaintOffset ().x () != 0 ||
	     cScreen->windowPaintOffset ().y () != 0) &&
	    !w->onAllViewports ())
	{
	    offXY = w->getMovementForOffset (cScreen->windowPaintOffset ());

	    vTransform = transform;
	    vTransform.translate (offXY.x (), offXY.y (), 0);
	    gw->glPaint (gw->paintAttrib (), vTransform, clip,
		         windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
	}
	else
	{
	    gw->glPaint (gw->paintAttrib (), transform, clip, windowMask);
	}
    }
}
Пример #8
0
bool
WallScreen::moveViewport (int    x,
			  int    y,
			  Window moveWin)
{
    CompOption::Vector o(0);

    if (!x && !y)
	return false;

    if (screen->otherGrabExist ("move", "switcher", "group-drag", "wall", 0))
	return false;

    if (!checkDestination (x, y))
	return false;

    if (moveWindow != moveWin)
    {
	CompWindow *w;

	releaseMoveWindow ();
	w = screen->findWindow (moveWin);
	if (w)
	{
	    if (!(w->type () & (CompWindowTypeDesktopMask |
				CompWindowTypeDockMask)))
	    {
		if (!(w->state () & CompWindowStateStickyMask))
		{
		    moveWindow = w->id ();
		    moveWindowX = w->x ();
		    moveWindowY = w->y ();
		    w->raise ();
		}
	    }
	}
    }

    if (!moving)
    {
	curPosX = screen->vp ().x ();
	curPosY = screen->vp ().y ();
    }
    gotoX = screen->vp ().x () - x;
    gotoY = screen->vp ().y () - y;

    determineMovementAngle ();

    screen->handleCompizEvent ("wall", "start_viewport_switch", o);

    if (!grabIndex)
	grabIndex = screen->pushGrab (screen->invisibleCursor (), "wall");

    screen->moveViewport (x, y, true);

    moving          = true;
    focusDefault    = true;
    boxOutputDevice = screen->outputDeviceForPoint (pointerX, pointerY);

    if (optionGetShowSwitcher ())
	boxTimeout = optionGetPreviewTimeout () * 1000;
    else
	boxTimeout = 0;

    timer = optionGetSlideDuration () * 1000;

    cScreen->damageScreen ();

    return true;
}
Пример #9
0
void 
RotateScreen::preparePaint (int msSinceLastPaint)
{
    float oldXrot = mXrot + mBaseXrot;

    if (mGrabIndex || mMoving)
    {
	float amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
	int   steps  = amount / (0.5f * optionGetTimestep ());

	if (!steps)
	    steps = 1;

	float chunk  = amount / (float) steps;

	while (steps--)
	{
	    mXrot += mXVelocity * chunk;
	    mYrot += mYVelocity * chunk;

	    if (mXrot > 360.0f / screen->vpSize ().width ())
	    {
		mBaseXrot += 360.0f / screen->vpSize ().width ();
		mXrot     -= 360.0f / screen->vpSize ().width ();
	    }
	    else if (mXrot < 0.0f)
	    {
		mBaseXrot -= 360.0f / screen->vpSize ().width ();
		mXrot     += 360.0f / screen->vpSize ().width ();
	    }

	    if (cubeScreen->invert () == -1)
	    {
		if (mYrot > 45.0f)
		{
		    mYVelocity = 0.0f;
		    mYrot      = 45.0f;
		}
		else if (mYrot < -45.0f)
		{
		    mYVelocity = 0.0f;
		    mYrot      = -45.0f;
		}
	    }
	    else
	    {
		if (mYrot > 100.0f)
		{
		    mYVelocity = 0.0f;
		    mYrot      = 100.0f;
		}
		else if (mYrot < -100.0f)
		{
		    mYVelocity = 0.0f;
		    mYrot      = -100.0f;
		}
	    }

	    if (mGrabbed)
	    {
		mXVelocity /= 1.25f;
		mYVelocity /= 1.25f;

		if (fabs (mXVelocity) < 0.01f)
		    mXVelocity = 0.0f;

		if (fabs (mYVelocity) < 0.01f)
		    mYVelocity = 0.0f;
	    }
	    else if (adjustVelocity (screen->vpSize ().width (), cubeScreen->invert ()))
	    {
		mXVelocity = 0.0f;
		mYVelocity = 0.0f;

		if (fabs (mYrot) < 0.1f)
		{
		    CompOption::Vector o (0);
		    int                tx;
		    float              xrot = mBaseXrot + mXrot;

		    if (xrot < 0.0f)
			tx = (screen->vpSize ().width () * xrot / 360.0f) - 0.5f;
		    else
			tx = (screen->vpSize ().width () * xrot / 360.0f) + 0.5f;

		    /* flag end of rotation */
		    cubeScreen->rotationState (CubeScreen::RotationNone);

		    screen->moveViewport (tx, 0, true);

		    mBaseXrot = mMoveTo = mXrot = mYrot = 0.0f;
		    mMoving   = false;

		    if (mGrabIndex)
		    {
			screen->removeGrab (mGrabIndex, &mSavedPointer);
			mGrabIndex = 0;
		    }

		    if (mMoveWindow)
		    {
			CompWindow *w = screen->findWindow (mMoveWindow);

			if (w)
			    w->move (mMoveWindowX - w->x (), 0);
		    }
		    /* only focus default window if switcher isn't active */
		    else if (!screen->grabExist ("switcher"))
			screen->focusDefaultWindow ();

		    mMoveWindow = 0;

		    screen->handleCompizEvent ("rotate", "end_viewport_switch", o);
		}
		break;
	    }
	}

	if (mMoveWindow)
	{
	    CompWindow *w = screen->findWindow (mMoveWindow);

	    if (w)
	    {
		float xrot = (screen->vpSize ().width () * (mBaseXrot + mXrot)) / 360.0f;
		w->moveToViewportPosition (mMoveWindowX - xrot * screen->width (),
					   w->y (), false);
	    }
	}
    }

    if (mMoving)
    {
	if (fabs (mXrot + mBaseXrot + mMoveTo) <= 180 / screen->vpSize ().width ())
	    mProgress = fabs (mXrot + mBaseXrot + mMoveTo) /
			180 / screen->vpSize ().width ();
	else if (fabs (mXrot + mBaseXrot) <= 180 / screen->vpSize ().width ())
	    mProgress = fabs (mXrot + mBaseXrot) /
			180 / screen->vpSize ().width ();
	else
	{
	    mProgress += fabs (mXrot + mBaseXrot - oldXrot) /
			 180 / (screen->vpSize ().width ());
	    mProgress = MIN (mProgress, 1.0);
	}
    }
    else if (mProgress != 0.0f || mGrabbed)
    {
	float amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
	int   steps  = amount / (0.5f * optionGetTimestep ());

	if (!steps)
	    steps = 1;

	float chunk  = amount / (float) steps;

	while (steps--)
	{
	    float dt;

	    if (mGrabbed)
		dt = 1.0 - mProgress;
	    else
		dt = 0.0f - mProgress;

	    float adjust  = dt * 0.15f;
	    float tamount = fabs (dt) * 1.5f;

	    if (tamount < 0.2f)
		tamount = 0.2f;
	    else if (tamount > 2.0f)
		tamount = 2.0f;

	    mProgressVelocity = (tamount * mProgressVelocity + adjust) /
				(tamount + 1.0f);

	    mProgress += mProgressVelocity * chunk;

	    if (fabs (dt) < 0.01f && fabs (mProgressVelocity) < 0.0001f)
	    {
		if (mGrabbed)
		    mProgress = 1.0f;
		else
		    mProgress = 0.0f;

		break;
	    }
	}
    }

    if (cubeScreen->invert () == 1 && !cubeScreen->unfolded ())
	mZoomTranslate = optionGetZoom () * mProgress;
    else
	mZoomTranslate = 0.0;

    cScreen->preparePaint (msSinceLastPaint);
}
Пример #10
0
void
PrivateCompositeScreen::handleEvent (XEvent *event)
{
    CompWindow      *w;

    switch (event->type) {

	case CreateNotify:
	    if (screen->root () == event->xcreatewindow.parent)
	    {
		/* The first time some client asks for the composite
		 * overlay window, the X server creates it, which causes
		 * an errorneous CreateNotify event.  We catch it and
		 * ignore it. */
		if (overlay == event->xcreatewindow.window)
		    return;
	    }
	    break;
	case PropertyNotify:
	    if (event->xproperty.atom == Atoms::winOpacity)
	    {
		w = screen->findWindow (event->xproperty.window);
		if (w)
		    CompositeWindow::get (w)->updateOpacity ();
	    }
	    else if (event->xproperty.atom == Atoms::winBrightness)
	    {
		w = screen->findWindow (event->xproperty.window);
		if (w)
		    CompositeWindow::get (w)->updateBrightness ();
	    }
	    else if (event->xproperty.atom == Atoms::winSaturation)
	    {
		w = screen->findWindow (event->xproperty.window);
		if (w)
		    CompositeWindow::get (w)->updateSaturation ();
	    }
	    break;
	default:
	    if (shapeExtension &&
		event->type == shapeEvent + ShapeNotify)
	    {
		w = screen->findWindow (((XShapeEvent *) event)->window);
		if (w)
		{
		    if (w->mapNum ())
		    {
		        CompositeWindow::get (w)->addDamage ();
		    }
		}
	    }
	    else if (event->type == damageEvent + XDamageNotify)
	    {
		XDamageNotifyEvent *de = (XDamageNotifyEvent*)event;
		damages[de->damage] = de->area;
	    }
	    break;
    }

    screen->handleEvent (event);

    switch (event->type) {
	case Expose:
	    handleExposeEvent (&event->xexpose);
	break;
	case ClientMessage:
	    if (event->xclient.message_type == Atoms::winOpacity)
	    {
		w = screen->findWindow (event->xclient.window);
		if (w && (w->type () & CompWindowTypeDesktopMask) == 0)
		{
		    unsigned short opacity = event->xclient.data.l[0] >> 16;

		    screen->setWindowProp32 (w->id (),
			Atoms::winOpacity, opacity);
		}
	    }