# HG changeset patch # User Benjamin Golinvaux # Date 1586185076 -7200 # Node ID df8bf351c23f9caf8aed0f75b6e0718715ab9489 # Parent 0d6a01ffa1dd20ba1dae79d4d8c7e9fc1b0277bb The flag that allows the WebAssemblyViewport to **not** register the mouse events in the canvas (in case they are handled by other means) is now correctly passed down from the factory method. diff -r 0d6a01ffa1dd -r df8bf351c23f Framework/Viewport/WebAssemblyViewport.cpp --- a/Framework/Viewport/WebAssemblyViewport.cpp Mon Apr 06 09:17:40 2020 +0200 +++ b/Framework/Viewport/WebAssemblyViewport.cpp Mon Apr 06 16:57:56 2020 +0200 @@ -160,23 +160,16 @@ EM_BOOL WebAssemblyViewport::OnMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP1. userData = " << userData; - WebAssemblyViewport* that = reinterpret_cast(userData); - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP2"; if (that->compositor_.get() != NULL && that->controller_->HasActiveTracker()) { - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP3"; PointerEvent pointer; ConvertMouseEvent(pointer, *mouseEvent, *that->compositor_); - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP4"; if (that->controller_->HandleMouseMove(pointer)) { - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP5"; that->Invalidate(); - LOG(TRACE) << "WebAssemblyViewport::OnMouseMove CP6"; } } @@ -219,11 +212,11 @@ } WebAssemblyViewport::WebAssemblyViewport( - const std::string& canvasId, bool enableEmscriptenEvents) : + const std::string& canvasId, bool enableEmscriptenMouseEvents) : shortCanvasId_(canvasId), fullCanvasId_(canvasId), interactor_(new DefaultViewportInteractor), - enableEmscriptenEvents_(enableEmscriptenEvents) + enableEmscriptenMouseEvents_(enableEmscriptenMouseEvents) { } @@ -253,14 +246,15 @@ shortCanvasId_.c_str() // $0 ); - if (enableEmscriptenEvents_) + // It is not possible to monitor the resizing of individual + // canvas, so we track the full window of the browser + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, + reinterpret_cast(this), + false, + OnResize); + + if (enableEmscriptenMouseEvents_) { - // It is not possible to monitor the resizing of individual - // canvas, so we track the full window of the browser - emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, - reinterpret_cast(this), - false, - OnResize); emscripten_set_mousedown_callback(fullCanvasId_.c_str(), reinterpret_cast(this), @@ -281,12 +275,13 @@ WebAssemblyViewport::~WebAssemblyViewport() { - if (enableEmscriptenEvents_) + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, + reinterpret_cast(this), + false, + NULL); + + if (enableEmscriptenMouseEvents_) { - emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, - reinterpret_cast(this), - false, - NULL); emscripten_set_mousedown_callback(fullCanvasId_.c_str(), reinterpret_cast(this), diff -r 0d6a01ffa1dd -r df8bf351c23f Framework/Viewport/WebAssemblyViewport.h --- a/Framework/Viewport/WebAssemblyViewport.h Mon Apr 06 09:17:40 2020 +0200 +++ b/Framework/Viewport/WebAssemblyViewport.h Mon Apr 06 16:57:56 2020 +0200 @@ -53,7 +53,7 @@ std::unique_ptr compositor_; std::unique_ptr controller_; std::unique_ptr interactor_; - bool enableEmscriptenEvents_; + bool enableEmscriptenMouseEvents_; static EM_BOOL OnRequestAnimationFrame(double time, void *userData); @@ -90,7 +90,7 @@ to interactors is finished. */ WebAssemblyViewport(const std::string& canvasId, - bool enableEmscriptenEvents = true); + bool enableEmscriptenMouseEvents = true); void PostConstructor(); diff -r 0d6a01ffa1dd -r df8bf351c23f Framework/Viewport/WebGLViewport.cpp --- a/Framework/Viewport/WebGLViewport.cpp Mon Apr 06 09:17:40 2020 +0200 +++ b/Framework/Viewport/WebGLViewport.cpp Mon Apr 06 16:57:56 2020 +0200 @@ -79,18 +79,19 @@ } } - WebGLViewport::WebGLViewport(const std::string& canvasId) : - WebAssemblyViewport(canvasId), + WebGLViewport::WebGLViewport(const std::string& canvasId, bool enableEmscriptenMouseEvents) : + WebAssemblyViewport(canvasId,enableEmscriptenMouseEvents), context_(GetFullCanvasId()) { AcquireCompositor(new OpenGLCompositor(context_)); } boost::shared_ptr WebGLViewport::Create( - const std::string& canvasId) + const std::string& canvasId, bool enableEmscriptenMouseEvents) { - boost::shared_ptr that = - boost::shared_ptr(new WebGLViewport(canvasId)); + boost::shared_ptr that = boost::shared_ptr( + new WebGLViewport(canvasId, enableEmscriptenMouseEvents)); + that->WebAssemblyViewport::PostConstructor(); return that; } diff -r 0d6a01ffa1dd -r df8bf351c23f Framework/Viewport/WebGLViewport.h --- a/Framework/Viewport/WebGLViewport.h Mon Apr 06 09:17:40 2020 +0200 +++ b/Framework/Viewport/WebGLViewport.h Mon Apr 06 16:57:56 2020 +0200 @@ -30,8 +30,8 @@ { private: OpenGL::WebAssemblyOpenGLContext context_; - - WebGLViewport(const std::string& canvasId); + + WebGLViewport(const std::string& canvasId, bool enableEmscriptenMouseEvents); protected: virtual void Paint(ICompositor& compositor, @@ -40,7 +40,7 @@ virtual void UpdateSize(ICompositor& compositor) ORTHANC_OVERRIDE; public: - static boost::shared_ptr Create(const std::string& canvasId); + static boost::shared_ptr Create(const std::string& canvasId, bool enableEmscriptenMouseEvents = true); virtual ~WebGLViewport();