scratch: Use an explicit marker for floating windows

On startup we use a heuristic to figure out which windows should float in the
scratch layer, but from then on we simply check if the window is marked as
floating.

NB: Since `above` is reset when a window is minimized there's no guarantee that
a floating window will be above when visible.
This commit is contained in:
Tor Hedin Brønner
2018-03-10 20:42:00 +01:00
parent 32cca42def
commit d80e2eacc6
2 changed files with 14 additions and 1 deletions
+8 -1
View File
@@ -2,13 +2,16 @@ const Extension = imports.misc.extensionUtils.extensions['paperwm@hedning:matrix
const Meta = imports.gi.Meta;
const utils = Extension.imports.utils;
const debug = utils.debug;
let float;
function makeScratch(metaWindow) {
metaWindow[float] = true;
metaWindow.make_above();
metaWindow.stick();
}
function unmakeScratch(metaWindow) {
metaWindow[float] = false;
metaWindow.unmake_above();
metaWindow.unstick();
}
@@ -22,7 +25,7 @@ function toggle(metaWindow) {
}
function isScratchWindow(metaWindow) {
return metaWindow && (metaWindow.above || metaWindow.minimized);
return metaWindow[float];
}
/** Return scratch windows in MRU order */
@@ -60,6 +63,10 @@ const PopupMenu = imports.ui.popupMenu;
const WindowMenu = imports.ui.windowMenu;
const originalBuildMenu = WindowMenu.WindowMenu.prototype._buildMenu;
function init() {
float = Symbol();
}
function enable() {
WindowMenu.WindowMenu.prototype._buildMenu =
function (window) {
+6
View File
@@ -831,6 +831,12 @@ function add_all_from_workspace(workspace) {
let space = spaces.spaceOf(workspace);
windows.forEach((meta_window, i) => {
if(space.indexOf(meta_window) < 0 && add_filter(meta_window, true)) {
if (meta_window.above || meta_window.minimized) {
// Rough heuristic to figure out if a window should float
Scratch.makeScratch(meta_window);
return;
}
// Using add_handler is unreliable since it interacts with focus.
space.push(meta_window);
meta_window[focus_signal] = meta_window.connect("focus", focus_wrapper);