summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-02-22 18:07:33 +0900
committerSam Spilsbury <smspillaz@gmail.com>2009-02-22 18:07:33 +0900
commit6417e068279c42bd61d9427da54dd83e7049e592 (patch)
treedde7381886e7537598535eb4d371937974c03c81
parent528435cafc07a61e1d00d24df6092d25b5c5a963 (diff)
downloadtile-6417e068279c42bd61d9427da54dd83e7049e592.tar.gz
tile-6417e068279c42bd61d9427da54dd83e7049e592.tar.bz2
Fix vertical and horizontal tile border calculations. Also drop in some code that should allow us to restore windows that cannot be resized to the size specified (currently not working)
-rw-r--r--tile.cpp83
-rw-r--r--tile.h8
2 files changed, 74 insertions, 17 deletions
diff --git a/tile.cpp b/tile.cpp
index 7a9fceb..bd0b18c 100644
--- a/tile.cpp
+++ b/tile.cpp
@@ -306,8 +306,37 @@ 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
+ */
+
+ if (window->x () == tiler->current.x () &&
+ window->y () == tiler->current.y () &&
+ window->width () == tiler->current.width () &&
+ window->height () == tiler->current.height ())
+ {
+ 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 ();
+ }
+
alreadyResized = true;
- return;
}
#if 0
//WE WILL MOVE THIS TO A DIFFERENT PLUGIN
@@ -563,24 +592,34 @@ TileWindow::is ()
{
TILE_SCREEN (screen);
+ /* Check the exclude match */
if (ts->optionGetExcludeMatch ().evaluate (window))
return false;
+ /* We never touch override redirect windows */
if (window->overrideRedirect ())
return false;
+ /* We don't tile windows that we can't focus */
if (!window->focus ())
return false;
+ /* Never mess with docks or desktops */
if (window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
return false;
+ /* Don't tile dialog windows or windows that skip the pager */
if (window->state () & CompWindowStateSkipPagerMask)
return false;
+ /* We can't tile minimized or non placed windows */
if (window->minimized () || !window->placed ())
return false;
+ /* This window was tiled, and we are re-tiling so do not tile it again */
+ if (skipReTile)
+ return false;
+
return true;
}
@@ -622,7 +661,7 @@ Tiler::configure (CompWindow *w,
if (type == TileScreen::Restore)
{
if (maximized)
- w->maximize (savedMaxState); // ???
+ w->maximize (savedMaxState);
}
else
w->maximize (0);
@@ -646,9 +685,7 @@ Tiler::configure (CompWindow *w,
}
void
-TileScreen::restoreTile (CompWindowExtents &border,
- XRectangle &workArea,
- int count)
+TileScreen::restoreTile ()
{
foreach (CompWindow *w, screen->windows ())
{
@@ -659,6 +696,7 @@ TileScreen::restoreTile (CompWindowExtents &border,
tw->tiler->saved.width (), tw->tiler->saved.height ());
/* We must configure here as we remove the tiler object */
tw->tiler->configure (w, TileScreen::Restore);
+ tw->window->resizeNotifySetEnabled (tw, false);
tilers.remove (tw->tiler);
delete tw->tiler;
tw->tiler = NULL;
@@ -719,7 +757,7 @@ TileScreen::horizontalTile (CompWindowExtents &border,
int count)
{
int winWidth = workArea.width;
- int winHeight = workArea.height / count;
+ int winHeight = workArea.height / (count);
int x = workArea.x;
int i = 0;
@@ -732,7 +770,7 @@ TileScreen::horizontalTile (CompWindowExtents &border,
tw->placeWin (x + border.left,
workArea.y + border.top +
- (i * (winHeight - (border.top + border.bottom))),
+ (i * (winHeight - (border.bottom))),
winWidth - (border.left + border.right),
winHeight - (border.top + border.bottom));
@@ -745,7 +783,7 @@ TileScreen::verticalTile (CompWindowExtents &border,
XRectangle &workArea,
int count)
{
- int winWidth = workArea.width / count;
+ int winWidth = workArea.width / (count);
int winHeight = workArea.height;
int y = workArea.y;
int i = 0;
@@ -758,7 +796,7 @@ TileScreen::verticalTile (CompWindowExtents &border,
continue;
tw->placeWin (workArea.x + border.left
- + (i * (winWidth - (border.left + border.right))),
+ + (i * (winWidth - (border.right))),
y + border.top,
winWidth - (border.left + border.right),
winHeight - (border.top + border.bottom));
@@ -830,10 +868,7 @@ TileScreen::cascadeTile (CompWindowExtents &border,
}
bool
-TileScreen::applyTiling (CompAction *action,
- CompAction::State state,
- CompOption::Vector options,
- TileScreen::TileType type)
+TileScreen::chooseTileModeAndTile ()
{
int count = 0;
XRectangle workArea;
@@ -861,6 +896,7 @@ TileScreen::applyTiling (CompAction *action,
{
tw->tiler = new Tiler;
tw->tiler->save (w);
+ tw->window->resizeNotifySetEnabled (tw, true);
}
count++;
@@ -869,7 +905,7 @@ TileScreen::applyTiling (CompAction *action,
if (type == Restore)
{
- restoreTile (border, workArea, count);
+ restoreTile ();
return true;
}
@@ -914,6 +950,24 @@ TileScreen::applyTiling (CompAction *action,
return true;
}
+bool
+TileScreen::applyTiling (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector options,
+ TileScreen::TileType a_type)
+{
+ type = a_type;
+
+ /* Reset on action */
+ foreach (CompWindow *w, screen->windows ())
+ {
+ TILE_WINDOW (w);
+ tw->skipReTile = false;
+ }
+
+ return chooseTileModeAndTile ();
+}
+
#if 0
/* Applies tiling/restoring */
static bool
@@ -1140,6 +1194,7 @@ TileWindow::TileWindow (CompWindow *window) :
time (0),
alreadyResized (false),
needConfigure (false),
+ skipReTile (false),
tiler (NULL)
{
WindowInterface::setHandler (window, false);
diff --git a/tile.h b/tile.h
index 5ed6faa..5c372bd 100644
--- a/tile.h
+++ b/tile.h
@@ -114,9 +114,7 @@ class TileScreen :
/* Tiling modes */
void
- restoreTile (CompWindowExtents &border,
- XRectangle &workArea,
- int count);
+ restoreTile ();
void
squareTile (CompWindowExtents &border,
@@ -156,6 +154,9 @@ class TileScreen :
/* Actions */
bool
+ chooseTileModeAndTile ();
+
+ bool
applyTiling (CompAction *action,
CompAction::State state,
CompOption::Vector options,
@@ -220,6 +221,7 @@ class TileWindow :
bool alreadyResized;
bool needConfigure;
+ bool skipReTile;
Tiler *tiler;