Use the pointer API for mouse events too

Mouse messages and pointer messages do not go well together.
If we don't use the pointer API for mouse messages, we start
receiving random mouse messages when a pointer is being used
(this is increased when a modifier key is pressed).

With this patch we start using the pointer API for mouse
messages and remove our workaround to avoid these
random messages.

This might be a possible solution for issues like:
https://community.aseprite.org/t/all-the-tools-stop-working/738
https://community.aseprite.org/t/after-using-the-snipping-tool-on-win-10-the-mouse-pointer-disappears/906
http://steamcommunity.com/app/431730/discussions/0/1485487749769857401/
This commit is contained in:
David Capello 2018-03-13 11:55:57 -03:00
parent f9af5c21c7
commit 5ccdacc9de

View File

@ -39,7 +39,7 @@
// Not yet ready because if we start receiving WM_POINTERDOWN messages
// instead of WM_LBUTTONDBLCLK we lost the automatic double-click
// messages.
#define USE_EnableMouseInPointer 0
#define USE_EnableMouseInPointer 1
#ifndef INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS_SCREEN
#define INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS_SCREEN 1
@ -530,11 +530,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
case WM_MOUSEMOVE: {
// If the pointer API is enable, we use WM_POINTERUPDATE instead
// of WM_MOUSEMOVE. This check is here because Windows keeps
// sending us WM_MOUSEMOVE messages even when we call
// EnableMouseInPointer() (mainly when we use Alt+stylus we
// receive WM_MOUSEMOVE with the position of the mouse/trackpad
// + WM_POINTERUPDATE with the position of the pen)
// of WM_MOUSEMOVE.
if (m_ignoreMouseMessages)
break;
@ -769,13 +765,6 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
MOUSE_TRACE("POINTERENTER id=%d xy=%d,%d\n",
pi.pointerId, ev.position().x, ev.position().y);
#if USE_EnableMouseInPointer == 0
// This is necessary to avoid receiving random WM_MOUSEMOVE from
// the mouse position when we use Alt+pen tip.
// TODO Remove this line when we enable EnableMouseInPointer(TRUE);
m_ignoreMouseMessages = true;
#endif
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.AddPointerInteractionContext)
@ -801,10 +790,6 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
MOUSE_TRACE("POINTERLEAVE id=%d\n", pi.pointerId);
#if USE_EnableMouseInPointer == 0
m_ignoreMouseMessages = false;
#endif
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.RemovePointerInteractionContext)