@Override public void destroy() { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() START - "+currentThreadName()); } glWindow.setVisible(false); // hide 1st base.destroy(); // destroy glWindow unrecoverable base=null; glWindow=null; browserWin.destroy(); // make sure the open display connection gets closed! browserWin = null; if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() END - "+currentThreadName()); } }
/** * @param nw * @return top-left client-area position in window units */ public static PointImmutable getLocationOnScreen(final NativeWindow nw) { final String nwt = NativeWindowFactory.getNativeWindowType(true); if( NativeWindowFactory.TYPE_X11 == nwt ) { return X11Lib.GetRelativeLocation(nw.getDisplayHandle(), nw.getScreenIndex(), nw.getWindowHandle(), 0, 0, 0); } else if( NativeWindowFactory.TYPE_WINDOWS == nwt ) { return GDIUtil.GetRelativeLocation(nw.getWindowHandle(), 0, 0, 0); } else if( NativeWindowFactory.TYPE_MACOSX == nwt ) { return OSXUtil.GetLocationOnScreen(nw.getWindowHandle(), 0, 0); /** * FIXME: Needs service provider interface (SPI) for TK dependent implementation } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) { } else if( NativeWindowFactory.TYPE_ANDROID== nwt ) { } else if( NativeWindowFactory.TYPE_EGL == nwt ) { } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) { } else if( NativeWindowFactory.TYPE_AWT == nwt ) { */ } throw new UnsupportedOperationException("n/a for windowing system: "+nwt); }
/** * @param cWin child window, must not be null * @param pWin parent window, may be null * @return true if at least one of both window's configurations is offscreen */ protected static boolean isOffscreenInstance(final NativeWindow cWin, final NativeWindow pWin) { boolean ofs = false; final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); if( null != cWinCfg ) { ofs = !cWinCfg.getChosenCapabilities().isOnscreen(); } if( !ofs && null != pWin ) { final AbstractGraphicsConfiguration pWinCfg = pWin.getGraphicsConfiguration(); if( null != pWinCfg ) { ofs = !pWinCfg.getChosenCapabilities().isOnscreen(); } } return ofs; }
private static long getNativeWindowHandle(final NativeWindow nativeWindow) { long handle = 0; if(null!=nativeWindow) { boolean wasLocked = false; if( NativeSurface.LOCK_SURFACE_NOT_READY < nativeWindow.lockSurface() ) { wasLocked = true; try { handle = nativeWindow.getWindowHandle(); if(0==handle) { throw new NativeWindowException("Parent native window handle is NULL, after succesful locking: "+nativeWindow); } } catch (final NativeWindowException nwe) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.getNativeWindowHandle: not successful yet: "+nwe); } } finally { nativeWindow.unlockSurface(); } } if(DEBUG_IMPLEMENTATION) { System.err.println("Window.getNativeWindowHandle: locked "+wasLocked+", "+nativeWindow); } } return handle; }
if( w > parentWindow.getWidth() ) { w = parentWindow.getWidth(); if( h > parentWindow.getHeight() ) { h = parentWindow.getHeight(); if( null != parentWindow ) { parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); parentWindowLocked.unlockSurface();
} else { final AbstractGraphicsConfiguration parentConfig = parentWindow.getGraphicsConfiguration(); if(null!=parentConfig) { final AbstractGraphicsScreen parentScreen = parentConfig.getScreen(); win.setSize(parentWindow.getWidth(), parentWindow.getHeight()); if ( null != newtParentWindow ) { newtParentWindow.addChild(win);
if(nw.getWindowHandle() != nw.getSurfaceHandle()) { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); eglSurface = createSurface(eglConfig, eglws.getSurfaceWidth(), eglws.getSurfaceHeight(), nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError();
private Point getLocationOnScreenImpl(final int x, final int y, final NativeWindow parent, final boolean useParent) { if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) { return OSXUtil.GetLocationOnScreen(surfaceHandle, x, y); } final Point p = new Point(x, y); if( useParent ) { p.translate( parent.getLocationOnScreen(null) ); } return p; }
private boolean useParent(final NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); }
if( width > newParentWindow.getWidth() ) { width = newParentWindow.getWidth(); if( height > newParentWindow.getHeight() ) { height = newParentWindow.getHeight(); if( null != parentWindow ) { parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindowLocked); parentWindowHandle = parentWindowLocked.getWindowHandle(); } else { parentWindowLocked = null; } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface();
/** Callback for native screen position change event of the client area. */ protected void screenPositionChanged(final boolean defer, final int newX, final int newY) { // passed coordinates are in screen position of the client area if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); if( null == parent || isOffscreenInstance ) { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } positionChanged(defer, newX, newY); } else { // screen position -> rel child window position final Point absPos = new Point(newX, newY); final Point parentOnScreen = parent.getLocationOnScreen(null); absPos.translate( parentOnScreen.scale(-1, -1) ); if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); } positionChanged(defer, absPos.getX(), absPos.getY()); } } else if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.positionChanged.2 (Screen Pos - IGN): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } }
@Override public void windowDestroyNotify(final WindowEvent e) { if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && null == glWindow.getParent() && null != parentWin && 0 != parentWin.getWindowHandle() ) { // we may be called directly by the native EDT new Thread(new Runnable() { @Override public void run() { if( glWindow.isNativeValid() && null != parentWin && 0 != parentWin.getWindowHandle() ) { glWindow.reparentWindow(parentWin, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); } } }).start(); } } };
public static boolean isScreenCompatible(final NativeWindow parent, final Screen childScreen) { // Get parent's NativeWindow details final AbstractGraphicsConfiguration parentConfig = parent.getGraphicsConfiguration(); final AbstractGraphicsScreen parentScreen = parentConfig.getScreen(); final AbstractGraphicsDevice parentDevice = parentScreen.getDevice(); final DisplayImpl childDisplay = (DisplayImpl) childScreen.getDisplay(); final String parentDisplayName = childDisplay.validateDisplayName(null, parentDevice.getHandle()); final String childDisplayName = childDisplay.getName(); if( ! parentDisplayName.equals( childDisplayName ) ) { return false; } if( parentScreen.getIndex() != childScreen.getIndex() ) { return false; } return true; }
parentWindow.getLocationOnScreen(storage);
if( null != nw ) { setGraphicsConfiguration( awtCanvas.getAWTGraphicsConfiguration() ); setWindowHandle( nw.getWindowHandle() );
((WindowImpl)nw).windowDestroyNotify(true); } else { nw.destroy();
public static Screen createCompatibleScreen(final NativeWindow parent, final Screen childScreen) { // Get parent's NativeWindow details final AbstractGraphicsConfiguration parentConfig = parent.getGraphicsConfiguration(); final AbstractGraphicsScreen parentScreen = parentConfig.getScreen(); final AbstractGraphicsDevice parentDevice = parentScreen.getDevice(); if(null != childScreen) { // check if child Display/Screen is compatible already final DisplayImpl childDisplay = (DisplayImpl) childScreen.getDisplay(); final String parentDisplayName = childDisplay.validateDisplayName(null, parentDevice.getHandle()); final String childDisplayName = childDisplay.getName(); final boolean displayEqual = parentDisplayName.equals( childDisplayName ); final boolean screenEqual = parentScreen.getIndex() == childScreen.getIndex(); if(DEBUG_IMPLEMENTATION) { System.err.println("NewtFactory.createCompatibleScreen: Display: "+ parentDisplayName+" =? "+childDisplayName+" : "+displayEqual+"; Screen: "+ parentScreen.getIndex()+" =? "+childScreen.getIndex()+" : "+screenEqual); } if( displayEqual && screenEqual ) { // match: display/screen return childScreen; } } // Prep NEWT's Display and Screen according to the parent final String type = NativeWindowFactory.getNativeWindowType(true); final Display display = NewtFactory.createDisplay(type, parentDevice.getHandle(), true); return NewtFactory.createScreen(display, parentScreen.getIndex()); } }
final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration(); final NativeWindow pWin = getParent(); final AbstractGraphicsConfiguration pWinCfg = null != pWin ? pWin.getGraphicsConfiguration() : null; System.err.println("MacWindow reconfig.0: "+x+"/"+y+" -> clientPos "+pClientLevelOnSreen+" - "+width+"x"+height+ ",\n\t parent type "+(null != pWin ? pWin.getClass().getName() : null)+