Chromium Code Reviews| Index: native_client_sdk/src/libraries/ppapi_simple/ppapi_event.h |
| diff --git a/native_client_sdk/src/libraries/ppapi_simple/ppapi_event.h b/native_client_sdk/src/libraries/ppapi_simple/ppapi_event.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9616fdc0aa251c9f6d39a3779fcdcd2e763473b0 |
| --- /dev/null |
| +++ b/native_client_sdk/src/libraries/ppapi_simple/ppapi_event.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| + |
| +#ifndef PPAPI_SIMPLE_PPAPI_EVENT_H_ |
| +#define PPAPI_SIMPLE_PPAPI_EVENT_H_ |
| + |
| +#include "ppapi/c/pp_bool.h" |
| +#include "ppapi/c/pp_resource.h" |
| +#include "ppapi/c/pp_var.h" |
| + |
| +#include "utils/macros.h" |
| + |
| +EXTERN_C_BEGIN |
| + |
| + |
| + |
| +/** |
| + * PSEvent |
| + * |
| + * The PSEvent system provides an in-order event processing mechanism. |
| + * As Pepper events such as input, or focus and view changes arrive on the |
| + * main pepper thread, they are placed on various FIFOs based on event type. |
| + * For any given event type, only a single thread will process those events. |
| + * |
| + * By default, the "EventThread" will receive all messages. However any thread |
| + * can call PSRequestEventsType to request that all new events of that type |
| + * are placed on that particular thread's queue. |
| + * |
| + * This allows the developer to choose which threads handle which event types |
| + * while keeping all events belonging to a particular thread in order. This |
| + * is useful, for example, in the case of graphics to synchronize the size |
| + * of the graphics context, with mouse clicks to correctly interpret location. |
| + */ |
| + |
| + |
| +typedef enum { |
| + PS_NO_EVENTS = 0, // Mask off all events |
| + PS_MESSAGE_EVENT = 1, // From HandleMessage, contains a PP_Var |
| + PS_VIEW_EVENT = 2, // From DidChangeView, contains a view resource |
|
Sam Clegg
2013/05/29 04:48:25
We don't align the assignment operators normally d
noelallen_use_chromium
2013/05/30 00:25:07
Done.
|
| + PS_INPUT_EVENT = 4, // From HandleInputEvent, conatins an input resource |
| + PS_FOCUS_EVENT = 8, // Focus change, contains a PP_Bool |
| + PS_3D_LOST_EVENT = 16, // When the 3D context is lost, no resource. |
| + PS_MOUSELOCK_EVENT = 32,// When the mouse lock is lost. |
| + PS_ALL_EVENTS = -1, // Enable all events |
| +} PSEventType; |
| + |
| + |
| +// Generic Event |
| +typedef struct { |
| + PSEventType type; |
| + union { |
| + PP_Bool as_bool; |
| + PP_Resource as_resource; |
| + struct PP_Var as_var; |
| + }; |
| +} PSEvent; |
| + |
| + |
| +/** |
| + * Function for queuing, acquiring, and releasing events. |
| + */ |
| +PSEvent* PSCreateEvent(); |
| +PSEvent* PSTryToAcquireEvent(); |
| +PSEvent* PSWaitForAcquireEvent(); |
| +void PSReleaseEvent(PSEvent* event); |
| +void PSSetEventFilter(uint32_t); |
| + |
| +/** |
| + * PSPostEvent |
| + * |
| + * Creates and adds an event of the specified type to the event queue if |
| + * that event type is not currently filtered. |
| + */ |
| +void PSPostEvent(PSEventType type); |
| +void PSPostBoolEvent(PSEventType type, PP_Bool state); |
| +void PSPostVarEvent(PSEventType type, struct PP_Var var); |
| +void PSPostResourceEvent(PSEventType type, PP_Resource resource); |
| + |
| +EXTERN_C_END |
| + |
| +#endif // PPAPI_SIMPLE_PPAPI_EVENT_H_ |
| + |