diff options
author | enikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2008-12-25 11:02:56 +0000 |
---|---|---|
committer | enikey <enikey@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2008-12-25 11:02:56 +0000 |
commit | d765356a293564dd5d07b81dad363323d002fa60 (patch) | |
tree | 6f3565270f33ba68f15a0fdca7452a73342748d3 /java | |
parent | a0a955fef9b54cd6d722c3096966c17b3094fe68 (diff) | |
download | tigervnc-d765356a293564dd5d07b81dad363323d002fa60.tar.gz tigervnc-d765356a293564dd5d07b81dad363323d002fa60.zip |
[Developement] Added ability to freeze video (enable/disabe rectangular screen area that treated as video) using tight rfb video freeze extension(if server support it).
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3474 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/tightvnc/vncviewer/ButtonPanel.java | 41 | ||||
-rw-r--r-- | java/src/com/tightvnc/vncviewer/RfbProto.java | 26 | ||||
-rw-r--r-- | java/src/com/tightvnc/vncviewer/VncViewer.java | 5 |
3 files changed, 62 insertions, 10 deletions
diff --git a/java/src/com/tightvnc/vncviewer/ButtonPanel.java b/java/src/com/tightvnc/vncviewer/ButtonPanel.java index 63ad6a15..dea182d5 100644 --- a/java/src/com/tightvnc/vncviewer/ButtonPanel.java +++ b/java/src/com/tightvnc/vncviewer/ButtonPanel.java @@ -39,9 +39,10 @@ class ButtonPanel extends Panel implements ActionListener { Button ctrlAltDelButton; Button refreshButton; Button selectButton; - Button videoIgnoreButton; + Button videoFreezeButton; - final String videoIgnoreLabel = "Video Ignore"; + final String enableVideoFreezeLabel = "Enable Video Freeze"; + final String disableVideoFreezeLabel = "Disable Video Freeze"; final String selectEnterLabel = "Select Video Area"; final String selectLeaveLabel = "Hide Selection"; @@ -88,11 +89,10 @@ class ButtonPanel extends Panel implements ActionListener { /** * Add video ignore button to the ButtonPanel. */ - public void addVideoIgnoreButton() { - videoIgnoreButton = new Button(videoIgnoreLabel); - videoIgnoreButton.setEnabled(false); - add(selectButton); - videoIgnoreButton.addActionListener(this); + public void addVideoFreezeButton() { + videoFreezeButton = new Button(enableVideoFreezeLabel); + add(videoFreezeButton); + videoFreezeButton.addActionListener(this); } // @@ -156,11 +156,32 @@ class ButtonPanel extends Panel implements ActionListener { } else if (evt.getSource() == clipboardButton) { viewer.clipboard.setVisible(!viewer.clipboard.isVisible()); - } else if (evt.getSource() == videoIgnoreButton) { + } else if (evt.getSource() == videoFreezeButton) { + + // + // Send video freeze message to server and change caption of button // - // Do something onVideoIgnoreButtonClick event - // ... + + // + // TODO: Move this code to another place. // + + boolean sendOk = true; + boolean currentFreezeState = + videoFreezeButton.getLabel().equals(disableVideoFreezeLabel); + try { + viewer.rfb.trySendVideoFreeze(!currentFreezeState); + } catch (IOException ex) { + sendOk = false; + ex.printStackTrace(); + } + if (sendOk) { + if (!currentFreezeState) { + videoFreezeButton.setLabel(disableVideoFreezeLabel); + } else { + videoFreezeButton.setLabel(enableVideoFreezeLabel); + } + } } else if (evt.getSource() == ctrlAltDelButton) { try { final int modifiers = InputEvent.CTRL_MASK | InputEvent.ALT_MASK; diff --git a/java/src/com/tightvnc/vncviewer/RfbProto.java b/java/src/com/tightvnc/vncviewer/RfbProto.java index 156b41a5..9e6284f8 100644 --- a/java/src/com/tightvnc/vncviewer/RfbProto.java +++ b/java/src/com/tightvnc/vncviewer/RfbProto.java @@ -100,6 +100,8 @@ class RfbProto { // Non-standard client-to-server messages final static int EnableContinuousUpdates = 150; final static int VideoRectangleSelection = 151; + final static int VideoFreeze = 152; + final static String SigVideoFreeze = "VD_FREEZ"; final static String SigEnableContinuousUpdates = "CUC_ENCU"; final static String SigVideoRectangleSelection = "VRECTSEL"; @@ -498,6 +500,9 @@ class RfbProto { clientMsgCaps.add(VideoRectangleSelection, TightVncVendor, SigVideoRectangleSelection, "Select a rectangle to be treated as video"); + clientMsgCaps.add(VideoFreeze, TightVncVendor, + SigVideoFreeze, + "Disable/enable video rectangle"); // Supported encoding types encodingCaps.add(EncodingCopyRect, StandardVendor, @@ -1406,6 +1411,27 @@ class RfbProto { System.out.println("Video rectangle selection message sent"); } + void trySendVideoFreeze(boolean freeze) throws IOException + { + if (!clientMsgCaps.isEnabled(VideoFreeze)) { + System.out.println("Video freeze is not supported by the server"); + return; + } + + byte[] b = new byte[2]; + byte fb = 0; + if (freeze) { + fb = 1; + } + + b[0] = (byte) VideoFreeze; + b[1] = (byte) fb; + + os.write(b); + + System.out.println("Video freeze selection message sent"); + } + public void startTiming() { timing = true; diff --git a/java/src/com/tightvnc/vncviewer/VncViewer.java b/java/src/com/tightvnc/vncviewer/VncViewer.java index 4ff85ffa..fd711145 100644 --- a/java/src/com/tightvnc/vncviewer/VncViewer.java +++ b/java/src/com/tightvnc/vncviewer/VncViewer.java @@ -167,6 +167,11 @@ public class VncViewer extends java.applet.Applet buttonPanel.addSelectButton(); } + if (showControls && + rfb.clientMsgCaps.isEnabled(RfbProto.VideoFreeze)) { + buttonPanel.addVideoFreezeButton(); + } + // FIXME: Use auto-scaling not only in a separate frame. if (options.autoScale && inSeparateFrame) { Dimension screenSize; |