@@ -7183,6 +7183,25 @@ void nsWindow::UserActivity() {
7183
7183
}
7184
7184
}
7185
7185
7186
+ LayoutDeviceIntPoint nsWindow::GetTouchCoordinates (WPARAM wParam,
7187
+ LPARAM lParam) {
7188
+ LayoutDeviceIntPoint ret;
7189
+ uint32_t cInputs = LOWORD (wParam);
7190
+ if (cInputs != 1 ) {
7191
+ // Just return 0,0 if there isn't exactly one touch point active
7192
+ return ret;
7193
+ }
7194
+ PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
7195
+ if (mGesture .GetTouchInputInfo ((HTOUCHINPUT)lParam, cInputs, pInputs)) {
7196
+ ret.x = TOUCH_COORD_TO_PIXEL (pInputs[0 ].x );
7197
+ ret.y = TOUCH_COORD_TO_PIXEL (pInputs[0 ].y );
7198
+ }
7199
+ delete[] pInputs;
7200
+ // Note that we don't call CloseTouchInputHandle here because we need
7201
+ // to read the touch input info again in OnTouch later.
7202
+ return ret;
7203
+ }
7204
+
7186
7205
// Helper function for TouchDeviceNeedsPanGestureConversion(PTOUCHINPUT,
7187
7206
// uint32_t).
7188
7207
static bool TouchDeviceNeedsPanGestureConversion (HANDLE aSource) {
@@ -8239,24 +8258,6 @@ static bool IsTouchSupportEnabled(HWND aWnd) {
8239
8258
return topWindow ? topWindow->IsTouchWindow () : false ;
8240
8259
}
8241
8260
8242
- static Maybe<POINT> GetSingleTouch (WPARAM wParam, LPARAM lParam) {
8243
- Maybe<POINT> ret;
8244
- uint32_t cInputs = LOWORD (wParam);
8245
- if (cInputs != 1 ) {
8246
- return ret;
8247
- }
8248
- TOUCHINPUT input;
8249
- if (GetTouchInputInfo ((HTOUCHINPUT)lParam, cInputs, &input,
8250
- sizeof (TOUCHINPUT))) {
8251
- ret.emplace ();
8252
- ret->x = TOUCH_COORD_TO_PIXEL (input.x );
8253
- ret->y = TOUCH_COORD_TO_PIXEL (input.y );
8254
- }
8255
- // Note that we don't call CloseTouchInputHandle here because we need
8256
- // to read the touch input info again in OnTouch later.
8257
- return ret;
8258
- }
8259
-
8260
8261
// static
8261
8262
bool nsWindow::DealWithPopups (HWND aWnd, UINT aMessage, WPARAM aWParam,
8262
8263
LPARAM aLParam, LRESULT* aResult) {
@@ -8289,7 +8290,6 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
8289
8290
uint32_t popupsToRollup = UINT32_MAX;
8290
8291
8291
8292
bool consumeRollupEvent = false ;
8292
- Maybe<POINT> touchPoint; // In screen coords.
8293
8293
8294
8294
// If we rollup with animations but get occluded right away, we might not
8295
8295
// advance the refresh driver enough for the animation to finish.
@@ -8303,10 +8303,6 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
8303
8303
// compatibility mouse events will do it instead.
8304
8304
return false ;
8305
8305
}
8306
- touchPoint = GetSingleTouch (aWParam, aLParam);
8307
- if (!touchPoint) {
8308
- return false ;
8309
- }
8310
8306
[[fallthrough]];
8311
8307
case WM_LBUTTONDOWN:
8312
8308
case WM_RBUTTONDOWN:
@@ -8326,8 +8322,8 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
8326
8322
// handling the long-tap-up.
8327
8323
return false ;
8328
8324
}
8329
- if (!EventIsInsideWindow (popupWindow, touchPoint ) &&
8330
- GetPopupsToRollup (rollupListener, &popupsToRollup, touchPoint )) {
8325
+ if (!EventIsInsideWindow (popupWindow) &&
8326
+ GetPopupsToRollup (rollupListener, &popupsToRollup)) {
8331
8327
break ;
8332
8328
}
8333
8329
return false ;
@@ -8461,16 +8457,15 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
8461
8457
nativeMessage == WM_POINTERDOWN) {
8462
8458
LayoutDeviceIntPoint pos;
8463
8459
if (nativeMessage == WM_TOUCH) {
8464
- pos.x = touchPoint->x ;
8465
- pos.y = touchPoint->y ;
8460
+ if (nsWindow* win = WinUtils::GetNSWindowPtr (aWnd)) {
8461
+ pos = win->GetTouchCoordinates (aWParam, aLParam);
8462
+ }
8466
8463
} else {
8467
8464
POINT pt;
8468
8465
pt.x = GET_X_LPARAM (aLParam);
8469
8466
pt.y = GET_Y_LPARAM (aLParam);
8470
8467
// POINTERDOWN is already in screen coords.
8471
- if (nativeMessage == WM_LBUTTONDOWN) {
8472
- ::ClientToScreen (aWnd, &pt);
8473
- }
8468
+ ::ClientToScreen (aWnd, &pt);
8474
8469
pos = LayoutDeviceIntPoint (pt.x , pt.y );
8475
8470
}
8476
8471
0 commit comments