summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-10-27 01:10:58 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-10-27 01:10:58 +0800
commita38a012718751079fa93566209bf524148e962cc (patch)
tree15553598fda5fa1fffaacd14c58ee5d11c09082f
parent01416eda59a635fc9c1fc03c7d94024881d76489 (diff)
downloadtiles-a38a012718751079fa93566209bf524148e962cc.tar.gz
tiles-a38a012718751079fa93566209bf524148e962cc.tar.bz2
Make tiles adjust correctly when a tiled window is closedHEADmaster
-rw-r--r--src/tiles.cpp39
-rw-r--r--src/tiles.h11
2 files changed, 48 insertions, 2 deletions
diff --git a/src/tiles.cpp b/src/tiles.cpp
index 3b425ac..fd392ac 100644
--- a/src/tiles.cpp
+++ b/src/tiles.cpp
@@ -71,6 +71,8 @@ Tile::allocateWindow (CompWindow *w)
priv->mSaveGeometry = priv->mWindow->serverGeometry ();
priv->mSaveMask = CWWidth | CWHeight;
+ TilesWindow::get (priv->mWindow)->assignTile (ptr ());
+
return true;
}
@@ -329,6 +331,12 @@ Tile::ungrab ()
priv->mDragBuffer = CompPoint ();
}
+TileLayer::Ptr
+Tile::layer ()
+{
+ return priv->mParent;
+}
+
void
TileLayer::handleWindowGrabbed (CompWindow *w)
{
@@ -603,7 +611,7 @@ TileLayer::tilesToRegion (std::vector <Tile::Ptr> tiles,
bool
TileLayer::addWindow (CompWindow *w, CompRect &r)
{
- Tile::Ptr t = Tile::Ptr (new Tile (shared_from_this ()));
+ Tile::Ptr t = Tile::Ptr (new Tile (ptr ()));
std::vector <Tile::Ptr> intersectingTiles;
CompRegion intersectingTilesRegion;
CompRegion insertRegion (r);
@@ -676,6 +684,7 @@ TileLayer::removeWindow (CompWindow *w)
{
if ((*tpit)->window () == w)
{
+ TilesWindow::get (w)->releaseTile ();
priv->mTiles.erase (tpit);
break;
}
@@ -783,6 +792,18 @@ TileLayer::~TileLayer ()
delete priv;
}
+bool
+TilesWindow::assignTile (Tile::Ptr tp)
+{
+ priv->mTile = tp;
+}
+
+void
+TilesWindow::releaseTile ()
+{
+ priv->mTile.reset ();
+}
+
void
TilesWindow::grabNotify (int x, int y, unsigned int state, unsigned int mask)
{
@@ -918,6 +939,19 @@ TilesWindow::damageRect (bool initial, const CompRect &rect)
return ret;
}
+void
+TilesWindow::windowNotify(CompWindowNotify n)
+{
+ switch (n)
+ {
+ case CompWindowNotifyClose:
+ if (priv->mTile)
+ priv->mTile->layer ()->removeWindow (priv->window);
+ }
+
+ priv->window->windowNotify (n);
+}
+
bool
TilesWindow::animate(unsigned int ms)
{
@@ -977,7 +1011,8 @@ TilesScreen::removeGrabbedWindow (TilesWindow *tw)
if (rit != priv->mResizedWindows.end ())
priv->mResizedWindows.erase (rit);
- if (priv->mResizedWindows.empty ())
+ if (priv->mResizedWindows.empty () &&
+ !priv->mTileLayers.empty ())
{
for (const Tile::Ptr &tp : priv->mTileLayers.front ()->tiles ())
tp->lockTargetSize ();
diff --git a/src/tiles.h b/src/tiles.h
index 0d30bb6..e3c3d27 100644
--- a/src/tiles.h
+++ b/src/tiles.h
@@ -99,7 +99,12 @@ class Tile :
bool drag (CompPoint &p);
void ungrab ();
+ TileLayerPtr layer ();
+
typedef boost::shared_ptr<Tile> Ptr;
+
+ Ptr ptr () { return shared_from_this (); }
+
private:
PrivateTile *priv;
@@ -143,6 +148,8 @@ class TileLayer :
typedef TileLayerPtr Ptr;
+ Ptr ptr () { return shared_from_this (); }
+
protected:
bool tilesToRegion (std::vector <Tile::Ptr> tiles,
@@ -187,11 +194,15 @@ class TilesWindow :
bool glPaint (const GLWindowPaintAttrib &attrib, const GLMatrix &matrix,
const CompRegion &region, unsigned int mask);
bool damageRect (bool initial, const CompRect &rect);
+ void windowNotify (CompWindowNotify n);
bool animate (unsigned int ms);
void damage ();
+ bool assignTile (Tile::Ptr tp);
+ void releaseTile ();
+
CompWindow * window () { return priv->window; } // XXX
private: