blob: 9f2cc8b219de81636936d7351d89e2d6c072a2d5 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/gfx/native_widget_types.h"
namespace ash {
class CursorDelegate;
// This class controls the visibility and the type of the cursor.
// The cursor type can be locked so that the type stays the same
// until it's unlocked.
class CursorManager : public aura::client::CursorClient {
virtual ~CursorManager();
void set_delegate(CursorDelegate* delegate) { delegate_ = delegate; }
// Locks/Unlocks the cursor change.
void LockCursor();
void UnlockCursor();
bool is_cursor_locked() const { return cursor_lock_count_ > 0; }
// Shows or hides the cursor.
bool cursor_visible() const { return cursor_visible_; }
virtual void SetCursor(gfx::NativeCursor) OVERRIDE;
virtual void ShowCursor(bool show) OVERRIDE;
virtual bool IsCursorVisible() const OVERRIDE;
CursorDelegate* delegate_;
// Number of times LockCursor() has been invoked without a corresponding
// UnlockCursor().
int cursor_lock_count_;
// Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0.
bool did_cursor_change_;
// Cursor to set once |cursor_lock_count_| is set to 0. Only valid if
// |did_cursor_change_| is true.
gfx::NativeCursor cursor_to_set_on_unlock_;
// Is cursor visible?
bool cursor_visible_;
} // namespace aura