summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 18:00:56 +0200
committerDennis Kasprzyk <onestone@opencompositing.org>2008-08-06 18:00:56 +0200
commit84fbdc90df2b2a53dd94cae3d1f51a012ac42c49 (patch)
tree1f877dc74f230008e5443d53c06c23771c166889 /src
parent6d03dac7963e2b17d3e499b301cbced515e0ea04 (diff)
downloadunity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.gz
unity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.bz2
CompRect class.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/output.cpp75
-rw-r--r--src/rect.cpp90
3 files changed, 101 insertions, 67 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 447b625..edd53d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,4 +30,5 @@ compiz_SOURCES = \
cursor.cpp \
match.cpp \
metadata.cpp \
- output.cpp
+ output.cpp \
+ rect.cpp
diff --git a/src/output.cpp b/src/output.cpp
index 8d526f6..ff6213a 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -6,12 +6,6 @@ CompOutput::CompOutput ()
{
mName = "";
mId = ~0;
- mRegion.rects = &mRegion.extents;
- mRegion.numRects = 1;
- mRegion.extents.x1 = 0;
- mRegion.extents.x2 = 0;
- mRegion.extents.y1 = 0;
- mRegion.extents.y2 = 0;
mWorkArea.x = 0;
mWorkArea.y = 0;
@@ -31,48 +25,6 @@ CompOutput::id ()
return mId;
}
-unsigned int
-CompOutput::x1 ()
-{
- return mRegion.extents.x1;
-}
-
-unsigned int
-CompOutput::y1 ()
-{
- return mRegion.extents.y1;
-}
-
-unsigned int
-CompOutput::x2 ()
-{
- return mRegion.extents.x2;
-}
-
-unsigned int
-CompOutput::y2 ()
-{
- return mRegion.extents.y2;
-}
-
-unsigned int
-CompOutput::width ()
-{
- return mRegion.extents.x2 - mRegion.extents.x1;
-}
-
-unsigned int
-CompOutput::height ()
-{
- return mRegion.extents.y2 - mRegion.extents.y1;
-}
-
-Region
-CompOutput::region ()
-{
- return &mRegion;
-}
-
XRectangle
CompOutput::workArea ()
{
@@ -104,31 +56,22 @@ CompOutput::setWorkArea (XRectangle workarea)
}
void
-CompOutput::setGeometry (unsigned int x1, unsigned int x2,
- unsigned int y1, unsigned int y2)
+CompOutput::setGeometry (int x1, int x2, int y1, int y2)
{
if (x1 < 0)
- mRegion.extents.x1 = 0;
- else
- mRegion.extents.x1 = x1;
+ x1 = 0;
if (y1 < 0)
- mRegion.extents.y1 = 0;
- else
- mRegion.extents.y1 = y1;
+ y1 = 0;
- if ((int) x2 < mRegion.extents.x1)
- mRegion.extents.x2 = mRegion.extents.x1;
- else
- mRegion.extents.x2 = x2;
+ if (x2 < 0)
+ x2 = 0;
- if ((int) y2 < mRegion.extents.y1)
- mRegion.extents.y2 = mRegion.extents.y1;
- else
- mRegion.extents.y2 = y2;
+ if (y2 < 0)
+ y2 = 0;
- mWorkArea.x = mRegion.extents.x1;
- mWorkArea.y = mRegion.extents.y1;
+ mWorkArea.x = this->x1 ();
+ mWorkArea.y = this->y1 ();
mWorkArea.width = width ();
mWorkArea.height = height ();
}
diff --git a/src/rect.cpp b/src/rect.cpp
new file mode 100644
index 0000000..892e369
--- /dev/null
+++ b/src/rect.cpp
@@ -0,0 +1,90 @@
+#include <compiz-core.h>
+#include <comprect.h>
+
+CompRect::CompRect ()
+{
+ mRegion.rects = &mRegion.extents;
+ mRegion.numRects = 1;
+ mRegion.extents.x1 = 0;
+ mRegion.extents.x2 = 0;
+ mRegion.extents.y1 = 0;
+ mRegion.extents.y2 = 0;
+}
+
+CompRect::CompRect (int x1, int x2, int y1, int y2)
+{
+ CompRect ();
+ setGeometry (x1, x2, y1, y2);
+}
+
+int
+CompRect::x ()
+{
+ return mRegion.extents.x1;
+}
+
+int
+CompRect::y ()
+{
+ return mRegion.extents.y1;
+}
+
+int
+CompRect::x1 ()
+{
+ return mRegion.extents.x1;
+}
+
+int
+CompRect::y1 ()
+{
+ return mRegion.extents.y1;
+}
+
+int
+CompRect::x2 ()
+{
+ return mRegion.extents.x2;
+}
+
+int
+CompRect::y2 ()
+{
+ return mRegion.extents.y2;
+}
+
+unsigned int
+CompRect::width ()
+{
+ return mRegion.extents.x2 - mRegion.extents.x1;
+}
+
+unsigned int
+CompRect::height ()
+{
+ return mRegion.extents.y2 - mRegion.extents.y1;
+}
+
+Region
+CompRect::region ()
+{
+ return &mRegion;
+}
+
+void
+CompRect::setGeometry (int x1, int x2, int y1, int y2)
+{
+ mRegion.extents.x1 = x1;
+ mRegion.extents.y1 = y1;
+
+ if (x2 < x1)
+ mRegion.extents.x2 = x1;
+ else
+ mRegion.extents.x2 = x2;
+
+ if (y2 < y1)
+ mRegion.extents.y2 = y1;
+ else
+ mRegion.extents.y2 = y2;
+}
+