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

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 API Created 4 years, 2 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/BUILD.gn ('k') | ui/events/platform/x11/x11_event_source.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.h
diff --git a/ui/events/platform/x11/x11_event_source.h b/ui/events/platform/x11/x11_event_source.h
index 927e67d803e6bae145f6150498b8ae9380016f82..cfa43914ecfe3c230b989910a994d839ca8cbef3 100644
--- a/ui/events/platform/x11/x11_event_source.h
+++ b/ui/events/platform/x11/x11_event_source.h
@@ -6,11 +6,15 @@
#define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
#include <stdint.h>
+#include <xcb/xcb.h>
+#include <list>
#include <memory>
+#include <queue>
#include <stack>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "ui/events/events_export.h"
#include "ui/gfx/x/x11_types.h"
@@ -47,6 +51,32 @@ 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_; }
+
+ base::WeakPtr<Request> GetWeakPtr();
+
+ protected:
+ Request(uint32_t sequence);
+
+ uint32_t sequence_;
+
+ // State necessary for discarding. Set during
+ // X11EventSource::EnqueueRequest.
+ std::list<std::unique_ptr<Request>>::iterator it_;
+
+ base::WeakPtrFactory<Request> weak_factory_;
+
+ private:
+ friend class X11EventSource;
+ };
+
X11EventSource(X11EventSourceDelegate* delegate, XDisplay* display);
~X11EventSource();
@@ -87,6 +117,16 @@ class EVENTS_EXPORT X11EventSource {
// dispatched that contains that information.
base::Optional<gfx::Point> GetRootCursorLocationFromCurrentEvent() const;
+ // Takes ownership of |request|.
+ void EnqueueRequest(Request* request);
+
+ void DiscardRequest(Request* request);
+
+ // Blocks until the reply corresponding to |request| is available. Dispatches
+ // the request in a nested-message-loop fashion. Returns true iff the request
+ // resulted in an error.
+ bool DispatchRequestNow(Request* request);
+
void StopCurrentEventStream();
void OnDispatcherListChanged();
@@ -107,13 +147,26 @@ class EVENTS_EXPORT X11EventSource {
// |last_seen_server_time_| with this value.
Time GetCurrentServerTime();
+ bool HasNextReply();
+ uint32_t NextReplySequence();
+ void ProcessRequest(Request* request,
+ xcb_generic_reply_t* reply,
+ xcb_generic_error_t* error);
+ void ProcessNextReply();
+
+ bool HasNextEvent();
+ uint32_t NextEventSequence();
+ 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_;
// Events currently being dispatched. The topmost event in this stack
// corresponds to the deepest-nested message loop.
@@ -125,6 +178,13 @@ class EVENTS_EXPORT X11EventSource {
XAtom dummy_atom_;
std::unique_ptr<XScopedEventSelector> dummy_window_events_;
+ // 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;
« no previous file with comments | « ui/events/platform/x11/BUILD.gn ('k') | ui/events/platform/x11/x11_event_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698