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

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: Set stylus count and set id and pressure as well 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..dcf2ef4a8d1f3de7e275777bf475d535bd338739 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,12 +663,16 @@ 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) {
mustaq 2016/06/02 15:39:12 Please rename the |pointerType| param to |pointerT
lanwei 2016/06/03 14:13:15 Done.
blink::WebMouseEvent result;
result.clickCount = 0;
- switch ([event type]) {
+ NSEventType type = [event type];
+ switch (type) {
case NSMouseExited:
result.type = blink::WebInputEvent::MouseLeave;
result.button = blink::WebMouseEvent::ButtonNone;
@@ -729,6 +733,27 @@ blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) {
result.timeStampSeconds = [event timestamp];
+ // Currently, NSMouseExited and NSMouseEntered do not have the 'subtype' and
+ // 'deviceID' properties.
+ // This is a simple solution which works only for a single input device.
+ if (type == NSMouseExited || type == NSMouseEntered) {
+ // Set the pointerType based on if there is a stylus in the proximity of
+ // the tablet
+ result.pointerType = pointerType;
+ return result;
+ }
+
+ // For the mouse events and the touchpad events, the pointer type is mouse.
+ // For all tablet events, the pointer type will be just pen.
+ NSEventSubtype subtype = [event subtype];
+ if (subtype == NSTabletPointEventSubtype ||
+ subtype == NSTabletProximityEventSubtype) {
+ result.pointerType = blink::WebPointerProperties::PointerType::Pen;
+ } else {
+ result.pointerType = blink::WebPointerProperties::PointerType::Mouse;
+ }
+ result.id = [event deviceID];
+ result.force = [event pressure];
return result;
}

Powered by Google App Engine
This is Rietveld 408576698