Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / aura / client / cursor_client.h
blobfc48e036107ab9eb57c5dbf05e4021d345298cd6
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"
13 namespace gfx {
14 class Display;
17 namespace ui {
18 class KeyEvent;
21 namespace aura {
22 class Window;
23 namespace client {
24 class CursorClientObserver;
26 // An interface that receives cursor change events.
27 class AURA_EXPORT CursorClient {
28 public:
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
39 // invisible.
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;
84 protected:
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);
93 } // namespace client
94 } // namespace aura
96 #endif // UI_AURA_CLIENT_CURSOR_CLIENT_H_