| OLD | NEW |
| 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/display_client_compositor_frame_sink.h" | 10 #include "services/ui/ws/display_client_compositor_frame_sink.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Don't notify the delegate from the destructor. | 45 // Don't notify the delegate from the destructor. |
| 46 delegate_ = nullptr; | 46 delegate_ = nullptr; |
| 47 | 47 |
| 48 frame_generator_.reset(); | 48 frame_generator_.reset(); |
| 49 // Destroy the PlatformWindow early on as it may call us back during | 49 // Destroy the PlatformWindow early on as it may call us back during |
| 50 // destruction and we want to be in a known state. But destroy the surface | 50 // destruction and we want to be in a known state. But destroy the surface |
| 51 // first because it can still be using the platform window. | 51 // first because it can still be using the platform window. |
| 52 platform_window_.reset(); | 52 platform_window_.reset(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 EventSink* PlatformDisplayDefault::GetEventSink() { |
| 56 return delegate_->GetEventSink(); |
| 57 } |
| 58 |
| 55 void PlatformDisplayDefault::Init(PlatformDisplayDelegate* delegate) { | 59 void PlatformDisplayDefault::Init(PlatformDisplayDelegate* delegate) { |
| 56 delegate_ = delegate; | 60 delegate_ = delegate; |
| 57 | 61 |
| 58 const gfx::Rect& bounds = metrics_.bounds_in_pixels; | 62 const gfx::Rect& bounds = metrics_.bounds_in_pixels; |
| 59 DCHECK(!bounds.size().IsEmpty()); | 63 DCHECK(!bounds.size().IsEmpty()); |
| 60 | 64 |
| 61 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 62 platform_window_ = base::MakeUnique<ui::WinWindow>(this, bounds); | 66 platform_window_ = base::MakeUnique<ui::WinWindow>(this, bounds); |
| 63 #elif defined(USE_X11) && !defined(OS_CHROMEOS) | 67 #elif defined(USE_X11) && !defined(OS_CHROMEOS) |
| 64 platform_window_ = base::MakeUnique<ui::X11Window>(this, bounds); | 68 platform_window_ = base::MakeUnique<ui::X11Window>(this, bounds); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 frame_generator_->OnWindowDamaged(); | 173 frame_generator_->OnWindowDamaged(); |
| 170 } | 174 } |
| 171 | 175 |
| 172 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { | 176 void PlatformDisplayDefault::DispatchEvent(ui::Event* event) { |
| 173 if (event->IsLocatedEvent()) | 177 if (event->IsLocatedEvent()) |
| 174 UpdateEventRootLocation(event->AsLocatedEvent()); | 178 UpdateEventRootLocation(event->AsLocatedEvent()); |
| 175 | 179 |
| 176 if (event->IsScrollEvent()) { | 180 if (event->IsScrollEvent()) { |
| 177 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as | 181 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as |
| 178 // they are once we have proper support for scroll events. | 182 // they are once we have proper support for scroll events. |
| 179 delegate_->OnEvent( | 183 |
| 180 ui::PointerEvent(ui::MouseWheelEvent(*event->AsScrollEvent()))); | 184 ui::PointerEvent pointer_event( |
| 185 ui::MouseWheelEvent(*event->AsScrollEvent())); |
| 186 SendEventToSink(&pointer_event); |
| 181 } else if (event->IsMouseEvent()) { | 187 } else if (event->IsMouseEvent()) { |
| 182 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); | 188 ui::PointerEvent pointer_event(*event->AsMouseEvent()); |
| 189 SendEventToSink(&pointer_event); |
| 183 } else if (event->IsTouchEvent()) { | 190 } else if (event->IsTouchEvent()) { |
| 184 delegate_->OnEvent(ui::PointerEvent(*event->AsTouchEvent())); | 191 ui::PointerEvent pointer_event(*event->AsTouchEvent()); |
| 192 SendEventToSink(&pointer_event); |
| 185 } else { | 193 } else { |
| 186 delegate_->OnEvent(*event); | 194 SendEventToSink(event); |
| 187 } | 195 } |
| 188 | 196 |
| 189 #if defined(USE_X11) || defined(USE_OZONE) | 197 #if defined(USE_X11) || defined(USE_OZONE) |
| 190 // We want to emulate the WM_CHAR generation behaviour of Windows. | 198 // We want to emulate the WM_CHAR generation behaviour of Windows. |
| 191 // | 199 // |
| 192 // On Linux, we've previously inserted characters by having | 200 // On Linux, we've previously inserted characters by having |
| 193 // InputMethodAuraLinux take all key down events and send a character event | 201 // InputMethodAuraLinux take all key down events and send a character event |
| 194 // to the TextInputClient. This causes a mismatch in code that has to be | 202 // to the TextInputClient. This causes a mismatch in code that has to be |
| 195 // shared between Windows and Linux, including blink code. Now that we're | 203 // shared between Windows and Linux, including blink code. Now that we're |
| 196 // trying to have one way of doing things, we need to standardize on and | 204 // trying to have one way of doing things, we need to standardize on and |
| 197 // emulate Windows character events. | 205 // emulate Windows character events. |
| 198 // | 206 // |
| 199 // This is equivalent to what we're doing in the current Linux port, but | 207 // This is equivalent to what we're doing in the current Linux port, but |
| 200 // done once instead of done multiple times in different places. | 208 // done once instead of done multiple times in different places. |
| 201 if (event->type() == ui::ET_KEY_PRESSED) { | 209 if (event->type() == ui::ET_KEY_PRESSED) { |
| 202 ui::KeyEvent* key_press_event = event->AsKeyEvent(); | 210 ui::KeyEvent* key_press_event = event->AsKeyEvent(); |
| 203 ui::KeyEvent char_event(key_press_event->GetCharacter(), | 211 ui::KeyEvent char_event(key_press_event->GetCharacter(), |
| 204 key_press_event->key_code(), | 212 key_press_event->key_code(), |
| 205 key_press_event->flags()); | 213 key_press_event->flags()); |
| 206 // We don't check that GetCharacter() is equal because changing a key event | 214 // We don't check that GetCharacter() is equal because changing a key event |
| 207 // with an accelerator to a character event can change the character, for | 215 // with an accelerator to a character event can change the character, for |
| 208 // example, from 'M' to '^M'. | 216 // example, from 'M' to '^M'. |
| 209 DCHECK_EQ(key_press_event->key_code(), char_event.key_code()); | 217 DCHECK_EQ(key_press_event->key_code(), char_event.key_code()); |
| 210 DCHECK_EQ(key_press_event->flags(), char_event.flags()); | 218 DCHECK_EQ(key_press_event->flags(), char_event.flags()); |
| 211 delegate_->OnEvent(char_event); | 219 SendEventToSink(&char_event); |
| 212 } | 220 } |
| 213 #endif | 221 #endif |
| 214 } | 222 } |
| 215 | 223 |
| 216 void PlatformDisplayDefault::OnCloseRequest() { | 224 void PlatformDisplayDefault::OnCloseRequest() { |
| 217 // TODO(tonikitoo): Handle a close request in external window mode. The window | 225 // TODO(tonikitoo): Handle a close request in external window mode. The window |
| 218 // should be closed by the WS and it shouldn't involve ScreenManager. | 226 // should be closed by the WS and it shouldn't involve ScreenManager. |
| 219 const int64_t display_id = delegate_->GetDisplay().id(); | 227 const int64_t display_id = delegate_->GetDisplay().id(); |
| 220 display::ScreenManager::GetInstance()->RequestCloseDisplay(display_id); | 228 display::ScreenManager::GetInstance()->RequestCloseDisplay(display_id); |
| 221 } | 229 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 270 } |
| 263 | 271 |
| 264 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { | 272 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { |
| 265 NOTREACHED(); | 273 NOTREACHED(); |
| 266 } | 274 } |
| 267 | 275 |
| 268 void PlatformDisplayDefault::OnActivationChanged(bool active) {} | 276 void PlatformDisplayDefault::OnActivationChanged(bool active) {} |
| 269 | 277 |
| 270 } // namespace ws | 278 } // namespace ws |
| 271 } // namespace ui | 279 } // namespace ui |
| OLD | NEW |