47 * they can still represent the same physical screen. This can happen 48 * if e.g. only a certain parameter of the screen has been updated such 49 * as its scale factor. 50 * 51 * On some platforms when a window is moved to another physical screen 52 * an app can receive this event twice. One representing the physical 53 * screen change, and another - the display's parameters change. Note 54 * that sending two events instead of just one is platform-specific. 55 * 56 * The event handler can use the {@link Screen#getNativeScreen} method 57 * to determine if this is the same physical screen or not. If the 58 * native system always creates new native screen instances, there's no 59 * way for the app to distinguish between a real move to another screen 60 * or jsut a parameters update event. Since this is a somewhat rare 61 * event, an app is advised to always process it the same way. 62 * 63 * @see Window#getScreen 64 */ 65 public void handleScreenChangedEvent(Window window, long time, Screen oldScreen, Screen newScreen) { 66 } 67 } 68 69 // Native object handle (HWND, or NSWindow*, etc.) 70 private long ptr; 71 72 // 'Delegate window' ptr. Used in e.g. the Full Screen mode. 73 private volatile long delegatePtr = 0L; 74 75 // window list 76 static private final LinkedList<Window> visibleWindows = new LinkedList<Window>(); 77 // Return a list of all visible windows. Note that on platforms without a native window manager, 78 // this list will be sorted in proper z-order 79 static public synchronized List<Window> getWindows() { 80 Application.checkEventThread(); 81 return Collections.unmodifiableList(Window.visibleWindows); 82 } 83 84 static public List<Window> getWindowsClone() { 85 Application.checkEventThread(); 86 return (List<Window>)visibleWindows.clone(); 1352 + " isDecorated: " + isDecorated() + "\n" 1353 + " title: " + getTitle() + "\n" 1354 + " visible: " + isVisible() + "\n" 1355 + " focused: " + isFocused() + "\n" 1356 + " modal: " + isModal() + "\n" 1357 + " state: " + state + "\n" 1358 + " x: " + getX() + ", y: " + getY() + ", w: " + getWidth() + ", h: " + getHeight() + "\n" 1359 + ""; 1360 } 1361 1362 // "programmical" move/resize support for undecorated windows 1363 1364 static private class TrackingRectangle { 1365 int size = 0; 1366 int x = 0, y = 0, width = 0, height = 0; 1367 boolean contains(final int x, final int y) { 1368 return ((size > 0) && 1369 (x >= this.x) && (x < (this.x + this.width)) && 1370 (y >= this.y) && (y < (this.y + this.height))); 1371 } 1372 } 1373 1374 private class UndecoratedMoveResizeHelper { 1375 TrackingRectangle moveRect = null; 1376 TrackingRectangle resizeRect = null; 1377 1378 boolean inMove = false; // we are in "move" mode 1379 boolean inResize = false; // we are in "resize" mode 1380 1381 int startMouseX, startMouseY; // start mouse coords 1382 int startX, startY; // start window location (for move) 1383 int startWidth, startHeight; // start window size (for resize) 1384 1385 UndecoratedMoveResizeHelper() { 1386 this.moveRect = new TrackingRectangle(); 1387 this.resizeRect = new TrackingRectangle(); 1388 } 1389 1390 void setMoveRectangle(final int size) { 1391 this.moveRect.size = size; | 47 * they can still represent the same physical screen. This can happen 48 * if e.g. only a certain parameter of the screen has been updated such 49 * as its scale factor. 50 * 51 * On some platforms when a window is moved to another physical screen 52 * an app can receive this event twice. One representing the physical 53 * screen change, and another - the display's parameters change. Note 54 * that sending two events instead of just one is platform-specific. 55 * 56 * The event handler can use the {@link Screen#getNativeScreen} method 57 * to determine if this is the same physical screen or not. If the 58 * native system always creates new native screen instances, there's no 59 * way for the app to distinguish between a real move to another screen 60 * or jsut a parameters update event. Since this is a somewhat rare 61 * event, an app is advised to always process it the same way. 62 * 63 * @see Window#getScreen 64 */ 65 public void handleScreenChangedEvent(Window window, long time, Screen oldScreen, Screen newScreen) { 66 } 67 68 public void handleLevelEvent(int level) { 69 } 70 } 71 72 // Native object handle (HWND, or NSWindow*, etc.) 73 private long ptr; 74 75 // 'Delegate window' ptr. Used in e.g. the Full Screen mode. 76 private volatile long delegatePtr = 0L; 77 78 // window list 79 static private final LinkedList<Window> visibleWindows = new LinkedList<Window>(); 80 // Return a list of all visible windows. Note that on platforms without a native window manager, 81 // this list will be sorted in proper z-order 82 static public synchronized List<Window> getWindows() { 83 Application.checkEventThread(); 84 return Collections.unmodifiableList(Window.visibleWindows); 85 } 86 87 static public List<Window> getWindowsClone() { 88 Application.checkEventThread(); 89 return (List<Window>)visibleWindows.clone(); 1355 + " isDecorated: " + isDecorated() + "\n" 1356 + " title: " + getTitle() + "\n" 1357 + " visible: " + isVisible() + "\n" 1358 + " focused: " + isFocused() + "\n" 1359 + " modal: " + isModal() + "\n" 1360 + " state: " + state + "\n" 1361 + " x: " + getX() + ", y: " + getY() + ", w: " + getWidth() + ", h: " + getHeight() + "\n" 1362 + ""; 1363 } 1364 1365 // "programmical" move/resize support for undecorated windows 1366 1367 static private class TrackingRectangle { 1368 int size = 0; 1369 int x = 0, y = 0, width = 0, height = 0; 1370 boolean contains(final int x, final int y) { 1371 return ((size > 0) && 1372 (x >= this.x) && (x < (this.x + this.width)) && 1373 (y >= this.y) && (y < (this.y + this.height))); 1374 } 1375 } 1376 1377 protected void notifyLevelChanged(int level) { 1378 if (this.eventHandler != null) { 1379 this.eventHandler.handleLevelEvent(level); 1380 } 1381 this.level = level; 1382 } 1383 1384 private class UndecoratedMoveResizeHelper { 1385 TrackingRectangle moveRect = null; 1386 TrackingRectangle resizeRect = null; 1387 1388 boolean inMove = false; // we are in "move" mode 1389 boolean inResize = false; // we are in "resize" mode 1390 1391 int startMouseX, startMouseY; // start mouse coords 1392 int startX, startY; // start window location (for move) 1393 int startWidth, startHeight; // start window size (for resize) 1394 1395 UndecoratedMoveResizeHelper() { 1396 this.moveRect = new TrackingRectangle(); 1397 this.resizeRect = new TrackingRectangle(); 1398 } 1399 1400 void setMoveRectangle(final int size) { 1401 this.moveRect.size = size; |