Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: ash/wm/toplevel_window_event_handler.cc

Issue 2540013005: Reland of Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Applying the fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/toplevel_window_event_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
17 #include "ui/aura/window_tracker.h"
15 #include "ui/aura/window_tree_host.h" 18 #include "ui/aura/window_tree_host.h"
16 #include "ui/base/cursor/cursor.h" 19 #include "ui/base/cursor/cursor.h"
17 #include "ui/base/hit_test.h" 20 #include "ui/base/hit_test.h"
18 #include "ui/events/event.h" 21 #include "ui/events/event.h"
19 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
20 #include "ui/events/gestures/gesture_recognizer.h" 23 #include "ui/events/gestures/gesture_recognizer.h"
21 24
22 namespace ash { 25 namespace ash {
23 26
24 ToplevelWindowEventHandler::ToplevelWindowEventHandler(WmShell* shell) 27 ToplevelWindowEventHandler::ToplevelWindowEventHandler(WmShell* shell)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 weak_factory_.GetWeakPtr(), &result, &run_loop))) { 83 weak_factory_.GetWeakPtr(), &result, &run_loop))) {
81 return aura::client::MOVE_CANCELED; 84 return aura::client::MOVE_CANCELED;
82 } 85 }
83 86
84 in_move_loop_ = true; 87 in_move_loop_ = true;
85 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr( 88 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr(
86 weak_factory_.GetWeakPtr()); 89 weak_factory_.GetWeakPtr());
87 base::MessageLoop* loop = base::MessageLoop::current(); 90 base::MessageLoop* loop = base::MessageLoop::current();
88 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); 91 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
89 92
93 // Disable window position auto management while dragging and restore it
94 // aftrewards.
95 wm::WindowState* window_state = wm::GetWindowState(source);
96 const bool window_position_managed = window_state->window_position_managed();
97 window_state->set_window_position_managed(false);
98 aura::WindowTracker tracker({source});
99
90 run_loop.Run(); 100 run_loop.Run();
91 101
92 if (!weak_ptr) 102 if (!weak_ptr)
93 return aura::client::MOVE_CANCELED; 103 return aura::client::MOVE_CANCELED;
94 104
105 // Make sure the window hasn't been deleted.
106 if (tracker.Contains(source))
107 window_state->set_window_position_managed(window_position_managed);
108
95 in_move_loop_ = false; 109 in_move_loop_ = false;
96 return result == wm::WmToplevelWindowEventHandler::DragResult::SUCCESS 110 return result == wm::WmToplevelWindowEventHandler::DragResult::SUCCESS
97 ? aura::client::MOVE_SUCCESSFUL 111 ? aura::client::MOVE_SUCCESSFUL
98 : aura::client::MOVE_CANCELED; 112 : aura::client::MOVE_CANCELED;
99 } 113 }
100 114
101 void ToplevelWindowEventHandler::EndMoveLoop() { 115 void ToplevelWindowEventHandler::EndMoveLoop() {
102 if (in_move_loop_) 116 if (in_move_loop_)
103 wm_toplevel_window_event_handler_.RevertDrag(); 117 wm_toplevel_window_event_handler_.RevertDrag();
104 } 118 }
105 119
106 void ToplevelWindowEventHandler::OnDragCompleted( 120 void ToplevelWindowEventHandler::OnDragCompleted(
107 wm::WmToplevelWindowEventHandler::DragResult* result_return_value, 121 wm::WmToplevelWindowEventHandler::DragResult* result_return_value,
108 base::RunLoop* run_loop, 122 base::RunLoop* run_loop,
109 wm::WmToplevelWindowEventHandler::DragResult result) { 123 wm::WmToplevelWindowEventHandler::DragResult result) {
110 *result_return_value = result; 124 *result_return_value = result;
111 run_loop->Quit(); 125 run_loop->Quit();
112 } 126 }
113 127
114 } // namespace ash 128 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/toplevel_window_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698