From b6b55c3d96ed10d4fccac8873827f76203b9d087 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 24 Nov 2021 00:08:21 +0300 Subject: [PATCH] 0032686: Visualization, Wasm_Window - filter out unexpected pressed buttons state within mouse move / up events 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 | 16 +++++++++++----- src/Wasm/Wasm_Window.cxx | 9 +++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Draw/Draw_BasicCommands.cxx b/src/Draw/Draw_BasicCommands.cxx index 0f8dd40da0..d8d0bb0c69 100644 --- a/src/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/Draw_BasicCommands.cxx @@ -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; diff --git a/src/Wasm/Wasm_Window.cxx b/src/Wasm/Wasm_Window.cxx index 985333b634..71e44783d7 100644 --- a/src/Wasm/Wasm_Window.cxx +++ b/src/Wasm/Wasm_Window.cxx @@ -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; }