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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 window_manager_->RemoveWindow(widget_); | 43 window_manager_->RemoveWindow(widget_); |
44 cursor_->OnWindowRemoved(widget_); | 44 cursor_->OnWindowRemoved(widget_); |
45 | 45 |
46 sender_->RemoveChannelObserver(this); | 46 sender_->RemoveChannelObserver(this); |
47 sender_->Send(new OzoneGpuMsg_DestroyWindowDelegate(widget_)); | 47 sender_->Send(new OzoneGpuMsg_DestroyWindowDelegate(widget_)); |
48 } | 48 } |
49 | 49 |
50 void DriWindow::Initialize() { | 50 void DriWindow::Initialize() { |
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_, GetCursorConfinedBounds()); |
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 if (cursor_confined_bounds_ == bounds) |
| 108 return; |
| 109 |
| 110 cursor_confined_bounds_ = bounds; |
| 111 cursor_->ConfineCursorToBounds(widget_, bounds); |
| 112 } |
| 113 |
101 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { | 114 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { |
102 DCHECK(ne); | 115 DCHECK(ne); |
103 Event* event = static_cast<Event*>(ne); | 116 Event* event = static_cast<Event*>(ne); |
104 | 117 |
105 // If there is a grab, capture events here. | 118 // If there is a grab, capture events here. |
106 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); | 119 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); |
107 if (grabber != gfx::kNullAcceleratedWidget) | 120 if (grabber != gfx::kNullAcceleratedWidget) |
108 return grabber == widget_; | 121 return grabber == widget_; |
109 | 122 |
110 if (event->IsTouchEvent()) { | 123 if (event->IsTouchEvent()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 162 } |
150 DispatchEventFromNativeUiEvent( | 163 DispatchEventFromNativeUiEvent( |
151 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 164 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
152 base::Unretained(delegate_))); | 165 base::Unretained(delegate_))); |
153 return POST_DISPATCH_STOP_PROPAGATION; | 166 return POST_DISPATCH_STOP_PROPAGATION; |
154 } | 167 } |
155 | 168 |
156 void DriWindow::OnChannelEstablished() { | 169 void DriWindow::OnChannelEstablished() { |
157 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | 170 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); |
158 SendBoundsChange(); | 171 SendBoundsChange(); |
| 172 cursor_->ConfineCursorToBounds(widget_, GetCursorConfinedBounds()); |
159 } | 173 } |
160 | 174 |
161 void DriWindow::OnChannelDestroyed() { | 175 void DriWindow::OnChannelDestroyed() { |
162 } | 176 } |
163 | 177 |
164 void DriWindow::SendBoundsChange() { | 178 void DriWindow::SendBoundsChange() { |
165 cursor_->PrepareForBoundsChange(widget_); | 179 cursor_->PrepareForBoundsChange(widget_); |
166 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 180 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
167 cursor_->CommitBoundsChange(widget_, bounds_); | |
168 } | 181 } |
169 | 182 |
170 } // namespace ui | 183 } // namespace ui |
OLD | NEW |