| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/activation_client.h" | 8 #include "ui/aura/client/activation_client.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" |
| 10 #include "ui/aura/client/stacking_client.h" | 11 #include "ui/aura/client/stacking_client.h" |
| 11 #include "ui/aura/focus_manager.h" | 12 #include "ui/aura/focus_manager.h" |
| 12 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/root_window_host.h" | 14 #include "ui/aura/root_window_host.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 16 #include "ui/aura/window_property.h" | 17 #include "ui/aura/window_property.h" |
| 17 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
| 18 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
| 19 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 161 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
| 161 internal::NativeWidgetDelegate* delegate) | 162 internal::NativeWidgetDelegate* delegate) |
| 162 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 163 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 163 close_widget_factory_(this), | 164 close_widget_factory_(this), |
| 164 can_activate_(true), | 165 can_activate_(true), |
| 165 desktop_root_window_host_(NULL), | 166 desktop_root_window_host_(NULL), |
| 166 window_(new aura::Window(this)), | 167 window_(new aura::Window(this)), |
| 167 native_widget_delegate_(delegate), | 168 native_widget_delegate_(delegate), |
| 168 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), | 169 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| 169 restore_focus_on_activate_(false) { | 170 restore_focus_on_activate_(false), |
| 171 cursor_(gfx::kNullCursor) { |
| 170 window_->SetProperty(kDesktopNativeWidgetAuraKey, this); | 172 window_->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 171 aura::client::SetFocusChangeObserver(window_, this); | 173 aura::client::SetFocusChangeObserver(window_, this); |
| 172 aura::client::SetActivationChangeObserver(window_, this); | 174 aura::client::SetActivationChangeObserver(window_, this); |
| 173 } | 175 } |
| 174 | 176 |
| 175 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { | 177 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { |
| 176 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 178 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 177 delete native_widget_delegate_; | 179 delete native_widget_delegate_; |
| 178 else | 180 else |
| 179 CloseNow(); | 181 CloseNow(); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 ui::DragDropTypes::DragEventSource source) { | 545 ui::DragDropTypes::DragEventSource source) { |
| 544 views::RunShellDrag(window_, data, location, operation, source); | 546 views::RunShellDrag(window_, data, location, operation, source); |
| 545 } | 547 } |
| 546 | 548 |
| 547 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 549 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
| 548 if (window_) | 550 if (window_) |
| 549 window_->SchedulePaintInRect(rect); | 551 window_->SchedulePaintInRect(rect); |
| 550 } | 552 } |
| 551 | 553 |
| 552 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 554 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
| 553 desktop_root_window_host_->AsRootWindowHost()->SetCursor(cursor); | 555 cursor_ = cursor; |
| 556 aura::client::CursorClient* cursor_client = |
| 557 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 558 if (cursor_client) |
| 559 cursor_client->SetCursor(cursor); |
| 554 } | 560 } |
| 555 | 561 |
| 556 bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const { | 562 bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const { |
| 557 return true; | 563 aura::client::CursorClient* cursor_client = |
| 564 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 565 return cursor_client ? cursor_client->IsMouseEventsEnabled() : true; |
| 558 } | 566 } |
| 559 | 567 |
| 560 void DesktopNativeWidgetAura::ClearNativeFocus() { | 568 void DesktopNativeWidgetAura::ClearNativeFocus() { |
| 561 desktop_root_window_host_->ClearNativeFocus(); | 569 desktop_root_window_host_->ClearNativeFocus(); |
| 562 | 570 |
| 563 if (ShouldActivate()) { | 571 if (ShouldActivate()) { |
| 564 aura::client::GetFocusClient(window_)-> | 572 aura::client::GetFocusClient(window_)-> |
| 565 ResetFocusWithinActiveWindow(window_); | 573 ResetFocusWithinActiveWindow(window_); |
| 566 } | 574 } |
| 567 } | 575 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 620 |
| 613 void DesktopNativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, | 621 void DesktopNativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, |
| 614 const gfx::Rect& new_bounds) { | 622 const gfx::Rect& new_bounds) { |
| 615 if (old_bounds.origin() != new_bounds.origin()) | 623 if (old_bounds.origin() != new_bounds.origin()) |
| 616 native_widget_delegate_->OnNativeWidgetMove(); | 624 native_widget_delegate_->OnNativeWidgetMove(); |
| 617 if (old_bounds.size() != new_bounds.size()) | 625 if (old_bounds.size() != new_bounds.size()) |
| 618 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 626 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
| 619 } | 627 } |
| 620 | 628 |
| 621 gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { | 629 gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { |
| 622 return gfx::kNullCursor; | 630 return cursor_; |
| 623 } | 631 } |
| 624 | 632 |
| 625 int DesktopNativeWidgetAura::GetNonClientComponent( | 633 int DesktopNativeWidgetAura::GetNonClientComponent( |
| 626 const gfx::Point& point) const { | 634 const gfx::Point& point) const { |
| 627 return native_widget_delegate_->GetNonClientComponent(point); | 635 return native_widget_delegate_->GetNonClientComponent(point); |
| 628 } | 636 } |
| 629 | 637 |
| 630 bool DesktopNativeWidgetAura::ShouldDescendIntoChildForEventHandling( | 638 bool DesktopNativeWidgetAura::ShouldDescendIntoChildForEventHandling( |
| 631 aura::Window* child, | 639 aura::Window* child, |
| 632 const gfx::Point& location) { | 640 const gfx::Point& location) { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 } | 875 } |
| 868 | 876 |
| 869 //////////////////////////////////////////////////////////////////////////////// | 877 //////////////////////////////////////////////////////////////////////////////// |
| 870 // DesktopNativeWidgetAura, NativeWidget implementation: | 878 // DesktopNativeWidgetAura, NativeWidget implementation: |
| 871 | 879 |
| 872 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 880 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
| 873 return this; | 881 return this; |
| 874 } | 882 } |
| 875 | 883 |
| 876 } // namespace views | 884 } // namespace views |
| OLD | NEW |