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/window_tree_host_ozone.h" 6 7#include "ui/aura/window_event_dispatcher.h" 8#include "ui/ozone/public/cursor_factory_ozone.h" 9#include "ui/ozone/public/ozone_platform.h" 10#include "ui/platform_window/platform_window.h" 11 12namespace aura { 13 14WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) 15 : widget_(gfx::kNullAcceleratedWidget) { 16 platform_window_ = 17 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); 18} 19 20WindowTreeHostOzone::~WindowTreeHostOzone() { 21 DestroyCompositor(); 22 DestroyDispatcher(); 23} 24 25void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect& new_bounds) { 26 // TOOD(spang): Should we determine which parts changed? 27 OnHostResized(new_bounds.size()); 28 OnHostMoved(new_bounds.origin()); 29} 30 31void WindowTreeHostOzone::OnDamageRect(const gfx::Rect& damaged_region) { 32} 33 34void WindowTreeHostOzone::DispatchEvent(ui::Event* event) { 35 SendEventToProcessor(event); 36} 37 38void WindowTreeHostOzone::OnCloseRequest() { 39 OnHostCloseRequested(); 40} 41 42void WindowTreeHostOzone::OnClosed() { 43} 44 45void WindowTreeHostOzone::OnWindowStateChanged( 46 ui::PlatformWindowState new_state) { 47} 48 49void WindowTreeHostOzone::OnLostCapture() { 50} 51 52void WindowTreeHostOzone::OnAcceleratedWidgetAvailable( 53 gfx::AcceleratedWidget widget) { 54 widget_ = widget; 55 CreateCompositor(widget_); 56} 57 58void WindowTreeHostOzone::OnActivationChanged(bool active) { 59} 60 61ui::EventSource* WindowTreeHostOzone::GetEventSource() { 62 return this; 63} 64 65gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { 66 return widget_; 67} 68 69void WindowTreeHostOzone::Show() { 70 platform_window_->Show(); 71} 72 73void WindowTreeHostOzone::Hide() { 74 platform_window_->Hide(); 75} 76 77gfx::Rect WindowTreeHostOzone::GetBounds() const { 78 return platform_window_->GetBounds(); 79} 80 81void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) { 82 platform_window_->SetBounds(bounds); 83} 84 85gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const { 86 return platform_window_->GetBounds().origin(); 87} 88 89void WindowTreeHostOzone::SetCapture() { 90 platform_window_->SetCapture(); 91} 92 93void WindowTreeHostOzone::ReleaseCapture() { 94 platform_window_->ReleaseCapture(); 95} 96 97void WindowTreeHostOzone::PostNativeEvent( 98 const base::NativeEvent& native_event) { 99 SendEventToProcessor(static_cast<ui::Event*>(native_event)); 100} 101 102void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) { 103 platform_window_->SetCursor(cursor.platform()); 104} 105 106void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point& location) { 107 platform_window_->MoveCursorTo(location); 108} 109 110void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) { 111 NOTIMPLEMENTED(); 112} 113 114ui::EventProcessor* WindowTreeHostOzone::GetEventProcessor() { 115 return dispatcher(); 116} 117 118// static 119WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { 120 return new WindowTreeHostOzone(bounds); 121} 122 123// static 124gfx::Size WindowTreeHost::GetNativeScreenSize() { 125 NOTIMPLEMENTED(); 126 return gfx::Size(); 127} 128 129} // namespace aura 130