Skip to content

Commit

Permalink
Review fix: remove global object initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
meronz committed Oct 1, 2023
1 parent 2f1655b commit 96c2e4c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/extension/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ import ModifiersManager, { MODIFIERS_ENUM } from './modifiers';
const WorkspaceManager: WorkspaceManagerInterface = (
global.screen || global.workspace_manager);

let enabled = false;
let monitorsChangedConnect: any = false;
const trackedWindows: Window[] = global.trackedWindows = [];

const SHELL_VERSION = ShellVersion.defaultVersion();
Expand All @@ -87,6 +85,12 @@ export default class App extends Extension {
private layoutsUtils: LayoutsUtils;
private isGrabbing: boolean = false;
private minimizedWindows: Window[];
private isEnabled: boolean = false;
private monitorsChangedConnect: any = false;
private restackConnection: any;
private workspaceSwitchedConnect: any;
private workareasChangedConnect: any;


private currentLayoutIdxPerMonitor: number[];
public layouts: LayoutsSettings = {
Expand Down Expand Up @@ -234,10 +238,6 @@ export default class App extends Extension {
this.metadata = metadata;
}

private restackConnection: any;
private workspaceSwitchedConnect: any;
private workareasChangedConnect: any;

setLayout(layoutIndex: number, monitorIndex = -1) {
if (this.layouts.definitions.length <= layoutIndex) {
return;
Expand Down Expand Up @@ -310,7 +310,7 @@ export default class App extends Extension {
}

this.setToCurrentWorkspace();
monitorsChangedConnect = Main.layoutManager.connect(
this.monitorsChangedConnect = Main.layoutManager.connect(
'monitors-changed', () => {
activeMonitors().forEach(m => {
this.tabManager[m.index]?.layoutWindows();
Expand Down Expand Up @@ -463,14 +463,14 @@ export default class App extends Extension {

this.modifiersManager.enable();

enabled = true;
this.isEnabled = true;

log("Extension enable completed");
}

changed_settings() {
log("changed_settings");
if (enabled) {
if (this.isEnabled) {
this.disable();
this.enable();
}
Expand Down Expand Up @@ -798,7 +798,7 @@ export default class App extends Extension {
log("Extension disable begin");
deinitSettings();
this.settings = null;
enabled = false;
this.isEnabled = false;
this.modifiersManager.destroy();
this.preview?.forEach(p => { p?.destroy(); p = null });
this.editor?.forEach(e => { e?.destroy(); e = null; });
Expand All @@ -812,10 +812,10 @@ export default class App extends Extension {
global.display.disconnect(this.restackConnection);
this.restackConnection = false;
}
if (monitorsChangedConnect) {
if (this.monitorsChangedConnect) {
log("Disconnecting monitors-changed");
Main.layoutManager.disconnect(monitorsChangedConnect);
monitorsChangedConnect = false;
Main.layoutManager.disconnect(this.monitorsChangedConnect);
this.monitorsChangedConnect = false;
}

if (this.workareasChangedConnect) {
Expand Down

0 comments on commit 96c2e4c

Please sign in to comment.