diff --git a/schemas/org.gnome.shell.extensions.fairy.gschema.xml b/schemas/org.gnome.shell.extensions.fairy.gschema.xml index e933549..b49e6f0 100644 --- a/schemas/org.gnome.shell.extensions.fairy.gschema.xml +++ b/schemas/org.gnome.shell.extensions.fairy.gschema.xml @@ -50,6 +50,10 @@ f']]]> Switch to the floating layout + + d']]]> + Switch to the deck layout + k']]]> diff --git a/sources/keybinds.js b/sources/keybinds.js index d78a268..78360be 100644 --- a/sources/keybinds.js +++ b/sources/keybinds.js @@ -47,6 +47,7 @@ var KeyboardManager = GObject.registerClass( this._addBinding("set-layout-floating", () => this._switchLayout("floating") ); + this._addBinding("set-layout-deck", () => this._switchLayout("deck")); this._addBinding("cycle-prev", () => { const mon = global.display.get_current_monitor(); @@ -164,6 +165,7 @@ var KeyboardManager = GObject.registerClass( this._removeBinding("set-layout-tiling"); this._removeBinding("set-layout-monocle"); this._removeBinding("set-layout-floating"); + this._removeBinding("set-layout-deck"); this._removeBinding("cycle-next"); this._removeBinding("cycle-prev"); diff --git a/sources/state.js b/sources/state.js index ec922ed..aa7beb5 100644 --- a/sources/state.js +++ b/sources/state.js @@ -142,22 +142,22 @@ var StateManager = GObject.registerClass( * @returns WindowGeometry[] */ render(mon, tags) { - const { layout, nmaster, mfact } = this.monitors[mon]; const windows = this.windows.filter( (x) => x.monitor === mon && x.tags & tags ); log(`${windows.length} windows for monitor ${mon} with tags ${tags}`); + return this._layout(this.monitors[mon], windows); + } + + _layout({ layout, nmaster, mfact, focused }, windows) { + const focusedW = this.windows.find((x) => x.handle === focused); - // TODO: Implement other layouts switch (layout) { case "monocle": - const focused = this.windows.find( - (x) => x.handle === this.monitors[mon].focused - ); return [ { - ...focused, - handle: focused.handle, + ...focusedW, + handle: focusedW.handle, maximized: true, minimized: false, x: 0, @@ -184,8 +184,8 @@ var StateManager = GObject.registerClass( windows.length <= nmaster || nmaster <= 0 ? 100 : i < nmaster - ? mfact - : 100 - mfact, + ? mfact + : 100 - mfact, height: 100 / stackLength, }; }); @@ -195,6 +195,23 @@ var StateManager = GObject.registerClass( handle: x.handle, floating: true, })); + case "deck": + if (windows.length < 2) { + return this._layout( + { layout: "tiling", nmaster, mfact, focused }, + windows + ); + } + const deckWindows = + windows[0] === focusedW + ? windows.splice(0, 2) + : [windows[0], focusedW]; + // Raise the window else lower docks can be above + deckWindows[1].handle.raise(); + return this._layout( + { layout: "tiling", nmaster, mfact, focused }, + deckWindows + ); default: return []; }