diff --git a/contents/code/layout.js b/contents/code/layout.js index 3e7a527521005e09c855bf051cee8997db1ac1ab..13efbec0e5f2b539aa036f531b95e4911ffb3f32 100644 --- a/contents/code/layout.js +++ b/contents/code/layout.js @@ -30,35 +30,49 @@ var Direction = { * @class */ function Layout(screenRectangle) { - /** - * Screen area which is used by the layout. - */ - this.screenRectangle = screenRectangle; - /** - * Geometry of the different tiles. This array stays empty in the case of - * floating layouts. - */ - this.tiles = []; - // TODO + try { + /** + * Screen area which is used by the layout. + */ + this.screenRectangle = screenRectangle; + /** + * Geometry of the different tiles. This array stays empty in the case of + * floating layouts. + */ + this.tiles = []; + // TODO + } catch(err) { + print(err, "in Layout"); + } } Layout.prototype.setLayoutArea = function(area) { - var oldArea = this.screenRectangle; - this.screenRectangle = area; - this.onLayoutAreaChange(oldArea, area); + try { + var oldArea = this.screenRectangle; + this.screenRectangle = area; + this.onLayoutAreaChange(oldArea, area); + } catch(err) { + print(err, "in Layout.setLayoutArea"); + } } -Layout.prototype.onLayoutAreaChange = function(oldArea, newArea) { - var xscale = newArea.width / oldArea.width; - var yscale = newArea.height / oldArea.height; - var xoffset = newArea.x - oldArea.x; - var yoffset = newArea.y - oldArea.y; - this.tiles.forEach(function(tile) { - var lastrect = tile.rectangle; - var newrect = Qt.rect(lastrect.x + xoffset, - lastrect.y + yoffset, - lastrect.width * xscale, - lastrect.height * yscale); - tile.rectangle = newrect; - }); +Layout.prototype.onLayoutAreaChange = function(newArea) { + try { + var oldArea = this.screenRectangle; + var xscale = newArea.width / oldArea.width; + var yscale = newArea.height / oldArea.height; + var xoffset = newArea.x - oldArea.x; + var yoffset = newArea.y - oldArea.y; + this.tiles.forEach(function(tile) { + var lastrect = tile.rectangle; + var newrect = Qt.rect(lastrect.x + xoffset, + lastrect.y + yoffset, + lastrect.width * xscale, + lastrect.height * yscale); + tile.rectangle = newrect; + }); + this.screenRectangle = newArea; + } catch(err) { + print(err, "in Layout.onLayoutAreaChange"); + } } diff --git a/contents/code/tiling.js b/contents/code/tiling.js index 0558ed911856545f14ddd9bfede2a0094f5a0936..1dc1eabbc6a0e8b7749efcfba6768057f6a8f2c6 100644 --- a/contents/code/tiling.js +++ b/contents/code/tiling.js @@ -22,36 +22,48 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. * Class which implements tiling for a single screen. * @class */ -function Tiling(screenRectangle, layoutType) { - /** - * Tiles which have been added to the layout - */ - this.tiles = []; - /** - * Layout type which provided the current layout. - */ - this.layoutType = layoutType; - /** - * Layout which specifies window sizes/positions. - */ - this.layout = new layoutType(screenRectangle); - /** - * True if the layout is active. - */ - this.active = false; - - this.screenRectangle = screenRectangle; +function Tiling(screenRectangle, layoutType, desktop, screen) { + try { + /** + * Tiles which have been added to the layout + */ + this.tiles = []; + /** + * Layout type which provided the current layout. + */ + this.layoutType = layoutType; + /** + * Layout which specifies window sizes/positions. + */ + this.layout = new layoutType(screenRectangle); + /** + * True if the layout is active. + */ + this.active = false; + + this.screenRectangle = screenRectangle; + + this.desktop = desktop; + + this.screen = screen; + } catch(err) { + print(err, "in Tiling"); + } } Tiling.prototype.setLayoutType = function(layoutType) { - var newLayout = new layoutType(this.layout.screenRectangle); - for(i = 0; i < this.layout.tiles.length; i++) { - newLayout.addTile(); - this.layout.tiles[i].tileIndex = i; + try { + var newLayout = new layoutType(this.layout.screenRectangle); + for(i = 0; i < this.layout.tiles.length; i++) { + newLayout.addTile(); + this.layout.tiles[i].tileIndex = i; + } + this.layout = newLayout; + this.layoutType = layoutType; + this.layout.resetTileSizes(); + } catch(err) { + print(err, "in Tiling.setLayoutType"); } - this.layout = newLayout; - this.layoutType = layoutType; - this.layout.resetTileSizes(); } Tiling.prototype.setLayoutArea = function(area) { @@ -186,14 +198,21 @@ Tiling.prototype.resizeTile = function(tile){ } Tiling.prototype._updateAllTiles = function() { - // Set the position/size of all tiles - if (this.active) { - for (var i = 0; i < this.layout.tiles.length; i++) { - var newRect = this.layout.tiles[i].rectangle; - if (! newRect) { - return; + try { + // Set the position/size of all tiles + if (this.active) { + var rect = workspace.clientArea(KWin.PlacementArea, this.desktop, this.screen); + this.layout.onLayoutAreaChange(rect); + for (var i = 0; i < this.layout.tiles.length; i++) { + var newRect = this.layout.tiles[i].rectangle; + if (! newRect) { + return; + } + this.tiles[i].setGeometry(newRect); } - this.tiles[i].setGeometry(newRect); } + } catch(err) { + print(err, "in Tiling._updateAllTiles"); } + } diff --git a/contents/code/tilingmanager.js b/contents/code/tilingmanager.js index 69a395243b85b2a8ead50473bb9a804ef0da2d6a..c2ceb594bd3e0afa3ebdb41504d37c9164d54c85 100644 --- a/contents/code/tilingmanager.js +++ b/contents/code/tilingmanager.js @@ -254,6 +254,7 @@ function TilingManager() { */ TilingManager.getTilingArea = function(desktop, screen) { // TODO: Should this function be moved to Layout? + return workspace.clientArea(KWin.PlacementArea, screen, desktop); return workspace.clientArea(KWin.MaximizeArea, screen, desktop); }; @@ -261,7 +262,7 @@ TilingManager.prototype._createDefaultLayouts = function(desktop) { var screenLayouts = []; for (var j = 0; j < this.screenCount; j++) { var area = TilingManager.getTilingArea(desktop, j); - screenLayouts[j] = new Tiling(area, this.defaultLayout); + screenLayouts[j] = new Tiling(area, this.defaultLayout, desktop, j); } this.layouts[desktop] = screenLayouts; }; @@ -344,7 +345,7 @@ TilingManager.prototype._onNumberScreensChanged = function() { for (var i = 0; i < this.desktopCount; i++) { for (var j = this.screenCount; j < workspace.numScreens; j++) { var area = TilingManager.getTilingArea(i, j); - this.layouts[i][j] = new Tiling(area, this.defaultLayout); + this.layouts[i][j] = new Tiling(area, this.defaultLayout, i, j); // Activate the new layout if necessary if (i == workspace.currentDesktop - 1) { this.layouts[i][j].activate();