summaryrefslogtreecommitdiff
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
parent6d03dac7963e2b17d3e499b301cbced515e0ea04 (diff)
downloadunity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.gz
unity-window-decorator-84fbdc90df2b2a53dd94cae3d1f51a012ac42c49.tar.bz2
CompRect class.
-rw-r--r--include/compiz-core.h1
-rw-r--r--include/compoutput.h17
-rw-r--r--include/comprect.h32
-rw-r--r--src/Makefile.am3
-rw-r--r--src/output.cpp75
-rw-r--r--src/rect.cpp90
6 files changed, 138 insertions, 80 deletions
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 32e58d6..ba77ebb 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -1841,6 +1841,7 @@ COMPIZ_END_DECLS
typedef std::string CompString;
+#include <comprect.h>
#include <compoutput.h>
#include <compobject.h>
#include <compcore.h>
diff --git a/include/compoutput.h b/include/compoutput.h
index 526b2ae..b00e51d 100644
--- a/include/compoutput.h
+++ b/include/compoutput.h
@@ -1,7 +1,9 @@
#ifndef _COMPOUTPUT_H
#define _COMPOUTPUT_H
-class CompOutput {
+#include <comprect.h>
+
+class CompOutput : public CompRect {
public:
CompOutput ();
@@ -10,20 +12,10 @@ class CompOutput {
unsigned int id ();
- unsigned int x1 ();
- unsigned int y1 ();
- unsigned int x2 ();
- unsigned int y2 ();
- unsigned int width ();
- unsigned int height ();
-
- Region region ();
-
XRectangle workArea ();
void setWorkArea (XRectangle);
- void setGeometry (unsigned int, unsigned int,
- unsigned int, unsigned int);
+ void setGeometry (int, int, int, int);
void setId (CompString, unsigned int);
typedef std::vector<CompOutput> vector;
@@ -34,7 +26,6 @@ class CompOutput {
CompString mName;
unsigned int mId;
- REGION mRegion;
XRectangle mWorkArea;
};
diff --git a/include/comprect.h b/include/comprect.h
new file mode 100644
index 0000000..115aae1
--- /dev/null
+++ b/include/comprect.h
@@ -0,0 +1,32 @@
+#ifndef _COMPRECT_H
+#define _COMPRECT_H
+
+class CompRect {
+
+ public:
+ CompRect ();
+ CompRect (int, int, int, int);
+
+ int x ();
+ int y ();
+
+ int x1 ();
+ int y1 ();
+ int x2 ();
+ int y2 ();
+ unsigned int width ();
+ unsigned int height ();
+
+ Region region ();
+
+ void setGeometry (int, int, int, int);
+
+ typedef std::vector<CompRect> vector;
+ typedef std::vector<CompRect *> ptrVector;
+ typedef std::list<CompRect *> ptrList;
+
+ private:
+ REGION mRegion;
+};
+
+#endif
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;
+}
+