diff --git a/include/context_win.h b/include/context_win.h index 421adf954..6a16af8a2 100644 --- a/include/context_win.h +++ b/include/context_win.h @@ -35,6 +35,8 @@ extern HWND win_mainwindow; extern HDC win_maindc; +extern HCURSOR win_arrow; +extern bool win_cursor_visible; extern int win_palettized; extern int win_canalttab; extern DEVMODE win_gdevmode; @@ -69,8 +71,6 @@ struct vulkan_ctx_s *Win_Vulkan_Context (struct vid_internal_s *); void Win_Vulkan_Init_Cvars (void); void IN_UpdateClipCursor (void); -void IN_ShowMouse (void); -void IN_HideMouse (void); void IN_ActivateMouse (void); void IN_DeactivateMouse (void); diff --git a/libs/video/targets/context_win.c b/libs/video/targets/context_win.c index 71a8dde42..04588da95 100644 --- a/libs/video/targets/context_win.c +++ b/libs/video/targets/context_win.c @@ -47,6 +47,8 @@ HWND win_mainwindow; HDC win_maindc; +HCURSOR win_arrow; +bool win_cursor_visible; int win_palettized; int win_minimized; int win_canalttab = 0; @@ -382,22 +384,19 @@ VID_CheckAdequateMem (int width, int height) static void VID_InitModes (HINSTANCE hInstance) { - WNDCLASS wc; + WNDCLASS wc = { + .style = CS_OWNDC, + .lpfnWndProc = (WNDPROC) Win_EventHandler, + .hInstance = hInstance, + .lpszClassName = WINDOW_CLASS, + }; HDC hdc; + win_arrow = LoadCursor (NULL, IDC_ARROW); + //FIXME hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON2)); /* Register the frame class */ - wc.style = CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) Win_EventHandler; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = 0; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = 0; - wc.lpszClassName = WINDOW_CLASS; if (!RegisterClass (&wc)) Sys_Error ("Couldn't register window class"); @@ -777,16 +776,13 @@ VID_SetMode (int modenum, const byte *palette) if (_windowed_mouse) { stat = VID_SetWindowedMode (modenum); IN_ActivateMouse (); - IN_HideMouse (); } else { IN_DeactivateMouse (); - IN_ShowMouse (); stat = VID_SetWindowedMode (modenum); } } else { stat = VID_SetFullDIBMode (modenum); IN_ActivateMouse (); - IN_HideMouse (); } Win_UpdateWindowStatus (); @@ -957,30 +953,6 @@ Win_CreateWindow (int width, int height) } - -//========================================================================== - - -/* -================ -VID_HandlePause -================ -*/ -static void __attribute__ ((used)) -VID_HandlePause (bool pause) -{ - if ((modestate == MS_WINDOWED) && _windowed_mouse) { - if (pause) { - IN_DeactivateMouse (); - IN_ShowMouse (); - } else { - IN_ActivateMouse (); - IN_HideMouse (); - } - } -} - - /* =================================================================== diff --git a/libs/video/targets/in_win.c b/libs/video/targets/in_win.c index d452c104b..064010fa4 100644 --- a/libs/video/targets/in_win.c +++ b/libs/video/targets/in_win.c @@ -67,7 +67,6 @@ static bool mouseinitialized; static bool restore_spi; static int originalmouseparms[3], newmouseparms[3] = { 0, 0, 1 }; static bool mouseparmsvalid, mouseactivatetoggle; -static bool mouseshowtoggle = 1; static bool dinput_acquired; static bool in_win_initialized; static unsigned int mstate_di; @@ -274,24 +273,6 @@ IN_UpdateClipCursor (void) } } -void -IN_ShowMouse (void) -{ - if (!mouseshowtoggle) { - ShowCursor (TRUE); - mouseshowtoggle = 1; - } -} - -void -IN_HideMouse (void) -{ - if (mouseshowtoggle) { - ShowCursor (FALSE); - mouseshowtoggle = 0; - } -} - void IN_ActivateMouse (void) { @@ -496,20 +477,6 @@ in_paste_buffer_f (void) CloseClipboard (); } } -#if 0 -static void -win_keydest_callback (keydest_t key_dest, void *data) -{ - win_in_game = key_dest == key_game; - if (win_in_game) { - IN_ActivateMouse (); - IN_HideMouse (); - } else { - IN_DeactivateMouse (); - IN_ShowMouse (); - } -} -#endif static void win_add_device (win_device_t *dev) @@ -610,7 +577,6 @@ in_win_shutdown (void *data) { IN_DeactivateMouse (); - IN_ShowMouse (); if (g_pMouse) { IDirectInputDevice_Release (g_pMouse); @@ -894,13 +860,11 @@ Win_Activate (BOOL active, BOOL minimize) if (active) { if (modestate == MS_FULLDIB) { IN_ActivateMouse (); - IN_HideMouse (); if (win_canalttab && vid_wassuspended) { vid_wassuspended = false; if (ChangeDisplaySettings (&win_gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { - IN_ShowMouse (); Sys_Error ("Couldn't set fullscreen DIB mode\n" "(try upgrading your video drivers)\n (%lx)", GetLastError()); @@ -915,19 +879,16 @@ Win_Activate (BOOL active, BOOL minimize) else if ((modestate == MS_WINDOWED) && in_grab && win_in_game) { IN_ActivateMouse (); - IN_HideMouse (); } } else { if (modestate == MS_FULLDIB) { IN_DeactivateMouse (); - IN_ShowMouse (); if (win_canalttab) { ChangeDisplaySettings (NULL, 0); vid_wassuspended = true; } } else if ((modestate == MS_WINDOWED) && in_grab) { IN_DeactivateMouse (); - IN_ShowMouse (); } } } @@ -1050,6 +1011,10 @@ event_mouse (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) win_mouse.x = x; win_mouse.y = y; + + if (!win_cursor_visible) { + SetCursor (0); + } } win_mouse_axes[0].value = x - win_mouse.x; diff --git a/libs/video/targets/vid_win.c b/libs/video/targets/vid_win.c index 430e58433..96438edc4 100644 --- a/libs/video/targets/vid_win.c +++ b/libs/video/targets/vid_win.c @@ -59,6 +59,14 @@ Win_VID_SetPalette (byte *palette, byte *colormap) viddef.vid_internal->set_palette (win_sw_context, palette); } +static void +Win_VID_SetCursor (bool visible) +{ + Sys_Printf ("Win_VID_SetCursor: %d\n", visible); + win_cursor_visible = visible; + SetCursor (visible ? win_arrow : 0); +} + static void Win_VID_Init (byte *palette, byte *colormap) { @@ -104,6 +112,7 @@ vid_system_t vid_system = { .init = Win_VID_Init, .set_palette = Win_VID_SetPalette, .init_cvars = Win_VID_Init_Cvars, + .set_cursor = Win_VID_SetCursor, }; void