From f295e51d5967fbd777bc43a5c8b9ef16715ca258 Mon Sep 17 00:00:00 2001 From: pax Date: Mon, 6 Apr 2026 15:07:43 -0500 Subject: [PATCH] Clamp popout to both screen width and height on aspect change --- booru_viewer/gui/preview.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/booru_viewer/gui/preview.py b/booru_viewer/gui/preview.py index 6e5e1ed..2ec4dd0 100644 --- a/booru_viewer/gui/preview.py +++ b/booru_viewer/gui/preview.py @@ -256,13 +256,16 @@ class FullscreenPreview(QMainWindow): aspect = content_w / content_h w = self.width() new_h = int(w / aspect) - # Clamp to screen bounds if portrait content would overspill + # Clamp to screen bounds if content would overspill screen = self.screen() if screen: - max_h = screen.availableGeometry().height() - if new_h > max_h: - new_h = max_h + avail = screen.availableGeometry() + if new_h > avail.height(): + new_h = avail.height() w = int(new_h * aspect) + if w > avail.width(): + w = avail.width() + new_h = int(w / aspect) self.resize(w, new_h) self._hyprctl_resize(w, new_h)