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

Side by Side Diff: mash/wm/frame/move_event_handler.cc

Issue 1814533002: Use ui::Event instead of mojom::EventPtr in mash/wm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_eventptr
Patch Set: Created 4 years, 9 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
« no previous file with comments | « components/mus/ws/window_manager_client_unittest.cc ('k') | mash/wm/frame/move_loop.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/frame/move_event_handler.h" 5 #include "mash/wm/frame/move_event_handler.h"
6 6
7 #include "components/mus/public/cpp/window.h" 7 #include "components/mus/public/cpp/window.h"
8 #include "components/mus/public/interfaces/cursor.mojom.h" 8 #include "components/mus/public/interfaces/cursor.mojom.h"
9 #include "mash/wm/frame/move_loop.h" 9 #include "mash/wm/frame/move_loop.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 10 #include "mojo/converters/input_events/input_events_type_converters.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 root_window_->AddObserver(this); 49 root_window_->AddObserver(this);
50 root_window_->AddPreTargetHandler(this); 50 root_window_->AddPreTargetHandler(this);
51 } 51 }
52 52
53 MoveEventHandler::~MoveEventHandler() { 53 MoveEventHandler::~MoveEventHandler() {
54 Detach(); 54 Detach();
55 } 55 }
56 56
57 void MoveEventHandler::ProcessLocatedEvent(ui::LocatedEvent* event) { 57 void MoveEventHandler::ProcessLocatedEvent(ui::LocatedEvent* event) {
58 const bool had_move_loop = move_loop_.get() != nullptr; 58 const bool had_move_loop = move_loop_.get() != nullptr;
59 ui::Event* ui_event = static_cast<ui::Event*>(event); 59 DCHECK(event->IsMouseEvent() || event->IsTouchEvent());
60
61 // TODO(moshayedi): no need for this once MoveEventHandler directly receives
62 // pointer events.
63 scoped_ptr<ui::PointerEvent> pointer_event;
64 if (event->IsMouseEvent())
65 pointer_event.reset(new ui::PointerEvent(*event->AsMouseEvent()));
66 else
67 pointer_event.reset(new ui::PointerEvent(*event->AsTouchEvent()));
68
60 if (move_loop_) { 69 if (move_loop_) {
61 if (move_loop_->Move(*mus::mojom::Event::From(*ui_event)) == MoveLoop::DONE) 70 if (move_loop_->Move(*pointer_event.get()) == MoveLoop::DONE)
62 move_loop_.reset(); 71 move_loop_.reset();
63 } else if (event->type() == ui::ET_MOUSE_PRESSED || 72 } else if (pointer_event->type() == ui::ET_POINTER_DOWN) {
64 event->type() == ui::ET_TOUCH_PRESSED) { 73 const int ht_location = GetNonClientComponentForEvent(pointer_event.get());
65 const int ht_location = GetNonClientComponentForEvent(event);
66 if (ht_location != HTNOWHERE) { 74 if (ht_location != HTNOWHERE) {
67 // TODO(sky): convert MoveLoop to take ui::Event. 75 move_loop_ =
68 move_loop_ = MoveLoop::Create(mus_window_, ht_location, 76 MoveLoop::Create(mus_window_, ht_location, *pointer_event.get());
69 *mus::mojom::Event::From(*ui_event));
70 } 77 }
71 } else if (event->type() == ui::ET_MOUSE_MOVED) { 78 } else if (pointer_event->type() == ui::ET_POINTER_MOVED) {
72 const int ht_location = GetNonClientComponentForEvent(event); 79 const int ht_location = GetNonClientComponentForEvent(pointer_event.get());
73 mus_window_->SetPredefinedCursor(CursorForWindowComponent(ht_location)); 80 mus_window_->SetPredefinedCursor(CursorForWindowComponent(ht_location));
74 } 81 }
75 if (had_move_loop || move_loop_) 82 if (had_move_loop || move_loop_)
76 event->SetHandled(); 83 event->SetHandled();
77 } 84 }
78 85
79 int MoveEventHandler::GetNonClientComponentForEvent( 86 int MoveEventHandler::GetNonClientComponentForEvent(
80 const ui::LocatedEvent* event) { 87 const ui::LocatedEvent* event) {
81 return aura_window_->delegate()->GetNonClientComponent(event->location()); 88 return aura_window_->delegate()->GetNonClientComponent(event->location());
82 } 89 }
(...skipping 24 matching lines...) Expand all
107 event->SetHandled(); 114 event->SetHandled();
108 } 115 }
109 116
110 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { 117 void MoveEventHandler::OnWindowDestroying(aura::Window* window) {
111 DCHECK_EQ(root_window_, window); 118 DCHECK_EQ(root_window_, window);
112 Detach(); 119 Detach();
113 } 120 }
114 121
115 } // namespace wm 122 } // namespace wm
116 } // namespace mash 123 } // namespace mash
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_client_unittest.cc ('k') | mash/wm/frame/move_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698