mirror_window_controller.h revision 868fa2fe829687343ffae624259930155e16dbd8
1// Copyright (c) 2013 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_MIRROR_WINDOW_CONTROLLER_H_
6#define ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
7
8#include "ash/ash_export.h"
9#include "base/compiler_specific.h"
10#include "base/memory/ref_counted.h"
11#include "base/memory/scoped_ptr.h"
12#include "ui/aura/root_window_observer.h"
13#include "ui/gfx/native_widget_types.h"
14#include "ui/gfx/point.h"
15#include "ui/gfx/size.h"
16
17namespace aura {
18class RootWindow;
19class Window;
20}
21
22namespace ui {
23class Reflector;
24}
25
26namespace ash {
27namespace test{
28class MirrorWindowTestApi;
29}
30
31namespace internal {
32class DisplayInfo;
33class CursorWindowDelegate;
34
35// An object that copies the content of the primary root window to a
36// mirror window. This also draws a mouse cursor as the mouse cursor
37// is typically drawn by the window system.
38class MirrorWindowController : public aura::RootWindowObserver {
39 public:
40  MirrorWindowController();
41  virtual ~MirrorWindowController();
42
43  // Updates the root window's bounds using |display_info|.
44  // Creates the new root window if one doesn't exist.
45  void UpdateWindow(const DisplayInfo& display_info);
46
47  // Same as above, but using existing display info
48  // for the mirrored display.
49  void UpdateWindow();
50
51  // Close the mirror window.
52  void Close();
53
54  // Updates the mirrored cursor location,shape and
55  // visibility.
56  void UpdateCursorLocation();
57  void SetMirroredCursor(gfx::NativeCursor cursor);
58  void SetMirroredCursorVisibility(bool visible);
59
60  // aura::RootWindowObserver overrides:
61  virtual void OnRootWindowResized(const aura::RootWindow* root,
62                                   const gfx::Size& old_size) OVERRIDE;
63
64 private:
65  friend class test::MirrorWindowTestApi;
66
67  int current_cursor_type_;
68  aura::Window* cursor_window_;  // owned by root window.
69  scoped_ptr<aura::RootWindow> root_window_;
70  scoped_ptr<CursorWindowDelegate> cursor_window_delegate_;
71  gfx::Point hot_point_;
72  gfx::Size mirror_window_host_size_;
73  scoped_refptr<ui::Reflector> reflector_;
74
75  DISALLOW_COPY_AND_ASSIGN(MirrorWindowController);
76};
77
78}  // namespace internal
79}  // namespace ash
80
81#endif  // ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
82