Select Git revision
halflayout.js 7.09 KiB
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Fabian Homborg <FHomborg@gmail.com>
based on spirallayout.js by Matthias Gottschlag
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
/**
* Class which arranges the windows in a spiral with the largest window filling
* the left half of the screen.
*/
function HalfLayout(screenRectangle) {
print("Creating HalfLayout");
Layout.call(this, screenRectangle);
this.firstWidth = this.screenRectangle.width / 2;
this.master = 0;
};
HalfLayout.name = "Half";
// TODO: Add an image for the layout switcher
HalfLayout.image = null;
HalfLayout.prototype = new Layout();
HalfLayout.prototype.constructor = HalfLayout;
HalfLayout.prototype.resetTileSizes = function() {
try {
// Simply erase all tiles and recreate them to recompute the initial sizes
var tileCount = this.tiles.length;
this.tiles.length = 0;
for (var i = 0; i < tileCount; i++) {
this.addTile();
}
} catch(err) {
print(err, "in HalfLayout.resetTileSizes");
}
};
HalfLayout.prototype.addTile = function() {
try {
if (this.tiles.length == 0) {
// The first tile fills the whole screen
var rect = util.copyRect(this.screenRectangle);
this._createTile(rect);
return;
}
if (this.tiles.length == 1) {
// The second tile fills the right half of the screen
// Also, javascript sucks
var firstRect = util.copyRect(this.tiles[0].rectangle);
firstRect.width = this.firstWidth;
this.tiles[0].rectangle = firstRect;
var newRect = new Qt.rect(firstRect.x + firstRect.width,
firstRect.y,
this.screenRectangle.width - firstRect.width,
firstRect.height)