OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "blimp/client/linux/blimp_display_manager.h" |
| 6 |
| 7 #include "blimp/client/compositor/blimp_compositor.h" |
| 8 #include "blimp/client/session/render_widget_feature.h" |
| 9 #include "blimp/client/session/tab_control_feature.h" |
| 10 #include "ui/events/event.h" |
| 11 #include "ui/gfx/geometry/size.h" |
| 12 #include "ui/platform_window/platform_window.h" |
| 13 #include "ui/platform_window/x11/x11_window.h" |
| 14 |
| 15 namespace blimp { |
| 16 |
| 17 BlimpDisplayManager::BlimpDisplayManager( |
| 18 const gfx::Size& window_size, |
| 19 BlimpDisplayManagerDelegate* delegate, |
| 20 RenderWidgetFeature* render_widget_feature, |
| 21 TabControlFeature* tab_control_feature) |
| 22 : device_pixel_ratio_(1.f), |
| 23 delegate_(delegate), |
| 24 tab_control_feature_(tab_control_feature), |
| 25 blimp_compositor_(new BlimpCompositor(1.f, render_widget_feature)), |
| 26 platform_window_(new ui::X11Window(this)) { |
| 27 platform_window_->SetBounds(gfx::Rect(window_size)); |
| 28 platform_window_->Show(); |
| 29 blimp_compositor_->SetSize(window_size); |
| 30 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(), |
| 31 device_pixel_ratio_); |
| 32 |
| 33 blimp_compositor_->SetVisible(true); |
| 34 } |
| 35 |
| 36 BlimpDisplayManager::~BlimpDisplayManager() {} |
| 37 |
| 38 void BlimpDisplayManager::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 39 blimp_compositor_->SetSize(new_bounds.size()); |
| 40 tab_control_feature_->SetSizeAndScale(new_bounds.size(), device_pixel_ratio_); |
| 41 } |
| 42 |
| 43 void BlimpDisplayManager::OnDamageRect(const gfx::Rect& damaged_region) {} |
| 44 |
| 45 void BlimpDisplayManager::DispatchEvent(ui::Event* event) { |
| 46 // TODO(dtrainor): Look into using web_input_event_aura to translate these to |
| 47 // blink events. |
| 48 } |
| 49 |
| 50 void BlimpDisplayManager::OnCloseRequest() { |
| 51 blimp_compositor_->SetVisible(false); |
| 52 platform_window_->Close(); |
| 53 } |
| 54 |
| 55 void BlimpDisplayManager::OnClosed() { |
| 56 if (delegate_) |
| 57 delegate_->OnClosed(); |
| 58 } |
| 59 |
| 60 void BlimpDisplayManager::OnWindowStateChanged( |
| 61 ui::PlatformWindowState new_state) {} |
| 62 |
| 63 void BlimpDisplayManager::OnLostCapture() {} |
| 64 |
| 65 void BlimpDisplayManager::OnAcceleratedWidgetAvailable( |
| 66 gfx::AcceleratedWidget widget, |
| 67 float device_pixel_ratio) { |
| 68 device_pixel_ratio_ = device_pixel_ratio; |
| 69 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(), |
| 70 device_pixel_ratio_); |
| 71 |
| 72 if (widget != gfx::kNullAcceleratedWidget) |
| 73 blimp_compositor_->SetAcceleratedWidget(widget); |
| 74 } |
| 75 |
| 76 void BlimpDisplayManager::OnAcceleratedWidgetDestroyed() { |
| 77 blimp_compositor_->ReleaseAcceleratedWidget(); |
| 78 } |
| 79 |
| 80 void BlimpDisplayManager::OnActivationChanged(bool active) {} |
| 81 |
| 82 } // namespace blimp |
OLD | NEW |