1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/aura/root_window_host_ozone.h"
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/aura/root_window.h"
8ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "ui/base/ozone/surface_factory_ozone.h"
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace aura {
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
13ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch   : delegate_(NULL),
14ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      widget_(0),
15ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      bounds_(bounds),
16ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      factory_(new ui::EventFactoryOzone()) {
17ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  factory_->CreateStartupEventConverters();
18ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  ui::SurfaceFactoryOzone* surface_factory =
19ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch      ui::SurfaceFactoryOzone::GetInstance();
20ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  widget_ = surface_factory->GetAcceleratedWidget();
21ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
22ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
23ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)RootWindowHostOzone::~RootWindowHostOzone() {
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool RootWindowHostOzone::Dispatch(const base::NativeEvent& ne) {
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ui::Event* event = static_cast<ui::Event*>(ne);
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (event->IsTouchEvent()) {
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(ne);
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    delegate_->OnHostTouchEvent(touchev);
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  } else if (event->IsKeyEvent()) {
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ui::KeyEvent* keyev = static_cast<ui::KeyEvent*>(ne);
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    delegate_->OnHostKeyEvent(keyev);
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return true;
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetDelegate(RootWindowHostDelegate* delegate) {
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  delegate_ = delegate;
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)RootWindow* RootWindowHostOzone::GetRootWindow() {
48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return delegate_->AsRootWindow();
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::AcceleratedWidget RootWindowHostOzone::GetAcceleratedWidget() {
52ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  return widget_;
53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); }
56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); }
58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::Rect RootWindowHostOzone::GetBounds() const { return bounds_; }
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetBounds(const gfx::Rect& bounds) {
64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::Insets RootWindowHostOzone::GetInsets() const { return gfx::Insets(); }
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetInsets(const gfx::Insets& insets) {
70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::Point RootWindowHostOzone::GetLocationOnNativeScreen() const {
74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return bounds_.origin();
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); }
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) {
82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool RootWindowHostOzone::QueryMouseLocation(gfx::Point* location_return) {
86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return false;
88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool RootWindowHostOzone::ConfineCursorToRootWindow() {
91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return false;
93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::OnCursorVisibilityChanged(bool show) {
98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::MoveCursorTo(const gfx::Point& location) {
102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) {
106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)bool RootWindowHostOzone::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                             const gfx::Point& dest_offset,
111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                             SkCanvas* canvas) {
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return false;
114868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::PostNativeEvent(
117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const base::NativeEvent& native_event) {
118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::OnDeviceScaleFactorChanged(
122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    float device_scale_factor) {
123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
124868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// static
129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return new RootWindowHostOzone(bounds);
131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// static
134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)gfx::Size RootWindowHost::GetNativeScreenSize() {
135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  NOTIMPLEMENTED();
136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  return gfx::Size();
137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace aura
140