mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-08-14 13:10:24 +00:00
Basic scratch toggle
Stack ordering isn't preserved properly. Use <Super>e to toggle for now.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Extension = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const convenience = Extension.imports.convenience;
|
||||
const Tiling = Extension.imports.tiling;
|
||||
const Scratch = Extension.imports.scratch;
|
||||
const utils = Extension.utils;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Meta = imports.gi.Meta;
|
||||
@@ -84,6 +85,7 @@ function enable() {
|
||||
// Must use `Meta.keybindings_set_custom_handler` to re-assign handler?
|
||||
set_action_handler("move-left", dynamic_function_ref("move_left"));
|
||||
set_action_handler("move-right", dynamic_function_ref("move_right"));
|
||||
set_action_handler("toggle-scratch-layer", dynamic_function_ref("toggleScratch"));
|
||||
}
|
||||
|
||||
function disable() {
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
const Meta = imports.gi.Meta;
|
||||
|
||||
toggleScratch = function() {
|
||||
let workspace = global.screen.get_active_workspace()
|
||||
let windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace)
|
||||
.filter(function(meta_window) {
|
||||
return meta_window.is_on_all_workspaces();
|
||||
});
|
||||
|
||||
let isSomeShown = windows.reduce(function(shown, meta_window) {
|
||||
return shown || !meta_window.minimized;
|
||||
}, false)
|
||||
|
||||
if (isSomeShown) {
|
||||
windows.map(function(meta_window) {
|
||||
meta_window.minimize();
|
||||
})
|
||||
} else {
|
||||
windows.map(function(meta_window) {
|
||||
meta_window.unminimize();
|
||||
meta_window.make_above();
|
||||
})
|
||||
windows[0].activate(global.get_current_time())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user