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

Unified Diff: ui/ozone/platform/wayland/wayland_display.cc

Issue 1739193004: ozone/platform/wayland: Use more realistic event processing and request flushing in tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wayland-test2
Patch Set: Use watching_ instead of base::MessageLoopForUI::IsCurrent() Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/wayland/wayland_display.h ('k') | ui/ozone/platform/wayland/wayland_display_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/wayland/wayland_display.cc
diff --git a/ui/ozone/platform/wayland/wayland_display.cc b/ui/ozone/platform/wayland/wayland_display.cc
index 1adc88e0b1b85aa6c2bc1c8f861544e410ad5f99..fcd841fa3124966e8f7a48814f0206a26782f585 100644
--- a/ui/ozone/platform/wayland/wayland_display.cc
+++ b/ui/ozone/platform/wayland/wayland_display.cc
@@ -6,6 +6,7 @@
#include <xdg-shell-unstable-v5-client-protocol.h>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "ui/ozone/platform/wayland/wayland_object.h"
@@ -60,9 +61,29 @@ bool WaylandDisplay::Initialize() {
return true;
}
-void WaylandDisplay::Flush() {
+bool WaylandDisplay::StartProcessingEvents() {
+ if (watching_)
+ return true;
+
DCHECK(display_);
wl_display_flush(display_.get());
+
+ DCHECK(base::MessageLoopForUI::IsCurrent());
+ if (!base::MessageLoopForUI::current()->WatchFileDescriptor(
+ wl_display_get_fd(display_.get()), true,
+ base::MessagePumpLibevent::WATCH_READ, &controller_, this))
+ return false;
+
+ watching_ = true;
+ return true;
+}
+
+void WaylandDisplay::ScheduleFlush() {
+ if (scheduled_flush_ || !watching_)
+ return;
+ base::MessageLoopForUI::current()->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&WaylandDisplay::Flush, base::Unretained(this)));
+ scheduled_flush_ = true;
}
WaylandWindow* WaylandDisplay::GetWindow(gfx::AcceleratedWidget widget) {
@@ -80,15 +101,12 @@ void WaylandDisplay::RemoveWindow(gfx::AcceleratedWidget widget) {
}
void WaylandDisplay::OnDispatcherListChanged() {
- if (watching_)
- return;
+ StartProcessingEvents();
+}
- DCHECK(display_);
- DCHECK(base::MessageLoopForUI::IsCurrent());
- base::MessageLoopForUI::current()->WatchFileDescriptor(
- wl_display_get_fd(display_.get()), true,
- base::MessagePumpLibevent::WATCH_READ, &controller_, this);
- watching_ = true;
+void WaylandDisplay::Flush() {
+ wl_display_flush(display_.get());
+ scheduled_flush_ = false;
}
void WaylandDisplay::OnFileCanReadWithoutBlocking(int fd) {
@@ -131,6 +149,8 @@ void WaylandDisplay::Global(void* data,
xdg_shell_use_unstable_version(display->shell_.get(),
XDG_SHELL_VERSION_CURRENT);
}
+
+ display->ScheduleFlush();
}
// static
@@ -142,7 +162,9 @@ void WaylandDisplay::GlobalRemove(void* data,
// static
void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) {
+ WaylandDisplay* display = static_cast<WaylandDisplay*>(data);
xdg_shell_pong(shell, serial);
+ display->ScheduleFlush();
}
} // namespace ui
« no previous file with comments | « ui/ozone/platform/wayland/wayland_display.h ('k') | ui/ozone/platform/wayland/wayland_display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698