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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /* 5 /*
6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
7 * Copyright (C) 2006-2009 Google Inc. 7 * Copyright (C) 2006-2009 Google Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 encoding:NSASCIIStringEncoding]; 656 encoding:NSASCIIStringEncoding];
657 657
658 result.timeStampSeconds = [event timestamp]; 658 result.timeStampSeconds = [event timestamp];
659 result.isSystemKey = IsSystemKeyEvent(result); 659 result.isSystemKey = IsSystemKeyEvent(result);
660 660
661 return result; 661 return result;
662 } 662 }
663 663
664 // WebMouseEvent -------------------------------------------------------------- 664 // WebMouseEvent --------------------------------------------------------------
665 665
666 blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { 666 blink::WebMouseEvent WebMouseEventBuilder::Build(
667 NSEvent* event,
668 NSView* view,
669 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.
667 blink::WebMouseEvent result; 670 blink::WebMouseEvent result;
668 671
669 result.clickCount = 0; 672 result.clickCount = 0;
670 673
671 switch ([event type]) { 674 NSEventType type = [event type];
675 switch (type) {
672 case NSMouseExited: 676 case NSMouseExited:
673 result.type = blink::WebInputEvent::MouseLeave; 677 result.type = blink::WebInputEvent::MouseLeave;
674 result.button = blink::WebMouseEvent::ButtonNone; 678 result.button = blink::WebMouseEvent::ButtonNone;
675 break; 679 break;
676 case NSLeftMouseDown: 680 case NSLeftMouseDown:
677 result.type = blink::WebInputEvent::MouseDown; 681 result.type = blink::WebInputEvent::MouseDown;
678 result.clickCount = [event clickCount]; 682 result.clickCount = [event clickCount];
679 result.button = blink::WebMouseEvent::ButtonLeft; 683 result.button = blink::WebMouseEvent::ButtonLeft;
680 break; 684 break;
681 case NSOtherMouseDown: 685 case NSOtherMouseDown:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 default: 726 default:
723 NOTIMPLEMENTED(); 727 NOTIMPLEMENTED();
724 } 728 }
725 729
726 SetWebEventLocationFromEventInView(&result, event, view); 730 SetWebEventLocationFromEventInView(&result, event, view);
727 731
728 result.modifiers = ModifiersFromEvent(event); 732 result.modifiers = ModifiersFromEvent(event);
729 733
730 result.timeStampSeconds = [event timestamp]; 734 result.timeStampSeconds = [event timestamp];
731 735
736 // Currently, NSMouseExited and NSMouseEntered do not have the 'subtype' and
737 // 'deviceID' properties.
738 // This is a simple solution which works only for a single input device.
739 if (type == NSMouseExited || type == NSMouseEntered) {
740 // Set the pointerType based on if there is a stylus in the proximity of
741 // the tablet
742 result.pointerType = pointerType;
743 return result;
744 }
745
746 // For the mouse events and the touchpad events, the pointer type is mouse.
747 // For all tablet events, the pointer type will be just pen.
748 NSEventSubtype subtype = [event subtype];
749 if (subtype == NSTabletPointEventSubtype ||
750 subtype == NSTabletProximityEventSubtype) {
751 result.pointerType = blink::WebPointerProperties::PointerType::Pen;
752 } else {
753 result.pointerType = blink::WebPointerProperties::PointerType::Mouse;
754 }
755 result.id = [event deviceID];
756 result.force = [event pressure];
732 return result; 757 return result;
733 } 758 }
734 759
735 // WebMouseWheelEvent --------------------------------------------------------- 760 // WebMouseWheelEvent ---------------------------------------------------------
736 761
737 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( 762 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build(
738 NSEvent* event, 763 NSEvent* event,
739 NSView* view, 764 NSView* view,
740 bool can_rubberband_left, 765 bool can_rubberband_left,
741 bool can_rubberband_right) { 766 bool can_rubberband_right) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 break; 956 break;
932 default: 957 default:
933 NOTIMPLEMENTED(); 958 NOTIMPLEMENTED();
934 result.type = blink::WebInputEvent::Undefined; 959 result.type = blink::WebInputEvent::Undefined;
935 } 960 }
936 961
937 return result; 962 return result;
938 } 963 }
939 964
940 } // namespace content 965 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698