| 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;
|
|
|