]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_wgl.c
more fullscreen cleanup
[xonotic/darkplaces.git] / vid_wgl.c
index 7b39e2289da548a44ebbf93e3f66c001f985c31d..752241d1fe47ef19935e1198e07f1d3a6b8a99de 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -95,6 +95,7 @@ static DEVMODE gdevmode, initialdevmode;
 static qboolean vid_initialized = false;
 static qboolean vid_wassuspended = false;
 static qboolean vid_usingmouse = false;
+static qboolean vid_usinghidecursor = false;
 static qboolean vid_usingvsync = false;
 static qboolean vid_usevsync = false;
 static HICON hIcon;
@@ -427,7 +428,7 @@ void AppActivate(BOOL fActive, BOOL minimize)
 
        if (!fActive)
        {
-               VID_GrabMouse(false);
+               VID_SetMouse(false, false, false);
                if (vid_isfullscreen)
                {
                        ChangeDisplaySettings (NULL, 0);
@@ -501,7 +502,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);
-                       VID_GrabMouse(false);
+                       VID_SetMouse(false, false, false);
                        break;
 
                case WM_KEYDOWN:
@@ -578,9 +579,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM lParam)
                                temp |= 512;
 
 #ifdef SUPPORTDIRECTX
-                       if (vid_usingmouse && !dinput_acquired)
-#else
-                       if (vid_usingmouse)
+                       if (!dinput_acquired)
 #endif
                        {
                                // perform button actions
@@ -782,7 +781,7 @@ void VID_Init(void)
        IN_Init();
 }
 
-int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples)
+int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples)
 {
        int i;
        HDC hdc;
@@ -923,8 +922,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
                        foundmode = true;
                        gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
                        gdevmode.dmBitsPerPel = bpp;
-                       gdevmode.dmPelsWidth = width;
-                       gdevmode.dmPelsHeight = height;
+                       gdevmode.dmPelsWidth = *width;
+                       gdevmode.dmPelsHeight = *height;
                        gdevmode.dmSize = sizeof (gdevmode);
                        if(refreshrate)
                        {
@@ -1015,13 +1014,13 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
                if (!foundmode)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", width, height, bpp);
+                       Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", *width, *height, bpp);
                        return false;
                }
                else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
                {
                        VID_Shutdown();
-                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp);
+                       Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", *width, *height, bpp);
                        return false;
                }
 
@@ -1054,8 +1053,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
 
        rect.top = 0;
        rect.left = 0;
-       rect.right = width;
-       rect.bottom = height;
+       rect.right = *width;
+       rect.bottom = *height;
        AdjustWindowRectEx(&rect, WindowStyle, false, 0);
 
        if (fullscreen)
@@ -1220,6 +1219,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat
        //vid_menudrawfn = VID_MenuDraw;
        //vid_menukeyfn = VID_MenuKey;
        vid_usingmouse = false;
+       vid_usinghidecursor = false;
        vid_usingvsync = false;
        vid_hidden = false;
        vid_initialized = true;
@@ -1243,7 +1243,7 @@ void VID_Shutdown (void)
        if(vid_initialized == false)
                return;
 
-       VID_GrabMouse(false);
+       VID_SetMouse(false, false, false);
        VID_RestoreSystemGamma();
 
        vid_initialized = false;
@@ -1265,7 +1265,7 @@ void VID_Shutdown (void)
        vid_isfullscreen = false;
 }
 
-void VID_GrabMouse(qboolean grab)
+void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
 {
        static qboolean restore_spi;
        static int originalmouseparms[3];
@@ -1273,7 +1273,7 @@ void VID_GrabMouse(qboolean grab)
        if (!mouseinitialized)
                return;
 
-       if (grab)
+       if (relative)
        {
                if (!vid_usingmouse)
                {
@@ -1311,7 +1311,6 @@ void VID_GrabMouse(qboolean grab)
                                SetCapture (mainwindow);
                                ClipCursor (&window_rect);
                        }
-                       ShowCursor (false);
                }
        }
        else
@@ -1336,9 +1335,14 @@ void VID_GrabMouse(qboolean grab)
                                ClipCursor (NULL);
                                ReleaseCapture ();
                        }
-                       ShowCursor (true);
                }
        }
+
+       if (vid_usinghidecursor != hidecursor)
+       {
+               vid_usinghidecursor = hidecursor;
+               ShowCursor (!hidecursor);
+       }
 }
 
 
@@ -1475,7 +1479,7 @@ static void IN_MouseMove (void)
        in_windowmouse_x = current_pos.x - window_x;
        in_windowmouse_y = current_pos.y - window_y;
 
-       if (!vid.mouseaim)
+       if (!vid_usingmouse)
                return;
 
 #ifdef SUPPORTDIRECTX