#ifndef UI_AURA_WINDOW_TREE_HOST_H_
#define UI_AURA_WINDOW_TREE_HOST_H_
#include <vector>
#include "base/event_types.h"
#include "base/message_loop/message_loop.h"
#include "ui/aura/aura_export.h"
#include "ui/base/cursor/cursor.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class Insets;
class Point;
class Rect;
class Size;
class Transform;
}
namespace ui {
class Compositor;
class EventProcessor;
class ViewProp;
}
namespace aura {
class RootWindowTransformer;
class WindowEventDispatcher;
class WindowTreeHostObserver;
class AURA_EXPORT WindowTreeHost {
public:
virtual ~WindowTreeHost();
static WindowTreeHost* Create(const gfx::Rect& bounds);
static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget);
void InitHost();
void InitCompositor();
void AddObserver(WindowTreeHostObserver* observer);
void RemoveObserver(WindowTreeHostObserver* observer);
Window* window() { return window_; }
const Window* window() const { return window_; }
ui::EventProcessor* event_processor();
WindowEventDispatcher* dispatcher() {
return const_cast<WindowEventDispatcher*>(
const_cast<const WindowTreeHost*>(this)->dispatcher());
}
const WindowEventDispatcher* dispatcher() const { return dispatcher_.get(); }
ui::Compositor* compositor() { return compositor_.get(); }
void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
gfx::Transform GetRootTransform() const;
void SetTransform(const gfx::Transform& transform);
gfx::Transform GetInverseRootTransform() const;
void UpdateRootWindowSize(const gfx::Size& host_size);
static gfx::Size GetNativeScreenSize();
void ConvertPointToNativeScreen(gfx::Point* point) const;
void ConvertPointFromNativeScreen(gfx::Point* point) const;
void ConvertPointToHost(gfx::Point* point) const;
void ConvertPointFromHost(gfx::Point* point) const;
void SetCursor(gfx::NativeCursor cursor);
void OnCursorVisibilityChanged(bool visible);
void MoveCursorTo(const gfx::Point& location);
void MoveCursorToHostLocation(const gfx::Point& host_location);
gfx::NativeCursor last_cursor() const { return last_cursor_; }
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void ToggleFullScreen() = 0;
virtual gfx::Rect GetBounds() const = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual gfx::Insets GetInsets() const = 0;
virtual void SetInsets(const gfx::Insets& insets) = 0;
virtual void SetCapture() = 0;
virtual void ReleaseCapture() = 0;
virtual bool QueryMouseLocation(gfx::Point* location_return) = 0;
virtual bool ConfineCursorToRootWindow() = 0;
virtual void UnConfineCursor() = 0;
virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0;
protected:
friend class TestScreen;
WindowTreeHost();
void DestroyCompositor();
void DestroyDispatcher();
void CreateCompositor(gfx::AcceleratedWidget accelerated_widget);
virtual gfx::Point GetLocationOnNativeScreen() const = 0;
void OnHostMoved(const gfx::Point& new_location);
void OnHostResized(const gfx::Size& new_size);
void OnHostCloseRequested();
void OnHostActivated();
void OnHostLostWindowCapture();
virtual void SetCursorNative(gfx::NativeCursor cursor) = 0;
virtual void MoveCursorToNative(const gfx::Point& location) = 0;
virtual void OnCursorVisibilityChangedNative(bool show) = 0;
private:
void MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location);
Window* window_;
ObserverList<WindowTreeHostObserver> observers_;
scoped_ptr<WindowEventDispatcher> dispatcher_;
scoped_ptr<ui::Compositor> compositor_;
scoped_ptr<RootWindowTransformer> transformer_;
gfx::NativeCursor last_cursor_;
scoped_ptr<ui::ViewProp> prop_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHost);
};
}
#endif