()
| 296 | |
| 297 | |
| 298 | protected void initWindow() { |
| 299 | window = GLWindow.create(screen, pgl.getCaps()); |
| 300 | |
| 301 | // Make sure that we pass the window close through to exit(), otherwise |
| 302 | // we're likely to have OpenGL try to shut down halfway through rendering |
| 303 | // a frame. Particularly problematic for complex/slow apps. |
| 304 | // https://github.com/processing/processing/issues/4690 |
| 305 | window.setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSE); |
| 306 | |
| 307 | // macOS pixel density is handled transparently by the OS |
| 308 | windowScaleFactor = |
| 309 | (PApplet.platform == PConstants.MACOS) ? 1 : sketch.pixelDensity; |
| 310 | |
| 311 | boolean spanDisplays = sketch.sketchDisplay() == PConstants.SPAN; |
| 312 | |
| 313 | screenRect = spanDisplays ? |
| 314 | // TODO probably need to apply this to the spanning version [fry 230218] |
| 315 | new Rectangle(screen.getX(), screen.getY(), |
| 316 | screen.getWidth(), screen.getHeight()) : |
| 317 | new Rectangle((int) displayRect.getX(), |
| 318 | (int) displayRect.getY(), |
| 319 | (int) displayRect.getWidth(), |
| 320 | (int) displayRect.getHeight()); |
| 321 | |
| 322 | // new Rectangle((int) (uiScale * displayRect.getX()), |
| 323 | // (int) (uiScale * displayRect.getY()), |
| 324 | // (int) (uiScale * displayRect.getWidth()), |
| 325 | // (int) (uiScale * displayRect.getHeight())); |
| 326 | |
| 327 | // Set the displayWidth/Height variables inside PApplet, so that they're |
| 328 | // usable and can even be returned by the sketchWidth()/Height() methods. |
| 329 | sketch.displayWidth = screenRect.width; |
| 330 | sketch.displayHeight = screenRect.height; |
| 331 | |
| 332 | // Sometimes the window manager or OS will resize the window. |
| 333 | // Keep track of the requested width/height to notify the user. |
| 334 | sketchWidthRequested = sketch.sketchWidth(); |
| 335 | sketchHeightRequested = sketch.sketchHeight(); |
| 336 | |
| 337 | sketchWidth = sketch.sketchWidth(); |
| 338 | sketchHeight = sketch.sketchHeight(); |
| 339 | |
| 340 | boolean fullScreen = sketch.sketchFullScreen(); |
| 341 | |
| 342 | // Before 3.x, we would set the window to full screen when the requested |
| 343 | // width/height was the size of the screen. But not everyone *wants* that |
| 344 | // to be full screen (they might want to drag the window, or who knows), |
| 345 | // so that code was removed because fullScreen() is easy to use instead. |
| 346 | // https://github.com/processing/processing/issues/3545 |
| 347 | |
| 348 | if (fullScreen || spanDisplays) { |
| 349 | // sketchWidth = (int) (uiScale * screenRect.width / windowScaleFactor); |
| 350 | // sketchHeight = (int) (uiScale * screenRect.height / windowScaleFactor); |
| 351 | sketchWidth = screenRect.width / windowScaleFactor; |
| 352 | sketchHeight = screenRect.height / windowScaleFactor; |
| 353 | } |
| 354 | |
| 355 | sketch.setSize(sketchWidth, sketchHeight); |
no test coverage detected