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 #include "ui/views/widget/native_widget_mac.h" | 5 #include "ui/views/widget/native_widget_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 | 495 |
496 void NativeWidgetMac::RunShellDrag(View* view, | 496 void NativeWidgetMac::RunShellDrag(View* view, |
497 const ui::OSExchangeData& data, | 497 const ui::OSExchangeData& data, |
498 const gfx::Point& location, | 498 const gfx::Point& location, |
499 int operation, | 499 int operation, |
500 ui::DragDropTypes::DragEventSource source) { | 500 ui::DragDropTypes::DragEventSource source) { |
501 NOTIMPLEMENTED(); | 501 NOTIMPLEMENTED(); |
502 } | 502 } |
503 | 503 |
504 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { | 504 void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { |
505 // TODO(tapted): This should use setNeedsDisplayInRect:, once the coordinate | 505 // |rect| is relative to coordinate system of the window. |
tapted
2016/02/05 04:51:08
is it the window or the client area? (i.e. excludi
karandeepb
2016/02/08 07:47:10
You are correct. It's the client area. Have correc
| |
506 // system of |rect| has been converted. | 506 NSRect window_frame = [GetNativeWindow() frame]; |
507 [GetNativeView() setNeedsDisplay:YES]; | 507 // Convert rect to AppKit coordinate system. |
508 NSRect target_rect_window = | |
tapted
2016/02/05 04:51:08
maybe
NSRect ns_rect = rect.ToCGRect();
ns_rect.o
karandeepb
2016/02/08 07:47:10
Done.
| |
509 NSMakeRect(rect.x(), window_frame.size.height - rect.y() - rect.height(), | |
510 rect.width(), rect.height()); | |
511 // Now target_rect is in the Appkit window's coordinate system. Convert it to | |
512 // native view's coordinate system. | |
513 NSView* native_view = GetNativeView(); | |
514 NSRect target_rect_view = | |
515 [native_view convertRect:target_rect_window fromView:nil]; | |
516 [native_view setNeedsDisplayInRect:target_rect_view]; | |
508 if (bridge_ && bridge_->layer()) | 517 if (bridge_ && bridge_->layer()) |
509 bridge_->layer()->SchedulePaint(rect); | 518 bridge_->layer()->SchedulePaint(rect); |
510 } | 519 } |
511 | 520 |
512 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { | 521 void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { |
513 if (bridge_) | 522 if (bridge_) |
514 bridge_->SetCursor(cursor); | 523 bridge_->SetCursor(cursor); |
515 } | 524 } |
516 | 525 |
517 bool NativeWidgetMac::IsMouseEventsEnabled() const { | 526 bool NativeWidgetMac::IsMouseEventsEnabled() const { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; | 730 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; |
722 } | 731 } |
723 | 732 |
724 - (void)animationDidEnd:(NSAnimation*)animation { | 733 - (void)animationDidEnd:(NSAnimation*)animation { |
725 [window_ close]; | 734 [window_ close]; |
726 [animation_ setDelegate:nil]; | 735 [animation_ setDelegate:nil]; |
727 [self release]; | 736 [self release]; |
728 } | 737 } |
729 | 738 |
730 @end | 739 @end |
OLD | NEW |