OLD | NEW |
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_cursor_client.h" | 5 #include "ui/views/widget/desktop_aura/desktop_cursor_client.h" |
6 | 6 |
7 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
8 #include "ui/base/cursor/cursor_loader.h" | 8 #include "ui/base/cursor/cursor_loader.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 DesktopCursorClient::DesktopCursorClient(aura::RootWindow* window) | 12 DesktopCursorClient::DesktopCursorClient(aura::RootWindow* window) |
13 : root_window_(window), | 13 : root_window_(window), |
14 cursor_loader_(ui::CursorLoader::Create()), | 14 cursor_loader_(ui::CursorLoader::Create()), |
15 current_cursor_(ui::kCursorNone), | 15 current_cursor_(ui::kCursorNone), |
16 cursor_visible_(true) { | 16 cursor_visible_(true) { |
17 } | 17 } |
18 | 18 |
19 DesktopCursorClient::~DesktopCursorClient() { | 19 DesktopCursorClient::~DesktopCursorClient() { |
20 } | 20 } |
21 | 21 |
22 void DesktopCursorClient::SetCursor(gfx::NativeCursor cursor) { | 22 void DesktopCursorClient::SetCursor(gfx::NativeCursor cursor) { |
23 current_cursor_ = cursor; | 23 current_cursor_ = cursor; |
24 cursor_loader_->SetPlatformCursor(¤t_cursor_); | 24 cursor_loader_->SetPlatformCursor(¤t_cursor_); |
25 if (cursor_visible_) | 25 if (cursor_visible_) |
26 root_window_->SetCursor(current_cursor_); | 26 root_window_->SetCursor(current_cursor_); |
27 } | 27 } |
28 | 28 |
29 void DesktopCursorClient::ShowCursor(bool show) { | 29 void DesktopCursorClient::ShowCursor() { |
30 if (cursor_visible_ == show) | 30 SetCursorVisibility(true); |
31 return; | 31 } |
32 cursor_visible_ = show; | 32 |
33 if (cursor_visible_) | 33 void DesktopCursorClient::HideCursor() { |
34 root_window_->SetCursor(current_cursor_); | 34 SetCursorVisibility(false); |
35 else | |
36 root_window_->SetCursor(ui::kCursorNone); | |
37 root_window_->OnCursorVisibilityChanged(cursor_visible_); | |
38 } | 35 } |
39 | 36 |
40 bool DesktopCursorClient::IsCursorVisible() const { | 37 bool DesktopCursorClient::IsCursorVisible() const { |
41 return cursor_visible_; | 38 return cursor_visible_; |
42 } | 39 } |
43 | 40 |
| 41 void DesktopCursorClient::EnableMouseEvents() { |
| 42 // TODO(mazda): Implement this. |
| 43 NOTIMPLEMENTED(); |
| 44 } |
| 45 |
| 46 void DesktopCursorClient::DisableMouseEvents() { |
| 47 // TODO(mazda): Implement this. |
| 48 NOTIMPLEMENTED(); |
| 49 } |
| 50 |
| 51 bool DesktopCursorClient::IsMouseEventsEnabled() const { |
| 52 // TODO(mazda): Implement this. |
| 53 NOTIMPLEMENTED(); |
| 54 return true; |
| 55 } |
| 56 |
44 void DesktopCursorClient::SetDeviceScaleFactor(float device_scale_factor) { | 57 void DesktopCursorClient::SetDeviceScaleFactor(float device_scale_factor) { |
45 cursor_loader_->UnloadAll(); | 58 cursor_loader_->UnloadAll(); |
46 cursor_loader_->set_device_scale_factor(device_scale_factor); | 59 cursor_loader_->set_device_scale_factor(device_scale_factor); |
47 } | 60 } |
48 | 61 |
49 void DesktopCursorClient::LockCursor() { | 62 void DesktopCursorClient::LockCursor() { |
50 // TODO(mazda): Implement this. | 63 // TODO(mazda): Implement this. |
51 NOTIMPLEMENTED(); | 64 NOTIMPLEMENTED(); |
52 } | 65 } |
53 | 66 |
54 void DesktopCursorClient::UnlockCursor() { | 67 void DesktopCursorClient::UnlockCursor() { |
55 // TODO(mazda): Implement this. | 68 // TODO(mazda): Implement this. |
56 NOTIMPLEMENTED(); | 69 NOTIMPLEMENTED(); |
57 } | 70 } |
58 | 71 |
| 72 void DesktopCursorClient::SetCursorVisibility(bool visible) { |
| 73 if (cursor_visible_ == visible) |
| 74 return; |
| 75 cursor_visible_ = visible; |
| 76 root_window_->SetCursor(current_cursor_); |
| 77 root_window_->OnCursorVisibilityChanged(visible); |
| 78 } |
| 79 |
59 } // namespace views | 80 } // namespace views |
OLD | NEW |