@@ -24,6 +24,22 @@ using namespace mozilla::widget;
24
24
25
25
extern mozilla::LazyLogModule gWindowsLog ;
26
26
27
+ const wchar_t nsWinGesture::kGestureLibraryName [] = L" user32.dll" ;
28
+ HMODULE nsWinGesture::sLibraryHandle = nullptr ;
29
+ nsWinGesture::GetGestureInfoPtr nsWinGesture::getGestureInfo = nullptr ;
30
+ nsWinGesture::CloseGestureInfoHandlePtr nsWinGesture::closeGestureInfoHandle = nullptr ;
31
+ nsWinGesture::GetGestureExtraArgsPtr nsWinGesture::getGestureExtraArgs = nullptr ;
32
+ nsWinGesture::SetGestureConfigPtr nsWinGesture::setGestureConfig = nullptr ;
33
+ nsWinGesture::GetGestureConfigPtr nsWinGesture::getGestureConfig = nullptr ;
34
+ nsWinGesture::BeginPanningFeedbackPtr nsWinGesture::beginPanningFeedback = nullptr ;
35
+ nsWinGesture::EndPanningFeedbackPtr nsWinGesture::endPanningFeedback = nullptr ;
36
+ nsWinGesture::UpdatePanningFeedbackPtr nsWinGesture::updatePanningFeedback = nullptr ;
37
+
38
+ nsWinGesture::RegisterTouchWindowPtr nsWinGesture::registerTouchWindow = nullptr ;
39
+ nsWinGesture::UnregisterTouchWindowPtr nsWinGesture::unregisterTouchWindow = nullptr ;
40
+ nsWinGesture::GetTouchInputInfoPtr nsWinGesture::getTouchInputInfo = nullptr ;
41
+ nsWinGesture::CloseTouchInputHandlePtr nsWinGesture::closeTouchInputHandle = nullptr ;
42
+
27
43
static bool gEnableSingleFingerPanEvents = false ;
28
44
29
45
nsWinGesture::nsWinGesture ()
@@ -39,6 +55,58 @@ nsWinGesture::nsWinGesture()
39
55
/* Load and shutdown */
40
56
41
57
bool nsWinGesture::InitLibrary () {
58
+ if (getGestureInfo) {
59
+ return true ;
60
+ } else if (sLibraryHandle ) {
61
+ return false ;
62
+ }
63
+
64
+ sLibraryHandle = ::LoadLibraryW (kGestureLibraryName );
65
+ HMODULE hTheme = nsUXThemeData::GetThemeDLL ();
66
+
67
+ // gesture interfaces
68
+ if (sLibraryHandle ) {
69
+ getGestureInfo = (GetGestureInfoPtr)GetProcAddress (sLibraryHandle , " GetGestureInfo" );
70
+ closeGestureInfoHandle = (CloseGestureInfoHandlePtr)GetProcAddress (sLibraryHandle , " CloseGestureInfoHandle" );
71
+ getGestureExtraArgs = (GetGestureExtraArgsPtr)GetProcAddress (sLibraryHandle , " GetGestureExtraArgs" );
72
+ setGestureConfig = (SetGestureConfigPtr)GetProcAddress (sLibraryHandle , " SetGestureConfig" );
73
+ getGestureConfig = (GetGestureConfigPtr)GetProcAddress (sLibraryHandle , " GetGestureConfig" );
74
+ registerTouchWindow = (RegisterTouchWindowPtr)GetProcAddress (sLibraryHandle , " RegisterTouchWindow" );
75
+ unregisterTouchWindow = (UnregisterTouchWindowPtr)GetProcAddress (sLibraryHandle , " UnregisterTouchWindow" );
76
+ getTouchInputInfo = (GetTouchInputInfoPtr)GetProcAddress (sLibraryHandle , " GetTouchInputInfo" );
77
+ closeTouchInputHandle = (CloseTouchInputHandlePtr)GetProcAddress (sLibraryHandle , " CloseTouchInputHandle" );
78
+ }
79
+
80
+ if (!getGestureInfo || !closeGestureInfoHandle || !getGestureExtraArgs ||
81
+ !setGestureConfig || !getGestureConfig) {
82
+ getGestureInfo = nullptr ;
83
+ closeGestureInfoHandle = nullptr ;
84
+ getGestureExtraArgs = nullptr ;
85
+ setGestureConfig = nullptr ;
86
+ getGestureConfig = nullptr ;
87
+ return false ;
88
+ }
89
+
90
+ if (!registerTouchWindow || !unregisterTouchWindow || !getTouchInputInfo || !closeTouchInputHandle) {
91
+ registerTouchWindow = nullptr ;
92
+ unregisterTouchWindow = nullptr ;
93
+ getTouchInputInfo = nullptr ;
94
+ closeTouchInputHandle = nullptr ;
95
+ }
96
+
97
+ // panning feedback interfaces
98
+ if (hTheme) {
99
+ beginPanningFeedback = (BeginPanningFeedbackPtr)GetProcAddress (hTheme, " BeginPanningFeedback" );
100
+ endPanningFeedback = (EndPanningFeedbackPtr)GetProcAddress (hTheme, " EndPanningFeedback" );
101
+ updatePanningFeedback = (UpdatePanningFeedbackPtr)GetProcAddress (hTheme, " UpdatePanningFeedback" );
102
+ }
103
+
104
+ if (!beginPanningFeedback || !endPanningFeedback || !updatePanningFeedback) {
105
+ beginPanningFeedback = nullptr ;
106
+ endPanningFeedback = nullptr ;
107
+ updatePanningFeedback = nullptr ;
108
+ }
109
+
42
110
// Check to see if we want single finger gesture input. Only do this once
43
111
// for the app so we don't have to look it up on every window create.
44
112
gEnableSingleFingerPanEvents =
@@ -51,6 +119,11 @@ bool nsWinGesture::InitLibrary() {
51
119
52
120
bool nsWinGesture::SetWinGestureSupport (
53
121
HWND hWnd, WidgetGestureNotifyEvent::PanDirection aDirection) {
122
+
123
+ if (!getGestureInfo) {
124
+ return false ;
125
+ }
126
+
54
127
GESTURECONFIG config[GCOUNT];
55
128
56
129
memset (&config, 0 , sizeof (config));
@@ -90,12 +163,115 @@ bool nsWinGesture::SetWinGestureSupport(
90
163
config[4 ].dwID = GID_PRESSANDTAP;
91
164
config[4 ].dwBlock = 0 ;
92
165
93
- return SetGestureConfig (hWnd, 0 , GCOUNT, (PGESTURECONFIG)&config,
94
- sizeof (GESTURECONFIG));
166
+ return SetGestureConfig (hWnd, GCOUNT, (PGESTURECONFIG)&config);
95
167
}
96
168
97
169
/* Helpers */
98
170
171
+ // bool nsWinGesture::IsAvailable()
172
+ // {
173
+ // return getGestureInfo != nullptr;
174
+ // }
175
+
176
+ bool nsWinGesture::RegisterTouchWindow (HWND hWnd)
177
+ {
178
+ if (!registerTouchWindow)
179
+ return false ;
180
+
181
+ return registerTouchWindow (hWnd, TWF_WANTPALM);
182
+ }
183
+
184
+ bool nsWinGesture::UnregisterTouchWindow (HWND hWnd)
185
+ {
186
+ if (!unregisterTouchWindow)
187
+ return false ;
188
+
189
+ return unregisterTouchWindow (hWnd);
190
+ }
191
+
192
+ bool nsWinGesture::GetTouchInputInfo (HTOUCHINPUT hTouchInput, uint32_t cInputs, PTOUCHINPUT pInputs)
193
+ {
194
+ if (!getTouchInputInfo)
195
+ return false ;
196
+
197
+ return getTouchInputInfo (hTouchInput, cInputs, pInputs, sizeof (TOUCHINPUT));
198
+ }
199
+
200
+ bool nsWinGesture::CloseTouchInputHandle (HTOUCHINPUT hTouchInput)
201
+ {
202
+ if (!closeTouchInputHandle)
203
+ return false ;
204
+
205
+ return closeTouchInputHandle (hTouchInput);
206
+ }
207
+
208
+ bool nsWinGesture::GetGestureInfo (HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo)
209
+ {
210
+ if (!getGestureInfo || !hGestureInfo || !pGestureInfo)
211
+ return false ;
212
+
213
+ ZeroMemory (pGestureInfo, sizeof (GESTUREINFO));
214
+ pGestureInfo->cbSize = sizeof (GESTUREINFO);
215
+
216
+ return getGestureInfo (hGestureInfo, pGestureInfo);
217
+ }
218
+
219
+ bool nsWinGesture::CloseGestureInfoHandle (HGESTUREINFO hGestureInfo)
220
+ {
221
+ if (!getGestureInfo || !hGestureInfo)
222
+ return false ;
223
+
224
+ return closeGestureInfoHandle (hGestureInfo);
225
+ }
226
+
227
+ bool nsWinGesture::GetGestureExtraArgs (HGESTUREINFO hGestureInfo, UINT cbExtraArgs, PBYTE pExtraArgs)
228
+ {
229
+ if (!getGestureInfo || !hGestureInfo || !pExtraArgs)
230
+ return false ;
231
+
232
+ return getGestureExtraArgs (hGestureInfo, cbExtraArgs, pExtraArgs);
233
+ }
234
+
235
+ bool nsWinGesture::SetGestureConfig (HWND hWnd, UINT cIDs, PGESTURECONFIG pGestureConfig)
236
+ {
237
+ if (!getGestureInfo || !pGestureConfig)
238
+ return false ;
239
+
240
+ return setGestureConfig (hWnd, 0 , cIDs, pGestureConfig, sizeof (GESTURECONFIG));
241
+ }
242
+
243
+ bool nsWinGesture::GetGestureConfig (HWND hWnd, DWORD dwFlags, PUINT pcIDs, PGESTURECONFIG pGestureConfig)
244
+ {
245
+ if (!getGestureInfo || !pGestureConfig)
246
+ return false ;
247
+
248
+ return getGestureConfig (hWnd, 0 , dwFlags, pcIDs, pGestureConfig, sizeof (GESTURECONFIG));
249
+ }
250
+
251
+ bool nsWinGesture::BeginPanningFeedback (HWND hWnd)
252
+ {
253
+ if (!beginPanningFeedback)
254
+ return false ;
255
+
256
+ return beginPanningFeedback (hWnd);
257
+ }
258
+
259
+ bool nsWinGesture::EndPanningFeedback (HWND hWnd)
260
+ {
261
+ if (!beginPanningFeedback)
262
+ return false ;
263
+
264
+ return endPanningFeedback (hWnd, TRUE );
265
+ }
266
+
267
+ bool nsWinGesture::UpdatePanningFeedback (HWND hWnd, LONG offsetX, LONG offsetY, BOOL fInInertia )
268
+ {
269
+ if (!beginPanningFeedback)
270
+ return false ;
271
+
272
+ return updatePanningFeedback (hWnd, offsetX, offsetY, fInInertia );
273
+ }
274
+
99
275
bool nsWinGesture::IsPanEvent (LPARAM lParam) {
100
276
GESTUREINFO gi;
101
277
@@ -354,7 +530,7 @@ void nsWinGesture::PanFeedbackFinalize(HWND hWnd, bool endFeedback) {
354
530
mXAxisFeedback = false ;
355
531
mYAxisFeedback = false ;
356
532
mPixelScrollOverflow = 0 ;
357
- EndPanningFeedback (hWnd, TRUE );
533
+ EndPanningFeedback (hWnd);
358
534
return ;
359
535
}
360
536
0 commit comments