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