mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-04 11:36:54 +00:00
Port to class in preperation for 3.32
see: https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361 TODO: port the LayoutManager in minimap.js, though it looks like gjs won't deprecrate Lang.Class yet, so it's probably fine to keep using it for now.
This commit is contained in:
+26
-29
@@ -1,6 +1,5 @@
|
||||
var Extension = imports.misc.extensionUtils.extensions['paperwm@hedning:matrix.org'];
|
||||
var Clutter = imports.gi.Clutter;
|
||||
var Lang = imports.lang;
|
||||
var Meta = imports.gi.Meta;
|
||||
var AltTab = imports.ui.altTab;
|
||||
var Main = imports.ui.main;
|
||||
@@ -14,16 +13,14 @@ var debug = utils.debug;
|
||||
|
||||
var prefs = Extension.imports.settings.prefs;
|
||||
|
||||
var LiveAltTab = Lang.Class({
|
||||
Name: 'LiveAltTab',
|
||||
Extends: AltTab.WindowSwitcherPopup,
|
||||
var LiveAltTab = class LiveAltTab extends AltTab.WindowSwitcherPopup {
|
||||
|
||||
_init(reverse) {
|
||||
constructor(reverse) {
|
||||
this.reverse = reverse;
|
||||
this.parent();
|
||||
},
|
||||
super();
|
||||
}
|
||||
|
||||
_getWindowList: function (reverse) {
|
||||
_getWindowList(reverse) {
|
||||
let tabList = global.display.get_tab_list(
|
||||
Meta.TabList.NORMAL_ALL,
|
||||
global.workspace_manager.get_active_workspace())
|
||||
@@ -37,9 +34,9 @@ var LiveAltTab = Lang.Class({
|
||||
} else {
|
||||
return tabList.concat(this.reverse ? scratch.reverse() : scratch);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_initialSelection: function(backward, actionName) {
|
||||
_initialSelection(backward, actionName) {
|
||||
this._block = Main.wm._blockAnimations;
|
||||
Main.wm._blockAnimations = true;
|
||||
this.space = Tiling.spaces.selectedSpace;
|
||||
@@ -65,10 +62,10 @@ var LiveAltTab = Lang.Class({
|
||||
Main.uiGroup.insert_child_above(fog, global.window_group);
|
||||
this.fog = fog;
|
||||
|
||||
this.parent(backward, actionName);
|
||||
},
|
||||
super._initialSelection(backward, actionName);
|
||||
}
|
||||
|
||||
_keyPressHandler: function(keysym, mutterActionId) {
|
||||
_keyPressHandler(keysym, mutterActionId) {
|
||||
if (keysym === Clutter.KEY_Escape)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
// After the first super-tab the mutterActionId we get is apparently
|
||||
@@ -96,10 +93,10 @@ var LiveAltTab = Lang.Class({
|
||||
// action.handler(metaWindow, space);
|
||||
// return true;
|
||||
// }
|
||||
return this.parent(keysym, mutterActionId);
|
||||
},
|
||||
return super._keyPressHandler(keysym, mutterActionId);
|
||||
}
|
||||
|
||||
_select: function(num) {
|
||||
_select(num) {
|
||||
|
||||
let from = this._switcherList.windows[this._selectedIndex];
|
||||
let to = this._switcherList.windows[num];
|
||||
@@ -111,11 +108,11 @@ var LiveAltTab = Lang.Class({
|
||||
let clone = new Clutter.Clone({source: actor});
|
||||
clone.position = actor.position;
|
||||
|
||||
let space = Tiling.spaces.spaceOfWindow(to);
|
||||
let space = Tiling.spaces.spaceOfWindow(to);
|
||||
if (space.indexOf(to) !== -1) {
|
||||
let x = Tiling.ensuredX(to, space) + space.monitor.x;
|
||||
clone.x = x + space.monitor.x ;
|
||||
clone.x -= frame.x - actor.x;
|
||||
clone.x = x + space.monitor.x ;
|
||||
clone.x -= frame.x - actor.x;
|
||||
}
|
||||
|
||||
this.clone = clone;
|
||||
@@ -124,24 +121,24 @@ var LiveAltTab = Lang.Class({
|
||||
// Tiling.ensureViewport(to, space);
|
||||
this._selectedIndex = num;
|
||||
this._switcherList.highlight(num);
|
||||
},
|
||||
}
|
||||
|
||||
_finish: function() {
|
||||
this.parent();
|
||||
_finish() {
|
||||
super._finish();
|
||||
this.was_accepted = true;
|
||||
},
|
||||
}
|
||||
|
||||
_itemEnteredHandler: function() {
|
||||
_itemEnteredHandler() {
|
||||
// The item-enter (mouse hover) event is triggered even after a item is
|
||||
// accepted. This can cause _select to run on the item below the pointer
|
||||
// ensuring the wrong window.
|
||||
if(!this.was_accepted) {
|
||||
this.parent.apply(this, arguments);
|
||||
super._itemEnteredHandler.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onDestroy: function() {
|
||||
this.parent();
|
||||
_onDestroy() {
|
||||
super._onDestroy();
|
||||
debug('#preview', 'onDestroy', this.was_accepted);
|
||||
Main.wm._blockAnimations = this._block;
|
||||
if(!this.was_accepted) {
|
||||
@@ -162,7 +159,7 @@ var LiveAltTab = Lang.Class({
|
||||
let to = this._switcherList.windows[this._selectedIndex];
|
||||
Tiling.focus_handler(to);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function liveAltTab(meta_window, space, {display, screen, binding}) {
|
||||
let tabPopup = new LiveAltTab(binding.is_reversed());
|
||||
|
||||
+19
-23
@@ -7,7 +7,6 @@
|
||||
|
||||
var Extension = imports.misc.extensionUtils.extensions['paperwm@hedning:matrix.org'];
|
||||
var SwitcherPopup = imports.ui.switcherPopup;
|
||||
var Lang = imports.lang;
|
||||
var Meta = imports.gi.Meta;
|
||||
var Main = imports.ui.main;
|
||||
var Mainloop = imports.mainloop;
|
||||
@@ -39,24 +38,21 @@ class SwitcherList {
|
||||
}
|
||||
Signals.addSignalMethods(SwitcherList.prototype);
|
||||
|
||||
var PreviewedWindowNavigator = new Lang.Class({
|
||||
Name: 'PreviewedWindowNavigator',
|
||||
Extends: SwitcherPopup.SwitcherPopup,
|
||||
|
||||
_init: function() {
|
||||
var PreviewedWindowNavigator = class PreviewedWindowNavigator extends SwitcherPopup.SwitcherPopup {
|
||||
constructor() {
|
||||
// Do the absolute minimal here, as `parent.show` is buggy and can
|
||||
// return early making cleanup hard. We do most initialization in
|
||||
// `_initialSelection` instead.
|
||||
|
||||
// HACK: workaround to enable moving from empty workspace. See check in
|
||||
// SwitcherPopup.show
|
||||
this.parent([1]);
|
||||
super([1]);
|
||||
this._switcherList = new SwitcherList();
|
||||
debug('#preview', 'init', this._switcherList);
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
_initialSelection: function(backward, actionName) {
|
||||
_initialSelection(backward, actionName) {
|
||||
debug('#preview', '_initialSelection');
|
||||
this.navigator = getNavigator();
|
||||
let actionId = Keybindings.idOf(actionName);
|
||||
@@ -71,9 +67,9 @@ var PreviewedWindowNavigator = new Lang.Class({
|
||||
}
|
||||
|
||||
this._doAction(actionId);
|
||||
},
|
||||
}
|
||||
|
||||
_doAction: function(mutterActionId) {
|
||||
_doAction(mutterActionId) {
|
||||
|
||||
let action = Keybindings.byId(mutterActionId);
|
||||
if (action && action.options.activeInNavigator) {
|
||||
@@ -90,37 +86,37 @@ var PreviewedWindowNavigator = new Lang.Class({
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
||||
_keyPressHandler: function(keysym, action) {
|
||||
_keyPressHandler(keysym, action) {
|
||||
if (keysym !== Clutter.KEY_Escape && this._doAction(action)) {
|
||||
return Clutter.EVENT_STOP;
|
||||
} else {
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_finish: function(timestamp) {
|
||||
_finish(timestamp) {
|
||||
debug('#preview', 'finish');
|
||||
this.navigator.accept();
|
||||
this.parent(timestamp);
|
||||
},
|
||||
super._finish(timestamp);
|
||||
}
|
||||
|
||||
_itemEnteredHandler: function() {
|
||||
_itemEnteredHandler() {
|
||||
// The item-enter (mouse hover) event is triggered even after a item is
|
||||
// accepted. This can cause _select to run on the item below the pointer
|
||||
// ensuring the wrong window.
|
||||
if(!this.was_accepted) {
|
||||
this.parent.apply(this, arguments);
|
||||
super._itemEnteredHandler.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
destroy: function() {
|
||||
destroy() {
|
||||
this.actor.hide(); // Prevents finalized crap
|
||||
this.parent();
|
||||
super.destroy();
|
||||
this.navigator.destroy();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var navigator;
|
||||
var Navigator = class Navigator {
|
||||
|
||||
@@ -4,7 +4,6 @@ const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Lang = imports.lang;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
|
||||
@@ -175,7 +175,6 @@ function hide() {
|
||||
}
|
||||
|
||||
// Monkey patch the alt-space menu
|
||||
var Lang = imports.lang;
|
||||
var PopupMenu = imports.ui.popupMenu;
|
||||
var WindowMenu = imports.ui.windowMenu;
|
||||
var originalBuildMenu = WindowMenu.WindowMenu.prototype._buildMenu;
|
||||
|
||||
+12
-15
@@ -2,7 +2,6 @@ var Extension = imports.misc.extensionUtils.extensions['paperwm@hedning:matrix.o
|
||||
var Tiling = Extension.imports.tiling;
|
||||
var Clutter = imports.gi.Clutter;
|
||||
var Tweener = imports.ui.tweener;
|
||||
var Lang = imports.lang;
|
||||
var Main = imports.ui.main;
|
||||
var Mainloop = imports.mainloop;
|
||||
var Shell = imports.gi.Shell;
|
||||
@@ -153,10 +152,8 @@ class ClickOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
var StackOverlay = new Lang.Class({
|
||||
Name: 'Stackoverlay',
|
||||
|
||||
_init: function(direction, monitor) {
|
||||
var StackOverlay = class StackOverlay {
|
||||
constructor(direction, monitor) {
|
||||
|
||||
this._direction = direction;
|
||||
|
||||
@@ -194,7 +191,7 @@ var StackOverlay = new Lang.Class({
|
||||
Main.layoutManager.trackChrome(overlay);
|
||||
|
||||
this.overlay = overlay;
|
||||
},
|
||||
}
|
||||
|
||||
triggerPreview() {
|
||||
if ("_previewId" in this)
|
||||
@@ -221,7 +218,7 @@ var StackOverlay = new Lang.Class({
|
||||
x = monitor.x;
|
||||
clone.set_position(x, y);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
removePreview() {
|
||||
if ("_previewId" in this) {
|
||||
@@ -237,9 +234,9 @@ var StackOverlay = new Lang.Class({
|
||||
let space = Tiling.spaces.spaceOfWindow(this.target);
|
||||
// Show the WindowActors again and re-apply clipping
|
||||
space.moveDone();
|
||||
},
|
||||
}
|
||||
|
||||
removeBarrier: function() {
|
||||
removeBarrier() {
|
||||
if (this.barrier) {
|
||||
if (this.pressureBarrier)
|
||||
this.pressureBarrier.removeBarrier(this.barrier);
|
||||
@@ -248,9 +245,9 @@ var StackOverlay = new Lang.Class({
|
||||
this.barrier = null;
|
||||
}
|
||||
this._removeBarrierTimeoutId = 0;
|
||||
},
|
||||
}
|
||||
|
||||
updateBarrier: function(force) {
|
||||
updateBarrier(force) {
|
||||
if (force)
|
||||
this.removeBarrier();
|
||||
|
||||
@@ -289,9 +286,9 @@ var StackOverlay = new Lang.Class({
|
||||
directions
|
||||
});
|
||||
this.pressureBarrier.addBarrier(this.barrier);
|
||||
},
|
||||
}
|
||||
|
||||
setTarget: function(space, index) {
|
||||
setTarget(space, index) {
|
||||
|
||||
if (this.clone) {
|
||||
this.clone.destroy();
|
||||
@@ -360,5 +357,5 @@ var StackOverlay = new Lang.Class({
|
||||
this.updateBarrier();
|
||||
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user