| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/ozone/platform/dri/dri_window.h" | 5 #include "ui/ozone/platform/dri/dri_window.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // If there is a grab, capture events here. | 118 // If there is a grab, capture events here. |
| 119 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); | 119 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); |
| 120 if (grabber != gfx::kNullAcceleratedWidget) | 120 if (grabber != gfx::kNullAcceleratedWidget) |
| 121 return grabber == widget_; | 121 return grabber == widget_; |
| 122 | 122 |
| 123 if (event->IsTouchEvent()) { | 123 if (event->IsTouchEvent()) { |
| 124 // Dispatch the event if it is from the touchscreen associated with the | 124 // Dispatch the event if it is from the touchscreen associated with the |
| 125 // DriWindow. We cannot check the event's location because if the | 125 // DriWindow. We cannot check the event's location because if the |
| 126 // touchscreen has a bezel, touches in the bezel have a location outside of | 126 // touchscreen has a bezel, touches in the bezel have a location outside of |
| 127 // |bounds_|. | 127 // |bounds_|. |
| 128 int64_t display_id = | 128 gfx::Display display = |
| 129 DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( | 129 DeviceDataManager::GetInstance()->GetDisplayForTouchDevice( |
| 130 event->source_device_id()); | 130 event->source_device_id()); |
| 131 | 131 |
| 132 if (display_id == gfx::Display::kInvalidDisplayID) | 132 if (display.id() == gfx::Display::kInvalidDisplayID) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 DisplaySnapshot* snapshot = display_manager_->GetDisplay(display_id); | 135 // If |display| is mirroring another display's content, touches should be |
| 136 // dispatched to that display. |
| 137 int64_t touch_display_id = |
| 138 display.mirrored_display_id() == gfx::Display::kInvalidDisplayID |
| 139 ? display.id() |
| 140 : display.mirrored_display_id(); |
| 141 |
| 142 DisplaySnapshot* snapshot = display_manager_->GetDisplay(touch_display_id); |
| 136 if (!snapshot || !snapshot->current_mode()) | 143 if (!snapshot || !snapshot->current_mode()) |
| 137 return false; | 144 return false; |
| 138 | 145 |
| 139 gfx::Rect display_bounds(snapshot->origin(), | 146 gfx::Rect touch_display_bounds(snapshot->origin(), |
| 140 snapshot->current_mode()->size()); | 147 snapshot->current_mode()->size()); |
| 141 return display_bounds == bounds_; | 148 return touch_display_bounds == bounds_; |
| 142 } else if (event->IsLocatedEvent()) { | 149 } else if (event->IsLocatedEvent()) { |
| 143 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | 150 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); |
| 144 return bounds_.Contains(gfx::ToFlooredPoint(located_event->location())); | 151 return bounds_.Contains(gfx::ToFlooredPoint(located_event->location())); |
| 145 } | 152 } |
| 146 | 153 |
| 147 // TODO(spang): For non-ash builds we would need smarter keyboard focus. | 154 // TODO(spang): For non-ash builds we would need smarter keyboard focus. |
| 148 return true; | 155 return true; |
| 149 } | 156 } |
| 150 | 157 |
| 151 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { | 158 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 175 void DriWindow::OnChannelDestroyed() { | 182 void DriWindow::OnChannelDestroyed() { |
| 176 } | 183 } |
| 177 | 184 |
| 178 void DriWindow::SendBoundsChange() { | 185 void DriWindow::SendBoundsChange() { |
| 179 cursor_->PrepareForBoundsChange(widget_); | 186 cursor_->PrepareForBoundsChange(widget_); |
| 180 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 187 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
| 181 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); | 188 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); |
| 182 } | 189 } |
| 183 | 190 |
| 184 } // namespace ui | 191 } // namespace ui |
| OLD | NEW |