From: havoc Date: Thu, 8 May 2008 00:05:43 +0000 (+0000) Subject: renamed IN_Activate to VID_GrabMouse and made it a public function in X-Git-Tag: xonotic-v0.1.0preview~2248 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=64a00997d5d76bae2e6aae5e2de6ac17ea3504a9;ds=sidebyside renamed IN_Activate to VID_GrabMouse and made it a public function in 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 --- diff --git a/cl_screen.c b/cl_screen.c index 6a127f5d..a46093d2 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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 f80ac780..e76fbae6 100644 --- 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); diff --git a/vid_agl.c b/vid_agl.c index 5de1a3ea..67173880 100644 --- 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) diff --git a/vid_glx.c b/vid_glx.c index 199d8eac..3969fe16 100644 --- 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 diff --git a/vid_null.c b/vid_null.c index a7c18f97..9d01e8a8 100644 --- a/vid_null.c +++ b/vid_null.c @@ -51,7 +51,11 @@ void InitSig(void) #endif } -void VID_Finish (qboolean allowmousegrab) +void VID_GrabMouse (qboolean grab) +{ +} + +void VID_Finish (void) { } diff --git a/vid_sdl.c b/vid_sdl.c index 01381a3a..3a636cc1 100644 --- 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) diff --git a/vid_wgl.c b/vid_wgl.c index df392e98..e664cf05 100644 --- 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);