WebKit roll 98705:98715
[chromium-blink-merge.git] / base / message_pump_wayland.h
blob86b22a224db5b66c6113f4c8dbc29ab3cb5979e2
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_WAYLAND_H_
6 #define BASE_MESSAGE_PUMP_WAYLAND_H_
7 #pragma once
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_pump_glib.h"
12 typedef struct _GMainContext GMainContext;
13 typedef struct _GPollFD GPollFD;
14 typedef struct _GSource GSource;
16 namespace ui {
17 union WaylandEvent;
18 } // namespace ui
20 namespace base {
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.
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);
36 protected:
37 virtual ~MessagePumpObserver() {}
40 // The documentation for this class is in message_pump_glib.h
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.
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;
57 protected:
58 virtual ~MessagePumpDispatcher() {}
61 class BASE_EXPORT MessagePumpWayland : public MessagePumpGlib {
63 public:
64 MessagePumpWayland();
65 virtual ~MessagePumpWayland();
67 // Overridden from MessagePumpGlib
68 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE;
69 private:
71 // This is a GLib structure that we can add event sources to.
72 GMainContext* context_;
74 DISALLOW_COPY_AND_ASSIGN(MessagePumpWayland);
77 typedef MessagePumpWayland MessagePumpForUI;
79 } // namespace base
81 #endif // BASE_MESSAGE_PUMP_WAYLAND_H_