mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-07 04:17:00 +00:00
Move binding registration to init as there's no way to disable
As far as I know there's no to disable a custom key handler, so it makes sense to do this in init which is meant to be run only once.
This commit is contained in:
+62
-62
@@ -62,62 +62,10 @@ window.paperActions = {
|
||||
|
||||
|
||||
function init() {
|
||||
initCount++;
|
||||
SESSIONID += "#"
|
||||
debug('init', SESSIONID);
|
||||
}
|
||||
|
||||
var settings;
|
||||
let nWorkspacesSignal;
|
||||
let workspaceRemovedSignal;
|
||||
let windowCreatedSignal;
|
||||
function enable() {
|
||||
// Only enable after disable have been run
|
||||
if (enabled)
|
||||
return;
|
||||
|
||||
debug('enable', SESSIONID);
|
||||
// HACK: couldn't find an other way within a reasonable time budget
|
||||
// This state is different from being enabled after startup. Existing
|
||||
// windows are not accessible yet for instance.
|
||||
isDuringGnomeShellStartup = Main.actionMode === Shell.ActionMode.NONE;
|
||||
|
||||
nWorkspacesSignal =
|
||||
global.screen.connect('notify::n-workspaces',
|
||||
Lang.bind(Tiling.spaces, utils.dynamic_function_ref('workspacesChanged', Tiling.spaces)));
|
||||
|
||||
workspaceRemovedSignal =
|
||||
global.screen.connect('workspace-removed',
|
||||
utils.dynamic_function_ref('workspaceRemoved', Tiling.spaces));
|
||||
|
||||
windowCreatedSignal =
|
||||
global.display.connect('window-created',
|
||||
utils.dynamic_function_ref('window_created', Tiling.spaces));
|
||||
|
||||
function initWorkspaces() {
|
||||
// Hook up existing workspaces
|
||||
for (let i=0; i < global.screen.n_workspaces; i++) {
|
||||
let workspace = global.screen.get_workspace_by_index(i)
|
||||
Tiling.spaces.addSpace(workspace);
|
||||
debug("workspace", workspace)
|
||||
Tiling.add_all_from_workspace(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
if (isDuringGnomeShellStartup) {
|
||||
// Defer workspace initialization until existing windows are accessible.
|
||||
// Otherwise we're unable to restore the tiling-order. (when restarting
|
||||
// gnome-shell)
|
||||
Main.layoutManager.connect('startup-complete', function() {
|
||||
isDuringGnomeShellStartup = false;
|
||||
initWorkspaces();
|
||||
});
|
||||
} else {
|
||||
initWorkspaces();
|
||||
}
|
||||
|
||||
enabled = true;
|
||||
if(initCount > 1) {
|
||||
if(initCount > 0) {
|
||||
debug("#startup",
|
||||
"Reinitialized against our will! Skip adding bindings again to not cause trouble. ('disable()' isn't fully implemented yet)")
|
||||
return;
|
||||
@@ -127,15 +75,6 @@ function enable() {
|
||||
let dynamic_function_ref = utils.dynamic_function_ref;
|
||||
let as_key_handler = utils.as_key_handler;
|
||||
|
||||
settings = new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings"});
|
||||
|
||||
settings.set_strv("close", ['<super>c'])
|
||||
settings.set_strv("maximize-horizontally", ['<super>f'])
|
||||
settings.set_strv("toggle-fullscreen", ['<super><shift>f']);
|
||||
|
||||
let shell_settings = new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"});
|
||||
shell_settings.set_strv("toggle-overview", ["<super>space"])
|
||||
|
||||
// Or use "toggle-maximize"?
|
||||
Meta.keybindings_set_custom_handler("maximize-horizontally",
|
||||
as_key_handler("toggle_maximize_horizontally",
|
||||
@@ -188,6 +127,67 @@ function enable() {
|
||||
loadRcFile();
|
||||
}
|
||||
|
||||
var settings;
|
||||
let nWorkspacesSignal;
|
||||
let workspaceRemovedSignal;
|
||||
let windowCreatedSignal;
|
||||
function enable() {
|
||||
// Only enable after disable have been run
|
||||
if (enabled)
|
||||
return;
|
||||
|
||||
debug('enable', SESSIONID);
|
||||
// HACK: couldn't find an other way within a reasonable time budget
|
||||
// This state is different from being enabled after startup. Existing
|
||||
// windows are not accessible yet for instance.
|
||||
isDuringGnomeShellStartup = Main.actionMode === Shell.ActionMode.NONE;
|
||||
|
||||
nWorkspacesSignal =
|
||||
global.screen.connect('notify::n-workspaces',
|
||||
Lang.bind(Tiling.spaces, utils.dynamic_function_ref('workspacesChanged', Tiling.spaces)));
|
||||
|
||||
workspaceRemovedSignal =
|
||||
global.screen.connect('workspace-removed',
|
||||
utils.dynamic_function_ref('workspaceRemoved', Tiling.spaces));
|
||||
|
||||
windowCreatedSignal =
|
||||
global.display.connect('window-created',
|
||||
utils.dynamic_function_ref('window_created', Tiling.spaces));
|
||||
|
||||
function initWorkspaces() {
|
||||
// Hook up existing workspaces
|
||||
for (let i=0; i < global.screen.n_workspaces; i++) {
|
||||
let workspace = global.screen.get_workspace_by_index(i)
|
||||
Tiling.spaces.addSpace(workspace);
|
||||
debug("workspace", workspace)
|
||||
Tiling.add_all_from_workspace(workspace);
|
||||
}
|
||||
}
|
||||
|
||||
if (isDuringGnomeShellStartup) {
|
||||
// Defer workspace initialization until existing windows are accessible.
|
||||
// Otherwise we're unable to restore the tiling-order. (when restarting
|
||||
// gnome-shell)
|
||||
Main.layoutManager.connect('startup-complete', function() {
|
||||
isDuringGnomeShellStartup = false;
|
||||
initWorkspaces();
|
||||
});
|
||||
} else {
|
||||
initWorkspaces();
|
||||
}
|
||||
|
||||
let settings = new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings"});
|
||||
|
||||
settings.set_strv("close", ['<super>c'])
|
||||
settings.set_strv("maximize-horizontally", ['<super>f'])
|
||||
settings.set_strv("toggle-fullscreen", ['<super><shift>f']);
|
||||
|
||||
let shell_settings = new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"});
|
||||
shell_settings.set_strv("toggle-overview", ["<super>space"])
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
function disable() {
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user