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

Unified Diff: content/browser/renderer_host/render_widget_host_view_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/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 384bc26e6c6ce9b9ad80bd1be324c28b90d3a594..5c3234ca827f601e33178ed797d15d4197b4a255 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1255,7 +1255,8 @@ void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) {
eventNumber:0
clickCount:0
pressure:0];
- WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_);
+ WebMouseEvent web_event = WebMouseEventBuilder::Build(
+ event, cocoa_view_, blink::WebPointerProperties::PointerType::Mouse);
if (showing)
web_event.type = WebInputEvent::MouseLeave;
ForwardMouseEvent(web_event);
@@ -1842,6 +1843,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
canBeKeyView_ = YES;
opaque_ = YES;
pinchHasReachedZoomThreshold_ = false;
+ stylusEnteringProximityCount_ = 0;
// OpenGL support:
if ([self respondsToSelector:
@@ -1989,10 +1991,17 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
return;
}
+ // If the pointing device enters proximity of its tablet and does not leave,
+ // the pointer type should be pen, otherwise is mouse.
+ blink::WebPointerProperties::PointerType pointerType =
mustaq 2016/06/02 15:39:12 As in the other file, rename |pointerType| to |poi
lanwei 2016/06/03 14:13:15 Done.
+ (stylusEnteringProximityCount_ > 0)
+ ? blink::WebPointerProperties::PointerType::Pen
+ : blink::WebPointerProperties::PointerType::Mouse;
if ([self shouldIgnoreMouseEvent:theEvent]) {
// If this is the first such event, send a mouse exit to the host view.
if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) {
- WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self);
+ WebMouseEvent exitEvent =
+ WebMouseEventBuilder::Build(theEvent, self, pointerType);
exitEvent.type = WebInputEvent::MouseLeave;
exitEvent.button = WebMouseEvent::ButtonNone;
renderWidgetHostView_->ForwardMouseEvent(exitEvent);
@@ -2005,7 +2014,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
// If this is the first mouse event after a previous event that was ignored
// due to the hitTest, send a mouse enter event to the host view.
if (renderWidgetHostView_->render_widget_host_) {
- WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self);
+ WebMouseEvent enterEvent =
+ WebMouseEventBuilder::Build(theEvent, self, pointerType);
enterEvent.type = WebInputEvent::MouseMove;
enterEvent.button = WebMouseEvent::ButtonNone;
if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) {
@@ -2042,7 +2052,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
[self confirmComposition];
}
- WebMouseEvent event = WebMouseEventBuilder::Build(theEvent, self);
+ WebMouseEvent event =
+ WebMouseEventBuilder::Build(theEvent, self, pointerType);
if (renderWidgetHostView_->ShouldRouteEvent(event)) {
renderWidgetHostView_->render_widget_host_->delegate()
->GetInputEventRouter()
@@ -2052,6 +2063,13 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
}
}
+- (void)tabletEvent:(NSEvent*)theEvent {
+ if ([theEvent isEnteringProximity])
+ stylusEnteringProximityCount_++;
+ else
+ stylusEnteringProximityCount_--;
+}
+
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent {
// |performKeyEquivalent:| is sent to all views of a window, not only down the
// responder chain (cf. "Handling Key Equivalents" in

Powered by Google App Engine
This is Rietveld 408576698