summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorBrian Hinz <bphinz@users.sourceforge.net>2012-08-26 20:35:30 +0000
committerBrian Hinz <bphinz@users.sourceforge.net>2012-08-26 20:35:30 +0000
commit7e4488dce2eaf6b2d661aae890213500af9a5ba6 (patch)
tree6bb4cf840e54cc927588912b63170e0f25e90579 /java
parent60b07f2c666a9023e8edd4694412e7f53ca4efb0 (diff)
downloadtigervnc-7e4488dce2eaf6b2d661aae890213500af9a5ba6.tar.gz
tigervnc-7e4488dce2eaf6b2d661aae890213500af9a5ba6.zip
Split the Viewport out from CConn, really should never have been in there to begin with.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4964 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r--java/com/tigervnc/vncviewer/CConn.java90
-rw-r--r--java/com/tigervnc/vncviewer/DesktopWindow.java2
-rw-r--r--java/com/tigervnc/vncviewer/Viewport.java112
3 files changed, 117 insertions, 87 deletions
diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java
index 814b0df7..f4c75a2e 100644
--- a/java/com/tigervnc/vncviewer/CConn.java
+++ b/java/com/tigervnc/vncviewer/CConn.java
@@ -34,11 +34,8 @@
package com.tigervnc.vncviewer;
-import java.awt.Color;
-import java.awt.Graphics;
+import java.awt.*;
import java.awt.event.*;
-import java.awt.Dimension;
-import java.awt.Event;
import java.io.IOException;
import java.io.InputStream;
@@ -55,90 +52,11 @@ import java.util.*;
import com.tigervnc.rdr.*;
import com.tigervnc.rfb.*;
-import com.tigervnc.rfb.Exception;
import com.tigervnc.rfb.Point;
-import com.tigervnc.rfb.Rect;
+import com.tigervnc.rfb.Exception;
import com.tigervnc.network.Socket;
import com.tigervnc.network.TcpSocket;
-class ViewportFrame extends JFrame
-{
- public ViewportFrame(String name, CConn cc_) {
- cc = cc_;
- setTitle(name+" - TigerVNC");
- setFocusable(false);
- setFocusTraversalKeysEnabled(false);
- sp = new JScrollPane();
- sp.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
- getContentPane().add(sp);
- addWindowFocusListener(new WindowAdapter() {
- public void windowGainedFocus(WindowEvent e) {
- sp.getViewport().getView().requestFocusInWindow();
- }
- });
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- cc.deleteWindow();
- }
- });
- addComponentListener(new ComponentAdapter() {
- public void componentResized(ComponentEvent e) {
- if ((getExtendedState() != JFrame.MAXIMIZED_BOTH) &&
- cc.fullScreen) {
- cc.toggleFullScreen();
- }
- String scaleString = cc.viewer.scalingFactor.getValue();
- if (scaleString.equals("Auto") || scaleString.equals("FixedRatio")) {
- if ((sp.getSize().width != cc.desktop.scaledWidth) ||
- (sp.getSize().height != cc.desktop.scaledHeight)) {
- int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
- sp.setHorizontalScrollBarPolicy(policy);
- cc.desktop.setScaledSize();
- sp.setSize(new Dimension(cc.desktop.scaledWidth,
- cc.desktop.scaledHeight));
- sp.validate();
- if (getExtendedState() != JFrame.MAXIMIZED_BOTH &&
- scaleString.equals("FixedRatio")) {
- int w = cc.desktop.scaledWidth + getInsets().left + getInsets().right;
- int h = cc.desktop.scaledHeight + getInsets().top + getInsets().bottom;
- setSize(w, h);
- }
- if (cc.desktop.cursor != null) {
- Cursor cursor = cc.desktop.cursor;
- cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot,
- cursor.data, cursor.mask);
- }
- }
- } else {
- int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
- sp.setHorizontalScrollBarPolicy(policy);
- sp.validate();
- }
- }
- });
- }
-
- public void setChild(DesktopWindow child) {
- sp.getViewport().setView(child);
- }
-
- public void setGeometry(int x, int y, int w, int h, boolean pack) {
- if (pack) {
- pack();
- } else {
- setSize(w, h);
- }
- if (!cc.fullScreen)
- setLocation(x, y);
- setBackground(Color.BLACK);
- }
-
-
- CConn cc;
- JScrollPane sp;
- static LogWriter vlog = new LogWriter("ViewportFrame");
-}
-
public class CConn extends CConnection
implements UserPasswdGetter, UserMsgBox, OptionsDialogCallback, FdInStreamBlockCallback
{
@@ -588,7 +506,7 @@ public class CConn extends CConnection
private void recreateViewport()
{
if (viewport != null) viewport.dispose();
- viewport = new ViewportFrame(cp.name(), this);
+ viewport = new Viewport(cp.name(), this);
viewport.setUndecorated(fullScreen);
desktop.setViewport(viewport);
ClassLoader loader = this.getClass().getClassLoader();
@@ -1450,7 +1368,7 @@ public class CConn extends CConnection
private boolean supportsSyncFence;
public int menuKeyCode;
- ViewportFrame viewport;
+ Viewport viewport;
private boolean fullColour;
private boolean autoSelect;
boolean fullScreen;
diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java
index bc73143e..b55947ea 100644
--- a/java/com/tigervnc/vncviewer/DesktopWindow.java
+++ b/java/com/tigervnc/vncviewer/DesktopWindow.java
@@ -96,7 +96,7 @@ class DesktopWindow extends JPanel implements
final public PixelFormat getPF() { return im.getPF(); }
- public void setViewport(ViewportFrame viewport)
+ public void setViewport(Viewport viewport)
{
viewport.setChild(this);
}
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java
new file mode 100644
index 00000000..680a02d3
--- /dev/null
+++ b/java/com/tigervnc/vncviewer/Viewport.java
@@ -0,0 +1,112 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright (C) 2011-2012 Brian P. Hinz
+ * Copyright (C) 2012 D. R. Commander. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+package com.tigervnc.vncviewer;
+
+import java.awt.Color;
+import java.awt.event.*;
+import java.awt.Dimension;
+import java.awt.Event;
+import javax.swing.*;
+
+import com.tigervnc.rdr.*;
+import com.tigervnc.rfb.*;
+
+public class Viewport extends JFrame
+{
+ public Viewport(String name, CConn cc_) {
+ cc = cc_;
+ setTitle(name+" - TigerVNC");
+ setFocusable(false);
+ setFocusTraversalKeysEnabled(false);
+ UIManager.getDefaults().put("ScrollPane.ancestorInputMap",
+ new UIDefaults.LazyInputMap(new Object[]{}));
+ sp = new JScrollPane();
+ sp.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
+ getContentPane().add(sp);
+ addWindowFocusListener(new WindowAdapter() {
+ public void windowGainedFocus(WindowEvent e) {
+ if (isVisible())
+ sp.getViewport().getView().requestFocusInWindow();
+ }
+ });
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ cc.deleteWindow();
+ }
+ });
+ addComponentListener(new ComponentAdapter() {
+ public void componentResized(ComponentEvent e) {
+ if ((getExtendedState() != JFrame.MAXIMIZED_BOTH) &&
+ cc.fullScreen) {
+ cc.toggleFullScreen();
+ }
+ String scaleString = cc.viewer.scalingFactor.getValue();
+ if (scaleString.equals("Auto") || scaleString.equals("FixedRatio")) {
+ if ((sp.getSize().width != cc.desktop.scaledWidth) ||
+ (sp.getSize().height != cc.desktop.scaledHeight)) {
+ int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
+ sp.setHorizontalScrollBarPolicy(policy);
+ cc.desktop.setScaledSize();
+ sp.setSize(new Dimension(cc.desktop.scaledWidth,
+ cc.desktop.scaledHeight));
+ sp.validate();
+ if (getExtendedState() != JFrame.MAXIMIZED_BOTH &&
+ scaleString.equals("FixedRatio")) {
+ int w = cc.desktop.scaledWidth + getInsets().left + getInsets().right;
+ int h = cc.desktop.scaledHeight + getInsets().top + getInsets().bottom;
+ setSize(w, h);
+ }
+ if (cc.desktop.cursor != null) {
+ Cursor cursor = cc.desktop.cursor;
+ cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot,
+ cursor.data, cursor.mask);
+ }
+ }
+ } else {
+ int policy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
+ sp.setHorizontalScrollBarPolicy(policy);
+ sp.validate();
+ }
+ }
+ });
+ }
+
+ public void setChild(DesktopWindow child) {
+ sp.getViewport().setView(child);
+ }
+
+ public void setGeometry(int x, int y, int w, int h, boolean pack) {
+ if (pack) {
+ pack();
+ } else {
+ setSize(w, h);
+ }
+ if (!cc.fullScreen)
+ setLocation(x, y);
+ setBackground(Color.BLACK);
+ }
+
+
+ CConn cc;
+ JScrollPane sp;
+ static LogWriter vlog = new LogWriter("Viewport");
+}
+