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

Side by Side Diff: ui/events/platform/x11/x11_event_source.h

Issue 1949393007: X11: Better timestamp handling for _NET_ACTIVE_WINDOW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ms->microseconds 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 unified diff | Download patch
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/events/platform/x11/x11_event_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ 5 #ifndef UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ 6 #define UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "ui/events/events_export.h" 13 #include "ui/events/events_export.h"
14 #include "ui/gfx/x/x11_types.h" 14 #include "ui/gfx/x/x11_types.h"
15 15
16 using Time = unsigned long; 16 using Time = unsigned long;
17 using XEvent = union _XEvent; 17 using XEvent = union _XEvent;
18 using XID = unsigned long; 18 using XID = unsigned long;
19 using XWindow = unsigned long;
19 20
20 namespace ui { 21 namespace ui {
21 22
22 class X11HotplugEventHandler; 23 class X11HotplugEventHandler;
23 24
24 // Responsible for notifying X11EventSource when new XEvents are available and 25 // Responsible for notifying X11EventSource when new XEvents are available and
25 // processing/dispatching XEvents. Implementations will likely be a 26 // processing/dispatching XEvents. Implementations will likely be a
26 // PlatformEventSource. 27 // PlatformEventSource.
27 class X11EventSourceDelegate { 28 class X11EventSourceDelegate {
28 public: 29 public:
(...skipping 26 matching lines...) Expand all
55 // For those that know X11, this is really a wrapper around XWindowEvent 56 // For those that know X11, this is really a wrapper around XWindowEvent
56 // which still makes sure the preempted event is dispatched instead of 57 // which still makes sure the preempted event is dispatched instead of
57 // dropped on the floor. This method exists because mapping a window is 58 // dropped on the floor. This method exists because mapping a window is
58 // asynchronous (and we receive an XEvent when mapped), while there are also 59 // asynchronous (and we receive an XEvent when mapped), while there are also
59 // functions which require a mapped window. 60 // functions which require a mapped window.
60 void BlockUntilWindowMapped(XID window); 61 void BlockUntilWindowMapped(XID window);
61 62
62 XDisplay* display() { return display_; } 63 XDisplay* display() { return display_; }
63 Time last_seen_server_time() const { return last_seen_server_time_; } 64 Time last_seen_server_time() const { return last_seen_server_time_; }
64 65
66 // Explicitly asks the X11 server for the current timestamp, and updates
67 // |last_seen_server_time| with this value.
68 Time UpdateLastSeenServerTime();
69
65 void StopCurrentEventStream(); 70 void StopCurrentEventStream();
66 void OnDispatcherListChanged(); 71 void OnDispatcherListChanged();
67 72
68 protected: 73 protected:
69 // Extracts cookie data from |xevent| if it's of GenericType, and dispatches 74 // Extracts cookie data from |xevent| if it's of GenericType, and dispatches
70 // the event. This function also frees up the cookie data after dispatch is 75 // the event. This function also frees up the cookie data after dispatch is
71 // complete. 76 // complete.
72 void ExtractCookieDataDispatchEvent(XEvent* xevent); 77 void ExtractCookieDataDispatchEvent(XEvent* xevent);
73 78
74 // Handles updates after event has been dispatched. 79 // Handles updates after event has been dispatched.
75 void PostDispatchEvent(XEvent* xevent); 80 void PostDispatchEvent(XEvent* xevent);
76 81
77 private: 82 private:
78 static X11EventSource* instance_; 83 static X11EventSource* instance_;
79 84
80 X11EventSourceDelegate* delegate_; 85 X11EventSourceDelegate* delegate_;
81 86
82 // The connection to the X11 server used to receive the events. 87 // The connection to the X11 server used to receive the events.
83 XDisplay* display_; 88 XDisplay* display_;
84 89
85 // The last timestamp seen in an XEvent. 90 // The last timestamp seen in an XEvent.
86 Time last_seen_server_time_; 91 Time last_seen_server_time_;
87 92
93 // State necessary for UpdateLastSeenServerTime
94 bool dummy_initialized_;
95 XWindow dummy_window_;
96 XAtom dummy_atom_;
97
88 // Keeps track of whether this source should continue to dispatch all the 98 // Keeps track of whether this source should continue to dispatch all the
89 // available events. 99 // available events.
90 bool continue_stream_ = true; 100 bool continue_stream_ = true;
91 101
92 std::unique_ptr<X11HotplugEventHandler> hotplug_event_handler_; 102 std::unique_ptr<X11HotplugEventHandler> hotplug_event_handler_;
93 103
94 DISALLOW_COPY_AND_ASSIGN(X11EventSource); 104 DISALLOW_COPY_AND_ASSIGN(X11EventSource);
95 }; 105 };
96 106
97 } // namespace ui 107 } // namespace ui
98 108
99 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_ 109 #endif // UI_EVENTS_PLATFORM_X11_X11_EVENT_SOURCE_H_
OLDNEW
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/events/platform/x11/x11_event_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698