diff --git a/schemas/org.gnome.shell.extensions.fairy.gschema.xml b/schemas/org.gnome.shell.extensions.fairy.gschema.xml
index 826a494..d3a48de 100644
--- a/schemas/org.gnome.shell.extensions.fairy.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.fairy.gschema.xml
@@ -56,7 +56,7 @@
Cycle prev
- ']]]>
+ Return']]]>
Swap the current window with the master
diff --git a/sources/keybinds.js b/sources/keybinds.js
index 3bb59c0..4d88193 100644
--- a/sources/keybinds.js
+++ b/sources/keybinds.js
@@ -43,44 +43,46 @@ var KeyboardManager = GObject.registerClass(
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const currentLayout = state.layout;
- if (state.layout === mode)
- state.layout = state.oldLayout;
- else
- state.layout = mode;
+ if (state.layout === mode) state.layout = state.oldLayout;
+ else state.layout = mode;
state.oldLayout = currentLayout;
this._renderer.render(mon);
}
enable() {
this._addBinding("set-layout-tiling", () => this._switchLayout("tiling"));
- this._addBinding("set-layout-monocle", () => this._switchLayout("monocle"));
- this._addBinding("set-layout-floating", () => this._switchLayout("floating"));
-
+ this._addBinding("set-layout-monocle", () =>
+ this._switchLayout("monocle")
+ );
+ this._addBinding("set-layout-floating", () =>
+ this._switchLayout("floating")
+ );
this._addBinding("cycle-next", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
- this._state.focus(this._state.workIndex(mon, state.tags, idx + 1));
+ const newW = this._state.workIndex(mon, state.tags, idx + 1);
+ this._state.focus(newW.handle);
});
this._addBinding("cycle-prev", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
const idx = this._state.workIndexByHandle(state.focused);
- this._state.focus(this._state.workIndex(mon, state.tags, idx - 1));
+ const win = this._state.workIndex(mon, state.tags, idx - 1);
+ this._state.focus(win.handle);
});
this._addBinding("zoom", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
- const idx = this._state.workIndexByHandle(state.focused);
- if (this._state.workIndexByHandle(state.focused))
- this._state.focus(this._state.workIndex(mon, state.tags, 0));
- else
- this.state.focus(state.beforeZoom);
- state.beforeZoom = state.focused;
+ const beforeZoom = state.focused;
+ if (this._state.workIndexByHandle(state.focused)) {
+ const win = this._state.workIndex(mon, state.tags, 0);
+ this._state.focus(win.handle);
+ } else this.state.focus(state.beforeZoom);
+ state.beforeZoom = beforeZoom;
});
-
this._addBinding("incrmfact", () => {
const mon = global.display.get_current_monitor();
const state = this._state.monitors[mon];
diff --git a/sources/state.js b/sources/state.js
index 0eb983f..9782a18 100644
--- a/sources/state.js
+++ b/sources/state.js
@@ -1,6 +1,9 @@
"use strict";
const GObject = imports.gi.GObject;
+const GLib = imports.gi.GLib;
+const Mainloop = imports.mainloop;
+
var StateManager = GObject.registerClass(
class StateManager extends GObject.Object {
@@ -101,16 +104,30 @@ var StateManager = GObject.registerClass(
/**
* @param {Meta.Window} handle
- * @param {boolean} internalOnly
*/
- focus(handle, internalOnly = false) {
- const mon = handle.get_monitor();
- this.monitors[mon].focused = handle;
- // This was focused without a zoom, removing the old zoom value.
- this.monitors[mon].beforeZoom = null;
+ focus(handle) {
+ GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
+ const mon = handle.get_monitor();
+ this.monitors[mon].focused = handle;
+ // This was focused without a zoom, removing the old zoom value.
+ this.monitors[mon].beforeZoom = null;
- if (!internalOnly)
+ log("focusing window with title", handle.get_title());
+ handle.raise();
handle.focus(global.display.get_current_time());
+ handle.activate(global.display.get_current_time());
+ this.warpCursor(handle);
+ // Do not retrigger this idle.
+ return false;
+ });
+ }
+
+ /**
+ * @param {Meta.Window} handle
+ */
+ warpCusror(handle) {
+ // TODO: Warp the cursor
+ // TODO: Check if the warp-cursor setting is enabled.
}
/**