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

Side by Side Diff: ui/views/mus/platform_window_mus.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do it the other way + explicit checks that it is a mouse pointer. Created 5 years 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 | « ui/views/mus/platform_window_mus.h ('k') | no next file » | 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 "ui/views/mus/platform_window_mus.h" 5 #include "ui/views/mus/platform_window_mus.h"
6 6
7 #include "components/mus/public/cpp/property_type_converters.h" 7 #include "components/mus/public/cpp/property_type_converters.h"
8 #include "components/mus/public/cpp/window_property.h" 8 #include "components/mus/public/cpp/window_property.h"
9 #include "components/mus/public/interfaces/window_manager.mojom.h" 9 #include "components/mus/public/interfaces/window_manager.mojom.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 10 #include "mojo/converters/input_events/input_events_type_converters.h"
11 #include "ui/platform_window/platform_window_delegate.h" 11 #include "ui/platform_window/platform_window_delegate.h"
12 #include "ui/views/mus/window_manager_connection.h" 12 #include "ui/views/mus/window_manager_connection.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 namespace { 16 namespace {
17 static uint32_t accelerated_widget_count = 1; 17 static uint32_t accelerated_widget_count = 1;
18 18
19 } // namespace 19 } // namespace
20 20
21 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, 21 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
22 mus::Window* mus_window) 22 mus::Window* mus_window)
23 : delegate_(delegate), 23 : delegate_(delegate),
24 mus_window_(mus_window), 24 mus_window_(mus_window),
25 show_state_(mus::mojom::SHOW_STATE_RESTORED), 25 show_state_(mus::mojom::SHOW_STATE_RESTORED),
26 last_cursor_(mus::mojom::CURSOR_NULL),
26 has_capture_(false) { 27 has_capture_(false) {
27 DCHECK(delegate_); 28 DCHECK(delegate_);
28 DCHECK(mus_window_); 29 DCHECK(mus_window_);
29 mus_window_->AddObserver(this); 30 mus_window_->AddObserver(this);
30 31
31 // We need accelerated widget numbers to be different for each 32 // We need accelerated widget numbers to be different for each
32 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t 33 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
33 // has this property. 34 // has this property.
34 #if defined(OS_WIN) || defined(OS_ANDROID) 35 #if defined(OS_WIN) || defined(OS_ANDROID)
35 delegate_->OnAcceleratedWidgetAvailable( 36 delegate_->OnAcceleratedWidgetAvailable(
(...skipping 11 matching lines...) Expand all
47 return; 48 return;
48 mus_window_->RemoveObserver(this); 49 mus_window_->RemoveObserver(this);
49 mus_window_->Destroy(); 50 mus_window_->Destroy();
50 } 51 }
51 52
52 53
53 void PlatformWindowMus::Activate() { 54 void PlatformWindowMus::Activate() {
54 mus_window_->SetFocus(); 55 mus_window_->SetFocus();
55 } 56 }
56 57
58 void PlatformWindowMus::SetCursorById(mus::mojom::Cursor cursor) {
59 if (last_cursor_ != cursor) {
60 // The ui::PlatformWindow interface uses ui::PlatformCursor at this level,
61 // instead of ui::Cursor. All of the cursor abstractions in ui right now are
62 // sort of leaky; despite being nominally cross platform, they all drop down
63 // to platform types almost immediately, which makes them unusable as
64 // transport types.
65 mus_window_->SetPredefinedCursor(cursor);
66 }
67 }
68
57 void PlatformWindowMus::Show() { 69 void PlatformWindowMus::Show() {
58 mus_window_->SetVisible(true); 70 mus_window_->SetVisible(true);
59 } 71 }
60 72
61 void PlatformWindowMus::Hide() { 73 void PlatformWindowMus::Hide() {
62 mus_window_->SetVisible(false); 74 mus_window_->SetVisible(false);
63 } 75 }
64 76
65 void PlatformWindowMus::Close() { 77 void PlatformWindowMus::Close() {
66 NOTIMPLEMENTED(); 78 NOTIMPLEMENTED();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 152 }
141 153
142 void PlatformWindowMus::OnWindowFocusChanged(mus::Window* gained_focus, 154 void PlatformWindowMus::OnWindowFocusChanged(mus::Window* gained_focus,
143 mus::Window* lost_focus) { 155 mus::Window* lost_focus) {
144 if (gained_focus == mus_window_) 156 if (gained_focus == mus_window_)
145 delegate_->OnActivationChanged(true); 157 delegate_->OnActivationChanged(true);
146 else if (lost_focus == mus_window_) 158 else if (lost_focus == mus_window_)
147 delegate_->OnActivationChanged(false); 159 delegate_->OnActivationChanged(false);
148 } 160 }
149 161
162 void PlatformWindowMus::OnWindowPredefinedCursorChanged(
163 mus::Window* window,
164 mus::mojom::Cursor cursor) {
165 DCHECK_EQ(window, mus_window_);
166 last_cursor_ = cursor;
167 }
168
150 void PlatformWindowMus::OnWindowInputEvent(mus::Window* view, 169 void PlatformWindowMus::OnWindowInputEvent(mus::Window* view,
151 const mus::mojom::EventPtr& event) { 170 const mus::mojom::EventPtr& event) {
152 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); 171 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
153 delegate_->DispatchEvent(ui_event.get()); 172 delegate_->DispatchEvent(ui_event.get());
154 } 173 }
155 174
156 void PlatformWindowMus::OnWindowSharedPropertyChanged( 175 void PlatformWindowMus::OnWindowSharedPropertyChanged(
157 mus::Window* window, 176 mus::Window* window,
158 const std::string& name, 177 const std::string& name,
159 const std::vector<uint8_t>* old_data, 178 const std::vector<uint8_t>* old_data,
(...skipping 20 matching lines...) Expand all
180 case mus::mojom::SHOW_STATE_IMMERSIVE: 199 case mus::mojom::SHOW_STATE_IMMERSIVE:
181 case mus::mojom::SHOW_STATE_PRESENTATION: 200 case mus::mojom::SHOW_STATE_PRESENTATION:
182 // This may not be sufficient. 201 // This may not be sufficient.
183 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; 202 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN;
184 break; 203 break;
185 } 204 }
186 delegate_->OnWindowStateChanged(state); 205 delegate_->OnWindowStateChanged(state);
187 } 206 }
188 207
189 } // namespace views 208 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/platform_window_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698