| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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 |
| 6 #ifndef PPAPI_SIMPLE_PS_EVENT_H_ |
| 7 #define PPAPI_SIMPLE_PS_EVENT_H_ |
| 8 |
| 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/c/pp_var.h" |
| 12 |
| 13 #include "utils/macros.h" |
| 14 |
| 15 EXTERN_C_BEGIN |
| 16 |
| 17 /** |
| 18 * PSEvent |
| 19 * |
| 20 * The PSEvent system provides an in-order event processing mechanism. |
| 21 * As Pepper events such as input, or focus and view changes arrive on the |
| 22 * main pepper thread, they are placed on various FIFOs based on event type. |
| 23 * For any given event type, only a single thread will process those events. |
| 24 * |
| 25 * By default, the "EventThread" will receive all messages. However any thread |
| 26 * can call PSRequestEventsType to request that all new events of that type |
| 27 * are placed on that particular thread's queue. |
| 28 * |
| 29 * This allows the developer to choose which threads handle which event types |
| 30 * while keeping all events belonging to a particular thread in order. This |
| 31 * is useful, for example, in the case of graphics to synchronize the size |
| 32 * of the graphics context, with mouse clicks to correctly interpret location. |
| 33 */ |
| 34 |
| 35 |
| 36 typedef enum { |
| 37 /* Mask off all events. */ |
| 38 PSE_NONE = 0, |
| 39 |
| 40 /* From HandleInputEvent, conatins an input resource. */ |
| 41 PSE_INSTANCE_HANDLEINPUT = 1, |
| 42 |
| 43 /* From HandleMessage, contains a PP_Var. */ |
| 44 PSE_INSTANCE_HANDLEMESSAGE = 2, |
| 45 |
| 46 /* From DidChangeView, contains a view resource */ |
| 47 PSE_INSTANCE_DIDCHANGEVIEW = 4, |
| 48 |
| 49 /* From DidChangeFocus, contains a PP_Bool with the current focus state. */ |
| 50 PSE_INSTANCE_DIDCHANGEFOCUS = 8, |
| 51 |
| 52 /* When the 3D context is lost, no resource. */ |
| 53 PSE_GRAPHICS3D_GRAPHICS3DCONTEXTLOST = 16, |
| 54 |
| 55 /* When the mouse lock is lost. */ |
| 56 PSE_MOUSELOCK_MOUSELOCKLOST = 32, |
| 57 |
| 58 /* Enable all events. */ |
| 59 PSE_ALL = -1, |
| 60 } PSEventType; |
| 61 |
| 62 typedef uint32_t PSEventTypeMask; |
| 63 |
| 64 // Generic Event |
| 65 typedef struct { |
| 66 PSEventType type; |
| 67 union { |
| 68 PP_Bool as_bool; |
| 69 PP_Resource as_resource; |
| 70 struct PP_Var as_var; |
| 71 }; |
| 72 } PSEvent; |
| 73 |
| 74 |
| 75 /** |
| 76 * Function for queuing, acquiring, and releasing events. |
| 77 */ |
| 78 PSEvent* PSEventTryAcquire(); |
| 79 PSEvent* PSEventWaitAcquire(); |
| 80 void PSEventRelease(PSEvent* event); |
| 81 void PSEventSetFilter(PSEventTypeMask mask); |
| 82 |
| 83 /** |
| 84 * Creates and adds an event of the specified type to the event queue if |
| 85 * that event type is not currently filtered. |
| 86 */ |
| 87 void PSEventPost(PSEventType type); |
| 88 void PSEventPostBool(PSEventType type, PP_Bool state); |
| 89 void PSEventPostVar(PSEventType type, struct PP_Var var); |
| 90 void PSEventPostResource(PSEventType type, PP_Resource resource); |
| 91 |
| 92 EXTERN_C_END |
| 93 |
| 94 #endif // PPAPI_SIMPLE_PS_EVENT_H_ |
| 95 |
| OLD | NEW |