MCPcopy Create free account
hub / github.com/benfry/processing4 / placeWindow

Method placeWindow

core/src/processing/opengl/PSurfaceJOGL.java:598–638  ·  view source on GitHub ↗
(int[] location, int[] editorLocation)

Source from the content-addressed store, hash-verified

596
597
598 @Override
599 public void placeWindow(int[] location, int[] editorLocation) {
600 if (sketch.sketchFullScreen()) {
601 return;
602 }
603
604 int x = window.getX() - window.getInsets().getLeftWidth();
605 int y = window.getY() - window.getInsets().getTopHeight();
606 int w = window.getWidth() + window.getInsets().getTotalWidth();
607 int h = window.getHeight() + window.getInsets().getTotalHeight();
608
609 if (location != null) {
610 window.setTopLevelPosition(location[0], location[1]);
611
612 } else if (editorLocation != null) {
613 int locationX = editorLocation[0] - 20;
614 int locationY = editorLocation[1];
615
616 if (locationX - w > 10) {
617 // if it fits to the left of the window
618 window.setTopLevelPosition(locationX - w, locationY);
619
620 } else { // doesn't fit
621 locationX = (sketch.displayWidth - w) / 2;
622 locationY = (sketch.displayHeight - h) / 2;
623 window.setTopLevelPosition(locationX, locationY);
624 }
625 } else { // just center on screen
626 // Can't use frame.setLocationRelativeTo(null) because it sends the
627 // frame to the main display, which undermines the --display setting.
628 window.setTopLevelPosition(screenRect.x + (screenRect.width - sketchWidth) / 2,
629 screenRect.y + (screenRect.height - sketchHeight) / 2);
630 }
631
632 Point frameLoc = new Point(x, y);
633 if (frameLoc.y < 0) {
634 // Windows actually allows you to place frames where they can't be
635 // closed. Awesome. https://download.processing.org/bugzilla/1508.html
636 window.setTopLevelPosition(frameLoc.x, 30);
637 }
638 }
639
640
641 public void placePresent(int stopColor) {

Callers

nothing calls this directly

Calls 5

sketchFullScreenMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected