Skip to content

Commit a3dd19a

Browse files
committed
avoiding thread lockup in windows
1 parent cbc8aeb commit a3dd19a

1 file changed

Lines changed: 13 additions & 54 deletions

File tree

java/libraries/jogl/src/processing/jogl/PSurfaceJOGL.java

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class PSurfaceJOGL implements PSurface {
5151
PApplet sketch;
5252
PGraphics graphics;
5353

54+
int sketchX;
55+
int sketchY;
5456
int sketchWidth;
5557
int sketchHeight;
5658

@@ -168,8 +170,8 @@ public void initFrame(PApplet sketch, int backgroundColor,
168170
if (displayDevice == null) {
169171
displayDevice = window.getMainMonitor();
170172
}
171-
int sketchX = displayDevice.getViewportInWindowUnits().getX();
172-
int sketchY = displayDevice.getViewportInWindowUnits().getY();
173+
sketchX = displayDevice.getViewportInWindowUnits().getX();
174+
sketchY = displayDevice.getViewportInWindowUnits().getY();
173175

174176
int screenWidth = screen.getWidth();
175177
int screenHeight = screen.getHeight();
@@ -194,8 +196,7 @@ public void initFrame(PApplet sketch, int backgroundColor,
194196
sketchHeight = screenRect.height;
195197
}
196198

197-
// window..setBackground(new Color(backgroundColor, true));
198-
window.setPosition(sketchX, sketchY);
199+
// window..setBackground(new Color(backgroundColor, true));
199200
window.setSize(sketchWidth, sketchHeight);
200201

201202
System.out.println("deviceIndex: " + deviceIndex);
@@ -253,7 +254,7 @@ public void uncaughtException(final GLAnimatorControl animator,
253254
}
254255
});
255256

256-
(new Thread(new Runnable() {
257+
new Thread(new Runnable() {
257258
public void run() {
258259
synchronized (waitObject) {
259260
try {
@@ -269,31 +270,7 @@ public void run() {
269270
}
270271
}
271272
}
272-
}
273-
)).start();
274-
275-
276-
/*
277-
try {
278-
EventQueue.invokeAndWait(new Runnable() {
279-
public void run() {
280-
while (true) {
281-
try {
282-
if (drawException != null) {
283-
if (drawException instanceof RuntimeException) {
284-
throw (RuntimeException)drawException;
285-
} else {
286-
throw new RuntimeException(drawException);
287-
}
288-
} else {
289-
Thread.sleep(100);
290-
}
291-
} catch (InterruptedException e) { }
292-
}
293-
}});
294-
} catch (Exception ex) {
295-
}
296-
*/
273+
}).start();
297274

298275

299276
window.addWindowListener(new WindowAdapter() {
@@ -325,30 +302,6 @@ public void run() {
325302
// return frame;
326303
}
327304

328-
// @SuppressWarnings("serial")
329-
// class DummyFrame extends Frame {
330-
//
331-
// public DummyFrame() {
332-
// super();
333-
// }
334-
//
335-
// @Override
336-
// public void setResizable(boolean resizable) {
337-
//// super.setResizable(resizable);
338-
// }
339-
//
340-
// @Override
341-
// public void setVisible(boolean visible) {
342-
// window.setVisible(visible);
343-
// }
344-
//
345-
// @Override
346-
// public void setTitle(String title) {
347-
// window.setTitle(title);
348-
// }
349-
// }
350-
351-
352305
@Override
353306
public void setTitle(String title) {
354307
window.setTitle(title);
@@ -468,6 +421,12 @@ public void startThread() {
468421
if (animator != null) {
469422
System.err.println("5. start animator");
470423
animator.start();
424+
425+
if (0 < sketchX && 0 < sketchY) {
426+
System.err.println("5.1 set inital window position");
427+
window.setPosition(sketchX, sketchY);
428+
sketchX = sketchY = 0;
429+
}
471430
// animator.getThread().setName("Processing-GL-draw");
472431
}
473432
}

0 commit comments

Comments
 (0)