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