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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc

Issue 2504743002: Linux Aura: Fixes and improvements for cursor loader (Closed)
Patch Set: Formatting 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/widget/desktop_aura/desktop_native_cursor_manager.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ui/aura/window_event_dispatcher.h" 9 #include "ui/aura/window_event_dispatcher.h"
10 #include "ui/aura/window_tree_host.h" 10 #include "ui/aura/window_tree_host.h"
11 #include "ui/base/cursor/cursor_loader.h" 11 #include "ui/base/cursor/cursor_loader.h"
12 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
13 12
14 namespace views { 13 namespace views {
15 14
16 DesktopNativeCursorManager::DesktopNativeCursorManager( 15 DesktopNativeCursorManager::DesktopNativeCursorManager()
17 std::unique_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater) 16 : cursor_loader_(ui::CursorLoader::Create()) {}
18 : cursor_loader_updater_(std::move(cursor_loader_updater)),
19 cursor_loader_(ui::CursorLoader::Create()) {
20 if (cursor_loader_updater_.get())
21 cursor_loader_updater_->OnCreate(1.0f, cursor_loader_.get());
22 }
23 17
24 DesktopNativeCursorManager::~DesktopNativeCursorManager() { 18 DesktopNativeCursorManager::~DesktopNativeCursorManager() {
25 } 19 }
26 20
27 gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) { 21 gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) {
28 gfx::NativeCursor cursor(type); 22 gfx::NativeCursor cursor(type);
29 cursor_loader_->SetPlatformCursor(&cursor); 23 cursor_loader_->SetPlatformCursor(&cursor);
30 return cursor; 24 return cursor;
31 } 25 }
32 26
33 void DesktopNativeCursorManager::AddHost(aura::WindowTreeHost* host) { 27 void DesktopNativeCursorManager::AddHost(aura::WindowTreeHost* host) {
34 hosts_.insert(host); 28 hosts_.insert(host);
35 } 29 }
36 30
37 void DesktopNativeCursorManager::RemoveHost(aura::WindowTreeHost* host) { 31 void DesktopNativeCursorManager::RemoveHost(aura::WindowTreeHost* host) {
38 hosts_.erase(host); 32 hosts_.erase(host);
39 } 33 }
40 34
41 void DesktopNativeCursorManager::SetDisplay( 35 void DesktopNativeCursorManager::SetDisplay(
42 const display::Display& display, 36 const display::Display& display,
43 wm::NativeCursorManagerDelegate* delegate) { 37 wm::NativeCursorManagerDelegate* delegate) {
44 cursor_loader_->UnloadAll(); 38 cursor_loader_->UnloadAll();
45 cursor_loader_->set_rotation(display.rotation()); 39 cursor_loader_->set_rotation(display.rotation());
46 cursor_loader_->set_scale(display.device_scale_factor()); 40 cursor_loader_->set_scale(display.device_scale_factor());
47 41
48 if (cursor_loader_updater_.get())
49 cursor_loader_updater_->OnDisplayUpdated(display, cursor_loader_.get());
50
51 SetCursor(delegate->GetCursor(), delegate); 42 SetCursor(delegate->GetCursor(), delegate);
52 } 43 }
53 44
54 void DesktopNativeCursorManager::SetCursor( 45 void DesktopNativeCursorManager::SetCursor(
55 gfx::NativeCursor cursor, 46 gfx::NativeCursor cursor,
56 wm::NativeCursorManagerDelegate* delegate) { 47 wm::NativeCursorManagerDelegate* delegate) {
57 gfx::NativeCursor new_cursor = cursor; 48 gfx::NativeCursor new_cursor = cursor;
58 cursor_loader_->SetPlatformCursor(&new_cursor); 49 cursor_loader_->SetPlatformCursor(&new_cursor);
59 delegate->CommitCursor(new_cursor); 50 delegate->CommitCursor(new_cursor);
60 51
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // TODO(erg): In the ash version, we set the last mouse location on Env. I'm 87 // TODO(erg): In the ash version, we set the last mouse location on Env. I'm
97 // not sure this concept makes sense on the desktop. 88 // not sure this concept makes sense on the desktop.
98 89
99 SetVisibility(delegate->IsCursorVisible(), delegate); 90 SetVisibility(delegate->IsCursorVisible(), delegate);
100 91
101 for (Hosts::const_iterator i = hosts_.begin(); i != hosts_.end(); ++i) 92 for (Hosts::const_iterator i = hosts_.begin(); i != hosts_.end(); ++i)
102 (*i)->dispatcher()->OnMouseEventsEnableStateChanged(enabled); 93 (*i)->dispatcher()->OnMouseEventsEnableStateChanged(enabled);
103 } 94 }
104 95
105 } // namespace views 96 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698