techartorg / bqt

A Blender add-on to support & manage Qt Widgets in Blender (PySide2)
https://github.com/techartorg/bqt/wiki
Mozilla Public License 2.0
162 stars 23 forks source link

Attempting to fix alt-tab bug in bqt #17

Closed friedererdmann closed 1 year ago

friedererdmann commented 3 years ago

Currently there is a bug in bqt, if you alt-tab out of Blender and back in, it will often perceive that the alt key is stuck. The same can happen with the shift or ctrl key (but alt-tab is the most common use-case where the bug becomes apparent).

I'm attempting a fix that catches at least some cases of this behavior by running a second operator along side the QOperator. The second operator is a regular Blender operator running modally and scanning inputs. I've also added a just_focused property on the BlenderApplication object, that we can check if - "Blender just got focused" (came back from Alt-Tab). In that case the modal operator will check if there's a keyboard event perceived and if that keyboard event contained any modifier key. We then simply send an emulated key release to the operating system.

Apparently Blender having trouble catching if any modifier keys have been released is not a new issue by bqt, but appears to be more common with bqt. E.g. see the following two older issues: https://developer.blender.org/T52905 https://developer.blender.org/T64105

hannesdelbeke commented 2 years ago

when testing this out

can i suggest to split this PR in 2 parts? ctypes & keyboard alt tab

friedererdmann commented 1 year ago

Closing this in favor of Hannes cleaned up Pull request here #23