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

Unified Diff: ui/events/platform/x11/x11_event_source.cc

Issue 1913913004: Regularly poll the X11 event queue. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 4 years, 7 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/events/platform/x11/x11_event_source.h ('k') | ui/events/platform/x11/x11_event_source_libevent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/platform/x11/x11_event_source.cc
diff --git a/ui/events/platform/x11/x11_event_source.cc b/ui/events/platform/x11/x11_event_source.cc
index 5101f2703a3bff44f677e1c64db1a2ec09532980..84451d1a10feb2f8249f1c5c6ced3d42f325ee42 100644
--- a/ui/events/platform/x11/x11_event_source.cc
+++ b/ui/events/platform/x11/x11_event_source.cc
@@ -9,8 +9,10 @@
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
+#include "base/command_line.h"
#include "base/logging.h"
#include "ui/events/devices/x11/device_data_manager_x11.h"
+#include "ui/events/event_switches.h"
#include "ui/events/event_utils.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/x11/x11_hotplug_event_handler.h"
@@ -81,6 +83,10 @@ X11EventSource::X11EventSource(XDisplay* display)
DeviceDataManagerX11::CreateInstance();
InitializeXInput2(display_);
InitializeXkb(display_);
+
+ base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
+ dispatch_one_event_per_loop_ =
+ cmdline->HasSwitch(switches::kDispatchOneEventPerLoop);
}
X11EventSource::~X11EventSource() {
@@ -94,17 +100,19 @@ X11EventSource* X11EventSource::GetInstance() {
////////////////////////////////////////////////////////////////////////////////
// X11EventSource, public
-void X11EventSource::DispatchXEvents() {
+bool X11EventSource::DispatchXEvents() {
DCHECK(display_);
- // Handle all pending events.
- // It may be useful to eventually align this event dispatch with vsync, but
- // not yet.
- continue_stream_ = true;
- while (XPending(display_) && continue_stream_) {
+
+ int pending_events = XPending(display_);
+ if (!pending_events)
+ return false;
+ do {
XEvent xevent;
XNextEvent(display_, &xevent);
DispatchEvent(&xevent);
- }
+ } while (--pending_events && continue_stream_ &&
+ !dispatch_one_event_per_loop_);
+ return true;
}
void X11EventSource::BlockUntilWindowMapped(XID window) {
« no previous file with comments | « ui/events/platform/x11/x11_event_source.h ('k') | ui/events/platform/x11/x11_event_source_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698