OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/message_pump_gtk.h" | 5 #include "base/message_pump_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include "base/profiler/scoped_profile.h" | 10 #include "base/profiler/scoped_profile.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 MessagePumpDispatcher* dispatcher = GetDispatcher(); | 79 MessagePumpDispatcher* dispatcher = GetDispatcher(); |
80 if (!dispatcher) | 80 if (!dispatcher) |
81 gtk_main_do_event(event); | 81 gtk_main_do_event(event); |
82 else if (!dispatcher->Dispatch(event)) | 82 else if (!dispatcher->Dispatch(event)) |
83 Quit(); | 83 Quit(); |
84 | 84 |
85 DidProcessEvent(event); | 85 DidProcessEvent(event); |
86 } | 86 } |
87 | 87 |
88 // static | 88 // static |
89 Display* MessagePumpGtk::GetDefaultXDisplay() { | 89 Display* MessagePumpGtk::GetDefaultXDisplay() { |
darin (slow to review)
2012/04/23 16:52:57
why do we need to involve a class named *Gtk in co
| |
90 static GdkDisplay* display = gdk_display_get_default(); | 90 static GdkDisplay* display = gdk_display_get_default(); |
91 return display ? GDK_DISPLAY_XDISPLAY(display) : NULL; | 91 if (!display) { |
92 // GTK / GDK has not been initialized, which is a decision we wish to | |
93 // support, for example for the GPU process. | |
94 static Display* xdisplay = XOpenDisplay(NULL); | |
95 return xdisplay; | |
96 } | |
97 return GDK_DISPLAY_XDISPLAY(display); | |
92 } | 98 } |
93 | 99 |
94 void MessagePumpGtk::WillProcessEvent(GdkEvent* event) { | 100 void MessagePumpGtk::WillProcessEvent(GdkEvent* event) { |
95 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), WillProcessEvent(event)); | 101 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), WillProcessEvent(event)); |
96 } | 102 } |
97 | 103 |
98 void MessagePumpGtk::DidProcessEvent(GdkEvent* event) { | 104 void MessagePumpGtk::DidProcessEvent(GdkEvent* event) { |
99 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(event)); | 105 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(event)); |
100 } | 106 } |
101 | 107 |
102 // static | 108 // static |
103 void MessagePumpGtk::EventDispatcher(GdkEvent* event, gpointer data) { | 109 void MessagePumpGtk::EventDispatcher(GdkEvent* event, gpointer data) { |
104 MessagePumpGtk* message_pump = reinterpret_cast<MessagePumpGtk*>(data); | 110 MessagePumpGtk* message_pump = reinterpret_cast<MessagePumpGtk*>(data); |
105 message_pump->DispatchEvents(event); | 111 message_pump->DispatchEvents(event); |
106 } | 112 } |
107 | 113 |
108 } // namespace base | 114 } // namespace base |
OLD | NEW |