mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-06 11:56:54 +00:00
Refactor switch-next/previous
This commit is contained in:
committed by
Tor Hedin Brønner
parent
0b551114b3
commit
39e0a68d3c
+2
-2
@@ -88,8 +88,8 @@ function init() {
|
||||
registerPaperAction('move-previous-workspace', previewNavigate);
|
||||
registerPaperAction('move-previous-workspace-backward', previewNavigate);
|
||||
|
||||
registerPaperAction("switch-next", previewNavigate);
|
||||
registerPaperAction("switch-previous", previewNavigate);
|
||||
registerNavigatorAction("switch-next", (mw, space) => space.switchLinear(1));
|
||||
registerNavigatorAction("switch-previous", (mw, space) => space.switchLinear(-1));
|
||||
|
||||
registerPaperAction("switch-first", Tiling.activateFirstWindow);
|
||||
registerPaperAction("switch-last", Tiling.activateLastWindow);
|
||||
|
||||
+1
-38
@@ -58,37 +58,6 @@ var PreviewedWindowNavigator = new Lang.Class({
|
||||
|
||||
},
|
||||
|
||||
_next: function() {
|
||||
let index = this.space.selectedIndex();
|
||||
let column = this.space[index];
|
||||
if (!column)
|
||||
return false;
|
||||
let row = column.indexOf(this.space.selectedWindow);
|
||||
if (row + 1 >= column.length) {
|
||||
index = Math.min(this.space.length-1, index + 1);
|
||||
row = 0;
|
||||
} else {
|
||||
row++;
|
||||
}
|
||||
return [index, row];
|
||||
},
|
||||
|
||||
_previous: function() {
|
||||
let index = this.space.selectedIndex();
|
||||
let column = this.space[index];
|
||||
if (!column)
|
||||
return false;
|
||||
let row = column.indexOf(this.space.selectedWindow);
|
||||
if (row - 1 < 0) {
|
||||
index = Math.max(0, index - 1);
|
||||
column = this.space[index];
|
||||
row = column.length - 1;
|
||||
} else {
|
||||
row--;
|
||||
}
|
||||
return [index, row];
|
||||
},
|
||||
|
||||
_initialSelection: function(backward, actionName) {
|
||||
debug('#preview', '_initialSelection');
|
||||
TopBar.show();
|
||||
@@ -280,13 +249,7 @@ var PreviewedWindowNavigator = new Lang.Class({
|
||||
break;
|
||||
}
|
||||
|
||||
if (mutterActionId === Keybindings.idOf("switch-next")) {
|
||||
this._select(this._next());
|
||||
return true;
|
||||
} else if (mutterActionId === Keybindings.idOf("switch-previous")) {
|
||||
this._select(this._previous());
|
||||
return true;
|
||||
} else if (mutterActionId
|
||||
if (mutterActionId
|
||||
=== Keybindings.idOf('previous-workspace-backward')) {
|
||||
this.selectSpace(Meta.MotionDirection.UP);
|
||||
return true;
|
||||
|
||||
@@ -391,6 +391,29 @@ class Space extends Array {
|
||||
ensureViewport(this.selectedWindow, this, true);
|
||||
}
|
||||
|
||||
switchLinear(dir) {
|
||||
let index = this.selectedIndex();
|
||||
let column = this[index];
|
||||
if (!column)
|
||||
return false;
|
||||
let row = column.indexOf(this.selectedWindow);
|
||||
if (utils.in_bounds(column, row + dir) == false) {
|
||||
index += dir;
|
||||
if (dir === 1) {
|
||||
if (index < this.length) row = 0;
|
||||
} else {
|
||||
if (index >= 0)
|
||||
row = this[index].length - 1
|
||||
}
|
||||
} else {
|
||||
row += dir;
|
||||
}
|
||||
|
||||
let metaWindow = this.getWindow(index, row);
|
||||
ensureViewport(metaWindow, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
switchLeft() { this.switch(Meta.MotionDirection.LEFT) }
|
||||
switchRight() { this.switch(Meta.MotionDirection.RIGHT) }
|
||||
switchUp() { this.switch(Meta.MotionDirection.UP) }
|
||||
|
||||
Reference in New Issue
Block a user