Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "gpu/ipc/client/gpu_channel_host.h" | 8 #include "gpu/ipc/client/gpu_channel_host.h" |
| 9 #include "services/ui/display/screen_manager.h" | 9 #include "services/ui/display/screen_manager.h" |
| 10 #include "services/ui/ws/platform_display_init_params.h" | 10 #include "services/ui/ws/platform_display_init_params.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 return widget_; | 162 return widget_; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) { | 165 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) { |
| 166 gfx::Point location = event->location(); | 166 gfx::Point location = event->location(); |
| 167 location.Offset(metrics_.bounds.x(), metrics_.bounds.y()); | 167 location.Offset(metrics_.bounds.x(), metrics_.bounds.y()); |
| 168 event->set_root_location(location); | 168 event->set_root_location(location); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { | 171 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 172 // Since we aren't resizing the Chrome OS display size, if the user resizes | |
| 173 // the window or the WM doesn't honor the requested size then cursor | |
| 174 // locations end up incorrect. | |
| 175 window_height_offset_ = new_bounds.height() - metrics_.pixel_size.height(); | |
| 176 | |
| 172 // We only care if the window size has changed. | 177 // We only care if the window size has changed. |
| 173 if (new_bounds.size() == metrics_.pixel_size) | 178 if (new_bounds.size() == metrics_.pixel_size) |
| 174 return; | 179 return; |
| 175 | 180 |
| 176 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support | 181 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support |
| 177 // PlatformWindow initiated resizes. For other platforms we need to do | 182 // PlatformWindow initiated resizes. For other platforms we need to do |
| 178 // something but that isn't fully flushed out. | 183 // something but that isn't fully flushed out. |
| 179 } | 184 } |
| 180 | 185 |
| 181 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {} | 186 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {} |
| 182 | 187 |
| 183 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { | 188 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { |
| 184 if (event->IsLocatedEvent()) | 189 if (event->IsLocatedEvent()) { |
| 185 UpdateEventRootLocation(event->AsLocatedEvent()); | 190 ui::LocatedEvent* located_event = event->AsLocatedEvent(); |
| 191 gfx::PointF location = located_event->location_f(); | |
| 192 location.Offset(0, -window_height_offset_); | |
| 193 located_event->set_location_f(location); | |
| 194 UpdateEventRootLocation(located_event); | |
|
tonikitoo
2017/01/13 17:07:14
driven-by comment: maybe moving moving this offset
| |
| 195 } | |
| 186 | 196 |
| 187 if (event->IsScrollEvent()) { | 197 if (event->IsScrollEvent()) { |
| 188 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as | 198 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as |
| 189 // they are once we have proper support for scroll events. | 199 // they are once we have proper support for scroll events. |
| 190 delegate_->OnEvent( | 200 delegate_->OnEvent( |
| 191 ui::PointerEvent(ui::MouseWheelEvent(*event->AsScrollEvent()))); | 201 ui::PointerEvent(ui::MouseWheelEvent(*event->AsScrollEvent()))); |
| 192 } else if (event->IsMouseEvent()) { | 202 } else if (event->IsMouseEvent()) { |
| 193 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); | 203 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); |
| 194 } else if (event->IsTouchEvent()) { | 204 } else if (event->IsTouchEvent()) { |
| 195 delegate_->OnEvent(ui::PointerEvent(*event->AsTouchEvent())); | 205 delegate_->OnEvent(ui::PointerEvent(*event->AsTouchEvent())); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 ServerWindow* PlatformDisplayDefault::GetActiveRootWindow() { | 268 ServerWindow* PlatformDisplayDefault::GetActiveRootWindow() { |
| 259 return delegate_->GetActiveRootWindow(); | 269 return delegate_->GetActiveRootWindow(); |
| 260 } | 270 } |
| 261 | 271 |
| 262 bool PlatformDisplayDefault::IsInHighContrastMode() { | 272 bool PlatformDisplayDefault::IsInHighContrastMode() { |
| 263 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 273 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
| 264 } | 274 } |
| 265 | 275 |
| 266 } // namespace ws | 276 } // namespace ws |
| 267 } // namespace ui | 277 } // namespace ui |
| OLD | NEW |