mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Hide the cursor by overriding WM_SETCURSOR, as seen in the IDirect3DDEvice9::ShowCursor()
example. Do not modify the window class pointer. I still had an instance where I was left with an invisible pointer no matter where I moved it, so hopefully this takes care of that. (edit: it doesn't.) SVN r2496 (trunk)
This commit is contained in:
parent
d32d8b4f9f
commit
6000217889
3 changed files with 20 additions and 8 deletions
|
@ -147,6 +147,7 @@ EXTERN_CVAR (Bool, lookstrafe)
|
||||||
EXTERN_CVAR (Bool, use_joystick)
|
EXTERN_CVAR (Bool, use_joystick)
|
||||||
|
|
||||||
static int WheelDelta;
|
static int WheelDelta;
|
||||||
|
extern bool CursorState;
|
||||||
|
|
||||||
extern BOOL paused;
|
extern BOOL paused;
|
||||||
static bool noidle = false;
|
static bool noidle = false;
|
||||||
|
@ -418,6 +419,14 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
I_CheckNativeMouse (false);
|
I_CheckNativeMouse (false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_SETCURSOR:
|
||||||
|
if (!CursorState)
|
||||||
|
{
|
||||||
|
SetCursor(NULL); // turn off window cursor
|
||||||
|
return TRUE; // Prevent Windows from setting cursor to window class cursor
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
InvalidateRect (Window, NULL, FALSE);
|
InvalidateRect (Window, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -118,7 +118,6 @@ extern BYTE *ST_Util_BitsForBitmap (BITMAPINFO *bitmap_info);
|
||||||
extern EXCEPTION_POINTERS CrashPointers;
|
extern EXCEPTION_POINTERS CrashPointers;
|
||||||
extern BITMAPINFO *StartupBitmap;
|
extern BITMAPINFO *StartupBitmap;
|
||||||
extern UINT TimerPeriod;
|
extern UINT TimerPeriod;
|
||||||
extern HCURSOR TheArrowCursor;
|
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
|
||||||
|
@ -931,8 +930,6 @@ void DoMain (HINSTANCE hInstance)
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TheArrowCursor = LoadCursor (NULL, IDC_ARROW);
|
|
||||||
|
|
||||||
WNDCLASS WndClass;
|
WNDCLASS WndClass;
|
||||||
WndClass.style = 0;
|
WndClass.style = 0;
|
||||||
WndClass.lpfnWndProc = LConProc;
|
WndClass.lpfnWndProc = LConProc;
|
||||||
|
@ -940,7 +937,7 @@ void DoMain (HINSTANCE hInstance)
|
||||||
WndClass.cbWndExtra = 0;
|
WndClass.cbWndExtra = 0;
|
||||||
WndClass.hInstance = hInstance;
|
WndClass.hInstance = hInstance;
|
||||||
WndClass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
WndClass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||||
WndClass.hCursor = TheArrowCursor;
|
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||||
WndClass.hbrBackground = NULL;
|
WndClass.hbrBackground = NULL;
|
||||||
WndClass.lpszMenuName = NULL;
|
WndClass.lpszMenuName = NULL;
|
||||||
WndClass.lpszClassName = (LPCTSTR)WinClassName;
|
WndClass.lpszClassName = (LPCTSTR)WinClassName;
|
||||||
|
|
|
@ -134,7 +134,7 @@ static FMouse *(*MouseFactory[])() =
|
||||||
|
|
||||||
FMouse *Mouse;
|
FMouse *Mouse;
|
||||||
|
|
||||||
HCURSOR TheArrowCursor;
|
bool CursorState;
|
||||||
|
|
||||||
CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR (Bool, m_noprescale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR (Bool, m_noprescale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
|
@ -181,11 +181,17 @@ CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
|
|
||||||
static void SetCursorState(bool visible)
|
static void SetCursorState(bool visible)
|
||||||
{
|
{
|
||||||
HCURSOR usingCursor = visible ? TheArrowCursor : NULL;
|
CursorState = visible;
|
||||||
SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)usingCursor);
|
|
||||||
if (GetForegroundWindow() == Window)
|
if (GetForegroundWindow() == Window)
|
||||||
{
|
{
|
||||||
SetCursor(usingCursor);
|
if (visible)
|
||||||
|
{
|
||||||
|
SetCursor((HCURSOR)(intptr_t)GetClassLongPtr(Window, GCLP_HCURSOR));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetCursor(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue