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 WAYLAND_MESSAGE_PUMP_H_ |
| 6 #define WAYLAND_MESSAGE_PUMP_H_ |
| 7 |
| 8 #include <glib.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 |
| 13 class WaylandDisplay; |
| 14 |
| 15 /* The message pump handles Wayland specific event delivery. This message |
| 16 pump uses the default glib context, so running a glib main loop with the |
| 17 default context will allow looping through Wayland events. |
| 18 */ |
| 19 class WaylandMessagePump { |
| 20 public: |
| 21 WaylandMessagePump(WaylandDisplay* display); |
| 22 virtual ~WaylandMessagePump(); |
| 23 |
| 24 protected: |
| 25 /* These are used to process the pump callbacks. |
| 26 HandlePrepare: is called during glib's prepare step and returns a timeout |
| 27 that will be passed to the poll. |
| 28 HandleCheck: called after HandlePrepare and returns whether HandleDispatch |
| 29 should be called. |
| 30 HandleDispatch:is called after HandleCheck returns true and it will dispatch |
| 31 a Wayland event. |
| 32 */ |
| 33 virtual int HandlePrepare(); |
| 34 virtual bool HandleCheck(); |
| 35 virtual void HandleDispatch(); |
| 36 private: |
| 37 struct WorkSource : public GSource { |
| 38 WaylandMessagePump* pump; |
| 39 }; |
| 40 |
| 41 /* Actual callbacks for glib. These functions will just call the appropriate |
| 42 Handle* functions in a WaylandMessagePump object. |
| 43 */ |
| 44 static gboolean SourcePrepare(GSource* source, gint* timeout); |
| 45 static gboolean SourceCheck(GSource* source); |
| 46 static gboolean SourceDispatch(GSource* source, |
| 47 GSourceFunc callback, |
| 48 gpointer data); |
| 49 /* Handles updates to the Wayland mask. This is used to signal when the |
| 50 compositor is done processing writable events. |
| 51 */ |
| 52 static int SourceUpdate(uint32_t mask, void* data); |
| 53 |
| 54 WaylandDisplay* display_; |
| 55 WorkSource* source_; |
| 56 GPollFD pfd_; |
| 57 uint32_t mask_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(WaylandMessagePump); |
| 60 }; |
| 61 |
| 62 #endif |
OLD | NEW |