From 552f3db5f5bf2a4e3af28edad741395e1681e575 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Wed, 12 Oct 2011 20:51:05 +0000 Subject: [PATCH] Revert a change from yesterday that broke the viewer (setAccelerationPriority). Fix some more issues with window sizing and scaling. Trying to eliminate unnecessary synchronization. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4725 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- java/com/tigervnc/vncviewer/CConn.java | 10 ++++-- .../com/tigervnc/vncviewer/DesktopWindow.java | 34 +++++++++---------- .../tigervnc/vncviewer/PixelBufferImage.java | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/java/com/tigervnc/vncviewer/CConn.java b/java/com/tigervnc/vncviewer/CConn.java index 089d241a..a485f339 100644 --- a/java/com/tigervnc/vncviewer/CConn.java +++ b/java/com/tigervnc/vncviewer/CConn.java @@ -85,8 +85,12 @@ class ViewportFrame extends JFrame sp.setSize(new Dimension(cc.desktop.scaledWidth, cc.desktop.scaledHeight)); sp.validate(); - if (getExtendedState() != JFrame.MAXIMIZED_BOTH) - pack(); + 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, @@ -512,7 +516,7 @@ public class CConn extends CConnection pack = false; } - if (!pack) + if (pack) viewport.setPreferredSize(new Dimension(w,h)); if (viewport.getExtendedState() == JFrame.MAXIMIZED_BOTH) { diff --git a/java/com/tigervnc/vncviewer/DesktopWindow.java b/java/com/tigervnc/vncviewer/DesktopWindow.java index 8bf718b1..978368de 100644 --- a/java/com/tigervnc/vncviewer/DesktopWindow.java +++ b/java/com/tigervnc/vncviewer/DesktopWindow.java @@ -55,7 +55,6 @@ class DesktopWindow extends JPanel implements cc = cc_; setSize(width, height); im = new PixelBufferImage(width, height, cc, this); - im.image.setAccelerationPriority(1); cursor = new Cursor(); cursorBacking = new ManagedPixelBuffer(); @@ -85,7 +84,7 @@ class DesktopWindow extends JPanel implements // DesktopWindow has actually been made visible so that getGraphics() ought // to work. - public void initGraphics() { + synchronized public void initGraphics() { cc.viewport.g = cc.viewport.getGraphics(); graphics = getComponentGraphics(cc.viewport.g); prepareImage(im.image, scaledWidth, scaledHeight, this); @@ -111,8 +110,9 @@ class DesktopWindow extends JPanel implements // might be being altered by the GUI thread. However it's only a single // boolean and it doesn't matter if we get the wrong value anyway. - synchronized(this) { - if (!cc.viewer.useLocalCursor.getValue()) return; + synchronized(cc.viewer.useLocalCursor) { + if (!cc.viewer.useLocalCursor.getValue()) + return; } hideLocalCursor(); @@ -211,7 +211,7 @@ class DesktopWindow extends JPanel implements int h = cc.cp.height; hideLocalCursor(); setSize(w, h); - synchronized (this) { + synchronized (im) { im.resize(w, h); } } @@ -224,7 +224,7 @@ class DesktopWindow extends JPanel implements int h = invalidBottom - y; invalidRect = false; - synchronized (this) { + synchronized (im) { im.put(x, y, w, h, graphics); } } @@ -258,7 +258,7 @@ class DesktopWindow extends JPanel implements final public void fillRect(int x, int y, int w, int h, int pix) { if (overlapsCursor(x, y, w, h)) hideLocalCursor(); - synchronized (this) { + synchronized (im) { im.fillRect(x, y, w, h, pix); } invalidate(x, y, w, h); @@ -269,7 +269,7 @@ class DesktopWindow extends JPanel implements final public void imageRect(int x, int y, int w, int h, int[] pix) { if (overlapsCursor(x, y, w, h)) hideLocalCursor(); - synchronized (this) { + synchronized (im) { im.imageRect(x, y, w, h, pix); } invalidate(x, y, w, h); @@ -281,7 +281,7 @@ class DesktopWindow extends JPanel implements int srcX, int srcY) { if (overlapsCursor(x, y, w, h) || overlapsCursor(srcX, srcY, w, h)) hideLocalCursor(); - synchronized (this) { + synchronized (im) { im.copyRect(x, y, w, h, srcX, srcY); } if (!cc.viewer.fastCopyRect.getValue()) { @@ -407,7 +407,7 @@ class DesktopWindow extends JPanel implements // - Render the cursor! if (e.getX() != cursorPosX || e.getY() != cursorPosY) { hideLocalCursor(); - synchronized(this) { + synchronized(im) { if (e.getX() >= 0 && e.getX() < im.width() && e.getY() >= 0 && e.getY() < im.height()) { cursorPosX = e.getX(); @@ -473,7 +473,7 @@ class DesktopWindow extends JPanel implements // Note that mutex MUST be held when hideLocalCursor() and showLocalCursor() // are called. - private void hideLocalCursor() { + synchronized private void hideLocalCursor() { // - Blit the cursor backing store over the cursor if (cursorVisible) { cursorVisible = false; @@ -484,7 +484,7 @@ class DesktopWindow extends JPanel implements } } - private void showLocalCursor() { + synchronized private void showLocalCursor() { if (cursorAvailable && !cursorVisible) { if (!im.getPF().equal(cursor.getPF()) || cursor.width() == 0 || cursor.height() == 0) { @@ -522,15 +522,13 @@ class DesktopWindow extends JPanel implements // run() is executed by the setColourMapEntriesTimerThread - it sleeps for // 100ms before actually updating the colourmap. - public void run() { + synchronized public void run() { try { Thread.sleep(100); } catch (InterruptedException e) {} - synchronized (this) { - im.updateColourMap(); - im.put(0, 0, im.width(), im.height(), graphics); - setColourMapEntriesTimerThread = null; - } + im.updateColourMap(); + im.put(0, 0, im.width(), im.height(), graphics); + setColourMapEntriesTimerThread = null; } // access to cc by different threads is specified in CConn diff --git a/java/com/tigervnc/vncviewer/PixelBufferImage.java b/java/com/tigervnc/vncviewer/PixelBufferImage.java index bb7e0e48..ef0eed86 100644 --- a/java/com/tigervnc/vncviewer/PixelBufferImage.java +++ b/java/com/tigervnc/vncviewer/PixelBufferImage.java @@ -63,7 +63,7 @@ public class PixelBufferImage extends PixelBuffer implements ImageProducer width_ = w; height_ = h; image = desktop.createImage(this); - //image.setAccelerationPriority(1); + image.setAccelerationPriority(1); data = new int[width() * height()]; -- 2.39.5