OLD | NEW |
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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 | 7 |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #import "base/mac/scoped_objc_class_swizzler.h" | 9 #import "base/mac/scoped_objc_class_swizzler.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // assume that the contentRect of |target| is at the top-left corner of the | 40 // assume that the contentRect of |target| is at the top-left corner of the |
41 // screen. | 41 // screen. |
42 NSRect content_rect = [target contentRectForFrameRect:[target frame]]; | 42 NSRect content_rect = [target contentRectForFrameRect:[target frame]]; |
43 return NSMakePoint(point_in_root.x(), | 43 return NSMakePoint(point_in_root.x(), |
44 NSHeight(content_rect) - point_in_root.y()); | 44 NSHeight(content_rect) - point_in_root.y()); |
45 } | 45 } |
46 | 46 |
47 // Inverse of ui::EventFlagsFromModifiers(). | 47 // Inverse of ui::EventFlagsFromModifiers(). |
48 NSUInteger EventFlagsToModifiers(int flags) { | 48 NSUInteger EventFlagsToModifiers(int flags) { |
49 NSUInteger modifiers = 0; | 49 NSUInteger modifiers = 0; |
50 modifiers |= (flags & ui::EF_CAPS_LOCK_DOWN) ? NSAlphaShiftKeyMask : 0; | |
51 modifiers |= (flags & ui::EF_SHIFT_DOWN) ? NSShiftKeyMask : 0; | 50 modifiers |= (flags & ui::EF_SHIFT_DOWN) ? NSShiftKeyMask : 0; |
52 modifiers |= (flags & ui::EF_CONTROL_DOWN) ? NSControlKeyMask : 0; | 51 modifiers |= (flags & ui::EF_CONTROL_DOWN) ? NSControlKeyMask : 0; |
53 modifiers |= (flags & ui::EF_ALT_DOWN) ? NSAlternateKeyMask : 0; | 52 modifiers |= (flags & ui::EF_ALT_DOWN) ? NSAlternateKeyMask : 0; |
54 modifiers |= (flags & ui::EF_COMMAND_DOWN) ? NSCommandKeyMask : 0; | 53 modifiers |= (flags & ui::EF_COMMAND_DOWN) ? NSCommandKeyMask : 0; |
| 54 modifiers |= (flags & ui::EF_CAPS_LOCK_ON) ? NSAlphaShiftKeyMask : 0; |
55 // ui::EF_*_MOUSE_BUTTON not handled here. | 55 // ui::EF_*_MOUSE_BUTTON not handled here. |
56 // NSFunctionKeyMask, NSNumericPadKeyMask and NSHelpKeyMask not mapped. | 56 // NSFunctionKeyMask, NSNumericPadKeyMask and NSHelpKeyMask not mapped. |
57 return modifiers; | 57 return modifiers; |
58 } | 58 } |
59 | 59 |
60 // Picks the corresponding mouse event type for the buttons set in |flags|. | 60 // Picks the corresponding mouse event type for the buttons set in |flags|. |
61 NSEventType PickMouseEventType(int flags, | 61 NSEventType PickMouseEventType(int flags, |
62 NSEventType left, | 62 NSEventType left, |
63 NSEventType right, | 63 NSEventType right, |
64 NSEventType other) { | 64 NSEventType other) { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 - (NSEvent*)currentEvent { | 483 - (NSEvent*)currentEvent { |
484 if (g_current_event) | 484 if (g_current_event) |
485 return g_current_event; | 485 return g_current_event; |
486 | 486 |
487 // Find the original implementation and invoke it. | 487 // Find the original implementation and invoke it. |
488 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); | 488 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); |
489 return original(self, _cmd); | 489 return original(self, _cmd); |
490 } | 490 } |
491 | 491 |
492 @end | 492 @end |
OLD | NEW |