summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-02-22 20:48:01 +0900
committerSam Spilsbury <smspillaz@gmail.com>2009-02-22 20:48:01 +0900
commit9c7b694815ec129564de0d6aa07dbf08643c4353 (patch)
tree485955c47d1ac486bd9c397c4adc3454b8c53c63
parentfa148a307c307650ce5626d602db3c54daf7fcea (diff)
downloadtile-9c7b694815ec129564de0d6aa07dbf08643c4353.tar.gz
tile-9c7b694815ec129564de0d6aa07dbf08643c4353.tar.bz2
Fix zero division error and save/restore maximized windows
-rw-r--r--tile.cpp71
-rw-r--r--tile.h1
2 files changed, 48 insertions, 24 deletions
diff --git a/tile.cpp b/tile.cpp
index 40dabd2..2a11849 100644
--- a/tile.cpp
+++ b/tile.cpp
@@ -306,37 +306,54 @@ TileWindow::resizeNotify (int dx,
if (!alreadyResized)
{
- /* Check to see if the window was tiled correctly:
- * some windows have minimum sizes, this messes up
- * tiling, so if this is the case, move and resize
- * other windows
+ /* A window was maximized but this resizeNotify
+ * is for the window unmaximizing. Position
+ * the window again and don't set
+ * the alreadyResized flag
*/
- if (window->x () == tiler->current.x () &&
- window->y () == tiler->current.y () &&
- window->width () == tiler->current.width () &&
- window->height () == tiler->current.height ())
+ if (tiler && tiler->maximized && !tiler->maxClean)
{
- skipReTile = false;
+ TILE_SCREEN (screen);
+ tiler->maxClean = true;
+ ts->chooseTileModeAndTile ();
}
else
{
- TILE_SCREEN (screen);
- skipReTile = true;
- /* Restore the window */
- placeWin (tiler->saved.x (), tiler->saved.y (),
- tiler->saved.width (), tiler->saved.height ());
- /* We must configure here as we remove the tiler object */
- tiler->configure (window, TileScreen::Restore);
- ts->tilers.remove (tiler);
- delete tiler;
- tiler = NULL;
- window->resizeNotifySetEnabled (this, false);
+ alreadyResized = true;
- ts->chooseTileModeAndTile ();
- }
+ /* Check to see if the window was tiled correctly:
+ * some windows have minimum sizes, this messes up
+ * tiling, so if this is the case, move and resize
+ * other windows
+ */
- alreadyResized = true;
+ if (tiler &&
+ (window->x () == tiler->current.x () &&
+ window->y () == tiler->current.y () &&
+ window->width () == tiler->current.width () &&
+ window->height () == tiler->current.height () &&
+ tiler->maxClean))
+ {
+ skipReTile = false;
+ }
+ else
+ {
+ TILE_SCREEN (screen);
+ skipReTile = true;
+ /* Restore the window */
+ placeWin (tiler->saved.x (), tiler->saved.y (),
+ tiler->saved.width (), tiler->saved.height ());
+ /* We must configure here as we remove the tiler object */
+ tiler->configure (window, TileScreen::Restore);
+ ts->tilers.remove (tiler);
+ delete tiler;
+ tiler = NULL;
+ window->resizeNotifySetEnabled (this, false);
+
+ ts->chooseTileModeAndTile ();
+ }
+ }
}
#if 0
//WE WILL MOVE THIS TO A DIFFERENT PLUGIN
@@ -626,6 +643,7 @@ TileWindow::is ()
Tiler::Tiler () :
state (Tiler::NotTiled),
maximized (false),
+ maxClean (true),
savedMaxState (0)
{
TILE_SCREEN (screen);
@@ -641,6 +659,8 @@ Tiler::save (CompWindow *w)
maximized = w->state () & MAXIMIZE_STATE;
savedMaxState = w->state () & MAXIMIZE_STATE;
+
+ maxClean = !(w->state () & MAXIMIZE_STATE);
}
bool
@@ -658,7 +678,7 @@ Tiler::configure (CompWindow *w,
xwc.width = current.width ();
xwc.height = current.height ();
- if (type == TileScreen::Restore)
+ if (TileScreen::get(screen)->type == TileScreen::Restore)
{
if (maximized)
w->maximize (savedMaxState);
@@ -903,6 +923,9 @@ TileScreen::chooseTileModeAndTile ()
}
}
+ if (!count)
+ type = Restore;
+
if (type == Restore)
{
restoreTile ();
diff --git a/tile.h b/tile.h
index 5c372bd..4540626 100644
--- a/tile.h
+++ b/tile.h
@@ -187,6 +187,7 @@ class Tiler
State state;
bool maximized;
+ bool maxClean;
int savedMaxState;
CompRect saved;