mirror of https://github.com/OpenTTD/OpenTTD
Codechange: [Win32] Remove Windows 95 specific mouse tracking work-around.
parent
40d5fe1631
commit
7415964a4d
|
@ -39,9 +39,6 @@
|
||||||
#define PM_QS_INPUT 0x20000
|
#define PM_QS_INPUT 0x20000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef BOOL (WINAPI *PFNTRACKMOUSEEVENT)(LPTRACKMOUSEEVENT lpEventTrack);
|
|
||||||
static PFNTRACKMOUSEEVENT _pTrackMouseEvent = nullptr;
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
HWND main_wnd; ///< Handle to system window.
|
HWND main_wnd; ///< Handle to system window.
|
||||||
HBITMAP dib_sect; ///< System bitmap object referencing our rendering buffer.
|
HBITMAP dib_sect; ///< System bitmap object referencing our rendering buffer.
|
||||||
|
@ -229,31 +226,6 @@ int RedrawScreenDebug()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Windows 95 will not have a WM_MOUSELEAVE message, so define it if needed */
|
|
||||||
#if !defined(WM_MOUSELEAVE)
|
|
||||||
#define WM_MOUSELEAVE 0x02A3
|
|
||||||
#endif
|
|
||||||
#define TID_POLLMOUSE 1
|
|
||||||
#define MOUSE_POLL_DELAY 75
|
|
||||||
|
|
||||||
static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT_PTR event, DWORD time)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
POINT pt;
|
|
||||||
|
|
||||||
/* Get the rectangle of our window and translate it to screen coordinates.
|
|
||||||
* Compare this with the current screen coordinates of the mouse and if it
|
|
||||||
* falls outside of the area or our window we have left the window. */
|
|
||||||
GetClientRect(hwnd, &rc);
|
|
||||||
MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT)(LPRECT)&rc, 2);
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
|
|
||||||
if (!PtInRect(&rc, pt) || (WindowFromPoint(pt) != hwnd)) {
|
|
||||||
KillTimer(hwnd, event);
|
|
||||||
PostMessage(hwnd, WM_MOUSELEAVE, 0, 0L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a new window.
|
* Instantiate a new window.
|
||||||
* @param full_screen Whether to make a full screen window or not.
|
* @param full_screen Whether to make a full screen window or not.
|
||||||
|
@ -633,7 +605,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, TrackMouseTimerProc);
|
_cursor.in_window = false; // Win32 has mouse tracking.
|
||||||
SetCompositionPos(hwnd);
|
SetCompositionPos(hwnd);
|
||||||
_imm_props = ImmGetProperty(GetKeyboardLayout(0), IGP_PROPERTY);
|
_imm_props = ImmGetProperty(GetKeyboardLayout(0), IGP_PROPERTY);
|
||||||
break;
|
break;
|
||||||
|
@ -730,16 +702,12 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
* tracking the mouse for exiting the window */
|
* tracking the mouse for exiting the window */
|
||||||
if (!_cursor.in_window) {
|
if (!_cursor.in_window) {
|
||||||
_cursor.in_window = true;
|
_cursor.in_window = true;
|
||||||
if (_pTrackMouseEvent != nullptr) {
|
TRACKMOUSEEVENT tme;
|
||||||
TRACKMOUSEEVENT tme;
|
tme.cbSize = sizeof(tme);
|
||||||
tme.cbSize = sizeof(tme);
|
tme.dwFlags = TME_LEAVE;
|
||||||
tme.dwFlags = TME_LEAVE;
|
tme.hwndTrack = hwnd;
|
||||||
tme.hwndTrack = hwnd;
|
|
||||||
|
|
||||||
_pTrackMouseEvent(&tme);
|
TrackMouseEvent(&tme);
|
||||||
} else {
|
|
||||||
SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, TrackMouseTimerProc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cursor.fix_at) {
|
if (_cursor.fix_at) {
|
||||||
|
@ -1024,9 +992,6 @@ static void RegisterWndClass()
|
||||||
|
|
||||||
registered = true;
|
registered = true;
|
||||||
if (!RegisterClass(&wnd)) usererror("RegisterClass failed");
|
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue