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

Unified Diff: base/message_pump_x.cc

Issue 8872055: Refactor MessagePumpX to dispatch events inside of the source Dispatch function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« base/message_loop.cc ('K') | « base/message_pump_x.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_x.cc
diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc
index 13adb37837b4e9b529d8212102329ae61b787cbc..2ef34effbde80e8cec2b8f10adc4a771d3b73fed 100644
--- a/base/message_pump_x.cc
+++ b/base/message_pump_x.cc
@@ -25,11 +25,9 @@ gboolean XSourceCheck(GSource* source) {
gboolean XSourceDispatch(GSource* source,
GSourceFunc unused_func,
- gpointer unused_data) {
- // TODO(sad): When GTK event proecssing is completely removed, the event
- // processing and dispatching should be done here (i.e. XNextEvent,
- // ProcessXEvent etc.)
- return TRUE;
+ gpointer data) {
+ base::MessagePumpX* pump = static_cast<base::MessagePumpX*>(data);
+ return pump->DispatchXEvents();
}
GSourceFuncs XSourceFuncs = {
@@ -129,6 +127,7 @@ void MessagePumpX::InitXSource() {
x_source_ = g_source_new(&XSourceFuncs, sizeof(GSource));
g_source_add_poll(x_source_, x_poll);
g_source_set_can_recurse(x_source_, FALSE);
+ g_source_set_callback(x_source_, NULL, this, NULL);
g_source_attach(x_source_, g_main_context_default());
}
@@ -162,24 +161,21 @@ bool MessagePumpX::ProcessXEvent(MessagePumpDispatcher* dispatcher,
return should_quit;
}
-bool MessagePumpX::RunOnce(GMainContext* context, bool block) {
+gboolean MessagePumpX::DispatchXEvents() {
Display* display = GetDefaultXDisplay();
+ DCHECK(display);
MessagePumpDispatcher* dispatcher =
GetDispatcher() ? GetDispatcher() : g_default_dispatcher;
- if (!display)
- return g_main_context_iteration(context, block);
-
// In the general case, we want to handle all pending events before running
// the tasks. This is what happens in the message_pump_glib case.
while (XPending(display)) {
XEvent xev;
XNextEvent(display, &xev);
if (dispatcher && ProcessXEvent(dispatcher, &xev))
- return true;
+ return TRUE;
}
-
- return g_main_context_iteration(context, block);
+ return TRUE;
}
bool MessagePumpX::WillProcessXEvent(XEvent* xevent) {
« base/message_loop.cc ('K') | « base/message_pump_x.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698