diff options
author | Brian P. Hinz <bphinz@users.sf.net> | 2015-08-20 01:20:10 -0400 |
---|---|---|
committer | Brian P. Hinz <bphinz@users.sf.net> | 2015-08-20 01:20:10 -0400 |
commit | 8442509bca6db16a009784517fd1a2531b9476b6 (patch) | |
tree | 484197c281b5084bc09b0962f59985fa7d7ffe18 /java/com/tigervnc/vncviewer/Viewport.java | |
parent | fa85642107e57195dd3a71e4b755f2474cf61649 (diff) | |
download | tigervnc-8442509bca6db16a009784517fd1a2531b9476b6.tar.gz tigervnc-8442509bca6db16a009784517fd1a2531b9476b6.zip |
Add multiple monitor spanning feature to java viewer
Adds support for spanning multiple monitors in "Extended" mode
to the Java viewer. Allows for spanning when maximizing in
addition to just full-screen mode. Seems a bit unpredictable on
MS Windows 7 (ie: depends on window placement, which screen is
set as primary, etc.), but this appears to be the behavior of
the OS itself.
Diffstat (limited to 'java/com/tigervnc/vncviewer/Viewport.java')
-rw-r--r-- | java/com/tigervnc/vncviewer/Viewport.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java index 8cb87b6f..acc6bfd1 100644 --- a/java/com/tigervnc/vncviewer/Viewport.java +++ b/java/com/tigervnc/vncviewer/Viewport.java @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * Copyright (C) 2011-2014 Brian P. Hinz + * Copyright (C) 2011-2015 Brian P. Hinz * Copyright (C) 2012-2013 D. R. Commander. All Rights Reserved. * * This is free software; you can redistribute it and/or modify @@ -28,12 +28,14 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Image; +import java.awt.Insets; import java.awt.Window; import java.lang.reflect.*; import javax.swing.*; import com.tigervnc.rfb.*; import java.lang.Exception; +import java.awt.Rectangle; public class Viewport extends JFrame { @@ -167,6 +169,32 @@ public class Viewport extends JFrame setLocation(x, y); } + public Dimension getScreenSize() { + return getScreenBounds().getSize(); + } + + public Rectangle getScreenBounds() { + GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + Rectangle r = new Rectangle(); + setMaximizedBounds(null); + if (cc.viewer.fullScreenAllMonitors.getValue()) { + for (GraphicsDevice gd : ge.getScreenDevices()) + for (GraphicsConfiguration gc : gd.getConfigurations()) + r = r.union(gc.getBounds()); + if (!cc.fullScreen) + pack(); + Rectangle mb = new Rectangle(r); + mb.grow(getInsets().left, getInsets().bottom); + setMaximizedBounds(mb); + } else { + GraphicsDevice gd = ge.getDefaultScreenDevice(); + GraphicsConfiguration gc = gd.getDefaultConfiguration(); + r = gc.getBounds(); + } + return r; + } + public static Window getFullScreenWindow() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |