summaryrefslogtreecommitdiff
path: root/src/tile.c
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-04-16 15:47:00 +0200
committerDanny Baumann <dannybaumann@web.de>2007-04-16 15:47:00 +0200
commitdbe87a08b1b1e76d8897b47c7454d4013b4e32ac (patch)
treeb30fd87a117cb6acafa9cd460c90d9fd30dc6f26 /src/tile.c
parentf5be415caa085a112636187cae337c999af8c0a7 (diff)
downloadberyl-premerge-dbe87a08b1b1e76d8897b47c7454d4013b4e32ac.tar.gz
beryl-premerge-dbe87a08b1b1e76d8897b47c7454d4013b4e32ac.tar.bz2
Reactive join mode.
Diffstat (limited to 'src/tile.c')
-rw-r--r--src/tile.c210
1 files changed, 114 insertions, 96 deletions
diff --git a/src/tile.c b/src/tile.c
index 953e1c7..fe8f937 100644
--- a/src/tile.c
+++ b/src/tile.c
@@ -355,107 +355,125 @@ static void tileResizeNotify(CompWindow * w, int dx, int dy, int dwidth, int dhe
// Dont do anything if joining is disabled or windows are being resized
if (!tileGetTileJoin(w->screen->display) || ts->isAnimating)
return;
-#if 0
+
+ /* determine previous and next tiled window */
+ CompWindow *prev = NULL, *next = NULL, *cw;
+ Bool windowSeen = FALSE;
+ for (cw = w->screen->reverseWindows; cw; cw = cw->prev)
+ {
+ if (windowSeen)
+ {
+ next = cw;
+ break;
+ }
+ else
+ {
+ if (cw != w)
+ prev = cw;
+ else
+ windowSeen = TRUE;
+ }
+ }
+
switch (ts->tileType)
{
case TileToggleTypeTile:
- if (tw->prev)
- placeWindow(tw->prev,
- tw->prev->attrib.x, tw->prev->attrib.y,
- w->attrib.x - tw->prev->attrib.x - w->input.left - tw->prev->input.right,
- tw->prev->height);
-
- if (tw->next)
- {
- int currentX = w->attrib.x + w->width + w->input.right + tw->next->input.left;
- placeWindow(tw->next, currentX, tw->next->attrib.y,
- tw->next->width + tw->next->attrib.x - currentX, tw->next->height);
- }
- break;
+ if (prev)
+ placeWindow(prev,
+ prev->attrib.x, prev->attrib.y,
+ w->attrib.x - prev->attrib.x - w->input.left - prev->input.right,
+ prev->height);
+
+ if (next)
+ {
+ int currentX = w->attrib.x + w->width + w->input.right + next->input.left;
+ placeWindow(next, currentX, next->attrib.y,
+ next->width + next->attrib.x - currentX, next->height);
+ }
+ break;
- case TileToggleTypeHorizontal:
- if (tw->prev)
- placeWindow(tw->prev,
- tw->prev->attrib.x, tw->prev->attrib.y,
- tw->prev->width,
- w->attrib.y - tw->prev->attrib.y - w->input.top - tw->prev->input.bottom);
-
- if (tw->next)
- {
- int currentY = w->attrib.y + w->height + w->input.bottom + tw->next->input.top;
- placeWindow(tw->next, tw->next->attrib.x, currentY,
- tw->next->width, tw->next->height + tw->next->attrib.y - currentY);
- }
- break;
+ case TileToggleTypeHorizontal:
+ if (prev)
+ placeWindow(prev,
+ prev->attrib.x, prev->attrib.y,
+ prev->width,
+ w->attrib.y - prev->attrib.y - w->input.top - prev->input.bottom);
+
+ if (next)
+ {
+ int currentY = w->attrib.y + w->height + w->input.bottom + next->input.top;
+ placeWindow(next, next->attrib.x, currentY,
+ next->width, next->height + next->attrib.y - currentY);
+ }
+ break;
+ case TileToggleTypeLeft:
+ if (!next && prev && dwidth) // last window - on the left
+ {
+ XRectangle workArea;
+ int currentX;
- case TileToggleTypeLeft:
- if (!tw->next && tw->prev && dwidth) // last window - on the left
- {
- CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
- while (temp)
- {
- TILE_WINDOW(temp);
-
- if (!tw->next)
- break;
-
- XRectangle workArea;
- getWorkareaForOutput(w->screen, w->screen->currentOutputDev, &workArea);
-
- int currentX = workArea.x + w->serverX + w->serverWidth + w->input.right + temp->input.left;
-
- placeWindow(temp, currentX, temp->attrib.y,
- workArea.width - currentX - w->input.right, temp->attrib.height);
-
- temp = tw->next;
- }
- }
- else if (tw->next) // windows on the right
- {
- XRectangle workArea;
- getWorkareaForOutput(w->screen, w->screen->currentOutputDev, &workArea);
-
- CompWindow *temp = THIS_VIEWPORT(w->screen).firstTiled;
- while (temp)
- {
- TILE_WINDOW(temp);
- if (!tw->next) // left window, last window
- {
- placeWindow(temp,
- workArea.x + temp->input.left, temp->attrib.y,
- w->serverX - w->input.left - temp->input.left - temp->input.right - workArea.x,
- temp->attrib.height);
- break;
- }
-
- if (w->id != temp->id)
- {
- int x = temp->attrib.x;
- int y = temp->attrib.y;
- int width = temp->attrib.width;
- int height = temp->attrib.height;
-
- /* tileWindow of the resized window, tw is the tileWindow of temp */
- TileWindow * otw = GET_TILE_WINDOW(w, ts);
-
- if (otw->prev && (temp->id == otw->prev->id))
- height = w->serverY - temp->attrib.y - w->input.top - temp->input.bottom;
- else if (otw->next && (temp->id == otw->next->id))
- y = w->serverY + w->serverHeight + w->input.bottom + temp->input.top;
-
- x = w->serverX;
- width = workArea.width + workArea.x - w->serverX - w->input.right;
-
- placeWindow(temp, x, y, width, height);
- }
- temp = tw->next;
- }
- }
- break;
- default:
- break;
- }
-#endif
+ workArea = w->screen->workArea;
+
+ for (cw = w->screen->windows; cw; cw = cw->next)
+ {
+ TILE_WINDOW(cw);
+
+ if (!tw->isTiled || (cw->id == w->id))
+ continue;
+
+ currentX = workArea.x + w->serverX + w->serverWidth + w->input.right + cw->input.left;
+
+ placeWindow(cw, currentX, cw->attrib.y,
+ workArea.width - currentX - w->input.right, cw->attrib.height);
+ }
+ }
+ else if (next) // windows on the right
+ {
+ XRectangle workArea;
+ Bool first = TRUE;
+
+ workArea = w->screen->workArea;
+
+ for (cw = w->screen->windows; cw; cw = cw->next)
+ {
+ TILE_WINDOW(cw);
+
+ if (!tw->isTiled || (cw->id == w->id))
+ continue;
+
+ if (first)
+ {
+ placeWindow(cw,
+ workArea.x + cw->input.left, cw->attrib.y,
+ w->serverX - w->input.left - cw->input.left - cw->input.right - workArea.x,
+ cw->attrib.height);
+
+ first = FALSE;
+ }
+ else
+ {
+ int x = cw->attrib.x;
+ int y = cw->attrib.y;
+ int width = cw->attrib.width;
+ int height = cw->attrib.height;
+
+ if (prev && (cw->id == prev->id))
+ height = w->serverY - cw->attrib.y - w->input.top - cw->input.bottom;
+ else if (next && (cw->id == next->id))
+ y = w->serverY + w->serverHeight + w->input.bottom + cw->input.top;
+
+ x = w->serverX;
+ width = workArea.width + workArea.x - w->serverX - w->input.right;
+
+ placeWindow(cw, x, y, width, height);
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
}
static Bool tileInitScreen(CompPlugin * p, CompScreen * s)