diff options
author | Jiri Vanek <[email protected]> | 2013-01-10 17:57:19 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-01-10 17:57:19 +0100 |
commit | f38ac428ba5289313c21623a267cedcde554bf95 (patch) | |
tree | 52b6c8479ef829b867ba4b2abaa985085a8aa414 | |
parent | 5d5ba9ba1d34ae35503ba016ceaabab2afe7fefe (diff) |
All IcedTea-Web dialogues are centered to middle of active screen
Active screen in this context is the one, where the mouse is presented
or default when no mouse presention detected.
Patch is affecteing only IcedTea-Web custom dialogues.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/JNLPSplashScreen.java | 8 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java | 6 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java | 6 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/security/SecurityDialog.java | 7 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java | 7 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java | 3 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/ScreenFinder.java | 100 |
9 files changed, 128 insertions, 24 deletions
@@ -1,3 +1,17 @@ +2013-01-10 Jiri Vanek <[email protected]> + + All IcedTea-Web dialogues are centered to middle of active screen + * NEWS: mentioned this feature + * netx/net/sourceforge/jnlp/JNLPSplashScreen.java: + * netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java: + * netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java: + * netx/net/sourceforge/jnlp/security/SecurityDialog.java: + * netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java: + * netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java: + Dialogues in above classes made centering to active screen + * netx/net/sourceforge/jnlp/util/ScreenFinder.java: New file, utility + class which can find active monitor and center dialogue into it. + 2013-01-09 Jiri Vanek <[email protected]> First part of fix of recreating desktop icon @@ -11,6 +11,7 @@ CVE-XXXX-YYYY: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=XXXX-YYYY New in release 1.4 (2012-XX-XX): * Added cs_CZ localisation * Splash screen for javaws and plugin +* All IcedTea-Web dialogues are centered to middle of active screen * Security updates - CVE-2012-3422, RH840592: Potential read from an uninitialized memory location - CVE-2012-3423, RH841345: Incorrect handling of not 0-terminated strings diff --git a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java index 77698db..6a8a221 100644 --- a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java +++ b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java @@ -43,6 +43,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Insets; +import java.awt.Rectangle; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; @@ -53,6 +54,7 @@ import net.sourceforge.jnlp.splashscreen.SplashPanel; import net.sourceforge.jnlp.splashscreen.SplashUtils; import net.sourceforge.jnlp.splashscreen.parts.InformationElement; import net.sourceforge.jnlp.util.ImageResources; +import net.sourceforge.jnlp.util.ScreenFinder; public class JNLPSplashScreen extends JDialog { @@ -145,11 +147,7 @@ public class JNLPSplashScreen extends JDialog { setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); setSize(new Dimension(minimumWidth, minimumHeight)); setPreferredSize(new Dimension(minimumWidth, minimumHeight)); - // Centering to middle of Toolkit.getDefaultToolkit().getScreenSize() - // centers to the middle of all monitors. Let's center to the middle - // of the primary monitor instead. - // TODO center on the 'current' monitor to meet user expectation - setLocationRelativeTo(null); + ScreenFinder.centerWindowsToCurrentScreen(this); } @Override diff --git a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java index 462bf65..398bc15 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java +++ b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java @@ -32,6 +32,7 @@ import javax.swing.JDialog; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.ImageResources; +import net.sourceforge.jnlp.util.ScreenFinder; /** * This dialog provides a means for user to edit more of the proxy settings. @@ -106,10 +107,7 @@ public class AdvancedProxySettingsDialog extends JDialog { * Center the dialog box. */ private void centerDialog() { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension dialogSize = getSize(); - - setLocation((screen.width - dialogSize.width) / 2, (screen.height - dialogSize.height) / 2); + ScreenFinder.centerWindowsToCurrentScreen(this); } /** diff --git a/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java b/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java index a06165a..fc63b60 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java +++ b/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java @@ -31,6 +31,7 @@ import javax.swing.JDialog; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.ImageResources; +import net.sourceforge.jnlp.util.ScreenFinder; /** * This class will provide a visual way of viewing cache. @@ -113,9 +114,6 @@ public class CacheViewer extends JDialog { * Center the dialog box. */ private void centerDialog() { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension dialogSize = getSize(); - - setLocation((screen.width - dialogSize.width) / 2, (screen.height - dialogSize.height) / 2); + ScreenFinder.centerWindowsToCurrentScreen(this); } } diff --git a/netx/net/sourceforge/jnlp/security/SecurityDialog.java b/netx/net/sourceforge/jnlp/security/SecurityDialog.java index 3c11326..6420c29 100644 --- a/netx/net/sourceforge/jnlp/security/SecurityDialog.java +++ b/netx/net/sourceforge/jnlp/security/SecurityDialog.java @@ -52,6 +52,7 @@ import java.security.cert.X509Certificate; import java.util.concurrent.CopyOnWriteArrayList; import java.util.List; +import net.sourceforge.jnlp.util.ScreenFinder; /** * Provides methods for showing security warning dialogs for a wide range of @@ -312,11 +313,7 @@ public class SecurityDialog extends JDialog { } private static void centerDialog(JDialog dialog) { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension dialogSize = dialog.getSize(); - - dialog.setLocation((screen.width - dialogSize.width) / 2, - (screen.height - dialogSize.height) / 2); + ScreenFinder.centerWindowsToCurrentScreen(dialog); } private void selectDefaultButton() { diff --git a/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java b/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java index 2792fb9..1a76663 100644 --- a/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java +++ b/netx/net/sourceforge/jnlp/security/viewer/CertificateViewer.java @@ -52,6 +52,7 @@ import javax.swing.UIManager; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.ImageResources; +import net.sourceforge.jnlp.util.ScreenFinder; public class CertificateViewer extends JDialog { @@ -94,11 +95,7 @@ public class CertificateViewer extends JDialog { } private void centerDialog() { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension dialogSize = getSize(); - - setLocation((screen.width - dialogSize.width) / 2, - (screen.height - dialogSize.height) / 2); + ScreenFinder.centerWindowsToCurrentScreen(this); } public static void showCertificateViewer() throws Exception { diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java index 729b278..8bef868 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java +++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java @@ -58,6 +58,7 @@ import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason; import net.sourceforge.jnlp.splashscreen.parts.BasicComponentSplashScreen; import net.sourceforge.jnlp.splashscreen.parts.InfoItem; import net.sourceforge.jnlp.splashscreen.parts.InformationElement; +import net.sourceforge.jnlp.util.ScreenFinder; public class BasePainter implements Observer { @@ -281,7 +282,7 @@ public class BasePainter implements Observer { showInfo = false; } } - if (Math.min(h, w) < Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 10) { + if (Math.min(h, w) < ScreenFinder.getCurrentScreenSizeWithoutBounds().getHeight() / 10) { showNiceTexts = false; } else { showNiceTexts = true; diff --git a/netx/net/sourceforge/jnlp/util/ScreenFinder.java b/netx/net/sourceforge/jnlp/util/ScreenFinder.java new file mode 100644 index 0000000..b633ae2 --- /dev/null +++ b/netx/net/sourceforge/jnlp/util/ScreenFinder.java @@ -0,0 +1,100 @@ +/* ScreenFinder.java +Copyright (C) 2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ +package net.sourceforge.jnlp.util; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; + +public class ScreenFinder { + + public static GraphicsDevice getCurrentScreen() { + Point p = MouseInfo.getPointerInfo().getLocation(); + return getScreenOnCoords(p); + + } + public static Rectangle getCurrentScreenSizeWithoutBounds() { + Point p = MouseInfo.getPointerInfo().getLocation(); + return getScreenOnCoordsWithutBounds(p); + + } + + public static void centerWindowsToCurrentScreen(Window w) { + Rectangle bounds = getCurrentScreenSizeWithoutBounds(); + w.setLocation(bounds.x + (bounds.width - w.getWidth())/2, + bounds.y + (bounds.height - w.getHeight())/2); + + } + + public static GraphicsDevice getScreenOnCoords(Point point) { + GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice[] devices = e.getScreenDevices(); + GraphicsDevice result = null; + //now get the configuration(s) for each device + for (GraphicsDevice device : devices) { + //GraphicsConfiguration[] configurations = device.getConfigurations(); + //or? + GraphicsConfiguration[] configurations = new GraphicsConfiguration[]{device.getDefaultConfiguration()}; + for (GraphicsConfiguration config : configurations) { + Rectangle gcBounds = config.getBounds(); + if (gcBounds.contains(point)) { + result = device; + } + } + } + if (result == null) { + //not found, get the default display + result = e.getDefaultScreenDevice(); + } + return result; + } + + public static Rectangle getScreenOnCoordsWithutBounds(Point p) { + GraphicsDevice device = getScreenOnCoords(p); + Rectangle screenSize = device.getDefaultConfiguration().getBounds(); + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(device.getDefaultConfiguration()); + return new Rectangle((int)screenSize.getX()+insets.left, (int)screenSize.getY()+insets.top, (int)screenSize.getWidth()-insets.left, (int)screenSize.getHeight()-insets.bottom); + } + + +} |