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_WAYLAND_H_ |
| 6 #define BASE_MESSAGE_PUMP_WAYLAND_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_pump_glib.h" |
| 11 |
| 12 typedef struct _GMainContext GMainContext; |
| 13 typedef struct _GPollFD GPollFD; |
| 14 typedef struct _GSource GSource; |
| 15 |
| 16 namespace ui { |
| 17 union WaylandEvent; |
| 18 } // namespace ui |
| 19 |
| 20 namespace base { |
| 21 |
| 22 // The documentation for this class is in message_pump_glib.h |
| 23 class BASE_EXPORT MessagePumpObserver { |
| 24 public: |
| 25 enum EventStatus { |
| 26 EVENT_CONTINUE, // The event should be dispatched as normal. |
| 27 EVENT_HANDLED // The event should not be processed any farther. |
| 28 }; |
| 29 |
| 30 // This method is called before processing an Event. If the method returns |
| 31 // EVENT_HANDLED, it indicates the event has already been handled, so the |
| 32 // event is not processed any farther. If the method returns EVENT_CONTINUE, |
| 33 // the event dispatching proceeds as normal. |
| 34 virtual EventStatus WillProcessEvent(ui::WaylandEvent* event); |
| 35 |
| 36 protected: |
| 37 virtual ~MessagePumpObserver() {} |
| 38 }; |
| 39 |
| 40 // The documentation for this class is in message_pump_glib.h |
| 41 // |
| 42 // The nested loop is exited by either posting a quit, or returning false |
| 43 // from Dispatch. |
| 44 class MessagePumpDispatcher { |
| 45 public: |
| 46 enum DispatchStatus { |
| 47 EVENT_IGNORED, // The event was not processed. |
| 48 EVENT_PROCESSED, // The event has been processed. |
| 49 EVENT_QUIT // The event was processed and the message-loop should |
| 50 // terminate. |
| 51 }; |
| 52 |
| 53 // Dispatches the event. If true is returned processing continues as |
| 54 // normal. If false is returned, the nested loop exits immediately. |
| 55 virtual DispatchStatus Dispatch(ui::WaylandEvent* event) = 0; |
| 56 |
| 57 protected: |
| 58 virtual ~MessagePumpDispatcher() {} |
| 59 }; |
| 60 |
| 61 class BASE_EXPORT MessagePumpWayland : public MessagePumpGlib { |
| 62 |
| 63 public: |
| 64 MessagePumpWayland(); |
| 65 virtual ~MessagePumpWayland(); |
| 66 |
| 67 // Overridden from MessagePumpGlib |
| 68 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; |
| 69 private: |
| 70 |
| 71 // This is a GLib structure that we can add event sources to. |
| 72 GMainContext* context_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(MessagePumpWayland); |
| 75 }; |
| 76 |
| 77 typedef MessagePumpWayland MessagePumpForUI; |
| 78 |
| 79 } // namespace base |
| 80 |
| 81 #endif // BASE_MESSAGE_PUMP_WAYLAND_H_ |
OLD | NEW |