]> source.dussan.org Git - tigervnc.git/commitdiff
Add multiple monitor spanning feature to java viewer
authorBrian P. Hinz <bphinz@users.sf.net>
Thu, 20 Aug 2015 05:20:10 +0000 (01:20 -0400)
committerBrian P. Hinz <bphinz@users.sf.net>
Thu, 20 Aug 2015 05:20:10 +0000 (01:20 -0400)
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.

java/com/tigervnc/vncviewer/CConn.java
java/com/tigervnc/vncviewer/OptionsDialog.java
java/com/tigervnc/vncviewer/Viewport.java
java/com/tigervnc/vncviewer/VncViewer.java

index 71bd090166338a1177d65cc9c484529a7b6afb03..280b1b4f2ba9822ea5827b07a12ca88e43392763 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
  * Copyright 2009-2013 Pierre Ossman <ossman@cendio.se> for Cendio AB
  * Copyright (C) 2011-2013 D. R. Commander.  All Rights Reserved.
- * Copyright (C) 2011-2014 Brian P. Hinz
+ * Copyright (C) 2011-2015 Brian P. Hinz
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -548,6 +548,7 @@ public class CConn extends CConnection implements
     menu.fullScreen.setEnabled(s);
     menu.newConn.setEnabled(s);
     options.fullScreen.setEnabled(s);
+    options.fullScreenAllMonitors.setEnabled(s);
     options.scalingFactor.setEnabled(s);
   }
 
@@ -569,16 +570,17 @@ public class CConn extends CConnection implements
   }
 
   private void reconfigureViewport() {
-    //viewport.setMaxSize(cp.width, cp.height);
     boolean pack = true;
-    Dimension dpySize = viewport.getToolkit().getScreenSize();
+    Dimension dpySize = viewport.getScreenSize();
     desktop.setScaledSize();
     int w = desktop.scaledWidth;
     int h = desktop.scaledHeight;
     if (fullScreen) {
-      viewport.setExtendedState(JFrame.MAXIMIZED_BOTH);
-      viewport.setGeometry(0, 0, dpySize.width, dpySize.height, false);
-      Viewport.setFullScreenWindow(viewport);
+      if (!viewer.fullScreenAllMonitors.getValue())
+        viewport.setExtendedState(JFrame.MAXIMIZED_BOTH);
+      viewport.setBounds(viewport.getScreenBounds());
+      if (!viewer.fullScreenAllMonitors.getValue())
+        Viewport.setFullScreenWindow(viewport);
     } else {
       int wmDecorationWidth = viewport.getInsets().left + viewport.getInsets().right;
       int wmDecorationHeight = viewport.getInsets().top + viewport.getInsets().bottom;
@@ -982,6 +984,7 @@ public class CConn extends CConnection implements
     }
 
     options.fullScreen.setSelected(fullScreen);
+    options.fullScreenAllMonitors.setSelected(viewer.fullScreenAllMonitors.getValue());
     options.useLocalCursor.setSelected(viewer.useLocalCursor.getValue());
     options.acceptBell.setSelected(viewer.acceptBell.getValue());
     String scaleString = viewer.scalingFactor.getValue();
@@ -1211,8 +1214,19 @@ public class CConn extends CConnection implements
     String desktopSize = (options.desktopSize.isSelected()) ?
         options.desktopWidth.getText() + "x" + options.desktopHeight.getText() : "";
     viewer.desktopSize.setParam(desktopSize);
-    if (options.fullScreen.isSelected() ^ fullScreen)
+    if (options.fullScreen.isSelected() ^ fullScreen) {
+      viewer.fullScreenAllMonitors.setParam(options.fullScreenAllMonitors.isSelected());
       toggleFullScreen();
+    } else {
+      if (viewer.fullScreenAllMonitors.getValue() !=
+          options.fullScreenAllMonitors.isSelected()) {
+        viewer.fullScreenAllMonitors.setParam(options.fullScreenAllMonitors.isSelected());
+        if (desktop != null)
+          recreateViewport();
+      } else {
+        viewer.fullScreenAllMonitors.setParam(options.fullScreenAllMonitors.isSelected());
+      }
+    }
   }
 
   public void toggleFullScreen() {
index 8c9542cb44206abb5d1914fbde0fc1767c43fc92..ebfaed732462c54b2d6105a3ee60a644fe51416f 100644 (file)
@@ -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
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -62,7 +62,7 @@ class OptionsDialog extends Dialog implements
   JRadioButton zrle, hextile, tight, raw;
   JRadioButton fullColour, mediumColour, lowColour, veryLowColour;
   JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell;
-  JCheckBox desktopSize, fullScreen, shared, useLocalCursor;
+  JCheckBox desktopSize, fullScreen, fullScreenAllMonitors, shared, useLocalCursor;
   JCheckBox secVeNCrypt, encNone, encTLS, encX509;
   JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;
   JButton okButton, cancelButton;
@@ -185,6 +185,9 @@ class OptionsDialog extends Dialog implements
     fullScreen = new JCheckBox("Full-screen mode");
     fullScreen.addItemListener(this);
     fullScreen.setEnabled(!cc.viewer.embed.getValue());
+    fullScreenAllMonitors = new JCheckBox("Enable full-screen mode over all monitors");
+    fullScreenAllMonitors.addItemListener(this);
+    fullScreenAllMonitors.setEnabled(!cc.viewer.embed.getValue());
     JLabel scalingFactorLabel = new JLabel("Scaling Factor");
     Object[] scalingFactors = {
       "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%",
@@ -206,6 +209,7 @@ class OptionsDialog extends Dialog implements
     addGBComponent(desktopSize,ScreenPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5));
     addGBComponent(desktopSizePanel,ScreenPanel, 0, 1, 2, 1, 2, 2, 1, 0, GridBagConstraints.REMAINDER, GridBagConstraints.LINE_START, new Insets(0,20,0,0));
     addGBComponent(fullScreen,ScreenPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,5));
+    addGBComponent(fullScreenAllMonitors,ScreenPanel, 0, 3, 4, 1, 2, 2, 1, 0, GridBagConstraints.REMAINDER, GridBagConstraints.LINE_START, new Insets(4,25,0,5));
     addGBComponent(scalingFactorLabel,ScreenPanel, 0, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 1, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(8,8,0,5));
     addGBComponent(scalingFactor,ScreenPanel, 1, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));
 
@@ -330,6 +334,7 @@ class OptionsDialog extends Dialog implements
     veryLowColour.setEnabled(!autoSelect.isSelected());
     compressLevel.setEnabled(customCompressLevel.isSelected());
     qualityLevel.setEnabled(noJpeg.isSelected());
+    fullScreenAllMonitors.setEnabled(fullScreen.isSelected());
     sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&&
       (secPlain.isSelected()||secIdent.isSelected()));
   }
@@ -374,6 +379,7 @@ class OptionsDialog extends Dialog implements
       desktopSize.isSelected() ? desktopWidth.getText() + "x" + desktopHeight.getText() : "";
     UserPreferences.set("global", "DesktopSize", desktopSizeString);
     UserPreferences.set("global", "FullScreen", fullScreen.isSelected());
+    UserPreferences.set("global", "FullScreenAllMonitors", fullScreenAllMonitors.isSelected());
     UserPreferences.set("global", "Shared", shared.isSelected());
     UserPreferences.set("global", "UseLocalCursor", useLocalCursor.isSelected());
     UserPreferences.set("global", "AcceptBell", acceptBell.isSelected());
@@ -451,6 +457,7 @@ class OptionsDialog extends Dialog implements
       desktopHeight.setText(desktopSizeString.split("x")[1]);
     }
     fullScreen.setSelected(UserPreferences.getBool("global", "FullScreen"));
+    fullScreenAllMonitors.setSelected(UserPreferences.getBool("global", "FullScreenAllMonitors"));
     if (shared.isEnabled())
       shared.setSelected(UserPreferences.getBool("global", "Shared"));
     useLocalCursor.setSelected(UserPreferences.getBool("global", "UseLocalCursor"));
index 8cb87b6f0b181d9430d7f5b51d5c75a2f19f60b6..acc6bfd1bfe91d031c4e81ab3ac7bc47a5d9b495 100644 (file)
@@ -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();
index 1a49d00989771e5d19ec0c0eb9b4fa9d85115045..0f7ce8eb366e578c4217b0827b564a0c354171fd 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
  * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
  * Copyright (C) 2011-2013 D. R. Commander.  All Rights Reserved.
- * Copyright (C) 2011-2014 Brian P. Hinz
+ * Copyright (C) 2011-2015 Brian P. Hinz
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -56,7 +56,7 @@ public class VncViewer extends javax.swing.JApplet
 
   public static final String aboutText = new String("TigerVNC Java Viewer v%s (%s)%n"+
                                                     "Built on %s at %s%n"+
-                                                    "Copyright (C) 1999-2013 TigerVNC Team and many others (see README.txt)%n"+
+                                                    "Copyright (C) 1999-2015 TigerVNC Team and many others (see README.txt)%n"+
                                                     "See http://www.tigervnc.org for information on TigerVNC.");
 
   public static String version = null;
@@ -553,6 +553,10 @@ public class VncViewer extends javax.swing.JApplet
   = new BoolParameter("FullScreen",
                       "Full Screen Mode",
                       false);
+  BoolParameter fullScreenAllMonitors
+  = new BoolParameter("FullScreenAllMonitors",
+                      "Enable full screen over all monitors",
+                      true);
   BoolParameter acceptClipboard
   = new BoolParameter("AcceptClipboard",
                       "Accept clipboard changes from the server",