diff options
Diffstat (limited to 'base/message_pump_glib.cc')
-rw-r--r-- | base/message_pump_glib.cc | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc index e85a712..ad6d177 100644 --- a/base/message_pump_glib.cc +++ b/base/message_pump_glib.cc @@ -207,8 +207,7 @@ void MessagePumpForUI::RunWithDispatcher(Delegate* delegate, // Don't block if we think we have more work to do. bool block = !more_work_is_plausible; - // g_main_context_iteration returns true if events have been dispatched. - more_work_is_plausible = g_main_context_iteration(context_, block); + more_work_is_plausible = RunOnce(context_, block); if (state_->should_quit) break; @@ -232,6 +231,11 @@ void MessagePumpForUI::RunWithDispatcher(Delegate* delegate, state_ = previous_state; } +bool MessagePumpForUI::RunOnce(GMainContext* context, bool block) { + // g_main_context_iteration returns true if events have been dispatched. + return g_main_context_iteration(context, block); +} + // Return the timeout we want passed to poll. int MessagePumpForUI::HandlePrepare() { // We know we have work, but we haven't called HandleDispatch yet. Don't let @@ -332,19 +336,21 @@ void MessagePumpForUI::ScheduleDelayedWork(const Time& delayed_work_time) { ScheduleWork(); } -// static -void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) { - MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data); - - message_pump->WillProcessEvent(event); - if (message_pump->state_ && // state_ may be null during tests. - message_pump->state_->dispatcher) { - if (!message_pump->state_->dispatcher->Dispatch(event)) - message_pump->state_->should_quit = true; +void MessagePumpForUI::DispatchEvents(GdkEvent* event) { + WillProcessEvent(event); + if (state_ && state_->dispatcher) { // state_ may be null during tests. + if (!state_->dispatcher->Dispatch(event)) + state_->should_quit = true; } else { gtk_main_do_event(event); } - message_pump->DidProcessEvent(event); + DidProcessEvent(event); +} + +// static +void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) { + MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data); + message_pump->DispatchEvents(event); } } // namespace base |