From 328296a2c5a58504dad2917ba5349100030ab10f Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Mon, 7 Aug 2017 10:44:56 +0200 Subject: [PATCH] Only reapply serial monitor last location if it fits the screen There could be a couple of edge cases in this approach (for example, if someone wants to keep the serial monitor window only half visible). However, it should be at least safe (no serial monitors on the second screen) if the Window Manager acts correctly (by moving all the windows on the second monitor to the primary on detach). --- app/src/processing/app/AbstractMonitor.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/processing/app/AbstractMonitor.java b/app/src/processing/app/AbstractMonitor.java index 35c458574..52c5b65b5 100644 --- a/app/src/processing/app/AbstractMonitor.java +++ b/app/src/processing/app/AbstractMonitor.java @@ -59,17 +59,11 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener { pack(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - if (PreferencesData.get("last.screen.height") != null) { - // if screen size has changed, the window coordinates no longer - // make sense, so don't use them unless they're identical - int screenW = PreferencesData.getInteger("last.screen.width"); - int screenH = PreferencesData.getInteger("last.screen.height"); - if ((screen.width == screenW) && (screen.height == screenH)) { - String locationStr = PreferencesData.get("last.serial.location"); - if (locationStr != null) { - int[] location = PApplet.parseInt(PApplet.split(locationStr, ',')); - setPlacement(location); - } + String locationStr = PreferencesData.get("last.serial.location"); + if (locationStr != null) { + int[] location = PApplet.parseInt(PApplet.split(locationStr, ',')); + if (location[0] + location[2] <= screen.width && location[1] + location[3] <= screen.height) { + setPlacement(location); } }