[gnome-shell-extensions/gnome-3-34] screenshot-window-sizer: Fix cycling through all valid sizes
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions/gnome-3-34] screenshot-window-sizer: Fix cycling through all valid sizes
- Date: Wed, 27 Nov 2019 19:56:58 +0000 (UTC)
commit e5421b6cc62debb51688eab2986df03b9a741912
Author: Willy Stadnick <willy stadnick gmail com>
Date: Sat Nov 23 03:20:45 2019 +0000
screenshot-window-sizer: Fix cycling through all valid sizes
When cycling through window sizes, we should skip any sizes that are
bigger than the available area. We do that, but the current code
assumes that the possible sizes are sorted, which is no longer the
case since the addition of "phone" sizes in commit 5b43d4733c6.
As a result, we may now skip sizes that would fit perfectly fine.
Address this by filtering out invalid sizes beforehand instead of
assuming a certain order (wich no longer work due to the addition
of a portrait format).
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/97
extensions/screenshot-window-sizer/extension.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/extensions/screenshot-window-sizer/extension.js b/extensions/screenshot-window-sizer/extension.js
index c135be6..1a7634c 100644
--- a/extensions/screenshot-window-sizer/extension.js
+++ b/extensions/screenshot-window-sizer/extension.js
@@ -82,7 +82,8 @@ function cycleScreenshotSizes(display, window, binding) {
// Double both axes if on a hidpi display
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
- let scaledSizes = SIZES.map(size => size.map(wh => wh * scaleFactor));
+ let scaledSizes = SIZES.map(size => size.map(wh => wh * scaleFactor))
+ .filter(([w, h]) => w <= workArea.width && h <= workArea.height);
// Find the nearest 16:9 size for the current window size
let nearestIndex;
@@ -105,10 +106,7 @@ function cycleScreenshotSizes(display, window, binding) {
// get the next size up or down from ideal
let newIndex = (nearestIndex + (backwards ? -1 : 1)) % scaledSizes.length;
- let newWidth, newHeight;
- [newWidth, newHeight] = scaledSizes[newIndex];
- if (newWidth > workArea.width || newHeight > workArea.height)
- [newWidth, newHeight] = scaledSizes[0];
+ let [newWidth, newHeight] = scaledSizes[newIndex];
// Push the window onscreen if it would be resized offscreen
let newX = outerRect.x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]