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

Side by Side Diff: ui/events/cocoa/events_mac.mm

Issue 2439953005: Support NSFlagsChanged in ui::EventFromNative. (Closed)
Patch Set: Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/event_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #import "base/mac/mac_util.h" 11 #import "base/mac/mac_util.h"
12 #import "base/mac/sdk_forward_declarations.h" 12 #import "base/mac/sdk_forward_declarations.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/events/base_event_utils.h" 15 #include "ui/events/base_event_utils.h"
16 #include "ui/events/cocoa/cocoa_event_utils.h" 16 #include "ui/events/cocoa/cocoa_event_utils.h"
17 #include "ui/events/event_utils.h" 17 #include "ui/events/event_utils.h"
18 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" 18 #import "ui/events/keycodes/keyboard_code_conversion_mac.h"
19 #include "ui/gfx/geometry/point.h" 19 #include "ui/gfx/geometry/point.h"
20 #include "ui/gfx/geometry/vector2d.h" 20 #include "ui/gfx/geometry/vector2d.h"
21 21
22 namespace ui { 22 namespace ui {
23 23
24 namespace {
25
26 EventType EventTypeForFlagsChanged(NSEventModifierFlags flags,
27 KeyboardCode key_code) {
28 switch (key_code) {
29 case VKEY_CAPITAL:
tapted 2016/10/25 06:55:09 There's no need to use the Windows keycodes that K
30 return (flags & NSAlphaShiftKeyMask) ? ET_KEY_PRESSED : ET_KEY_RELEASED;
31 case VKEY_SHIFT:
32 return (flags & NSShiftKeyMask) ? ET_KEY_PRESSED : ET_KEY_RELEASED;
33 case VKEY_CONTROL:
34 return (flags & NSControlKeyMask) ? ET_KEY_PRESSED : ET_KEY_RELEASED;
35 case VKEY_MENU:
36 return (flags & NSAlternateKeyMask) ? ET_KEY_PRESSED : ET_KEY_RELEASED;
37 case VKEY_APPS: // Fallthrough.
38 case VKEY_LWIN:
39 return (flags & NSCommandKeyMask) ? ET_KEY_PRESSED : ET_KEY_RELEASED;
40 default:
41 return ET_UNKNOWN;
42 }
43 }
44
45 } // namespace
46
24 EventType EventTypeFromNative(const base::NativeEvent& native_event) { 47 EventType EventTypeFromNative(const base::NativeEvent& native_event) {
25 NSEventType type = [native_event type]; 48 NSEventType type = [native_event type];
26 switch (type) { 49 switch (type) {
27 case NSKeyDown: 50 case NSKeyDown:
28 return ET_KEY_PRESSED; 51 return ET_KEY_PRESSED;
29 case NSKeyUp: 52 case NSKeyUp:
30 return ET_KEY_RELEASED; 53 return ET_KEY_RELEASED;
31 case NSLeftMouseDown: 54 case NSLeftMouseDown:
32 case NSRightMouseDown: 55 case NSRightMouseDown:
33 case NSOtherMouseDown: 56 case NSOtherMouseDown:
(...skipping 13 matching lines...) Expand all
47 case NSMouseEntered: 70 case NSMouseEntered:
48 return ET_MOUSE_ENTERED; 71 return ET_MOUSE_ENTERED;
49 case NSMouseExited: 72 case NSMouseExited:
50 return ET_MOUSE_EXITED; 73 return ET_MOUSE_EXITED;
51 case NSEventTypeSwipe: 74 case NSEventTypeSwipe:
52 return ET_SCROLL_FLING_START; 75 return ET_SCROLL_FLING_START;
53 case NSAppKitDefined: 76 case NSAppKitDefined:
54 case NSSystemDefined: 77 case NSSystemDefined:
55 return ET_UNKNOWN; 78 return ET_UNKNOWN;
56 case NSFlagsChanged: 79 case NSFlagsChanged:
80 return EventTypeForFlagsChanged(native_event.modifierFlags,
tapted 2016/10/25 06:55:09 [native_event modifierFlags] - we only use dot no
tapted 2016/10/27 00:33:05 And here just have case NSKeyDown: case NSKey
alshabalin 2016/10/28 19:58:13 Done.
81 KeyboardCodeFromNSEvent(native_event));
57 case NSApplicationDefined: 82 case NSApplicationDefined:
58 case NSPeriodic: 83 case NSPeriodic:
59 case NSCursorUpdate: 84 case NSCursorUpdate:
60 case NSTabletPoint: 85 case NSTabletPoint:
61 case NSTabletProximity: 86 case NSTabletProximity:
62 case NSEventTypeGesture: 87 case NSEventTypeGesture:
63 case NSEventTypeMagnify: 88 case NSEventTypeMagnify:
64 case NSEventTypeRotate: 89 case NSEventTypeRotate:
65 case NSEventTypeBeginGesture: 90 case NSEventTypeBeginGesture:
66 case NSEventTypeEndGesture: 91 case NSEventTypeEndGesture:
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 uint16_t return_value; 325 uint16_t return_value;
301 [text getCharacters:&return_value]; 326 [text getCharacters:&return_value];
302 return return_value; 327 return return_value;
303 } 328 }
304 329
305 bool IsCharFromNative(const base::NativeEvent& native_event) { 330 bool IsCharFromNative(const base::NativeEvent& native_event) {
306 return false; 331 return false;
307 } 332 }
308 333
309 } // namespace ui 334 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/events/cocoa/events_mac_unittest.mm » ('j') | ui/events/cocoa/events_mac_unittest.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698