| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 sender_->AddChannelObserver(this); | 51 sender_->AddChannelObserver(this); |
| 52 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 52 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
| 53 cursor_->OnWindowAdded(widget_, bounds_); | 53 cursor_->OnWindowAdded(widget_, bounds_); |
| 54 delegate_->OnAcceleratedWidgetAvailable(widget_); | 54 delegate_->OnAcceleratedWidgetAvailable(widget_); |
| 55 } | 55 } |
| 56 | 56 |
| 57 gfx::AcceleratedWidget DriWindow::GetAcceleratedWidget() { | 57 gfx::AcceleratedWidget DriWindow::GetAcceleratedWidget() { |
| 58 return widget_; | 58 return widget_; |
| 59 } | 59 } |
| 60 | 60 |
| 61 gfx::Rect DriWindow::GetCursorConfinedBounds() const { |
| 62 return cursor_confined_bounds_.IsEmpty() ? gfx::Rect(bounds_.size()) |
| 63 : cursor_confined_bounds_; |
| 64 } |
| 65 |
| 61 void DriWindow::Show() {} | 66 void DriWindow::Show() {} |
| 62 | 67 |
| 63 void DriWindow::Hide() {} | 68 void DriWindow::Hide() {} |
| 64 | 69 |
| 65 void DriWindow::Close() {} | 70 void DriWindow::Close() {} |
| 66 | 71 |
| 67 void DriWindow::SetBounds(const gfx::Rect& bounds) { | 72 void DriWindow::SetBounds(const gfx::Rect& bounds) { |
| 68 bounds_ = bounds; | 73 bounds_ = bounds; |
| 69 delegate_->OnBoundsChanged(bounds); | 74 delegate_->OnBoundsChanged(bounds); |
| 70 SendBoundsChange(); | 75 SendBoundsChange(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 91 void DriWindow::Restore() {} | 96 void DriWindow::Restore() {} |
| 92 | 97 |
| 93 void DriWindow::SetCursor(PlatformCursor cursor) { | 98 void DriWindow::SetCursor(PlatformCursor cursor) { |
| 94 cursor_->SetCursor(widget_, cursor); | 99 cursor_->SetCursor(widget_, cursor); |
| 95 } | 100 } |
| 96 | 101 |
| 97 void DriWindow::MoveCursorTo(const gfx::Point& location) { | 102 void DriWindow::MoveCursorTo(const gfx::Point& location) { |
| 98 event_factory_->WarpCursorTo(widget_, location); | 103 event_factory_->WarpCursorTo(widget_, location); |
| 99 } | 104 } |
| 100 | 105 |
| 106 void DriWindow::ConfineCursorToBounds(const gfx::Rect& bounds) { |
| 107 cursor_confined_bounds_ = bounds; |
| 108 cursor_->ConfineCursorToBounds(widget_, bounds); |
| 109 } |
| 110 |
| 101 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { | 111 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { |
| 102 DCHECK(ne); | 112 DCHECK(ne); |
| 103 Event* event = static_cast<Event*>(ne); | 113 Event* event = static_cast<Event*>(ne); |
| 104 | 114 |
| 105 // If there is a grab, capture events here. | 115 // If there is a grab, capture events here. |
| 106 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); | 116 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); |
| 107 if (grabber != gfx::kNullAcceleratedWidget) | 117 if (grabber != gfx::kNullAcceleratedWidget) |
| 108 return grabber == widget_; | 118 return grabber == widget_; |
| 109 | 119 |
| 110 if (event->IsTouchEvent()) { | 120 if (event->IsTouchEvent()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 159 } |
| 150 DispatchEventFromNativeUiEvent( | 160 DispatchEventFromNativeUiEvent( |
| 151 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 161 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 152 base::Unretained(delegate_))); | 162 base::Unretained(delegate_))); |
| 153 return POST_DISPATCH_STOP_PROPAGATION; | 163 return POST_DISPATCH_STOP_PROPAGATION; |
| 154 } | 164 } |
| 155 | 165 |
| 156 void DriWindow::OnChannelEstablished() { | 166 void DriWindow::OnChannelEstablished() { |
| 157 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | 167 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); |
| 158 SendBoundsChange(); | 168 SendBoundsChange(); |
| 169 cursor_->ConfineCursorToBounds(widget_, GetCursorConfinedBounds()); |
| 159 } | 170 } |
| 160 | 171 |
| 161 void DriWindow::OnChannelDestroyed() { | 172 void DriWindow::OnChannelDestroyed() { |
| 162 } | 173 } |
| 163 | 174 |
| 164 void DriWindow::SendBoundsChange() { | 175 void DriWindow::SendBoundsChange() { |
| 165 cursor_->PrepareForBoundsChange(widget_); | 176 cursor_->PrepareForBoundsChange(widget_); |
| 166 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 177 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
| 167 cursor_->CommitBoundsChange(widget_, bounds_); | |
| 168 } | 178 } |
| 169 | 179 |
| 170 } // namespace ui | 180 } // namespace ui |
| OLD | NEW |