| OLD | NEW |
| 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 #import "ui/base/cocoa/command_dispatcher.h" | 5 #import "ui/base/cocoa/command_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 8 | 9 |
| 9 namespace { | 10 namespace { |
| 10 | 11 |
| 11 // Duplicate the given key event, but changing the associated window. | 12 // Duplicate the given key event, but changing the associated window. |
| 12 NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) { | 13 NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) { |
| 13 NSEventType event_type = [event type]; | 14 NSEventType event_type = [event type]; |
| 14 | 15 |
| 15 // Convert the event's location from the original window's coordinates into | 16 // Convert the event's location from the original window's coordinates into |
| 16 // our own. | 17 // our own. |
| 17 NSPoint location = [event locationInWindow]; | 18 NSPoint location = [event locationInWindow]; |
| 18 location = [[event window] convertBaseToScreen:location]; | 19 location = ui::ConvertPointFromWindowToScreen([event window], location); |
| 19 location = [window convertScreenToBase:location]; | 20 location = ui::ConvertPointFromScreenToWindow(window, location); |
| 20 | 21 |
| 21 // Various things *only* apply to key down/up. | 22 // Various things *only* apply to key down/up. |
| 22 bool is_a_repeat = false; | 23 bool is_a_repeat = false; |
| 23 NSString* characters = nil; | 24 NSString* characters = nil; |
| 24 NSString* charactors_ignoring_modifiers = nil; | 25 NSString* charactors_ignoring_modifiers = nil; |
| 25 if (event_type == NSKeyDown || event_type == NSKeyUp) { | 26 if (event_type == NSKeyDown || event_type == NSKeyUp) { |
| 26 is_a_repeat = [event isARepeat]; | 27 is_a_repeat = [event isARepeat]; |
| 27 characters = [event characters]; | 28 characters = [event characters]; |
| 28 charactors_ignoring_modifiers = [event charactersIgnoringModifiers]; | 29 charactors_ignoring_modifiers = [event charactersIgnoringModifiers]; |
| 29 } | 30 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // If we get here, then the event was not handled by NSApplication. | 122 // If we get here, then the event was not handled by NSApplication. |
| 122 eventHandled_ = NO; | 123 eventHandled_ = NO; |
| 123 // Return YES to stop native -sendEvent handling. | 124 // Return YES to stop native -sendEvent handling. |
| 124 return YES; | 125 return YES; |
| 125 } | 126 } |
| 126 | 127 |
| 127 return NO; | 128 return NO; |
| 128 } | 129 } |
| 129 | 130 |
| 130 @end | 131 @end |
| OLD | NEW |