| 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 "ash/wm/toplevel_window_event_handler.h" | 5 #include "ash/wm/toplevel_window_event_handler.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/window_state_aura.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 11 #include "ui/aura/client/cursor_client.h" | 13 #include "ui/aura/client/cursor_client.h" |
| 12 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
| 13 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
| 16 #include "ui/base/cursor/cursor.h" | 18 #include "ui/base/cursor/cursor.h" |
| 17 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 18 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 weak_factory_.GetWeakPtr(), &result, &run_loop))) { | 82 weak_factory_.GetWeakPtr(), &result, &run_loop))) { |
| 81 return aura::client::MOVE_CANCELED; | 83 return aura::client::MOVE_CANCELED; |
| 82 } | 84 } |
| 83 | 85 |
| 84 in_move_loop_ = true; | 86 in_move_loop_ = true; |
| 85 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr( | 87 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr( |
| 86 weak_factory_.GetWeakPtr()); | 88 weak_factory_.GetWeakPtr()); |
| 87 base::MessageLoop* loop = base::MessageLoop::current(); | 89 base::MessageLoop* loop = base::MessageLoop::current(); |
| 88 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); | 90 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
| 89 | 91 |
| 92 // Disable window position auto management while dragging and restore it |
| 93 // aftrewards. |
| 94 wm::WindowState* window_state = wm::GetWindowState(source); |
| 95 const bool window_position_managed = window_state->window_position_managed(); |
| 96 window_state->set_window_position_managed(false); |
| 97 |
| 90 run_loop.Run(); | 98 run_loop.Run(); |
| 91 | 99 |
| 92 if (!weak_ptr) | 100 if (!weak_ptr) |
| 93 return aura::client::MOVE_CANCELED; | 101 return aura::client::MOVE_CANCELED; |
| 94 | 102 |
| 103 window_state->set_window_position_managed(window_position_managed); |
| 104 |
| 95 in_move_loop_ = false; | 105 in_move_loop_ = false; |
| 96 return result == wm::WmToplevelWindowEventHandler::DragResult::SUCCESS | 106 return result == wm::WmToplevelWindowEventHandler::DragResult::SUCCESS |
| 97 ? aura::client::MOVE_SUCCESSFUL | 107 ? aura::client::MOVE_SUCCESSFUL |
| 98 : aura::client::MOVE_CANCELED; | 108 : aura::client::MOVE_CANCELED; |
| 99 } | 109 } |
| 100 | 110 |
| 101 void ToplevelWindowEventHandler::EndMoveLoop() { | 111 void ToplevelWindowEventHandler::EndMoveLoop() { |
| 102 if (in_move_loop_) | 112 if (in_move_loop_) |
| 103 wm_toplevel_window_event_handler_.RevertDrag(); | 113 wm_toplevel_window_event_handler_.RevertDrag(); |
| 104 } | 114 } |
| 105 | 115 |
| 106 void ToplevelWindowEventHandler::OnDragCompleted( | 116 void ToplevelWindowEventHandler::OnDragCompleted( |
| 107 wm::WmToplevelWindowEventHandler::DragResult* result_return_value, | 117 wm::WmToplevelWindowEventHandler::DragResult* result_return_value, |
| 108 base::RunLoop* run_loop, | 118 base::RunLoop* run_loop, |
| 109 wm::WmToplevelWindowEventHandler::DragResult result) { | 119 wm::WmToplevelWindowEventHandler::DragResult result) { |
| 110 *result_return_value = result; | 120 *result_return_value = result; |
| 111 run_loop->Quit(); | 121 run_loop->Quit(); |
| 112 } | 122 } |
| 113 | 123 |
| 114 } // namespace ash | 124 } // namespace ash |
| OLD | NEW |