mirror of
https://github.com/zoriya/fairy.git
synced 2025-12-06 05:36:09 +00:00
Fix focus keybinds
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
<summary>Cycle prev</summary>
|
||||
</key>
|
||||
<key type="as" name="zoom">
|
||||
<default><![CDATA[['<Super><Return>']]]></default>
|
||||
<default><![CDATA[['<Super>Return']]]></default>
|
||||
<summary>Swap the current window with the master</summary>
|
||||
</key>
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user