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_connection.h" | 5 #include "ui/ozone/platform/wayland/wayland_connection.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/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" |
14 #include "ui/ozone/platform/wayland/wayland_object.h" | 15 #include "ui/ozone/platform/wayland/wayland_object.h" |
15 #include "ui/ozone/platform/wayland/wayland_window.h" | 16 #include "ui/ozone/platform/wayland/wayland_window.h" |
16 | 17 |
17 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); | 18 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); |
18 | 19 |
19 namespace ui { | 20 namespace ui { |
20 namespace { | 21 namespace { |
21 const uint32_t kMaxCompositorVersion = 4; | 22 const uint32_t kMaxCompositorVersion = 4; |
22 const uint32_t kMaxSeatVersion = 4; | 23 const uint32_t kMaxSeatVersion = 4; |
23 const uint32_t kMaxShmVersion = 1; | 24 const uint32_t kMaxShmVersion = 1; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::MessagePumpLibevent::WATCH_READ, &controller_, this)) | 82 base::MessagePumpLibevent::WATCH_READ, &controller_, this)) |
82 return false; | 83 return false; |
83 | 84 |
84 watching_ = true; | 85 watching_ = true; |
85 return true; | 86 return true; |
86 } | 87 } |
87 | 88 |
88 void WaylandConnection::ScheduleFlush() { | 89 void WaylandConnection::ScheduleFlush() { |
89 if (scheduled_flush_ || !watching_) | 90 if (scheduled_flush_ || !watching_) |
90 return; | 91 return; |
91 base::MessageLoopForUI::current()->task_runner()->PostTask( | 92 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 93 base::ThreadTaskRunnerHandle::Get()->PostTask( |
92 FROM_HERE, base::Bind(&WaylandConnection::Flush, base::Unretained(this))); | 94 FROM_HERE, base::Bind(&WaylandConnection::Flush, base::Unretained(this))); |
93 scheduled_flush_ = true; | 95 scheduled_flush_ = true; |
94 } | 96 } |
95 | 97 |
96 WaylandWindow* WaylandConnection::GetWindow(gfx::AcceleratedWidget widget) { | 98 WaylandWindow* WaylandConnection::GetWindow(gfx::AcceleratedWidget widget) { |
97 auto it = window_map_.find(widget); | 99 auto it = window_map_.find(widget); |
98 return it == window_map_.end() ? nullptr : it->second; | 100 return it == window_map_.end() ? nullptr : it->second; |
99 } | 101 } |
100 | 102 |
101 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget, | 103 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {} | 234 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {} |
233 | 235 |
234 // static | 236 // static |
235 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) { | 237 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) { |
236 WaylandConnection* connection = static_cast<WaylandConnection*>(data); | 238 WaylandConnection* connection = static_cast<WaylandConnection*>(data); |
237 xdg_shell_pong(shell, serial); | 239 xdg_shell_pong(shell, serial); |
238 connection->ScheduleFlush(); | 240 connection->ScheduleFlush(); |
239 } | 241 } |
240 | 242 |
241 } // namespace ui | 243 } // namespace ui |
OLD | NEW |