| 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 "ui/ozone/platform/wayland/wayland_display.h" | 5 #include "ui/ozone/platform/wayland/wayland_display.h" |
| 6 | 6 |
| 7 #include <xdg-shell-unstable-v5-client-protocol.h> | 7 #include <xdg-shell-unstable-v5-client-protocol.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "ui/ozone/platform/wayland/wayland_object.h" | 13 #include "ui/ozone/platform/wayland/wayland_object.h" |
| 13 #include "ui/ozone/platform/wayland/wayland_window.h" | 14 #include "ui/ozone/platform/wayland/wayland_window.h" |
| 14 | 15 |
| 15 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); | 16 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 namespace { | 19 namespace { |
| 19 const uint32_t kMaxCompositorVersion = 4; | 20 const uint32_t kMaxCompositorVersion = 4; |
| 20 const uint32_t kMaxSeatVersion = 4; | 21 const uint32_t kMaxSeatVersion = 4; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 wl_seat* seat, | 186 wl_seat* seat, |
| 186 uint32_t capabilities) { | 187 uint32_t capabilities) { |
| 187 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); | 188 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); |
| 188 if (capabilities & WL_SEAT_CAPABILITY_POINTER) { | 189 if (capabilities & WL_SEAT_CAPABILITY_POINTER) { |
| 189 if (!display->pointer_) { | 190 if (!display->pointer_) { |
| 190 wl_pointer* pointer = wl_seat_get_pointer(display->seat_.get()); | 191 wl_pointer* pointer = wl_seat_get_pointer(display->seat_.get()); |
| 191 if (!pointer) { | 192 if (!pointer) { |
| 192 LOG(ERROR) << "Failed to get wl_pointer from seat"; | 193 LOG(ERROR) << "Failed to get wl_pointer from seat"; |
| 193 return; | 194 return; |
| 194 } | 195 } |
| 195 display->pointer_ = make_scoped_ptr(new WaylandPointer( | 196 display->pointer_ = base::WrapUnique(new WaylandPointer( |
| 196 pointer, base::Bind(&WaylandDisplay::DispatchUiEvent, | 197 pointer, base::Bind(&WaylandDisplay::DispatchUiEvent, |
| 197 base::Unretained(display)))); | 198 base::Unretained(display)))); |
| 198 } | 199 } |
| 199 } else if (display->pointer_) { | 200 } else if (display->pointer_) { |
| 200 display->pointer_.reset(); | 201 display->pointer_.reset(); |
| 201 } | 202 } |
| 202 display->ScheduleFlush(); | 203 display->ScheduleFlush(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 // static | 206 // static |
| 206 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {} | 207 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {} |
| 207 | 208 |
| 208 // static | 209 // static |
| 209 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) { | 210 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) { |
| 210 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); | 211 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); |
| 211 xdg_shell_pong(shell, serial); | 212 xdg_shell_pong(shell, serial); |
| 212 display->ScheduleFlush(); | 213 display->ScheduleFlush(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 } // namespace ui | 216 } // namespace ui |
| OLD | NEW |