66import java .awt .GraphicsConfiguration ;
77import java .awt .GraphicsDevice ;
88import java .awt .GraphicsEnvironment ;
9+ import java .awt .Point ;
910import java .awt .Rectangle ;
1011import java .awt .geom .Rectangle2D ;
1112import java .awt .image .BufferedImage ;
@@ -55,6 +56,8 @@ public class PSurfaceLWJGL implements PSurface {
5556
5657 // Event handling
5758
59+ boolean externalMessages = false ;
60+
5861 /** Poller threads to get the keyboard/mouse events from LWJGL */
5962 protected static KeyPoller keyPoller ;
6063 protected static MousePoller mousePoller ;
@@ -225,20 +228,19 @@ public void placeWindow(int[] location) {
225228 // frame to the main display, which undermines the --display setting.
226229 setFrameCentered ();
227230 }
231+
232+ if (Display .getY () < 0 ) {
233+ // Windows actually allows you to place frames where they can't be
234+ // closed. Awesome. http://dev.processing.org/bugs/show_bug.cgi?id=1508
235+ Display .setLocation (Display .getX (), 30 );
236+ }
228237 }
229238
230239 @ Override
231240 public void placeWindow (int [] location , int [] editorLocation ) {
232241 // TODO Auto-generated method stub
233242
234243 }
235-
236- private void setFrameCentered () {
237- // Can't use frame.setLocationRelativeTo(null) because it sends the
238- // frame to the main display, which undermines the --display setting.
239- Display .setLocation (screenRect .x + (screenRect .width - sketchWidth ) / 2 ,
240- screenRect .y + (screenRect .height - sketchHeight ) / 2 );
241- }
242244
243245 @ Override
244246 public void placePresent (Color stopColor ) {
@@ -248,10 +250,16 @@ public void placePresent(Color stopColor) {
248250
249251 @ Override
250252 public void setupExternalMessages () {
251- // TODO Auto-generated method stub
252-
253+ externalMessages = true ;
253254 }
254255
256+ private void setFrameCentered () {
257+ // Can't use frame.setLocationRelativeTo(null) because it sends the
258+ // frame to the main display, which undermines the --display setting.
259+ Display .setLocation (screenRect .x + (screenRect .width - sketchWidth ) / 2 ,
260+ screenRect .y + (screenRect .height - sketchHeight ) / 2 );
261+ }
262+
255263 @ Override
256264 public void startThread () {
257265 if (thread == null ) {
@@ -494,13 +502,17 @@ public void run() { // not good to make this synchronized, locks things up
494502
495503 // un-pause the sketch and get rolling
496504 sketch .start ();
497-
505+
506+ int x0 = Display .getX ();
507+ int y0 = Display .getY ();
498508 while ((Thread .currentThread () == thread ) && !sketch .finished ) {
499509 if (Display .wasResized ()) {
500510 setSize (Display .getWidth (), Display .getHeight ());
501511 }
502512 pgl .setThread (thread );
503513 checkPause ();
514+
515+
504516
505517 // Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
506518 // otherwise it may attempt a resize mid-render.
@@ -548,9 +560,23 @@ public void run() { // not good to make this synchronized, locks things up
548560// beforeTime = System.nanoTime();
549561 Display .sync ((int )frameRateTarget );
550562
563+
564+ int x = Display .getX ();
565+ int y = Display .getY ();
566+ if (externalMessages && (x != x0 || y0 != y )) {
567+ System .err .println (PApplet .EXTERNAL_MOVE + " " + x + " " + y );
568+ System .err .flush (); // doesn't seem to help or hurt
569+ }
570+ x0 = x ;
571+ y0 = y ;
572+
551573 if (Display .isCloseRequested ()) break ;
552574 }
553575
576+ if (externalMessages ) {
577+ sketch .exit (); // don't quit, need to just shut everything down (0133)
578+ }
579+
554580 keyPoller .requestStop ();
555581 mousePoller .requestStop ();
556582 sketch .dispose (); // call to shutdown libs?
0 commit comments