OLD | NEW |
(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 #ifndef BASE_MESSAGE_PUMP_GTK_H_ |
| 6 #define BASE_MESSAGE_PUMP_GTK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/message_pump_glib.h" |
| 10 |
| 11 typedef union _GdkEvent GdkEvent; |
| 12 |
| 13 namespace base { |
| 14 |
| 15 // The documentation for this class is in message_pump_glib.h |
| 16 class MessagePumpObserver { |
| 17 public: |
| 18 virtual ~MessagePumpObserver() {} |
| 19 |
| 20 // This method is called before processing a message. |
| 21 virtual void WillProcessEvent(GdkEvent* event) = 0; |
| 22 |
| 23 // This method is called after processing a message. |
| 24 virtual void DidProcessEvent(GdkEvent* event) = 0; |
| 25 }; |
| 26 |
| 27 // The documentation for this class is in message_pump_glib.h |
| 28 class MessagePumpDispatcher { |
| 29 public: |
| 30 virtual ~MessagePumpDispatcher() {} |
| 31 |
| 32 // Dispatches the event. If true is returned processing continues as |
| 33 // normal. If false is returned, the nested loop exits immediately. |
| 34 virtual bool Dispatch(GdkEvent* event) = 0; |
| 35 }; |
| 36 |
| 37 // This class implements a message-pump for dispatching GTK events. |
| 38 class MessagePumpGtk : public MessagePumpGlib { |
| 39 public: |
| 40 MessagePumpGtk(); |
| 41 virtual ~MessagePumpGtk(); |
| 42 |
| 43 // Dispatch an available GdkEvent. Essentially this allows a subclass to do |
| 44 // some task before/after calling the default handler (EventDispatcher). |
| 45 virtual void DispatchEvents(GdkEvent* event); |
| 46 |
| 47 private: |
| 48 // Overridden from MessagePumpGlib |
| 49 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; |
| 50 |
| 51 // Invoked from EventDispatcher. Notifies all observers we're about to |
| 52 // process an event. |
| 53 void WillProcessEvent(GdkEvent* event); |
| 54 |
| 55 // Invoked from EventDispatcher. Notifies all observers we processed an |
| 56 // event. |
| 57 void DidProcessEvent(GdkEvent* event); |
| 58 |
| 59 // Callback prior to gdk dispatching an event. |
| 60 static void EventDispatcher(GdkEvent* event, void* data); |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(MessagePumpGtk); |
| 63 }; |
| 64 |
| 65 typedef MessagePumpGtk MessagePumpForUI; |
| 66 |
| 67 } // namespace base |
| 68 |
| 69 #endif // BASE_MESSAGE_PUMP_GTK_H_ |
OLD | NEW |