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/event.h" | 8 #include "ui/events/event.h" |
9 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 9 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
10 #include "ui/events/ozone/events_ozone.h" | 10 #include "ui/events/ozone/events_ozone.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds)); | 67 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds)); |
68 | 68 |
69 if (window_manager_->cursor()->GetCursorWindow() == widget_) | 69 if (window_manager_->cursor()->GetCursorWindow() == widget_) |
70 window_manager_->cursor()->ShowCursor(); | 70 window_manager_->cursor()->ShowCursor(); |
71 } | 71 } |
72 | 72 |
73 gfx::Rect DriWindow::GetBounds() { | 73 gfx::Rect DriWindow::GetBounds() { |
74 return bounds_; | 74 return bounds_; |
75 } | 75 } |
76 | 76 |
77 void DriWindow::SetCapture() {} | 77 void DriWindow::SetCapture() { |
78 window_manager_->GrabEvents(widget_); | |
79 } | |
78 | 80 |
79 void DriWindow::ReleaseCapture() {} | 81 void DriWindow::ReleaseCapture() { |
82 window_manager_->UngrabEvents(widget_); | |
83 } | |
80 | 84 |
81 void DriWindow::ToggleFullscreen() {} | 85 void DriWindow::ToggleFullscreen() {} |
82 | 86 |
83 void DriWindow::Maximize() {} | 87 void DriWindow::Maximize() {} |
84 | 88 |
85 void DriWindow::Minimize() {} | 89 void DriWindow::Minimize() {} |
86 | 90 |
87 void DriWindow::Restore() {} | 91 void DriWindow::Restore() {} |
88 | 92 |
89 void DriWindow::SetCursor(PlatformCursor cursor) { | 93 void DriWindow::SetCursor(PlatformCursor cursor) { |
90 DriCursor* dri_cursor = window_manager_->cursor(); | 94 DriCursor* dri_cursor = window_manager_->cursor(); |
91 dri_cursor->SetCursor(widget_, cursor); | 95 dri_cursor->SetCursor(widget_, cursor); |
92 // ShowCursor results in a IPC call to GPU. So, we make sure the channel | 96 // ShowCursor results in a IPC call to GPU. So, we make sure the channel |
93 // is connected. OnChannelEstablished guarantees that ShowCursor is called | 97 // is connected. OnChannelEstablished guarantees that ShowCursor is called |
94 // eventually. | 98 // eventually. |
95 if (sender_->IsConnected() && dri_cursor->GetCursorWindow() == widget_) | 99 if (sender_->IsConnected() && dri_cursor->GetCursorWindow() == widget_) |
96 dri_cursor->ShowCursor(); | 100 dri_cursor->ShowCursor(); |
97 } | 101 } |
98 | 102 |
99 void DriWindow::MoveCursorTo(const gfx::Point& location) { | 103 void DriWindow::MoveCursorTo(const gfx::Point& location) { |
100 event_factory_->WarpCursorTo(widget_, location); | 104 event_factory_->WarpCursorTo(widget_, location); |
101 } | 105 } |
102 | 106 |
103 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { | 107 bool DriWindow::CanDispatchEvent(const PlatformEvent& ne) { |
104 DCHECK(ne); | 108 DCHECK(ne); |
105 Event* event = static_cast<Event*>(ne); | 109 Event* event = static_cast<Event*>(ne); |
106 if (event->IsMouseEvent() || event->IsScrollEvent()) | 110 |
111 // Bail out if there is a grab on mouse events. | |
112 gfx::AcceleratedWidget grabber = window_manager_->event_grabber(); | |
113 if (grabber != gfx::kNullAcceleratedWidget) | |
114 return grabber == widget_; | |
spang
2014/11/11 19:00:24
Let's talk about this more.
Touch events should n
llandwerlin-old
2014/11/12 15:47:24
Acknowledged.
sadrul
2014/11/19 21:07:10
I think we do grab for touch-events. Can you verif
| |
115 | |
116 if (event->IsMouseEvent() || event->IsScrollEvent()) { | |
117 // Otherwise, just consider the position of the cursor. | |
107 return window_manager_->cursor()->GetCursorWindow() == widget_; | 118 return window_manager_->cursor()->GetCursorWindow() == widget_; |
119 } | |
108 | 120 |
109 return true; | 121 return true; |
110 } | 122 } |
111 | 123 |
112 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { | 124 uint32_t DriWindow::DispatchEvent(const PlatformEvent& native_event) { |
125 // Implement implicit mouse grab on button press | |
126 Event* event = static_cast<Event*>(native_event); | |
127 if (event->IsLocatedEvent()) { | |
spang
2014/11/11 19:00:24
As above, touch events must not be affected by the
llandwerlin-old
2014/11/12 15:47:24
They shouldn't be, because they will be delivered
spang
2014/11/19 18:32:30
That conditional is only for mouse events. Touch e
| |
128 // We need to convert the cursor's position into coordinates | |
129 // relative to the window in case of an implicit grab. | |
130 if (window_manager_->cursor()->GetCursorWindow() != widget_) { | |
spang
2014/11/19 18:32:30
I don't think you need this conditional as the cal
| |
131 LocatedEvent* located_event = static_cast<LocatedEvent*>(event); | |
132 gfx::PointF location = located_event->root_location(); | |
133 location.Offset(-bounds_.origin().x(), -bounds_.origin().y()); | |
134 located_event->set_location(location); | |
135 } | |
136 } | |
113 DispatchEventFromNativeUiEvent( | 137 DispatchEventFromNativeUiEvent( |
114 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 138 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
115 base::Unretained(delegate_))); | 139 base::Unretained(delegate_))); |
116 return POST_DISPATCH_STOP_PROPAGATION; | 140 return POST_DISPATCH_STOP_PROPAGATION; |
117 } | 141 } |
118 | 142 |
119 void DriWindow::OnChannelEstablished() { | 143 void DriWindow::OnChannelEstablished() { |
120 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); | 144 sender_->Send(new OzoneGpuMsg_CreateWindowDelegate(widget_)); |
121 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 145 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); |
122 | 146 |
123 DriCursor* dri_cursor = window_manager_->cursor(); | 147 DriCursor* dri_cursor = window_manager_->cursor(); |
124 if (dri_cursor->GetCursorWindow() == widget_) | 148 if (dri_cursor->GetCursorWindow() == widget_) |
125 dri_cursor->ShowCursor(); | 149 dri_cursor->ShowCursor(); |
126 } | 150 } |
127 | 151 |
128 void DriWindow::OnChannelDestroyed() { | 152 void DriWindow::OnChannelDestroyed() { |
129 } | 153 } |
130 | 154 |
131 } // namespace ui | 155 } // namespace ui |
OLD | NEW |