mirror_window_controller.h revision 7d4cd473f85ac64c3747c96c277f9e506a0d2246
190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file.
490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ash/ash_export.h"
990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/compiler_specific.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/ref_counted.h"
1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "base/memory/scoped_ptr.h"
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/aura/root_window_observer.h"
137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "ui/gfx/display.h"
1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/gfx/native_widget_types.h"
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/gfx/point.h"
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/gfx/size.h"
1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace aura {
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class RootWindow;
207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class RootWindowTransformer;
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Window;
2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace ui {
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class Reflector;
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace ash {
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace test{
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class MirrorWindowTestApi;
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace internal {
3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class DisplayInfo;
3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class CursorWindowDelegate;
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// An object that copies the content of the primary root window to a
3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// mirror window. This also draws a mouse cursor as the mouse cursor
3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// is typically drawn by the window system.
407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)class ASH_EXPORT MirrorWindowController : public aura::RootWindowObserver {
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) public:
4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  MirrorWindowController();
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~MirrorWindowController();
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Updates the root window's bounds using |display_info|.
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Creates the new root window if one doesn't exist.
4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void UpdateWindow(const DisplayInfo& display_info);
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Same as above, but using existing display info
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // for the mirrored display.
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void UpdateWindow();
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Close the mirror window.
5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void Close();
5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Updates the mirrored cursor location,shape and
5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // visibility.
5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void UpdateCursorLocation();
5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void SetMirroredCursor(gfx::NativeCursor cursor);
6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void SetMirroredCursorVisibility(bool visible);
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // aura::RootWindowObserver overrides:
637d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  virtual void OnRootWindowHostResized(const aura::RootWindow* root) OVERRIDE;
64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private:
6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  friend class test::MirrorWindowTestApi;
6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
687d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // Creates a RootWindowTransformer for current display
697d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  // configuration.
707d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  scoped_ptr<aura::RootWindowTransformer> CreateRootWindowTransformer() const;
717d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  int current_cursor_type_;
737d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  gfx::Display::Rotation current_cursor_rotation_;
7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  aura::Window* cursor_window_;  // owned by root window.
7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  scoped_ptr<aura::RootWindow> root_window_;
7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  scoped_ptr<CursorWindowDelegate> cursor_window_delegate_;
7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  gfx::Point hot_point_;
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  gfx::Size mirror_window_host_size_;
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<ui::Reflector> reflector_;
8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(MirrorWindowController);
8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)};
8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}  // namespace internal
8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}  // namespace ash
8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif  // ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
88