Home | History | Annotate | Download | only in aura
      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_ROOT_WINDOW_HOST_H_
      6 #define UI_AURA_ROOT_WINDOW_HOST_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/message_loop/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"
     14 
     15 class SkCanvas;
     16 
     17 namespace gfx {
     18 class Insets;
     19 class Point;
     20 class Rect;
     21 class Size;
     22 }
     23 
     24 namespace aura {
     25 
     26 class RootWindow;
     27 class RootWindowHostDelegate;
     28 
     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
     31 // aura.
     32 class AURA_EXPORT RootWindowHost {
     33  public:
     34   virtual ~RootWindowHost() {}
     35 
     36   // Creates a new RootWindowHost. The caller owns the returned value.
     37   static RootWindowHost* Create(const gfx::Rect& bounds);
     38 
     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();
     42 
     43   // Sets the delegate, which is normally done by the root window.
     44   virtual void SetDelegate(RootWindowHostDelegate* delegate) = 0;
     45 
     46   virtual RootWindow* GetRootWindow() = 0;
     47 
     48   // Returns the accelerated widget.
     49   virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
     50 
     51   // Shows the RootWindowHost.
     52   virtual void Show() = 0;
     53 
     54   // Hides the RootWindowHost.
     55   virtual void Hide() = 0;
     56 
     57   // Toggles the host's full screen state.
     58   virtual void ToggleFullScreen() = 0;
     59 
     60   // Gets/Sets the size of the RootWindowHost.
     61   virtual gfx::Rect GetBounds() const = 0;
     62   virtual void SetBounds(const gfx::Rect& bounds) = 0;
     63 
     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;
     68 
     69   // Returns the location of the RootWindow on native screen.
     70   virtual gfx::Point GetLocationOnNativeScreen() const = 0;
     71 
     72   // Sets the OS capture to the root window.
     73   virtual void SetCapture() = 0;
     74 
     75   // Releases OS capture of the root window.
     76   virtual void ReleaseCapture() = 0;
     77 
     78   // Sets the currently displayed cursor.
     79   virtual void SetCursor(gfx::NativeCursor cursor) = 0;
     80 
     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
     85   // |location_return|.
     86   // This method is expensive, instead use gfx::Screen::GetCursorScreenPoint().
     87   virtual bool QueryMouseLocation(gfx::Point* location_return) = 0;
     88 
     89   // Clips the cursor to the bounds of the root window until UnConfineCursor().
     90   virtual bool ConfineCursorToRootWindow() = 0;
     91   virtual void UnConfineCursor() = 0;
     92 
     93   // Called when the cursor visibility has changed.
     94   virtual void OnCursorVisibilityChanged(bool show) = 0;
     95 
     96   // Moves the cursor to the specified location relative to the root window.
     97   virtual void MoveCursorTo(const gfx::Point& location) = 0;
     98 
     99   // Sets if the window should be focused when shown.
    100   virtual void SetFocusWhenShown(bool focus_when_shown) = 0;
    101 
    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
    104   // physical pixels.
    105   virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
    106                                   const gfx::Point& dest_offset,
    107                                   SkCanvas* canvas) = 0;
    108 
    109   // Posts |native_event| to the platform's event queue.
    110 #if !defined(OS_MACOSX)
    111   virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
    112 #endif
    113 
    114   // Called when the device scale factor of the root window has chagned.
    115   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0;
    116 
    117   // Stop listening events in preparation for shutdown.
    118   virtual void PrepareForShutdown() = 0;
    119 };
    120 
    121 }  // namespace aura
    122 
    123 #endif  // UI_AURA_ROOT_WINDOW_HOST_H_
    124