summaryrefslogtreecommitdiff
path: root/src/region.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-25 15:51:44 +0200
committerDennis kasprzyk <onestone@compiz-fusion.org>2008-09-25 15:51:44 +0200
commitea9a1308151656f2b967f53c9ddf774dc133f1c9 (patch)
tree91dac9768524d8bac8ec92d5816671ee20ea957f /src/region.cpp
parente86fac1b049392a9bff8dac615b9ff34ec8092fd (diff)
downloadunity-window-decorator-ea9a1308151656f2b967f53c9ddf774dc133f1c9.tar.gz
unity-window-decorator-ea9a1308151656f2b967f53c9ddf774dc133f1c9.tar.bz2
More region operators.
Diffstat (limited to 'src/region.cpp')
-rw-r--r--src/region.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/region.cpp b/src/region.cpp
index 350aeb6..37c664b 100644
--- a/src/region.cpp
+++ b/src/region.cpp
@@ -8,6 +8,10 @@
#include "privateregion.h"
+const CompRegion infiniteRegion (CompRect (MINSHORT, MAXSHORT,
+ MINSHORT, MAXSHORT));
+const CompRegion emptyRegion;
+
CompRegion::CompRegion ()
{
priv = new PrivateRegion ();
@@ -22,7 +26,7 @@ CompRegion::CompRegion (const CompRegion &c)
if (c.priv->region)
{
priv->region = XCreateRegion ();
- XUnionRegion (&emptyRegion, c.priv->region, priv->region);
+ XUnionRegion (CompRegion ().handle (), c.priv->region, priv->region);
}
}
@@ -63,7 +67,7 @@ CompRegion::operator= (const CompRegion &c)
{
if (!priv->region)
priv->region = XCreateRegion ();
- XUnionRegion (&emptyRegion, c.priv->region, priv->region);
+ XUnionRegion (CompRegion ().handle (), c.priv->region, priv->region);
}
return *this;
}
@@ -173,6 +177,15 @@ CompRegion::subtracted (const CompRegion &r) const
return rv;
}
+CompRegion
+CompRegion::subtracted (const CompRect &r) const
+{
+ CompRegion rv;
+ rv.priv->makeReal ();
+ XSubtractRegion (handle (), r.region (), rv.handle ());
+ return rv;
+}
+
void
CompRegion::translate (int dx, int dy)
{
@@ -284,12 +297,24 @@ CompRegion::operator- (const CompRegion &r) const
return subtracted (r);
}
+const CompRegion
+CompRegion::operator- (const CompRect &r) const
+{
+ return subtracted (r);
+}
+
CompRegion &
CompRegion::operator-= (const CompRegion &r)
{
return *this = *this - r;
}
+CompRegion &
+CompRegion::operator-= (const CompRect &r)
+{
+ return *this = *this - r;
+}
+
const CompRegion
CompRegion::operator^ (const CompRegion &r) const
{
@@ -318,7 +343,12 @@ CompRegion::operator|= (const CompRegion &r)
PrivateRegion::PrivateRegion ()
{
region = NULL;
- box = emptyRegion;
+ box.numRects = 0;
+ box.extents.x1 = 0;
+ box.extents.y1 = 0;
+ box.extents.x2 = 0;
+ box.extents.y2 = 0;
+ box.size = 0;
}
PrivateRegion::~PrivateRegion ()
@@ -334,6 +364,6 @@ PrivateRegion::makeReal ()
return;
region = XCreateRegion ();
if (box.numRects)
- XUnionRegion (&emptyRegion, &box, region);
+ XUnionRegion (CompRegion ().handle (), &box, region);
}