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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Forget to add these files to previous patch. Created 4 years, 1 month 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 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 "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/ws/event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "services/ui/ws/accelerator.h" 10 #include "services/ui/ws/accelerator.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 gfx::Point location = mouse_pointer_last_location_; 237 gfx::Point location = mouse_pointer_last_location_;
238 mouse_cursor_source_window_ = FindDeepestVisibleWindowForEvents(&location); 238 mouse_cursor_source_window_ = FindDeepestVisibleWindowForEvents(&location);
239 239
240 mouse_cursor_in_non_client_area_ = 240 mouse_cursor_in_non_client_area_ =
241 mouse_cursor_source_window_ 241 mouse_cursor_source_window_
242 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location) 242 ? IsLocationInNonclientArea(mouse_cursor_source_window_, location)
243 : false; 243 : false;
244 } 244 }
245 } 245 }
246 246
247 bool EventDispatcher::AddAccelerator(uint32_t id, 247 bool EventDispatcher::AddAccelerator(
248 mojom::EventMatcherPtr event_matcher) { 248 mojo::Array<ui::mojom::AcceleratorEventPtr> multi_accelerators) {
249 std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); 249 for (auto iter = multi_accelerators.begin(); iter != multi_accelerators.end();
250 // If an accelerator with the same id or matcher already exists, then abort. 250 ++iter) {
mfomitchev 2016/11/22 22:44:16 Update the comment, but don't remove it please
251 for (const auto& pair : accelerators_) { 251 std::unique_ptr<Accelerator> accelerator(
252 if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get())) 252 new Accelerator(iter->get()->id, *(iter->get()->event_matcher)));
253 return false; 253
254 bool does_accelerator_exist = false;
mfomitchev 2016/11/22 22:44:16 accelerator_exists
thanhph 2016/11/24 16:10:13 Done.
255 for (const auto& pair : accelerators_)
mfomitchev 2016/11/22 22:44:16 You need braces for multi-line body
thanhph 2016/11/24 16:10:13 Done, thanks!
256 if (pair.first == iter->get()->id ||
257 accelerator->EqualEventMatcher(pair.second.get())) {
258 does_accelerator_exist = true;
259 break;
260 }
261
262 if (!does_accelerator_exist) {
263 accelerators_.insert(Entry(iter->get()->id, std::move(accelerator)));
264 return true;
mfomitchev 2016/11/22 22:44:16 This is a bit too early to return - you've just in
thanhph 2016/11/24 16:10:13 Done, thanks!
265 }
254 } 266 }
255 accelerators_.insert(Entry(id, std::move(accelerator))); 267 return false;
256 return true;
257 } 268 }
258 269
259 void EventDispatcher::RemoveAccelerator(uint32_t id) { 270 void EventDispatcher::RemoveAccelerator(uint32_t id) {
260 auto it = accelerators_.find(id); 271 auto it = accelerators_.find(id);
261 // Clients may pass bogus ids. 272 // Clients may pass bogus ids.
262 if (it != accelerators_.end()) 273 if (it != accelerators_.end())
263 accelerators_.erase(it); 274 accelerators_.erase(it);
264 } 275 }
265 276
266 void EventDispatcher::ProcessEvent(const ui::Event& event, 277 void EventDispatcher::ProcessEvent(const ui::Event& event,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (mouse_cursor_source_window_ == window) 627 if (mouse_cursor_source_window_ == window)
617 mouse_cursor_source_window_ = nullptr; 628 mouse_cursor_source_window_ = nullptr;
618 } 629 }
619 630
620 void EventDispatcher::OnDragCursorUpdated() { 631 void EventDispatcher::OnDragCursorUpdated() {
621 delegate_->UpdateNativeCursorFromDispatcher(); 632 delegate_->UpdateNativeCursorFromDispatcher();
622 } 633 }
623 634
624 } // namespace ws 635 } // namespace ws
625 } // namespace ui 636 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698