OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/aura/cursor_manager.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "ui/aura/cursor_delegate.h" | |
9 #include "ui/aura/env.h" | |
10 | |
11 namespace aura { | |
12 | |
13 CursorManager::CursorManager() | |
14 : delegate_(NULL), | |
15 cursor_lock_count_(0), | |
16 did_cursor_change_(false), | |
17 cursor_to_set_on_unlock_(0), | |
18 cursor_visible_(true) { | |
19 } | |
20 | |
21 CursorManager::~CursorManager() { | |
22 } | |
23 | |
24 void CursorManager::LockCursor() { | |
25 cursor_lock_count_++; | |
26 } | |
27 | |
28 void CursorManager::UnlockCursor() { | |
29 cursor_lock_count_--; | |
30 DCHECK_GE(cursor_lock_count_, 0); | |
31 if (cursor_lock_count_ == 0) { | |
32 if (did_cursor_change_) { | |
33 did_cursor_change_ = false; | |
34 if (delegate_) | |
35 delegate_->SetCursor(cursor_to_set_on_unlock_); | |
36 } | |
37 did_cursor_change_ = false; | |
38 cursor_to_set_on_unlock_ = gfx::kNullCursor; | |
39 } | |
40 } | |
41 | |
42 void CursorManager::SetCursor(gfx::NativeCursor cursor) { | |
43 if (cursor_lock_count_ == 0) { | |
44 if (delegate_) | |
45 delegate_->SetCursor(cursor); | |
46 } else { | |
47 cursor_to_set_on_unlock_ = cursor; | |
48 did_cursor_change_ = true; | |
49 } | |
50 } | |
51 | |
52 void CursorManager::ShowCursor(bool show) { | |
53 cursor_visible_ = show; | |
54 if (delegate_) | |
55 delegate_->ShowCursor(show); | |
56 } | |
57 | |
58 } // namespace aura | |
OLD | NEW |