]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
renamed IN_Activate to VID_GrabMouse and made it a public function in
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 May 2008 00:05:43 +0000 (00:05 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 May 2008 00:05:43 +0000 (00:05 +0000)
the VID API, this removed some shared logic from each VID_Finish
implementation, and allows disabling the mouse grab at the beginning of
a loading screen

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8284 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
vid.h
vid_agl.c
vid_glx.c
vid_null.c
vid_sdl.c
vid_wgl.c

index 6a127f5d77a230a623bff5c0adc824b649365e2c..a46093d2f14e455183369002fcf4f4bfcb60d547 100644 (file)
@@ -2037,6 +2037,8 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        // don't do anything if not initialized yet
        if (vid_hidden || !scr_refresh.integer)
                return;
+       // release mouse grab while loading
+       VID_GrabMouse(false);
        CHECKGLERROR
        qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
        //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
@@ -2093,7 +2095,7 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        R_Mesh_Finish();
        // refresh
        // not necessary when rendering to GL_FRONT buffers
-       //VID_Finish(false);
+       //VID_Finish();
        // however this IS necessary on Windows Vista
        qglFinish();
 }
@@ -2111,6 +2113,11 @@ void CL_UpdateScreen(void)
        double rendertime1;
        float conwidth, conheight;
 
+       if (!scr_initialized || !con_initialized)
+               return;                         // not initialized yet
+
+       VID_GrabMouse((vid.fullscreen || (vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))) && vid_activewindow && !cl.csqc_wantsmousemove);
+
        if(gamemode == GAME_NEXUIZ)
        {
                // play a bit with the palette (experimental)
@@ -2127,9 +2134,6 @@ void CL_UpdateScreen(void)
        if (vid_hidden || !scr_refresh.integer)
                return;
 
-       if (!scr_initialized || !con_initialized)
-               return;                         // not initialized yet
-
        rendertime1 = Sys_DoubleTime();
 
        conwidth = bound(320, vid_conwidth.value, 2048);
@@ -2269,7 +2273,9 @@ void CL_UpdateScreen(void)
        else
                cl_updatescreen_quality = 1;
 
-       VID_Finish(true);
+       VID_GrabMouse((vid.fullscreen || (vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))) && vid_activewindow && !cl.csqc_wantsmousemove);
+
+       VID_Finish();
 }
 
 void CL_Screen_NewMap(void)
diff --git a/vid.h b/vid.h
index f80ac7801848d6f44ff19ec670d1775771841ea8..e76fbae62fe736835a88140d78cef6df141c7606 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -146,7 +146,8 @@ void VID_UpdateGamma(qboolean force, int rampsize);
 // (called from various shutdown/deactivation functions)
 void VID_RestoreSystemGamma(void);
 
-void VID_Finish (qboolean allowmousegrab);
+void VID_GrabMouse (qboolean grab);
+void VID_Finish (void);
 
 void VID_Restart_f(void);
 
index 5de1a3ea0e8cf5b01bcf7da7826e8afbe5e6a5d8..671738800d584baf8009564c1bb5dc4f7798e1f1 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -106,12 +106,12 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height)
        *height = scr_height;
 }
 
-static void IN_Activate( qboolean grab )
+void VID_GrabMouse(qboolean grab)
 {
        if (grab)
        {
                if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
-                       IN_Activate(false); // ungrab first!
+                       VID_GrabMouse(false); // ungrab first!
                if (!vid_usingmouse && mouse_avail && window)
                {
                        Rect winBounds;
@@ -191,21 +191,10 @@ static void IN_Activate( qboolean grab )
 }
 
 #define GAMMA_TABLE_SIZE 256
-void VID_Finish (qboolean allowmousegrab)
+void VID_Finish (void)
 {
-       qboolean vid_usemouse;
        qboolean vid_usevsync;
 
-       // handle the mouse state when windowed if that's changed
-       vid_usemouse = false;
-       if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))
-               vid_usemouse = true;
-       if (!vid_activewindow)
-               vid_usemouse = false;
-       if (vid_isfullscreen)
-               vid_usemouse = true;
-       IN_Activate(vid_usemouse);
-
        // handle changes of the vsync option
        vid_usevsync = (vid_vsync.integer && !cls.timedemo);
        if (vid_usingvsync != vid_usevsync)
@@ -410,7 +399,7 @@ void VID_Shutdown(void)
        if (context == NULL && window == NULL)
                return;
 
-       IN_Activate(false);
+       VID_GrabMouse(false);
        VID_RestoreSystemGamma();
 
        if (context != NULL)
index 199d8eaca80f4d3f8fdbe597eb61e3e15d307818..3969fe16b196c08c8bf2216bd3d7d248a9d72904 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -249,7 +249,7 @@ static Cursor CreateNullCursor(Display *display, Window root)
        return cursor;
 }
 
-static void IN_Activate (qboolean grab)
+void VID_GrabMouse(qboolean grab)
 {
        if (!vidx11_display)
                return;
@@ -257,7 +257,7 @@ static void IN_Activate (qboolean grab)
        {
 #if !defined(__APPLE__) && !defined(SUNOS)
                if(vid_usingmouse && (vid_usingdgamouse != !!vid_dgamouse.integer))
-                       IN_Activate(false); // ungrab first!
+                       VID_GrabMouse(false); // ungrab first!
 #endif
                if (!vid_usingmouse && mouse_avail && win)
                {
@@ -515,18 +515,16 @@ void VID_Shutdown(void)
        if (!ctx || !vidx11_display)
                return;
 
-       if (vidx11_display)
-       {
-               IN_Activate(false);
-               VID_RestoreSystemGamma();
-
-               // FIXME: glXDestroyContext here?
-               if (vid_isfullscreen)
-                       XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, &init_vidmode);
-               if (win)
-                       XDestroyWindow(vidx11_display, win);
-               XCloseDisplay(vidx11_display);
-       }
+       VID_GrabMouse(false);
+       VID_RestoreSystemGamma();
+
+       // FIXME: glXDestroyContext here?
+       if (vid_isfullscreen)
+               XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, &init_vidmode);
+       if (win)
+               XDestroyWindow(vidx11_display, win);
+       XCloseDisplay(vidx11_display);
+
        vid_hidden = true;
        vid_isfullscreen = false;
        vidx11_display = NULL;
@@ -558,10 +556,8 @@ void InitSig(void)
        signal(SIGTERM, signal_handler);
 }
 
-void VID_Finish (qboolean allowmousegrab)
+void VID_Finish (void)
 {
-       qboolean vid_usemouse;
-
        vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
        if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
        {
@@ -570,16 +566,6 @@ void VID_Finish (qboolean allowmousegrab)
                        Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
        }
 
-       // handle the mouse state when windowed if that's changed
-       vid_usemouse = false;
-       if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))
-               vid_usemouse = true;
-       if (!vid_activewindow)
-               vid_usemouse = false;
-       if (vid_isfullscreen)
-               vid_usemouse = true;
-       IN_Activate(vid_usemouse);
-
        if (r_render.integer)
        {
                CHECKGLERROR
index a7c18f977d95c363131a536a02028aad276ce33d..9d01e8a884e82d3fe9d5e5b1fa14a7d1ed7358ec 100644 (file)
@@ -51,7 +51,11 @@ void InitSig(void)
 #endif
 }
 
-void VID_Finish (qboolean allowmousegrab)
+void VID_GrabMouse (qboolean grab)
+{
+}
+
+void VID_Finish (void)
 {
 }
 
index 01381a3a3a957cab2eb3f4b2bafdc449fbe775cb..3a636cc17ab7c9555052b85705752672854f643c 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -232,7 +232,7 @@ static int MapKey( unsigned int sdlkey )
     return tbl_sdltoquake[ sdlkey ];
 }
 
-static void IN_Activate( qboolean grab )
+void VID_GrabMouse(qboolean grab)
 {
        //SDL_WM_GrabInput( SDL_GRAB_OFF );
        //Con_Printf("< Turning off input-grabbing. --blub\n");
@@ -765,10 +765,9 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
 
 void VID_Shutdown (void)
 {
-       // this is needed to retry gamma after a vid_restart
+       VID_GrabMouse(false);
        VID_RestoreSystemGamma();
 
-       IN_Activate(false);
        SDL_QuitSubSystem(SDL_INIT_VIDEO);
 
        gl_driver[0] = 0;
@@ -787,10 +786,9 @@ int VID_GetGamma (unsigned short *ramps, int rampsize)
        return !SDL_GetGammaRamp (ramps, ramps + rampsize, ramps + rampsize*2);
 }
 
-void VID_Finish (qboolean allowmousegrab)
+void VID_Finish (void)
 {
        Uint8 appstate;
-       qboolean vid_usemouse;
 
        //react on appstate changes
        appstate = SDL_GetAppState();
@@ -802,16 +800,6 @@ void VID_Finish (qboolean allowmousegrab)
        else
                vid_activewindow = true;
 
-       vid_usemouse = false;
-       if( allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback) )
-               vid_usemouse = true;
-       if( vid_isfullscreen )
-               vid_usemouse = true;
-       if( !vid_activewindow )
-               vid_usemouse = false;
-
-       IN_Activate(vid_usemouse);
-
        VID_UpdateGamma(false, 256);
 
        if (r_render.integer && !vid_hidden)
index df392e98d6b9781964e2636787799ade33931de9..e664cf056e0f9d32c97c00da110ce050b0af904c 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -121,8 +121,6 @@ static qboolean vid_isfullscreen;
 
 static int window_x, window_y;
 
-static void IN_Activate (qboolean grab);
-
 static qboolean mouseinitialized;
 
 #ifdef SUPPORTDIRECTX
@@ -243,7 +241,7 @@ static void IN_StartupMouse (void);
 
 //====================================
 
-void VID_Finish (qboolean allowmousegrab)
+void VID_Finish (void)
 {
        qboolean vid_usemouse;
 
@@ -254,16 +252,6 @@ void VID_Finish (qboolean allowmousegrab)
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
-// handle the mouse state when windowed if that's changed
-       vid_usemouse = false;
-       if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))
-               vid_usemouse = true;
-       if (vid_isfullscreen)
-               vid_usemouse = true;
-       if (!vid_activewindow)
-               vid_usemouse = false;
-       IN_Activate(vid_usemouse);
-
        if (r_render.integer && !vid_hidden)
        {
                CHECKGLERROR
@@ -441,7 +429,7 @@ void AppActivate(BOOL fActive, BOOL minimize)
 
        if (!fActive)
        {
-               IN_Activate (false);
+               VID_GrabMouse(false);
                if (vid_isfullscreen)
                {
                        ChangeDisplaySettings (NULL, 0);
@@ -515,7 +503,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
                case WM_MOVE:
                        window_x = (int) LOWORD(lParam);
                        window_y = (int) HIWORD(lParam);
-                       IN_Activate(false);
+                       VID_GrabMouse(false);
                        break;
 
                case WM_KEYDOWN:
@@ -1257,6 +1245,7 @@ void VID_Shutdown (void)
        if(vid_initialized == false)
                return;
 
+       VID_GrabMouse(false);
        VID_RestoreSystemGamma();
 
        vid_initialized = false;
@@ -1278,7 +1267,7 @@ void VID_Shutdown (void)
        vid_isfullscreen = false;
 }
 
-static void IN_Activate (qboolean grab)
+void VID_GrabMouse(qboolean grab)
 {
        static qboolean restore_spi;
        static int originalmouseparms[3];
@@ -2078,8 +2067,6 @@ static void IN_Init(void)
 
 static void IN_Shutdown(void)
 {
-       IN_Activate (false);
-
 #ifdef SUPPORTDIRECTX
        if (g_pMouse)
                IDirectInputDevice_Release(g_pMouse);