OLD | NEW |
(Empty) | |
| 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_android.h" |
| 6 |
| 7 #include "base/trace_event/trace_event.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/base/ime/input_method.h" |
| 10 #include "ui/compositor/compositor.h" |
| 11 #include "ui/platform_window/android/platform_window_android.h" |
| 12 |
| 13 namespace aura { |
| 14 namespace { |
| 15 WindowTreeHostAndroid* instance = nullptr; |
| 16 } |
| 17 |
| 18 WindowTreeHostAndroid::WindowTreeHostAndroid(const gfx::Rect& bounds) |
| 19 : widget_(gfx::kNullAcceleratedWidget), current_cursor_(ui::kCursorNull) { |
| 20 DCHECK(!instance); |
| 21 instance = this; |
| 22 CreateCompositor(); |
| 23 platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
| 24 platform_window_->SetBounds(bounds); |
| 25 platform_window_->Show(); |
| 26 } |
| 27 |
| 28 // static |
| 29 WindowTreeHostAndroid* WindowTreeHostAndroid::GetHost() { |
| 30 return instance; |
| 31 } |
| 32 |
| 33 |
| 34 WindowTreeHostAndroid::~WindowTreeHostAndroid() { |
| 35 DestroyCompositor(); |
| 36 DestroyDispatcher(); |
| 37 } |
| 38 |
| 39 ui::EventSource* WindowTreeHostAndroid::GetEventSource() { |
| 40 return this; |
| 41 } |
| 42 |
| 43 gfx::AcceleratedWidget WindowTreeHostAndroid::GetAcceleratedWidget() { |
| 44 return widget_; |
| 45 } |
| 46 |
| 47 void WindowTreeHostAndroid::ShowImpl() { |
| 48 platform_window_->Show(); |
| 49 } |
| 50 |
| 51 void WindowTreeHostAndroid::HideImpl() { |
| 52 platform_window_->Hide(); |
| 53 } |
| 54 |
| 55 gfx::Rect WindowTreeHostAndroid::GetBounds() const { |
| 56 return platform_window_->GetBounds(); |
| 57 } |
| 58 |
| 59 void WindowTreeHostAndroid::SetBounds(const gfx::Rect& bounds) { |
| 60 platform_window_->SetBounds(bounds); |
| 61 } |
| 62 |
| 63 gfx::Point WindowTreeHostAndroid::GetLocationOnNativeScreen() const { |
| 64 return platform_window_->GetBounds().origin(); |
| 65 } |
| 66 |
| 67 void WindowTreeHostAndroid::SetCapture() { |
| 68 platform_window_->SetCapture(); |
| 69 } |
| 70 |
| 71 void WindowTreeHostAndroid::ReleaseCapture() { |
| 72 platform_window_->ReleaseCapture(); |
| 73 } |
| 74 |
| 75 void WindowTreeHostAndroid::SetCursorNative(gfx::NativeCursor cursor) { |
| 76 if (cursor == current_cursor_) |
| 77 return; |
| 78 current_cursor_ = cursor; |
| 79 platform_window_->SetCursor(cursor.platform()); |
| 80 } |
| 81 |
| 82 void WindowTreeHostAndroid::MoveCursorToNative(const gfx::Point& location) { |
| 83 platform_window_->MoveCursorTo(location); |
| 84 } |
| 85 |
| 86 void WindowTreeHostAndroid::OnCursorVisibilityChangedNative(bool show) { |
| 87 } |
| 88 |
| 89 void WindowTreeHostAndroid::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 90 // TOOD(spang): Should we determine which parts changed? |
| 91 OnHostResized(new_bounds.size()); |
| 92 OnHostMoved(new_bounds.origin()); |
| 93 } |
| 94 |
| 95 void WindowTreeHostAndroid::OnDamageRect(const gfx::Rect& damaged_region) { |
| 96 } |
| 97 |
| 98 void WindowTreeHostAndroid::DispatchEvent(ui::Event* event) { |
| 99 TRACE_EVENT0("input", "WindowTreeHostAndroid::DispatchEvent"); |
| 100 SendEventToProcessor(event); |
| 101 } |
| 102 |
| 103 void WindowTreeHostAndroid::OnCloseRequest() { |
| 104 OnHostCloseRequested(); |
| 105 } |
| 106 |
| 107 void WindowTreeHostAndroid::OnClosed() { |
| 108 } |
| 109 |
| 110 void WindowTreeHostAndroid::OnWindowStateChanged( |
| 111 ui::PlatformWindowState new_state) { |
| 112 } |
| 113 |
| 114 void WindowTreeHostAndroid::OnLostCapture() { |
| 115 } |
| 116 |
| 117 void WindowTreeHostAndroid::OnAcceleratedWidgetAvailable( |
| 118 gfx::AcceleratedWidget widget, |
| 119 float device_pixel_ratio) { |
| 120 widget_ = widget; |
| 121 WindowTreeHost::OnAcceleratedWidgetAvailable(); |
| 122 } |
| 123 |
| 124 void WindowTreeHostAndroid::OnActivationChanged(bool active) { |
| 125 if (active) |
| 126 GetInputMethod()->OnFocus(); |
| 127 else |
| 128 GetInputMethod()->OnBlur(); |
| 129 } |
| 130 |
| 131 ui::InputMethod* WindowTreeHostAndroid::GetInputMethod2() { |
| 132 return GetInputMethod(); |
| 133 } |
| 134 |
| 135 // static |
| 136 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { |
| 137 return new WindowTreeHostAndroid(bounds); |
| 138 } |
| 139 |
| 140 // static |
| 141 gfx::Size WindowTreeHost::GetNativeScreenSize() { |
| 142 NOTIMPLEMENTED(); |
| 143 return gfx::Size(); |
| 144 } |
| 145 |
| 146 } // namespace aura |
OLD | NEW |