set noBorder based on state, not manually

this fixes a regression bug where noBorder state is messed up.
This commit is contained in:
Eon S. Jeon 2020-01-02 09:43:03 +09:00
parent 661c789ab5
commit a690906507
6 changed files with 46 additions and 55 deletions

View File

@ -46,14 +46,6 @@ enum Shortcut {
SetLayout,
}
enum WindowState {
Tile,
FreeTile,
Float,
FullScreen,
Unmanaged,
}
//#region Driver
interface IConfig {

View File

@ -109,8 +109,7 @@ class TilingEngine {
const tileables = this.windows.getVisibleTileables(srf);
if (CONFIG.maximizeSoleTile && tileables.length === 1) {
tileables[0].state = WindowState.Tile;
tileables[0].noBorder = true;
tileables[0].state = WindowState.FullTile;
tileables[0].geometry = workingArea;
} else if (tileables.length > 0)
layout.apply(new EngineContext(ctx, this), tileables, tilingArea);

View File

@ -18,8 +18,31 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
enum WindowState {
Tile,
FullTile,
FloatTile,
Float,
FullScreen,
Unmanaged,
}
class Window {
/* read-only */
public static isTileableState(state: WindowState): boolean {
return (
(state === WindowState.Tile)
|| (state === WindowState.FullTile)
|| (state === WindowState.FloatTile)
);
}
public static isFloatingState(state: WindowState): boolean {
return (
(state === WindowState.Float)
|| (state === WindowState.FloatTile)
);
}
public readonly id: string;
public readonly window: IDriverWindow;
@ -28,18 +51,15 @@ class Window {
public get shouldFloat(): boolean { return this.window.shouldFloat; }
public get shouldIgnore(): boolean { return this.window.shouldIgnore; }
public get tileable(): boolean { return Window.isTileableState(this.state); }
public get floating(): boolean { return Window.isFloatingState(this.state); }
public get geometryDelta(): RectDelta {
return RectDelta.fromRects(this.geometry, this.actualGeometry);
}
public get tileable(): boolean {
return (this.state === WindowState.Tile) || (this.state === WindowState.FreeTile);
}
/* read-write */
public floatGeometry: Rect;
public geometry: Rect;
public noBorder: boolean;
public get state(): WindowState {
if (this.window.fullScreen)
@ -53,34 +73,18 @@ class Window {
return;
const state = this.state;
if (state === value) {
if (state === value)
return;
} else if (state === WindowState.Unmanaged) {
/* internally accept the new state */
} else if (state === WindowState.FullScreen) {
/* internally accept the new state */
} else if (state === WindowState.Tile && value === WindowState.Float) {
if (Window.isTileableState(state) && Window.isFloatingState(value))
this.window.commit(this.floatGeometry, false, false);
} else if (state === WindowState.Tile && value === WindowState.FreeTile) {
this.window.commit(this.floatGeometry, false, false);
} else if (state === WindowState.Float && value === WindowState.Tile) {
else if (Window.isFloatingState(state) && Window.isTileableState(value))
this.floatGeometry = this.actualGeometry;
} else if (state === WindowState.Float && value === WindowState.FreeTile) {
/* do nothing */
} else if (state === WindowState.FreeTile && value === WindowState.Tile) {
this.floatGeometry = this.actualGeometry;
} else if (state === WindowState.FreeTile && value === WindowState.Float) {
/* do nothing */
} else {
/* deny */
debugObj(() => ["Window#state/ignored", {from: state, to: value}]);
return;
}
this._state = value;
}
/* private */
private _state: WindowState;
constructor(window: IDriverWindow) {
@ -88,19 +92,16 @@ class Window {
this.floatGeometry = window.geometry;
this.geometry = window.geometry;
this.noBorder = false;
this.window = window;
this._state = WindowState.Unmanaged;
}
/*
* Methods
*/
public commit() {
if (this.state === WindowState.Tile)
this.window.commit(this.geometry, this.noBorder, CONFIG.keepTileBelow ? true : false);
this.window.commit(this.geometry, CONFIG.noTileBorder, CONFIG.keepTileBelow);
else if (this.state === WindowState.FullTile)
this.window.commit(this.geometry, true, CONFIG.keepTileBelow);
else if (this.state === WindowState.FullScreen)
this.window.commit(undefined, undefined, false);
}

View File

@ -33,7 +33,7 @@ class FloatingLayout implements ILayout {
public apply(ctx: EngineContext, tileables: Window[], area: Rect): void {
tileables.forEach((tileable: Window) =>
tileable.state = WindowState.FreeTile);
tileable.state = WindowState.FloatTile);
}
public toString(): string {

View File

@ -25,21 +25,20 @@ class MonocleLayout implements ILayout {
public apply(ctx: EngineContext, tileables: Window[], area: Rect): void {
/* Tile all tileables */
tileables.forEach((tileable) => tileable.state = WindowState.Tile);
const tiles = tileables;
if (CONFIG.monocleMaximize)
tiles.forEach((window) => window.noBorder = true);
tiles.forEach((window) => (window.geometry = area));
tileables.forEach((tile) => {
tile.state = (CONFIG.monocleMaximize)
? WindowState.FullTile
: WindowState.Tile;
tile.geometry = area;
});
/* KWin-specific `monocleMinimizeRest` option */
if (ctx.backend === KWinDriver.backendName && KWINCONFIG.monocleMinimizeRest) {
const tilesBak = [...tiles];
const tiles = [...tileables];
ctx.setTimeout(() => {
const current = ctx.currentWindow;
if (current && current.state === WindowState.Tile) {
tilesBak.forEach((window) => {
tiles.forEach((window) => {
if (window !== current)
(window.window as KWinWindow).client.minimized = true;
});

View File

@ -76,7 +76,7 @@ class QuarterLayout implements ILayout {
tileables[i].state = WindowState.Tile;
if (tileables.length > 4)
tileables.slice(4).forEach((tile) => tile.state = WindowState.FreeTile);
tileables.slice(4).forEach((tile) => tile.state = WindowState.FloatTile);
if (tileables.length === 1) {
tileables[0].geometry = area;