blob: 6516fb892707db131a5775aed0332119cab574d7 [file] [log] [blame]
Constantin Kaplinsky1215b992008-04-18 09:51:44 +00001//
2// Copyright (C) 2001,2002 HorizonLive.com, Inc. All Rights Reserved.
3// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
4//
5// This is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This software is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this software; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18// USA.
19//
20
Constantin Kaplinskycf689b32008-04-30 12:50:34 +000021package com.tightvnc.rfbplayer;
wimba.comc23aeb02004-09-16 00:00:00 +000022
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000023import java.awt.*;
24import java.awt.event.*;
25import java.io.*;
26
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000027public class RfbPlayer extends java.applet.Applet
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +000028 implements java.lang.Runnable, WindowListener {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000029
30 boolean inAnApplet = true;
31 boolean inSeparateFrame = false;
32
wimba.com252eb3b2004-09-21 21:27:54 +000033 /** current applet width */
34 int dispW = 300;
35 /** current applet height */
36 int dispH = 200;
37
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000038 //
39 // main() is called when run as a java program from the command line.
40 // It simply runs the applet inside a newly-created frame.
41 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000042 public static void main(String[] argv) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000043 RfbPlayer p = new RfbPlayer();
44 p.mainArgs = argv;
45 p.inAnApplet = false;
46 p.inSeparateFrame = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000047
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000048 p.init();
49 p.start();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000050 }
51
52 String[] mainArgs;
53
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +000054 FbsInputStream fbs;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000055 RfbProto rfb;
56 Thread rfbThread;
57
58 Frame vncFrame;
59 Container vncContainer;
wimba.come8e19102005-02-08 17:15:23 +000060 //ScrollPane desktopScrollPane;
61 LWScrollPane desktopScrollPane;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000062 GridBagLayout gridbag;
63 ButtonPanel buttonPanel;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000064 VncCanvas vc;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000065
Constantin Kaplinsky5d99c952002-05-25 09:49:23 +000066 String sessionURL;
Constantin Kaplinsky972c2572002-05-30 14:19:02 +000067 long initialTimeOffset;
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +000068 double playbackSpeed;
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +000069 boolean autoPlay;
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000070 boolean showControls;
wimba.comd1f56df2004-11-01 16:18:54 +000071 boolean isQuitting = false;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000072 int deferScreenUpdates;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000073
74 //
75 // init()
76 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000077 public void init() {
78
wimba.comc23aeb02004-09-16 00:00:00 +000079 // LiveConnect work-a-round
80 RfbSharedStatic.refApplet = this;
81
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000082 readParameters();
83
84 if (inSeparateFrame) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +000085 vncFrame = new Frame("RFB Session Player");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000086 if (!inAnApplet) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +000087 vncFrame.add("Center", this);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000088 }
89 vncContainer = vncFrame;
90 } else {
91 vncContainer = this;
92 }
93
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000094 if (inSeparateFrame)
95 vncFrame.addWindowListener(this);
96
wimba.comd1f56df2004-11-01 16:18:54 +000097 rfbThread = new Thread(this, "RfbThread");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +000098 rfbThread.start();
99 }
100
101 public void update(Graphics g) {
102 }
103
104 //
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000105 // run() - executed by the rfbThread to read RFB data.
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000106 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000107 public void run() {
108
109 gridbag = new GridBagLayout();
110 vncContainer.setLayout(gridbag);
111
112 GridBagConstraints gbc = new GridBagConstraints();
113 gbc.gridwidth = GridBagConstraints.REMAINDER;
114 gbc.anchor = GridBagConstraints.NORTHWEST;
115
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000116 if (showControls) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000117 buttonPanel = new ButtonPanel(this);
118 buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
119 gridbag.setConstraints(buttonPanel, gbc);
120 vncContainer.add(buttonPanel);
121 }
122
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000123 if (inSeparateFrame) {
124 vncFrame.pack();
Constantin Kaplinskyaa7b5612008-06-17 09:27:52 +0000125 vncFrame.setVisible(true);
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000126 } else {
127 validate();
128 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000129
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000130 try {
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000131 java.applet.Applet applet = (inAnApplet) ? this : null;
132 FbsConnection conn = new FbsConnection(sessionURL, null, applet);
133 fbs = conn.connect(initialTimeOffset);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000134 rfb = new RfbProto(fbs);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000135
136 vc = new VncCanvas(this);
137 gbc.weightx = 1.0;
138 gbc.weighty = 1.0;
139
wimba.com252eb3b2004-09-21 21:27:54 +0000140 // Create a panel which itself is resizeable and can hold
141 // non-resizeable VncCanvas component at the top left corner.
wimba.come8e19102005-02-08 17:15:23 +0000142 //Panel canvasPanel = new Panel();
143 //canvasPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
144 //canvasPanel.add(vc);
wimba.com252eb3b2004-09-21 21:27:54 +0000145
146 // Create a ScrollPane which will hold a panel with VncCanvas
147 // inside.
wimba.come8e19102005-02-08 17:15:23 +0000148 //desktopScrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
149 desktopScrollPane = new LWScrollPane();
wimba.com252eb3b2004-09-21 21:27:54 +0000150 gbc.fill = GridBagConstraints.BOTH;
wimba.come8e19102005-02-08 17:15:23 +0000151 gridbag.setConstraints(vc, gbc);
152 //gridbag.setConstraints(canvasPanel, gbc);
153 desktopScrollPane.addComp(vc);
154 desktopScrollPane.setSize(dispW, dispH);
155 //desktopScrollPane.add(canvasPanel);
wimba.com252eb3b2004-09-21 21:27:54 +0000156
157 // Now add the scroll bar to the container.
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000158 if (inSeparateFrame) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000159 gridbag.setConstraints(desktopScrollPane, gbc);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000160 vncFrame.add(desktopScrollPane);
161 vncFrame.setTitle(rfb.desktopName);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000162 vc.resizeDesktopFrame();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000163 } else {
wimba.com252eb3b2004-09-21 21:27:54 +0000164 // Size the scroll pane to display size.
165 desktopScrollPane.setSize(dispW, dispH);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000166
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000167 // Just add the VncCanvas component to the Applet.
wimba.com252eb3b2004-09-21 21:27:54 +0000168 gbc.fill = GridBagConstraints.NONE;
169 gridbag.setConstraints(desktopScrollPane, gbc);
170 add(desktopScrollPane);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000171 validate();
wimba.com252eb3b2004-09-21 21:27:54 +0000172 vc.resizeEmbeddedApplet();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000173 }
174
wimba.comd1f56df2004-11-01 16:18:54 +0000175 while (!isQuitting) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000176 try {
177 setPaused(!autoPlay);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000178 fbs.setSpeed(playbackSpeed);
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000179 vc.processNormalProtocol();
180 } catch (EOFException e) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000181 long newTimeOffset;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000182 if (e.getMessage() != null && e.getMessage().equals("[REWIND]")) {
183 // A special type of EOFException allowing us to seek backwards.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000184 newTimeOffset = fbs.getSeekOffset();
185 autoPlay = !fbs.isPaused();
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000186 } else {
187 // Return to the beginning after the playback is finished.
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000188 newTimeOffset = 0;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000189 autoPlay = false;
190 }
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000191 fbs.close();
Constantin Kaplinsky2859fdc2008-06-19 16:07:52 +0000192 fbs = conn.connect(newTimeOffset);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000193 rfb.newSession(fbs);
Constantin Kaplinsky282aaa12002-09-22 11:33:22 +0000194 vc.updateFramebufferSize();
wimba.com30ff9ed2004-11-01 20:54:08 +0000195 } catch (NullPointerException e) {
196 // catching this causes a hang with 1.4.1 JVM's under Win32 IE
197 throw e;
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000198 }
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000199 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000200
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000201 } catch (FileNotFoundException e) {
202 fatalError(e.toString());
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000203 } catch (Exception e) {
204 e.printStackTrace();
205 fatalError(e.toString());
206 }
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000207
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000208 }
209
wimba.comb5a90342007-04-02 18:54:41 +0000210 public void setPausedInt(String paused) {
211 // default to true (pause)
212 int pause = 1;
213
214 try {
215 pause = Integer.parseInt(paused);
216 } catch (NumberFormatException e) {
217 }
218
219 if (pause == 0) {
220 setPaused(false);
221 } else {
222 setPaused(true);
223 }
224 }
225
Constantin Kaplinskyac6420d2002-05-29 17:05:39 +0000226 public void setPaused(boolean paused) {
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000227 if (showControls)
228 buttonPanel.setPaused(paused);
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000229 if (paused) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000230 fbs.pausePlayback();
Constantin Kaplinsky37cc43e2002-05-30 17:30:11 +0000231 } else {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000232 fbs.resumePlayback();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000233 }
234 }
235
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000236 public double getSpeed() {
237 return playbackSpeed;
238 }
239
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000240 public void setSpeed(double speed) {
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000241 playbackSpeed = speed;
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000242 fbs.setSpeed(speed);
Constantin Kaplinskyce39d3b2002-05-30 15:54:56 +0000243 }
244
wimba.comc23aeb02004-09-16 00:00:00 +0000245 public void jumpTo(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000246 long diff = Math.abs(pos - fbs.getTimeOffset());
wimba.comc23aeb02004-09-16 00:00:00 +0000247
248 // Current threshold is 5 seconds
249 if (diff > 5000) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000250 fbs.pausePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000251 setPos(pos);
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000252 fbs.resumePlayback();
wimba.comc23aeb02004-09-16 00:00:00 +0000253 }
254 }
255
Constantin Kaplinskyc833e012002-05-30 17:59:22 +0000256 public void setPos(long pos) {
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000257 fbs.setTimeOffset(pos);
Constantin Kaplinsky30f786a2002-05-29 10:59:52 +0000258 }
259
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000260 public void updatePos() {
Constantin Kaplinskyaa7b5612008-06-17 09:27:52 +0000261 if (showControls && buttonPanel != null)
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000262 buttonPanel.setPos(fbs.getTimeOffset());
Constantin Kaplinskyfe079832002-05-29 00:52:32 +0000263 }
264
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000265 //
266 // readParameters() - read parameters from the html source or from the
267 // command line. On the command line, the arguments are just a sequence of
268 // param_name/param_value pairs where the names and values correspond to
269 // those expected in the html applet tag source.
270 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000271 public void readParameters() {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000272
Constantin Kaplinsky5d99c952002-05-25 09:49:23 +0000273 sessionURL = readParameter("URL", true);
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000274
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000275 initialTimeOffset = readLongParameter("Position", 0);
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000276 if (initialTimeOffset < 0)
277 initialTimeOffset = 0;
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000278
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000279 playbackSpeed = readDoubleParameter("Speed", 1.0);
280 if (playbackSpeed <= 0.0)
281 playbackSpeed = 1.0;
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000282
Constantin Kaplinsky5a7133a2002-07-24 17:02:04 +0000283 autoPlay = false;
284 String str = readParameter("Autoplay", false);
285 if (str != null && str.equalsIgnoreCase("Yes"))
286 autoPlay = true;
287
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000288 showControls = true;
wimba.com9bd9c5c2005-09-14 18:42:46 +0000289 str = readParameter("Show_Controls", false);
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000290 if (str != null && str.equalsIgnoreCase("No"))
291 showControls = false;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000292
293 if (inAnApplet) {
wimba.com9bd9c5c2005-09-14 18:42:46 +0000294 str = readParameter("Open_New_Window", false);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000295 if (str != null && str.equalsIgnoreCase("Yes"))
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000296 inSeparateFrame = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000297 }
298
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000299 // Fine tuning options.
wimba.com9bd9c5c2005-09-14 18:42:46 +0000300 deferScreenUpdates = (int)readLongParameter("Defer_screen_updates", 20);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000301 if (deferScreenUpdates < 0)
302 deferScreenUpdates = 0; // Just in case.
wimba.com252eb3b2004-09-21 21:27:54 +0000303
304 // Display width and height.
305 dispW = readIntParameter("DISPLAY_WIDTH", dispW);
306 dispH = readIntParameter("DISPLAY_HEIGHT", dispH);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000307 }
308
309 public String readParameter(String name, boolean required) {
310 if (inAnApplet) {
311 String s = getParameter(name);
312 if ((s == null) && required) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000313 fatalError(name + " parameter not specified");
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000314 }
315 return s;
316 }
317
318 for (int i = 0; i < mainArgs.length; i += 2) {
319 if (mainArgs[i].equalsIgnoreCase(name)) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000320 try {
321 return mainArgs[i + 1];
322 } catch (Exception e) {
323 if (required) {
324 fatalError(name + " parameter not specified");
325 }
326 return null;
327 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000328 }
329 }
330 if (required) {
331 fatalError(name + " parameter not specified");
332 }
333 return null;
334 }
335
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000336 long readLongParameter(String name, long defaultValue) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000337 String str = readParameter(name, false);
Constantin Kaplinsky972c2572002-05-30 14:19:02 +0000338 long result = defaultValue;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000339 if (str != null) {
340 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000341 result = Long.parseLong(str);
342 } catch (NumberFormatException e) {
343 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000344 }
345 return result;
346 }
347
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000348 double readDoubleParameter(String name, double defaultValue) {
349 String str = readParameter(name, false);
350 double result = defaultValue;
351 if (str != null) {
352 try {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000353 result = Double.valueOf(str).doubleValue();
354 } catch (NumberFormatException e) {
355 }
Constantin Kaplinsky7957ca12002-05-30 16:19:11 +0000356 }
357 return result;
358 }
359
wimba.com252eb3b2004-09-21 21:27:54 +0000360 int readIntParameter(String name, int defaultValue) {
361 String str = readParameter(name, false);
362 int result = defaultValue;
363 if (str != null) {
364 try {
365 result = Integer.parseInt(str);
366 } catch (NumberFormatException e) {
367 }
368 }
369 return result;
370 }
371
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000372 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000373 // fatalError() - print out a fatal error message.
374 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000375 public void fatalError(String str) {
376 System.out.println(str);
377
378 if (inAnApplet) {
379 vncContainer.removeAll();
380 if (rfb != null) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000381 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000382 }
383 Label errLabel = new Label(str);
384 errLabel.setFont(new Font("Helvetica", Font.PLAIN, 12));
385 vncContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 30));
386 vncContainer.add(errLabel);
387 if (inSeparateFrame) {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000388 vncFrame.pack();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000389 } else {
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000390 validate();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000391 }
392 Thread.currentThread().stop();
393 } else {
394 System.exit(1);
395 }
396 }
397
398
399 //
400 // This method is called before the applet is destroyed.
401 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000402 public void destroy() {
wimba.comd1f56df2004-11-01 16:18:54 +0000403 isQuitting = true;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000404 vncContainer.removeAll();
Constantin Kaplinsky7b55c4f2008-06-18 09:28:30 +0000405 if (fbs != null) {
406 fbs.quit();
407 try {
408 fbs.close();
409 } catch (IOException e) {
410 }
wimba.comd1f56df2004-11-01 16:18:54 +0000411 }
412 try {
413 rfbThread.join();
414 } catch (InterruptedException e) {
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000415 }
416 if (inSeparateFrame) {
wimba.com30ff9ed2004-11-01 20:54:08 +0000417 vncFrame.removeWindowListener(this);
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000418 vncFrame.dispose();
419 }
420 }
421
wimba.com252eb3b2004-09-21 21:27:54 +0000422 //
423 // Set the new width and height of the applet. Call when browser is resized to
424 // resize the viewer.
425 //
426 public void displaySize(int width, int height) {
427 dispW = width;
428 dispH = height;
429 if (!inSeparateFrame) {
430 vc.resizeEmbeddedApplet();
431 }
432 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000433
434 //
435 // Close application properly on window close event.
436 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000437 public void windowClosing(WindowEvent evt) {
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000438 vncContainer.removeAll();
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000439 if (rfb != null)
Constantin Kaplinsky903009e2002-05-20 10:55:47 +0000440 rfb = null;
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000441
442 vncFrame.dispose();
443 if (!inAnApplet) {
444 System.exit(0);
445 }
446 }
447
448 //
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000449 // Ignore window events we're not interested in.
450 //
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000451 public void windowActivated(WindowEvent evt) {
452 }
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000453
Constantin Kaplinsky72e47ef2008-04-18 17:48:16 +0000454 public void windowDeactivated(WindowEvent evt) {
455 }
456
457 public void windowOpened(WindowEvent evt) {
458 }
459
460 public void windowClosed(WindowEvent evt) {
461 }
462
463 public void windowIconified(WindowEvent evt) {
464 }
465
466 public void windowDeiconified(WindowEvent evt) {
467 }
468
Constantin Kaplinsky1215b992008-04-18 09:51:44 +0000469}