cursor_window_controller.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1// Copyright 2014 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 ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
6#define ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
7
8#include "ui/aura/window.h"
9#include "ui/base/cursor/cursor.h"
10#include "ui/gfx/display.h"
11
12namespace ash {
13namespace test{
14class MirrorWindowTestApi;
15}
16
17namespace internal {
18
19class CursorWindowDelegate;
20
21// Draws a mouse cursor on a given container window.
22// When cursor compositing is disabled, CursorWindowController is responsible
23// to scale and rotate the mouse cursor bitmap to match settings of the
24// primary display.
25// When cursor compositing is enabled, just draw the cursor as-is.
26class CursorWindowController {
27 public:
28  CursorWindowController();
29  ~CursorWindowController();
30
31  bool is_cursor_compositing_enabled() const {
32    return is_cursor_compositing_enabled_;
33  }
34
35  // Sets cursor compositing mode on/off.
36  void SetCursorCompositingEnabled(bool enabled);
37
38  // Updates the container window for the cursor window controller.
39  void UpdateContainer();
40
41  // Sets the display on which to draw cursor.
42  // Only applicable when cursor compositing is enabled.
43  void SetDisplay(const gfx::Display& display);
44
45  // Sets cursor location, shape, set and visibility.
46  void UpdateLocation();
47  void SetCursor(gfx::NativeCursor cursor);
48  void SetCursorSet(ui::CursorSetType);
49  void SetVisibility(bool visible);
50
51 private:
52  friend class test::MirrorWindowTestApi;
53
54  // Sets the container window for the cursor window controller.
55  // Closes the cursor window if |container| is NULL.
56  void SetContainer(aura::Window* container);
57
58  // Sets the bounds of the container in screen coordinates.
59  void SetBoundsInScreen(const gfx::Rect& bounds);
60
61  // Updates cursor image based on current cursor state.
62  void UpdateCursorImage();
63
64  bool is_cursor_compositing_enabled_;
65  aura::Window* container_;
66
67  // The bounds of the container in screen coordinates.
68  gfx::Rect bounds_in_screen_;
69
70  // The native_type of the cursor, see definitions in cursor.h
71  int cursor_type_;
72
73  ui::CursorSetType cursor_set_;
74  gfx::Display::Rotation cursor_rotation_;
75  gfx::Point hot_point_;
76
77  // The display on which the cursor is drawn.
78  // For mirroring mode, the display is always the primary display.
79  gfx::Display display_;
80
81  scoped_ptr<aura::Window> cursor_window_;
82  scoped_ptr<CursorWindowDelegate> delegate_;
83
84  DISALLOW_COPY_AND_ASSIGN(CursorWindowController);
85};
86
87}  // namespace internal
88}  // namespace ash
89
90#endif  // ASH_DISPLAY_CURSOR_WINDOW_CONTROLLER_H_
91