diff options
author | Michael Lutz <michi@icosahedron.de> | 2015-12-27 16:13:19 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2018-04-10 21:07:27 +0200 |
commit | 4bfd2770179989d5ade3d018004dc15fa5b102bf (patch) | |
tree | 7127e4f91509faa54caf000cf29bf1ef272126a0 /src | |
parent | afa3e15afed641e986eded7b26862f610188caf1 (diff) | |
download | openttd-4bfd2770179989d5ade3d018004dc15fa5b102bf.tar.xz |
Codechange: [Win32] Use OS function for mouse tracking if present.
Diffstat (limited to 'src')
-rw-r--r-- | src/video/win32_v.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 23794cb32..4534b87be 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -38,6 +38,9 @@ #define PM_QS_INPUT 0x20000 #endif +typedef BOOL (WINAPI *PFNTRACKMOUSEEVENT)(LPTRACKMOUSEEVENT lpEventTrack); +static PFNTRACKMOUSEEVENT _pTrackMouseEvent = NULL; + static struct { HWND main_wnd; HBITMAP dib_sect; @@ -747,7 +750,16 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP * tracking the mouse for exiting the window */ if (!_cursor.in_window) { _cursor.in_window = true; - SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); + if (_pTrackMouseEvent != NULL) { + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + + _pTrackMouseEvent(&tme); + } else { + SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); + } } if (_cursor.fix_at) { @@ -1038,6 +1050,9 @@ static void RegisterWndClass() registered = true; if (!RegisterClass(&wnd)) usererror("RegisterClass failed"); + + /* Dynamically load mouse tracking, as it doesn't exist on Windows 95. */ + _pTrackMouseEvent = (PFNTRACKMOUSEEVENT)GetProcAddress(GetModuleHandle(_T("User32")), "TrackMouseEvent"); } } |