Skip to content

Commit

Permalink
Viewer: Add a space after the synchronized keyword
Browse files Browse the repository at this point in the history
This seems to be the more common convention, since synchronized is a
keyword (like if or catch) rather than a function.
  • Loading branch information
dcommander committed Feb 4, 2025
1 parent 8276416 commit 5125b62
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions java/com/turbovnc/network/StreamDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void close() {

private void inThreadRun() {
while (true) {
synchronized(this) {
synchronized (this) {
// Wait until data has been removed from the input buffer
while (inPos != inLen) {
try {
Expand All @@ -84,14 +84,14 @@ private void inThreadRun() {
try {
n = inputStream.read(inBuffer, 0, inBuffer.length);
} catch (IOException e) {
synchronized(this) {
synchronized (this) {
error = e;
notifyAll();
return;
}
}

synchronized(this) {
synchronized (this) {
if (n < 0) { // EOF
inLen = -1;
notifyAll();
Expand Down Expand Up @@ -127,7 +127,7 @@ public synchronized int read(byte[] buf, int bufPtr, int length) {

private void outThreadRun() {
while (true) {
synchronized(this) {
synchronized (this) {
// Wait until there is data in the output buffer
while (outLen == 0) {
try {
Expand All @@ -149,14 +149,14 @@ private void outThreadRun() {
outputStream.write(outBuffer, 0, outLen);
outputStream.flush();
} catch (IOException e) {
synchronized(this) {
synchronized (this) {
error = e;
notifyAll();
return;
}
}

synchronized(this) {
synchronized (this) {
outLen = 0;
notifyAll();
}
Expand Down
2 changes: 1 addition & 1 deletion java/com/turbovnc/rfb/CConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public void fence(int flags, int len, byte[] data) {
// We cannot guarantee any synchronisation at this level
flags = 0;

synchronized(this) {
synchronized (this) {
writer().writeFence(flags, len, data);
}
}
Expand Down
4 changes: 2 additions & 2 deletions java/com/turbovnc/vncviewer/BIPixelBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void imageRect(int x, int y, int w, int h, Object pix) {
if (pix instanceof Image) {
Image img = (Image)pix;
clip = new Rectangle(x, y, w, h);
synchronized(clip) {
synchronized (clip) {
tk.prepareImage(img, -1, -1, this);
try {
clip.wait(1000);
Expand Down Expand Up @@ -143,7 +143,7 @@ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
} else {
if ((infoflags & ALLBITS) != 0) {
if (clip != null) {
synchronized(clip) {
synchronized (clip) {
Graphics2D graphics = (Graphics2D)image.getGraphics();
graphics.drawImage(img, clip.x, clip.y, clip.width, clip.height,
null);
Expand Down
4 changes: 2 additions & 2 deletions java/com/turbovnc/vncviewer/CConn.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void deleteWindow(boolean disposeViewport) {
// block.
public void blockCallback() {
try {
synchronized(this) {
synchronized (this) {
wait(0, 50000);
}
} catch (InterruptedException e) {
Expand Down Expand Up @@ -406,7 +406,7 @@ public void run() {
SystemException.checkException(e);
throw new SystemException(e);
}
synchronized(viewer) {
synchronized (viewer) {
viewer.notify();
}
}
Expand Down
12 changes: 6 additions & 6 deletions java/com/turbovnc/vncviewer/Viewport.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public void setupExtInputHelper() {
(cc.cp.supportsGII || Utils.isMac())) {
try {
if (Utils.isMac()) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
setupExtInput(cc.params.serverKeyMap.get());
}
} else
Expand Down Expand Up @@ -592,7 +592,7 @@ public void cleanupExtInputHelper() {
}
try {
if (Utils.isMac()) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
cleanupExtInput();
}
} else
Expand Down Expand Up @@ -637,7 +637,7 @@ boolean processExtInputEventHelper(int type) {
boolean retval = false;
if (Helper.isAvailable() && cc.cp.supportsGII && !Utils.isMac()) {
boolean isExtEvent = false;
synchronized(lastEvent) {
synchronized (lastEvent) {
try {
isExtEvent = processExtInputEvent(type);
} catch (UnsatisfiedLinkError e) {
Expand Down Expand Up @@ -731,7 +731,7 @@ void handleTabletProximityEvent(final boolean enteringProximity,
if (devices == null || !cc.cp.supportsGII)
return;

synchronized(lastEvent) {
synchronized (lastEvent) {
if (enteringProximity) {
switch (pointingDeviceType) {
case 1: // pen
Expand Down Expand Up @@ -763,7 +763,7 @@ boolean handleTabletEvent(final int type, final double x, final double y,
if (devices == null || windowID != x11win || !cc.cp.supportsGII)
return false;

synchronized(lastEvent) {
synchronized (lastEvent) {
if (lastEvent.deviceID < 0)
// No prior proximity event was received, so we don't know which
// tablet device is generating this event. Punt to the regular
Expand All @@ -780,7 +780,7 @@ boolean handleTabletEvent(final int type, final double x, final double y,
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
synchronized(lastEvent) {
synchronized (lastEvent) {
Dimension winSize = sp.getSize();
java.awt.Point spOffset = sp.getViewport().getViewPosition();
ExtInputDevice dev = null;
Expand Down
30 changes: 15 additions & 15 deletions java/com/turbovnc/vncviewer/VncViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static class MyInvocationHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args) {
try {
if (method.getName().equals("openFiles") && args[0] != null) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
Class ofEventClass = Utils.JAVA_VERSION >= 9 ?
Class.forName("java.awt.desktop.OpenFilesEvent") :
Class.forName("com.apple.eawt.AppEvent$OpenFilesEvent");
Expand Down Expand Up @@ -231,7 +231,7 @@ static void setLookAndFeel() {
// This allows us to trap Command-Q and shut things down properly.
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
synchronized(VncViewer.conns) {
synchronized (VncViewer.conns) {
for (CConn cc : VncViewer.conns)
cc.close(false);
VncViewer.conns.clear();
Expand Down Expand Up @@ -277,7 +277,7 @@ static void setGlobalInsets() {
if (Utils.isX11()) {
frame.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
synchronized(frame) {
synchronized (frame) {
if (frame.isVisible() &&
frame.getExtendedState() == JFrame.NORMAL) {
insets = frame.getInsets();
Expand All @@ -288,7 +288,7 @@ public void componentResized(ComponentEvent e) {
});
frame.setExtendedState(JFrame.NORMAL);
frame.setVisible(true);
synchronized(frame) {
synchronized (frame) {
while (insets == null)
frame.wait();
}
Expand Down Expand Up @@ -356,7 +356,7 @@ public static void setBlitterDefaults() {
static void startViewer(String[] argv) {
VncViewer viewer = new VncViewer(argv);
if (Utils.isMac()) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
if (fileName != null) {
try {
if (fileName.toLowerCase().endsWith(".vnc"))
Expand All @@ -374,7 +374,7 @@ static void startViewer(String[] argv) {
}
viewer.start();
try {
synchronized(viewer) {
synchronized (viewer) {
viewer.wait();
}
} catch (InterruptedException e) {
Expand Down Expand Up @@ -626,7 +626,7 @@ public static void tileWindows() {
Rectangle workArea = CConn.getMaxSpannedSize(true);
int nTilesX, nTilesY;

synchronized(conns) {
synchronized (conns) {
nTilesX = nTilesY = (int)Math.sqrt(conns.size());
if (nTilesX * nTilesY < conns.size()) {
nTilesX++;
Expand Down Expand Up @@ -713,7 +713,7 @@ void reportException(Exception e, boolean reconnect) {
params.server.set(null);
start();
} else {
synchronized(this) {
synchronized (this) {
this.notify();
}
}
Expand Down Expand Up @@ -823,7 +823,7 @@ else if (params.port.get() > 0)
if (cc == null) {
cc = new CConn(this, sock, params);
if (benchFile == null) {
synchronized(conns) {
synchronized (conns) {
conns.add(cc);
}
}
Expand Down Expand Up @@ -876,7 +876,7 @@ else if (params.port.get() > 0)
cc.state() == CConnection.RFBSTATE_INITIALISATION)
cc.close(true);
}
synchronized(conns) {
synchronized (conns) {
conns.remove(cc);
}
}
Expand All @@ -890,13 +890,13 @@ else if (params.port.get() > 0)
if (cc != null) {
cc.deleteWindow(true);
cc.closeSocket();
synchronized(conns) {
synchronized (conns) {
conns.remove(cc);
}
}
} else {
cc.closeSocket();
synchronized(conns) {
synchronized (conns) {
conns.remove(cc);
}
cc = null;
Expand All @@ -915,20 +915,20 @@ else if (params.port.get() > 0)

// Is the keyboard grabbed by any TurboVNC Viewer window?
public static boolean isKeyboardGrabbed() {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
return grabOwner != null;
}
}

// Is the keyboard grabbed by a specific TurboVNC Viewer window?
public static boolean isKeyboardGrabbed(Viewport viewport) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
return grabOwner == viewport;
}
}

public static void setGrabOwner(Viewport viewport) {
synchronized(VncViewer.class) {
synchronized (VncViewer.class) {
grabOwner = viewport;
}
}
Expand Down

0 comments on commit 5125b62

Please sign in to comment.