• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef UI_AURA_CLIENT_CURSOR_CLIENT_H_
6 #define UI_AURA_CLIENT_CURSOR_CLIENT_H_
7 
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"
12 
13 namespace gfx {
14 class Display;
15 }
16 
17 namespace aura {
18 class Window;
19 namespace client {
20 class CursorClientObserver;
21 
22 // An interface that receives cursor change events.
23 class AURA_EXPORT CursorClient {
24  public:
25   // Notes that |window| has requested the change to |cursor|.
26   virtual void SetCursor(gfx::NativeCursor cursor) = 0;
27 
28   // Returns the current cursor.
29   virtual gfx::NativeCursor GetCursor() const = 0;
30 
31   // Shows the cursor. This does not take effect When mouse events are disabled.
32   virtual void ShowCursor() = 0;
33 
34   // Hides the cursor. Mouse events keep being sent even when the cursor is
35   // invisible.
36   virtual void HideCursor() = 0;
37 
38   // Sets the scale of the mouse cursor icon.
39   virtual void SetScale(float scale) = 0;
40 
41   // Gets the current scale of the mouse cursor icon.
42   virtual float GetScale() const = 0;
43 
44   // Sets the type of the mouse cursor icon.
45   virtual void SetCursorSet(ui::CursorSetType cursor_set) = 0;
46 
47   // Gets the type of the mouse cursor icon.
48   virtual ui::CursorSetType GetCursorSet() const = 0;
49 
50   // Gets whether the cursor is visible.
51   virtual bool IsCursorVisible() const = 0;
52 
53   // Makes mouse events start being sent and shows the cursor if it was hidden
54   // with DisableMouseEvents.
55   virtual void EnableMouseEvents() = 0;
56 
57   // Makes mouse events stop being sent and hides the cursor if it is visible.
58   virtual void DisableMouseEvents() = 0;
59 
60   // Returns true if mouse events are enabled.
61   virtual bool IsMouseEventsEnabled() const = 0;
62 
63   // Sets the display for the cursor.
64   virtual void SetDisplay(const gfx::Display& display) = 0;
65 
66   // Locks the cursor change. The cursor type, cursor visibility, and mouse
67   // events enable state never change as long as lock is held by anyone.
68   virtual void LockCursor() = 0;
69 
70   // Unlocks the cursor change. If all the locks are released, the cursor type,
71   // cursor visibility, and mouse events enable state are restored to the ones
72   // set by the lastest call of SetCursor, ShowCursor/HideCursor, and
73   // EnableMouseEvents/DisableMouseEvents.
74   virtual void UnlockCursor() = 0;
75 
76   // Returns true if the cursor is locked.
77   virtual bool IsCursorLocked() const = 0;
78 
79   // Used to add or remove a CursorClientObserver.
80   virtual void AddObserver(CursorClientObserver* observer) = 0;
81   virtual void RemoveObserver(CursorClientObserver* observer) = 0;
82 
83  protected:
~CursorClient()84   virtual ~CursorClient() {}
85 };
86 
87 // Sets/Gets the activation client for the specified window.
88 AURA_EXPORT void SetCursorClient(Window* window,
89                                  CursorClient* client);
90 AURA_EXPORT CursorClient* GetCursorClient(Window* window);
91 
92 }  // namespace client
93 }  // namespace aura
94 
95 #endif  // UI_AURA_CLIENT_CURSOR_CLIENT_H_
96