Added final mouse support with double widths

This commit is contained in:
Fmstrat
2020-01-03 11:51:45 -05:00
parent 030ad5a47a
commit 32b33c4134
4 changed files with 87 additions and 25 deletions

View File

@@ -29,6 +29,7 @@ let config = {
debug: true,
preview: {
enabled: true,
doubleWidth: true,
close: 75,
delay: 500
}
@@ -48,6 +49,7 @@ let settings = new Gio.Settings({
function updateSettings() {
config.cols = (settings.get_value('cols').deep_unpack())+2;
config.preview.doubleWidth = settings.get_value('double-width').deep_unpack();
config.useMaximize = settings.get_value('use-maximize').deep_unpack();
config.preview.enabled = settings.get_value('preview').deep_unpack();
config.debug = settings.get_value('debug').deep_unpack();
@@ -609,7 +611,7 @@ function windowGrabEnd(meta_display, meta_screen, meta_window, meta_grab_op, gpo
var app = global.display.focus_window;
if (!app.wintile)
initApp(app)
moveApp(app, { "row": preview.row, "col": preview.col, "height": 1, "width": 1, "mouse": true });
moveApp(app, { "row": preview.loc.row, "col": preview.loc.col, "height": preview.loc.height, "width": preview.loc.width, "mouse": true });
hidePreview();
}
}
@@ -643,11 +645,10 @@ var preview = new St.BoxLayout({
});
Main.uiGroup.add_actor(preview);
function showPreview(col, row, _x, _y, _w, _h) {
function showPreview(loc, _x, _y, _w, _h) {
Tweener.removeTweens(preview);
preview.visible = true;
preview.col = col;
preview.row = row;
preview.loc = loc;
Tweener.addTween(preview, {
time: 0.125,
opacity: 255,
@@ -663,8 +664,7 @@ function showPreview(col, row, _x, _y, _w, _h) {
function hidePreview() {
Tweener.removeTweens(preview);
preview.visible = false;
preview.col = null;
preview.row = null;
preview.loc = null;
}
function checkIfNearGrid(app) {
@@ -686,34 +686,73 @@ function checkIfNearGrid(app) {
_log(`space - x:${space.x} y:${space.y} w:${space.width} h:${space.height}`);
for (var i = 0; i < config.cols; i++) {
var grid_x = i * colWidth + space.x;
if (inMonitorBounds && (isClose(y, space.y) || y < space.y) && x > grid_x && x < grid_x+colWidth) {
// If we are close to the top, show a preview for the top grid item
showPreview(i, 0, grid_x, space.y, colWidth, rowHeight)
if (inMonitorBounds && (isClose(y, space.y) || y < space.y) && x > Math.floor(space.width/2+space.x-colWidth/2) && x < Math.floor(space.width/2+space.x+colWidth/2)) {
// If we are in the center top, show a preview for maximize
showPreview({ col:0, row:0, width:config.cols, height:2 }, space.x, space.y, space.width, space.height)
close = true;
break;
} else if (inMonitorBounds && (isClose(y, space.y+space.height) || y > space.y+space.height) && x > grid_x && x < grid_x+colWidth) {
// If we are close to the bottom, show a preview for the bottom grid item
showPreview(i, 1, grid_x, space.y+rowHeight, colWidth, rowHeight)
} else if (inMonitorBounds && (isClose(x, space.x) || x < space.x) && y > Math.floor(space.height/2+space.y-rowHeight/2) && y < Math.floor(space.height/2+space.y+rowHeight/2)) {
// If we are in the center left, show a preview for left maximize
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:0, row:0, width:2, height:2 }, space.x, space.y, colWidth*2, space.height)
} else {
showPreview({ col:0, row:0, width:1, height:2 }, space.x, space.y, colWidth, space.height)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(x, space.x+space.width) || x > space.x+space.width) && y > Math.floor(space.height/2+space.y-rowHeight/2) && y < Math.floor(space.height/2+space.y+rowHeight/2)) {
// If we are in the center right, show a preview for right maximize
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:config.cols-2, row:0, width:2, height:2 }, space.x+space.width-colWidth*2, space.y, colWidth*2, space.height)
} else {
showPreview({ col:config.cols-1, row:0, width:1, height:2 }, space.x+space.width-colWidth, space.y, colWidth, space.height)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(x, space.x) || x < space.x) && y > space.y && y < space.y+rowHeight) {
// If we are close to the top left, show the top left grid item
showPreview(0, 0, space.x, space.y, colWidth, rowHeight)
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:0, row:0, width:2, height:1 }, space.x, space.y, colWidth*2, rowHeight)
} else {
showPreview({ col:0, row:0, width:1, height:1 }, space.x, space.y, colWidth, rowHeight)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(x, space.x) || x < space.x) && y > space.y+rowHeight) {
// If we are close to the bottom left, show the bottom left grid item
showPreview(0, 1, space.x, space.y+rowHeight, colWidth, rowHeight)
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:0, row:1, width:2, height:1 }, space.x, space.y+rowHeight, colWidth*2, rowHeight)
} else {
showPreview({ col:0, row:1, width:1, height:1 }, space.x, space.y+rowHeight, colWidth, rowHeight)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(x, space.x+space.width) || x > space.x+space.width) && y > space.y && y < space.y+rowHeight) {
// If we are close to the top right, show the top right grid item
showPreview(config.cols, 0, space.x+space.width-colWidth, space.y, colWidth, rowHeight)
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:config.cols-2, row:0, width:2, height:1 }, space.x+space.width-colWidth*2, space.y, colWidth*2, rowHeight)
} else {
showPreview({ col:config.cols-1, row:0, width:1, height:1 }, space.x+space.width-colWidth, space.y, colWidth, rowHeight)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(x, space.x+space.width) || x > space.x+space.width) && y > space.y+rowHeight) {
// If we are close to the bottom right, show the bottom right grid item
showPreview(config.cols, 1, space.x+space.width-colWidth, space.y+rowHeight, colWidth, rowHeight)
if (config.cols == 4 && config.preview.doubleWidth) {
showPreview({ col:config.cols-2, row:1, width:2, height:1 }, space.x+space.width-colWidth*2, space.y+rowHeight, colWidth*2, rowHeight)
} else {
showPreview({ col:config.cols-1, row:1, width:1, height:1 }, space.x+space.width-colWidth, space.y+rowHeight, colWidth, rowHeight)
}
close = true;
break;
} else if (inMonitorBounds && (isClose(y, space.y) || y < space.y) && x > grid_x && x < grid_x+colWidth) {
// If we are close to the top, show a preview for the top grid item
showPreview({ col:i, row:0, width:1, height:1 }, grid_x, space.y, colWidth, rowHeight)
close = true;
break;
} else if (inMonitorBounds && (isClose(y, space.y+space.height) || y > space.y+space.height) && x > grid_x && x < grid_x+colWidth) {
// If we are close to the bottom, show a preview for the bottom grid item
showPreview({ col:i, row:1, width:1, height:1 }, grid_x, space.y+rowHeight, colWidth, rowHeight)
close = true;
break;
}

View File

@@ -50,6 +50,8 @@ function buildPrefsWidget() {
row_spacing: 12,
visible: true
});
let row = 0;
// Add a simple title and add it to the layout
let title = new Gtk.Label({
@@ -58,7 +60,7 @@ function buildPrefsWidget() {
use_markup: true,
visible: true
});
layout.attach(title, 0, 0, 2, 1);
layout.attach(title, 0, row++, 2, 1);
// Column setting
let colsLabel = new Gtk.Label({
@@ -73,8 +75,23 @@ function buildPrefsWidget() {
});
colsInput.pack_start (rendererText, false);
colsInput.add_attribute (rendererText, "text", 0);
layout.attach(colsLabel, 0, 1, 1, 1);
layout.attach(colsInput, 1, 1, 1, 1);
layout.attach(colsLabel, 0, row, 1, 1);
layout.attach(colsInput, 1, row++, 1, 1);
// Maximize setting
let doubleWidthLabel = new Gtk.Label({
label: _("Use double width previews on sides in 4 column mode"),
visible: true,
hexpand: true,
halign: Gtk.Align.START
});
let doubleWidthInput = new Gtk.Switch({
active: this.settings.get_boolean ('double-width'),
halign: Gtk.Align.END,
visible: true
});
layout.attach(doubleWidthLabel, 0, row, 1, 1);
layout.attach(doubleWidthInput, 1, row++, 1, 1);
// Maximize setting
let maximizeLabel = new Gtk.Label({
@@ -88,8 +105,8 @@ function buildPrefsWidget() {
halign: Gtk.Align.END,
visible: true
});
layout.attach(maximizeLabel, 0, 2, 1, 1);
layout.attach(maximizeInput, 1, 2, 1, 1);
layout.attach(maximizeLabel, 0, row, 1, 1);
layout.attach(maximizeInput, 1, row++, 1, 1);
// Preview setting
let previewLabel = new Gtk.Label({
@@ -103,8 +120,8 @@ function buildPrefsWidget() {
halign: Gtk.Align.END,
visible: true
});
layout.attach(previewLabel, 0, 3, 1, 1);
layout.attach(previewInput, 1, 3, 1, 1);
layout.attach(previewLabel, 0, row, 1, 1);
layout.attach(previewInput, 1, row++, 1, 1);
// Debug setting
let debugLabel = new Gtk.Label({
@@ -118,10 +135,11 @@ function buildPrefsWidget() {
halign: Gtk.Align.END,
visible: true
});
layout.attach(debugLabel, 0, 4, 1, 1);
layout.attach(debugInput, 1, 4, 1, 1);
layout.attach(debugLabel, 0, row, 1, 1);
layout.attach(debugInput, 1, row++, 1, 1);
this.settings.bind('cols', colsInput, 'active', Gio.SettingsBindFlags.DEFAULT);
this.settings.bind('double-width', doubleWidthInput, 'active', Gio.SettingsBindFlags.DEFAULT);
this.settings.bind('use-maximize', maximizeInput, 'active', Gio.SettingsBindFlags.DEFAULT);
this.settings.bind('preview', previewInput, 'active', Gio.SettingsBindFlags.DEFAULT);
this.settings.bind('debug', debugInput, 'active', Gio.SettingsBindFlags.DEFAULT);

Binary file not shown.

View File

@@ -7,6 +7,11 @@
<description></description>
<range min="0" max="2"/>
</key>
<key name="double-width" type="b">
<default>true</default>
<summary>Use double width previews on sides in 4 column mode</summary>
<description>When on, dragging a window to the side will preview 2 columns wide instead of 1.</description>
</key>
<key name="use-maximize" type="b">
<default>true</default>
<summary>Turn on/off use of maximizing windows</summary>