mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
refactor: ♻️ improve logging
This commit is contained in:
parent
d989261d82
commit
fadcaeac95
@ -11,7 +11,7 @@
|
|||||||
<group name="">
|
<group name="">
|
||||||
|
|
||||||
<entry name="debug" type="Bool">
|
<entry name="debug" type="Bool">
|
||||||
<label>Print debug messages</label>
|
<label>Enable logging</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
|
@ -626,8 +626,7 @@
|
|||||||
<string>Use this option to debug the script or submit detailed bug report.</string>
|
<string>Use this option to debug the script or submit detailed bug report.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Print debug messages
|
<string>Enable logging</string>
|
||||||
(must run KWin from terminal)</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -27,7 +27,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
console.log("Bismuth: Initiating the script");
|
console.log("[Bismuth] Initiating the script");
|
||||||
|
|
||||||
const qmlObjects = {
|
const qmlObjects = {
|
||||||
scriptRoot: scriptRoot,
|
scriptRoot: scriptRoot,
|
||||||
|
@ -8,9 +8,12 @@ import { createMock } from "ts-auto-mock";
|
|||||||
import { Engine } from "../engine";
|
import { Engine } from "../engine";
|
||||||
import { WindowsLayout } from "../engine/layout";
|
import { WindowsLayout } from "../engine/layout";
|
||||||
import Window from "../engine/window";
|
import Window from "../engine/window";
|
||||||
|
import { NullLog } from "../util/log";
|
||||||
import * as Action from "./action";
|
import * as Action from "./action";
|
||||||
|
|
||||||
describe("action", () => {
|
describe("action", () => {
|
||||||
|
const fakeLog = new NullLog();
|
||||||
|
|
||||||
describe("focus", () => {
|
describe("focus", () => {
|
||||||
let fakeEngine: Engine;
|
let fakeEngine: Engine;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -25,7 +28,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("up", () => {
|
describe("up", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusUpperWindow(fakeEngine);
|
const action = new Action.FocusUpperWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -35,7 +38,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("down", () => {
|
describe("down", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusBottomWindow(fakeEngine);
|
const action = new Action.FocusBottomWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -45,7 +48,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("left", () => {
|
describe("left", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusLeftWindow(fakeEngine);
|
const action = new Action.FocusLeftWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("right", () => {
|
describe("right", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusRightWindow(fakeEngine);
|
const action = new Action.FocusRightWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -65,7 +68,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("next", () => {
|
describe("next", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusNextWindow(fakeEngine);
|
const action = new Action.FocusNextWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -75,7 +78,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("prev", () => {
|
describe("prev", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.FocusPreviousWindow(fakeEngine);
|
const action = new Action.FocusPreviousWindow(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -99,7 +102,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("up", () => {
|
describe("up", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowUp(fakeEngine);
|
const action = new Action.MoveActiveWindowUp(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -109,7 +112,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("down", () => {
|
describe("down", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowDown(fakeEngine);
|
const action = new Action.MoveActiveWindowDown(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -119,7 +122,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("left", () => {
|
describe("left", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowLeft(fakeEngine);
|
const action = new Action.MoveActiveWindowLeft(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -129,7 +132,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("right", () => {
|
describe("right", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowRight(fakeEngine);
|
const action = new Action.MoveActiveWindowRight(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -139,7 +142,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("next", () => {
|
describe("next", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowToNextPosition(fakeEngine);
|
const action = new Action.MoveActiveWindowToNextPosition(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -150,7 +156,8 @@ describe("action", () => {
|
|||||||
describe("prev", () => {
|
describe("prev", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.MoveActiveWindowToPreviousPosition(
|
const action = new Action.MoveActiveWindowToPreviousPosition(
|
||||||
fakeEngine
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
);
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
@ -175,7 +182,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("width increase", () => {
|
describe("width increase", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.IncreaseActiveWindowWidth(fakeEngine);
|
const action = new Action.IncreaseActiveWindowWidth(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -189,7 +199,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("width decrease", () => {
|
describe("width decrease", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.DecreaseActiveWindowWidth(fakeEngine);
|
const action = new Action.DecreaseActiveWindowWidth(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -203,7 +216,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("height increase", () => {
|
describe("height increase", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.IncreaseActiveWindowHeight(fakeEngine);
|
const action = new Action.IncreaseActiveWindowHeight(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -217,7 +233,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("height decrease", () => {
|
describe("height decrease", () => {
|
||||||
it("correctly executes", () => {
|
it("correctly executes", () => {
|
||||||
const action = new Action.DecreaseActiveWindowHeight(fakeEngine);
|
const action = new Action.DecreaseActiveWindowHeight(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -241,7 +260,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("increase windows count", () => {
|
describe("increase windows count", () => {
|
||||||
it("shows a note that there is no master area in general case", () => {
|
it("shows a note that there is no master area in general case", () => {
|
||||||
const action = new Action.IncreaseMasterAreaWindowCount(fakeEngine);
|
const action = new Action.IncreaseMasterAreaWindowCount(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -251,7 +273,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("decrease windows count", () => {
|
describe("decrease windows count", () => {
|
||||||
it("shows a note that there is no master area in general case", () => {
|
it("shows a note that there is no master area in general case", () => {
|
||||||
const action = new Action.DecreaseMasterAreaWindowCount(fakeEngine);
|
const action = new Action.DecreaseMasterAreaWindowCount(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -261,7 +286,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("increase size", () => {
|
describe("increase size", () => {
|
||||||
it("shows a note that there is no master area in general case", () => {
|
it("shows a note that there is no master area in general case", () => {
|
||||||
const action = new Action.IncreaseLayoutMasterAreaSize(fakeEngine);
|
const action = new Action.IncreaseLayoutMasterAreaSize(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -271,7 +299,10 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("decrease size", () => {
|
describe("decrease size", () => {
|
||||||
it("shows a note that there is no master area in general case", () => {
|
it("shows a note that there is no master area in general case", () => {
|
||||||
const action = new Action.DecreaseLayoutMasterAreaSize(fakeEngine);
|
const action = new Action.DecreaseLayoutMasterAreaSize(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -288,7 +319,7 @@ describe("action", () => {
|
|||||||
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
|
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
|
||||||
});
|
});
|
||||||
|
|
||||||
const action = new Action.ToggleActiveWindowFloating(fakeEngine);
|
const action = new Action.ToggleActiveWindowFloating(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -304,7 +335,10 @@ describe("action", () => {
|
|||||||
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
|
currentWindow: jest.fn().mockReturnValue(fakeCurrentWindow),
|
||||||
});
|
});
|
||||||
|
|
||||||
const action = new Action.PushActiveWindowIntoMasterAreaFront(fakeEngine);
|
const action = new Action.PushActiveWindowIntoMasterAreaFront(
|
||||||
|
fakeEngine,
|
||||||
|
fakeLog
|
||||||
|
);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -328,7 +362,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("next layout", () => {
|
describe("next layout", () => {
|
||||||
it("executes correctly", () => {
|
it("executes correctly", () => {
|
||||||
const action = new Action.SwitchToNextLayout(fakeEngine);
|
const action = new Action.SwitchToNextLayout(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -338,7 +372,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("prev layout", () => {
|
describe("prev layout", () => {
|
||||||
it("executes correctly", () => {
|
it("executes correctly", () => {
|
||||||
const action = new Action.SwitchToPreviousLayout(fakeEngine);
|
const action = new Action.SwitchToPreviousLayout(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
@ -348,7 +382,7 @@ describe("action", () => {
|
|||||||
|
|
||||||
describe("set layout", () => {
|
describe("set layout", () => {
|
||||||
it("executes correctly when asking to set Monocle Layout", () => {
|
it("executes correctly when asking to set Monocle Layout", () => {
|
||||||
const action = new Action.SetMonocleLayout(fakeEngine);
|
const action = new Action.SetMonocleLayout(fakeEngine, fakeLog);
|
||||||
|
|
||||||
action.execute();
|
action.execute();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import { Engine } from "../engine";
|
import { Engine } from "../engine";
|
||||||
|
import { Log } from "../util/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action that is requested by the user.
|
* Action that is requested by the user.
|
||||||
@ -50,7 +51,8 @@ abstract class ActionImpl implements Action {
|
|||||||
protected engine: Engine,
|
protected engine: Engine,
|
||||||
public key: string,
|
public key: string,
|
||||||
public description: string,
|
public description: string,
|
||||||
public defaultKeybinding: string
|
public defaultKeybinding: string,
|
||||||
|
protected log: Log
|
||||||
) {
|
) {
|
||||||
this.key = `bismuth_${this.key}`;
|
this.key = `bismuth_${this.key}`;
|
||||||
this.description = `Bismuth: ${this.description}`;
|
this.description = `Bismuth: ${this.description}`;
|
||||||
@ -62,7 +64,7 @@ abstract class ActionImpl implements Action {
|
|||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
public execute(): void {
|
public execute(): void {
|
||||||
console.log(`Bismuth: Executing action: ${this.key}`);
|
this.log.log(`Executing action: ${this.key}`);
|
||||||
|
|
||||||
const currentLayout = this.engine.currentLayoutOnCurrentSurface();
|
const currentLayout = this.engine.currentLayoutOnCurrentSurface();
|
||||||
if (currentLayout.executeAction) {
|
if (currentLayout.executeAction) {
|
||||||
@ -82,8 +84,8 @@ abstract class ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusNextWindow extends ActionImpl implements Action {
|
export class FocusNextWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_next_window", "Focus Next Window", "");
|
super(engine, "focus_next_window", "Focus Next Window", "", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -92,8 +94,8 @@ export class FocusNextWindow extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusPreviousWindow extends ActionImpl implements Action {
|
export class FocusPreviousWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_prev_window", "Focus Previous Window", "");
|
super(engine, "focus_prev_window", "Focus Previous Window", "", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -102,8 +104,8 @@ export class FocusPreviousWindow extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusUpperWindow extends ActionImpl implements Action {
|
export class FocusUpperWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_upper_window", "Focus Upper Window", "Meta+K");
|
super(engine, "focus_upper_window", "Focus Upper Window", "Meta+K", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -112,8 +114,8 @@ export class FocusUpperWindow extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusBottomWindow extends ActionImpl implements Action {
|
export class FocusBottomWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_bottom_window", "Focus Bottom Window", "Meta+J");
|
super(engine, "focus_bottom_window", "Focus Bottom Window", "Meta+J", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -122,8 +124,8 @@ export class FocusBottomWindow extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusLeftWindow extends ActionImpl implements Action {
|
export class FocusLeftWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_left_window", "Focus Left Window", "Meta+H");
|
super(engine, "focus_left_window", "Focus Left Window", "Meta+H", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -132,8 +134,8 @@ export class FocusLeftWindow extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FocusRightWindow extends ActionImpl implements Action {
|
export class FocusRightWindow extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "focus_right_window", "Focus Right Window", "Meta+L");
|
super(engine, "focus_right_window", "Focus Right Window", "Meta+L", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -145,12 +147,13 @@ export class MoveActiveWindowToNextPosition
|
|||||||
extends ActionImpl
|
extends ActionImpl
|
||||||
implements Action
|
implements Action
|
||||||
{
|
{
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"move_window_to_next_pos",
|
"move_window_to_next_pos",
|
||||||
"Move Window to the Next Position",
|
"Move Window to the Next Position",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +169,13 @@ export class MoveActiveWindowToPreviousPosition
|
|||||||
extends ActionImpl
|
extends ActionImpl
|
||||||
implements Action
|
implements Action
|
||||||
{
|
{
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"move_window_to_prev_pos",
|
"move_window_to_prev_pos",
|
||||||
"Move Window to the Previous Position",
|
"Move Window to the Previous Position",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +188,14 @@ export class MoveActiveWindowToPreviousPosition
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MoveActiveWindowUp extends ActionImpl implements Action {
|
export class MoveActiveWindowUp extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "move_window_to_upper_pos", "Move Window Up", "Meta+Shift+K");
|
super(
|
||||||
|
engine,
|
||||||
|
"move_window_to_upper_pos",
|
||||||
|
"Move Window Up",
|
||||||
|
"Meta+Shift+K",
|
||||||
|
log
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -194,12 +204,13 @@ export class MoveActiveWindowUp extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MoveActiveWindowDown extends ActionImpl implements Action {
|
export class MoveActiveWindowDown extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"move_window_to_bottom_pos",
|
"move_window_to_bottom_pos",
|
||||||
"Move Window Down",
|
"Move Window Down",
|
||||||
"Meta+Shift+J"
|
"Meta+Shift+J",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,12 +220,13 @@ export class MoveActiveWindowDown extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MoveActiveWindowLeft extends ActionImpl implements Action {
|
export class MoveActiveWindowLeft extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"move_window_to_left_pos",
|
"move_window_to_left_pos",
|
||||||
"Move Window Left",
|
"Move Window Left",
|
||||||
"Meta+Shift+H"
|
"Meta+Shift+H",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,12 +236,13 @@ export class MoveActiveWindowLeft extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MoveActiveWindowRight extends ActionImpl implements Action {
|
export class MoveActiveWindowRight extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"move_window_to_right_pos",
|
"move_window_to_right_pos",
|
||||||
"Move Window Right",
|
"Move Window Right",
|
||||||
"Meta+Shift+L"
|
"Meta+Shift+L",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,12 +252,13 @@ export class MoveActiveWindowRight extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class IncreaseActiveWindowWidth extends ActionImpl implements Action {
|
export class IncreaseActiveWindowWidth extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"increase_window_width",
|
"increase_window_width",
|
||||||
"Increase Window Width",
|
"Increase Window Width",
|
||||||
"Meta+Ctrl+L"
|
"Meta+Ctrl+L",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,12 +271,13 @@ export class IncreaseActiveWindowWidth extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class IncreaseActiveWindowHeight extends ActionImpl implements Action {
|
export class IncreaseActiveWindowHeight extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"increase_window_height",
|
"increase_window_height",
|
||||||
"Increase Window Height",
|
"Increase Window Height",
|
||||||
"Meta+Ctrl+J"
|
"Meta+Ctrl+J",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +290,13 @@ export class IncreaseActiveWindowHeight extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DecreaseActiveWindowWidth extends ActionImpl implements Action {
|
export class DecreaseActiveWindowWidth extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"decrease_window_width",
|
"decrease_window_width",
|
||||||
"Decrease Window Width",
|
"Decrease Window Width",
|
||||||
"Meta+Ctrl+H"
|
"Meta+Ctrl+H",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,12 +309,13 @@ export class DecreaseActiveWindowWidth extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DecreaseActiveWindowHeight extends ActionImpl implements Action {
|
export class DecreaseActiveWindowHeight extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"decrease_window_height",
|
"decrease_window_height",
|
||||||
"Decrease Window Height",
|
"Decrease Window Height",
|
||||||
"Meta+Ctrl+K"
|
"Meta+Ctrl+K",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,12 +331,13 @@ export class IncreaseMasterAreaWindowCount
|
|||||||
extends ActionImpl
|
extends ActionImpl
|
||||||
implements Action
|
implements Action
|
||||||
{
|
{
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"increase_master_win_count",
|
"increase_master_win_count",
|
||||||
"Increase Master Area Window Count",
|
"Increase Master Area Window Count",
|
||||||
"Meta+]"
|
"Meta+]",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,12 +350,13 @@ export class DecreaseMasterAreaWindowCount
|
|||||||
extends ActionImpl
|
extends ActionImpl
|
||||||
implements Action
|
implements Action
|
||||||
{
|
{
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"decrease_master_win_count",
|
"decrease_master_win_count",
|
||||||
"Decrease Master Area Window Count",
|
"Decrease Master Area Window Count",
|
||||||
"Meta+["
|
"Meta+[",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,8 +366,8 @@ export class DecreaseMasterAreaWindowCount
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class IncreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
export class IncreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "increase_master_size", "Increase Master Area Size", "");
|
super(engine, "increase_master_size", "Increase Master Area Size", "", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -357,8 +376,8 @@ export class IncreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DecreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
export class DecreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "decrease_master_size", "Decrease Master Area Size", "");
|
super(engine, "decrease_master_size", "Decrease Master Area Size", "", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -367,12 +386,13 @@ export class DecreaseLayoutMasterAreaSize extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ToggleActiveWindowFloating extends ActionImpl implements Action {
|
export class ToggleActiveWindowFloating extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"toggle_window_floating",
|
"toggle_window_floating",
|
||||||
"Toggle Active Window Floating",
|
"Toggle Active Window Floating",
|
||||||
"Meta+F"
|
"Meta+F",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,12 +408,13 @@ export class PushActiveWindowIntoMasterAreaFront
|
|||||||
extends ActionImpl
|
extends ActionImpl
|
||||||
implements Action
|
implements Action
|
||||||
{
|
{
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"push_window_to_master",
|
"push_window_to_master",
|
||||||
"Push Active Window to Master Area",
|
"Push Active Window to Master Area",
|
||||||
"Meta+Return"
|
"Meta+Return",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,8 +427,8 @@ export class PushActiveWindowIntoMasterAreaFront
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class SwitchToNextLayout extends ActionImpl implements Action {
|
export class SwitchToNextLayout extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "next_layout", "Switch to the Next Layout", "Meta+\\");
|
super(engine, "next_layout", "Switch to the Next Layout", "Meta+\\", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -416,8 +437,14 @@ export class SwitchToNextLayout extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class SwitchToPreviousLayout extends ActionImpl implements Action {
|
export class SwitchToPreviousLayout extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "prev_layout", "Switch to the Previous Layout", "Meta+|");
|
super(
|
||||||
|
engine,
|
||||||
|
"prev_layout",
|
||||||
|
"Switch to the Previous Layout",
|
||||||
|
"Meta+|",
|
||||||
|
log
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -431,106 +458,112 @@ abstract class SetCurrentLayout extends ActionImpl implements Action {
|
|||||||
protected layoutId: string,
|
protected layoutId: string,
|
||||||
key: string,
|
key: string,
|
||||||
description: string,
|
description: string,
|
||||||
defaultShortcut: string
|
defaultShortcut: string,
|
||||||
|
protected log: Log
|
||||||
) {
|
) {
|
||||||
super(engine, key, description, defaultShortcut);
|
super(engine, key, description, defaultShortcut, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
console.log("Set layout called!");
|
|
||||||
|
|
||||||
this.engine.setLayout(this.layoutId);
|
this.engine.setLayout(this.layoutId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetTileLayout extends SetCurrentLayout {
|
export class SetTileLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"TileLayout",
|
"TileLayout",
|
||||||
"toggle_tile_layout",
|
"toggle_tile_layout",
|
||||||
"Toggle Tile Layout",
|
"Toggle Tile Layout",
|
||||||
"Meta+T"
|
"Meta+T",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetMonocleLayout extends SetCurrentLayout {
|
export class SetMonocleLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"MonocleLayout",
|
"MonocleLayout",
|
||||||
"toggle_monocle_layout",
|
"toggle_monocle_layout",
|
||||||
"Toggle Monocle Layout",
|
"Toggle Monocle Layout",
|
||||||
"Meta+M"
|
"Meta+M",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetThreeColumnLayout extends SetCurrentLayout {
|
export class SetThreeColumnLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"ThreeColumnLayout",
|
"ThreeColumnLayout",
|
||||||
"toggle_three_column_layout",
|
"toggle_three_column_layout",
|
||||||
"Toggle Three Column Layout",
|
"Toggle Three Column Layout",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetSpreadLayout extends SetCurrentLayout {
|
export class SetSpreadLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"SpreadLayout",
|
"SpreadLayout",
|
||||||
"toggle_spread_layout",
|
"toggle_spread_layout",
|
||||||
"Toggle Spread Layout",
|
"Toggle Spread Layout",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetStairLayout extends SetCurrentLayout {
|
export class SetStairLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"StairLayout",
|
"StairLayout",
|
||||||
"toggle_stair_layout",
|
"toggle_stair_layout",
|
||||||
"Toggle Stair Layout",
|
"Toggle Stair Layout",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetFloatingLayout extends SetCurrentLayout {
|
export class SetFloatingLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
// NOTE: space is intentional (Temporary)
|
// NOTE: space is intentional (Temporary)
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"FloatingLayout ",
|
"FloatingLayout ",
|
||||||
"toggle_float_layout",
|
"toggle_float_layout",
|
||||||
"Toggle Floating Layout",
|
"Toggle Floating Layout",
|
||||||
"Meta+Shift+F"
|
"Meta+Shift+F",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetQuarterLayout extends SetCurrentLayout {
|
export class SetQuarterLayout extends SetCurrentLayout {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(
|
super(
|
||||||
engine,
|
engine,
|
||||||
"QuarterLayout",
|
"QuarterLayout",
|
||||||
"toggle_quarter_layout",
|
"toggle_quarter_layout",
|
||||||
"Toggle Quarter Layout",
|
"Toggle Quarter Layout",
|
||||||
""
|
"",
|
||||||
|
log
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Rotate extends ActionImpl implements Action {
|
export class Rotate extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "rotate", "Rotate", "Meta+R");
|
super(engine, "rotate", "Rotate", "Meta+R", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
@ -539,8 +572,8 @@ export class Rotate extends ActionImpl implements Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class RotatePart extends ActionImpl implements Action {
|
export class RotatePart extends ActionImpl implements Action {
|
||||||
constructor(protected engine: Engine) {
|
constructor(protected engine: Engine, protected log: Log) {
|
||||||
super(engine, "rotate_part", "Rotate Part", "Meta+Shift+R");
|
super(engine, "rotate_part", "Rotate Part", "Meta+Shift+R", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public executeWithoutLayoutOverride(): void {
|
public executeWithoutLayoutOverride(): void {
|
||||||
|
@ -9,10 +9,9 @@ import { WindowState } from "../engine/window";
|
|||||||
|
|
||||||
import { DriverContext, KWinDriver } from "../driver";
|
import { DriverContext, KWinDriver } from "../driver";
|
||||||
import { DriverSurface } from "../driver/surface";
|
import { DriverSurface } from "../driver/surface";
|
||||||
import MonocleLayout from "../engine/layout/monocle_layout";
|
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
|
|
||||||
import * as Action from "./action";
|
import * as Action from "./action";
|
||||||
|
|
||||||
@ -148,19 +147,18 @@ export class TilingController implements Controller {
|
|||||||
qmlObjects: Bismuth.Qml.Main,
|
qmlObjects: Bismuth.Qml.Main,
|
||||||
kwinApi: KWin.Api,
|
kwinApi: KWin.Api,
|
||||||
private config: Config,
|
private config: Config,
|
||||||
private debug: Debug
|
private log: Log
|
||||||
) {
|
) {
|
||||||
this.engine = new TilingEngine(this, config, debug);
|
this.engine = new TilingEngine(this, config, log);
|
||||||
this.driver = new KWinDriver(qmlObjects, kwinApi, this, config, debug);
|
this.driver = new KWinDriver(qmlObjects, kwinApi, this, config, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point: start tiling window management
|
* Entry point: start tiling window management
|
||||||
*/
|
*/
|
||||||
public start(): void {
|
public start(): void {
|
||||||
console.log("Let's get down to bismuth!");
|
this.log.log("Let's get down to bismuth!");
|
||||||
|
this.log.log(`Config: ${this.config}`);
|
||||||
this.debug.debug(() => `Config: ${this.config}`);
|
|
||||||
|
|
||||||
this.driver.bindEvents();
|
this.driver.bindEvents();
|
||||||
this.bindShortcuts();
|
this.bindShortcuts();
|
||||||
@ -195,15 +193,12 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onSurfaceUpdate(comment: string): void {
|
public onSurfaceUpdate(comment: string): void {
|
||||||
this.debug.debugObj(() => ["onSurfaceUpdate", { comment }]);
|
this.log.log(["onSurfaceUpdate", { comment }]);
|
||||||
this.engine.arrange();
|
this.engine.arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCurrentSurfaceChanged(): void {
|
public onCurrentSurfaceChanged(): void {
|
||||||
this.debug.debugObj(() => [
|
this.log.log(["onCurrentSurfaceChanged", { srf: this.currentSurface }]);
|
||||||
"onCurrentSurfaceChanged",
|
|
||||||
{ srf: this.currentSurface },
|
|
||||||
]);
|
|
||||||
this.engine.arrange();
|
this.engine.arrange();
|
||||||
/* HACK: minimize others and change geometry with Monocle Layout and
|
/* HACK: minimize others and change geometry with Monocle Layout and
|
||||||
* config.monocleMinimizeRest
|
* config.monocleMinimizeRest
|
||||||
@ -214,8 +209,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowAdded(window: Window): void {
|
public onWindowAdded(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowAdded", { window }]);
|
this.log.log(["onWindowAdded", { window }]);
|
||||||
console.log(`New window added: ${window}`);
|
|
||||||
this.engine.manage(window);
|
this.engine.manage(window);
|
||||||
|
|
||||||
/* move window to next surface if the current surface is "full" */
|
/* move window to next surface if the current surface is "full" */
|
||||||
@ -237,8 +231,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowRemoved(window: Window): void {
|
public onWindowRemoved(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowRemoved", { window }]);
|
this.log.log(["onWindowRemoved", { window }]);
|
||||||
console.log(`Window remove: ${window}`);
|
|
||||||
|
|
||||||
this.engine.unmanage(window);
|
this.engine.unmanage(window);
|
||||||
this.engine.arrange();
|
this.engine.arrange();
|
||||||
@ -263,7 +256,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowMoveOver(window: Window): void {
|
public onWindowMoveOver(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowMoveOver", { window }]);
|
this.log.log(["onWindowMoveOver", { window }]);
|
||||||
|
|
||||||
/* swap window by dragging */
|
/* swap window by dragging */
|
||||||
if (window.state === WindowState.Tiled) {
|
if (window.state === WindowState.Tiled) {
|
||||||
@ -304,7 +297,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowResize(window: Window): void {
|
public onWindowResize(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowResize", { window }]);
|
this.log.log(["onWindowResize", { window }]);
|
||||||
if (this.config.adjustLayout && this.config.adjustLayoutLive) {
|
if (this.config.adjustLayout && this.config.adjustLayoutLive) {
|
||||||
if (window.state === WindowState.Tiled) {
|
if (window.state === WindowState.Tiled) {
|
||||||
this.engine.adjustLayout(window);
|
this.engine.adjustLayout(window);
|
||||||
@ -314,8 +307,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowResizeOver(window: Window): void {
|
public onWindowResizeOver(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowResizeOver", { window }]);
|
this.log.log(["onWindowResizeOver", { window }]);
|
||||||
console.log(`Window resize is over: ${window}`);
|
|
||||||
if (this.config.adjustLayout && window.tiled) {
|
if (this.config.adjustLayout && window.tiled) {
|
||||||
this.engine.adjustLayout(window);
|
this.engine.adjustLayout(window);
|
||||||
this.engine.arrange();
|
this.engine.arrange();
|
||||||
@ -329,7 +321,7 @@ export class TilingController implements Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onWindowGeometryChanged(window: Window): void {
|
public onWindowGeometryChanged(window: Window): void {
|
||||||
this.debug.debugObj(() => ["onWindowGeometryChanged", { window }]);
|
this.log.log(["onWindowGeometryChanged", { window }]);
|
||||||
this.engine.enforceSize(window);
|
this.engine.enforceSize(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +329,7 @@ export class TilingController implements Controller {
|
|||||||
// by itself anyway.
|
// by itself anyway.
|
||||||
public onWindowChanged(window: Window | null, comment?: string): void {
|
public onWindowChanged(window: Window | null, comment?: string): void {
|
||||||
if (window) {
|
if (window) {
|
||||||
this.debug.debugObj(() => ["onWindowChanged", { window, comment }]);
|
this.log.log(["onWindowChanged", { window, comment }]);
|
||||||
|
|
||||||
if (comment === "unminimized") {
|
if (comment === "unminimized") {
|
||||||
this.currentWindow = window;
|
this.currentWindow = window;
|
||||||
@ -350,12 +342,12 @@ export class TilingController implements Controller {
|
|||||||
public onWindowFocused(window: Window): void {
|
public onWindowFocused(window: Window): void {
|
||||||
window.timestamp = new Date().getTime();
|
window.timestamp = new Date().getTime();
|
||||||
this.currentWindow = window;
|
this.currentWindow = window;
|
||||||
// Minimize other windows if Moncole and config.monocleMinimizeRest
|
// Minimize other windows if Monocle and config.monocleMinimizeRest
|
||||||
if (
|
if (
|
||||||
this.engine.isLayoutMonocleAndMinimizeRest() &&
|
this.engine.isLayoutMonocleAndMinimizeRest() &&
|
||||||
this.engine.windows.getVisibleTiles(window.surface).includes(window)
|
this.engine.windows.getVisibleTiles(window.surface).includes(window)
|
||||||
) {
|
) {
|
||||||
/* If a window hasn't been foucsed in this layout yet, ensure its geometry
|
/* If a window hasn't been focused in this layout yet, ensure its geometry
|
||||||
* gets maximized.
|
* gets maximized.
|
||||||
*/
|
*/
|
||||||
this.engine
|
this.engine
|
||||||
@ -376,45 +368,45 @@ export class TilingController implements Controller {
|
|||||||
|
|
||||||
private bindShortcuts(): void {
|
private bindShortcuts(): void {
|
||||||
const allPossibleActions = [
|
const allPossibleActions = [
|
||||||
new Action.FocusNextWindow(this.engine),
|
new Action.FocusNextWindow(this.engine, this.log),
|
||||||
new Action.FocusPreviousWindow(this.engine),
|
new Action.FocusPreviousWindow(this.engine, this.log),
|
||||||
new Action.FocusUpperWindow(this.engine),
|
new Action.FocusUpperWindow(this.engine, this.log),
|
||||||
new Action.FocusBottomWindow(this.engine),
|
new Action.FocusBottomWindow(this.engine, this.log),
|
||||||
new Action.FocusLeftWindow(this.engine),
|
new Action.FocusLeftWindow(this.engine, this.log),
|
||||||
new Action.FocusRightWindow(this.engine),
|
new Action.FocusRightWindow(this.engine, this.log),
|
||||||
new Action.MoveActiveWindowToNextPosition(this.engine),
|
new Action.MoveActiveWindowToNextPosition(this.engine, this.log),
|
||||||
|
|
||||||
new Action.MoveActiveWindowToPreviousPosition(this.engine),
|
new Action.MoveActiveWindowToPreviousPosition(this.engine, this.log),
|
||||||
new Action.MoveActiveWindowUp(this.engine),
|
new Action.MoveActiveWindowUp(this.engine, this.log),
|
||||||
new Action.MoveActiveWindowDown(this.engine),
|
new Action.MoveActiveWindowDown(this.engine, this.log),
|
||||||
new Action.MoveActiveWindowLeft(this.engine),
|
new Action.MoveActiveWindowLeft(this.engine, this.log),
|
||||||
new Action.MoveActiveWindowRight(this.engine),
|
new Action.MoveActiveWindowRight(this.engine, this.log),
|
||||||
|
|
||||||
new Action.IncreaseActiveWindowWidth(this.engine),
|
new Action.IncreaseActiveWindowWidth(this.engine, this.log),
|
||||||
new Action.IncreaseActiveWindowHeight(this.engine),
|
new Action.IncreaseActiveWindowHeight(this.engine, this.log),
|
||||||
new Action.DecreaseActiveWindowWidth(this.engine),
|
new Action.DecreaseActiveWindowWidth(this.engine, this.log),
|
||||||
new Action.DecreaseActiveWindowHeight(this.engine),
|
new Action.DecreaseActiveWindowHeight(this.engine, this.log),
|
||||||
|
|
||||||
new Action.IncreaseMasterAreaWindowCount(this.engine),
|
new Action.IncreaseMasterAreaWindowCount(this.engine, this.log),
|
||||||
new Action.DecreaseMasterAreaWindowCount(this.engine),
|
new Action.DecreaseMasterAreaWindowCount(this.engine, this.log),
|
||||||
new Action.IncreaseLayoutMasterAreaSize(this.engine),
|
new Action.IncreaseLayoutMasterAreaSize(this.engine, this.log),
|
||||||
new Action.DecreaseLayoutMasterAreaSize(this.engine),
|
new Action.DecreaseLayoutMasterAreaSize(this.engine, this.log),
|
||||||
|
|
||||||
new Action.ToggleActiveWindowFloating(this.engine),
|
new Action.ToggleActiveWindowFloating(this.engine, this.log),
|
||||||
new Action.PushActiveWindowIntoMasterAreaFront(this.engine),
|
new Action.PushActiveWindowIntoMasterAreaFront(this.engine, this.log),
|
||||||
|
|
||||||
new Action.SwitchToNextLayout(this.engine),
|
new Action.SwitchToNextLayout(this.engine, this.log),
|
||||||
new Action.SwitchToPreviousLayout(this.engine),
|
new Action.SwitchToPreviousLayout(this.engine, this.log),
|
||||||
new Action.SetTileLayout(this.engine),
|
new Action.SetTileLayout(this.engine, this.log),
|
||||||
new Action.SetMonocleLayout(this.engine),
|
new Action.SetMonocleLayout(this.engine, this.log),
|
||||||
new Action.SetThreeColumnLayout(this.engine),
|
new Action.SetThreeColumnLayout(this.engine, this.log),
|
||||||
new Action.SetStairLayout(this.engine),
|
new Action.SetStairLayout(this.engine, this.log),
|
||||||
new Action.SetSpreadLayout(this.engine),
|
new Action.SetSpreadLayout(this.engine, this.log),
|
||||||
new Action.SetFloatingLayout(this.engine),
|
new Action.SetFloatingLayout(this.engine, this.log),
|
||||||
new Action.SetQuarterLayout(this.engine),
|
new Action.SetQuarterLayout(this.engine, this.log),
|
||||||
|
|
||||||
new Action.Rotate(this.engine),
|
new Action.Rotate(this.engine, this.log),
|
||||||
new Action.RotatePart(this.engine),
|
new Action.RotatePart(this.engine, this.log),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const action of allPossibleActions) {
|
for (const action of allPossibleActions) {
|
||||||
|
@ -15,7 +15,7 @@ import Window from "../engine/window";
|
|||||||
import { WindowState } from "../engine/window";
|
import { WindowState } from "../engine/window";
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
|
|
||||||
export interface DriverContext {
|
export interface DriverContext {
|
||||||
readonly screens: DriverSurface[];
|
readonly screens: DriverSurface[];
|
||||||
@ -65,7 +65,6 @@ export class KWinDriver implements DriverContext {
|
|||||||
|
|
||||||
public get currentWindow(): Window | null {
|
public get currentWindow(): Window | null {
|
||||||
const client = this.kwinApi.workspace.activeClient;
|
const client = this.kwinApi.workspace.activeClient;
|
||||||
console.log(`Active client: ${client}`);
|
|
||||||
return client ? this.windowMap.get(client) : null;
|
return client ? this.windowMap.get(client) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +101,6 @@ export class KWinDriver implements DriverContext {
|
|||||||
private kwinApi: KWin.Api;
|
private kwinApi: KWin.Api;
|
||||||
|
|
||||||
private config: Config;
|
private config: Config;
|
||||||
private debug: Debug;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param qmlObjects objects from QML gui. Required for the interaction with QML, as we cannot access globals.
|
* @param qmlObjects objects from QML gui. Required for the interaction with QML, as we cannot access globals.
|
||||||
@ -114,16 +112,13 @@ export class KWinDriver implements DriverContext {
|
|||||||
kwinApi: KWin.Api,
|
kwinApi: KWin.Api,
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
config: Config,
|
config: Config,
|
||||||
debug: Debug
|
private log: Log
|
||||||
) {
|
) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.debug = debug;
|
|
||||||
|
|
||||||
// TODO: find a better way to to this
|
// TODO: find a better way to to this
|
||||||
if (this.config.preventMinimize && this.config.monocleMinimizeRest) {
|
if (this.config.preventMinimize && this.config.monocleMinimizeRest) {
|
||||||
this.debug.debug(
|
log.log("preventMinimize is disabled because of monocleMinimizeRest");
|
||||||
() => "preventMinimize is disabled because of monocleMinimizeRest."
|
|
||||||
);
|
|
||||||
this.config.preventMinimize = false;
|
this.config.preventMinimize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,15 +127,9 @@ export class KWinDriver implements DriverContext {
|
|||||||
(client: KWin.Client) => KWinWindow.generateID(client),
|
(client: KWin.Client) => KWinWindow.generateID(client),
|
||||||
(client: KWin.Client) =>
|
(client: KWin.Client) =>
|
||||||
new Window(
|
new Window(
|
||||||
new KWinWindow(
|
new KWinWindow(client, this.qml, this.kwinApi, this.config, this.log),
|
||||||
client,
|
|
||||||
this.qml,
|
|
||||||
this.kwinApi,
|
|
||||||
this.config,
|
|
||||||
this.debug
|
|
||||||
),
|
|
||||||
this.config,
|
this.config,
|
||||||
this.debug
|
this.log
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
this.entered = false;
|
this.entered = false;
|
||||||
@ -180,17 +169,17 @@ export class KWinDriver implements DriverContext {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onClientAdded = (client: KWin.Client): void => {
|
const onClientAdded = (client: KWin.Client): void => {
|
||||||
console.log(`Client added: ${client}`);
|
this.log.log(`Client added: ${client}`);
|
||||||
|
|
||||||
const window = this.windowMap.add(client);
|
const window = this.windowMap.add(client);
|
||||||
this.controller.onWindowAdded(window);
|
this.controller.onWindowAdded(window);
|
||||||
if (window.state === WindowState.Unmanaged) {
|
if (window.state === WindowState.Unmanaged) {
|
||||||
console.log(
|
this.log.log(
|
||||||
`Window becomes unmanaged and gets removed :( The client was ${client}`
|
`Window becomes unmanaged and gets removed :( The client was ${client}`
|
||||||
);
|
);
|
||||||
this.windowMap.remove(client);
|
this.windowMap.remove(client);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Client is ok, can manage. Bind events now...`);
|
this.log.log(`Client is ok, can manage. Bind events now...`);
|
||||||
this.bindWindowEvents(window, client);
|
this.bindWindowEvents(window, client);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -307,9 +296,6 @@ export class KWinDriver implements DriverContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bindShortcut(action: Action): void {
|
public bindShortcut(action: Action): void {
|
||||||
console.log(
|
|
||||||
`Registering ${action.key} with the description ${action.description}`
|
|
||||||
);
|
|
||||||
this.kwinApi.KWin.registerShortcut(
|
this.kwinApi.KWin.registerShortcut(
|
||||||
action.key,
|
action.key,
|
||||||
action.description,
|
action.description,
|
||||||
@ -356,10 +342,8 @@ export class KWinDriver implements DriverContext {
|
|||||||
this.entered = true;
|
this.entered = true;
|
||||||
try {
|
try {
|
||||||
callback();
|
callback();
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
// TODO: investigate why this line prevents compiling
|
this.log.log(e);
|
||||||
// debug(() => "Error raised from line " + e.lineNumber);
|
|
||||||
this.debug.debug(() => e);
|
|
||||||
} finally {
|
} finally {
|
||||||
this.entered = false;
|
this.entered = false;
|
||||||
}
|
}
|
||||||
@ -370,7 +354,7 @@ export class KWinDriver implements DriverContext {
|
|||||||
let resizing = false;
|
let resizing = false;
|
||||||
|
|
||||||
this.connect(client.moveResizedChanged, () => {
|
this.connect(client.moveResizedChanged, () => {
|
||||||
this.debug.debugObj(() => [
|
this.log.log([
|
||||||
"moveResizedChanged",
|
"moveResizedChanged",
|
||||||
{ window, move: client.move, resize: client.resize },
|
{ window, move: client.move, resize: client.resize },
|
||||||
]);
|
]);
|
||||||
|
@ -9,7 +9,7 @@ import Rect from "../util/rect";
|
|||||||
import { toQRect, toRect } from "../util/kwinutil";
|
import { toQRect, toRect } from "../util/kwinutil";
|
||||||
import { clip, matchWords } from "../util/func";
|
import { clip, matchWords } from "../util/func";
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
|
|
||||||
export interface DriverWindow {
|
export interface DriverWindow {
|
||||||
readonly fullScreen: boolean;
|
readonly fullScreen: boolean;
|
||||||
@ -132,14 +132,13 @@ export class KWinWindow implements DriverWindow {
|
|||||||
private qml: Bismuth.Qml.Main;
|
private qml: Bismuth.Qml.Main;
|
||||||
private kwinApi: KWin.Api;
|
private kwinApi: KWin.Api;
|
||||||
private config: Config;
|
private config: Config;
|
||||||
private debug: Debug;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
client: KWin.Client,
|
client: KWin.Client,
|
||||||
qml: Bismuth.Qml.Main,
|
qml: Bismuth.Qml.Main,
|
||||||
kwinApi: KWin.Api,
|
kwinApi: KWin.Api,
|
||||||
config: Config,
|
config: Config,
|
||||||
debug: Debug
|
private log: Log
|
||||||
) {
|
) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.id = KWinWindow.generateID(client);
|
this.id = KWinWindow.generateID(client);
|
||||||
@ -149,7 +148,6 @@ export class KWinWindow implements DriverWindow {
|
|||||||
this.qml = qml;
|
this.qml = qml;
|
||||||
this.kwinApi = kwinApi;
|
this.kwinApi = kwinApi;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.debug = debug;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public commit(
|
public commit(
|
||||||
@ -157,10 +155,7 @@ export class KWinWindow implements DriverWindow {
|
|||||||
noBorder?: boolean,
|
noBorder?: boolean,
|
||||||
keepAbove?: boolean
|
keepAbove?: boolean
|
||||||
): void {
|
): void {
|
||||||
this.debug.debugObj(() => [
|
this.log.log(["KWinWindow#commit", { geometry, noBorder, keepAbove }]);
|
||||||
"KWinWindow#commit",
|
|
||||||
{ geometry, noBorder, keepAbove },
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (this.client.move || this.client.resize) {
|
if (this.client.move || this.client.resize) {
|
||||||
return;
|
return;
|
||||||
|
@ -11,7 +11,7 @@ import Config from "../config";
|
|||||||
import { Controller } from "../controller";
|
import { Controller } from "../controller";
|
||||||
import { DriverSurface } from "../driver/surface";
|
import { DriverSurface } from "../driver/surface";
|
||||||
|
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
import Rect from "../util/rect";
|
import Rect from "../util/rect";
|
||||||
import TileLayout from "./layout/tile_layout";
|
import TileLayout from "./layout/tile_layout";
|
||||||
import LayoutStore from "./layout_store";
|
import LayoutStore from "./layout_store";
|
||||||
@ -25,9 +25,9 @@ describe("arrange", () => {
|
|||||||
const fakeScreens = [screenMock, screenMock, screenMock, screenMock];
|
const fakeScreens = [screenMock, screenMock, screenMock, screenMock];
|
||||||
|
|
||||||
const controllerMock = createMock<Controller>({ screens: fakeScreens });
|
const controllerMock = createMock<Controller>({ screens: fakeScreens });
|
||||||
const debugMock = createMock<Debug>();
|
const logMock = createMock<Log>();
|
||||||
const configMock = createMock<Config>();
|
const configMock = createMock<Config>();
|
||||||
const engine = new TilingEngine(controllerMock, configMock, debugMock);
|
const engine = new TilingEngine(controllerMock, configMock, logMock);
|
||||||
|
|
||||||
jest.spyOn(engine, "arrangeScreen").mockReturnValue();
|
jest.spyOn(engine, "arrangeScreen").mockReturnValue();
|
||||||
|
|
||||||
@ -43,9 +43,9 @@ describe("arrangeScreen", () => {
|
|||||||
describe("window states are correctly changed", () => {
|
describe("window states are correctly changed", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const controllerMock = createMock<Controller>();
|
const controllerMock = createMock<Controller>();
|
||||||
const debugMock = createMock<Debug>();
|
const logMock = createMock<Log>();
|
||||||
const configMock = createMock<Config>();
|
const configMock = createMock<Config>();
|
||||||
const engine = new TilingEngine(controllerMock, configMock, debugMock);
|
const engine = new TilingEngine(controllerMock, configMock, logMock);
|
||||||
|
|
||||||
const window1 = createMock<Window>({
|
const window1 = createMock<Window>({
|
||||||
shouldFloat: false,
|
shouldFloat: false,
|
||||||
|
@ -18,7 +18,7 @@ import Rect from "../util/rect";
|
|||||||
import RectDelta from "../util/rectdelta";
|
import RectDelta from "../util/rectdelta";
|
||||||
import { overlap, wrapIndex } from "../util/func";
|
import { overlap, wrapIndex } from "../util/func";
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
import { WindowsLayout } from "./layout";
|
import { WindowsLayout } from "./layout";
|
||||||
|
|
||||||
export type Direction = "up" | "down" | "left" | "right";
|
export type Direction = "up" | "down" | "left" | "right";
|
||||||
@ -79,7 +79,7 @@ export class TilingEngine implements Engine {
|
|||||||
constructor(
|
constructor(
|
||||||
private controller: Controller,
|
private controller: Controller,
|
||||||
private config: Config,
|
private config: Config,
|
||||||
private debug: Debug
|
private log: Log
|
||||||
) {
|
) {
|
||||||
this.layouts = new LayoutStore(this.config);
|
this.layouts = new LayoutStore(this.config);
|
||||||
this.windows = new WindowStore();
|
this.windows = new WindowStore();
|
||||||
@ -236,7 +236,7 @@ export class TilingEngine implements Engine {
|
|||||||
* Arrange tiles on all screens.
|
* Arrange tiles on all screens.
|
||||||
*/
|
*/
|
||||||
public arrange(): void {
|
public arrange(): void {
|
||||||
this.debug.debug(() => "arrange");
|
this.log.log("arrange");
|
||||||
|
|
||||||
this.controller.screens.forEach((driverSurface: DriverSurface) => {
|
this.controller.screens.forEach((driverSurface: DriverSurface) => {
|
||||||
this.arrangeScreen(driverSurface);
|
this.arrangeScreen(driverSurface);
|
||||||
@ -255,7 +255,7 @@ export class TilingEngine implements Engine {
|
|||||||
const tilingArea = this.getTilingArea(workingArea, layout);
|
const tilingArea = this.getTilingArea(workingArea, layout);
|
||||||
|
|
||||||
const visibleWindows = this.windows.getVisibleWindows(screenSurface);
|
const visibleWindows = this.windows.getVisibleWindows(screenSurface);
|
||||||
this.debug.debugObj(() => [
|
this.log.log([
|
||||||
"arrangeScreen",
|
"arrangeScreen",
|
||||||
{
|
{
|
||||||
layout,
|
layout,
|
||||||
@ -304,7 +304,7 @@ export class TilingEngine implements Engine {
|
|||||||
|
|
||||||
// Commit window assigned properties
|
// Commit window assigned properties
|
||||||
visibleWindows.forEach((win: Window) => win.commit());
|
visibleWindows.forEach((win: Window) => win.commit());
|
||||||
this.debug.debugObj(() => ["arrangeScreen/finished", { screenSurface }]);
|
this.log.log(["arrangeScreen/finished", { screenSurface }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public currentLayoutOnCurrentSurface(): WindowsLayout {
|
public currentLayoutOnCurrentSurface(): WindowsLayout {
|
||||||
|
@ -65,7 +65,6 @@ export default class MonocleLayout implements WindowsLayout {
|
|||||||
) {
|
) {
|
||||||
engine.focusOrder(1, this.config.monocleMinimizeRest);
|
engine.focusOrder(1, this.config.monocleMinimizeRest);
|
||||||
} else {
|
} else {
|
||||||
console.log("Executing from Monocle regular action!");
|
|
||||||
action.executeWithoutLayoutOverride();
|
action.executeWithoutLayoutOverride();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { DriverWindow } from "../driver/window";
|
|||||||
import { DriverSurface } from "../driver/surface";
|
import { DriverSurface } from "../driver/surface";
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import Debug from "../util/debug";
|
import { Log } from "../util/log";
|
||||||
import Rect from "../util/rect";
|
import Rect from "../util/rect";
|
||||||
import RectDelta from "../util/rectdelta";
|
import RectDelta from "../util/rectdelta";
|
||||||
|
|
||||||
@ -163,11 +163,9 @@ export default class Window {
|
|||||||
private weightMap: { [key: string]: number };
|
private weightMap: { [key: string]: number };
|
||||||
|
|
||||||
private config: Config;
|
private config: Config;
|
||||||
private debug: Debug;
|
|
||||||
|
|
||||||
constructor(window: DriverWindow, config: Config, debug: Debug) {
|
constructor(window: DriverWindow, config: Config, private log: Log) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.debug = debug;
|
|
||||||
|
|
||||||
this.id = window.id;
|
this.id = window.id;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
@ -183,7 +181,7 @@ export default class Window {
|
|||||||
|
|
||||||
public commit(): void {
|
public commit(): void {
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
this.debug.debugObj(() => ["Window#commit", { state: WindowState[state] }]);
|
this.log.log(["Window#commit", { state: WindowState[state] }]);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case WindowState.NativeMaximized:
|
case WindowState.NativeMaximized:
|
||||||
this.window.commit(undefined, undefined, false);
|
this.window.commit(undefined, undefined, false);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { ConfigImpl } from "./config";
|
import { ConfigImpl } from "./config";
|
||||||
import { TilingController } from "./controller";
|
import { TilingController } from "./controller";
|
||||||
import Debug from "./util/debug";
|
import { LogImpl } from "./util/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Script entry-point from QML side.
|
* Script entry-point from QML side.
|
||||||
@ -16,13 +16,13 @@ export function init(
|
|||||||
kwinScriptingApi: KWin.Api
|
kwinScriptingApi: KWin.Api
|
||||||
): void {
|
): void {
|
||||||
const config = new ConfigImpl(kwinScriptingApi);
|
const config = new ConfigImpl(kwinScriptingApi);
|
||||||
const debug = new Debug(config);
|
const logger = new LogImpl(config);
|
||||||
|
|
||||||
const controller = new TilingController(
|
const controller = new TilingController(
|
||||||
qmlObjects,
|
qmlObjects,
|
||||||
kwinScriptingApi,
|
kwinScriptingApi,
|
||||||
config,
|
config,
|
||||||
debug
|
logger
|
||||||
);
|
);
|
||||||
|
|
||||||
controller.start();
|
controller.start();
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
|
|
||||||
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
import Config from "../config";
|
|
||||||
|
|
||||||
export default class Debug {
|
|
||||||
private enabled: boolean;
|
|
||||||
private started: number;
|
|
||||||
|
|
||||||
constructor(config: Config) {
|
|
||||||
this.enabled = config.debugEnabled;
|
|
||||||
this.started = new Date().getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public debug(f: () => any): void {
|
|
||||||
if (this.enabled) {
|
|
||||||
const timestamp = (new Date().getTime() - this.started) / 1000;
|
|
||||||
console.log(`[${timestamp}]`, f());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public debugObj(f: () => [string, any]): void {
|
|
||||||
if (this.enabled) {
|
|
||||||
const timestamp = (new Date().getTime() - this.started) / 1000;
|
|
||||||
const [name, obj] = f();
|
|
||||||
const buf = [];
|
|
||||||
for (const i in obj) {
|
|
||||||
buf.push(`${i}=${obj[i]}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[${timestamp}]`, `${name}: ${buf.join(" ")}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
87
src/util/log.ts
Normal file
87
src/util/log.ts
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
|
||||||
|
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import Config from "../config";
|
||||||
|
|
||||||
|
type LogType = string | Record<string, unknown> | LogType[];
|
||||||
|
export interface Log {
|
||||||
|
log(str: LogType): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard logger
|
||||||
|
*/
|
||||||
|
export class LogImpl implements Log {
|
||||||
|
private enabled: boolean;
|
||||||
|
private started: number;
|
||||||
|
|
||||||
|
constructor(config: Config) {
|
||||||
|
this.enabled = config.debugEnabled;
|
||||||
|
this.started = new Date().getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public log(logObj: LogType): void {
|
||||||
|
if (this.enabled) {
|
||||||
|
this.doLog(logObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private doLog(logObj: LogType): void {
|
||||||
|
if (Object.prototype.toString.call(logObj) === "[object Array]") {
|
||||||
|
// If log object is an array
|
||||||
|
this.logArray(logObj as LogType[]);
|
||||||
|
} else if (typeof logObj == "string") {
|
||||||
|
this.logString(logObj);
|
||||||
|
} else if (typeof logObj == "object") {
|
||||||
|
this.logObject(logObj as Record<string, unknown>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs object (without deep inspection)
|
||||||
|
* @param obj object to log
|
||||||
|
*/
|
||||||
|
private logObject(obj: Record<string, unknown>): void {
|
||||||
|
// NOTE: be aware, that constructor name could change if minification is used
|
||||||
|
const objectName = obj.constructor.name;
|
||||||
|
const logQueue = [];
|
||||||
|
for (const i in obj) {
|
||||||
|
logQueue.push(`${i}: ${obj[i]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logString(`${objectName}: ${logQueue.join(", ")}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs string
|
||||||
|
* @param str string to log
|
||||||
|
*/
|
||||||
|
private logString(str: string): void {
|
||||||
|
console.log(`[Bismuth] [${this.now()}] ${str}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sequentially logs the contents of the array
|
||||||
|
* @param arr array to log
|
||||||
|
*/
|
||||||
|
private logArray(arr: LogType[]): void {
|
||||||
|
for (const element of arr) {
|
||||||
|
this.doLog(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private now(): number {
|
||||||
|
return (new Date().getTime() - this.started) / 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null log, that does not output anything
|
||||||
|
*/
|
||||||
|
export class NullLog implements Log {
|
||||||
|
public log(_str: LogType): void {
|
||||||
|
// NOP
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user