summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tiles.cpp106
1 files changed, 99 insertions, 7 deletions
diff --git a/src/tiles.cpp b/src/tiles.cpp
index 86b279f..3b425ac 100644
--- a/src/tiles.cpp
+++ b/src/tiles.cpp
@@ -162,19 +162,99 @@ TileLayer::handleWindowResize (CompWindow *window, int x, int y, int width, int
if (tpit != priv->mTiles.end ())
{
- Tile::Ptr rtp = *tpit;
+ std::vector <Tile::Ptr> edgeTiles = { *tpit };
CompRegion reg = CompRegion (x - window->border ().left,
y - window->border ().top,
width + (window->border ().left + window->border ().right),
height + (window->border ().top + window->border ().bottom));
CompRect r = reg.boundingRect ();
- CompRect old = rtp->rect ();
+ CompRegion old = edgeTiles.front ()->rect ();
+
+ /* If this tile shares an edge with other tiles
+ * and that edge would not be shared after the resize
+ * operation occurrs, resize the other tiles too
+ * such that the edge will remain shared and add
+ * them to the "reserved" region */
+
+ for (Tile::Ptr stp : priv->mTiles)
+ {
+ if (stp->rect ().left () == edgeTiles.front ()->rect ().left () &&
+ stp->rect ().left () != r.left ())
+ {
+ CompRect nr = stp->rect ();
+ CompRegion tOld = stp->rect ();
+
+ nr.setLeft (r.left ());
+
+ if (!stp->setTargetSize (nr))
+ continue;
+ else
+ {
+ old += tOld;
+ reg += nr;
+ edgeTiles.push_back (stp);
+ }
+ }
+ else if (stp->rect ().right () == edgeTiles.front ()->rect ().right () &&
+ stp->rect ().right () != r.right ())
+ {
+ CompRect nr = stp->rect ();
+ CompRegion tOld = stp->rect ();
+
+ nr.setRight (r.right ());
+
+ if (!stp->setTargetSize (nr))
+ continue;
+ else
+ {
+ old += tOld;
+ reg += nr;
+ edgeTiles.push_back (stp);
+ }
+ }
+ else if (stp->rect ().top () == edgeTiles.front ()->rect ().top () &&
+ stp->rect ().top () != r.top ())
+ {
+ CompRect nr = stp->rect ();
+ CompRegion tOld = stp->rect ();
+
+ nr.setTop (r.top ());
+
+ if (!stp->setTargetSize (nr))
+ continue;
+ else
+ {
+ old += tOld;
+ reg += nr;
+ edgeTiles.push_back (stp);
+ }
+ }
+ else if (stp->rect ().bottom () == edgeTiles.front ()->rect ().bottom () &&
+ stp->rect ().bottom () != r.bottom ())
+ {
+ CompRect nr = stp->rect ();
+ CompRegion tOld = stp->rect ();
+
+ nr.setBottom (r.bottom ());
+
+ if (!stp->setTargetSize (nr))
+ continue;
+ else
+ {
+ old += tOld;
+ reg += nr;
+ edgeTiles.push_back (stp);
+ }
+ }
+ }
/* Allocate a new space for this window
* and change the target size of other windows */
- if (!rtp->setTargetSize (r))
+ if (!edgeTiles.front ()->setTargetSize (r))
return;
+ r = reg.boundingRect ();
+
CompRegion insertRegion = reg;
CompRegion intersectingTilesRegion;
std::vector <Tile::Ptr> intersectingTiles;
@@ -187,13 +267,25 @@ TileLayer::handleWindowResize (CompWindow *window, int x, int y, int width, int
/* Now reallocate the other tiles that intersect this one */
for (Tile::Ptr tp : priv->mTiles)
{
- if (tp == rtp)
+ CompRegion intersection;
+ bool isEdgeTile = false;
+
+ for (Tile::Ptr setp : edgeTiles)
{
- intersectingTilesRegion += old;
- continue;
+ if (tp == setp)
+ {
+ intersectingTilesRegion += old;
+ isEdgeTile = true;
+ break;
+ }
}
- if ((CompRegion (tp->rect ()).intersected (insertRegion)) == CompRegion (tp->rect ()))
+ if (isEdgeTile)
+ continue;
+
+ intersection = (CompRegion (tp->rect ()).intersected (insertRegion));
+
+ if (intersection == CompRegion (tp->rect ()))
{
intersectingTiles.push_back (tp);
intersectingTilesRegion += tp->rect ();