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

Side by Side Diff: components/mus/gesture_manager.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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/gesture_manager.h ('k') | components/mus/gesture_manager_delegate.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 "components/view_manager/gesture_manager.h" 5 #include "components/mus/gesture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "components/view_manager/gesture_manager_delegate.h" 9 #include "components/mus/gesture_manager_delegate.h"
10 #include "components/view_manager/public/cpp/keys.h" 10 #include "components/mus/public/cpp/keys.h"
11 #include "components/view_manager/server_view.h" 11 #include "components/mus/server_view.h"
12 #include "components/view_manager/view_coordinate_conversions.h" 12 #include "components/mus/view_coordinate_conversions.h"
13 #include "components/view_manager/view_locator.h" 13 #include "components/mus/view_locator.h"
14 #include "ui/gfx/geometry/point_f.h" 14 #include "ui/gfx/geometry/point_f.h"
15 #include "ui/mojo/events/input_events.mojom.h" 15 #include "ui/mojo/events/input_events.mojom.h"
16 16
17 namespace view_manager { 17 namespace view_manager {
18 18
19 using Views = std::vector<const ServerView*>; 19 using Views = std::vector<const ServerView*>;
20 20
21 namespace { 21 namespace {
22 22
23 GestureManager::GestureAndConnectionId MakeGestureAndConnectionId( 23 GestureManager::GestureAndConnectionId MakeGestureAndConnectionId(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 result->pointer_data->x = target_location.x(); 61 result->pointer_data->x = target_location.x();
62 result->pointer_data->y = target_location.y(); 62 result->pointer_data->y = target_location.y();
63 return result.Pass(); 63 return result.Pass();
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 // GestureStateChange ---------------------------------------------------------- 68 // GestureStateChange ----------------------------------------------------------
69 69
70 GestureStateChange::GestureStateChange() 70 GestureStateChange::GestureStateChange()
71 : chosen_gesture(GestureManager::kInvalidGestureId) { 71 : chosen_gesture(GestureManager::kInvalidGestureId) {}
72 }
73 72
74 GestureStateChange::~GestureStateChange() { 73 GestureStateChange::~GestureStateChange() {}
75 }
76 74
77 // ViewIterator ---------------------------------------------------------------- 75 // ViewIterator ----------------------------------------------------------------
78 76
79 // Used to iterate over a set of views. 77 // Used to iterate over a set of views.
80 class ViewIterator { 78 class ViewIterator {
81 public: 79 public:
82 explicit ViewIterator(const Views& views) 80 explicit ViewIterator(const Views& views)
83 : views_(views), current_(views_.begin()) {} 81 : views_(views), current_(views_.begin()) {}
84 82
85 // Advances to the next view. Returns true if there are no more views (at 83 // Advances to the next view. Returns true if there are no more views (at
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 158 }
161 159
162 private: 160 private:
163 const uint32_t id_; 161 const uint32_t id_;
164 State state_; 162 State state_;
165 std::set<PointerAndView> pointers_and_views_; 163 std::set<PointerAndView> pointers_and_views_;
166 164
167 DISALLOW_COPY_AND_ASSIGN(Gesture); 165 DISALLOW_COPY_AND_ASSIGN(Gesture);
168 }; 166 };
169 167
170 GestureManager::Gesture::Gesture(uint32_t id) : id_(id), state_(STATE_INITIAL) { 168 GestureManager::Gesture::Gesture(uint32_t id)
171 } 169 : id_(id), state_(STATE_INITIAL) {}
172 170
173 GestureManager::Gesture::~Gesture() { 171 GestureManager::Gesture::~Gesture() {}
174 }
175 172
176 void GestureManager::Gesture::Attach(Pointer* pointer, const ServerView* view) { 173 void GestureManager::Gesture::Attach(Pointer* pointer, const ServerView* view) {
177 pointers_and_views_.insert(PointerAndView(pointer, view)); 174 pointers_and_views_.insert(PointerAndView(pointer, view));
178 } 175 }
179 176
180 void GestureManager::Gesture::Detach(Pointer* pointer, const ServerView* view) { 177 void GestureManager::Gesture::Detach(Pointer* pointer, const ServerView* view) {
181 pointers_and_views_.erase(PointerAndView(pointer, view)); 178 pointers_and_views_.erase(PointerAndView(pointer, view));
182 } 179 }
183 180
184 // Pointer --------------------------------------------------------------------- 181 // Pointer ---------------------------------------------------------------------
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 498
502 private: 499 private:
503 GestureManager* manager_; 500 GestureManager* manager_;
504 501
505 DISALLOW_COPY_AND_ASSIGN(ScheduledDeleteProcessor); 502 DISALLOW_COPY_AND_ASSIGN(ScheduledDeleteProcessor);
506 }; 503 };
507 504
508 // PointerAndView -------------------------------------------------------------- 505 // PointerAndView --------------------------------------------------------------
509 506
510 GestureManager::PointerAndView::PointerAndView() 507 GestureManager::PointerAndView::PointerAndView()
511 : pointer(nullptr), view(nullptr) { 508 : pointer(nullptr), view(nullptr) {}
512 }
513 509
514 GestureManager::PointerAndView::PointerAndView(Pointer* pointer, 510 GestureManager::PointerAndView::PointerAndView(Pointer* pointer,
515 const ServerView* view) 511 const ServerView* view)
516 : pointer(pointer), view(view) { 512 : pointer(pointer), view(view) {}
517 }
518 513
519 bool GestureManager::PointerAndView::operator<( 514 bool GestureManager::PointerAndView::operator<(
520 const PointerAndView& other) const { 515 const PointerAndView& other) const {
521 if (other.pointer->pointer_id() == pointer->pointer_id()) 516 if (other.pointer->pointer_id() == pointer->pointer_id())
522 return view->id().connection_id < other.view->id().connection_id; 517 return view->id().connection_id < other.view->id().connection_id;
523 return pointer->pointer_id() < other.pointer->pointer_id(); 518 return pointer->pointer_id() < other.pointer->pointer_id();
524 } 519 }
525 520
526 // GestureManager -------------------------------------------------------------- 521 // GestureManager --------------------------------------------------------------
527 522
528 // static 523 // static
529 const uint32_t GestureManager::kInvalidGestureId = 0u; 524 const uint32_t GestureManager::kInvalidGestureId = 0u;
530 525
531 GestureManager::GestureManager(GestureManagerDelegate* delegate, 526 GestureManager::GestureManager(GestureManagerDelegate* delegate,
532 const ServerView* root) 527 const ServerView* root)
533 : delegate_(delegate), root_view_(root) { 528 : delegate_(delegate), root_view_(root) {}
534 }
535 529
536 GestureManager::~GestureManager() { 530 GestureManager::~GestureManager() {
537 // Explicitly delete the pointers first as this may result in calling back to 531 // Explicitly delete the pointers first as this may result in calling back to
538 // us to cleanup and delete gestures. 532 // us to cleanup and delete gestures.
539 active_pointers_.clear(); 533 active_pointers_.clear();
540 } 534 }
541 535
542 bool GestureManager::ProcessEvent(const mojo::Event& event) { 536 bool GestureManager::ProcessEvent(const mojo::Event& event) {
543 if (!event.pointer_data) 537 if (!event.pointer_data)
544 return false; 538 return false;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 void GestureManager::ScheduleDelete(Pointer* pointer) { 686 void GestureManager::ScheduleDelete(Pointer* pointer) {
693 auto iter = 687 auto iter =
694 std::find(active_pointers_.begin(), active_pointers_.end(), pointer); 688 std::find(active_pointers_.begin(), active_pointers_.end(), pointer);
695 if (iter != active_pointers_.end()) { 689 if (iter != active_pointers_.end()) {
696 active_pointers_.weak_erase(iter); 690 active_pointers_.weak_erase(iter);
697 pointers_to_delete_.push_back(pointer); 691 pointers_to_delete_.push_back(pointer);
698 } 692 }
699 } 693 }
700 694
701 } // namespace view_manager 695 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/mus/gesture_manager.h ('k') | components/mus/gesture_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698