diff options
author | Sam Spilsbury <sam.spilsbury@canonical.com> | 2010-11-11 13:11:46 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2010-11-11 13:11:46 +0800 |
commit | 0ab19e8fb13ba06511cebb49320e72479a4e1747 (patch) | |
tree | 499b3d85bd3fa5613eb5ec2cb126df74cb08849d | |
parent | 6ddb4b7f3cd390ce09500dbd373faa518272d9a6 (diff) | |
download | wall-0ab19e8fb13ba06511cebb49320e72479a4e1747.tar.gz wall-0ab19e8fb13ba06511cebb49320e72479a4e1747.tar.bz2 |
Be a little bit smarter about dynamically enabling and disabling edge actions
-rw-r--r-- | src/wall.cpp | 49 | ||||
-rw-r--r-- | src/wall.h | 3 |
2 files changed, 49 insertions, 3 deletions
diff --git a/src/wall.cpp b/src/wall.cpp index 187f36b..7300f99 100644 --- a/src/wall.cpp +++ b/src/wall.cpp @@ -501,6 +501,23 @@ WallScreen::handleEvent (XEvent *event) moveViewport (-dx, -dy, None); } + if (event->xclient.message_type == Atoms::xdndEnter) + { + toggleEdges (true); + edgeDrag = true; + } + else if (event->xclient.message_type == Atoms::xdndLeave) + edgeDrag = false; + + break; + + case FocusIn: + case FocusOut: + if (event->xfocus.mode == NotifyGrab) + poller.start (); + else if (event->xfocus.mode == NotifyUngrab) + poller.stop (); + break; } screen->handleEvent (event); @@ -519,8 +536,9 @@ void WallScreen::positionUpdate (const CompPoint &pos) { CompRegion noEdgeRegion (0, 0, screen->width (), screen->height ()); + CompRegion allEdgeRegion (0, 0, screen->width (), screen->height ()); - if (screen->grabbed ()) + if (edgeDrag) return; struct screenEdgeGeometry { @@ -553,9 +571,14 @@ WallScreen::positionUpdate (const CompPoint &pos) noEdgeRegion -= edgeRegion; } - if (noEdgeRegion.contains (pos)) + allEdgeRegion -= noEdgeRegion; + + if (allEdgeRegion.contains (pos)) + toggleEdges (false); + else if (noEdgeRegion.contains (pos)) { - poller.stop (); + if (!screen->grabbed ()) + poller.stop (); toggleEdges (true); } } @@ -590,6 +613,26 @@ WallWindow::activate () } void +WallWindow::grabNotify (int x, + int y, + unsigned int width, + unsigned int height) +{ + WallScreen::get (screen)->toggleEdges (true); + WallScreen::get (screen)->edgeDrag = true; + + window->grabNotify (x, y, width, height); +} + +void +WallWindow::ungrabNotify () +{ + WallScreen::get (screen)->edgeDrag = false; + + window->ungrabNotify (); +} + +void WallScreen::checkAmount (int dx, int dy, int &amountX, @@ -166,6 +166,7 @@ class WallScreen : WallCairoContext arrowContext; MousePoller poller; + bool edgeDrag; }; class WallWindow : @@ -177,6 +178,8 @@ class WallWindow : WallWindow (CompWindow *); virtual void activate (); + void grabNotify (int, int, unsigned int, unsigned int); + void ungrabNotify (); bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &, const CompRegion &, unsigned int); |