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.
5 #ifndef UI_AURA_ROOT_WINDOW_HOST_H_
6 #define UI_AURA_ROOT_WINDOW_HOST_H_
10 #include "base/message_loop.h"
11 #include "ui/aura/aura_export.h"
12 #include "ui/base/cursor/cursor.h"
13 #include "ui/gfx/native_widget_types.h"
27 class RootWindowHostDelegate
;
29 // RootWindowHost bridges between a native window and the embedded RootWindow.
30 // It provides the accelerated widget and maps events from the native os to
32 class AURA_EXPORT RootWindowHost
{
34 virtual ~RootWindowHost() {}
36 // Creates a new RootWindowHost. The caller owns the returned value.
37 static RootWindowHost
* Create(const gfx::Rect
& bounds
);
39 // Returns the actual size of the screen.
40 // (gfx::Screen only reports on the virtual desktop exposed by Aura.)
41 static gfx::Size
GetNativeScreenSize();
43 // Sets the delegate, which is normally done by the root window.
44 virtual void SetDelegate(RootWindowHostDelegate
* delegate
) = 0;
46 virtual RootWindow
* GetRootWindow() = 0;
48 // Returns the accelerated widget.
49 virtual gfx::AcceleratedWidget
GetAcceleratedWidget() = 0;
51 // Shows the RootWindowHost.
52 virtual void Show() = 0;
54 // Hides the RootWindowHost.
55 virtual void Hide() = 0;
57 // Toggles the host's full screen state.
58 virtual void ToggleFullScreen() = 0;
60 // Gets/Sets the size of the RootWindowHost.
61 virtual gfx::Rect
GetBounds() const = 0;
62 virtual void SetBounds(const gfx::Rect
& bounds
) = 0;
64 // Sets/Gets the insets that specifies the effective root window area
65 // in the host window.
66 virtual gfx::Insets
GetInsets() const = 0;
67 virtual void SetInsets(const gfx::Insets
& insets
) = 0;
69 // Returns the location of the RootWindow on native screen.
70 virtual gfx::Point
GetLocationOnNativeScreen() const = 0;
72 // Sets the OS capture to the root window.
73 virtual void SetCapture() = 0;
75 // Releases OS capture of the root window.
76 virtual void ReleaseCapture() = 0;
78 // Sets the currently displayed cursor.
79 virtual void SetCursor(gfx::NativeCursor cursor
) = 0;
81 // Queries the mouse's current position relative to the host window and sets
82 // it in |location_return|. Returns true if the cursor is within the host
83 // window. The position set to |location_return| is constrained within the
84 // host window. If the cursor is disabled, returns false and (0, 0) is set to
86 // This method is expensive, instead use gfx::Screen::GetCursorScreenPoint().
87 virtual bool QueryMouseLocation(gfx::Point
* location_return
) = 0;
89 // Clips the cursor to the bounds of the root window until UnConfineCursor().
90 virtual bool ConfineCursorToRootWindow() = 0;
91 virtual void UnConfineCursor() = 0;
93 // Called when the cursor visibility has changed.
94 virtual void OnCursorVisibilityChanged(bool show
) = 0;
96 // Moves the cursor to the specified location relative to the root window.
97 virtual void MoveCursorTo(const gfx::Point
& location
) = 0;
99 // Sets if the window should be focused when shown.
100 virtual void SetFocusWhenShown(bool focus_when_shown
) = 0;
102 // Copies |source_bounds| from the root window (as displayed on the host
103 // machine) to |canvas| at offset |dest_offset|. The bounds need to be in
105 virtual bool CopyAreaToSkCanvas(const gfx::Rect
& source_bounds
,
106 const gfx::Point
& dest_offset
,
107 SkCanvas
* canvas
) = 0;
109 // Grabs the snapshot of the root window by using the platform-dependent APIs.
110 // The bounds need to be in physical pixels.
111 virtual bool GrabSnapshot(
112 const gfx::Rect
& snapshot_bounds
,
113 std::vector
<unsigned char>* png_representation
) = 0;
115 // Posts |native_event| to the platform's event queue.
116 #if !defined(OS_MACOSX)
117 virtual void PostNativeEvent(const base::NativeEvent
& native_event
) = 0;
120 // Called when the device scale factor of the root window has chagned.
121 virtual void OnDeviceScaleFactorChanged(float device_scale_factor
) = 0;
123 // Stop listening events in preparation for shutdown.
124 virtual void PrepareForShutdown() = 0;
129 #endif // UI_AURA_ROOT_WINDOW_HOST_H_