Skip to content

Commit

Permalink
Add simple tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Jul 11, 2019
1 parent a57ff07 commit e59adb7
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 10 deletions.
6 changes: 6 additions & 0 deletions assets/icons/tiling/simple-horizontal-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/icons/tiling/simple-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/tiling/simple-vertical-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extension.gresource
Binary file not shown.
3 changes: 3 additions & 0 deletions extension.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
<file>assets/icons/tiling/maximize-symbolic.svg</file>
<file>assets/icons/tiling/native-symbolic.svg</file>
<file>assets/icons/tiling/ratio-symbolic.svg</file>
<file>assets/icons/tiling/simple-horizontal-symbolic.svg</file>
<file>assets/icons/tiling/simple-symbolic.svg</file>
<file>assets/icons/tiling/simple-vertical-symbolic.svg</file>
</gresource>
</gresources>
Binary file modified gschemas.compiled
Binary file not shown.
25 changes: 20 additions & 5 deletions layouts.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
</key>
<key name="half-horizontal" type="b">
<default>false</default>
<summary>Half Horizontal layout</summary>
<description>Tile windows horizontaly</description>
<summary>Half horizontal layout</summary>
<description>Tile windows horizontally</description>
</key>
<key name="half-vertical" type="b">
<default>false</default>
<summary>Half Vertical layout</summary>
<summary>Half vertical layout</summary>
<description>Tile windows vertically</description>
</key>
<key name="ratio" type="b">
<default>false</default>
<summary>Ratio based Grid layout</summary>
<summary>Ratio based grid layout</summary>
<description>Tile windows in both way according to the ratio of the remaining space</description>
</key>
<key name="ratio-value" type="d">
Expand All @@ -32,13 +32,28 @@
</key>
<key name="grid" type="b">
<default>false</default>
<summary>Regular Grid layout</summary>
<summary>Regular grid layout</summary>
<description>Tile windows according to a regular grid</description>
</key>
<key name="float" type="b">
<default>false</default>
<summary>Float layout</summary>
<description>No tiling is done, windows are floating freely</description>
</key>
<key name="simple" type="b">
<default>false</default>
<summary>Simple layout</summary>
<description>Split screen unidirectionally according to screen ratio</description>
</key>
<key name="simple-horizontal" type="b">
<default>false</default>
<summary>Simple horizontal layout</summary>
<description>Split screen horizontally</description>
</key>
<key name="simple-vertical" type="b">
<default>false</default>
<summary>Simple vertical layout</summary>
<description>Split screen vertically</description>
</key>
</schema>
</schemalist>
7 changes: 5 additions & 2 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ const layouts = {
maximize: 'Maximize all windows',
float: 'Windows are not tiled',
half: 'Tile windows according to screen ratio',
'half-horizontal': 'Tile windows horizontaly',
'half-horizontal': 'Tile windows horizontally',
'half-vertical': 'Tile windows vertically',
ratio:
'Tile windows in both way according to the ratio of the remaining space',
grid: 'Tile windows according to a regular grid'
grid: 'Tile windows according to a regular grid',
simple: 'Split screen unidirectionally according to screen ratio',
'simple-horizontal': 'Split screen horizontally',
'simple-vertical': 'Split screen vertically'
};
function buildPrefsWidget() {
let notebook = new Gtk.Notebook();
Expand Down
74 changes: 74 additions & 0 deletions tilingManager/tilingLayouts/custom/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const Main = imports.ui.main;
const { Meta, Gio } = imports.gi;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();

const {
BaseGrabbableLayout
} = Me.imports.tilingManager.tilingLayouts.custom.baseGrabbable;

/* exported SimpleLayout */
var SimpleLayout = class SimpleLayout extends BaseGrabbableLayout {
onTileRegulars(windows) {
if (!windows.length) return;

let workArea = Main.layoutManager.getWorkAreaForMonitor(
this.monitor.index
);

if (workArea.width > workArea.height) {
this.onTileHorizontal(windows);
} else {
this.onTileVertical(windows);
}
}

onTileHorizontal(windows) {
if (!windows.length) return;

let workArea = Main.layoutManager.getWorkAreaForMonitor(
this.monitor.index
);

windows.forEach((window, index) => {
if (window.grabbed) return;

if (window.get_maximized())
window.unmaximize(Meta.MaximizeFlags.BOTH);

this.moveAndResizeMetaWindow(
window,
workArea.x,
workArea.y + (index * workArea.height) / windows.length,
workArea.width,
workArea.height / windows.length
);
});
}

onTileVertical(windows) {
if (!windows.length) return;

let workArea = Main.layoutManager.getWorkAreaForMonitor(
this.monitor.index
);

windows.forEach((window, index) => {
if (window.grabbed) return;

if (window.get_maximized())
window.unmaximize(Meta.MaximizeFlags.BOTH);

this.moveAndResizeMetaWindow(
window,
workArea.x + (index * workArea.width) / windows.length,
workArea.y,
workArea.width / windows.length,
workArea.height
);
});
}
};

SimpleLayout.key = 'simple';
16 changes: 16 additions & 0 deletions tilingManager/tilingLayouts/custom/simpleHorizontal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const Main = imports.ui.main;
const { Meta, Gio } = imports.gi;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();

const { SimpleLayout } = Me.imports.tilingManager.tilingLayouts.custom.simple;

/* exported SimpleHorizontalLayout */
var SimpleHorizontalLayout = class SimpleHorizontalLayout extends SimpleLayout {
onTileRegulars(windows) {
super.onTileHorizontal(windows);
}
};

SimpleHorizontalLayout.key = 'simple-horizontal';
15 changes: 15 additions & 0 deletions tilingManager/tilingLayouts/custom/simpleVertical.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { Gio } = imports.gi;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();

const { SimpleLayout } = Me.imports.tilingManager.tilingLayouts.custom.simple;

/* exported SimpleVerticalLayout */
var SimpleVerticalLayout = class SimpleVerticalLayout extends SimpleLayout {
onTileRegulars(windows) {
super.onTileVertical(windows);
}
};

SimpleVerticalLayout.key = 'simple-vertical';
8 changes: 7 additions & 1 deletion tilingManager/tilingLayouts/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const custom = Me.imports.tilingManager.tilingLayouts.custom;
const { HalfLayout } = custom.half;
const { HalfHorizontalLayout } = custom.halfHorizontal;
const { HalfVerticalLayout } = custom.halfVertical;
const { SimpleLayout } = custom.simple;
const { SimpleHorizontalLayout } = custom.simpleHorizontal;
const { SimpleVerticalLayout } = custom.simpleVertical;
const { RatioLayout } = custom.ratio;
const { GridLayout } = custom.grid;

Expand All @@ -16,7 +19,10 @@ const layouts = [
HalfHorizontalLayout,
HalfVerticalLayout,
RatioLayout,
FloatLayout
FloatLayout,
SimpleLayout,
SimpleHorizontalLayout,
SimpleVerticalLayout
];

/* exported TilingLayoutByKey */
Expand Down
2 changes: 1 addition & 1 deletion tilingManager/tilingLayouts/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var NativeLayout = class NativeLayout extends BaseGrabbableLayout {
// windows[0].maximize(Meta.MaximizeFlags.BOTH);
// } else {
// windows.forEach((window, i) => {
// window.tile(i % 0 ? Meta.Tile.Left : Meta.Tile.RIGHT);
// window.tile(i % 2 ? Meta.Tile.Left : Meta.Tile.RIGHT);
// });
// }
}
Expand Down
1 change: 0 additions & 1 deletion tilingManager/tilingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ var TilingManager = class TilingManager {
(this.availableLayouts.indexOf(key) + 1) %
this.availableLayouts.length
];
log(key, '-->', newKey);
// And returns it
return TilingLayoutByKey[newKey];
}
Expand Down

0 comments on commit e59adb7

Please sign in to comment.