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

Side by Side Diff: base/message_pump_gtk.cc

Issue 7250001: Refactor the glib message-pump, and use it as the base for a gtk message pump and an X message pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: media.gyp update Created 9 years, 6 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
« no previous file with comments | « base/message_pump_gtk.h ('k') | base/message_pump_x.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/message_pump_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 namespace base {
10
11 MessagePumpGtk::MessagePumpGtk() : MessagePumpGlib() {
12 gdk_event_handler_set(&EventDispatcher, this, NULL);
13 }
14
15 MessagePumpGtk::~MessagePumpGtk() {
16 gdk_event_handler_set(reinterpret_cast<GdkEventFunc>(gtk_main_do_event),
17 this, NULL);
18 }
19
20 void MessagePumpGtk::DispatchEvents(GdkEvent* event) {
21 WillProcessEvent(event);
22
23 MessagePumpDispatcher* dispatcher = GetDispatcher();
24 if (!dispatcher)
25 gtk_main_do_event(event);
26 else if (!dispatcher->Dispatch(event))
27 Quit();
28
29 DidProcessEvent(event);
30 }
31
32 bool MessagePumpGtk::RunOnce(GMainContext* context, bool block) {
33 // g_main_context_iteration returns true if events have been dispatched.
34 return g_main_context_iteration(context, block);
35 }
36
37 void MessagePumpGtk::WillProcessEvent(GdkEvent* event) {
38 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), WillProcessEvent(event));
39 }
40
41 void MessagePumpGtk::DidProcessEvent(GdkEvent* event) {
42 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(event));
43 }
44
45 // static
46 void MessagePumpGtk::EventDispatcher(GdkEvent* event, gpointer data) {
47 MessagePumpGtk* message_pump = reinterpret_cast<MessagePumpGtk*>(data);
48 message_pump->DispatchEvents(event);
49 }
50
51 } // namespace base
52
OLDNEW
« no previous file with comments | « base/message_pump_gtk.h ('k') | base/message_pump_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698