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

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

Issue 274383002: events: Remove ability to terminate a nested message-loop from the event-source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 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 | Annotate | Revision Log
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 #include "ui/events/platform/x11/x11_event_source.h" 5 #include "ui/events/platform/x11/x11_event_source.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/X.h> 8 #include <X11/X.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 DVLOG(1) << "XKB not supported in the server."; 73 DVLOG(1) << "XKB not supported in the server.";
74 return false; 74 return false;
75 } 75 }
76 76
77 return true; 77 return true;
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 X11EventSource::X11EventSource(XDisplay* display) 82 X11EventSource::X11EventSource(XDisplay* display)
83 : display_(display) { 83 : display_(display),
84 continue_stream_(true) {
84 CHECK(display_); 85 CHECK(display_);
85 InitializeXInput2(display_); 86 InitializeXInput2(display_);
86 InitializeXkb(display_); 87 InitializeXkb(display_);
87 } 88 }
88 89
89 X11EventSource::~X11EventSource() { 90 X11EventSource::~X11EventSource() {
90 } 91 }
91 92
92 // static 93 // static
93 X11EventSource* X11EventSource::GetInstance() { 94 X11EventSource* X11EventSource::GetInstance() {
94 return static_cast<X11EventSource*>(PlatformEventSource::GetInstance()); 95 return static_cast<X11EventSource*>(PlatformEventSource::GetInstance());
95 } 96 }
96 97
97 //////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////////
98 // X11EventSource, public 99 // X11EventSource, public
99 100
100 void X11EventSource::DispatchXEvents() { 101 void X11EventSource::DispatchXEvents() {
101 DCHECK(display_); 102 DCHECK(display_);
102 // Handle all pending events. 103 // Handle all pending events.
103 // It may be useful to eventually align this event dispatch with vsync, but 104 // It may be useful to eventually align this event dispatch with vsync, but
104 // not yet. 105 // not yet.
105 while (XPending(display_)) { 106 continue_stream_ = true;
107 while (XPending(display_) && continue_stream_) {
106 XEvent xevent; 108 XEvent xevent;
107 XNextEvent(display_, &xevent); 109 XNextEvent(display_, &xevent);
108 uint32_t action = DispatchEvent(&xevent); 110 DispatchEvent(&xevent);
109 if (action & POST_DISPATCH_QUIT_LOOP)
110 break;
111 } 111 }
112 } 112 }
113 113
114 void X11EventSource::BlockUntilWindowMapped(XID window) { 114 void X11EventSource::BlockUntilWindowMapped(XID window) {
115 XEvent event; 115 XEvent event;
116 do { 116 do {
117 // Block until there's a message of |event_mask| type on |w|. Then remove 117 // Block until there's a message of |event_mask| type on |w|. Then remove
118 // it from the queue and stuff it in |event|. 118 // it from the queue and stuff it in |event|.
119 XWindowEvent(display_, window, StructureNotifyMask, &event); 119 XWindowEvent(display_, window, StructureNotifyMask, &event);
120 DispatchEvent(&event); 120 DispatchEvent(&event);
(...skipping 14 matching lines...) Expand all
135 if (xevent->type == GenericEvent && 135 if (xevent->type == GenericEvent &&
136 xevent->xgeneric.evtype == XI_HierarchyChanged) { 136 xevent->xgeneric.evtype == XI_HierarchyChanged) {
137 ui::UpdateDeviceList(); 137 ui::UpdateDeviceList();
138 } 138 }
139 139
140 if (have_cookie) 140 if (have_cookie)
141 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 141 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
142 return action; 142 return action;
143 } 143 }
144 144
145 void X11EventSource::StopCurrentEventStream() {
146 continue_stream_ = false;
147 }
148
145 } // namespace ui 149 } // namespace ui
OLDNEW
« ash/accelerators/accelerator_dispatcher_linux.cc ('K') | « ui/events/platform/x11/x11_event_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698