issue-#211 HostPorts.Input problem

issue-#211 HostPorts.Input problem

Postby luowy » Sat Oct 16, 2021 1:35 am

Recently, BB became unstable during Drag&Drop mouse operations, after win10 automatic update,
e.g. Alt + Drag to pull attributes, BB will lose respond... This is my fixup to this problem.
Code: Select all
  VAR idle:BOOLEAN;
 PROCEDURE (rd: Rider) Input* (OUT x, y: INTEGER; OUT modifiers: SET; OUT isDown: BOOLEAN);
      VAR msg: WinApi.MSG; wnd, mw: WinApi.HANDLE; pt: WinApi.POINT; res: INTEGER; set: SET;
   BEGIN
      wnd := rd.port.wnd;         
      mw := WinApi.GetCapture(); idle:=TRUE;
      (*res := WinApi.UpdateWindow(wnd);*)  (* optional,seems to have no side effects*)
      IF WinApi.PeekMessageW(msg, mw, WinApi.WM_MOUSEFIRST, WinApi.WM_MOUSELAST, 1) # 0 THEN
         mx := (msg.lParam + 32768) MOD 65536 - 32768;
         my := msg.lParam DIV 65536;                 
         IF (mw # 0) & (wnd # mw) THEN
            pt.x := mx; pt.y := my; res := WinApi.ClientToScreen(mw, pt);
            res := WinApi.ScreenToClient(wnd, pt);
            mx := pt.x;
            my := pt.y
         END;
         mb := {};
         set := BITS(msg.wParam);
         IF WinApi.MK_LBUTTON * set # {} THEN INCL(mb, left) END;
         IF WinApi.MK_MBUTTON * set # {} THEN INCL(mb, middle) END;
         IF WinApi.MK_RBUTTON * set # {} THEN INCL(mb, right) END;
         
         IF WinApi.MK_CONTROL * set # {} THEN INCL(mb, ctrl) END;
         IF WinApi.MK_SHIFT * set # {} THEN INCL(mb, shift) END;
         IF WinApi.GetAsyncKeyState(12H) < 0 THEN INCL(mb, alt) END;
      ELSIF  (WinApi.PeekMessageW(msg, 0, WinApi.WM_TIMER, WinApi.WM_TIMER, 1) # 0)  THEN
         idle:=FALSE;
         res := WinApi.DispatchMessageW(msg)
      END;
     
      IF WinApi.GetSystemMetrics(WinApi.SM_SWAPBUTTON) # 0 THEN
         IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, right) END;
         IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, left) END
      ELSE
         IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, left) END;
         IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, right) END
      END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_MBUTTON(*4*)) >= 0 THEN EXCL(mb, middle) END;
     
      IF WinApi.GetAsyncKeyState(WinApi.VK_SHIFT) < 0 THEN mb := mb + {shift, extend} ELSE mb := mb - {shift, extend} END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_CONTROL) < 0 THEN mb := mb + {ctrl, modify} ELSE mb := mb - {ctrl, modify}END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_MENU) < 0 THEN INCL(mb, alt) ELSE EXCL(mb, alt) END;
      x := mx; y := my; modifiers := mb; isDown := mb * {left, middle, right} # {};
      IF idle & isDown THEN WinApi.Sleep(1);END;
   END Input;
Last edited by luowy on Thu Oct 21, 2021 4:41 am, edited 1 time in total.
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#211 HostPorts.Input problem

Postby luowy » Sun Oct 17, 2021 2:37 am

refined fixup, for service mode
Code: Select all
   VAR idle:BOOLEAN;
   PROCEDURE (rd: Rider) Input* (OUT x, y: INTEGER; OUT modifiers: SET; OUT isDown: BOOLEAN);
      VAR msg: WinApi.MSG; wnd, mw: WinApi.HANDLE; pt: WinApi.POINT; res: INTEGER; set: SET;
   BEGIN
      idle:=TRUE;
      wnd := rd.port.wnd;          
      mw := WinApi.GetCapture(); 
      (*res := WinApi.UpdateWindow(wnd);*)
      IF  (WinApi.PeekMessageW(msg, 0, WinApi.WM_TIMER, WinApi.WM_TIMER, 1) # 0)  THEN
         idle:=FALSE;
         res := WinApi.DispatchMessageW(msg)
      ELSIF WinApi.PeekMessageW(msg, mw, WinApi.WM_MOUSEFIRST, WinApi.WM_MOUSELAST, 1) # 0 THEN
         mx := (msg.lParam + 32768) MOD 65536 - 32768; 
         my := msg.lParam DIV 65536;                  
         IF (mw # 0) & (wnd # mw) THEN
            pt.x := mx; pt.y := my; res := WinApi.ClientToScreen(mw, pt);
            res := WinApi.ScreenToClient(wnd, pt);
            mx := pt.x;
            my := pt.y
         END;
         mb := {};
         set := BITS(msg.wParam);
         IF WinApi.MK_LBUTTON * set # {} THEN INCL(mb, left) END;
         IF WinApi.MK_MBUTTON * set # {} THEN INCL(mb, middle) END;
         IF WinApi.MK_RBUTTON * set # {} THEN INCL(mb, right) END;
         
         IF WinApi.MK_CONTROL * set # {} THEN INCL(mb, ctrl) END;
         IF WinApi.MK_SHIFT * set # {} THEN INCL(mb, shift) END;
         IF WinApi.GetAsyncKeyState(12H) < 0 THEN INCL(mb, alt) END; 
      END;
      
      IF WinApi.GetSystemMetrics(WinApi.SM_SWAPBUTTON) # 0 THEN
         IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, right) END;
         IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, left) END
      ELSE
         IF WinApi.GetAsyncKeyState(WinApi.VK_LBUTTON(*1*)) >= 0 THEN EXCL(mb, left) END;
         IF WinApi.GetAsyncKeyState(WinApi.VK_RBUTTON(*2*)) >= 0 THEN EXCL(mb, right) END
      END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_MBUTTON(*4*)) >= 0 THEN EXCL(mb, middle) END;
      
      IF WinApi.GetAsyncKeyState(WinApi.VK_SHIFT) < 0 THEN mb := mb + {shift, extend} ELSE mb := mb - {shift, extend} END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_CONTROL) < 0 THEN mb := mb + {ctrl, modify} ELSE mb := mb - {ctrl, modify}END;
      IF WinApi.GetAsyncKeyState(WinApi.VK_MENU) < 0 THEN INCL(mb, alt) ELSE EXCL(mb, alt) END;
      x := mx; y := my; modifiers := mb; isDown := mb * {left, middle, right} # {};
      IF idle & isDown THEN WinApi.Sleep(1); END;
   END Input;
      
Last edited by luowy on Thu Oct 21, 2021 4:39 am, edited 1 time in total.
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#211 HostPorts.Input problem

Postby Josef Templ » Sun Oct 17, 2021 7:10 am

@luowy: can you please describe the steps needed to produce the problem?
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#211 HostPorts.Input problem

Postby luowy » Sun Oct 17, 2021 8:43 am

Josef Templ wrote:@luowy: can you please describe the steps needed to produce the problem?

1,pc version
Microsoft Windows [VERSION 10.0.19042.1266]
2, open the BB, Write two lines of text in the StdLog window
3, pull attributes (select one line,press ALT and hold,use the left button of mouse drag the selected line to another line and release left button )
4, BB will no longer respond to the mouse
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#211 HostPorts.Input problem

Postby Zinn » Mon Oct 18, 2021 3:31 pm

I checked Luowy's patches under Linux Wine and it works fine. I have no Windows any more. There is a different behaviour in Wine. The right mouse button didn't work correctly before I apply this patch.
- Helmut
Zinn
 
Posts: 475
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main

Re: issue-#211 HostPorts.Input problem

Postby luowy » Mon Oct 18, 2021 4:30 pm

The interesting effect is the service model patch,It makes Services.Action more stable than ever,avoid the influence of mouse movements! e.g.
1, Obx->New Cube,open a new cube window, the cube keeps rolling...
2, Press the left mouse button and keep moving, Check the speed at which the cube rolls
The speed at which the cube scrolls will not be affected by the movement of the mouse! but normal mode is not.

If we use Services.Action to read the serial port, even if the user uses the mouse a lot, the reading action will be stable;
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#211 HostPorts.Input problem

Postby Zinn » Tue Oct 19, 2021 2:10 pm

Louwy, that is true. It is a big improvement.
A little supplement: In Wine using the right mouse button still not response at step 4.
- Helmut
Zinn
 
Posts: 475
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main

Re: issue-#211 HostPorts.Input problem

Postby luowy » Tue Oct 19, 2021 5:29 pm

Helmut,thanks for the test

Sorry,I'm not familiar with linux and wine, compared with win-BB, the ALT key in wine-BB has a different behavior;
1, Press ALT and hold it,
Win-BB: the right mouse button can no longer open the context menu window;
Wine-BB: the right mouse button can open the context menu window;
2, at the end of pulling attibutes, when ALT is released,
Win-BB: the menu bar released also,the right button can work again;
Wine-BB: "File" menu will be held down, the right button can't work;(you had to left click or press ALT to relase the menu)

So I think the problem lies in the ALT key of wine,but I have no idea about it;
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#211 HostPorts.Input problem

Postby Josef Templ » Tue Oct 19, 2021 6:17 pm

I cannot reproduce the problem.
I am using Win 10, 64 bit, build 19043.1237 and BlackBox 1.7.2, tested with Server mode on and off.

- Josef
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#211 HostPorts.Input problem

Postby luowy » Wed Oct 20, 2021 3:25 am

Josef Templ wrote:I cannot reproduce the problem.
I am using Win 10, 64 bit, build 19043.1237 and BlackBox 1.7.2, tested with Server mode on and off.

- Josef

Same as your system:win10 64 bit
Code: Select all
Microsoft Windows [版本 10.0.19043.1237]
But the problem still exists
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Next

Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron