| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (owner_->targeting_application()) | 356 if (owner_->targeting_application()) |
| 357 [NSApp sendEvent:ns_event]; | 357 [NSApp sendEvent:ns_event]; |
| 358 else | 358 else |
| 359 EmulateSendEvent(window_, ns_event); | 359 EmulateSendEvent(window_, ns_event); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void EventGeneratorDelegateMac::OnKeyEvent(ui::KeyEvent* event) { | 362 void EventGeneratorDelegateMac::OnKeyEvent(ui::KeyEvent* event) { |
| 363 NSUInteger modifiers = EventFlagsToModifiers(event->flags()); | 363 NSUInteger modifiers = EventFlagsToModifiers(event->flags()); |
| 364 NSEvent* ns_event = cocoa_test_event_utils::SynthesizeKeyEvent( | 364 NSEvent* ns_event = cocoa_test_event_utils::SynthesizeKeyEvent( |
| 365 window_, event->type() == ui::ET_KEY_PRESSED, event->key_code(), | 365 window_, event->type() == ui::ET_KEY_PRESSED, event->key_code(), |
| 366 modifiers); | 366 modifiers, event->is_char() ? event->GetDomKey() : ui::DomKey::NONE); |
| 367 if (owner_->targeting_application()) { | 367 if (owner_->targeting_application()) { |
| 368 [NSApp sendEvent:ns_event]; | 368 [NSApp sendEvent:ns_event]; |
| 369 return; | 369 return; |
| 370 } | 370 } |
| 371 | 371 |
| 372 if ([fake_menu_ performKeyEquivalent:ns_event]) | 372 if ([fake_menu_ performKeyEquivalent:ns_event]) |
| 373 return; | 373 return; |
| 374 | 374 |
| 375 EmulateSendEvent(window_, ns_event); | 375 EmulateSendEvent(window_, ns_event); |
| 376 } | 376 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 - (NSEvent*)currentEvent { | 484 - (NSEvent*)currentEvent { |
| 485 if (g_current_event) | 485 if (g_current_event) |
| 486 return g_current_event; | 486 return g_current_event; |
| 487 | 487 |
| 488 // Find the original implementation and invoke it. | 488 // Find the original implementation and invoke it. |
| 489 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); | 489 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); |
| 490 return original(self, _cmd); | 490 return original(self, _cmd); |
| 491 } | 491 } |
| 492 | 492 |
| 493 @end | 493 @end |
| OLD | NEW |