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

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: const Created 3 years, 6 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
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | services/ui/ws/test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (frame_generator_) { 171 if (frame_generator_) {
172 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor); 172 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor);
173 frame_generator_->OnWindowSizeChanged(metrics_.bounds_in_pixels.size()); 173 frame_generator_->OnWindowSizeChanged(metrics_.bounds_in_pixels.size());
174 } 174 }
175 } 175 }
176 176
177 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { 177 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const {
178 return widget_; 178 return widget_;
179 } 179 }
180 180
181 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) {
182 // TODO(riajiang): This is broken for HDPI because it mixes PPs and DIPs. See
183 // http://crbug.com/701036 for details.
184 const display::Display& display = delegate_->GetDisplay();
185 gfx::Point location = event->location();
186 location.Offset(display.bounds().x(), display.bounds().y());
187 event->set_root_location(location);
188 }
189
190 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { 181 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) {
191 // We only care if the window size has changed. 182 // We only care if the window size has changed.
192 if (new_bounds.size() == metrics_.bounds_in_pixels.size()) 183 if (new_bounds.size() == metrics_.bounds_in_pixels.size())
193 return; 184 return;
194 185
195 // TODO(tonikitoo): Handle the bounds changing in external window mode. The 186 // TODO(tonikitoo): Handle the bounds changing in external window mode. The
196 // window should be resized by the WS and it shouldn't involve ScreenManager. 187 // window should be resized by the WS and it shouldn't involve ScreenManager.
197 } 188 }
198 189
199 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) { 190 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {
200 if (frame_generator_) 191 if (frame_generator_)
201 frame_generator_->OnWindowDamaged(); 192 frame_generator_->OnWindowDamaged();
202 } 193 }
203 194
204 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { 195 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) {
205 if (event->IsLocatedEvent()) 196 // Event location and event root location are the same, and both in pixels
206 UpdateEventRootLocation(event->AsLocatedEvent()); 197 // and display coordinates.
207
208 if (event->IsScrollEvent()) { 198 if (event->IsScrollEvent()) {
209 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as 199 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as
210 // they are once we have proper support for scroll events. 200 // they are once we have proper support for scroll events.
211 201
212 ui::PointerEvent pointer_event( 202 ui::PointerEvent pointer_event(
213 ui::MouseWheelEvent(*event->AsScrollEvent())); 203 ui::MouseWheelEvent(*event->AsScrollEvent()));
214 SendEventToSink(&pointer_event); 204 SendEventToSink(&pointer_event);
215 } else if (event->IsMouseEvent()) { 205 } else if (event->IsMouseEvent()) {
216 ui::PointerEvent pointer_event(*event->AsMouseEvent()); 206 ui::PointerEvent pointer_event(*event->AsMouseEvent());
217 SendEventToSink(&pointer_event); 207 SendEventToSink(&pointer_event);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 263 }
274 264
275 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { 265 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() {
276 NOTREACHED(); 266 NOTREACHED();
277 } 267 }
278 268
279 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 269 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
280 270
281 } // namespace ws 271 } // namespace ws
282 } // namespace ui 272 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | services/ui/ws/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698