X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_window.c;h=4f5c9bcc05fbcb3341638fb63ef1bd2ea24a458f;hb=1fd9514b5c5df8a4bf974787f26f6cc3dd84c1cc;hp=4663aba779066303f5a0551384227a98f5c2912b;hpb=da9e3ac06e920a889440155e59ae85843ef3ee78;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 4663aba..4f5c9bc 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -31,6 +31,7 @@ #if TARGET_HOST_POSIX_X11 #include /* LONG_MAX */ +#include /* usleep */ #endif #if defined(_WIN32_WCE) @@ -905,6 +906,14 @@ static void get_display_origin(int *xp,int *yp) #endif +#if TARGET_HOST_POSIX_X11 +static Bool fghWindowIsVisible( Display *display, XEvent *event, XPointer arg) +{ + Window window = arg; + return (event->type == MapNotify) && (event->xmap.window == window); +} +#endif + /* * Opens a window. Requires a SFG_Window object created and attached @@ -921,6 +930,7 @@ void fgOpenWindow( SFG_Window* window, const char* title, XTextProperty textProperty; XSizeHints sizeHints; XWMHints wmHints; + XEvent eventReturnBuffer; /* return buffer required for a call */ unsigned long mask; int num_FBConfigs, i; unsigned int current_DisplayMode = fgState.DisplayMode ; @@ -1110,10 +1120,18 @@ void fgOpenWindow( SFG_Window* window, const char* title, window->Window.Context ); + /* register extension events _before_ window is mapped */ + #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + fgRegisterDevices( fgDisplay.Display, &(window->Window.Handle) ); + #endif + XMapWindow( fgDisplay.Display, window->Window.Handle ); XFree(visualInfo); + if( !isSubWindow) + XPeekIfEvent( fgDisplay.Display, &eventReturnBuffer, &fghWindowIsVisible, window->Window.Handle ); + #elif TARGET_HOST_MS_WINDOWS WNDCLASS wc; @@ -1273,6 +1291,10 @@ void fgOpenWindow( SFG_Window* window, const char* title, /* SetWindowPos(window->Window.Handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); */ + /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */ + #ifdef WM_TOUCH + RegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM ); + #endif #if defined(_WIN32_WCE) ShowWindow( window->Window.Handle, SW_SHOW ); @@ -1303,6 +1325,12 @@ void fgOpenWindow( SFG_Window* window, const char* title, */ void fgCloseWindow( SFG_Window* window ) { + /* if we're in gamemode, call glutLeaveGameMode first to make sure the + * gamemode is properly closed before closing the window + */ + if (fgStructure.GameModeWindow != NULL) + glutLeaveGameMode(); + #if TARGET_HOST_POSIX_X11 if( window->Window.Context )