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 (); }
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 (); }
CompRegion::CompRegion ( int x, int y, int w, int h) { priv = new PrivateRegion (); priv->box.extents = CompRect (x, y, w, h).region ()->extents; priv->box.numRects = 1; priv->box.rects = &priv->box.extents; }
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))); } }
void CompositeWindow::damageOutputExtents () { if (priv->cScreen->damageMask () & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) return; if (priv->window->shaded () || (priv->window->isViewable ())) { int x1, x2, y1, y2; const CompWindow::Geometry &geom = priv->window->geometry (); const CompWindowExtents &output = priv->window->output (); /* top */ x1 = -output.left - geom.border (); y1 = -output.top - geom.border (); x2 = priv->window->size ().width () + output.right; y2 = -geom.border (); if (x1 < x2 && y1 < y2) addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1)); /* bottom */ y1 = priv->window->size ().height (); y2 = y1 + output.bottom - geom.border (); if (x1 < x2 && y1 < y2) addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1)); /* left */ x1 = -output.left - geom.border (); y1 = -geom.border (); x2 = -geom.border (); y2 = priv->window->size ().height (); if (x1 < x2 && y1 < y2) addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1)); /* right */ x1 = priv->window->size ().width (); x2 = x1 + output.right - geom.border (); if (x1 < x2 && y1 < y2) addDamageRect (CompRect (x1, y1, x2 - x1, y2 - y1)); } }
void SvgWindow::updateSvgContext () { if (context) { finiTexture (context->texture[0]); finiTexture (context->texture[1]); } else { context = new SvgContext; if (!context) return; } int x1, y1, x2, y2; CompSize wSize; initTexture (source, context->texture[1], context->size); context->source = source; wSize.setWidth (window->geometry ().width ()); wSize.setHeight (window->geometry ().height ()); decor_apply_gravity (source->p1.gravity, source->p1.x, source->p1.y, wSize.width (), wSize.height (), &x1, &y1); decor_apply_gravity (source->p2.gravity, source->p2.x, source->p2.y, wSize.width (), wSize.height (), &x2, &y2); x1 = MAX (x1, 0); y1 = MAX (y1, 0); x2 = MIN (x2, wSize.width ()); y2 = MIN (y2, wSize.height ()); if (!initTexture (source, context->texture[0], wSize)) { delete context; context = NULL; } else { renderSvg (source, context->texture[0], wSize, 0.0f, 0.0f, 1.0f, 1.0f); initTexture (source, context->texture[1], CompSize ()); context->box += CompRect (x1, y1, x2 - x1, y2 - y1); context->box.translate (window->geometry ().x (), window->geometry ().y ()); updateSvgMatrix (); } }
CompRect CompWindow::serverOutputRect () const { return CompRect (serverGeometry ().xMinusBorder () - priv->output.left, serverGeometry ().yMinusBorder () - priv->output.top, serverGeometry ().widthIncBorders () + priv->output.left + priv->output.right, serverGeometry ().heightIncBorders () + priv->output.top + priv->output.bottom); }
CompRect CompWindow::inputRect () const { return CompRect (geometry ().xMinusBorder () - priv->serverInput.left, geometry ().yMinusBorder () - priv->serverInput.top, geometry ().widthIncBorders () + priv->serverInput.left + priv->serverInput.right, geometry ().heightIncBorders () + priv->serverInput.top + priv->serverInput.bottom); }
CompRect CompWindow::borderRect () const { return CompRect (geometry ().xMinusBorder () - priv->border.left, geometry ().yMinusBorder () - priv->border.top, geometry ().widthIncBorders () + priv->border.left + priv->border.right, geometry ().heightIncBorders () + priv->border.top + priv->border.bottom); }
CompRect::vector CompRegion::rects () const { CompRect::vector rv; if (!numRects ()) return rv; if (!priv->region) { rv.push_back (CompRect (priv->box.extents.x1, priv->box.extents.y1, priv->box.extents.x2 - priv->box.extents.x1, priv->box.extents.y2 - priv->box.extents.y1)); return rv; } BOX b; for (int i = 0; i < priv->region->numRects; i++) { b = priv->region->rects[i]; rv.push_back (CompRect (b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1)); } return rv; }
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 ()))); } }
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); }
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 ()); }
TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenSizeChange) { CompSize current, old; compiz::window::Geometry g (200, 250, 300, 400, 0); MockScreenSizeChangeObject ms (g); current = CompSize (1280, 800); /* Reserve top, bottom and left parts of the screen for * fake "24px" panels */ CompRect workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); /* First test that changing the screen size * to something smaller here doesn't cause our * (small) window to be moved */ old = current; current = CompSize (1024, 768); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0)); /* Making the screen size bigger with no * saved geometry should cause the window not to move */ old = current; current = CompSize (2048, 768); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0)); /* Move the window to the other "monitor" */ ms.setGeometry (compiz::window::Geometry (1025, 250, 300, 400, 0)); old = current; /* Unplug a "monitor" */ current = CompSize (1024, 768); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (724, 250, 300, 400, 0)); old = current; /* Re-plug the monitor - window should go back * to the same position */ current = CompSize (2048, 768); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0)); old = current; /* Plug 2 monitors downwards, no change */ current = CompSize (2048, 1536); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0)); /* Move the window to the bottom "monitor" */ ms.setGeometry (compiz::window::Geometry (1025, 791, 300, 400, 0)); old = current; /* Unplug bottom "monitor" */ current = CompSize (2048, 768); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (1025, 344, 300, 400, 0)); old = current; /* Re-plug bottom "monitor" */ current = CompSize (2048, 1356); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (1025, 791, 300, 400, 0)); /* Move the entire window right a viewport */ g.setPos (g.pos () + CompPoint (current.width (), 0)); ms.setGeometry (g); /* Now change the screen resolution again - the window should * move to be within the constrained size of its current * viewport */ /* Unplug a "monitor" */ old = current; current = CompSize (1024, 1356); workArea = CompRect (0, 0, current.width (), current.height ()); reserveStruts (workArea); ms.setWorkArea (workArea); g = ms.adjustForSize (old, current); EXPECT_EQ (g, compiz::window::Geometry (current.width () + 724, 791, 300, 400, 0)); }
CompRect CompRegion::boundingRect () const { BOX b = handle ()->extents; return CompRect (b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1); }
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Authors: Dennis Kasprzyk <*****@*****.**> */ #include <stdio.h> #include <X11/Xlib-xcb.h> #include <X11/Xutil.h> #include <X11/Xregion.h> #include <core/core.h> #include "privateregion.h" const CompRegion infiniteRegion (CompRect (MINSHORT, MINSHORT, MAXSHORT * 2, MAXSHORT * 2)); const CompRegion emptyRegion; CompRegion::CompRegion () { priv = new PrivateRegion (); } 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) {