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

Side by Side Diff: ash/wm/cursor_manager.cc

Issue 10965020: Fix cursor getting invisible after moving a window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 "ash/wm/cursor_manager.h" 5 #include "ash/wm/cursor_manager.h"
6 6
7 #include "ash/wm/cursor_delegate.h" 7 #include "ash/wm/cursor_delegate.h"
8 #include "ash/wm/image_cursors.h" 8 #include "ash/wm/image_cursors.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/base/cursor/cursor.h" 11 #include "ui/base/cursor/cursor.h"
12 12
13 namespace ash { 13 namespace ash {
14 14
15 CursorManager::TestApi::TestApi(CursorManager* cursor_manager)
16 : cursor_manager_(cursor_manager) {
17 }
18
19 gfx::NativeCursor CursorManager::TestApi::current_cursor() {
20 return cursor_manager_->current_cursor_;
21 }
22
23 float CursorManager::TestApi::GetDeviceScaleFactor() {
24 return cursor_manager_->image_cursors_->GetDeviceScaleFactor();
25 }
26
15 CursorManager::CursorManager() 27 CursorManager::CursorManager()
16 : delegate_(NULL), 28 : delegate_(NULL),
17 cursor_lock_count_(0), 29 cursor_lock_count_(0),
18 did_cursor_change_(false), 30 did_cursor_change_(false),
19 cursor_to_set_on_unlock_(0), 31 cursor_to_set_on_unlock_(0),
20 cursor_visible_(true), 32 cursor_visible_(true),
21 current_cursor_(ui::kCursorNone), 33 current_cursor_(ui::kCursorNone),
22 image_cursors_(new ImageCursors) { 34 image_cursors_(new ImageCursors) {
23 } 35 }
24 36
25 CursorManager::~CursorManager() { 37 CursorManager::~CursorManager() {
26 } 38 }
27 39
28 void CursorManager::LockCursor() { 40 void CursorManager::LockCursor() {
29 cursor_lock_count_++; 41 cursor_lock_count_++;
30 } 42 }
31 43
32 void CursorManager::UnlockCursor() { 44 void CursorManager::UnlockCursor() {
33 cursor_lock_count_--; 45 cursor_lock_count_--;
34 DCHECK_GE(cursor_lock_count_, 0); 46 DCHECK_GE(cursor_lock_count_, 0);
35 if (cursor_lock_count_ == 0) { 47 if (cursor_lock_count_ == 0) {
36 if (did_cursor_change_) { 48 if (did_cursor_change_) {
37 did_cursor_change_ = false; 49 did_cursor_change_ = false;
38 if (delegate_) 50 if (delegate_)
39 delegate_->SetCursor(cursor_to_set_on_unlock_); 51 SetCursorInternal(cursor_to_set_on_unlock_);
40 } 52 }
41 did_cursor_change_ = false; 53 did_cursor_change_ = false;
42 cursor_to_set_on_unlock_ = gfx::kNullCursor; 54 cursor_to_set_on_unlock_ = gfx::kNullCursor;
43 } 55 }
44 } 56 }
45 57
46 void CursorManager::SetCursor(gfx::NativeCursor cursor) { 58 void CursorManager::SetCursor(gfx::NativeCursor cursor) {
47 if (cursor_lock_count_ == 0) { 59 if (cursor_lock_count_ == 0) {
48 if (delegate_) 60 if (delegate_)
49 SetCursorInternal(cursor); 61 SetCursorInternal(cursor);
(...skipping 23 matching lines...) Expand all
73 void CursorManager::SetCursorInternal(gfx::NativeCursor cursor) { 85 void CursorManager::SetCursorInternal(gfx::NativeCursor cursor) {
74 DCHECK(delegate_); 86 DCHECK(delegate_);
75 current_cursor_ = cursor; 87 current_cursor_ = cursor;
76 image_cursors_->SetPlatformCursor(&current_cursor_); 88 image_cursors_->SetPlatformCursor(&current_cursor_);
77 current_cursor_.set_device_scale_factor( 89 current_cursor_.set_device_scale_factor(
78 image_cursors_->GetDeviceScaleFactor()); 90 image_cursors_->GetDeviceScaleFactor());
79 delegate_->SetCursor(current_cursor_); 91 delegate_->SetCursor(current_cursor_);
80 } 92 }
81 93
82 } // namespace ash 94 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698