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

Side by Side Diff: mash/simple_wm/move_event_handler.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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/simple_wm/move_event_handler.h" 5 #include "mash/simple_wm/move_event_handler.h"
6 6
7 #include "mash/simple_wm/move_loop.h" 7 #include "mash/simple_wm/move_loop.h"
8 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" 8 #include "services/ui/public/interfaces/cursor/cursor.mojom.h"
9 #include "ui/aura/mus/window_port_mus.h" 9 #include "ui/aura/mus/window_port_mus.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura/window_delegate.h" 11 #include "ui/aura/window_delegate.h"
12 #include "ui/base/cursor/cursor.h"
12 #include "ui/base/hit_test.h" 13 #include "ui/base/hit_test.h"
13 #include "ui/events/event.h" 14 #include "ui/events/event.h"
14 15
15 namespace simple_wm { 16 namespace simple_wm {
16 namespace { 17 namespace {
17 18
18 ui::mojom::CursorType CursorForWindowComponent(int window_component) { 19 ui::CursorType CursorForWindowComponent(int window_component) {
19 switch (window_component) { 20 switch (window_component) {
20 case HTBOTTOM: 21 case HTBOTTOM:
21 return ui::mojom::CursorType::kSouthResize; 22 return ui::CursorType::kSouthResize;
22 case HTBOTTOMLEFT: 23 case HTBOTTOMLEFT:
23 return ui::mojom::CursorType::kSouthWestResize; 24 return ui::CursorType::kSouthWestResize;
24 case HTBOTTOMRIGHT: 25 case HTBOTTOMRIGHT:
25 return ui::mojom::CursorType::kSouthEastResize; 26 return ui::CursorType::kSouthEastResize;
26 case HTLEFT: 27 case HTLEFT:
27 return ui::mojom::CursorType::kWestResize; 28 return ui::CursorType::kWestResize;
28 case HTRIGHT: 29 case HTRIGHT:
29 return ui::mojom::CursorType::kEastResize; 30 return ui::CursorType::kEastResize;
30 case HTTOP: 31 case HTTOP:
31 return ui::mojom::CursorType::kNorthResize; 32 return ui::CursorType::kNorthResize;
32 case HTTOPLEFT: 33 case HTTOPLEFT:
33 return ui::mojom::CursorType::kNorthWestResize; 34 return ui::CursorType::kNorthWestResize;
34 case HTTOPRIGHT: 35 case HTTOPRIGHT:
35 return ui::mojom::CursorType::kNorthEastResize; 36 return ui::CursorType::kNorthEastResize;
36 default: 37 default:
37 return ui::mojom::CursorType::kNull; 38 return ui::CursorType::kNull;
38 } 39 }
39 } 40 }
40 41
41 } // namespace 42 } // namespace
42 43
43 MoveEventHandler::MoveEventHandler(aura::Window* window) 44 MoveEventHandler::MoveEventHandler(aura::Window* window)
44 : window_(window) { 45 : window_(window) {
45 window_->AddObserver(this); 46 window_->AddObserver(this);
46 window_->AddPreTargetHandler(this); 47 window_->AddPreTargetHandler(this);
47 } 48 }
(...skipping 23 matching lines...) Expand all
71 if (move_loop_) { 72 if (move_loop_) {
72 if (move_loop_->Move(*pointer_event.get()) == MoveLoop::DONE) 73 if (move_loop_->Move(*pointer_event.get()) == MoveLoop::DONE)
73 move_loop_.reset(); 74 move_loop_.reset();
74 } else if (pointer_event->type() == ui::ET_POINTER_DOWN) { 75 } else if (pointer_event->type() == ui::ET_POINTER_DOWN) {
75 const int ht_location = 76 const int ht_location =
76 GetNonClientComponentForEvent(pointer_event.get()); 77 GetNonClientComponentForEvent(pointer_event.get());
77 if (ht_location != HTNOWHERE) 78 if (ht_location != HTNOWHERE)
78 move_loop_ = MoveLoop::Create(window_, ht_location, *pointer_event.get()); 79 move_loop_ = MoveLoop::Create(window_, ht_location, *pointer_event.get());
79 } else if (pointer_event->type() == ui::ET_POINTER_MOVED) { 80 } else if (pointer_event->type() == ui::ET_POINTER_MOVED) {
80 const int ht_location = GetNonClientComponentForEvent(pointer_event.get()); 81 const int ht_location = GetNonClientComponentForEvent(pointer_event.get());
81 aura::WindowPortMus::Get(window_)->SetPredefinedCursor( 82 aura::WindowPortMus::Get(window_)->SetCursor(
82 CursorForWindowComponent(ht_location)); 83 ui::CursorData(CursorForWindowComponent(ht_location)));
83 } 84 }
84 if (had_move_loop || move_loop_) 85 if (had_move_loop || move_loop_)
85 event->SetHandled(); 86 event->SetHandled();
86 } 87 }
87 88
88 int MoveEventHandler::GetNonClientComponentForEvent( 89 int MoveEventHandler::GetNonClientComponentForEvent(
89 const ui::LocatedEvent* event) { 90 const ui::LocatedEvent* event) {
90 return window_->delegate()->GetNonClientComponent(event->location()); 91 return window_->delegate()->GetNonClientComponent(event->location());
91 } 92 }
92 93
(...skipping 19 matching lines...) Expand all
112 move_loop_.reset(); 113 move_loop_.reset();
113 event->SetHandled(); 114 event->SetHandled();
114 } 115 }
115 116
116 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { 117 void MoveEventHandler::OnWindowDestroying(aura::Window* window) {
117 DCHECK_EQ(window_, window); 118 DCHECK_EQ(window_, window);
118 Detach(); 119 Detach();
119 } 120 }
120 121
121 } // namespace simple_wm 122 } // namespace simple_wm
OLDNEW
« no previous file with comments | « content/renderer/mus/renderer_window_tree_client.cc ('k') | services/ui/public/interfaces/cursor/cursor.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698