| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <objc/runtime.h> | 8 #import <objc/runtime.h> |
| 9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
| 10 #include <QuartzCore/QuartzCore.h> | 10 #include <QuartzCore/QuartzCore.h> |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::mouseEvent"); | 1903 TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::mouseEvent"); |
| 1904 if (responderDelegate_ && | 1904 if (responderDelegate_ && |
| 1905 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { | 1905 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { |
| 1906 BOOL handled = [responderDelegate_ handleEvent:theEvent]; | 1906 BOOL handled = [responderDelegate_ handleEvent:theEvent]; |
| 1907 if (handled) | 1907 if (handled) |
| 1908 return; | 1908 return; |
| 1909 } | 1909 } |
| 1910 | 1910 |
| 1911 // Set the pointer type when we are receiving a NSMouseEntered event and the | 1911 // Set the pointer type when we are receiving a NSMouseEntered event and the |
| 1912 // following NSMouseExited event should have the same pointer type. | 1912 // following NSMouseExited event should have the same pointer type. |
| 1913 // For NSMouseExited and NSMouseEntered events, they do not have a subtype. |
| 1914 // We decide their pointer types by checking if we recevied a |
| 1915 // NSTabletProximity event. |
| 1913 NSEventType type = [theEvent type]; | 1916 NSEventType type = [theEvent type]; |
| 1914 if (type == NSMouseEntered) { | 1917 if (type == NSMouseEntered || type == NSMouseExited) { |
| 1915 pointerType_ = isStylusEnteringProximity_ | 1918 pointerType_ = isStylusEnteringProximity_ |
| 1916 ? blink::WebPointerProperties::PointerType::Pen | 1919 ? pointerType_ |
| 1917 : blink::WebPointerProperties::PointerType::Mouse; | 1920 : blink::WebPointerProperties::PointerType::Mouse; |
| 1921 } else { |
| 1922 NSEventSubtype subtype = [theEvent subtype]; |
| 1923 // For other mouse events and touchpad events, the pointer type is mouse. |
| 1924 if (subtype != NSTabletPointEventSubtype && |
| 1925 subtype != NSTabletProximityEventSubtype) { |
| 1926 pointerType_ = blink::WebPointerProperties::PointerType::Mouse; |
| 1927 } |
| 1918 } | 1928 } |
| 1919 | 1929 |
| 1920 if ([self shouldIgnoreMouseEvent:theEvent]) { | 1930 if ([self shouldIgnoreMouseEvent:theEvent]) { |
| 1921 // If this is the first such event, send a mouse exit to the host view. | 1931 // If this is the first such event, send a mouse exit to the host view. |
| 1922 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { | 1932 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
| 1923 WebMouseEvent exitEvent = | 1933 WebMouseEvent exitEvent = |
| 1924 WebMouseEventBuilder::Build(theEvent, self, pointerType_); | 1934 WebMouseEventBuilder::Build(theEvent, self, pointerType_); |
| 1925 exitEvent.setType(WebInputEvent::MouseLeave); | 1935 exitEvent.setType(WebInputEvent::MouseLeave); |
| 1926 exitEvent.button = WebMouseEvent::Button::NoButton; | 1936 exitEvent.button = WebMouseEvent::Button::NoButton; |
| 1927 renderWidgetHostView_->ForwardMouseEvent(exitEvent); | 1937 renderWidgetHostView_->ForwardMouseEvent(exitEvent); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 1990 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
| 1981 renderWidgetHostView_->render_widget_host_->delegate() | 1991 renderWidgetHostView_->render_widget_host_->delegate() |
| 1982 ->GetInputEventRouter() | 1992 ->GetInputEventRouter() |
| 1983 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); | 1993 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); |
| 1984 } else { | 1994 } else { |
| 1985 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); | 1995 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); |
| 1986 } | 1996 } |
| 1987 } | 1997 } |
| 1988 | 1998 |
| 1989 - (void)tabletEvent:(NSEvent*)theEvent { | 1999 - (void)tabletEvent:(NSEvent*)theEvent { |
| 1990 if ([theEvent type] == NSTabletProximity) | 2000 if ([theEvent type] == NSTabletProximity) { |
| 1991 isStylusEnteringProximity_ = [theEvent isEnteringProximity]; | 2001 isStylusEnteringProximity_ = [theEvent isEnteringProximity]; |
| 2002 NSPointingDeviceType deviceType = [theEvent pointingDeviceType]; |
| 2003 // For all tablet events, the pointer type will be pen or eraser. |
| 2004 pointerType_ = deviceType == NSEraserPointingDevice |
| 2005 ? blink::WebPointerProperties::PointerType::Eraser |
| 2006 : blink::WebPointerProperties::PointerType::Pen; |
| 2007 } |
| 1992 } | 2008 } |
| 1993 | 2009 |
| 1994 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2010 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
| 1995 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2011 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
| 1996 // responder chain (cf. "Handling Key Equivalents" in | 2012 // responder chain (cf. "Handling Key Equivalents" in |
| 1997 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2013 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event
Overview/HandlingKeyEvents/HandlingKeyEvents.html |
| 1998 // ). We only want to handle key equivalents if we're first responder. | 2014 // ). We only want to handle key equivalents if we're first responder. |
| 1999 if ([[self window] firstResponder] != self) | 2015 if ([[self window] firstResponder] != self) |
| 2000 return NO; | 2016 return NO; |
| 2001 | 2017 |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3489 | 3505 |
| 3490 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3506 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3491 // regions that are not draggable. (See ControlRegionView in | 3507 // regions that are not draggable. (See ControlRegionView in |
| 3492 // native_app_window_cocoa.mm). This requires the render host view to be | 3508 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3493 // draggable by default. | 3509 // draggable by default. |
| 3494 - (BOOL)mouseDownCanMoveWindow { | 3510 - (BOOL)mouseDownCanMoveWindow { |
| 3495 return YES; | 3511 return YES; |
| 3496 } | 3512 } |
| 3497 | 3513 |
| 3498 @end | 3514 @end |
| OLD | NEW |