aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2011-05-17 20:59:45 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2011-05-17 20:59:45 +0000
commitc2ca4c3214ff7d60728f91f7eee218e8c920455d (patch)
treeb0b135b781a59f02f9636b31748dedaa54143c14 /java
parentd6af24c6cad0d29784cce05c70c8aac446194767 (diff)
downloadtigervnc-c2ca4c3214ff7d60728f91f7eee218e8c920455d.tar.gz
tigervnc-c2ca4c3214ff7d60728f91f7eee218e8c920455d.zip
add support for SetDesktopSize
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4426 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r--java/src/com/tigervnc/vncviewer/CConn.java70
-rw-r--r--java/src/com/tigervnc/vncviewer/DesktopWindow.java6
-rw-r--r--java/src/com/tigervnc/vncviewer/VncViewer.java4
3 files changed, 51 insertions, 29 deletions
diff --git a/java/src/com/tigervnc/vncviewer/CConn.java b/java/src/com/tigervnc/vncviewer/CConn.java
index 26dd2a53..a85c0bc8 100644
--- a/java/src/com/tigervnc/vncviewer/CConn.java
+++ b/java/src/com/tigervnc/vncviewer/CConn.java
@@ -31,7 +31,8 @@
package com.tigervnc.vncviewer;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Graphics;
import java.awt.event.*;
import java.awt.Component;
import java.awt.Dimension;
@@ -88,6 +89,11 @@ class ViewportFrame extends JFrame
getContentPane().add(sp);
}
+ public void setChild(DesktopWindow child) {
+ getContentPane().removeAll();
+ addChild(child);
+ }
+
public void setGeometry(int x, int y, int w, int h) {
pack();
if (cc.fullScreen) setSize(w, h);
@@ -266,14 +272,14 @@ public class CConn extends CConnection
public void setExtendedDesktopSize(int reason, int result, int w, int h,
ScreenSet layout) {
super.setExtendedDesktopSize(reason, result, w, h, layout);
-
+
if ((reason == screenTypes.reasonClient) &&
(result != screenTypes.resultSuccess)) {
vlog.error("SetDesktopSize failed: "+result);
return;
}
-
- resizeFramebuffer();
+
+ resizeFramebuffer();
}
// setName() is called when the desktop name changes
@@ -306,12 +312,13 @@ public class CConn extends CConnection
desktop.framebufferUpdateEnd();
if (firstUpdate) {
- //int width = (int)viewer.desktopSize.getValue().split("x")[0];
- //int height = (int)viewer.desktopSize.getValue().split("x")[1];
+ int width, height;
-/*
if (cp.supportsSetDesktopSize &&
- ((width != 0) && (height != 0))) {
+ viewer.desktopSize.getValue() != null &&
+ viewer.desktopSize.getValue().split("x").length == 2) {
+ width = Integer.parseInt(viewer.desktopSize.getValue().split("x")[0]);
+ height = Integer.parseInt(viewer.desktopSize.getValue().split("x")[1]);
ScreenSet layout;
layout = cp.screenLayout;
@@ -322,23 +329,23 @@ public class CConn extends CConnection
while (true) {
Iterator iter = layout.screens.iterator();
- iter.next();
+ Screen screen = (Screen)iter.next();
if (!iter.hasNext())
break;
- layout.remove_screen(iter.id);
+ layout.remove_screen(screen.id);
}
}
- layout.screens.iterator().dimensions.tl.x = 0;
- layout.screens.iterator().dimensions.tl.y = 0;
- layout.screens.iterator().dimensions.by.x = width;
- layout.screens.iterator().dimensions.by.y = height;
+ Screen screen0 = (Screen)layout.screens.iterator().next();
+ screen0.dimensions.tl.x = 0;
+ screen0.dimensions.tl.y = 0;
+ screen0.dimensions.br.x = width;
+ screen0.dimensions.br.y = height;
writer().writeSetDesktopSize(width, height, layout);
}
-*/
firstUpdate = false;
}
@@ -415,6 +422,7 @@ public class CConn extends CConnection
if (viewport != null) viewport.dispose();
viewport = new ViewportFrame(cp.name(), this);
viewport.setUndecorated(fullScreen);
+ desktop.setViewport(viewport);
ClassLoader loader = this.getClass().getClassLoader();
URL url = loader.getResource("com/tigervnc/vncviewer/tigervnc.ico");
ImageIcon icon = null;
@@ -432,23 +440,24 @@ public class CConn extends CConnection
private void reconfigureViewport()
{
//viewport->setMaxSize(cp.width, cp.height);
- int w = cp.width;
- int h = cp.height;
- Dimension dpySize = viewport.getToolkit().getScreenSize();
- int wmDecorationWidth = 0;
- int wmDecorationHeight = 24;
- if (w + wmDecorationWidth >= dpySize.width)
- w = dpySize.width - wmDecorationWidth;
- if (h + wmDecorationHeight >= dpySize.height)
- h = dpySize.height - wmDecorationHeight;
-
- int x = (dpySize.width - w - wmDecorationWidth) / 2;
- int y = (dpySize.height - h - wmDecorationHeight)/2;
-
if (fullScreen) {
+ Dimension dpySize = viewport.getToolkit().getScreenSize();
viewport.setExtendedState(JFrame.MAXIMIZED_BOTH);
viewport.setGeometry(0, 0, dpySize.width, dpySize.height);
} else {
+ int w = cp.width;
+ int h = cp.height;
+ Dimension dpySize = viewport.getToolkit().getScreenSize();
+ int wmDecorationWidth = 0;
+ int wmDecorationHeight = 24;
+ if (w + wmDecorationWidth >= dpySize.width)
+ w = dpySize.width - wmDecorationWidth;
+ if (h + wmDecorationHeight >= dpySize.height)
+ h = dpySize.height - wmDecorationHeight;
+
+ int x = (dpySize.width - w - wmDecorationWidth) / 2;
+ int y = (dpySize.height - h - wmDecorationHeight)/2;
+
viewport.setExtendedState(JFrame.NORMAL);
viewport.setGeometry(x, y, w, h);
}
@@ -528,6 +537,10 @@ public class CConn extends CConnection
private void requestNewUpdate()
{
if (formatChange) {
+
+ /* Catch incorrect requestNewUpdate calls */
+ assert(pendingUpdate == false);
+
if (fullColour) {
desktop.setPF(fullColourPF);
} else {
@@ -621,6 +634,7 @@ public class CConn extends CConnection
synchronized public void refresh() {
writer().writeFramebufferUpdateRequest(new Rect(0,0,cp.width,cp.height), false);
+ pendingUpdate = true;
}
diff --git a/java/src/com/tigervnc/vncviewer/DesktopWindow.java b/java/src/com/tigervnc/vncviewer/DesktopWindow.java
index d008b41c..7a8cda84 100644
--- a/java/src/com/tigervnc/vncviewer/DesktopWindow.java
+++ b/java/src/com/tigervnc/vncviewer/DesktopWindow.java
@@ -95,6 +95,11 @@ class DesktopWindow extends JPanel implements
im.setPF(pf);
}
+ public void setViewport(ViewportFrame viewport)
+ {
+ viewport.setChild(this);
+ }
+
// Methods called from the RFB thread - these need to be synchronized
// wherever they access data shared with the GUI thread.
@@ -193,7 +198,6 @@ class DesktopWindow extends JPanel implements
// resize() is called when the desktop has changed size
synchronized public void resize() {
- vlog.debug("DesktopWindow.resize() called");
int w = cc.cp.width;
int h = cc.cp.height;
hideLocalCursor();
diff --git a/java/src/com/tigervnc/vncviewer/VncViewer.java b/java/src/com/tigervnc/vncviewer/VncViewer.java
index ba549186..1547013d 100644
--- a/java/src/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/src/com/tigervnc/vncviewer/VncViewer.java
@@ -229,6 +229,10 @@ public class VncViewer extends java.applet.Applet implements Runnable
BoolParameter sendClipboard
= new BoolParameter("SendClipboard",
"Send clipboard changes to the server", true);
+ StringParameter desktopSize
+ = new StringParameter("DesktopSize",
+ "Reconfigure desktop size on the server on "+
+ "connect (if possible)", "");
BoolParameter alwaysShowServerDialog
= new BoolParameter("AlwaysShowServerDialog",
"Always show the server dialog even if a server "+