summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-11-11 13:25:48 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-11 13:25:48 +0800
commit824f11e91c755402b915a8f6fd68afd29ebf07a3 (patch)
tree758d6a62b9f7b0c1a24309074b76869a3677f484
parent0ab19e8fb13ba06511cebb49320e72479a4e1747 (diff)
downloadwall-824f11e91c755402b915a8f6fd68afd29ebf07a3.tar.gz
wall-824f11e91c755402b915a8f6fd68afd29ebf07a3.tar.bz2
Don't update edge regions on every poll. Instead only do them on screen size change
-rw-r--r--src/wall.cpp51
-rw-r--r--src/wall.h3
2 files changed, 34 insertions, 20 deletions
diff --git a/src/wall.cpp b/src/wall.cpp
index 7300f99..fb2f66c 100644
--- a/src/wall.cpp
+++ b/src/wall.cpp
@@ -518,6 +518,13 @@ WallScreen::handleEvent (XEvent *event)
else if (event->xfocus.mode == NotifyUngrab)
poller.stop ();
break;
+
+ case ConfigureNotify:
+
+ if (event->xconfigure.window == screen->root ())
+ updateScreenEdgeRegions ();
+
+ break;
}
screen->handleEvent (event);
@@ -526,20 +533,15 @@ WallScreen::handleEvent (XEvent *event)
/*
* Borrowed this from PrivateScreen::updateScreenEdges
*
- * FIXME: This is really expensive
- *
*/
#define SCREEN_EDGE_NUM 8
void
-WallScreen::positionUpdate (const CompPoint &pos)
+WallScreen::updateScreenEdgeRegions ()
{
- CompRegion noEdgeRegion (0, 0, screen->width (), screen->height ());
- CompRegion allEdgeRegion (0, 0, screen->width (), screen->height ());
-
- if (edgeDrag)
- return;
+ edgeRegion = CompRegion (0, 0, screen->width (), screen->height ());
+ noEdgeRegion = CompRegion (0, 0, screen->width (), screen->height ());
struct screenEdgeGeometry {
int xw, x0;
@@ -559,21 +561,30 @@ WallScreen::positionUpdate (const CompPoint &pos)
for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)
{
- CompRegion edgeRegion (geometry[i].xw * screen->width () +
- geometry[i].x0,
- geometry[i].yh * screen->height () +
- geometry[i].y0,
- geometry[i].ww * screen->width () +
- geometry[i].w0,
- geometry[i].hh * screen->height () +
- geometry[i].h0);
+ CompRegion edge (geometry[i].xw * screen->width () +
+ geometry[i].x0,
+ geometry[i].yh * screen->height () +
+ geometry[i].y0,
+ geometry[i].ww * screen->width () +
+ geometry[i].w0,
+ geometry[i].hh * screen->height () +
+ geometry[i].h0);
noEdgeRegion -= edgeRegion;
}
- allEdgeRegion -= noEdgeRegion;
+ edgeRegion -= noEdgeRegion;
+}
- if (allEdgeRegion.contains (pos))
+#undef SCREEN_EDGE_NUM
+
+void
+WallScreen::positionUpdate (const CompPoint &pos)
+{
+ if (edgeDrag)
+ return;
+
+ if (edgeRegion.contains (pos))
toggleEdges (false);
else if (noEdgeRegion.contains (pos))
{
@@ -583,8 +594,6 @@ WallScreen::positionUpdate (const CompPoint &pos)
}
}
-#undef SCREEN_EDGE_NUM
-
void
WallWindow::activate ()
{
@@ -1695,6 +1704,8 @@ WallScreen::WallScreen (CompScreen *screen) :
setNotify (NoSlideMatch);
setNotify (EdgeflipPointer);
+ updateScreenEdgeRegions ();
+
poller.setCallback (boost::bind (&WallScreen::positionUpdate, this,
_1));
}
diff --git a/src/wall.h b/src/wall.h
index b0f3d7f..9093acd 100644
--- a/src/wall.h
+++ b/src/wall.h
@@ -122,6 +122,7 @@ class WallScreen :
void toggleEdges (bool);
void positionUpdate (const CompPoint &pos);
+ void updateScreenEdgeRegions ();
CompositeScreen *cScreen;
GLScreen *glScreen;
@@ -167,6 +168,8 @@ class WallScreen :
MousePoller poller;
bool edgeDrag;
+ CompRegion edgeRegion;
+ CompRegion noEdgeRegion;
};
class WallWindow :