Parcourir la source

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.
tags/v1.5.90
Brian P. Hinz il y a 8 ans
Parent
révision
8442509bca

+ 21
- 7
java/com/tigervnc/vncviewer/CConn.java Voir le fichier

@@ -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() {

+ 9
- 2
java/com/tigervnc/vncviewer/OptionsDialog.java Voir le fichier

@@ -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"));

+ 29
- 1
java/com/tigervnc/vncviewer/Viewport.java Voir le fichier

@@ -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();

+ 6
- 2
java/com/tigervnc/vncviewer/VncViewer.java Voir le fichier

@@ -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",

Chargement…
Annuler
Enregistrer