Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10285)

Unified Diff: content/browser/renderer_host/input/web_input_event_builders_mac.mm

Issue 2022843002: Identity the mouse pointer type from low-level events for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/web_input_event_builders_mac.mm
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac.mm b/content/browser/renderer_host/input/web_input_event_builders_mac.mm
index 2e8ea376b856638125284351bfa9cf527ce25316..aee06487ea8bd3c4c71949616e586938298a031f 100644
--- a/content/browser/renderer_host/input/web_input_event_builders_mac.mm
+++ b/content/browser/renderer_host/input/web_input_event_builders_mac.mm
@@ -663,7 +663,10 @@ blink::WebKeyboardEvent WebKeyboardEventBuilder::Build(NSEvent* event) {
// WebMouseEvent --------------------------------------------------------------
-blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) {
+blink::WebMouseEvent WebMouseEventBuilder::Build(
+ NSEvent* event,
+ NSView* view,
+ blink::WebPointerProperties::PointerType pointerType) {
blink::WebMouseEvent result;
result.clickCount = 0;
@@ -729,6 +732,20 @@ blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) {
result.timeStampSeconds = [event timestamp];
+ NSEventSubtype subtype = NSMouseEventSubtype;
+ if ([event type] != NSMouseExited && [event type] != NSMouseEntered)
+ subtype = [event subtype];
+ // For the mouse events and the touchpad events, the pointer type is mouse.
+ // For all tablet events, the pointer type will be just pen.
+ if (subtype == NSTabletPointEventSubtype ||
+ subtype == NSTabletProximityEventSubtype) {
+ result.pointerType = blink::WebPointerProperties::PointerType::Pen;
+ return result;
+ }
+
+ // Set the pointerType based on if the pointing device enters or leaves the
+ // proximity of its tablet.
+ result.pointerType = pointerType;
return result;
}

Powered by Google App Engine
This is Rietveld 408576698