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.
5 #ifndef UI_AURA_CLIENT_CURSOR_CLIENT_H_
6 #define UI_AURA_CLIENT_CURSOR_CLIENT_H_
8 #include "base/strings/string16.h"
9 #include "ui/aura/aura_export.h"
10 #include "ui/base/cursor/cursor.h"
11 #include "ui/gfx/native_widget_types.h"
24 class CursorClientObserver
;
26 // An interface that receives cursor change events.
27 class AURA_EXPORT CursorClient
{
29 // Notes that |window| has requested the change to |cursor|.
30 virtual void SetCursor(gfx::NativeCursor cursor
) = 0;
32 // Returns the current cursor.
33 virtual gfx::NativeCursor
GetCursor() const = 0;
35 // Shows the cursor. This does not take effect When mouse events are disabled.
36 virtual void ShowCursor() = 0;
38 // Hides the cursor. Mouse events keep being sent even when the cursor is
40 virtual void HideCursor() = 0;
42 // Sets the type of the mouse cursor icon.
43 virtual void SetCursorSet(ui::CursorSetType cursor_set
) = 0;
45 // Gets the type of the mouse cursor icon.
46 virtual ui::CursorSetType
GetCursorSet() const = 0;
48 // Gets whether the cursor is visible.
49 virtual bool IsCursorVisible() const = 0;
51 // Makes mouse events start being sent and shows the cursor if it was hidden
52 // with DisableMouseEvents.
53 virtual void EnableMouseEvents() = 0;
55 // Makes mouse events stop being sent and hides the cursor if it is visible.
56 virtual void DisableMouseEvents() = 0;
58 // Returns true if mouse events are enabled.
59 virtual bool IsMouseEventsEnabled() const = 0;
61 // Sets the display for the cursor.
62 virtual void SetDisplay(const gfx::Display
& display
) = 0;
64 // Locks the cursor change. The cursor type, cursor visibility, and mouse
65 // events enable state never change as long as lock is held by anyone.
66 virtual void LockCursor() = 0;
68 // Unlocks the cursor change. If all the locks are released, the cursor type,
69 // cursor visibility, and mouse events enable state are restored to the ones
70 // set by the lastest call of SetCursor, ShowCursor/HideCursor, and
71 // EnableMouseEvents/DisableMouseEvents.
72 virtual void UnlockCursor() = 0;
74 // Returns true if the cursor is locked.
75 virtual bool IsCursorLocked() const = 0;
77 // Used to add or remove a CursorClientObserver.
78 virtual void AddObserver(CursorClientObserver
* observer
) = 0;
79 virtual void RemoveObserver(CursorClientObserver
* observer
) = 0;
81 // Returns true if the mouse cursor should be hidden on |event|.
82 virtual bool ShouldHideCursorOnKeyEvent(const ui::KeyEvent
& event
) const = 0;
85 virtual ~CursorClient() {}
88 // Sets/Gets the activation client for the specified window.
89 AURA_EXPORT
void SetCursorClient(Window
* window
,
90 CursorClient
* client
);
91 AURA_EXPORT CursorClient
* GetCursorClient(Window
* window
);
96 #endif // UI_AURA_CLIENT_CURSOR_CLIENT_H_