Home | History | Annotate | Download | only in aura
      1 // Copyright 2013 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 #include "ui/aura/root_window_host_ozone.h"
      6 
      7 #include "ui/aura/root_window.h"
      8 #include "ui/base/ozone/surface_factory_ozone.h"
      9 
     10 namespace aura {
     11 
     12 RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
     13    : delegate_(NULL),
     14       widget_(0),
     15       bounds_(bounds),
     16       factory_(new ui::EventFactoryOzone()) {
     17   factory_->CreateStartupEventConverters();
     18   ui::SurfaceFactoryOzone* surface_factory =
     19       ui::SurfaceFactoryOzone::GetInstance();
     20   widget_ = surface_factory->GetAcceleratedWidget();
     21 
     22   surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
     23 
     24   base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
     25 }
     26 
     27 RootWindowHostOzone::~RootWindowHostOzone() {
     28   base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
     29 }
     30 
     31 bool RootWindowHostOzone::Dispatch(const base::NativeEvent& ne) {
     32   ui::Event* event = static_cast<ui::Event*>(ne);
     33   if (event->IsTouchEvent()) {
     34     ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(ne);
     35     delegate_->OnHostTouchEvent(touchev);
     36   } else if (event->IsKeyEvent()) {
     37     ui::KeyEvent* keyev = static_cast<ui::KeyEvent*>(ne);
     38     delegate_->OnHostKeyEvent(keyev);
     39   }
     40   return true;
     41 }
     42 
     43 void RootWindowHostOzone::SetDelegate(RootWindowHostDelegate* delegate) {
     44   delegate_ = delegate;
     45 }
     46 
     47 RootWindow* RootWindowHostOzone::GetRootWindow() {
     48   return delegate_->AsRootWindow();
     49 }
     50 
     51 gfx::AcceleratedWidget RootWindowHostOzone::GetAcceleratedWidget() {
     52   return widget_;
     53 }
     54 
     55 void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); }
     56 
     57 void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); }
     58 
     59 void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
     60 
     61 gfx::Rect RootWindowHostOzone::GetBounds() const { return bounds_; }
     62 
     63 void RootWindowHostOzone::SetBounds(const gfx::Rect& bounds) {
     64   NOTIMPLEMENTED();
     65 }
     66 
     67 gfx::Insets RootWindowHostOzone::GetInsets() const { return gfx::Insets(); }
     68 
     69 void RootWindowHostOzone::SetInsets(const gfx::Insets& insets) {
     70   NOTIMPLEMENTED();
     71 }
     72 
     73 gfx::Point RootWindowHostOzone::GetLocationOnNativeScreen() const {
     74   return bounds_.origin();
     75 }
     76 
     77 void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); }
     78 
     79 void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
     80 
     81 void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) {
     82   NOTIMPLEMENTED();
     83 }
     84 
     85 bool RootWindowHostOzone::QueryMouseLocation(gfx::Point* location_return) {
     86   NOTIMPLEMENTED();
     87   return false;
     88 }
     89 
     90 bool RootWindowHostOzone::ConfineCursorToRootWindow() {
     91   NOTIMPLEMENTED();
     92   return false;
     93 }
     94 
     95 void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
     96 
     97 void RootWindowHostOzone::OnCursorVisibilityChanged(bool show) {
     98   NOTIMPLEMENTED();
     99 }
    100 
    101 void RootWindowHostOzone::MoveCursorTo(const gfx::Point& location) {
    102   NOTIMPLEMENTED();
    103 }
    104 
    105 void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) {
    106   NOTIMPLEMENTED();
    107 }
    108 
    109 bool RootWindowHostOzone::CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
    110                                              const gfx::Point& dest_offset,
    111                                              SkCanvas* canvas) {
    112   NOTIMPLEMENTED();
    113   return false;
    114 }
    115 
    116 void RootWindowHostOzone::PostNativeEvent(
    117     const base::NativeEvent& native_event) {
    118   NOTIMPLEMENTED();
    119 }
    120 
    121 void RootWindowHostOzone::OnDeviceScaleFactorChanged(
    122     float device_scale_factor) {
    123   NOTIMPLEMENTED();
    124 }
    125 
    126 void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
    127 
    128 // static
    129 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
    130   return new RootWindowHostOzone(bounds);
    131 }
    132 
    133 // static
    134 gfx::Size RootWindowHost::GetNativeScreenSize() {
    135   NOTIMPLEMENTED();
    136   return gfx::Size();
    137 }
    138 
    139 }  // namespace aura
    140