Skip to content

Commit

Permalink
Switch to _on_thread set callback function for mousemove
Browse files Browse the repository at this point in the history
  • Loading branch information
iceiix committed May 21, 2019
1 parent cd5caf6 commit a319b50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/platform/emscripten/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ use std::os::raw::{c_int, c_char, c_void, c_ulong, c_double, c_long, c_ushort};
use std::mem;

pub type EM_BOOL = c_int;
pub type pthread_t = c_int;
pub type EM_UTF8 = c_char;
pub type EMSCRIPTEN_RESULT = c_int;

pub const EM_TRUE: EM_BOOL = 1;
pub const EM_FALSE: EM_BOOL = 0;

pub const EM_CALLBACK_THREAD_CONTEXT_MAIN_BROWSER_THREAD: pthread_t = 1;
pub const EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD: pthread_t = 2;

// values for EMSCRIPTEN_RESULT
pub const EMSCRIPTEN_RESULT_SUCCESS: c_int = 0;
pub const EMSCRIPTEN_RESULT_DEFERRED: c_int = 1;
Expand Down Expand Up @@ -258,9 +262,10 @@ extern "C" {
useCapture: EM_BOOL, callback: em_key_callback_func)
-> EMSCRIPTEN_RESULT;

pub fn emscripten_set_mousemove_callback(
pub fn emscripten_set_mousemove_callback_on_thread(
target: *const c_char, user_data: *mut c_void,
use_capture: EM_BOOL, callback: em_mouse_callback_func)
use_capture: EM_BOOL, callback: em_mouse_callback_func,
target_thread: pthread_t)
-> EMSCRIPTEN_RESULT;

pub fn emscripten_set_mousedown_callback(
Expand Down
2 changes: 1 addition & 1 deletion src/platform/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl Window {

// TODO: set up more event callbacks
unsafe {
em_try(ffi::emscripten_set_mousemove_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback)))
em_try(ffi::emscripten_set_mousemove_callback_on_thread(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback), ffi::EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD))
.map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?;
em_try(ffi::emscripten_set_mousedown_callback(DOCUMENT_NAME.as_ptr() as *const c_char, mem::transmute(&*window.window.events), ffi::EM_FALSE, Some(mouse_callback)))
.map_err(|e| ::CreationError::OsError(format!("emscripten error: {}", e)))?;
Expand Down

0 comments on commit a319b50

Please sign in to comment.