diff Framework/Viewport/WebAssemblyViewport.cpp @ 1346:df8bf351c23f broker

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.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 06 Apr 2020 16:57:56 +0200
parents ab81ee8fce1f
children 1b8e37770d78
line wrap: on
line diff
--- 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<WebAssemblyViewport*>(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<void*>(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<void*>(this),
-                                     false,
-                                     OnResize);
 
       emscripten_set_mousedown_callback(fullCanvasId_.c_str(),
                                         reinterpret_cast<void*>(this),
@@ -281,12 +275,13 @@
 
   WebAssemblyViewport::~WebAssemblyViewport()
   {
-    if (enableEmscriptenEvents_)
+    emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,
+                                   reinterpret_cast<void*>(this),
+                                   false,
+                                   NULL);
+
+    if (enableEmscriptenMouseEvents_)
     {
-      emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW,
-                                     reinterpret_cast<void*>(this),
-                                     false,
-                                     NULL);
 
       emscripten_set_mousedown_callback(fullCanvasId_.c_str(),
                                         reinterpret_cast<void*>(this),