public void addChild(DesktopWindow child) {
sp = new JScrollPane(child);
+ sp.setDoubleBuffered(true);
child.setBackground(Color.BLACK);
child.setOpaque(true);
sp.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
JOptionPane.PLAIN_MESSAGE);
}
- synchronized public void refresh() {
- writer().writeFramebufferUpdateRequest(new Rect(0,0,cp.width,cp.height), false);
+ public void refresh() {
+ synchronized (this) {
+ writer().writeFramebufferUpdateRequest(new Rect(0,0,cp.width,cp.height), false);
+ }
pendingUpdate = true;
}
}
- synchronized public void writePointerEvent(MouseEvent ev) {
+ public void writePointerEvent(MouseEvent ev) {
if (state() != RFBSTATE_NORMAL) return;
switch (ev.getID()) {
break;
}
- writeModifiers(ev.getModifiers() & ~KeyEvent.ALT_MASK & ~KeyEvent.META_MASK);
+ synchronized (this) {
+ writeModifiers(ev.getModifiers() & ~KeyEvent.ALT_MASK & ~KeyEvent.META_MASK);
+ }
if (cp.width != desktop.scaledWidth ||
cp.height != desktop.scaledHeight) {
int sy = (desktop.scaleHeightRatio == 1.00)
? ev.getY() : (int)Math.floor(ev.getY()/desktop.scaleHeightRatio);
ev.translatePoint(sx - ev.getX(), sy - ev.getY());
- writer().writePointerEvent(new Point(ev.getX(),ev.getY()), buttonMask);
- } else {
+ }
+
+ synchronized (this) {
writer().writePointerEvent(new Point(ev.getX(),ev.getY()), buttonMask);
}
}
- void writeModifiers(int m) {
+ synchronized void writeModifiers(int m) {
if ((m & Event.SHIFT_MASK) != (pressedModifiers & Event.SHIFT_MASK))
writeKeyEvent(Keysyms.Shift_L, (m & Event.SHIFT_MASK) != 0);
if ((m & Event.CTRL_MASK) != (pressedModifiers & Event.CTRL_MASK))
cc = cc_;
setSize(width, height);
im = new PixelBufferImage(width, height, cc, this);
+ im.image.setAccelerationPriority(1);
cursor = new Cursor();
cursorBacking = new ManagedPixelBuffer();
});
setFocusTraversalKeysEnabled(false);
setFocusable(true);
- setDoubleBuffered(true);
}
public int width() {
synchronized(this) {
if (!cc.viewer.useLocalCursor.getValue()) return;
+ }
hideLocalCursor();
tk.createImage(bitmap).getScaledInstance(cw,ch,hint);
softCursor = tk.createCustomCursor(cursorImage,
new java.awt.Point(hotspot.x,hotspot.y), "Cursor");
- }
if (softCursor != null) {
setCursor(softCursor);
}
// resize() is called when the desktop has changed size
- synchronized public void resize() {
+ public void resize() {
int w = cc.cp.width;
int h = cc.cp.height;
hideLocalCursor();
setSize(w, h);
- im.resize(w, h);
+ synchronized (this) {
+ im.resize(w, h);
+ }
}
final void drawInvalidRect() {
drawInvalidRect();
}
- synchronized final public void fillRect(int x, int y, int w, int h, int pix)
+ final public void fillRect(int x, int y, int w, int h, int pix)
{
if (overlapsCursor(x, y, w, h)) hideLocalCursor();
- im.fillRect(x, y, w, h, pix);
+ synchronized (this) {
+ im.fillRect(x, y, w, h, pix);
+ }
invalidate(x, y, w, h);
if (softCursor == null)
showLocalCursor();
}
- synchronized final public void imageRect(int x, int y, int w, int h,
+ final public void imageRect(int x, int y, int w, int h,
int[] pix) {
if (overlapsCursor(x, y, w, h)) hideLocalCursor();
- im.imageRect(x, y, w, h, pix);
+ synchronized (this) {
+ im.imageRect(x, y, w, h, pix);
+ }
invalidate(x, y, w, h);
if (softCursor == null)
showLocalCursor();
}
- synchronized final public void copyRect(int x, int y, int w, int h,
+ final public void copyRect(int x, int y, int w, int h,
int srcX, int srcY) {
if (overlapsCursor(x, y, w, h) || overlapsCursor(srcX, srcY, w, h))
hideLocalCursor();
- im.copyRect(x, y, w, h, srcX, srcY);
+ synchronized (this) {
+ im.copyRect(x, y, w, h, srcX, srcY);
+ }
if (!cc.viewer.fastCopyRect.getValue()) {
invalidate(x, y, w, h);
}
////////////////////////////////////////////////////////////////////
// The following methods are all called from the GUI thread
- synchronized void resetLocalCursor() {
+ void resetLocalCursor() {
hideLocalCursor();
cursorAvailable = false;
}
scaleHeightRatio = (float)scaledHeight / (float)cc.cp.height;
}
- synchronized public void paintComponent(Graphics g) {
+ public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(im.image, 0, 0, scaledWidth, scaledHeight, null);
}
}
-
+
String oldContents = "";
synchronized public void checkClipboard() {
if (!cc.viewer.viewOnly.getValue())
cc.writePointerEvent(e);
// - If local cursor rendering is enabled then use it
- synchronized(this) {
- if (cursorAvailable) {
- // - Render the cursor!
- if (e.getX() != cursorPosX || e.getY() != cursorPosY) {
- hideLocalCursor();
+ if (cursorAvailable) {
+ // - Render the cursor!
+ if (e.getX() != cursorPosX || e.getY() != cursorPosY) {
+ hideLocalCursor();
+ synchronized(this) {
if (e.getX() >= 0 && e.getX() < im.width() &&
e.getY() >= 0 && e.getY() < im.height()) {
cursorPosX = e.getX();