From 19c2258e698aa8b114fcd2cb256cfc8325780690 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:48:37 +0100 Subject: [PATCH] added boundary check. see #685 --- mzta-background.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index b7beef8b..549fcd59 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -805,8 +805,18 @@ function applyWindowPositionAndSize(win_options, prefs){ taLog.log("Applying saved window dimensions: width=" + prefs.chatgpt_win_width + ", height=" + prefs.chatgpt_win_height); } if((prefs.chatgpt_win_top != '') && (prefs.chatgpt_win_left != '')){ - win_options.top = prefs.chatgpt_win_top; - win_options.left = prefs.chatgpt_win_left; + // Check if the saved position is within the current screen bounds (supports multiple monitors) + let isWithinBounds = ( + prefs.chatgpt_win_left >= window.screen.availLeft && + prefs.chatgpt_win_top >= window.screen.availTop && + prefs.chatgpt_win_left < (window.screen.availLeft + window.screen.availWidth) && + prefs.chatgpt_win_top < (window.screen.availTop + window.screen.availHeight) + ); + + if (isWithinBounds) { + win_options.top = prefs.chatgpt_win_top; + win_options.left = prefs.chatgpt_win_left; + } taLog.log("Applying saved window position: top=" + prefs.chatgpt_win_top + ", left=" + prefs.chatgpt_win_left); } return win_options;