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

Side by Side Diff: services/ui/ws/platform_display_default.cc

Issue 2778943005: Keep root_location to be in pixels and display coordinates in WS. (Closed)
Patch Set: . Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/ws/platform_display_default.h" 5 #include "services/ui/ws/platform_display_default.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "gpu/ipc/client/gpu_channel_host.h" 10 #include "gpu/ipc/client/gpu_channel_host.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (frame_generator_) { 172 if (frame_generator_) {
173 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor); 173 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor);
174 frame_generator_->OnWindowSizeChanged(metrics_.bounds_in_pixels.size()); 174 frame_generator_->OnWindowSizeChanged(metrics_.bounds_in_pixels.size());
175 } 175 }
176 } 176 }
177 177
178 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { 178 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const {
179 return widget_; 179 return widget_;
180 } 180 }
181 181
182 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) {
183 // TODO(riajiang): This is broken for HDPI because it mixes PPs and DIPs. See
184 // http://crbug.com/701036 for details.
185 const display::Display& display = delegate_->GetDisplay();
186 gfx::Point location = event->location();
187 location.Offset(display.bounds().x(), display.bounds().y());
188 event->set_root_location(location);
189 }
190
191 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { 182 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) {
192 // We only care if the window size has changed. 183 // We only care if the window size has changed.
193 if (new_bounds.size() == metrics_.bounds_in_pixels.size()) 184 if (new_bounds.size() == metrics_.bounds_in_pixels.size())
194 return; 185 return;
195 186
196 // TODO(tonikitoo): Handle the bounds changing in external window mode. The 187 // TODO(tonikitoo): Handle the bounds changing in external window mode. The
197 // window should be resized by the WS and it shouldn't involve ScreenManager. 188 // window should be resized by the WS and it shouldn't involve ScreenManager.
198 } 189 }
199 190
200 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) { 191 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {
201 if (frame_generator_) 192 if (frame_generator_)
202 frame_generator_->OnWindowDamaged(); 193 frame_generator_->OnWindowDamaged();
203 } 194 }
204 195
205 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { 196 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) {
206 if (event->IsLocatedEvent()) 197 // Event location and event root location are the same, and both in pixels
207 UpdateEventRootLocation(event->AsLocatedEvent()); 198 // and display coordinates.
208
209 if (event->IsScrollEvent()) { 199 if (event->IsScrollEvent()) {
210 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as 200 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as
211 // they are once we have proper support for scroll events. 201 // they are once we have proper support for scroll events.
212 202
213 ui::PointerEvent pointer_event( 203 ui::PointerEvent pointer_event(
214 ui::MouseWheelEvent(*event->AsScrollEvent())); 204 ui::MouseWheelEvent(*event->AsScrollEvent()));
215 SendEventToSink(&pointer_event); 205 SendEventToSink(&pointer_event);
216 } else if (event->IsMouseEvent()) { 206 } else if (event->IsMouseEvent()) {
217 ui::PointerEvent pointer_event(*event->AsMouseEvent()); 207 ui::PointerEvent pointer_event(*event->AsMouseEvent());
218 SendEventToSink(&pointer_event); 208 SendEventToSink(&pointer_event);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 264 }
275 265
276 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { 266 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() {
277 NOTREACHED(); 267 NOTREACHED();
278 } 268 }
279 269
280 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 270 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
281 271
282 } // namespace ws 272 } // namespace ws
283 } // namespace ui 273 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698