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/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 return gfx::Screen::GetScreenFor(window_)-> | 641 return gfx::Screen::GetScreenFor(window_)-> |
642 GetDisplayNearestWindow(window_).work_area(); | 642 GetDisplayNearestWindow(window_).work_area(); |
643 } | 643 } |
644 | 644 |
645 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( | 645 Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( |
646 const gfx::Vector2d& drag_offset, | 646 const gfx::Vector2d& drag_offset, |
647 Widget::MoveLoopSource source, | 647 Widget::MoveLoopSource source, |
648 Widget::MoveLoopEscapeBehavior escape_behavior) { | 648 Widget::MoveLoopEscapeBehavior escape_behavior) { |
649 // |escape_behavior| is only needed on windows when running the native message | 649 // |escape_behavior| is only needed on windows when running the native message |
650 // loop. | 650 // loop. |
651 if (window_ && window_->parent() && | 651 if (!window_ || !window_->GetRootWindow()) |
652 aura::client::GetWindowMoveClient(window_->parent())) { | 652 return Widget::MOVE_LOOP_CANCELED; |
653 SetCapture(); | 653 aura::client::WindowMoveClient* move_client = |
654 aura::client::WindowMoveSource window_move_source = | 654 aura::client::GetWindowMoveClient(window_->GetRootWindow()); |
655 source == Widget::MOVE_LOOP_SOURCE_MOUSE ? | 655 if (!move_client) |
656 aura::client::WINDOW_MOVE_SOURCE_MOUSE : | 656 return Widget::MOVE_LOOP_CANCELED; |
657 aura::client::WINDOW_MOVE_SOURCE_TOUCH; | 657 |
658 if (aura::client::GetWindowMoveClient(window_->parent())->RunMoveLoop( | 658 SetCapture(); |
659 window_, drag_offset, window_move_source) == | 659 aura::client::WindowMoveSource window_move_source = |
660 aura::client::MOVE_SUCCESSFUL) { | 660 source == Widget::MOVE_LOOP_SOURCE_MOUSE ? |
661 return Widget::MOVE_LOOP_SUCCESSFUL; | 661 aura::client::WINDOW_MOVE_SOURCE_MOUSE : |
662 } | 662 aura::client::WINDOW_MOVE_SOURCE_TOUCH; |
| 663 if (move_client->RunMoveLoop(window_, drag_offset, window_move_source) == |
| 664 aura::client::MOVE_SUCCESSFUL) { |
| 665 return Widget::MOVE_LOOP_SUCCESSFUL; |
663 } | 666 } |
664 return Widget::MOVE_LOOP_CANCELED; | 667 return Widget::MOVE_LOOP_CANCELED; |
665 } | 668 } |
666 | 669 |
667 void NativeWidgetAura::EndMoveLoop() { | 670 void NativeWidgetAura::EndMoveLoop() { |
668 if (window_ && window_->parent() && | 671 if (!window_ || !window_->GetRootWindow()) |
669 aura::client::GetWindowMoveClient(window_->parent())) { | 672 return; |
670 aura::client::GetWindowMoveClient(window_->parent())->EndMoveLoop(); | 673 aura::client::WindowMoveClient* move_client = |
671 } | 674 aura::client::GetWindowMoveClient(window_->GetRootWindow()); |
| 675 if (move_client) |
| 676 move_client->EndMoveLoop(); |
672 } | 677 } |
673 | 678 |
674 void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { | 679 void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { |
675 if (window_) | 680 if (window_) |
676 window_->SetProperty(aura::client::kAnimationsDisabledKey, !value); | 681 window_->SetProperty(aura::client::kAnimationsDisabledKey, !value); |
677 } | 682 } |
678 | 683 |
679 ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const { | 684 ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const { |
680 #if !defined(OS_CHROMEOS) | 685 #if !defined(OS_CHROMEOS) |
681 return DesktopRootWindowHost::GetNativeTheme(window_); | 686 return DesktopRootWindowHost::GetNativeTheme(window_); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 return aura::Env::GetInstance()->IsMouseButtonDown(); | 1148 return aura::Env::GetInstance()->IsMouseButtonDown(); |
1144 } | 1149 } |
1145 | 1150 |
1146 // static | 1151 // static |
1147 bool NativeWidgetPrivate::IsTouchDown() { | 1152 bool NativeWidgetPrivate::IsTouchDown() { |
1148 return aura::Env::GetInstance()->is_touch_down(); | 1153 return aura::Env::GetInstance()->is_touch_down(); |
1149 } | 1154 } |
1150 | 1155 |
1151 } // namespace internal | 1156 } // namespace internal |
1152 } // namespace views | 1157 } // namespace views |
OLD | NEW |