Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "auto unstack" switch #1657

Open
wants to merge 9 commits into
base: master_jammy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/auto_tiler.ts
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is me trying to move the imports back to their rightful place

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const Me = imports.misc.extensionUtils.getCurrentExtension();

import * as ecs from 'ecs';
import * as geom from 'geom';
import * as lib from 'lib';
import * as log from 'log';
import * as node from 'node';
import * as result from 'result';
import * as stack from 'stack';
import * as geom from 'geom';
import * as tiling from 'tiling';

import type { Entity } from 'ecs';
Expand Down
10 changes: 5 additions & 5 deletions src/forest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();

import * as arena from 'arena';
import * as Ecs from 'ecs';
import * as Fork from 'fork';
import * as geom from 'geom';
import * as Lib from 'lib';
import * as log from 'log';
import * as movement from 'movement';
import * as Node from 'node';
import * as Rect from 'rectangle';
import * as Node from 'node';
import * as Fork from 'fork';
import * as geom from 'geom';

import type { Entity } from 'ecs';
import type { Ext } from './extension';
import type { Rectangle } from './rectangle';
import { Stack } from './stack';
import type { ShellWindow } from './window';
import type { Ext } from './extension';
import { Stack } from './stack';

const { Arena } = arena;
const { Meta } = imports.gi;
Expand Down
127 changes: 59 additions & 68 deletions src/prefs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { }
export { };

const ExtensionUtils = imports.misc.extensionUtils;
// @ts-ignore
Expand All @@ -8,9 +8,9 @@ const { Gtk } = imports.gi;

const { Settings } = imports.gi.Gio;

import * as settings from 'settings';
import * as log from 'log';
import * as focus from 'focus';
import * as log from 'log';
import * as settings from 'settings';

interface AppWidgets {
fullscreen_launcher: any,
Expand Down Expand Up @@ -51,7 +51,7 @@ function settings_dialog_new(): Gtk.Container {
app.smart_gaps.connect('state-set', (_widget: any, state: boolean) => {
ext.set_smart_gaps(state);
Settings.sync();
});
})

app.auto_unstack.set_active(ext.auto_unstack());
app.auto_unstack.connect('state-set', (_widget: any, state: boolean) => {
Expand All @@ -65,7 +65,7 @@ function settings_dialog_new(): Gtk.Container {
if (!isNaN(parsed)) {
ext.set_gap_outer(parsed);
Settings.sync();
}
};
});

app.inner_gap.set_text(String(ext.gap_inner()));
Expand All @@ -90,13 +90,10 @@ function settings_dialog_new(): Gtk.Container {
});

app.mouse_cursor_follows_active_window.set_active(ext.mouse_cursor_follows_active_window());
app.mouse_cursor_follows_active_window.connect(
'state-set',
(_widget: any, state: boolean) => {
ext.set_mouse_cursor_follows_active_window(state);
Settings.sync();
}
);
app.mouse_cursor_follows_active_window.connect('state-set', (_widget: any, state: boolean) => {
ext.set_mouse_cursor_follows_active_window(state);
Settings.sync();
});

app.mouse_cursor_focus_position.set_active(ext.mouse_cursor_focus_location());
app.mouse_cursor_focus_position.connect('changed', () => {
Expand All @@ -105,22 +102,16 @@ function settings_dialog_new(): Gtk.Container {
});

app.fullscreen_launcher.set_active(ext.fullscreen_launcher());
app.fullscreen_launcher.connect(
'state-set',
(_widget: any, state: boolean) => {
ext.set_fullscreen_launcher(state);
Settings.sync();
}
);
app.fullscreen_launcher.connect('state-set',(_widget: any, state: boolean) => {
ext.set_fullscreen_launcher(state);
Settings.sync()
});

app.stacking_with_mouse.set_active(ext.stacking_with_mouse());
app.stacking_with_mouse.connect(
'state-set',
(_widget: any, state: boolean) => {
ext.set_stacking_with_mouse(state);
Settings.sync();
}
);
app.stacking_with_mouse.connect('state-set', (_widget: any, state: boolean) => {
ext.set_stacking_with_mouse(state);
Settings.sync()
});

return grid;
}
Expand All @@ -133,48 +124,48 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
margin_end: 10,
margin_bottom: 10,
margin_top: 10,
});
})

const win_label = new Gtk.Label({
label: "Show Window Titles",
xalign: 0.0,
hexpand: true,
});
hexpand: true
})

const snap_label = new Gtk.Label({
label: "Snap to Grid (Floating Mode)",
xalign: 0.0,
});
xalign: 0.0
})

const smart_label = new Gtk.Label({
label: "Smart Gaps",
xalign: 0.0,
});
xalign: 0.0
})

const unstack_label = new Gtk.Label({
label: "Automatically destroy single-window stacks",
xalign: 0.0,
});
label: "Destroy stacks when separated by the mouse",
xalign: 0.0
})

const show_skip_taskbar_label = new Gtk.Label({
label: "Show Minimize to Tray Windows",
xalign: 0.0,
});
xalign: 0.0
})

const mouse_cursor_follows_active_window_label = new Gtk.Label({
label: "Mouse Cursor Follows Active Window",
xalign: 0.0,
});
xalign: 0.0
})

const fullscreen_launcher_label = new Gtk.Label({
label: "Allow launcher over fullscreen window",
xalign: 0.0,
});
xalign: 0.0
})

const stacking_with_mouse = new Gtk.Label({
label: "Allow stacking with mouse",
xalign: 0.0,
});
xalign: 0.0
})

const [inner_gap, outer_gap] = gaps_section(grid, 10);

Expand All @@ -188,7 +179,7 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
snap_to_grid: new Gtk.Switch({ halign: Gtk.Align.END }),
window_titles: new Gtk.Switch({ halign: Gtk.Align.END }),
show_skip_taskbar: new Gtk.Switch({ halign: Gtk.Align.END }),
mouse_cursor_follows_active_window: new Gtk.Switch({halign: Gtk.Align.END,}),
mouse_cursor_follows_active_window: new Gtk.Switch({ halign: Gtk.Align.END }),
mouse_cursor_focus_position: build_combo(
grid,
8,
Expand All @@ -203,29 +194,29 @@ function settings_dialog_view(): [AppWidgets, Gtk.Container] {
),
};

grid.attach(win_label, 0, 0, 1, 1);
grid.attach(settings.window_titles, 1, 0, 1, 1);
grid.attach(win_label, 0, 0, 1, 1)
grid.attach(settings.window_titles, 1, 0, 1, 1)

grid.attach(snap_label, 0, 1, 1, 1);
grid.attach(settings.snap_to_grid, 1, 1, 1, 1);
grid.attach(snap_label, 0, 1, 1, 1)
grid.attach(settings.snap_to_grid, 1, 1, 1, 1)

grid.attach(smart_label, 0, 2, 1, 1);
grid.attach(settings.smart_gaps, 1, 2, 1, 1);
grid.attach(smart_label, 0, 2, 1, 1)
grid.attach(settings.smart_gaps, 1, 2, 1, 1)

grid.attach(unstack_label, 0, 3, 1, 1);
grid.attach(settings.auto_unstack, 1, 3, 1, 1);
grid.attach(unstack_label, 0, 3, 1, 1)
grid.attach(settings.auto_unstack, 1, 3, 1, 1)

grid.attach(fullscreen_launcher_label, 0, 4, 1, 1);
grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1);
grid.attach(fullscreen_launcher_label, 0, 4, 1, 1)
grid.attach(settings.fullscreen_launcher, 1, 4, 1, 1)

grid.attach(stacking_with_mouse, 0, 5, 1, 1);
grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1);
grid.attach(stacking_with_mouse, 0, 5, 1, 1)
grid.attach(settings.stacking_with_mouse, 1, 5, 1, 1)

grid.attach(show_skip_taskbar_label, 0, 6, 1, 1);
grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1);
grid.attach(show_skip_taskbar_label, 0, 6, 1, 1)
grid.attach(settings.show_skip_taskbar, 1, 6, 1, 1)

grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1);
grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1);
grid.attach(mouse_cursor_follows_active_window_label, 0, 7, 1, 1)
grid.attach(settings.mouse_cursor_follows_active_window, 1, 7, 1, 1)

return [settings, grid];
}
Expand All @@ -234,22 +225,22 @@ function gaps_section(grid: any, top: number): [any, any] {
let outer_label = new Gtk.Label({
label: "Outer",
xalign: 0.0,
margin_start: 24,
margin_start: 24
});

let outer_entry = number_entry();

let inner_label = new Gtk.Label({
label: "Inner",
xalign: 0.0,
margin_start: 24,
margin_start: 24
});

let inner_entry = number_entry();

let section_label = new Gtk.Label({
label: "Gaps",
xalign: 0.0,
xalign: 0.0
});

grid.attach(section_label, 0, top, 1, 1);
Expand All @@ -269,11 +260,11 @@ function build_combo(
grid: any,
top_index: number,
iter_enum: any,
label: string
label: string,
) {
let label_ = new Gtk.Label({
label: label,
halign: Gtk.Align.START,
halign: Gtk.Align.START
});

grid.attach(label_, 0, top_index, 1, 1);
Expand All @@ -287,14 +278,14 @@ function build_combo(
}

grid.attach(combo, 1, top_index, 1, 1);
return combo;
return combo
}

// @ts-ignore
function buildPrefsWidget() {
let dialog = settings_dialog_new();
if (dialog.show_all) {
dialog.show_all();
dialog.show_all()
} else {
dialog.show();
}
Expand Down
23 changes: 9 additions & 14 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,14 @@ function settings_new_schema(schema: string): Settings {
const schemaDir = Me.dir.get_child("schemas");

let schemaSource = schemaDir.query_exists(null)
? GioSSS.new_from_directory(
schemaDir.get_path(),
GioSSS.get_default(),
false
)
: GioSSS.get_default();
? GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false) :
GioSSS.get_default();

const schemaObj = schemaSource.lookup(schema, true);

if (!schemaObj) {
throw new Error(
"Schema " + schema + " could not be found for extension " + Me.metadata.uuid + ". Please check your installation."
);
throw new Error("Schema " + schema + " could not be found for extension "
+ Me.metadata.uuid + ". Please check your installation.");
}

return new Gio.Settings({ settings_schema: schemaObj });
Expand Down Expand Up @@ -126,15 +121,15 @@ export class ExtensionSettings {

theme(): string {
return this.shell
? this.shell.get_string("name")
: this.int
? this.int.get_string("gtk-theme")
: "Adwaita";
? this.shell.get_string("name")
: this.int
? this.int.get_string("gtk-theme")
: "Adwaita"
}

is_dark(): boolean {
const theme = this.theme().toLowerCase();
return DARK.some((dark) => theme.includes(dark));
return DARK.some(dark => theme.includes(dark));
}

is_high_contrast(): boolean {
Expand Down
10 changes: 5 additions & 5 deletions src/tiling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
const Me = imports.misc.extensionUtils.getCurrentExtension();

// import * as Ecs from 'ecs';
import * as exec from 'executor';
import * as geom from 'geom';
import * as GrabOp from 'grab_op';
import * as Lib from 'lib';
import * as Log from 'log';
import * as Node from 'node';
import * as Rect from 'rectangle';
import * as Tags from 'tags';
import * as window from 'window';
import * as geom from 'geom';
import * as exec from 'executor';

import { AutoTiler } from './auto_tiler';
import type { Entity } from './ecs';
import type { Rectangle } from './rectangle';
import type { Ext } from './extension';
import { Fork } from './fork';
import type { NodeStack } from './node';
import type { Rectangle } from './rectangle';
import { AutoTiler } from './auto_tiler';
import { Fork } from './fork';

const { Meta } = imports.gi;
const Main = imports.ui.main;
Expand Down