fuhsjr00 / bug.n

Tiling Window Manager for Windows
GNU General Public License v3.0
3.35k stars 212 forks source link

Mouse trapping with electron apps #191

Open weichensw opened 5 years ago

weichensw commented 5 years ago

Thanks for the amazing work.

I recently found on latest version of Windows 10, with electron apps (Atom, Visual Studio Code, Hyper Terminal) the app could constantly send redraw event (wParam 6), causing bug.n keep trying to activate the window thus trapping the mouse to the center of the window.

Here's a part of the log when this happens:

2018-09-24 12:06:40 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:40 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:40 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:40 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:40 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:41 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:41 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:41 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:41 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0x1860390 )
2018-09-24 12:06:41 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:41 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:41 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:41 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0x1860390 )
2018-09-24 12:06:42 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:42 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:42 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:42 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0x1860390 )
2018-09-24 12:06:42 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:42 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:42 DEBUG[1] Activating window: 0x1a056a
2018-09-24 12:06:43 DEBUG[2] Manager_onShellMessage( wParam: 6, lParam: 0xe120a )
2018-09-24 12:06:43 DEBUG[1] Manager_onShellMessage: Manager_monitorCount: 2, Manager_aMonitor: 2, m: 2, aWndId: 0x1a056a
2018-09-24 12:06:43 DEBUG[1] Activating window: 0x1a056a
joten commented 5 years ago

The only thing, I can suggest, is setting the following Conifg.ini variable: Config_mouseFollowsFocus=0 (default is 1).

weichensw commented 5 years ago

Hi @joten thanks for the swift reply.

Will ignore wParam: 6 in onShellMessage be a viable solution? I tried on my local doesn't seem to break anything. But I don't know what other scenarios that wParam: 6 will be useful.

I wonder if a rule based wParam handling will be feasible, like "for Chrome_Widget_1 ignore wParam 6".

joten commented 5 years ago

From the initial research regarding shell events with wParam = 6 should be tracked; but this was based on Windows 7 and perhaps Windows 10 is more reliable and predictable.

Rule based wParam handling is an interesting idea, but way of the current functionality. Therefor it would need a lot of work and an overhaul of the shell message handling. -- I am currently not up to it.

weichensw commented 5 years ago

Could you give some details on the initial research of wParam = 6?

joten commented 5 years ago

Well, that was ten years ago, no systematic documentation exists; the different parts were developed in the course of debugging different applications regarding compatibility. I tried to untie the knot of shell message handling in bug.n at one time, but failed. It would need a rewrite and modularization, I think; I uploaded some code into the "X" branch, but currently have no time to work on it.