/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// We only handle WM_POINTER* when the input source is pen. This is because // we need some information (e.g. tiltX, tiltY) which can't be retrieved by // WM_*BUTTONDOWN.
uint32_t pointerId = GetPointerId(aWParam);
POINTER_INPUT_TYPE pointerType = PT_POINTER; if (!GetPointerType(pointerId, &pointerType)) {
MOZ_ASSERT(false, "cannot find PointerType"); returnfalse;
} return (pointerType == PT_PEN);
}
bool WinPointerEvents::ShouldRollupOnPointerEvent(UINT aMsg, WPARAM aWParam) {
MOZ_ASSERT(aMsg == WM_POINTERDOWN); // Only roll up popups when we handling WM_POINTER* to fire Gecko // WidgetMouseEvent and suppress Windows WM_*BUTTONDOWN. return ShouldHandleWinPointerMessages(aMsg, aWParam) &&
ShouldFirePointerEventByWinPointerMessages();
}
WinPointerInfo* WinPointerEvents::GetCachedPointerInfo(UINT aMsg,
WPARAM aWParam) { if (!sLibraryHandle ||
MOUSE_INPUT_SOURCE() != dom::MouseEvent_Binding::MOZ_SOURCE_PEN ||
ShouldFirePointerEventByWinPointerMessages()) { return nullptr;
} switch (aMsg) { case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: return &mPenPointerDownInfo; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: return &mPenPointerDownInfo; case WM_MOUSEMOVE: return &mPenPointerUpdateInfo; default:
MOZ_ASSERT(false);
} return nullptr;
}
void WinPointerEvents::ConvertAndCachePointerInfo(UINT aMsg, WPARAM aWParam) {
MOZ_ASSERT(
!StaticPrefs::dom_w3c_pointer_events_dispatch_by_pointer_messages()); // Windows doesn't support chorded buttons for pen, so we can simply keep the // latest information from pen generated pointer messages and use them when // handling mouse messages. Used different pointer info for pointerdown, // pointerupdate, and pointerup because Windows doesn't always interleave // pointer messages and mouse messages. switch (aMsg) { case WM_POINTERDOWN:
ConvertAndCachePointerInfo(aWParam, &mPenPointerDownInfo); break; case WM_POINTERUP:
ConvertAndCachePointerInfo(aWParam, &mPenPointerUpInfo); break; case WM_POINTERUPDATE:
ConvertAndCachePointerInfo(aWParam, &mPenPointerUpdateInfo); break; default: break;
}
}
void WinPointerEvents::ConvertAndCachePointerInfo(WPARAM aWParam,
WinPointerInfo* aInfo) {
MOZ_ASSERT(
!StaticPrefs::dom_w3c_pointer_events_dispatch_by_pointer_messages());
aInfo->pointerId = GetPointerId(aWParam);
MOZ_ASSERT(GetPointerType(aInfo->pointerId) == PT_PEN);
POINTER_PEN_INFO penInfo;
GetPointerPenInfo(aInfo->pointerId, &penInfo);
aInfo->tiltX = penInfo.tiltX;
aInfo->tiltY = penInfo.tiltY; // Windows defines the pen pressure is normalized to a range between 0 and // 1024. Convert it to float.
aInfo->mPressure = penInfo.pressure ? (float)penInfo.pressure / 1024 : 0;
}
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.