summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/core/core.h1
-rw-r--r--include/core/screen.h6
-rw-r--r--include/core/window.h10
-rw-r--r--src/main.cpp18
-rw-r--r--src/privatescreen.h2
-rw-r--r--src/privatewindow.h4
-rw-r--r--src/screen.cpp14
-rw-r--r--src/window.cpp123
8 files changed, 61 insertions, 117 deletions
diff --git a/include/core/core.h b/include/core/core.h
index d8c45ce..33d9645 100644
--- a/include/core/core.h
+++ b/include/core/core.h
@@ -80,5 +80,6 @@ typedef XBool Bool;
#include <core/rect.h>
#include <core/session.h>
#include <core/size.h>
+#include <core/region.h>
#endif
diff --git a/include/core/screen.h b/include/core/screen.h
index 8037d4e..9d1a4be 100644
--- a/include/core/screen.h
+++ b/include/core/screen.h
@@ -8,6 +8,7 @@
#include <core/plugin.h>
#include <core/match.h>
#include <core/privates.h>
+#include <core/region.h>
class CompScreen;
class PrivateScreen;
@@ -22,9 +23,6 @@ extern bool noDetection;
extern CompScreen *screen;
extern CompMetadata *coreMetadata;
-extern REGION emptyRegion;
-extern REGION infiniteRegion;
-
extern int lastPointerX;
extern int lastPointerY;
extern int pointerX;
@@ -293,7 +291,7 @@ class CompScreen :
CompActiveWindowHistory *currentHistory ();
- Region region ();
+ const CompRegion & region () const;
bool hasOverlappingOutputs ();
diff --git a/include/core/window.h b/include/core/window.h
index b771895..991e654 100644
--- a/include/core/window.h
+++ b/include/core/window.h
@@ -13,6 +13,7 @@
#include <core/privates.h>
#include <core/size.h>
#include <core/point.h>
+#include <core/region.h>
#include <core/wrapsystem.h>
@@ -234,7 +235,7 @@ class WindowInterface : public WrapableInterface<CompWindow, WindowInterface> {
virtual void stateChangeNotify (unsigned int lastState);
- virtual void updateFrameRegion (Region region);
+ virtual void updateFrameRegion (CompRegion &region);
};
class CompWindow :
@@ -279,9 +280,9 @@ class CompWindow :
Window id ();
Window frame ();
- Region region ();
+ const CompRegion & region () const;
- Region frameRegion ();
+ const CompRegion & frameRegion () const;
void updateFrameRegion ();
void setWindowFrameExtents (CompWindowExtents *input);
@@ -475,7 +476,8 @@ class CompWindow :
WRAPABLE_HND (11, WindowInterface, void, stateChangeNotify,
unsigned int);
- WRAPABLE_HND (12, WindowInterface, void, updateFrameRegion, Region);
+ WRAPABLE_HND (12, WindowInterface, void, updateFrameRegion,
+ CompRegion &);
friend class PrivateWindow;
friend class CompScreen;
diff --git a/src/main.cpp b/src/main.cpp
index 8c01333..44d8711 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,9 +45,6 @@ int programArgc;
char *backgroundImage = NULL;
-REGION emptyRegion;
-REGION infiniteRegion;
-
bool shutDown = false;
bool restartSignal = false;
@@ -168,21 +165,6 @@ main (int argc, char **argv)
signal (SIGINT, signalHandler);
signal (SIGTERM, signalHandler);
- emptyRegion.rects = &emptyRegion.extents;
- emptyRegion.numRects = 0;
- emptyRegion.extents.x1 = 0;
- emptyRegion.extents.y1 = 0;
- emptyRegion.extents.x2 = 0;
- emptyRegion.extents.y2 = 0;
- emptyRegion.size = 0;
-
- infiniteRegion.rects = &infiniteRegion.extents;
- infiniteRegion.numRects = 1;
- infiniteRegion.extents.x1 = MINSHORT;
- infiniteRegion.extents.y1 = MINSHORT;
- infiniteRegion.extents.x2 = MAXSHORT;
- infiniteRegion.extents.y2 = MAXSHORT;
-
memset (&ctx, 0, sizeof (ctx));
for (i = 1; i < argc; i++)
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 4127d32..114460b 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -476,7 +476,7 @@ class PrivateScreen {
CompSize vpSize;
unsigned int nDesktop;
unsigned int currentDesktop;
- REGION region;
+ CompRegion region;
Window root;
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 489232e..03af4d9 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -219,8 +219,8 @@ class PrivateWindow {
bool alpha;
int width;
int height;
- Region region;
- Region frameRegion;
+ CompRegion region;
+ CompRegion frameRegion;
unsigned int wmType;
unsigned int type;
diff --git a/src/screen.cpp b/src/screen.cpp
index 569171e..5445603 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -2255,13 +2255,7 @@ PrivateScreen::reshape (int w, int h)
{
updateScreenInfo();
- region.rects = &region.extents;
- region.numRects = 1;
- region.extents.x1 = 0;
- region.extents.y1 = 0;
- region.extents.x2 = w;
- region.extents.y2 = h;
- region.size = 1;
+ region = CompRegion (0, 0, w, h);
size.setWidth (w);
size.setHeight (h);
@@ -4216,10 +4210,10 @@ PrivateScreen::removeDestroyed ()
}
}
-Region
-CompScreen::region ()
+const CompRegion &
+CompScreen::region () const
{
- return &priv->region;
+ return priv->region;
}
bool
diff --git a/src/window.cpp b/src/window.cpp
index 37f776c..22f5f6c 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -707,7 +707,7 @@ PrivateWindow::updateFrameWindow ()
{
unreparent ();
frame = None;
- XSubtractRegion (&emptyRegion, &emptyRegion, frameRegion);
+ frameRegion = CompRegion ();
}
}
@@ -747,11 +747,11 @@ CompWindow::getOutputExtents (CompWindowExtents *output)
void
PrivateWindow::updateRegion ()
{
- REGION rect;
+ int x1, x2, y1, y2;
XRectangle r, *rects, *shapeRects = 0;
int i, n = 0;
- EMPTY_REGION (priv->region);
+ priv->region = CompRegion ();
if (screen->XShape ())
{
@@ -776,34 +776,30 @@ PrivateWindow::updateRegion ()
rects = shapeRects;
}
- rect.rects = &rect.extents;
- rect.numRects = rect.size = 1;
-
for (i = 0; i < n; i++)
{
- rect.extents.x1 = rects[i].x + priv->attrib.border_width;
- rect.extents.y1 = rects[i].y + priv->attrib.border_width;
- rect.extents.x2 = rect.extents.x1 + rects[i].width;
- rect.extents.y2 = rect.extents.y1 + rects[i].height;
-
- if (rect.extents.x1 < 0)
- rect.extents.x1 = 0;
- if (rect.extents.y1 < 0)
- rect.extents.y1 = 0;
- if (rect.extents.x2 > priv->width)
- rect.extents.x2 = priv->width;
- if (rect.extents.y2 > priv->height)
- rect.extents.y2 = priv->height;
-
- if (rect.extents.y1 < rect.extents.y2 &&
- rect.extents.x1 < rect.extents.x2)
+ x1 = rects[i].x + priv->attrib.border_width;
+ y1 = rects[i].y + priv->attrib.border_width;
+ x2 = x1 + rects[i].width;
+ y2 = y1 + rects[i].height;
+
+ if (x1 < 0)
+ x1 = 0;
+ if (y1 < 0)
+ y1 = 0;
+ if (x2 > priv->width)
+ x2 = priv->width;
+ if (y2 > priv->height)
+ y2 = priv->height;
+
+ if (y1 < y2 && x1 < x2)
{
- rect.extents.x1 += priv->attrib.x;
- rect.extents.y1 += priv->attrib.y;
- rect.extents.x2 += priv->attrib.x;
- rect.extents.y2 += priv->attrib.y;
+ x1 += priv->attrib.x;
+ y1 += priv->attrib.y;
+ x2 += priv->attrib.x;
+ y2 += priv->attrib.y;
- XUnionRegion (&rect, priv->region, priv->region);
+ priv->region += CompRect (x1, x2, y1, y2);
}
}
@@ -1516,9 +1512,9 @@ CompWindow::move (int dx, int dy, bool immediate)
priv->geometry.setX (priv->attrib.x);
priv->geometry.setY (priv->attrib.y);
- XOffsetRegion (priv->region, dx, dy);
- if (priv->frameRegion)
- XOffsetRegion (priv->frameRegion, dx, dy);
+ priv->region.translate (dx, dy);
+ if (!priv->frameRegion.isEmpty ())
+ priv->frameRegion.translate (dx, dy);
priv->invisible = WINDOW_INVISIBLE (priv);
@@ -3893,7 +3889,7 @@ WindowInterface::stateChangeNotify (unsigned int lastState)
WRAPABLE_DEF (stateChangeNotify, lastState)
void
-WindowInterface::updateFrameRegion (Region region)
+WindowInterface::updateFrameRegion (CompRegion &region)
WRAPABLE_DEF (updateFrameRegion, region)
Window
@@ -4094,14 +4090,14 @@ PrivateWindow::processMap ()
}
-Region
-CompWindow::region ()
+const CompRegion &
+CompWindow::region () const
{
return priv->region;
}
-Region
-CompWindow::frameRegion ()
+const CompRegion &
+CompWindow::frameRegion () const
{
return priv->frameRegion;
}
@@ -4381,13 +4377,6 @@ CompWindow::CompWindow (Window id,
priv = new PrivateWindow (this);
assert (priv);
- priv->region = XCreateRegion ();
- assert (priv->region);
- priv->frameRegion = XCreateRegion ();
- assert (priv->frameRegion);
-
-
-
/* Failure means that window has been destroyed. We still have to add the
window to the window list as we might get configure requests which
require us to stack other windows relative to it. Setting some default
@@ -4435,21 +4424,10 @@ CompWindow::CompWindow (Window id,
screen->insertWindow (this, aboveId);
- EMPTY_REGION (priv->region);
-
if (windowClass () != InputOnly)
{
- REGION rect;
-
- rect.rects = &rect.extents;
- rect.numRects = rect.size = 1;
-
- rect.extents.x1 = priv->attrib.x;
- rect.extents.y1 = priv->attrib.y;
- rect.extents.x2 = priv->attrib.x + priv->width;
- rect.extents.y2 = priv->attrib.y + priv->height;
-
- XUnionRegion (&rect, priv->region, priv->region);
+ priv->region = CompRegion (priv->attrib.x, priv->attrib.y,
+ priv->width, priv->height);
/* need to check for DisplayModal state on all windows */
priv->state = screen->priv->getWindowState (priv->id);
@@ -4644,7 +4622,7 @@ PrivateWindow::PrivateWindow (CompWindow *window) :
alpha (false),
width (0),
height (0),
- region (0),
+ region (),
wmType (0),
type (CompWindowTypeUnknownMask),
state (0),
@@ -4727,12 +4705,6 @@ PrivateWindow::~PrivateWindow ()
if (frame)
XDestroyWindow (screen->dpy (), frame);
- if (region)
- XDestroyRegion (region);
-
- if (frameRegion)
- XDestroyRegion (frameRegion);
-
if (struts)
free (struts);
@@ -4819,37 +4791,32 @@ CompWindow::mwmFunc ()
void
CompWindow::updateFrameRegion ()
{
- REGION r;
- int x, y;
+ CompRect r;
+ int x, y;
if ((priv->input.left || priv->input.right ||
priv->input.top || priv->input.bottom) && priv->frame)
{
- XSubtractRegion (&emptyRegion, &emptyRegion, priv->frameRegion);
+ priv->frameRegion = CompRegion ();
updateFrameRegion (priv->frameRegion);
- r.numRects = 1;
- r.rects = &r.extents;
- r.extents = priv->region->extents;
- XSubtractRegion (priv->frameRegion, &r, priv->frameRegion);
+ r = priv->region.boundingRect ();
+ priv->frameRegion -= r;
- r.extents.x1 -= priv->input.left;
- r.extents.x2 += priv->input.right;
- r.extents.y1 -= priv->input.top;
- r.extents.y2 += priv->input.bottom;
+ r.setGeometry (r.x1 () - priv->input.left, r.x1 () + priv->input.right,
+ r.y1 () - priv->input.top, r.y2 () + priv->input.bottom);
- XIntersectRegion (priv->frameRegion, &r, priv->frameRegion);
-
- XUnionRegion (priv->frameRegion, priv->region, priv->frameRegion);
+ priv->frameRegion &= CompRegion (r);
x = priv->serverGeometry.x () - priv->input.left;
y = priv->serverGeometry.y () - priv->input.top;
XShapeCombineRegion (screen->dpy (), priv->frame,
- ShapeBounding, -x, -y, priv->frameRegion,
+ ShapeBounding, -x, -y,
+ priv->frameRegion.united (priv->region).handle (),
ShapeSet);
}
}
@@ -4883,7 +4850,7 @@ CompWindow::setWindowFrameExtents (CompWindowExtents *i)
}
void
-CompWindow::updateFrameRegion (Region region)
+CompWindow::updateFrameRegion (CompRegion & region)
WRAPABLE_HND_FUNC(12, updateFrameRegion, region)
bool