Fix platform conditionalization of NaCl IRT file name
[chromium-blink-merge.git] / base / message_pump_gtk.h
blobea1630f06f2659dd1baae6f05ea938dc4934708d
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_
7 #pragma once
9 #include "base/message_pump_glib.h"
11 typedef union _GdkEvent GdkEvent;
12 typedef struct _XDisplay Display;
14 namespace base {
16 // The documentation for this class is in message_pump_glib.h
17 class MessagePumpObserver {
18 public:
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;
25 protected:
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
32 // from Dispatch.
33 class MessagePumpDispatcher {
34 public:
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;
39 protected:
40 virtual ~MessagePumpDispatcher() {}
43 // This class implements a message-pump for dispatching GTK events.
44 class BASE_EXPORT MessagePumpGtk : public MessagePumpGlib {
45 public:
46 MessagePumpGtk();
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();
56 private:
57 // Invoked from EventDispatcher. Notifies all observers we're about to
58 // process an event.
59 void WillProcessEvent(GdkEvent* event);
61 // Invoked from EventDispatcher. Notifies all observers we processed an
62 // event.
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;
73 } // namespace base
75 #endif // BASE_MESSAGE_PUMP_GTK_H_