0032686: Visualization, Wasm_Window - filter out unexpected pressed buttons state...
authorkgv <kgv@opencascade.com>
Tue, 23 Nov 2021 21:08:21 +0000 (00:08 +0300)
committersmoskvin <smoskvin@opencascade.com>
Thu, 25 Nov 2021 16:51:15 +0000 (19:51 +0300)
Wasm_Window::ProcessMouseEvent() now ignores not previously pressed mouse buttons within mouse move / up events.
Fixed -Wshorten-64-to-32 compiler warning within cpulimit command on 32-bit Linux.

src/Draw/Draw_BasicCommands.cxx
src/Wasm/Wasm_Window.cxx

index 0f8dd40..d8d0bb0 100644 (file)
@@ -636,15 +636,21 @@ static Standard_Integer cpulimit(Draw_Interpretor& di, Standard_Integer n, const
   rlimit rlp;
   rlp.rlim_max = RLIM_INFINITY;
   if (n <= 1)
+  {
     rlp.rlim_cur = RLIM_INFINITY;
+  }
   else
+  {
     rlp.rlim_cur = GetCpuLimit (a[1]);
-  CPU_LIMIT = rlp.rlim_cur;
+  }
 
-  int status;
-  status=setrlimit(RLIMIT_CPU,&rlp);
-  if (status !=0)
-    di << "status cpulimit setrlimit : " << status << "\n";
+  CPU_LIMIT = (clock_t )rlp.rlim_cur;
+
+  int aStatus = setrlimit (RLIMIT_CPU, &rlp);
+  if (aStatus != 0)
+  {
+    di << "status cpulimit setrlimit : " << aStatus << "\n";
+  }
 
   // set signal handler to print a message before death
   struct sigaction act, oact;
index 985333b..71e4478 100644 (file)
@@ -276,14 +276,19 @@ bool Wasm_Window::ProcessMouseEvent (Aspect_WindowInputListener& theListener,
   if (theEvent->metaKey  == EM_TRUE) { aFlags |= Aspect_VKeyFlags_META;  }
 
   const bool isEmulated = false;
-  const Aspect_VKeyMouse aButtons = Wasm_Window::MouseButtonsFromNative (theEvent->buttons);
+  const Aspect_VKeyMouse aButtonsOld = theListener.PressedMouseButtons();
+  Aspect_VKeyMouse aButtons = Wasm_Window::MouseButtonsFromNative (theEvent->buttons);
+  if (theEventType != EMSCRIPTEN_EVENT_MOUSEDOWN)
+  {
+    aButtons &= aButtonsOld; // filter out unexpected buttons
+  }
   switch (theEventType)
   {
     case EMSCRIPTEN_EVENT_MOUSEMOVE:
     {
       if ((aNewPos2i.x() < 0 || aNewPos2i.x() > mySize.x()
         || aNewPos2i.y() < 0 || aNewPos2i.y() > mySize.y())
-        && theListener.PressedMouseButtons() == Aspect_VKeyMouse_NONE)
+        && aButtonsOld == Aspect_VKeyMouse_NONE)
       {
         return false;
       }