From 32b33c41340f0dbb24026dec7ff09fe037aacf14 Mon Sep 17 00:00:00 2001 From: Fmstrat Date: Fri, 3 Jan 2020 11:51:45 -0500 Subject: [PATCH] Added final mouse support with double widths --- extension.js | 71 ++++++++++++++---- prefs.js | 36 ++++++--- schemas/gschemas.compiled | Bin 460 -> 512 bytes ...gnome.shell.extensions.wintile.gschema.xml | 5 ++ 4 files changed, 87 insertions(+), 25 deletions(-) diff --git a/extension.js b/extension.js index f07deac..0d3433a 100644 --- a/extension.js +++ b/extension.js @@ -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; } diff --git a/prefs.js b/prefs.js index 5c2a218..c4ab543 100644 --- a/prefs.js +++ b/prefs.js @@ -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); diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 3c6a08b1ff2a9c18bc65557ad2f5ef2572c49b4d..a142997d40a97a5c45d7fd99f36715a08c0d6ac7 100644 GIT binary patch literal 512 zcmY*WJxjzu5S`PDDHOy)u(nFT%a)c`-U$|BA$F3OCAW}|Bb!{#;}jb^OOg4;`1dyP7`N?jU5 zcVSq|L|=#xPSPfQGGk+wM_!a>iS%?&#<3@dg-o@|QteeLEmSPIo*diI{|~pA1vvL` zcr?%b&A(_sTS!*G+Resd6M5Da{A2J5@Me$J*=M}~e*(S)I_2pj`>bvFx8OTqdVbb? z{(JBfaJ~J0#`UbZ&olT1xM-h`*=OB^{|e^Wy}n=c;0p{c%;3TdF8&4=_27a?hcYN5 zlp~zL4YM+cWvf!5>A`M;{eCV7N>;yXh&hupS8VRc!n)M5mH0!IsF5`L_On>?raJPP P&3ih^IdGJ6UDvqZJxOH~ literal 460 zcmYLGu};G<6nupi29OW~5;Kz{m3U=A9a|(O2EuA zi#O?%n7@Inh{M=qsS52xB}u5}r7~7$#)dO(N}VV^Ph!In5x=$W(FS*b?%TfmW2jDUAdiL|gKI?7xIk*D))x(N?)|>F}!1uuC&FvO{J8QoG5&X{D z&%~N%`T+A>mughSY`GGnV4NkkS%M3%U2Z~)E1`7|1eH~XX*AcVzE;#C^yP(`YBl5I hZXM=PIjNf^f|D*d>4KC0!AT#SB(mtMi!*Ef(;pJwSd0Jw diff --git a/schemas/org.gnome.shell.extensions.wintile.gschema.xml b/schemas/org.gnome.shell.extensions.wintile.gschema.xml index 8663584..f82c4e3 100644 --- a/schemas/org.gnome.shell.extensions.wintile.gschema.xml +++ b/schemas/org.gnome.shell.extensions.wintile.gschema.xml @@ -7,6 +7,11 @@ + + true + Use double width previews on sides in 4 column mode + When on, dragging a window to the side will preview 2 columns wide instead of 1. + true Turn on/off use of maximizing windows