int[] zrleTilePixels24;
ZlibInStream zrleInStream;
boolean zrleRecWarningShown = false;
+ boolean isFirstSizeAutoUpdate = true;
// Zlib encoder's data.
byte[] zlibBuf;
int fbWidth = rfb.framebufferWidth;
int fbHeight = rfb.framebufferHeight;
+ // FIXME: This part of code must be in VncViewer i think
if (viewer.options.autoScale) {
- if (!(maxWidth > 0 && maxHeight > 0)) {
- maxWidth = fbWidth;
- maxHeight = fbHeight;
+ if (viewer.inAnApplet) {
+ maxWidth = viewer.getWidth();
+ maxHeight = viewer.getHeight();
+ } else {
+ if (viewer.vncFrame != null) {
+ if (isFirstSizeAutoUpdate) {
+ isFirstSizeAutoUpdate = false;
+ Dimension screenSize = viewer.vncFrame.getToolkit().getScreenSize();
+ maxWidth = (int)screenSize.getWidth() - 100;
+ maxHeight = (int)screenSize.getHeight() - 100;
+ viewer.vncFrame.setSize(maxWidth, maxHeight);
+ } else {
+ viewer.desktopScrollPane.doLayout();
+ maxWidth = viewer.desktopScrollPane.getWidth();
+ maxHeight = viewer.desktopScrollPane.getHeight();
+ }
+ } else {
+ maxWidth = fbWidth;
+ maxHeight = fbHeight;
+ }
}
int f1 = maxWidth * 100 / fbWidth;
int f2 = maxHeight * 100 / fbHeight;
pixelsSource.setAnimated(true);
rawPixelsImage = Toolkit.getDefaultToolkit().createImage(pixelsSource);
+ // FIXME: This part of code must be in VncViewer i think
// Update the size of desktop containers.
if (viewer.inSeparateFrame) {
- if (viewer.desktopScrollPane != null)
- resizeDesktopFrame();
+ if (viewer.desktopScrollPane != null) {
+ if (!viewer.options.autoScale) {
+ resizeDesktopFrame();
+ } else {
+ setSize(scaledWidth, scaledHeight);
+ viewer.desktopScrollPane.setSize(maxWidth + 200,
+ maxHeight + 200);
+ }
+ }
} else {
setSize(scaledWidth, scaledHeight);
}
import java.net.*;
public class VncViewer extends java.applet.Applet
- implements java.lang.Runnable, WindowListener {
+ implements java.lang.Runnable, WindowListener, ComponentListener {
boolean inAnApplet = true;
boolean inSeparateFrame = false;
cursorUpdatesDef = null;
eightBitColorsDef = null;
- if (inSeparateFrame)
+ if (inSeparateFrame) {
vncFrame.addWindowListener(this);
+ vncFrame.addComponentListener(this);
+ }
rfbThread = new Thread(this);
rfbThread.start();
gbc.fill = GridBagConstraints.BOTH;
gridbag.setConstraints(desktopScrollPane, gbc);
desktopScrollPane.add(canvasPanel);
+ // If auto scale is not enabled we don't need to set first frame
+ // size to fullscreen
+ if (!options.autoScale) {
+ vc.isFirstSizeAutoUpdate = false;
+ }
// Finally, add our ScrollPane to the Frame window.
vncFrame.add(desktopScrollPane);
vc.resizeDesktopFrame();
} else {
-
// Just add the VncCanvas component to the Applet.
gridbag.setConstraints(vc, gbc);
add(vc);
validate();
-
}
if (showControls) {
public void enableInput(boolean enable) {
vc.enableInput(enable);
}
+
+ //
+ // Resize framebuffer if autoScale is enabled.
+ //
+
+ public void componentResized(ComponentEvent e) {
+ if (e.getComponent() == vncFrame) {
+ if (options.autoScale) {
+ if (vc != null) {
+ if (!vc.isFirstSizeAutoUpdate) {
+ vc.updateFramebufferSize();
+ }
+ }
+ }
+ }
+ }
+
+ //
+ // Ignore component events we're not interested in.
+ //
+
+ public void componentShown(ComponentEvent e) { }
+ public void componentMoved(ComponentEvent e) { }
+ public void componentHidden(ComponentEvent e) { }
//
// Close application properly on window close event.