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.
5 #ifndef BASE_MESSAGE_PUMP_GTK_H_
6 #define BASE_MESSAGE_PUMP_GTK_H_
9 #include "base/message_pump_glib.h"
11 typedef union _GdkEvent GdkEvent
;
12 typedef struct _XDisplay Display
;
16 // The documentation for this class is in message_pump_glib.h
17 class MessagePumpObserver
{
19 // This method is called before processing a message.
20 virtual void WillProcessEvent(GdkEvent
* event
) = 0;
22 // This method is called after processing a message.
23 virtual void DidProcessEvent(GdkEvent
* event
) = 0;
26 virtual ~MessagePumpObserver() {}
29 // The documentation for this class is in message_pump_glib.h
31 // The nested loop is exited by either posting a quit, or returning false
33 class MessagePumpDispatcher
{
35 // Dispatches the event. If true is returned processing continues as
36 // normal. If false is returned, the nested loop exits immediately.
37 virtual bool Dispatch(GdkEvent
* event
) = 0;
40 virtual ~MessagePumpDispatcher() {}
43 // This class implements a message-pump for dispatching GTK events.
44 class BASE_EXPORT MessagePumpGtk
: public MessagePumpGlib
{
47 virtual ~MessagePumpGtk();
49 // Dispatch an available GdkEvent. Essentially this allows a subclass to do
50 // some task before/after calling the default handler (EventDispatcher).
51 void DispatchEvents(GdkEvent
* event
);
53 // Returns default X Display.
54 static Display
* GetDefaultXDisplay();
57 // Invoked from EventDispatcher. Notifies all observers we're about to
59 void WillProcessEvent(GdkEvent
* event
);
61 // Invoked from EventDispatcher. Notifies all observers we processed an
63 void DidProcessEvent(GdkEvent
* event
);
65 // Callback prior to gdk dispatching an event.
66 static void EventDispatcher(GdkEvent
* event
, void* data
);
68 DISALLOW_COPY_AND_ASSIGN(MessagePumpGtk
);
71 typedef MessagePumpGtk MessagePumpForUI
;
75 #endif // BASE_MESSAGE_PUMP_GTK_H_