1 // Copyright (c) 2013 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.
5 #ifndef UI_WM_CORE_CURSOR_MANAGER_H_
6 #define UI_WM_CORE_CURSOR_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "ui/aura/client/cursor_client.h"
13 #include "ui/base/cursor/cursor.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/point.h"
16 #include "ui/wm/core/native_cursor_manager_delegate.h"
17 #include "ui/wm/wm_export.h"
33 class NativeCursorManager
;
35 // This class receives requests to change cursor properties, as well as
36 // requests to queue any further changes until a later time. It sends changes
37 // to the NativeCursorManager, which communicates back to us when these changes
38 // were made through the NativeCursorManagerDelegate interface.
39 class WM_EXPORT CursorManager
: public aura::client::CursorClient
,
40 public NativeCursorManagerDelegate
{
42 explicit CursorManager(scoped_ptr
<NativeCursorManager
> delegate
);
43 virtual ~CursorManager();
45 // Overridden from aura::client::CursorClient:
46 virtual void SetCursor(gfx::NativeCursor
) OVERRIDE
;
47 virtual gfx::NativeCursor
GetCursor() const OVERRIDE
;
48 virtual void ShowCursor() OVERRIDE
;
49 virtual void HideCursor() OVERRIDE
;
50 virtual bool IsCursorVisible() const OVERRIDE
;
51 virtual void SetCursorSet(ui::CursorSetType cursor_set
) OVERRIDE
;
52 virtual ui::CursorSetType
GetCursorSet() const OVERRIDE
;
53 virtual void EnableMouseEvents() OVERRIDE
;
54 virtual void DisableMouseEvents() OVERRIDE
;
55 virtual bool IsMouseEventsEnabled() const OVERRIDE
;
56 virtual void SetDisplay(const gfx::Display
& display
) OVERRIDE
;
57 virtual void LockCursor() OVERRIDE
;
58 virtual void UnlockCursor() OVERRIDE
;
59 virtual bool IsCursorLocked() const OVERRIDE
;
60 virtual void AddObserver(
61 aura::client::CursorClientObserver
* observer
) OVERRIDE
;
62 virtual void RemoveObserver(
63 aura::client::CursorClientObserver
* observer
) OVERRIDE
;
64 virtual bool ShouldHideCursorOnKeyEvent(
65 const ui::KeyEvent
& event
) const OVERRIDE
;
68 // Overridden from NativeCursorManagerDelegate:
69 virtual void CommitCursor(gfx::NativeCursor cursor
) OVERRIDE
;
70 virtual void CommitVisibility(bool visible
) OVERRIDE
;
71 virtual void CommitCursorSet(ui::CursorSetType cursor_set
) OVERRIDE
;
72 virtual void CommitMouseEventsEnabled(bool enabled
) OVERRIDE
;
74 scoped_ptr
<NativeCursorManager
> delegate_
;
76 // Number of times LockCursor() has been invoked without a corresponding
78 int cursor_lock_count_
;
80 // The current state of the cursor.
81 scoped_ptr
<internal::CursorState
> current_state_
;
83 // The cursor state to restore when the cursor is unlocked.
84 scoped_ptr
<internal::CursorState
> state_on_unlock_
;
86 ObserverList
<aura::client::CursorClientObserver
> observers_
;
88 DISALLOW_COPY_AND_ASSIGN(CursorManager
);
93 #endif // UI_WM_CORE_CURSOR_MANAGER_H_