Exemple #1
0
void
PrivateCompositeWindow::resizeNotify (int dx, int dy, int dwidth, int dheight)
{
    window->resizeNotify (dx, dy, dwidth, dheight);

    if (window->shaded () || (window->isViewable ()))
    {
	int x, y, x1, x2, y1, y2;

	x = window->geometry ().x ();
	y = window->geometry ().y ();

	x1 = x - window->output ().left - dx;
	y1 = y - window->output ().top - dy;
	x2 = x + window->size ().width () +
	     window->output ().right - dx - dwidth;
	y2 = y + window->size ().height () +
	     window->output ().bottom - dy - dheight;

	cScreen->damageRegion (CompRegion (CompRect (x1, y1, x2 - x1, y2 - y1)));
    }

    cWindow->release ();
    cWindow->addDamage ();
}
Exemple #2
0
void
CompositeWindow::damageTransformedRect (float          xScale,
					float          yScale,
					float          xTranslate,
					float          yTranslate,
					const CompRect &rect)
{
    int x1, x2, y1, y2;

    x1 = (short) (rect.x1 () * xScale) - 1;
    y1 = (short) (rect.y1 () * yScale) - 1;
    x2 = (short) (rect.x2 () * xScale + 0.5f) + 1;
    y2 = (short) (rect.y2 () * yScale + 0.5f) + 1;

    x1 += (short) xTranslate;
    y1 += (short) yTranslate;
    x2 += (short) (xTranslate + 0.5f);
    y2 += (short) (yTranslate + 0.5f);

    if (x2 > x1 && y2 > y1)
    {
	const CompWindow::Geometry &geom = priv->window->serverGeometry ();

	x1 += geom.x () + geom.border ();
	y1 += geom.y () + geom.border ();
	x2 += geom.x () + geom.border ();
	y2 += geom.y () + geom.border ();

	priv->cScreen->damageRegion (CompRegion (CompRect (x1, y1, x2 - x1, y2 - y1)));
    }
}
Exemple #3
0
void
PrivateCompositeWindow::handleDamageRect (CompositeWindow *w,
					  int             x,
					  int             y,
					  int             width,
					  int             height)
{
    if (!w->priv->redirected)
	return;

    bool   initial = false;

    if (!w->priv->damaged)
    {
	w->priv->damaged = initial = true;
    }

    if (!w->damageRect (initial, CompRect (x, y, width, height)))
    {
	const CompWindow::Geometry &geom = w->priv->window->geometry ();

	x += geom.x () + geom.border ();
	y += geom.y () + geom.border ();

	w->priv->cScreen->damageRegion (CompRegion (CompRect (x, y, width, height)));
    }

    if (initial)
	w->damageOutputExtents ();
}
Exemple #4
0
void
PrivateRegion::makeReal ()
{
    if (region)
	return;
    region = XCreateRegion ();
    if (box.numRects)
	XUnionRegion (CompRegion ().handle (), &box, region);
}
TEST(WallOffsetMovementTest, TestOffsetBottomMMSlice)
{
    CompRect sbr (0, 750, 500, 500);
    CompRegion sr (0, 0, 1000, 1000);

    sr -= CompRegion (400, 0, 200, 0);

    CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);

    EXPECT_EQ (offset, CompPoint (0, -250));
}
Exemple #6
0
CompRegion::CompRegion (const CompRegion &c)
{
    priv = new PrivateRegion ();
    priv->box = c.priv->box;
    if (priv->box.rects)
	priv->box.rects = &priv->box.extents;
    if (c.priv->region)
    {
	priv->region = XCreateRegion ();
	XUnionRegion (CompRegion ().handle (), c.priv->region, priv->region);
    }
}
Exemple #7
0
void
WallScreen::updateScreenEdgeRegions ()
{
    edgeRegion = CompRegion (0, 0, screen->width (), screen->height ());
    noEdgeRegion = CompRegion (0, 0, screen->width (), screen->height ());

    struct screenEdgeGeometry {
	int xw, x0;
	int yh, y0;
	int ww, w0;
	int hh, h0;
    } geometry[SCREEN_EDGE_NUM] = {
	{ 0,  0,   0,  2,   0,  2,   1, -4 }, /* left */
	{ 1, -2,   0,  2,   0,  2,   1, -4 }, /* right */
	{ 0,  2,   0,  0,   1, -4,   0,  2 }, /* top */
	{ 0,  2,   1, -2,   1, -4,   0,  2 }, /* bottom */
	{ 0,  0,   0,  0,   0,  2,   0,  2 }, /* top-left */
	{ 1, -2,   0,  0,   0,  2,   0,  2 }, /* top-right */
	{ 0,  0,   1, -2,   0,  2,   0,  2 }, /* bottom-left */
	{ 1, -2,   1, -2,   0,  2,   0,  2 }  /* bottom-right */
    };

    for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)
    {
	CompRegion edge (geometry[i].xw * screen->width () +
			 geometry[i].x0,
			 geometry[i].yh * screen->height () +
			 geometry[i].y0,
			 geometry[i].ww * screen->width () +
			 geometry[i].w0,
			 geometry[i].hh * screen->height () +
			 geometry[i].h0);

	noEdgeRegion -= edgeRegion;
    }

    edgeRegion -= noEdgeRegion;
}
Exemple #8
0
void
PrivateGLWindow::updateWindowRegions ()
{
    CompRect input (window->serverInputRect ());

    if (regions.size () != textures.size ())
	regions.resize (textures.size ());
    for (unsigned int i = 0; i < textures.size (); i++)
    {
	regions[i] = CompRegion (*textures[i]);
	regions[i].translate (input.x (), input.y ());
	regions[i] &= window->region ();
    }
    updateState &= ~(UpdateRegion);
}
Exemple #9
0
void
CompositeWindow::addDamageRect (const CompRect &rect)
{
    if (priv->cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
	return;

    if (!damageRect (false, rect))
    {
	int x, y;

	x = rect.x ();
	y = rect.y ();

	const CompWindow::Geometry &geom = priv->window->geometry ();
	x += geom.x () + geom.border ();
	y += geom.y () + geom.border ();

	priv->cScreen->damageRegion (CompRegion (CompRect (x, y,
							   rect.width (),
							   rect.height ())));
    }
}
Exemple #10
0
CompRegion &
CompRegion::operator= (const CompRegion &c)
{
    priv->box = c.priv->box;
    if (priv->box.rects)
	priv->box.rects = &priv->box.extents;
    if (c.priv->region)
    {
	if (!priv->region)
	    priv->region = XCreateRegion ();
	XUnionRegion (CompRegion ().handle (), c.priv->region, priv->region);
    }
    else
    {
	if (priv->region)
	{
	    XDestroyRegion (priv->region);
	    priv->region = NULL;
	}
    }
    return *this;
}
Exemple #11
0
void
PrivateCompositeWindow::moveNotify (int dx, int dy, bool now)
{
    if (window->shaded () || (window->isViewable ()))
    {
	int x, y, x1, x2, y1, y2;

	x = window->geometry ().x ();
	y = window->geometry ().y ();

	x1 = x - window->output ().left - dx;
	y1 = y - window->output ().top - dy;
	x2 = x + window->geometry ().width () +
	     window->output ().right - dx;
	y2 = y + window->geometry ().height () +
	     window->output ().bottom - dy;

	cScreen->damageRegion (CompRegion (CompRect (x1, y1, x2 - x1, y2 - y1)));
    }
    cWindow->addDamage ();

    window->moveNotify (dx, dy, now);
}
Exemple #12
0
void
BurnAnim::step ()
{
    CompRect outRect (mAWindow->savedRectsValid () ?
		      mAWindow->savedOutRect () :
		      mWindow->outputRect ());

    float timestep = mIntenseTimeStep;
    float old = 1 - (mRemainingTime) / (mTotalTime - timestep);
    float stepSize;

    mRemainingTime -= timestep;
    if (mRemainingTime <= 0)
	mRemainingTime = 0;	// avoid sub-zero values
    float newProgress = 1 - (mRemainingTime) / (mTotalTime - timestep);

    stepSize = newProgress - old;

    if (mCurWindowEvent == WindowEventOpen ||
	mCurWindowEvent == WindowEventUnminimize ||
	mCurWindowEvent == WindowEventUnshade)
    {
	newProgress = 1 - newProgress;
    }

    if (mRemainingTime > 0)
    {
	CompRect rect;

	switch (mDirection)
	{
	case AnimDirectionUp:
	    rect = CompRect (0, 0,
	                     outRect.width (),
	                     outRect.height () -
	                     (newProgress * outRect.height ()));
	    break;
	case AnimDirectionRight:
	    rect = CompRect (newProgress * outRect.width (),
			     0,
			     outRect.width () -
			     (newProgress * outRect.width ()),
			     outRect.height ());
	    break;
	case AnimDirectionLeft:
	    rect = CompRect (0, 0,
			     outRect.width () -
			     (newProgress * outRect.width ()),
			     outRect.height ());
	    break;
	case AnimDirectionDown:
	default:
	    rect = CompRect (0,
			     newProgress * outRect.height (),
			     outRect.width (),
			     outRect.height () -
			     (newProgress * outRect.height ()));
	    break;
	}
	rect.setX (rect.x () + outRect.x ());
	rect.setY (rect.y () + outRect.y ());

	mDrawRegion = CompRegion (rect);
    }
    else
    {
	mDrawRegion = emptyRegion;
    }
    mUseDrawRegion = (fabs (newProgress) > 1e-5);

    if (mRemainingTime > 0)
    {
	switch (mDirection)
	{
	case AnimDirectionUp:
	    if (mHasSmoke)
		genNewSmoke (outRect.x (),
			     outRect.y () + ((1 - newProgress) * outRect.height ()),
			     outRect.width (), 1, outRect.width () / 40.0,
			     mTimeSinceLastPaint);
	    genNewFire (outRect.x (),
			outRect.y () + ((1 - newProgress) * outRect.height ()),
			outRect.width (), (stepSize) * outRect.height (),
			outRect.width () / 40.0,
			mTimeSinceLastPaint);
	    break;
	case AnimDirectionLeft:
	    if (mHasSmoke)
		genNewSmoke (outRect.x () + ((1 - newProgress) * outRect.width ()),
			     outRect.y (),
			     (stepSize) * outRect.width (),
			     outRect.height (), outRect.height () / 40.0,
			     mTimeSinceLastPaint);
	    genNewFire (outRect.x () + ((1 - newProgress) * outRect.width ()),
			outRect.y (), (stepSize) * outRect.width (),
			outRect.height (), outRect.height () / 40.0,
			mTimeSinceLastPaint);
	    break;
	case AnimDirectionRight:
	    if (mHasSmoke)
		genNewSmoke (outRect.x () + (newProgress * outRect.width ()),
			     outRect.y (),
			     (stepSize) * outRect.width (),
			     outRect.height (), outRect.height () / 40.0,
			     mTimeSinceLastPaint);
	    genNewFire (outRect.x () + (newProgress * outRect.width ()),
			outRect.y (), (stepSize) * outRect.width (),
			outRect.height (), outRect.height () / 40.0,
			mTimeSinceLastPaint);
	    break;
	case AnimDirectionDown:
	default:
	    if (mHasSmoke)
		genNewSmoke (outRect.x (),
			     outRect.y () + (newProgress * outRect.height ()),
			     outRect.width (), 1, outRect.width () / 40.0,
			     mTimeSinceLastPaint);
	    genNewFire (outRect.x (),
			outRect.y () + (newProgress * outRect.height ()),
			outRect.width (), (stepSize) * outRect.height (),
			outRect.width () / 40.0,
			mTimeSinceLastPaint);
	    break;
	}

    }
    if (mRemainingTime <= 0 &&
	(mParticleSystems[0].active () ||
	 (mHasSmoke && mParticleSystems[1].active ())))
	// force animation to continue until particle systems are done
	mRemainingTime = timestep;

    Particle *part;

    if (mRemainingTime > 0)
    {
	int nParticles;
	if (mHasSmoke)
	{
	    float partxg = outRect.width () / 40.0;
	    float partxgNeg = -partxg;

	    vector<Particle> &particles = mParticleSystems[mSmokePSId].particles ();
	    nParticles = particles.size ();
	    part = &particles[0];

	    for (int i = 0; i < nParticles; i++, part++)
		part->xg = (part->x < part->xo) ? partxg : partxgNeg;

	    mParticleSystems[mSmokePSId].setOrigin (outRect.x (), outRect.y ());
	}

	vector<Particle> &particles = mParticleSystems[mFirePSId].particles ();
	nParticles = particles.size ();
	part = &particles[0];

	for (int i = 0; i < nParticles; i++, part++)
	    part->xg = (part->x < part->xo) ? 1.0 : -1.0;
    }
    mParticleSystems[mFirePSId].setOrigin (outRect.x (), outRect.y ());
}
Exemple #13
0
void
PrivateCubeScreen::moveViewportAndPaint (const GLScreenPaintAttrib &sAttrib,
					 const GLMatrix            &transform,
					 CompOutput                *outputPtr,
					 unsigned int              mask,
					 PaintOrder                paintOrder,
					 int                       dx)
{
    if (!cubeScreen->cubeShouldPaintViewport (sAttrib, transform, outputPtr, 
					      paintOrder))
	return;

    int output = ((unsigned int) outputPtr->id () != (unsigned int) ~0)
    							 ? outputPtr->id () : 0;

    mPaintOrder = paintOrder;

    if (mNOutput > 1)
    {
	int cubeOutput, dView;

	/* translate to cube output */
	cubeOutput = mOutputMask[output];

	/* convert from window movement to viewport movement */
	dView = -dx;

	cubeOutput += dView;

	dView      = cubeOutput / mNOutput;
	cubeOutput = cubeOutput % mNOutput;

	if (cubeOutput < 0)
	{
	    cubeOutput += mNOutput;
	    dView--;
	}

	/* translate back to compiz output */
	output = mSrcOutput = mOutput[cubeOutput];

	cScreen->setWindowPaintOffset (-dView * screen->width (), 0);
	
	CompRegion reg (screen->outputDevs () [output]);
	cubeScreen->cubePaintViewport (sAttrib, transform, reg, 
			               &screen->outputDevs () [output], mask);
	cScreen->setWindowPaintOffset (0, 0);
    }
    else
    {
	CompRegion region;

	cScreen->setWindowPaintOffset (dx * screen->width (), 0);

	if (optionGetMultioutputMode () == MultioutputModeMultipleCubes)
	    region = CompRegion (*outputPtr);
	else
	    region = screen->region ();

	cubeScreen->cubePaintViewport (sAttrib, transform, region, outputPtr, mask);

	cScreen->setWindowPaintOffset (0, 0);
    }
}
Exemple #14
0
void
BeamUpAnim::step ()
{
    CompRect outRect (mAWindow->savedRectsValid () ?
		      mAWindow->savedOutRect () :
		      mWindow->outputRect ());

    float timestep = mIntenseTimeStep;

    mRemainingTime -= timestep;
    if (mRemainingTime <= 0)
	mRemainingTime = 0;	// avoid sub-zero values

    float newProgress = 1 - mRemainingTime / (mTotalTime - timestep);

    bool creating = (mCurWindowEvent == WindowEventOpen ||
		     mCurWindowEvent == WindowEventUnminimize ||
		     mCurWindowEvent == WindowEventUnshade);

    if (creating)
	newProgress = 1 - newProgress;

    if (mRemainingTime > 0)
    {
	CompRect rect (((newProgress / 2) * outRect.width ()),
		       ((newProgress / 2) * outRect.height ()),
		       (1 - newProgress) * outRect.width (),
		       (1 - newProgress) * outRect.height ());
	rect.setX (rect.x () + outRect.x ());
	rect.setY (rect.y () + outRect.y ());

	mDrawRegion = CompRegion (rect);
    }
    else
    {
	mDrawRegion = emptyRegion;
    }

    mUseDrawRegion = (fabs (newProgress) > 1e-5);

    if (mRemainingTime > 0)
    {
	genNewBeam (outRect.x (), outRect.y () + (outRect.height () / 2),
	            outRect.width (),
	            creating ? (1 - newProgress / 2) * outRect.height ()
	                     : (1 - newProgress) * outRect.height (),
		    outRect.width () / 40.0,
		    mTimeSinceLastPaint);
    }
    if (mRemainingTime <= 0 && mParticleSystems[0].active ())
	// force animation to continue until particle systems are done
	mRemainingTime = 0.001f;

    if (mRemainingTime > 0)
    {
	vector<Particle> &particles = mParticleSystems[0].particles ();
	int nParticles = particles.size ();
	Particle *part = &particles[0];

	for (int i = 0; i < nParticles; i++, part++)
	    part->xg = (part->x < part->xo) ? 1.0 : -1.0;
    }
    mParticleSystems[0].setOrigin (outRect.x (), outRect.y ());
}