diff options
author | Sven Gothel <[email protected]> | 2011-09-07 01:32:22 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-07 01:32:22 +0200 |
commit | e1ecd85a9d5877861cde35baababb298d1339898 (patch) | |
tree | 6606557af3995f026166b4d7bcf67c5b77a4e751 /src/newt/native | |
parent | 3766fc329ec27c09f7e71bbf705defc44a8bedac (diff) |
NEWT/Window: Cleanup Actions: Reparenting, Fullscreen and Decoration
- don't assume size/pos change - hence don't set window's values, but wait for satisfaction
- don't send resize events on our own, just rely on the event mechanism
- fullscreen: don't wrap action around invisibility from Java, Win7 flashes otherwise.
Clients who benefit from it (X11) impl. it natively.
- fullscreen exit: validate pos/size in case of a child window, like reparenting.
Otherwise the container might gets confused (eg. AWT).
Diffstat (limited to 'src/newt/native')
-rw-r--r-- | src/newt/native/WindowsWindow.c | 12 | ||||
-rw-r--r-- | src/newt/native/X11Window.c | 67 |
2 files changed, 58 insertions, 21 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 9e635ef40..900b5a037 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -1452,19 +1452,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigure windowStyle |= WS_VISIBLE ; } - if( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - NewtWindows_setFullScreen(JNI_FALSE); - } - // order of call sequence: (MS documentation) // TOP: SetParent(.., NULL); Clear WS_CHILD [, Set WS_POPUP] // CHILD: Set WS_CHILD [, Clear WS_POPUP]; SetParent(.., PARENT) // if( TST_FLAG_CHANGE_PARENTING(flags) && NULL == hwndP ) { + // TOP: in -> out SetParent(hwnd, NULL); } if( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) { // FS on + // TOP: in -> out NewtWindows_setFullScreen(JNI_TRUE); } @@ -1480,7 +1478,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigure SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); } + if( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off + // CHILD: out -> in + NewtWindows_setFullScreen(JNI_FALSE); + } + if ( TST_FLAG_CHANGE_PARENTING(flags) && NULL != hwndP ) { + // CHILD: out -> in SetParent(hwnd, hwndP ); } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index b6c239479..8d47f544a 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -1567,6 +1567,14 @@ static void NewtWindows_setPosSize(Display *dpy, int screen_index, Window w, jin } } +static Bool WaitForMapNotify( Display *dpy, XEvent *event, XPointer arg ) { + return (event->type == MapNotify) && (event->xmap.window == (Window) arg); +} + +static Bool WaitForUnmapNotify( Display *dpy, XEvent *event, XPointer arg ) { + return (event->type == UnmapNotify) && (event->xmap.window == (Window) arg); +} + /* * Class: jogamp_newt_driver_x11_X11Window * Method: reconfigureWindow0 @@ -1583,56 +1591,81 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 Window parent = (0!=jparent)?(Window)jparent:root; Window topParentParent; Window topParentWindow; + XEvent event; + Bool tempInvisible = ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ) && + !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; displayDispatchErrorHandlerEnable(1, env); topParentParent = NewtWindows_getParent (dpy, parent); topParentWindow = NewtWindows_getParent (dpy, w); - DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d/%p, parent %p/%p (top %p), win %p (top %p), %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, visibleChange %d, visible %d\n", + DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d/%p, parent %p/%p (top %p), win %p (top %p), %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, visibleChange %d, visible %d, tempInvisible %d\n", (void*)dpy, screen_index, (void*)scrn, (void*) jparent, (void*)parent, (void*) topParentParent, (void*)w, (void*)topParentWindow, x, y, width, height, TST_FLAG_CHANGE_PARENTING(flags), TST_FLAG_HAS_PARENT(flags), TST_FLAG_CHANGE_DECORATION(flags), TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags), - TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags)); + TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags), tempInvisible); - if( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - NewtWindows_setFullscreen(dpy, root, w, False ); + if( tempInvisible ) { + DBG_PRINT( "X11: reconfigureWindow0 TEMP VISIBLE OFF\n"); + XUnmapWindow(dpy, w); + XIfEvent( dpy, &event, WaitForUnmapNotify, (XPointer) w ); + } + + if( TST_FLAG_CHANGE_PARENTING(flags) && !TST_FLAG_HAS_PARENT(flags) ) { + // TOP: in -> out + DBG_PRINT( "X11: reconfigureWindow0 PARENTING in->out\n"); + XReparentWindow( dpy, w, parent, x, y ); // actual reparent call XSync(dpy, False); } - if( TST_FLAG_CHANGE_DECORATION(flags) && TST_FLAG_IS_UNDECORATED(flags) ) { - NewtWindows_setDecorations (dpy, w, False); + if( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) { // FS on + // TOP: in -> out + DBG_PRINT( "X11: reconfigureWindow0 FULLSCREEN in->out\n"); + NewtWindows_setFullscreen(dpy, root, w, True ); XSync(dpy, False); } - if( TST_FLAG_CHANGE_PARENTING(flags) ) { - XReparentWindow( dpy, w, parent, x, y ); // actual reparent call + DBG_PRINT( "X11: reconfigureWindow0 DECORATIONS\n"); + NewtWindows_setDecorations (dpy, w, TST_FLAG_IS_UNDECORATED(flags) ? False : True); + XSync(dpy, False); + + if( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off + // CHILD: out -> in + DBG_PRINT( "X11: reconfigureWindow0 FULLSCREEN out->in\n"); + NewtWindows_setFullscreen(dpy, root, w, False ); XSync(dpy, False); } + + DBG_PRINT( "X11: reconfigureWindow0 setPosSize\n"); + NewtWindows_setPosSize(dpy, screen_index, w, x, y, width, height, TST_FLAG_IS_UNDECORATED(flags) ? True : False); - if( TST_FLAG_CHANGE_DECORATION(flags) && !TST_FLAG_IS_UNDECORATED(flags) ) { - NewtWindows_setDecorations (dpy, w, True); + if( TST_FLAG_CHANGE_PARENTING(flags) && TST_FLAG_HAS_PARENT(flags) ) { + // CHILD: out -> in + DBG_PRINT( "X11: reconfigureWindow0 PARENTING out->in\n"); + XReparentWindow( dpy, w, parent, x, y ); // actual reparent call XSync(dpy, False); } + if( tempInvisible ) { + DBG_PRINT( "X11: reconfigureWindow0 TEMP VISIBLE ON\n"); + XMapRaised(dpy, w); + XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) w ); + } + if( TST_FLAG_CHANGE_VISIBILITY(flags) ) { if( TST_FLAG_IS_VISIBLE(flags) ) { + DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n"); XMapRaised(dpy, w); } else { + DBG_PRINT( "X11: reconfigureWindow0 VISIBLE OFF\n"); XUnmapWindow(dpy, w); } XSync(dpy, False); } - NewtWindows_setPosSize(dpy, screen_index, w, x, y, width, height, TST_FLAG_IS_UNDECORATED(flags) ? True : False); - - if( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) { // FS on - NewtWindows_setFullscreen(dpy, root, w, True ); - XSync(dpy, False); - } - displayDispatchErrorHandlerEnable(0, env); DBG_PRINT( "X11: reconfigureWindow0 X\n"); |