Skip to content

Commit 27fcbaf

Browse files
committed
Gesture stuffs working on Vista part 2
This also undoes eaf8c1e, which theoretically would reintroduce Bug 1696786. This is suboptimal, but I don't know how to make it work otherwise. Please pr a proper fix.
1 parent add7802 commit 27fcbaf

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

widget/windows/nsWindow.cpp

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7183,6 +7183,25 @@ void nsWindow::UserActivity() {
71837183
}
71847184
}
71857185

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+
71867205
// Helper function for TouchDeviceNeedsPanGestureConversion(PTOUCHINPUT,
71877206
// uint32_t).
71887207
static bool TouchDeviceNeedsPanGestureConversion(HANDLE aSource) {
@@ -8239,24 +8258,6 @@ static bool IsTouchSupportEnabled(HWND aWnd) {
82398258
return topWindow ? topWindow->IsTouchWindow() : false;
82408259
}
82418260

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-
82608261
// static
82618262
bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
82628263
LPARAM aLParam, LRESULT* aResult) {
@@ -8289,7 +8290,6 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
82898290
uint32_t popupsToRollup = UINT32_MAX;
82908291

82918292
bool consumeRollupEvent = false;
8292-
Maybe<POINT> touchPoint; // In screen coords.
82938293

82948294
// If we rollup with animations but get occluded right away, we might not
82958295
// advance the refresh driver enough for the animation to finish.
@@ -8303,10 +8303,6 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
83038303
// compatibility mouse events will do it instead.
83048304
return false;
83058305
}
8306-
touchPoint = GetSingleTouch(aWParam, aLParam);
8307-
if (!touchPoint) {
8308-
return false;
8309-
}
83108306
[[fallthrough]];
83118307
case WM_LBUTTONDOWN:
83128308
case WM_RBUTTONDOWN:
@@ -8326,8 +8322,8 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
83268322
// handling the long-tap-up.
83278323
return false;
83288324
}
8329-
if (!EventIsInsideWindow(popupWindow, touchPoint) &&
8330-
GetPopupsToRollup(rollupListener, &popupsToRollup, touchPoint)) {
8325+
if (!EventIsInsideWindow(popupWindow) &&
8326+
GetPopupsToRollup(rollupListener, &popupsToRollup)) {
83318327
break;
83328328
}
83338329
return false;
@@ -8461,16 +8457,15 @@ bool nsWindow::DealWithPopups(HWND aWnd, UINT aMessage, WPARAM aWParam,
84618457
nativeMessage == WM_POINTERDOWN) {
84628458
LayoutDeviceIntPoint pos;
84638459
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+
}
84668463
} else {
84678464
POINT pt;
84688465
pt.x = GET_X_LPARAM(aLParam);
84698466
pt.y = GET_Y_LPARAM(aLParam);
84708467
// POINTERDOWN is already in screen coords.
8471-
if (nativeMessage == WM_LBUTTONDOWN) {
8472-
::ClientToScreen(aWnd, &pt);
8473-
}
8468+
::ClientToScreen(aWnd, &pt);
84748469
pos = LayoutDeviceIntPoint(pt.x, pt.y);
84758470
}
84768471

widget/windows/nsWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ class nsWindow final : public nsBaseWidget {
568568
TimeStamp GetMessageTimeStamp(LONG aEventTime) const;
569569
static void UpdateFirstEventTime(DWORD aEventTime);
570570
void FinishLiveResizing(ResizeState aNewState);
571+
LayoutDeviceIntPoint GetTouchCoordinates(WPARAM wParam, LPARAM lParam);
571572
mozilla::Maybe<mozilla::PanGestureInput> ConvertTouchToPanGesture(
572573
const mozilla::MultiTouchInput& aTouchInput, PTOUCHINPUT aOriginalEvent);
573574
void DispatchTouchOrPanGestureInput(mozilla::MultiTouchInput& aTouchInput,

0 commit comments

Comments
 (0)