| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 gfx::Point EventGeneratorDelegateMac::CenterOfTarget( | 422 gfx::Point EventGeneratorDelegateMac::CenterOfTarget( |
| 423 const ui::EventTarget* target) const { | 423 const ui::EventTarget* target) const { |
| 424 DCHECK_EQ(target, this); | 424 DCHECK_EQ(target, this); |
| 425 return CenterOfWindow(window_); | 425 return CenterOfWindow(window_); |
| 426 } | 426 } |
| 427 | 427 |
| 428 gfx::Point EventGeneratorDelegateMac::CenterOfWindow( | 428 gfx::Point EventGeneratorDelegateMac::CenterOfWindow( |
| 429 gfx::NativeWindow window) const { | 429 gfx::NativeWindow window) const { |
| 430 DCHECK_EQ(window, window_); | 430 DCHECK_EQ(window, window_); |
| 431 return gfx::ScreenRectFromNSRect([window frame]).CenterPoint(); | 431 // Assume the window is at the top-left of the coordinate system (even if |
| 432 // AppKit has moved it into the work area) see ConvertRootPointToTarget(). |
| 433 return gfx::Point(NSWidth([window frame]) / 2, NSHeight([window frame]) / 2); |
| 432 } | 434 } |
| 433 | 435 |
| 434 // Return the current owner of the EventGeneratorDelegate. May be null. | 436 // Return the current owner of the EventGeneratorDelegate. May be null. |
| 435 ui::test::EventGenerator* GetActiveGenerator() { | 437 ui::test::EventGenerator* GetActiveGenerator() { |
| 436 return EventGeneratorDelegateMac::GetInstance()->owner(); | 438 return EventGeneratorDelegateMac::GetInstance()->owner(); |
| 437 } | 439 } |
| 438 | 440 |
| 439 } // namespace | 441 } // namespace |
| 440 | 442 |
| 441 namespace views { | 443 namespace views { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 - (NSEvent*)currentEvent { | 491 - (NSEvent*)currentEvent { |
| 490 if (g_current_event) | 492 if (g_current_event) |
| 491 return g_current_event; | 493 return g_current_event; |
| 492 | 494 |
| 493 // Find the original implementation and invoke it. | 495 // Find the original implementation and invoke it. |
| 494 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); | 496 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); |
| 495 return original(self, _cmd); | 497 return original(self, _cmd); |
| 496 } | 498 } |
| 497 | 499 |
| 498 @end | 500 @end |
| OLD | NEW |