mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 02:20:43 -05:00
9ef37423fc
Instead of simply relying on the emscripten mainloop api to wake us up periodically so that we can poll for SDL events we now pause the emscripten mainloop whenever no redraw is queued and instead hook an input event listener into the real browser mainloop to resume the emscripten mainloop whenever input is received. This way the example can go to sleep while there's no input to handle. This provides a simple example of binding custom javascript into native code. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit a8b1e2eda491dc7c44c84cd47e160c7b8ba0f792)
19 lines
526 B
C
19 lines
526 B
C
|
|
#ifndef _EMSCRIPTEN_EXAMPLE_JS_H_
|
|
#define _EMSCRIPTEN_EXAMPLE_JS_H_
|
|
|
|
/*
|
|
* example_js_add_input_listener:
|
|
*
|
|
* Adds an input event listener to the browser's mainloop and whenever
|
|
* input is received then the emscripten mainloop is resumed, if it
|
|
* has been paused.
|
|
*
|
|
* This means we don't have to poll SDL for events and can instead go
|
|
* to sleep waiting in the browser mainloop when there's no input and
|
|
* nothing being animated.
|
|
*/
|
|
void example_js_add_input_listener (void);
|
|
|
|
#endif /* _EMSCRIPTEN_EXAMPLE_JS_H_ */
|