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

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

Issue 2177823002: X11: Add window cache Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test compilation Created 4 years, 3 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
Index: ui/events/platform/x11/x11_event_source.h
diff --git a/ui/events/platform/x11/x11_event_source.h b/ui/events/platform/x11/x11_event_source.h
index bd925027856034e64c30dee5786a9a07486f7a15..a671a6fd7b9c531e51b18333328660c8703ee6cb 100644
--- a/ui/events/platform/x11/x11_event_source.h
+++ b/ui/events/platform/x11/x11_event_source.h
@@ -6,7 +6,9 @@
#define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
#include <stdint.h>
+#include <xcb/xcb.h>
+#include <list>
#include <memory>
#include "base/macros.h"
@@ -40,6 +42,28 @@ class X11EventSourceDelegate {
// receiving, pre-process and post-processing XEvents.
class EVENTS_EXPORT X11EventSource {
public:
+ class EVENTS_EXPORT Request {
+ public:
+ ~Request();
+
+ virtual void OnReply(xcb_generic_reply_t* reply,
+ xcb_generic_error_t* error) = 0;
+
+ uint32_t sequence() { return sequence_; }
+
+ protected:
+ Request(uint32_t sequence);
+
+ uint32_t sequence_;
+
+ // State necessary for discarding. Set during
+ // X11EventSource::EnqueueRequest.
+ std::list<std::unique_ptr<Request>>::iterator it_;
+
+ private:
+ friend class X11EventSource;
+ };
+
X11EventSource(X11EventSourceDelegate* delegate, XDisplay* display);
~X11EventSource();
@@ -76,6 +100,11 @@ class EVENTS_EXPORT X11EventSource {
// current event does not have a timestamp.
Time GetTimestamp();
+ // Takes ownership of |request|.
+ void EnqueueRequest(Request* request);
+
+ void DiscardRequest(Request* request);
+
void StopCurrentEventStream();
void OnDispatcherListChanged();
@@ -96,13 +125,22 @@ class EVENTS_EXPORT X11EventSource {
// |last_seen_server_time_| with this value.
Time GetCurrentServerTime();
+ bool HasNextReply();
+ bool HasNextEvent();
+ uint32_t NextReplySequence();
+ uint32_t NextEventSequence();
+ void ProcessNextReply();
+ void ProcessNextEvent();
+
private:
+ friend class TestX11EventSource;
static X11EventSource* instance_;
X11EventSourceDelegate* delegate_;
// The connection to the X11 server used to receive the events.
XDisplay* display_;
+ xcb_connection_t* connection_;
// The timestamp of the event being dispatched.
Time event_timestamp_;
@@ -112,6 +150,13 @@ class EVENTS_EXPORT X11EventSource {
XWindow dummy_window_;
XAtom dummy_atom_;
+ // Outstanding requests that should be serviced.
+ std::list<std::unique_ptr<Request>> request_queue_;
+
+ // For HasNextReply();
+ void* next_reply_;
+ xcb_generic_error_t* next_error_;
+
// Keeps track of whether this source should continue to dispatch all the
// available events.
bool continue_stream_ = true;

Powered by Google App Engine
This is Rietveld 408576698