From bc40b86ace7eba25ceebbb429fbf3c660919190b Mon Sep 17 00:00:00 2001 From: Kevin Langman Date: Mon, 25 Mar 2024 21:29:49 -0400 Subject: [PATCH] [adjacent-windows@klangman] Add two algorithm tuning options (#588) 1. Added two configuration options to offer some advanced controls over how the algorithm works when using the "Closest with a visible corner" setting. 2. Moved files to a 5.4 directory as an added protection ensuring that the extension is only used in Cinnamon 5.4 or higher. 3. Fixed some typos in the README.md file. --- adjacent-windows@klangman/CHANGELOG.md | 8 ++- adjacent-windows@klangman/README.md | 6 +- .../{ => 5.4}/extension.js | 47 ++++++++----- .../{ => 5.4}/settings-schema.json | 22 +++++++ .../adjacent-windows@klangman/metadata.json | 2 +- .../po/adjacent-windows@klangman.pot | 66 ++++++++++++++----- .../files/adjacent-windows@klangman/po/es.po | 64 +++++++++++++----- 7 files changed, 159 insertions(+), 56 deletions(-) rename adjacent-windows@klangman/files/adjacent-windows@klangman/{ => 5.4}/extension.js (88%) rename adjacent-windows@klangman/files/adjacent-windows@klangman/{ => 5.4}/settings-schema.json (72%) diff --git a/adjacent-windows@klangman/CHANGELOG.md b/adjacent-windows@klangman/CHANGELOG.md index 26d5128a..ea61cecc 100644 --- a/adjacent-windows@klangman/CHANGELOG.md +++ b/adjacent-windows@klangman/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.1.0 + +* Added two configuration options to offer some advanced controls over how the algorithm works when using the "Closest with a visible corner" window selection option. These options might help some people achieve a window selection behaviour that is more to their liking. +* Moved files to a 5.4 directory as an added protection ensuring that the extension is only used in Cinnamon 5.4 or higher. +* Fixed some typos in the README.md + ## 1.0.0 -* Initial verion commited to cinnamon spices +* Initial version commited to cinnamon spices diff --git a/adjacent-windows@klangman/README.md b/adjacent-windows@klangman/README.md index 616654a9..c5ad8531 100644 --- a/adjacent-windows@klangman/README.md +++ b/adjacent-windows@klangman/README.md @@ -1,10 +1,10 @@ # Adjacent Windows -A Cinnamon extension that allows you to define hot keys which will activate the nearest window to the current window on the left, right, above, below or underneath. There is also an option (disabled by default) to undo the window change and activate the window that previously had the focus. With this extension you can easily switch the window focus without reaching for the mouse and it's faster than using Alt-TAB. It's particularly useful for people frequently who use window tiling. +A Cinnamon extension that allows you to define hotkeys which will activate the nearest window to the current window on the left, right, above, below or underneath. There is also an option (disabled by default) to undo the window change and activate the window that previously had the focus. With this extension you can easily change the window focus without reaching for the mouse and it's faster than using Alt-TAB. It's particularly useful for people who frequently use window tiling. -By default the Super+Alt+(arrow-keys) are defined as the hotkeys to move to adjacent windows, but this can be changed in the configuration. If you like, for instance, the Vim key bindings, you could change them to Super+h/j/k/l. The default hotkey for activating windows underneath the current window is Super+Alt+Insert (Keypad) +By default the Super+Alt+(arrow-keys) are defined as the hotkeys to move to adjacent windows, but this can be changed in the configuration. If for example, you like the Vim key bindings, you could change the hotkeys to be Super+h/j/k/l. The default hotkey for activating windows underneath the current window is Super+Alt+Insert (Keypad). ## Requirements -This applet requires at least Mint 21 / Cinnamon 5.4 because the Meta.Window.get_frame_rect() API is needed. +This extension requires at least Linux Mint 21 / Cinnamon 5.4 because the Meta.Window.get_frame_rect() API is needed. ## Installation 1. Right click on the cinnamon panel and click "System Settings" diff --git a/adjacent-windows@klangman/files/adjacent-windows@klangman/extension.js b/adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/extension.js similarity index 88% rename from adjacent-windows@klangman/files/adjacent-windows@klangman/extension.js rename to adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/extension.js index 9563a3be..94b84d4b 100644 --- a/adjacent-windows@klangman/files/adjacent-windows@klangman/extension.js +++ b/adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/extension.js @@ -277,6 +277,9 @@ class AdjacentWindows { let candidateList = []; let windowVisibilityList = []; let allowOtherMon = this.settings.getValue("include-other-monitors"); + let zoneReductionPercent = this.settings.getValue("boost-restriction"); + let zoneReduction = Math.round( ((direction == Direction.Left || direction == Direction.Right)? focusedRec.height : focusedRec.width) * (zoneReductionPercent/100) / 2 ); + let cornerAllowance = this.settings.getValue("overlap-allowance"); // Sort the list of windows in z-order (most recently focused is first in the list). windowList.sort(function(a, b) {return b.user_time - a.user_time;}); @@ -293,31 +296,43 @@ class AdjacentWindows { if (metaWindow != focusedWindow) { if (direction == Direction.Left) { if (rec.x < focusedRec.x) { - windowVisibilityList[idx].overlapping = (rec.y < focusedRec.y+focusedRec.height && rec.y+rec.height > focusedRec.y); - windowVisibilityList[idx].rec.width = Math.min(rec.width, focusedRec.x-1-rec.x); - windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x, rec.x+rec.width, rec.y, rec.y+rec.height ); - candidateList.push(windowVisibilityList[idx]); + windowVisibilityList[idx].overlapping = (rec.y < focusedRec.y+focusedRec.height-zoneReduction && rec.y+rec.height > focusedRec.y+zoneReduction); + rec.width = Math.min(rec.width, focusedRec.x-1-rec.x); + if (rec.width >= cornerAllowance && rec.height >= cornerAllowance) { + windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x+cornerAllowance, rec.x+rec.width-cornerAllowance, rec.y+cornerAllowance, rec.y+rec.height-cornerAllowance ); + candidateList.push(windowVisibilityList[idx]); + } } } else if (direction == Direction.Right) { if (rec.x+rec.width > focusedRec.x+focusedRec.width) { - windowVisibilityList[idx].overlapping = (rec.y < focusedRec.y+focusedRec.height && rec.y+rec.height > focusedRec.y); - windowVisibilityList[idx].rec.x = Math.max(rec.x, focusedRec.x+focusedRec.width+1); - windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x, rec.x+rec.width, rec.y, rec.y+rec.height ); - candidateList.push(windowVisibilityList[idx]); + windowVisibilityList[idx].overlapping = (rec.y < focusedRec.y+focusedRec.height-zoneReduction && rec.y+rec.height > focusedRec.y+zoneReduction); + let x2 = rec.x+rec.width; + rec.x = Math.max(rec.x, focusedRec.x+focusedRec.width+1); + rec.width = x2 - rec.x; + if (rec.width >= cornerAllowance && rec.height >= cornerAllowance) { + windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x+cornerAllowance, rec.x+rec.width-cornerAllowance, rec.y+cornerAllowance, rec.y+rec.height-cornerAllowance ); + candidateList.push(windowVisibilityList[idx]); + } } } else if (direction == Direction.Up) { if (rec.y < focusedRec.y) { - windowVisibilityList[idx].overlapping = (rec.x < focusedRec.x+focusedRec.width && rec.x+rec.width > focusedRec.x) - windowVisibilityList[idx].rec.height = Math.min(rec.height, focusedRec.y-1-rec.y); - windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x, rec.x+rec.width, rec.y, rec.y+rec.height ); - candidateList.push(windowVisibilityList[idx]); + windowVisibilityList[idx].overlapping = (rec.x < focusedRec.x+focusedRec.width-zoneReduction && rec.x+rec.width > focusedRec.x+zoneReduction) + rec.height = Math.min(rec.height, focusedRec.y-1-rec.y); + if (rec.width >= cornerAllowance && rec.height >= cornerAllowance) { + windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x+cornerAllowance, rec.x+rec.width-cornerAllowance, rec.y+cornerAllowance, rec.y+rec.height-cornerAllowance ); + candidateList.push(windowVisibilityList[idx]); + } } } else if (direction == Direction.Down) { if (rec.y+rec.height > focusedRec.y+focusedRec.height) { - windowVisibilityList[idx].overlapping = (rec.x < focusedRec.x+focusedRec.width && rec.x+rec.width > focusedRec.x) - windowVisibilityList[idx].rec.y = Math.max(rec.y, focusedRec.y+focusedRec.height+1); - windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x, rec.x+rec.width, rec.y, rec.y+rec.height ); - candidateList.push(windowVisibilityList[idx]); + windowVisibilityList[idx].overlapping = (rec.x < focusedRec.x+focusedRec.width-zoneReduction && rec.x+rec.width > focusedRec.x+zoneReduction) + let y2 = rec.y+rec.height; + rec.y = Math.max(rec.y, focusedRec.y+focusedRec.height+1); + rec.height = y2 - rec.y; + if (rec.width >= cornerAllowance && rec.height >= cornerAllowance) { + windowVisibilityList[idx].cornerVisibility = this.getCornerVisibility( windowVisibilityList[idx], windowList, rec.x+cornerAllowance, rec.x+rec.width-cornerAllowance, rec.y+cornerAllowance, rec.y+rec.height-cornerAllowance ); + candidateList.push(windowVisibilityList[idx]); + } } } } diff --git a/adjacent-windows@klangman/files/adjacent-windows@klangman/settings-schema.json b/adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/settings-schema.json similarity index 72% rename from adjacent-windows@klangman/files/adjacent-windows@klangman/settings-schema.json rename to adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/settings-schema.json index e57a1d0d..dfb925dc 100644 --- a/adjacent-windows@klangman/files/adjacent-windows@klangman/settings-schema.json +++ b/adjacent-windows@klangman/files/adjacent-windows@klangman/5.4/settings-schema.json @@ -49,6 +49,28 @@ "description": "Activate the window that is...", "tooltip": "When using the Left, Right, Above or Below hotkeys, activate the window that is either:\n- Closest to the current window: this might activate a window that is currently completely obscured by other windows.\n- Highest in the z-order: most recently focused; this might skip over visible windows that are closer to the current window.\n- Closest window with a visible corner: a compromise that is designed to be more like what most people would generally expect (I hope)." }, + "overlap-allowance": { + "type": "spinbutton", + "default": 0, + "min": 0, + "max": 50, + "units": "pixels", + "step": 1, + "description": "Corner overlap allowance / minimum visibility", + "tooltip": "Sets how many pixels a corner can be obscured by other windows and still be considered a candidate window. Also sets the minimum amount of window visibility in order to qualify as a candidate window", + "dependency": "next-focus=2" + }, + "boost-restriction": { + "type": "spinbutton", + "default": 0, + "min": 0, + "max": 85, + "units": "priority", + "step": 1, + "description": "Increase the priority of direction alignment", + "tooltip": "Increasing this setting gives more priority to windows that occupy the same area as the current window in the desired direction, and less priority to widows that are at an offset but closer. Max 85%", + "dependency": "next-focus=2" + }, "include-minimized": { "type": "switch", "default": false, diff --git a/adjacent-windows@klangman/files/adjacent-windows@klangman/metadata.json b/adjacent-windows@klangman/files/adjacent-windows@klangman/metadata.json index 7c8125f4..e37f5339 100644 --- a/adjacent-windows@klangman/files/adjacent-windows@klangman/metadata.json +++ b/adjacent-windows@klangman/files/adjacent-windows@klangman/metadata.json @@ -1,7 +1,7 @@ { "uuid": "adjacent-windows@klangman", "name": "Adjacent Windows", - "version": "1.0.0", + "version": "1.1.0", "description": "Use hotkeys to switch to adjacent windows", "url": "https://github.com/klangman/Adjacent-Windows", "website": "https://github.com/klangman/Adjacent-Windows", diff --git a/adjacent-windows@klangman/files/adjacent-windows@klangman/po/adjacent-windows@klangman.pot b/adjacent-windows@klangman/files/adjacent-windows@klangman/po/adjacent-windows@klangman.pot index d18e2027..e92023ca 100644 --- a/adjacent-windows@klangman/files/adjacent-windows@klangman/po/adjacent-windows@klangman.pot +++ b/adjacent-windows@klangman/files/adjacent-windows@klangman/po/adjacent-windows@klangman.pot @@ -5,10 +5,10 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: adjacent-windows@klangman 1.0.0\n" +"Project-Id-Version: adjacent-windows@klangman 1.1.0\n" "Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-" "extensions/issues\n" -"POT-Creation-Date: 2024-03-17 22:29-0400\n" +"POT-Creation-Date: 2024-03-25 21:17-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -25,31 +25,31 @@ msgstr "" msgid "Use hotkeys to switch to adjacent windows" msgstr "" -#. settings-schema.json->keybinding-header->description +#. 5.4->settings-schema.json->keybinding-header->description msgid "Hotkeys to switch focus relative to the current window" msgstr "" -#. settings-schema.json->left-key->description +#. 5.4->settings-schema.json->left-key->description msgid "Activate window to the left" msgstr "" -#. settings-schema.json->right-key->description +#. 5.4->settings-schema.json->right-key->description msgid "Activate window to the right" msgstr "" -#. settings-schema.json->up-key->description +#. 5.4->settings-schema.json->up-key->description msgid "Activate window above" msgstr "" -#. settings-schema.json->down-key->description +#. 5.4->settings-schema.json->down-key->description msgid "Activate window below" msgstr "" -#. settings-schema.json->under-key->description +#. 5.4->settings-schema.json->under-key->description msgid "Activate window under" msgstr "" -#. settings-schema.json->under-key->tooltip +#. 5.4->settings-schema.json->under-key->tooltip msgid "" "Switch to the next window in the z-order that is overlapped by the current " "window. If the key combo is pressed again within 3 sec, the focus will " @@ -57,31 +57,31 @@ msgid "" "during the fist key combo press." msgstr "" -#. settings-schema.json->back-key->description +#. 5.4->settings-schema.json->back-key->description msgid "Undo the focus change" msgstr "" -#. settings-schema.json->settings-header->description +#. 5.4->settings-schema.json->settings-header->description msgid "Other settings" msgstr "" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Closest to the current window" msgstr "" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Highest in the z-order" msgstr "" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Closest with a visible corner" msgstr "" -#. settings-schema.json->next-focus->description +#. 5.4->settings-schema.json->next-focus->description msgid "Activate the window that is..." msgstr "" -#. settings-schema.json->next-focus->tooltip +#. 5.4->settings-schema.json->next-focus->tooltip msgid "" "When using the Left, Right, Above or Below hotkeys, activate the window that " "is either:\n" @@ -93,10 +93,40 @@ msgid "" "more like what most people would generally expect (I hope)." msgstr "" -#. settings-schema.json->include-minimized->description +#. 5.4->settings-schema.json->overlap-allowance->units +msgid "pixels" +msgstr "" + +#. 5.4->settings-schema.json->overlap-allowance->description +msgid "Corner overlap allowance / minimum visibility" +msgstr "" + +#. 5.4->settings-schema.json->overlap-allowance->tooltip +msgid "" +"Sets how many pixels a corner can be obscured by other windows and still be " +"considered a candidate window. Also sets the minimum amount of window " +"visibility in order to qualify as a candidate window" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->units +msgid "priority" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->description +msgid "Increase the priority of direction alignment" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->tooltip +msgid "" +"Increasing this setting gives more priority to windows that occupy the same " +"area as the current window in the desired direction, and less priority to " +"widows that are at an offset but closer. Max 85%" +msgstr "" + +#. 5.4->settings-schema.json->include-minimized->description msgid "Allow switching to minimized windows" msgstr "" -#. settings-schema.json->include-other-monitors->description +#. 5.4->settings-schema.json->include-other-monitors->description msgid "Allow switching to windows on other monitors" msgstr "" diff --git a/adjacent-windows@klangman/files/adjacent-windows@klangman/po/es.po b/adjacent-windows@klangman/files/adjacent-windows@klangman/po/es.po index 832dae52..2479236a 100644 --- a/adjacent-windows@klangman/files/adjacent-windows@klangman/po/es.po +++ b/adjacent-windows@klangman/files/adjacent-windows@klangman/po/es.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: adjacent-windows@klangman 1.0.0\n" "Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-" "extensions/issues\n" -"POT-Creation-Date: 2024-03-17 22:29-0400\n" +"POT-Creation-Date: 2024-03-25 21:17-0400\n" "PO-Revision-Date: 2024-03-18 01:00-0300\n" "Last-Translator: \n" "Language-Team: \n" @@ -25,32 +25,32 @@ msgstr "Ventanas adyacentes" msgid "Use hotkeys to switch to adjacent windows" msgstr "Utilice teclas de acceso rápido para cambiar a ventanas adyacentes" -#. settings-schema.json->keybinding-header->description +#. 5.4->settings-schema.json->keybinding-header->description msgid "Hotkeys to switch focus relative to the current window" msgstr "" "Teclas de acceso rápido para cambiar el enfoque relativo a la ventana actual" -#. settings-schema.json->left-key->description +#. 5.4->settings-schema.json->left-key->description msgid "Activate window to the left" msgstr "Activar ventana a la izquierda" -#. settings-schema.json->right-key->description +#. 5.4->settings-schema.json->right-key->description msgid "Activate window to the right" msgstr "Activar ventana a la derecha" -#. settings-schema.json->up-key->description +#. 5.4->settings-schema.json->up-key->description msgid "Activate window above" msgstr "Activar la ventana de arriba" -#. settings-schema.json->down-key->description +#. 5.4->settings-schema.json->down-key->description msgid "Activate window below" msgstr "Activar la ventana de abajo" -#. settings-schema.json->under-key->description +#. 5.4->settings-schema.json->under-key->description msgid "Activate window under" msgstr "Activar ventana debajo" -#. settings-schema.json->under-key->tooltip +#. 5.4->settings-schema.json->under-key->tooltip msgid "" "Switch to the next window in the z-order that is overlapped by the current " "window. If the key combo is pressed again within 3 sec, the focus will " @@ -63,31 +63,31 @@ msgstr "" "ventana que tenía el foco originalmente durante la primera pulsación de la " "combinación de teclas." -#. settings-schema.json->back-key->description +#. 5.4->settings-schema.json->back-key->description msgid "Undo the focus change" msgstr "Deshacer el cambio de enfoque" -#. settings-schema.json->settings-header->description +#. 5.4->settings-schema.json->settings-header->description msgid "Other settings" msgstr "Otros ajustes" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Closest to the current window" msgstr "Más cerca de la ventana actual" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Highest in the z-order" msgstr "Más alta en el orden z" -#. settings-schema.json->next-focus->options +#. 5.4->settings-schema.json->next-focus->options msgid "Closest with a visible corner" msgstr "Más cercana con una esquina visible" -#. settings-schema.json->next-focus->description +#. 5.4->settings-schema.json->next-focus->description msgid "Activate the window that is..." msgstr "Active la ventana que está..." -#. settings-schema.json->next-focus->tooltip +#. 5.4->settings-schema.json->next-focus->tooltip msgid "" "When using the Left, Right, Above or Below hotkeys, activate the window that " "is either:\n" @@ -107,10 +107,40 @@ msgstr "" "- Ventana más cercana con una esquina visible: un compromiso diseñado para " "que se parezca más a lo que la mayoría de la gente esperaría (espero)." -#. settings-schema.json->include-minimized->description +#. 5.4->settings-schema.json->overlap-allowance->units +msgid "pixels" +msgstr "" + +#. 5.4->settings-schema.json->overlap-allowance->description +msgid "Corner overlap allowance / minimum visibility" +msgstr "" + +#. 5.4->settings-schema.json->overlap-allowance->tooltip +msgid "" +"Sets how many pixels a corner can be obscured by other windows and still be " +"considered a candidate window. Also sets the minimum amount of window " +"visibility in order to qualify as a candidate window" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->units +msgid "priority" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->description +msgid "Increase the priority of direction alignment" +msgstr "" + +#. 5.4->settings-schema.json->boost-restriction->tooltip +msgid "" +"Increasing this setting gives more priority to windows that occupy the same " +"area as the current window in the desired direction, and less priority to " +"widows that are at an offset but closer. Max 85%" +msgstr "" + +#. 5.4->settings-schema.json->include-minimized->description msgid "Allow switching to minimized windows" msgstr "Permitir el cambio a ventanas minimizadas" -#. settings-schema.json->include-other-monitors->description +#. 5.4->settings-schema.json->include-other-monitors->description msgid "Allow switching to windows on other monitors" msgstr "Permitir el cambio a ventanas de otros monitores"