Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: services/ui/ws/platform_display_default.cc

Issue 2712963003: mustash: Use ui::chromeos::EventRewriter in mus (Closed)
Patch Set: Fix compile issues Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { 160 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const {
161 return widget_; 161 return widget_;
162 } 162 }
163 163
164 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) { 164 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) {
165 gfx::Point location = event->location(); 165 gfx::Point location = event->location();
166 location.Offset(metrics_.bounds.x(), metrics_.bounds.y()); 166 location.Offset(metrics_.bounds.x(), metrics_.bounds.y());
167 event->set_root_location(location); 167 event->set_root_location(location);
168 } 168 }
169 169
170 ui::EventProcessor* PlatformDisplayDefault::GetEventProcessor() {
171 return delegate_->GetEventProcessor();
172 }
173
170 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { 174 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) {
171 // We only care if the window size has changed. 175 // We only care if the window size has changed.
172 if (new_bounds.size() == metrics_.pixel_size) 176 if (new_bounds.size() == metrics_.pixel_size)
173 return; 177 return;
174 178
175 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support 179 // TODO(kylechar): Maybe do something here. For CrOS we don't need to support
176 // PlatformWindow initiated resizes. For other platforms we need to do 180 // PlatformWindow initiated resizes. For other platforms we need to do
177 // something but that isn't fully flushed out. 181 // something but that isn't fully flushed out.
178 } 182 }
179 183
180 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) { 184 void PlatformDisplayDefault::OnDamageRect(const gfx::Rect& damaged_region) {
181 if (frame_generator_) 185 if (frame_generator_)
182 frame_generator_->OnWindowDamaged(); 186 frame_generator_->OnWindowDamaged();
183 } 187 }
184 188
185 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { 189 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) {
186 if (event->IsLocatedEvent()) 190 if (event->IsLocatedEvent())
187 UpdateEventRootLocation(event->AsLocatedEvent()); 191 UpdateEventRootLocation(event->AsLocatedEvent());
188 192
189 if (event->IsScrollEvent()) { 193 if (event->IsScrollEvent()) {
190 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as 194 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as
191 // they are once we have proper support for scroll events. 195 // they are once we have proper support for scroll events.
192 delegate_->OnEvent( 196 ui::PointerEvent pointer_event(
193 ui::PointerEvent(ui::MouseWheelEvent(*event->AsScrollEvent()))); 197 ui::MouseWheelEvent(*event->AsScrollEvent()));
198 SendEventToProcessor(&pointer_event);
194 } else if (event->IsMouseEvent()) { 199 } else if (event->IsMouseEvent()) {
195 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); 200 ui::PointerEvent pointer_event(*event->AsMouseEvent());
201 SendEventToProcessor(&pointer_event);
196 } else if (event->IsTouchEvent()) { 202 } else if (event->IsTouchEvent()) {
197 delegate_->OnEvent(ui::PointerEvent(*event->AsTouchEvent())); 203 ui::PointerEvent pointer_event(*event->AsTouchEvent());
204 SendEventToProcessor(&pointer_event);
198 } else { 205 } else {
199 delegate_->OnEvent(*event); 206 SendEventToProcessor(event);
200 } 207 }
201 208
202 #if defined(USE_X11) || defined(USE_OZONE) 209 #if defined(USE_X11) || defined(USE_OZONE)
203 // We want to emulate the WM_CHAR generation behaviour of Windows. 210 // We want to emulate the WM_CHAR generation behaviour of Windows.
204 // 211 //
205 // On Linux, we've previously inserted characters by having 212 // On Linux, we've previously inserted characters by having
206 // InputMethodAuraLinux take all key down events and send a character event 213 // InputMethodAuraLinux take all key down events and send a character event
207 // to the TextInputClient. This causes a mismatch in code that has to be 214 // to the TextInputClient. This causes a mismatch in code that has to be
208 // shared between Windows and Linux, including blink code. Now that we're 215 // shared between Windows and Linux, including blink code. Now that we're
209 // trying to have one way of doing things, we need to standardize on and 216 // trying to have one way of doing things, we need to standardize on and
210 // emulate Windows character events. 217 // emulate Windows character events.
211 // 218 //
212 // This is equivalent to what we're doing in the current Linux port, but 219 // This is equivalent to what we're doing in the current Linux port, but
213 // done once instead of done multiple times in different places. 220 // done once instead of done multiple times in different places.
214 if (event->type() == ui::ET_KEY_PRESSED) { 221 if (event->type() == ui::ET_KEY_PRESSED) {
215 ui::KeyEvent* key_press_event = event->AsKeyEvent(); 222 ui::KeyEvent* key_press_event = event->AsKeyEvent();
216 ui::KeyEvent char_event(key_press_event->GetCharacter(), 223 ui::KeyEvent char_event(key_press_event->GetCharacter(),
217 key_press_event->key_code(), 224 key_press_event->key_code(),
218 key_press_event->flags()); 225 key_press_event->flags());
219 // We don't check that GetCharacter() is equal because changing a key event 226 // We don't check that GetCharacter() is equal because changing a key event
220 // with an accelerator to a character event can change the character, for 227 // with an accelerator to a character event can change the character, for
221 // example, from 'M' to '^M'. 228 // example, from 'M' to '^M'.
222 DCHECK_EQ(key_press_event->key_code(), char_event.key_code()); 229 DCHECK_EQ(key_press_event->key_code(), char_event.key_code());
223 DCHECK_EQ(key_press_event->flags(), char_event.flags()); 230 DCHECK_EQ(key_press_event->flags(), char_event.flags());
224 delegate_->OnEvent(char_event); 231 SendEventToProcessor(&char_event);
225 } 232 }
226 #endif 233 #endif
227 } 234 }
228 235
229 void PlatformDisplayDefault::OnCloseRequest() { 236 void PlatformDisplayDefault::OnCloseRequest() {
230 display::ScreenManager::GetInstance()->RequestCloseDisplay(GetId()); 237 display::ScreenManager::GetInstance()->RequestCloseDisplay(GetId());
231 } 238 }
232 239
233 void PlatformDisplayDefault::OnClosed() {} 240 void PlatformDisplayDefault::OnClosed() {}
234 241
(...skipping 23 matching lines...) Expand all
258 } 265 }
259 266
260 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 267 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
261 268
262 bool PlatformDisplayDefault::IsInHighContrastMode() { 269 bool PlatformDisplayDefault::IsInHighContrastMode() {
263 return delegate_ ? delegate_->IsInHighContrastMode() : false; 270 return delegate_ ? delegate_->IsInHighContrastMode() : false;
264 } 271 }
265 272
266 } // namespace ws 273 } // namespace ws
267 } // namespace ui 274 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698