From 89af29c27f121fd1327795b5dc781bb0a2fce5a6 Mon Sep 17 00:00:00 2001 From: Margers Date: Mon, 17 Feb 2025 09:36:11 +0000 Subject: [PATCH] No mouse up events for mouse wheel. --- packages/rtl-console/src/inc/mouse.inc | 5 +++-- packages/rtl-console/src/unix/keyboard.pp | 16 ++++++++++------ packages/rtl-console/src/win/mouse.pp | 2 ++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/rtl-console/src/inc/mouse.inc b/packages/rtl-console/src/inc/mouse.inc index ea39b57e2c..cd2dba0427 100644 --- a/packages/rtl-console/src/inc/mouse.inc +++ b/packages/rtl-console/src/inc/mouse.inc @@ -130,8 +130,9 @@ begin begin if (LastMouseEvent.Buttons=0) then MouseEvent.Action:=MouseActionDown - else - MouseEvent.Action:=MouseActionUp; + else { MouseButton4 or MouseButton5 has no Up event, weed them out } + if ((LastMouseEvent.Buttons and (MouseButton4 or MouseButton5)) = 0) then + MouseEvent.Action:=MouseActionUp; end; LastMouseEvent:=MouseEvent; end; diff --git a/packages/rtl-console/src/unix/keyboard.pp b/packages/rtl-console/src/unix/keyboard.pp index 60bd8a20e4..58a77dfbc6 100644 --- a/packages/rtl-console/src/unix/keyboard.pp +++ b/packages/rtl-console/src/unix/keyboard.pp @@ -503,11 +503,12 @@ const Action : 0; ); - procedure GenFakeReleaseEvent(MouseEvent : TMouseEvent); + procedure GenFakeReleaseEvent(var MouseEvent : TMouseEvent); begin MouseEvent.action := MouseActionUp; MouseEvent.buttons := 0; - PutMouseEvent(MouseEvent); + { fake event is to decive LastMouseEvent + PutMouseEvent(MouseEvent); do not make real event } end; procedure GenMouseEvent; @@ -650,10 +651,13 @@ const end; *) PutMouseEvent(MouseEvent); - if (MouseEvent.buttons and (8+16)) <> 0 then // 'M' escape sequence cannot map button 4&5 release, so fake one. + if (MouseEvent.buttons and (MouseButton4 or MouseButton5)) <> 0 then GenFakeReleaseEvent(MouseEvent); if NeedMouseRelease then + begin GenFakeReleaseEvent(MouseEvent); + PutMouseEvent(MouseEvent); {rxvt bug, need real event here as workaround } + end; {$ifdef DebugMouse} if MouseEvent.Action=MouseActionDown then Write(system.stderr,'Button down : ') @@ -776,11 +780,11 @@ const end; end; PutMouseEvent(MouseEvent); - if (ButtonMask and (8+16)) <> 0 then // 'M' escape sequence cannot map button 4&5 release, so fake one. + if (ButtonMask and (MouseButton4 or MouseButton5)) <> 0 then begin - MouseEvent.Action:=MouseActionUp; + MouseEvent.Action:=MouseActionUp; {to trick LastMouseEvent pretend that we have MouseActionUp event } MouseEvent.Buttons:=LastMouseEvent.Buttons and not ButtonMask; - PutMouseEvent(MouseEvent); + {PutMouseEvent(MouseEvent); do not put actual event } end; LastMouseEvent:=MouseEvent; end; diff --git a/packages/rtl-console/src/win/mouse.pp b/packages/rtl-console/src/win/mouse.pp index c44de69564..ec225c0d0f 100644 --- a/packages/rtl-console/src/win/mouse.pp +++ b/packages/rtl-console/src/win/mouse.pp @@ -104,6 +104,7 @@ procedure MouseEventHandler(var ir:INPUT_RECORD); e.buttons := e.buttons and not (MouseButton4 or MouseButton5); e.Action := MouseActionUp; LastHandlermouseEvent:=e; + { do not put actual event (fake it just for LastHandlermouseEvent) while PendingMouseEvents>=MouseEventBufSize do begin LeaveCriticalSection(ChangeMouseEvents); @@ -111,6 +112,7 @@ procedure MouseEventHandler(var ir:INPUT_RECORD); EnterCriticalSection(ChangeMouseEvents); end; PutMouseEvent(e); + } end; end; // this should be done in PutMouseEvent, now it is PM