Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix alt tab bug with blender qt wrapping #32

Merged
merged 8 commits into from
Oct 4, 2022

Conversation

hannesdelbeke
Copy link
Collaborator

@hannesdelbeke hannesdelbeke commented Sep 25, 2022

this PR fixes the alt-tab bug with embedding blender in QT.

build on top of @friedererdmann his PR

  • reused the focus tracking system which seems to work well.
  • reused part of the fix

new stuff:

  • added comments since this is quiet complex
  • added various fixes to get this to work on my pc:

alt tab fix with keyboard

friedererdmann did a setup to run the release alt ctrl key etc when blender gets focus.
however it checked if the event type was matching the key that was stuck.
if the alt key is stuck, i cant copy paste (ctrl-v).
however since i dont press alt, the fix event wont run.
a simple solution is to have any event type, trigger the fix event.
now when i type ctrl-v, this will run the fix once, undoing the alt key being stuck.

ensure fix stays in place when opening new scene

there was a logic issue where the focus handle did not run on a new scene.
because it piggy backed on the existing create_global_app handle. which removed itself after running once.
causing the on focus also to be removed.
solution is moving to different handle

friedererdmann and others added 2 commits September 25, 2022 20:01
Attempting to fix the Alt-Hang when Alt-Tabbing between Blender and other applications by running a modal operator that checks if the window just got focus back. If that is the case, check if Blender perceives an event containing CTRL/ALT/SHIFT and fire a release event on the keyboard. Does not catch all cases.

# Conflicts:
#	bqt/blender_applications/win32_blender_application.py
#	requirements.txt
@hannesdelbeke
Copy link
Collaborator Author

hannesdelbeke commented Sep 25, 2022

note there is some weirdness going on with order of registering handles.
blender doesn't invoke the operator if i first register bqt, then focus
but works when registering focus and then bqt.

this is the only issue i dont understand why it happens.

@hannesdelbeke
Copy link
Collaborator Author

consider to remove instantiate_application from bqt startup since it's called twice (second time doesn't do anything)
wonder if this is on purpose since as mentioned above there are weird things going on with relying on post_load default invole/execute?

@hannesdelbeke hannesdelbeke added the bug Something isn't working label Sep 25, 2022
pass all events (e.g. keypress, mouse-move, ...) to detect_keyboard
"""
# if context.area:
# context.area.tag_redraw()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@friedererdmann this was included in your code, do you know what this is for?
commented it out and doesn't seem needed

fix for when  ctrl alt tab dont work if they are the first key pressed on a blender refocus
@hannesdelbeke
Copy link
Collaborator Author

hannesdelbeke commented Sep 26, 2022

pushed a bug-fix for when the keys we release didn't work when they were the first pressed on blender refocus.
e.g. when you alt tab back in blender, and the first thing you press is ctrl-v
this resulted in just v being run, since we forced a release of ctrl

@hannesdelbeke
Copy link
Collaborator Author

this is now ready to review & merge

@hannesdelbeke
Copy link
Collaborator Author

TODO add support for windows key, has same issue as alt and ctrl etc.

@hannesdelbeke hannesdelbeke merged commit 6e8e80a into techartorg:master Oct 4, 2022
@hannesdelbeke hannesdelbeke deleted the alt-tab branch October 4, 2022 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants