diff --git a/contents/code/spirallayout.js b/contents/code/spirallayout.js index aeef8a62db0e865f9e87b1f820ed67fdf5dc3ff9..9308e9e933897fbcaa3af1e938801b3c429f08fb 100644 --- a/contents/code/spirallayout.js +++ b/contents/code/spirallayout.js @@ -121,7 +121,55 @@ SpiralLayout.prototype.removeTile = function(tileIndex) { } SpiralLayout.prototype.resizeTile = function(tileIndex, rectangle) { - // TODO + print("SpiralLayout.resizeTile"); + if (tileIndex < 0 || tileIndex > this.tiles.length) { + print("Tileindex invalid", tileIndex, "/", this.tiles.length); + return; + } + var tile = this.tiles[tileIndex]; + if (tile == null) { + print("No tile"); + return; + } + if (rectangle == null){ + print("No rect"); + return; + } + // Cap rectangle at screenedges + if (rectangle.x < this.screenRectangle.x) { + rectangle.x = this.screenRectangle.x; + } + if (rectangle.y < this.screenRectangle.y) { + rectangle.y = this.screenRectangle.y; + } + if (rectangle.y + rectangle.height > this.screenRectangle.y + this.screenRectangle.height) { + rectangle.height = this.screenRectangle.y + this.screenRectangle.height - rectangle.y; + } + if (rectangle.x + rectangle.width > this.screenRectangle.x + this.screenRectangle.width) { + rectangle.width = this.screenRectangle.x + this.screenRectangle.width - rectangle.x; + } + + // HACK: The only case I know how to do + var oldrect = tile.rectangle; + if (this.tiles.length == 2) { + rectangle.height = oldrect.height; + rectangle.y = oldrect.y; + if (tileIndex == 0) { + var other = this.tiles[1]; + var otherrect = other.rectangle; + otherrect.x = rectangle.x + rectangle.width; + otherrect.width = this.screenRectangle.x + this.screenRectangle.width - otherrect.x; + other.rectangle = otherrect; + } else { + var other = this.tiles[0]; + var otherrect = other.rectangle; + otherrect.width = (rectangle.x - otherrect.x); + other.rectangle = otherrect; + } + tile.rectangle = rectangle; + } else { + // FIXME: This is _hard_. + } } SpiralLayout.prototype._createTile = function(rect) { diff --git a/contents/code/tile.js b/contents/code/tile.js index 9262e195b5dae2244449d36841e2bab90905a7f1..390f3fb790f5a05d2473e7580dfe5f1fb3698b4e 100644 --- a/contents/code/tile.js +++ b/contents/code/tile.js @@ -252,9 +252,11 @@ Tile.prototype.onClientDesktopChanged = function(client) { }; Tile.prototype.onClientStartUserMovedResized = function(client) { + /* // We want to distinguish between moving and resizing, so we have to wait // for the first geometry change this._lastGeometry = client.geometry; + */ }; Tile.prototype.onClientStepUserMovedResized = function(client) { diff --git a/contents/code/tiling.js b/contents/code/tiling.js index a20a46de32ceb25b31af024c859668c63aa16f7b..f6115408ca4d237d38fb7bd194aaf7f1350854bd 100644 --- a/contents/code/tiling.js +++ b/contents/code/tiling.js @@ -183,6 +183,15 @@ Tiling.prototype.getAdjacentTile = function(from, direction, directOnly) { } } +Tiling.prototype.resizeTile = function(tile){ + if (tile != null) { + var tileIndex = this.tiles.indexOf(tile); + var client = tile.clients[0]; + this.layout.resizeTile(tileIndex, client.geometry); + this._updateAllTiles(); + } +} + Tiling.prototype._updateAllTiles = function() { // Set the position/size of all tiles if (this.active) { diff --git a/contents/code/tilingmanager.js b/contents/code/tilingmanager.js index 93042c35eea9f46556c9bb4c0ac65fe698d6687a..4ec53db2fbc10a8db8bef03a68b389d145e452c7 100644 --- a/contents/code/tilingmanager.js +++ b/contents/code/tilingmanager.js @@ -88,9 +88,6 @@ function TilingManager() { */ this._movingStartScreen = 0; - //STUB: Resizing tiles - this._resizing = false; - var self = this; // Read the script settings // TODO (this is currently not supported by kwin) @@ -289,6 +286,9 @@ TilingManager.prototype._onTileAdded = function(tile) { var tileLayouts = this._getLayouts(client.desktop, client.screen); tileLayouts.forEach(function(layout) { layout.addTile(tile); + tile.resizingEnded.connect(function() { + layout.resizeTile(tile); + }); }); };