Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / widget / windows / WinPointerEvents.h
blob94179e7b4e1cb650e6f58f462ac149bd04ee5512
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WinPointerEvents_h__
7 #define WinPointerEvents_h__
9 #include "mozilla/MouseEvents.h"
10 #include "touchinjection_sdk80.h"
11 #include <windef.h>
13 /******************************************************************************
14 * WinPointerInfo
16 * This is a helper class to handle WM_POINTER*. It only supports Win8 or later.
18 ******************************************************************************/
19 class WinPointerInfo final : public mozilla::WidgetPointerHelper {
20 public:
21 WinPointerInfo() : WidgetPointerHelper(), mPressure(0), mButtons(0) {}
23 WinPointerInfo(uint32_t aPointerId, uint32_t aTiltX, uint32_t aTiltY,
24 float aPressure, int16_t aButtons)
25 : WidgetPointerHelper(aPointerId, aTiltX, aTiltY),
26 mPressure(aPressure),
27 mButtons(aButtons) {}
29 float mPressure;
30 int16_t mButtons;
33 class WinPointerEvents final {
34 public:
35 explicit WinPointerEvents();
37 public:
38 bool ShouldHandleWinPointerMessages(UINT aMsg, WPARAM aWParam);
40 uint32_t GetPointerId(WPARAM aWParam) {
41 return GET_POINTERID_WPARAM(aWParam);
43 bool GetPointerType(uint32_t aPointerId, POINTER_INPUT_TYPE* aPointerType);
44 POINTER_INPUT_TYPE GetPointerType(uint32_t aPointerId);
45 bool GetPointerInfo(uint32_t aPointerId, POINTER_INFO* aPointerInfo);
46 bool GetPointerPenInfo(uint32_t aPointerId, POINTER_PEN_INFO* aPenInfo);
47 bool ShouldRollupOnPointerEvent(UINT aMsg, WPARAM aWParam);
48 bool ShouldFirePointerEventByWinPointerMessages();
49 WinPointerInfo* GetCachedPointerInfo(UINT aMsg, WPARAM aWParam);
50 void ConvertAndCachePointerInfo(UINT aMsg, WPARAM aWParam);
51 void ConvertAndCachePointerInfo(WPARAM aWParam, WinPointerInfo* aInfo);
53 private:
54 // Function prototypes
55 typedef BOOL(WINAPI* GetPointerTypePtr)(uint32_t aPointerId,
56 POINTER_INPUT_TYPE* aPointerType);
57 typedef BOOL(WINAPI* GetPointerInfoPtr)(uint32_t aPointerId,
58 POINTER_INFO* aPointerInfo);
59 typedef BOOL(WINAPI* GetPointerPenInfoPtr)(uint32_t aPointerId,
60 POINTER_PEN_INFO* aPenInfo);
62 void InitLibrary();
64 static HMODULE sLibraryHandle;
65 static const wchar_t kPointerLibraryName[];
66 // Static function pointers
67 static GetPointerTypePtr getPointerType;
68 static GetPointerInfoPtr getPointerInfo;
69 static GetPointerPenInfoPtr getPointerPenInfo;
70 WinPointerInfo mPenPointerDownInfo;
71 WinPointerInfo mPenPointerUpInfo;
72 WinPointerInfo mPenPointerUpdateInfo;
75 #endif // #ifndef WinPointerEvents_h__