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/events/ozone/event_factory_ozone.h" 9 #include "ui/gfx/ozone/surface_factory_ozone.h" 10 #include "ui/ozone/ozone_platform.h" 11 12 namespace aura { 13 RootWindowHostOzone(const gfx::Rect & bounds)14RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds) 15 : widget_(0), 16 bounds_(bounds) { 17 ui::OzonePlatform::Initialize(); 18 19 // EventFactoryOzone creates converters that obtain input events from the 20 // underlying input system and dispatch them as |ui::Event| instances into 21 // Aura. 22 ui::EventFactoryOzone::GetInstance()->StartProcessingEvents(); 23 24 gfx::SurfaceFactoryOzone* surface_factory = 25 gfx::SurfaceFactoryOzone::GetInstance(); 26 widget_ = surface_factory->GetAcceleratedWidget(); 27 28 surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_); 29 30 base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this); 31 } 32 ~RootWindowHostOzone()33RootWindowHostOzone::~RootWindowHostOzone() { 34 base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0); 35 } 36 Dispatch(const base::NativeEvent & ne)37bool RootWindowHostOzone::Dispatch(const base::NativeEvent& ne) { 38 ui::Event* event = static_cast<ui::Event*>(ne); 39 if (event->IsTouchEvent()) { 40 ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(ne); 41 delegate_->OnHostTouchEvent(touchev); 42 } else if (event->IsKeyEvent()) { 43 ui::KeyEvent* keyev = static_cast<ui::KeyEvent*>(ne); 44 delegate_->OnHostKeyEvent(keyev); 45 } else if (event->IsMouseEvent()) { 46 ui::MouseEvent* mouseev = static_cast<ui::MouseEvent*>(ne); 47 delegate_->OnHostMouseEvent(mouseev); 48 } 49 return true; 50 } 51 GetRootWindow()52RootWindow* RootWindowHostOzone::GetRootWindow() { 53 return delegate_->AsRootWindow(); 54 } 55 GetAcceleratedWidget()56gfx::AcceleratedWidget RootWindowHostOzone::GetAcceleratedWidget() { 57 return widget_; 58 } 59 Show()60void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); } 61 Hide()62void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); } 63 ToggleFullScreen()64void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); } 65 GetBounds() const66gfx::Rect RootWindowHostOzone::GetBounds() const { return bounds_; } 67 SetBounds(const gfx::Rect & bounds)68void RootWindowHostOzone::SetBounds(const gfx::Rect& bounds) { 69 NOTIMPLEMENTED(); 70 } 71 GetInsets() const72gfx::Insets RootWindowHostOzone::GetInsets() const { return gfx::Insets(); } 73 SetInsets(const gfx::Insets & insets)74void RootWindowHostOzone::SetInsets(const gfx::Insets& insets) { 75 NOTIMPLEMENTED(); 76 } 77 GetLocationOnNativeScreen() const78gfx::Point RootWindowHostOzone::GetLocationOnNativeScreen() const { 79 return bounds_.origin(); 80 } 81 SetCapture()82void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); } 83 ReleaseCapture()84void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); } 85 SetCursor(gfx::NativeCursor cursor)86void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) { 87 NOTIMPLEMENTED(); 88 } 89 QueryMouseLocation(gfx::Point * location_return)90bool RootWindowHostOzone::QueryMouseLocation(gfx::Point* location_return) { 91 NOTIMPLEMENTED(); 92 return false; 93 } 94 ConfineCursorToRootWindow()95bool RootWindowHostOzone::ConfineCursorToRootWindow() { 96 NOTIMPLEMENTED(); 97 return false; 98 } 99 UnConfineCursor()100void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); } 101 OnCursorVisibilityChanged(bool show)102void RootWindowHostOzone::OnCursorVisibilityChanged(bool show) { 103 NOTIMPLEMENTED(); 104 } 105 MoveCursorTo(const gfx::Point & location)106void RootWindowHostOzone::MoveCursorTo(const gfx::Point& location) { 107 NOTIMPLEMENTED(); 108 } 109 PostNativeEvent(const base::NativeEvent & native_event)110void RootWindowHostOzone::PostNativeEvent( 111 const base::NativeEvent& native_event) { 112 NOTIMPLEMENTED(); 113 } 114 OnDeviceScaleFactorChanged(float device_scale_factor)115void RootWindowHostOzone::OnDeviceScaleFactorChanged( 116 float device_scale_factor) { 117 NOTIMPLEMENTED(); 118 } 119 PrepareForShutdown()120void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); } 121 122 // static Create(const gfx::Rect & bounds)123RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { 124 return new RootWindowHostOzone(bounds); 125 } 126 127 // static GetNativeScreenSize()128gfx::Size RootWindowHost::GetNativeScreenSize() { 129 NOTIMPLEMENTED(); 130 return gfx::Size(); 131 } 132 133 } // namespace aura 134