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

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

Issue 2830703003: [views-mus] Support custom cursors. (Closed)
Patch Set: fix cast_shell_linux 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
« no previous file with comments | « services/ui/ws/event_dispatcher.h ('k') | services/ui/ws/platform_display.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 "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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "services/ui/ws/accelerator.h" 11 #include "services/ui/ws/accelerator.h"
12 #include "services/ui/ws/drag_controller.h" 12 #include "services/ui/ws/drag_controller.h"
13 #include "services/ui/ws/drag_source.h" 13 #include "services/ui/ws/drag_source.h"
14 #include "services/ui/ws/event_dispatcher_delegate.h" 14 #include "services/ui/ws/event_dispatcher_delegate.h"
15 #include "services/ui/ws/server_window.h" 15 #include "services/ui/ws/server_window.h"
16 #include "services/ui/ws/server_window_delegate.h" 16 #include "services/ui/ws/server_window_delegate.h"
17 #include "services/ui/ws/window_coordinate_conversions.h" 17 #include "services/ui/ws/window_coordinate_conversions.h"
18 #include "services/ui/ws/window_finder.h" 18 #include "services/ui/ws/window_finder.h"
19 #include "ui/base/cursor/cursor.h"
19 #include "ui/events/event_utils.h" 20 #include "ui/events/event_utils.h"
20 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
21 #include "ui/gfx/geometry/point_conversions.h" 22 #include "ui/gfx/geometry/point_conversions.h"
22 23
23 namespace ui { 24 namespace ui {
24 namespace ws { 25 namespace ws {
25 26
26 using Entry = std::pair<uint32_t, std::unique_ptr<Accelerator>>; 27 using Entry = std::pair<uint32_t, std::unique_ptr<Accelerator>>;
27 28
28 namespace { 29 namespace {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const gfx::Point& screen_location) { 80 const gfx::Point& screen_location) {
80 DCHECK(pointer_targets_.empty()); 81 DCHECK(pointer_targets_.empty());
81 mouse_pointer_last_location_ = screen_location; 82 mouse_pointer_last_location_ = screen_location;
82 UpdateCursorProviderByLastKnownLocation(); 83 UpdateCursorProviderByLastKnownLocation();
83 // Write our initial location back to our shared screen coordinate. This 84 // Write our initial location back to our shared screen coordinate. This
84 // shouldn't cause problems because we already read the cursor before we 85 // shouldn't cause problems because we already read the cursor before we
85 // process any events in views during window construction. 86 // process any events in views during window construction.
86 delegate_->OnMouseCursorLocationChanged(screen_location); 87 delegate_->OnMouseCursorLocationChanged(screen_location);
87 } 88 }
88 89
89 ui::mojom::CursorType EventDispatcher::GetCurrentMouseCursor() const { 90 ui::CursorData EventDispatcher::GetCurrentMouseCursor() const {
90 if (drag_controller_) 91 if (drag_controller_)
91 return drag_controller_->current_cursor(); 92 return drag_controller_->current_cursor();
92 93
93 if (!mouse_cursor_source_window_) 94 if (!mouse_cursor_source_window_)
94 return ui::mojom::CursorType::kPointer; 95 return ui::CursorData(ui::CursorType::kPointer);
95 96
96 if (mouse_cursor_in_non_client_area_) 97 if (mouse_cursor_in_non_client_area_)
97 return mouse_cursor_source_window_->non_client_cursor(); 98 return mouse_cursor_source_window_->non_client_cursor();
98 99
99 const ServerWindow* window = GetWindowForMouseCursor(); 100 const ServerWindow* window = GetWindowForMouseCursor();
100 return window ? window->cursor() : ui::mojom::CursorType::kPointer; 101 return window ? window->cursor() : ui::CursorData(ui::CursorType::kPointer);
101 } 102 }
102 103
103 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, 104 bool EventDispatcher::SetCaptureWindow(ServerWindow* window,
104 ClientSpecificId client_id) { 105 ClientSpecificId client_id) {
105 if (!window) 106 if (!window)
106 client_id = kInvalidClientId; 107 client_id = kInvalidClientId;
107 108
108 if (window == capture_window_ && client_id == capture_window_client_id_) 109 if (window == capture_window_ && client_id == capture_window_client_id_)
109 return true; 110 return true;
110 111
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if (mouse_cursor_source_window_ == window) 653 if (mouse_cursor_source_window_ == window)
653 SetMouseCursorSourceWindow(nullptr); 654 SetMouseCursorSourceWindow(nullptr);
654 } 655 }
655 656
656 void EventDispatcher::OnDragCursorUpdated() { 657 void EventDispatcher::OnDragCursorUpdated() {
657 delegate_->UpdateNativeCursorFromDispatcher(); 658 delegate_->UpdateNativeCursorFromDispatcher();
658 } 659 }
659 660
660 } // namespace ws 661 } // namespace ws
661 } // namespace ui 662 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/event_dispatcher.h ('k') | services/ui/ws/platform_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698