From cb7ac912f491da7732bdb9d3a52d04c2d54e0695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 21 Feb 2018 18:29:21 +0100 Subject: [PATCH] Region: define static const functions returning infinite and empty regions See https://gcc.gnu.org/ml/gcc-help/2010-10/msg00255.html --- include/core/abiversion.h | 2 +- plugins/animationaddon/src/beamup.cpp | 2 +- plugins/animationaddon/src/burn.cpp | 2 +- plugins/animationaddon/src/particle.cpp | 2 +- plugins/animationplus/src/bonanza.cpp | 4 +-- plugins/blur/src/blur.cpp | 10 +++---- plugins/compiztoolbox/src/compiztoolbox.cpp | 4 +-- .../test-composite-backbuffertracking.cpp | 10 +++---- .../decor/src/clip-groups/src/clip-groups.cpp | 4 +-- plugins/decor/src/decor.cpp | 2 +- plugins/expo/src/expo.cpp | 2 +- plugins/group/src/paint.cpp | 2 +- plugins/group/src/selection.cpp | 2 +- plugins/group/src/tab.cpp | 2 +- plugins/imgsvg/src/imgsvg.cpp | 2 +- plugins/kdecompat/src/kdecompat.cpp | 4 +-- plugins/opacify/src/opacify.cpp | 2 +- plugins/opengl/src/paint.cpp | 2 +- plugins/resize/src/logic/src/resize-logic.cpp | 2 +- plugins/ring/src/ring.cpp | 2 +- plugins/shift/src/shift.cpp | 6 ++--- plugins/stackswitch/src/stackswitch.cpp | 4 +-- plugins/staticswitcher/src/staticswitcher.cpp | 2 +- plugins/switcher/src/switcher.cpp | 2 +- plugins/td/src/3d.cpp | 2 +- plugins/thumbnail/src/thumbnail.cpp | 2 +- plugins/wallpaper/src/wallpaper.cpp | 2 +- src/region/include/core/region.h | 6 ++--- src/region/src/region.cpp | 26 ++++++++++--------- src/window.cpp | 4 +-- 30 files changed, 61 insertions(+), 59 deletions(-) diff --git a/include/core/abiversion.h b/include/core/abiversion.h index 06a7494ef..efb6aa4ae 100644 --- a/include/core/abiversion.h +++ b/include/core/abiversion.h @@ -5,6 +5,6 @@ # error Conflicting definitions of CORE_ABIVERSION #endif -#define CORE_ABIVERSION 20170630 +#define CORE_ABIVERSION 20180221 #endif // COMPIZ_ABIVERSION_H diff --git a/plugins/animationaddon/src/beamup.cpp b/plugins/animationaddon/src/beamup.cpp index 8871ff138..59c31dd09 100644 --- a/plugins/animationaddon/src/beamup.cpp +++ b/plugins/animationaddon/src/beamup.cpp @@ -181,7 +181,7 @@ BeamUpAnim::step () } else { - mDrawRegion = emptyRegion; + mDrawRegion = CompRegion::empty (); } mUseDrawRegion = (fabs (newProgress) > 1e-5); diff --git a/plugins/animationaddon/src/burn.cpp b/plugins/animationaddon/src/burn.cpp index b524fa36b..cddf35d56 100644 --- a/plugins/animationaddon/src/burn.cpp +++ b/plugins/animationaddon/src/burn.cpp @@ -326,7 +326,7 @@ BurnAnim::step () } else { - mDrawRegion = emptyRegion; + mDrawRegion = CompRegion::empty (); } mUseDrawRegion = (fabs (newProgress) > 1e-5); diff --git a/plugins/animationaddon/src/particle.cpp b/plugins/animationaddon/src/particle.cpp index 2b0360a30..a0925dab6 100644 --- a/plugins/animationaddon/src/particle.cpp +++ b/plugins/animationaddon/src/particle.cpp @@ -297,7 +297,7 @@ ParticleAnim::updateBB (CompOutput &output) } } - if (mUseDrawRegion && mDrawRegion != emptyRegion) + if (mUseDrawRegion && mDrawRegion != CompRegion::empty ()) // expand BB with bounding box of draw region mAWindow->expandBBWithBox (mDrawRegion.handle ()->extents); else // drawing full window diff --git a/plugins/animationplus/src/bonanza.cpp b/plugins/animationplus/src/bonanza.cpp index 12f372647..656bc62d3 100644 --- a/plugins/animationplus/src/bonanza.cpp +++ b/plugins/animationplus/src/bonanza.cpp @@ -208,12 +208,12 @@ BonanzaAnim::step (float time) } Region pointsRegion = XPolygonRegion (&pts[0], 20, WindingRule);; - mDrawRegion = CompRegionRef(pointsRegion) - emptyRegion.united (rect); + mDrawRegion = CompRegionRef(pointsRegion) - CompRegion::empty ().united (rect); XDestroyRegion (pointsRegion); } else { - mDrawRegion = emptyRegion; + mDrawRegion = CompRegion::empty (); } diff --git a/plugins/blur/src/blur.cpp b/plugins/blur/src/blur.cpp index a0f79921f..00b8efa49 100644 --- a/plugins/blur/src/blur.cpp +++ b/plugins/blur/src/blur.cpp @@ -449,7 +449,7 @@ BlurScreen::damageCutoff () * and then use the real damage in order to determine what blur regions * should be updated */ - backbufferUpdateRegionThisFrame &= emptyRegion; + backbufferUpdateRegionThisFrame &= CompRegion::empty (); CompRegion frameAgeDamage = damageQuery->damageForFrameAge (cScreen->getFrameAge ()); foreach (CompWindow *w, screen->windows ()) { @@ -466,7 +466,7 @@ BlurScreen::damageCutoff () continue; if (!bw->projectedBlurRegion.isEmpty ()) - bw->projectedBlurRegion &= emptyRegion; + bw->projectedBlurRegion &= CompRegion::empty (); GLMatrix screenSpace; screenSpace.toScreenSpace (this->output, -DEFAULT_Z_CAMERA); @@ -561,7 +561,7 @@ BlurWindow::glTransformationComplete (const GLMatrix &matrix, clientThreshold = 0; if (mask & PAINT_WINDOW_TRANSFORMED_MASK) - reg = &infiniteRegion; + reg = &CompRegion::infinite (); else reg = ®ion; @@ -1218,7 +1218,7 @@ BlurWindow::projectRegion (CompOutput *output, GLTexture::MatrixList ml; gWindow->vertexBuffer ()->begin (); - gWindow->glAddGeometry (ml, bScreen->tmpRegion2, infiniteRegion); + gWindow->glAddGeometry (ml, bScreen->tmpRegion2, CompRegion::infinite ()); if (!gWindow->vertexBuffer ()->end ()) return; @@ -1627,7 +1627,7 @@ BlurWindow::glDraw (const GLMatrix &transform, const CompRegion *reg = NULL; if (mask & PAINT_WINDOW_TRANSFORMED_MASK) - reg = &infiniteRegion; + reg = &CompRegion::infinite (); else reg = ®ion; diff --git a/plugins/compiztoolbox/src/compiztoolbox.cpp b/plugins/compiztoolbox/src/compiztoolbox.cpp index 71aab9c98..42bd184cf 100644 --- a/plugins/compiztoolbox/src/compiztoolbox.cpp +++ b/plugins/compiztoolbox/src/compiztoolbox.cpp @@ -504,7 +504,7 @@ BaseSwitchWindow::paintThumb (const GLWindowPaintAttrib &attrib, very ugly but necessary until the vertex stage has been made fully pluggable. */ gWindow->glAddGeometrySetCurrentIndex (MAXSHORT); - gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask); + gWindow->glDraw (wTransform, sAttrib, CompRegion::infinite (), mask); gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex); gScreen->setTextureFilter (filter); @@ -552,7 +552,7 @@ BaseSwitchWindow::paintThumb (const GLWindowPaintAttrib &attrib, gWindow->vertexBuffer ()->begin (); gWindow->glAddGeometrySetCurrentIndex (MAXSHORT); - gWindow->glAddGeometry (matrix, iconReg, infiniteRegion); + gWindow->glAddGeometry (matrix, iconReg, CompRegion::infinite ()); gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex); if (gWindow->vertexBuffer ()->end ()) diff --git a/plugins/composite/src/backbuffertracking/tests/test-composite-backbuffertracking.cpp b/plugins/composite/src/backbuffertracking/tests/test-composite-backbuffertracking.cpp index bc8922a8a..2003a63ed 100644 --- a/plugins/composite/src/backbuffertracking/tests/test-composite-backbuffertracking.cpp +++ b/plugins/composite/src/backbuffertracking/tests/test-composite-backbuffertracking.cpp @@ -181,7 +181,7 @@ TEST_F (BackbufferTrackingCallbacks, NoTrackIntoCurrentIfCallbackFalse) allowDamage (false); CompRegion damage (100, 100, 100, 100); roster->dirtyAreaOnCurrentFrame (damage); - EXPECT_EQ (emptyRegion, roster->currentFrameDamage ()); + EXPECT_EQ (CompRegion::empty (), roster->currentFrameDamage ()); } TEST_F (BackbufferTracking, DirtyAreaSubtraction) @@ -210,7 +210,7 @@ TEST_F (BackbufferTracking, NoDirtyAreaForLastFrame) CompRegion all (0, 0, screen.width (), screen.height ()); roster->dirtyAreaOnCurrentFrame (all); roster->incrementFrameAges (); - EXPECT_EQ (emptyRegion, roster->damageForFrameAge (1)); + EXPECT_EQ (CompRegion::empty (), roster->damageForFrameAge (1)); } TEST_F (BackbufferTracking, DirtyAreaIfMoreSinceLastFrame) @@ -429,21 +429,21 @@ TEST_F (AgeingDamageBuffers, DirtyAreaOnInvalidRosters) { EXPECT_CALL (mockDamageAgeTracker, dirtyAreaOnCurrentFrame (_)).Times (0); ageing.unobserve (mockDamageAgeTracker); - ageing.markAreaDirty (emptyRegion); + ageing.markAreaDirty (CompRegion::empty ()); } TEST_F (AgeingDamageBuffers, SubtractObscuredAreaOnInvalidRosters) { EXPECT_CALL (mockDamageAgeTracker, subtractObscuredArea (_)).Times (0); ageing.unobserve (mockDamageAgeTracker); - ageing.subtractObscuredArea (emptyRegion); + ageing.subtractObscuredArea (CompRegion::empty ()); } TEST_F (AgeingDamageBuffers, AddOverdrawAreaOnInvalidRosters) { EXPECT_CALL (mockDamageAgeTracker, overdrawRegionOnPaintingFrame (_)).Times (0); ageing.unobserve (mockDamageAgeTracker); - ageing.markAreaDirtyOnLastFrame (emptyRegion); + ageing.markAreaDirtyOnLastFrame (CompRegion::empty ()); } diff --git a/plugins/decor/src/clip-groups/src/clip-groups.cpp b/plugins/decor/src/clip-groups/src/clip-groups.cpp index 953743cb8..dece6199c 100644 --- a/plugins/decor/src/clip-groups/src/clip-groups.cpp +++ b/plugins/decor/src/clip-groups/src/clip-groups.cpp @@ -41,7 +41,7 @@ GenericDecorClipGroup::doPopClippable (DecorClippableInterface *dc) if (it != mClippables.end ()) { dc->setOwner (NULL); - dc->updateShadow (emptyRegion); + dc->updateShadow (CompRegion::empty ()); mClippables.erase (it); regenerateClipRegion (); @@ -54,7 +54,7 @@ GenericDecorClipGroup::doPopClippable (DecorClippableInterface *dc) void GenericDecorClipGroup::doRegenerateClipRegion () { - mRegion -= infiniteRegion; + mRegion -= CompRegion::infinite (); foreach (DecorClippableInterface *clippable, mClippables) { diff --git a/plugins/decor/src/decor.cpp b/plugins/decor/src/decor.cpp index 2f93f9d88..b0be105ae 100644 --- a/plugins/decor/src/decor.cpp +++ b/plugins/decor/src/decor.cpp @@ -253,7 +253,7 @@ DecorWindow::glDecorate (const GLMatrix &transform, PAINT_WINDOW_WITH_OFFSET_MASK))) preg = ®ion; else if (mask & PAINT_WINDOW_TRANSFORMED_MASK) - preg = &infiniteRegion; + preg = &CompRegion::infinite (); else if (mClipGroup) { tmpRegion = mOutputRegion; diff --git a/plugins/expo/src/expo.cpp b/plugins/expo/src/expo.cpp index 14108f5b8..86c1618ba 100644 --- a/plugins/expo/src/expo.cpp +++ b/plugins/expo/src/expo.cpp @@ -1336,7 +1336,7 @@ ExpoWindow::glDraw (const GLMatrix &transform, /* reset geometry and paint */ gWindow->vertexBuffer ()->begin (); gWindow->vertexBuffer ()->end (); - paintGlow (transform, attrib, infiniteRegion, mask); + paintGlow (transform, attrib, CompRegion::infinite (), mask); } return status; diff --git a/plugins/group/src/paint.cpp b/plugins/group/src/paint.cpp index 6b13c1d98..4bf87d90d 100644 --- a/plugins/group/src/paint.cpp +++ b/plugins/group/src/paint.cpp @@ -829,7 +829,7 @@ GroupWindow::glDraw (const GLMatrix &transform, if (mGroup && (mGroup->mWindows.size () > 1) && mGlowQuads) { if (mask & PAINT_WINDOW_TRANSFORMED_MASK) - paintRegion = CompRegion (infiniteRegion); + paintRegion = CompRegion (CompRegion::infinite ()); if (paintRegion.numRects ()) { diff --git a/plugins/group/src/selection.cpp b/plugins/group/src/selection.cpp index 5b7fcb91d..41e4658ca 100644 --- a/plugins/group/src/selection.cpp +++ b/plugins/group/src/selection.cpp @@ -249,7 +249,7 @@ Selection::selectRegion () MIN (mY1, mY2) + 4; rect = CompRect (x, y, width, height); - reg = emptyRegion.united (rect); + reg = CompRegion::empty ().united (rect); gs->cScreen->damageRegion (reg); diff --git a/plugins/group/src/tab.cpp b/plugins/group/src/tab.cpp index 2014f5c71..fedc62f82 100644 --- a/plugins/group/src/tab.cpp +++ b/plugins/group/src/tab.cpp @@ -2015,7 +2015,7 @@ GroupScreen::recalcSlotPos (GroupTabBarSlot *slot, space = optionGetThumbSpace (); thumbSize = optionGetThumbSize (); - slot->mRegion = emptyRegion; + slot->mRegion = CompRegion::empty (); /* Padding between slots, account for this */ box.setX (space + ((thumbSize + space) * slotPos)); diff --git a/plugins/imgsvg/src/imgsvg.cpp b/plugins/imgsvg/src/imgsvg.cpp index 0150fd4d0..7d77a0fc8 100644 --- a/plugins/imgsvg/src/imgsvg.cpp +++ b/plugins/imgsvg/src/imgsvg.cpp @@ -230,7 +230,7 @@ SvgWindow::glDraw (const GLMatrix &transform, return status; const CompRegion ® = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ? - infiniteRegion : region; + CompRegion::infinite () : region; if (context && reg.numRects ()) { diff --git a/plugins/kdecompat/src/kdecompat.cpp b/plugins/kdecompat/src/kdecompat.cpp index 93bcd619d..4cc8d3ae1 100644 --- a/plugins/kdecompat/src/kdecompat.cpp +++ b/plugins/kdecompat/src/kdecompat.cpp @@ -323,7 +323,7 @@ KDECompatWindow::glPaint (const GLWindowPaintAttrib &attrib, matrices[0].y0 -= (tw->y () * icon->matrix ().yy); gtw->vertexBuffer ()->begin (); - gtw->glAddGeometry (matrices, tw->geometry (), infiniteRegion); + gtw->glAddGeometry (matrices, tw->geometry (), CompRegion::infinite ()); gtw->vertexBuffer ()->end (); } } @@ -343,7 +343,7 @@ KDECompatWindow::glPaint (const GLWindowPaintAttrib &attrib, if (!gtw->textures ().empty ()) gtw->glDraw (wTransform, attrib, - infiniteRegion, paintMask); + CompRegion::infinite (), paintMask); else if (icon) gtw->glDrawTexture (icon, wTransform, attrib, paintMask); } diff --git a/plugins/opacify/src/opacify.cpp b/plugins/opacify/src/opacify.cpp index 0d84af95e..94c3af7ff 100644 --- a/plugins/opacify/src/opacify.cpp +++ b/plugins/opacify/src/opacify.cpp @@ -407,7 +407,7 @@ OpacifyScreen::OpacifyScreen (CompScreen *screen) : isToggle (optionGetInitToggle ()), newActive (NULL), active (screen->activeWindow ()), - intersect (emptyRegion), + intersect (CompRegion::empty ()), justMoved (false) { ScreenInterface::setHandler (screen, false); diff --git a/plugins/opengl/src/paint.cpp b/plugins/opengl/src/paint.cpp index 5ed223658..e4e98082c 100644 --- a/plugins/opengl/src/paint.cpp +++ b/plugins/opengl/src/paint.cpp @@ -1315,7 +1315,7 @@ GLWindow::glDraw (const GLMatrix &transform, attrib, region, mask) const CompRegion ® = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ? - infiniteRegion : region; + CompRegion::infinite () : region; if (reg.isEmpty ()) return true; diff --git a/plugins/resize/src/logic/src/resize-logic.cpp b/plugins/resize/src/logic/src/resize-logic.cpp index d0222d8c9..a37e3d235 100644 --- a/plugins/resize/src/logic/src/resize-logic.cpp +++ b/plugins/resize/src/logic/src/resize-logic.cpp @@ -1440,7 +1440,7 @@ ResizeLogic::initiateResize (CompAction *action, lastGoodSize = w->serverSize (); /* Combine the work areas of all outputs */ - constraintRegion = emptyRegion; + constraintRegion = CompRegion::empty (); foreach (CompOutput &output, mScreen->outputDevs ()) constraintRegion += output.workArea (); } diff --git a/plugins/ring/src/ring.cpp b/plugins/ring/src/ring.cpp index eac2b28e2..7be912da5 100644 --- a/plugins/ring/src/ring.cpp +++ b/plugins/ring/src/ring.cpp @@ -768,7 +768,7 @@ RingScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, RING_WINDOW (w); status |= rw->gWindow->glPaint (rw->gWindow->paintAttrib (), - sTransform, infiniteRegion, 0); + sTransform, CompRegion::infinite (), 0); } if (mState != RingStateIn) diff --git a/plugins/shift/src/shift.cpp b/plugins/shift/src/shift.cpp index 189b077dc..8245240f4 100644 --- a/plugins/shift/src/shift.cpp +++ b/plugins/shift/src/shift.cpp @@ -1155,7 +1155,7 @@ ShiftScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, mActiveSlot = &mDrawSlots[i]; { sw->gWindow->glPaint (sw->gWindow->paintAttrib (), rTransform, - infiniteRegion, 0); + CompRegion::infinite (), 0); } } @@ -1248,7 +1248,7 @@ ShiftScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, mActiveSlot = &mDrawSlots[i]; { sw->gWindow->glPaint (sw->gWindow->paintAttrib (), sTransform, - infiniteRegion, 0); + CompRegion::infinite (), 0); } } @@ -1288,7 +1288,7 @@ ShiftScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, SHIFT_WINDOW (w); sw->gWindow->glPaint (sw->gWindow->paintAttrib (), sTransform, - infiniteRegion, 0); + CompRegion::infinite (), 0); } mPaintingAbove = false; diff --git a/plugins/stackswitch/src/stackswitch.cpp b/plugins/stackswitch/src/stackswitch.cpp index 31eddc325..ee1c54aa5 100644 --- a/plugins/stackswitch/src/stackswitch.cpp +++ b/plugins/stackswitch/src/stackswitch.cpp @@ -380,7 +380,7 @@ StackswitchWindow::glPaint (const GLWindowPaintAttrib &attrib, matl.push_back (matrix); gWindow->geometry ().reset (); - gWindow->glAddGeometry (matl, iconReg, infiniteRegion); + gWindow->glAddGeometry (matl, iconReg, CompRegion::infinite ()); if (gWindow->geometry ().vCount) { @@ -888,7 +888,7 @@ StackswitchScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, STACKSWITCH_WINDOW (w); - sw->gWindow->glPaint (sw->gWindow->paintAttrib (), sTransform, infiniteRegion, 0); + sw->gWindow->glPaint (sw->gWindow->paintAttrib (), sTransform, CompRegion::infinite (), 0); } } diff --git a/plugins/staticswitcher/src/staticswitcher.cpp b/plugins/staticswitcher/src/staticswitcher.cpp index 8c5389de2..452e1bef7 100644 --- a/plugins/staticswitcher/src/staticswitcher.cpp +++ b/plugins/staticswitcher/src/staticswitcher.cpp @@ -965,7 +965,7 @@ StaticSwitchScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib, sw->cWindow->damaged ()) { sw->gWindow->glPaint (sw->gWindow->paintAttrib (), - sTransform, infiniteRegion, 0); + sTransform, CompRegion::infinite (), 0); } } } diff --git a/plugins/switcher/src/switcher.cpp b/plugins/switcher/src/switcher.cpp index d9bc86d1a..122f3674d 100644 --- a/plugins/switcher/src/switcher.cpp +++ b/plugins/switcher/src/switcher.cpp @@ -790,7 +790,7 @@ SwitchScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib, sw->cWindow->damaged ()) { sw->gWindow->glPaint (sw->gWindow->paintAttrib (), - sTransform, infiniteRegion, 0); + sTransform, CompRegion::infinite (), 0); } } } diff --git a/plugins/td/src/3d.cpp b/plugins/td/src/3d.cpp index 2061c49fc..ad593b122 100644 --- a/plugins/td/src/3d.cpp +++ b/plugins/td/src/3d.cpp @@ -458,7 +458,7 @@ TdScreen::cubePaintViewport (const GLScreenPaintAttrib &attrib, GL::shaders = false; tdw->gWindow->glPaint (tdw->gWindow->paintAttrib (), mTransform, - infiniteRegion, newMask); + CompRegion::infinite (), newMask); GL::shaders = true; gScreen->glDisableOutputClipping (); diff --git a/plugins/thumbnail/src/thumbnail.cpp b/plugins/thumbnail/src/thumbnail.cpp index 584e04894..5a8303d04 100644 --- a/plugins/thumbnail/src/thumbnail.cpp +++ b/plugins/thumbnail/src/thumbnail.cpp @@ -908,7 +908,7 @@ ThumbScreen::thumbPaintThumb (Thumbnail *t, very ugly but necessary until the vertex stage has been made fully pluggable. */ gWindow->glAddGeometrySetCurrentIndex (MAXSHORT); - gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask); + gWindow->glDraw (wTransform, sAttrib, CompRegion::infinite (), mask); gScreen->setTextureFilter (filter); } diff --git a/plugins/wallpaper/src/wallpaper.cpp b/plugins/wallpaper/src/wallpaper.cpp index 289e9497e..24265abdc 100644 --- a/plugins/wallpaper/src/wallpaper.cpp +++ b/plugins/wallpaper/src/wallpaper.cpp @@ -450,7 +450,7 @@ WallpaperWindow::drawBackgrounds (const GLMatrix &transform, gWindow->glAddGeometry (tmpMatrixList, screen->region (), (mask & PAINT_WINDOW_TRANSFORMED_MASK) ? - infiniteRegion : region); + CompRegion::infinite () : region); if (ws->optionGetCycleWallpapers ()) tmpAttrib.opacity *= fadingIn ? (1.0f - ws->alpha) : ws->alpha; diff --git a/src/region/include/core/region.h b/src/region/include/core/region.h index 4412d0288..e5968c5c6 100644 --- a/src/region/include/core/region.h +++ b/src/region/include/core/region.h @@ -52,6 +52,9 @@ class CompRegion { CompRegion (const CompRect &); ~CompRegion (); + static const CompRegion &infinite(); + static const CompRegion &empty(); + /** * Returns a CompRect which encapsulates a given CompRegion */ @@ -193,7 +196,4 @@ class CompRegionRef : public CompRegion ~CompRegionRef (); }; -extern const CompRegion infiniteRegion; -extern const CompRegion emptyRegion; - #endif diff --git a/src/region/src/region.cpp b/src/region/src/region.cpp index c70551089..0eec7f2a1 100644 --- a/src/region/src/region.cpp +++ b/src/region/src/region.cpp @@ -38,19 +38,21 @@ template class std::vector; -const CompRegion infiniteRegion (CompRect (MINSHORT, MINSHORT, - MAXSHORT * 2, MAXSHORT * 2)); -const CompRegion emptyRegion; - -/* Alternate emptyRegion, mostly just required to construct infiniteRegion - when emptyRegion may still be uninitialized */ -static const CompRegion & -_emptyRegion () +const CompRegion & +CompRegion::empty () { static const CompRegion r; return r; } +const CompRegion & +CompRegion::infinite () +{ + static const CompRegion r(CompRect (MINSHORT, MINSHORT, + MAXSHORT * 2, MAXSHORT * 2)); + return r; +} + CompRegion::CompRegion () { init (); @@ -59,7 +61,7 @@ CompRegion::CompRegion () CompRegion::CompRegion (const CompRegion &c) { init (); - XUnionRegion (_emptyRegion ().handle (), c.handle (), handle ()); + XUnionRegion (empty ().handle (), c.handle (), handle ()); } CompRegion::CompRegion ( int x, int y, int w, int h) @@ -73,7 +75,7 @@ CompRegion::CompRegion ( int x, int y, int w, int h) rect.width = w; rect.height = h; - XUnionRectWithRegion (&rect, _emptyRegion ().handle (), handle ()); + XUnionRectWithRegion (&rect, empty ().handle (), handle ()); } CompRegion::CompRegion (const CompRect &r) @@ -87,7 +89,7 @@ CompRegion::CompRegion (const CompRect &r) rect.width = r.width (); rect.height = r.height (); - XUnionRectWithRegion (&rect, _emptyRegion ().handle (), handle ()); + XUnionRectWithRegion (&rect, empty ().handle (), handle ()); } CompRegion::CompRegion (Region external) @@ -129,7 +131,7 @@ CompRegion::handle () const CompRegion & CompRegion::operator= (const CompRegion &c) { - XUnionRegion (emptyRegion.handle (), c.handle (), handle ()); + XUnionRegion (empty ().handle (), c.handle (), handle ()); return *this; } diff --git a/src/window.cpp b/src/window.cpp index 12b31e80e..7ae108799 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -950,7 +950,7 @@ PrivateWindow::updateRegion () const CompWindow::Geometry &geom = attrib.override_redirect ? priv->geometry : priv->serverGeometry; - priv->region = priv->inputRegion = emptyRegion; + priv->region = priv->inputRegion = CompRegion::empty (); r.x = -geom.border (); r.y = -geom.border (); @@ -6658,7 +6658,7 @@ CompWindow::updateFrameRegion () { if (priv->serverFrame) { - priv->frameRegion = emptyRegion; + priv->frameRegion = CompRegion::empty (); updateFrameRegion (priv->frameRegion); -- GitLab