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

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

Issue 2905893002: chromeos: convert more ash/wm code to aura::Window (Closed)
Patch Set: moar cleanup Created 3 years, 7 months 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
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/window_state.h" 8 #include "ash/wm/window_state.h"
9 #include "ash/wm_window.h"
10 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 10 #include "base/run_loop.h"
12 #include "ui/aura/client/cursor_client.h" 11 #include "ui/aura/client/cursor_client.h"
13 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
14 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/aura/window_tracker.h" 15 #include "ui/aura/window_tracker.h"
17 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
18 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
19 #include "ui/base/hit_test.h" 18 #include "ui/base/hit_test.h"
20 #include "ui/events/event.h" 19 #include "ui/events/event.h"
21 #include "ui/events/event_utils.h" 20 #include "ui/events/event_utils.h"
22 #include "ui/events/gestures/gesture_recognizer.h" 21 #include "ui/events/gestures/gesture_recognizer.h"
23 22
24 namespace ash { 23 namespace ash {
25 24
26 ToplevelWindowEventHandler::ToplevelWindowEventHandler() 25 ToplevelWindowEventHandler::ToplevelWindowEventHandler()
27 : weak_factory_(this) {} 26 : weak_factory_(this) {}
28 27
29 ToplevelWindowEventHandler::~ToplevelWindowEventHandler() {} 28 ToplevelWindowEventHandler::~ToplevelWindowEventHandler() {}
30 29
31 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) { 30 void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
32 wm_toplevel_window_event_handler_.OnKeyEvent(event); 31 wm_toplevel_window_event_handler_.OnKeyEvent(event);
33 } 32 }
34 33
35 void ToplevelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) { 34 void ToplevelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event) {
36 aura::Window* target = static_cast<aura::Window*>(event->target()); 35 aura::Window* target = static_cast<aura::Window*>(event->target());
37 wm_toplevel_window_event_handler_.OnMouseEvent(event, WmWindow::Get(target)); 36 wm_toplevel_window_event_handler_.OnMouseEvent(event, target);
38 } 37 }
39 38
40 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { 39 void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
41 aura::Window* target = static_cast<aura::Window*>(event->target()); 40 aura::Window* target = static_cast<aura::Window*>(event->target());
42 wm_toplevel_window_event_handler_.OnGestureEvent(event, 41 wm_toplevel_window_event_handler_.OnGestureEvent(event, target);
43 WmWindow::Get(target));
44 } 42 }
45 43
46 aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop( 44 aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop(
47 aura::Window* source, 45 aura::Window* source,
48 const gfx::Vector2d& drag_offset, 46 const gfx::Vector2d& drag_offset,
49 aura::client::WindowMoveSource move_source) { 47 aura::client::WindowMoveSource move_source) {
50 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 48 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
51 aura::Window* root_window = source->GetRootWindow(); 49 aura::Window* root_window = source->GetRootWindow();
52 DCHECK(root_window); 50 DCHECK(root_window);
53 gfx::Point drag_location; 51 gfx::Point drag_location;
(...skipping 15 matching lines...) Expand all
69 aura::client::CursorClient* cursor_client = 67 aura::client::CursorClient* cursor_client =
70 aura::client::GetCursorClient(root_window); 68 aura::client::GetCursorClient(root_window);
71 if (cursor_client) 69 if (cursor_client)
72 cursor_client->SetCursor(ui::CursorType::kPointer); 70 cursor_client->SetCursor(ui::CursorType::kPointer);
73 71
74 base::RunLoop run_loop; 72 base::RunLoop run_loop;
75 73
76 wm::WmToplevelWindowEventHandler::DragResult result = 74 wm::WmToplevelWindowEventHandler::DragResult result =
77 wm::WmToplevelWindowEventHandler::DragResult::SUCCESS; 75 wm::WmToplevelWindowEventHandler::DragResult::SUCCESS;
78 if (!wm_toplevel_window_event_handler_.AttemptToStartDrag( 76 if (!wm_toplevel_window_event_handler_.AttemptToStartDrag(
79 WmWindow::Get(source), drag_location, HTCAPTION, move_source, 77 source, drag_location, HTCAPTION, move_source,
80 base::Bind(&ToplevelWindowEventHandler::OnDragCompleted, 78 base::Bind(&ToplevelWindowEventHandler::OnDragCompleted,
81 weak_factory_.GetWeakPtr(), &result, &run_loop))) { 79 weak_factory_.GetWeakPtr(), &result, &run_loop))) {
82 return aura::client::MOVE_CANCELED; 80 return aura::client::MOVE_CANCELED;
83 } 81 }
84 82
85 in_move_loop_ = true; 83 in_move_loop_ = true;
86 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr( 84 base::WeakPtr<ToplevelWindowEventHandler> weak_ptr(
87 weak_factory_.GetWeakPtr()); 85 weak_factory_.GetWeakPtr());
88 base::MessageLoop* loop = base::MessageLoop::current(); 86 base::MessageLoop* loop = base::MessageLoop::current();
89 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); 87 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
(...skipping 27 matching lines...) Expand all
117 115
118 void ToplevelWindowEventHandler::OnDragCompleted( 116 void ToplevelWindowEventHandler::OnDragCompleted(
119 wm::WmToplevelWindowEventHandler::DragResult* result_return_value, 117 wm::WmToplevelWindowEventHandler::DragResult* result_return_value,
120 base::RunLoop* run_loop, 118 base::RunLoop* run_loop,
121 wm::WmToplevelWindowEventHandler::DragResult result) { 119 wm::WmToplevelWindowEventHandler::DragResult result) {
122 *result_return_value = result; 120 *result_return_value = result;
123 run_loop->Quit(); 121 run_loop->Quit();
124 } 122 }
125 123
126 } // namespace ash 124 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698