mirror of
https://github.com/zoriya/fairy.git
synced 2025-12-06 05:36:09 +00:00
Add a deck layout
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
<default><![CDATA[['<Shift><Super>f']]]></default>
|
||||
<summary>Switch to the floating layout</summary>
|
||||
</key>
|
||||
<key type="as" name="set-layout-deck">
|
||||
<default><![CDATA[['<Super>d']]]></default>
|
||||
<summary>Switch to the deck layout</summary>
|
||||
</key>
|
||||
|
||||
<key type="as" name="cycle-next">
|
||||
<default><![CDATA[['<Super>k']]]></default>
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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 [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user