static gboolean pen_touch_input;
static POINT pen_touch_cursor_position;
+static LONG last_digitizer_time;
static void
track_mouse_event (DWORD dwFlags,
(gpointer) msg->wParam,
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
+ /* Even if we handle WM_POINTER messages, synthetic WM_MOUSEMOVE messages
+ * are still sent occasionally by the OS, e.g. when a surface is hidden
+ * or shown. Discard spurious WM_MOUSEMOVE messages while handling pen or
+ * touch input
+ *
+ * See the article
+ * "Why do I get spurious WM_MOUSEMOVE messages?" by Raymond Chen:
+ * https://devblogs.microsoft.com/oldnewthing/20031001-00/?p=42343
+ *
+ */
+ if (_gdk_win32_tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER &&
+ ( (msg->time - last_digitizer_time) < 200 ||
+ -(msg->time - last_digitizer_time) < 200 ))
+ break;
+
pen_touch_input = FALSE;
new_window = window;
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (pointer_grab != NULL &&
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (pointer_grab != NULL &&
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (pointer_grab != NULL &&
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (IS_POINTER_PRIMARY_WPARAM (msg->wParam) &&
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (pointer_grab != NULL &&
current_root_x = pen_touch_cursor_position.x = GET_X_LPARAM (msg->lParam);
current_root_y = pen_touch_cursor_position.y = GET_Y_LPARAM (msg->lParam);
pen_touch_input = TRUE;
+ last_digitizer_time = msg->time;
}
if (!IS_POINTER_INRANGE_WPARAM (msg->wParam))