Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: blimp/client/app/linux/blimp_display_manager.cc

Issue 2363153002: Migrate Linux Blimp client to use BlimpClientContext (Closed)
Patch Set: Fix more nits Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/client/app/linux/blimp_display_manager.h" 5 #include "blimp/client/app/linux/blimp_display_manager.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "blimp/client/app/compositor/browser_compositor.h" 8 #include "blimp/client/app/compositor/browser_compositor.h"
8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" 9 #include "blimp/client/public/compositor/compositor_dependencies.h"
9 #include "blimp/client/core/compositor/blimp_compositor_manager.h" 10 #include "blimp/client/public/contents/blimp_contents.h"
10 #include "blimp/client/core/contents/tab_control_feature.h" 11 #include "blimp/client/public/contents/blimp_contents_view.h"
11 #include "blimp/client/core/render_widget/render_widget_feature.h" 12 #include "blimp/client/public/contents/blimp_navigation_controller.h"
12 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/gesture_detection/motion_event_generic.h" 14 #include "ui/events/gesture_detection/motion_event_generic.h"
15 #include "ui/events/gestures/motion_event_aura.h" 15 #include "ui/events/gestures/motion_event_aura.h"
16 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
17 #include "ui/platform_window/platform_window.h" 17 #include "ui/platform_window/platform_window.h"
18 #include "ui/platform_window/x11/x11_window.h" 18 #include "ui/platform_window/x11/x11_window.h"
19 19
20 namespace blimp { 20 namespace blimp {
21 namespace { 21 namespace {
22 constexpr int kDummyBlimpContentsId = 0;
23 constexpr int kPointer1Id = 0; 22 constexpr int kPointer1Id = 0;
24 constexpr int kPointer2Id = 1; 23 constexpr int kPointer2Id = 1;
25 constexpr int kZoomOffsetMultiplier = 4; 24 constexpr int kZoomOffsetMultiplier = 4;
26 } // namespace 25 } // namespace
27 26
28 namespace client { 27 namespace client {
29 28
30 BlimpDisplayManager::BlimpDisplayManager( 29 BlimpDisplayManager::BlimpDisplayManager(
31 const gfx::Size& window_size, 30 const gfx::Size& window_size,
32 BlimpDisplayManagerDelegate* delegate, 31 BlimpDisplayManagerDelegate* delegate,
33 RenderWidgetFeature* render_widget_feature, 32 CompositorDependencies* compositor_dependencies,
34 TabControlFeature* tab_control_feature) 33 std::unique_ptr<BlimpContents> contents)
35 : device_pixel_ratio_(1.f), 34 : device_pixel_ratio_(1.f),
36 delegate_(delegate), 35 delegate_(delegate),
37 tab_control_feature_(tab_control_feature), 36 contents_(std::move(contents)),
38 platform_window_(new ui::X11Window(this)) { 37 platform_window_(new ui::X11Window(this)) {
38 compositor_ = base::MakeUnique<BrowserCompositor>(compositor_dependencies);
39
39 platform_window_->SetBounds(gfx::Rect(window_size)); 40 platform_window_->SetBounds(gfx::Rect(window_size));
Kevin M 2016/09/27 21:59:41 This is a strange ctor side effect - any reason wh
steimel 2016/09/27 23:23:19 As part of the initialization of the display manag
David Trainor- moved to gerrit 2016/09/28 16:34:01 Suggested split: Pull out a SetWindowSize() and S
steimel 2016/09/28 20:33:07 Done.
41 OnBoundsChanged(platform_window_->GetBounds());
40 42
41 compositor_dependencies_ = base::MakeUnique<BlimpCompositorDependencies>( 43 compositor_->SetContentLayer(contents_->GetView()->GetLayer());
42 base::MakeUnique<CompositorDependenciesImpl>());
43
44 compositor_ = base::MakeUnique<BrowserCompositor>(
45 compositor_dependencies_->GetEmbedderDependencies());
46 compositor_->SetSize(platform_window_->GetBounds().size());
47
48 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>(
49 kDummyBlimpContentsId, render_widget_feature,
50 compositor_dependencies_.get());
51
52 compositor_->SetContentLayer(compositor_manager_->layer());
53 44
54 platform_window_->Show(); 45 platform_window_->Show();
55
56 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(),
57 device_pixel_ratio_);
58 } 46 }
59 47
60 BlimpDisplayManager::~BlimpDisplayManager() {} 48 BlimpDisplayManager::~BlimpDisplayManager() {}
61 49
62 void BlimpDisplayManager::OnBoundsChanged(const gfx::Rect& new_bounds) { 50 void BlimpDisplayManager::OnBoundsChanged(const gfx::Rect& new_bounds) {
63 compositor_->SetSize(new_bounds.size()); 51 compositor_->SetSize(new_bounds.size());
64 tab_control_feature_->SetSizeAndScale(new_bounds.size(), device_pixel_ratio_); 52 contents_->GetView()->SetSizeAndScale(new_bounds.size(), device_pixel_ratio_);
65 } 53 }
66 54
67 void BlimpDisplayManager::DispatchEvent(ui::Event* event) { 55 void BlimpDisplayManager::DispatchEvent(ui::Event* event) {
68 if (event->IsMouseWheelEvent()) { 56 if (event->IsMouseWheelEvent()) {
69 DispatchMouseWheelEvent(event->AsMouseWheelEvent()); 57 DispatchMouseWheelEvent(event->AsMouseWheelEvent());
70 } else if (event->IsMouseEvent()) { 58 } else if (event->IsMouseEvent()) {
71 DispatchMouseEvent(event->AsMouseEvent()); 59 DispatchMouseEvent(event->AsMouseEvent());
72 } 60 }
73 } 61 }
74 62
75 void BlimpDisplayManager::DispatchMotionEventAura( 63 void BlimpDisplayManager::DispatchMotionEventAura(
76 ui::MotionEventAura* touch_event_stream, 64 ui::MotionEventAura* touch_event_stream,
77 ui::EventType event_type, 65 ui::EventType event_type,
78 int pointer_id, 66 int pointer_id,
79 int pointer_x, 67 int pointer_x,
80 int pointer_y) { 68 int pointer_y) {
81 touch_event_stream->OnTouch( 69 touch_event_stream->OnTouch(
82 ui::TouchEvent(event_type, gfx::Point(pointer_x, pointer_y), pointer_id, 70 ui::TouchEvent(event_type, gfx::Point(pointer_x, pointer_y), pointer_id,
83 base::TimeTicks::Now())); 71 base::TimeTicks::Now()));
84 compositor_manager_->OnTouchEvent(*touch_event_stream); 72 contents_->GetView()->OnTouchEvent(*touch_event_stream);
85 } 73 }
86 74
87 void BlimpDisplayManager::DispatchMouseWheelEvent( 75 void BlimpDisplayManager::DispatchMouseWheelEvent(
88 ui::MouseWheelEvent* wheel_event) { 76 ui::MouseWheelEvent* wheel_event) {
89 // In order to better simulate the Android experience on the Linux client 77 // In order to better simulate the Android experience on the Linux client
90 // we convert mousewheel scrolling events into pinch/zoom events. 78 // we convert mousewheel scrolling events into pinch/zoom events.
91 bool zoom_out = wheel_event->y_offset() < 0; 79 bool zoom_out = wheel_event->y_offset() < 0;
92 Zoom(wheel_event->x(), wheel_event->y(), wheel_event->y_offset(), zoom_out); 80 Zoom(wheel_event->x(), wheel_event->y(), wheel_event->y_offset(), zoom_out);
93 } 81 }
94 82
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 129
142 void BlimpDisplayManager::DispatchMouseEvent(ui::MouseEvent* mouse_event) { 130 void BlimpDisplayManager::DispatchMouseEvent(ui::MouseEvent* mouse_event) {
143 ui::MotionEvent::Action action = MouseEventToAction(mouse_event); 131 ui::MotionEvent::Action action = MouseEventToAction(mouse_event);
144 132
145 if (action != ui::MotionEvent::ACTION_NONE && 133 if (action != ui::MotionEvent::ACTION_NONE &&
146 mouse_event->IsOnlyLeftMouseButton()) { 134 mouse_event->IsOnlyLeftMouseButton()) {
147 ui::PointerProperties mouse_properties(mouse_event->x(), mouse_event->y(), 135 ui::PointerProperties mouse_properties(mouse_event->x(), mouse_event->y(),
148 0); 136 0);
149 ui::MotionEventGeneric motion_event(action, mouse_event->time_stamp(), 137 ui::MotionEventGeneric motion_event(action, mouse_event->time_stamp(),
150 mouse_properties); 138 mouse_properties);
151 compositor_manager_->OnTouchEvent(motion_event); 139 contents_->GetView()->OnTouchEvent(motion_event);
152 } 140 }
153 } 141 }
154 142
155 void BlimpDisplayManager::OnCloseRequest() { 143 void BlimpDisplayManager::OnCloseRequest() {
156 compositor_manager_->SetVisible(false); 144 contents_->Hide();
157 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 145 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
158 platform_window_->Close(); 146 platform_window_->Close();
159 } 147 }
160 148
161 void BlimpDisplayManager::OnClosed() { 149 void BlimpDisplayManager::OnClosed() {
162 if (delegate_) 150 if (delegate_)
163 delegate_->OnClosed(); 151 delegate_->OnClosed();
164 } 152 }
165 153
166 void BlimpDisplayManager::OnAcceleratedWidgetAvailable( 154 void BlimpDisplayManager::OnAcceleratedWidgetAvailable(
167 gfx::AcceleratedWidget widget, 155 gfx::AcceleratedWidget widget,
168 float device_pixel_ratio) { 156 float device_pixel_ratio) {
169 device_pixel_ratio_ = device_pixel_ratio; 157 device_pixel_ratio_ = device_pixel_ratio;
170 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(), 158 contents_->GetView()->SetSizeAndScale(platform_window_->GetBounds().size(),
171 device_pixel_ratio_); 159 device_pixel_ratio_);
172 160
173 if (widget != gfx::kNullAcceleratedWidget) { 161 if (widget != gfx::kNullAcceleratedWidget) {
174 compositor_manager_->SetVisible(true); 162 contents_->Show();
175 compositor_->SetAcceleratedWidget(widget); 163 compositor_->SetAcceleratedWidget(widget);
176 } 164 }
177 } 165 }
178 166
179 void BlimpDisplayManager::OnAcceleratedWidgetDestroyed() { 167 void BlimpDisplayManager::OnAcceleratedWidgetDestroyed() {
180 compositor_manager_->SetVisible(false); 168 contents_->Hide();
181 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 169 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
182 } 170 }
183 171
184 } // namespace client 172 } // namespace client
185 } // namespace blimp 173 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698