Browse 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 8 years ago
parent
commit
8442509bca

+ 21
- 7
java/com/tigervnc/vncviewer/CConn.java View File

/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2009-2013 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009-2013 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011-2013 D. R. Commander. All Rights Reserved. * 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 * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
menu.fullScreen.setEnabled(s); menu.fullScreen.setEnabled(s);
menu.newConn.setEnabled(s); menu.newConn.setEnabled(s);
options.fullScreen.setEnabled(s); options.fullScreen.setEnabled(s);
options.fullScreenAllMonitors.setEnabled(s);
options.scalingFactor.setEnabled(s); options.scalingFactor.setEnabled(s);
} }


} }


private void reconfigureViewport() { private void reconfigureViewport() {
//viewport.setMaxSize(cp.width, cp.height);
boolean pack = true; boolean pack = true;
Dimension dpySize = viewport.getToolkit().getScreenSize();
Dimension dpySize = viewport.getScreenSize();
desktop.setScaledSize(); desktop.setScaledSize();
int w = desktop.scaledWidth; int w = desktop.scaledWidth;
int h = desktop.scaledHeight; int h = desktop.scaledHeight;
if (fullScreen) { 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 { } else {
int wmDecorationWidth = viewport.getInsets().left + viewport.getInsets().right; int wmDecorationWidth = viewport.getInsets().left + viewport.getInsets().right;
int wmDecorationHeight = viewport.getInsets().top + viewport.getInsets().bottom; int wmDecorationHeight = viewport.getInsets().top + viewport.getInsets().bottom;
} }


options.fullScreen.setSelected(fullScreen); options.fullScreen.setSelected(fullScreen);
options.fullScreenAllMonitors.setSelected(viewer.fullScreenAllMonitors.getValue());
options.useLocalCursor.setSelected(viewer.useLocalCursor.getValue()); options.useLocalCursor.setSelected(viewer.useLocalCursor.getValue());
options.acceptBell.setSelected(viewer.acceptBell.getValue()); options.acceptBell.setSelected(viewer.acceptBell.getValue());
String scaleString = viewer.scalingFactor.getValue(); String scaleString = viewer.scalingFactor.getValue();
String desktopSize = (options.desktopSize.isSelected()) ? String desktopSize = (options.desktopSize.isSelected()) ?
options.desktopWidth.getText() + "x" + options.desktopHeight.getText() : ""; options.desktopWidth.getText() + "x" + options.desktopHeight.getText() : "";
viewer.desktopSize.setParam(desktopSize); viewer.desktopSize.setParam(desktopSize);
if (options.fullScreen.isSelected() ^ fullScreen)
if (options.fullScreen.isSelected() ^ fullScreen) {
viewer.fullScreenAllMonitors.setParam(options.fullScreenAllMonitors.isSelected());
toggleFullScreen(); 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() { public void toggleFullScreen() {

+ 9
- 2
java/com/tigervnc/vncviewer/OptionsDialog.java View File

/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. /* 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 * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
JRadioButton zrle, hextile, tight, raw; JRadioButton zrle, hextile, tight, raw;
JRadioButton fullColour, mediumColour, lowColour, veryLowColour; JRadioButton fullColour, mediumColour, lowColour, veryLowColour;
JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell; JCheckBox viewOnly, acceptClipboard, sendClipboard, acceptBell;
JCheckBox desktopSize, fullScreen, shared, useLocalCursor;
JCheckBox desktopSize, fullScreen, fullScreenAllMonitors, shared, useLocalCursor;
JCheckBox secVeNCrypt, encNone, encTLS, encX509; JCheckBox secVeNCrypt, encNone, encTLS, encX509;
JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername; JCheckBox secNone, secVnc, secPlain, secIdent, sendLocalUsername;
JButton okButton, cancelButton; JButton okButton, cancelButton;
fullScreen = new JCheckBox("Full-screen mode"); fullScreen = new JCheckBox("Full-screen mode");
fullScreen.addItemListener(this); fullScreen.addItemListener(this);
fullScreen.setEnabled(!cc.viewer.embed.getValue()); 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"); JLabel scalingFactorLabel = new JLabel("Scaling Factor");
Object[] scalingFactors = { Object[] scalingFactors = {
"Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%", "Auto", "Fixed Aspect Ratio", "50%", "75%", "95%", "100%", "105%",
addGBComponent(desktopSize,ScreenPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(4,5,0,5)); 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(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(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(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)); addGBComponent(scalingFactor,ScreenPanel, 1, 4, 1, GridBagConstraints.REMAINDER, 2, 2, 25, 1, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(4,5,0,5));


veryLowColour.setEnabled(!autoSelect.isSelected()); veryLowColour.setEnabled(!autoSelect.isSelected());
compressLevel.setEnabled(customCompressLevel.isSelected()); compressLevel.setEnabled(customCompressLevel.isSelected());
qualityLevel.setEnabled(noJpeg.isSelected()); qualityLevel.setEnabled(noJpeg.isSelected());
fullScreenAllMonitors.setEnabled(fullScreen.isSelected());
sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&& sendLocalUsername.setEnabled(secVeNCrypt.isEnabled()&&
(secPlain.isSelected()||secIdent.isSelected())); (secPlain.isSelected()||secIdent.isSelected()));
} }
desktopSize.isSelected() ? desktopWidth.getText() + "x" + desktopHeight.getText() : ""; desktopSize.isSelected() ? desktopWidth.getText() + "x" + desktopHeight.getText() : "";
UserPreferences.set("global", "DesktopSize", desktopSizeString); UserPreferences.set("global", "DesktopSize", desktopSizeString);
UserPreferences.set("global", "FullScreen", fullScreen.isSelected()); UserPreferences.set("global", "FullScreen", fullScreen.isSelected());
UserPreferences.set("global", "FullScreenAllMonitors", fullScreenAllMonitors.isSelected());
UserPreferences.set("global", "Shared", shared.isSelected()); UserPreferences.set("global", "Shared", shared.isSelected());
UserPreferences.set("global", "UseLocalCursor", useLocalCursor.isSelected()); UserPreferences.set("global", "UseLocalCursor", useLocalCursor.isSelected());
UserPreferences.set("global", "AcceptBell", acceptBell.isSelected()); UserPreferences.set("global", "AcceptBell", acceptBell.isSelected());
desktopHeight.setText(desktopSizeString.split("x")[1]); desktopHeight.setText(desktopSizeString.split("x")[1]);
} }
fullScreen.setSelected(UserPreferences.getBool("global", "FullScreen")); fullScreen.setSelected(UserPreferences.getBool("global", "FullScreen"));
fullScreenAllMonitors.setSelected(UserPreferences.getBool("global", "FullScreenAllMonitors"));
if (shared.isEnabled()) if (shared.isEnabled())
shared.setSelected(UserPreferences.getBool("global", "Shared")); shared.setSelected(UserPreferences.getBool("global", "Shared"));
useLocalCursor.setSelected(UserPreferences.getBool("global", "UseLocalCursor")); useLocalCursor.setSelected(UserPreferences.getBool("global", "UseLocalCursor"));

+ 29
- 1
java/com/tigervnc/vncviewer/Viewport.java View File

/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. /* 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. * Copyright (C) 2012-2013 D. R. Commander. All Rights Reserved.
* *
* This is free software; you can redistribute it and/or modify * This is free software; you can redistribute it and/or modify
import java.awt.GraphicsDevice; import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets;
import java.awt.Window; import java.awt.Window;
import java.lang.reflect.*; import java.lang.reflect.*;
import javax.swing.*; import javax.swing.*;


import com.tigervnc.rfb.*; import com.tigervnc.rfb.*;
import java.lang.Exception; import java.lang.Exception;
import java.awt.Rectangle;


public class Viewport extends JFrame public class Viewport extends JFrame
{ {
setLocation(x, y); 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() { public static Window getFullScreenWindow() {
GraphicsEnvironment ge = GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment.getLocalGraphicsEnvironment();

+ 6
- 2
java/com/tigervnc/vncviewer/VncViewer.java View File

/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011-2013 D. R. Commander. All Rights Reserved. * 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 * This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by


public static final String aboutText = new String("TigerVNC Java Viewer v%s (%s)%n"+ public static final String aboutText = new String("TigerVNC Java Viewer v%s (%s)%n"+
"Built on %s at %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."); "See http://www.tigervnc.org for information on TigerVNC.");


public static String version = null; public static String version = null;
= new BoolParameter("FullScreen", = new BoolParameter("FullScreen",
"Full Screen Mode", "Full Screen Mode",
false); false);
BoolParameter fullScreenAllMonitors
= new BoolParameter("FullScreenAllMonitors",
"Enable full screen over all monitors",
true);
BoolParameter acceptClipboard BoolParameter acceptClipboard
= new BoolParameter("AcceptClipboard", = new BoolParameter("AcceptClipboard",
"Accept clipboard changes from the server", "Accept clipboard changes from the server",

Loading…
Cancel
Save