- Notifications
You must be signed in to change notification settings - Fork3.8k
Add support for keyboard grab without mouse grab (expose SDL_GetWindowKeyboardGrab)#3843
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
72fd48e tof616310Compare@illume Would you be able to give feedback on why the CI builds are still failing? I fixed the obvious problems (e.g. clang linter), but don't know what else to do now. Locally, this builds and works for me. |
illume commentedMay 10, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey, Click on the details links for the checks that are failing. There's a bunch of noise, but in there you should be able to see what is happening. https://github.com/pygame/pygame/actions/runs/4937250903/jobs/8831461651?pr=3843#step:5:327This one meansdocs/reST/ref/key.rst needs to have the docs put in there. Then running https://ci.appveyor.com/project/pygame/pygame/builds/47008471/job/el4cuexts8uj4oqqsrc_c/event.c(2255):errorC2065:'DOC_PYGAMEEVENTSETKEYBOARDGRAB':undeclaredidentifierCreatinglibrarybuild\temp.win-amd64-3.9\Release\src_c\key.cp39-win_amd64.libandobjectbuild\temp.win-amd64-3.9\Release\src_c\key.cp39-win_amd64.expGeneratingcodesrc_c/event.c(2257):errorC2065:'DOC_PYGAMEEVENTGETKEYBOARDGRAB':undeclaredidentifierFinishedgeneratingcodesrc_c/event.c(2254):errorC2099:initializerisnotaconstantFinishedgeneratingcodebuilding 'pygame.rect'extension https://github.com/pygame/pygame/actions/runs/4937250895/jobs/8831457863?pr=3843#step:3:1167src_c/event.c:2255:6:error: ‘DOC_PYGAMEEVENTSETKEYBOARDGRAB’undeclaredhere (notinafunction);didyoumean ‘DOC_PYGAMEEVENTSETGRAB’?2255 |DOC_PYGAMEEVENTSETKEYBOARDGRAB}, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |DOC_PYGAMEEVENTSETGRABsrc_c/event.c:2257:6:error: ‘DOC_PYGAMEEVENTGETKEYBOARDGRAB’undeclaredhere (notinafunction);didyoumean ‘DOC_PYGAMEEVENTGETGRAB’?2257 |DOC_PYGAMEEVENTGETKEYBOARDGRAB}, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |DOC_PYGAMEEVENTGETGRAB |
Uh oh!
There was an error while loading.Please reload this page.
@illume Ah, I see. I did not know that |
Hi again. Probably we need to add a couple more things here to finish it off.
The test needs to be marked with this: @unittest.skipIf(pygame.get_sdl_version()< (2,0,16) ,"Needs at least SDL 2.0.16") |
Hi@illume I have updated my PR with |
25451c5 tod166279CompareI cannot figure out why the test is failing. I have tried this locally: and it results in the correct @illume Could you have a look? |
I think it's because the 'dummy' video driver doesn't implement it correctly. It seems to just ignore it. So we can skip it when running under the dummy driver: @unittest.skipIf(os.environ.get("SDL_VIDEODRIVER")=="dummy","requires the SDL_VIDEODRIVER to be a non dummy value", ) |
@illume Nope, this does not work. Maybe it suffers from the same problems as the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍 thanks
Uh oh!
There was an error while loading.Please reload this page.
Currently, onlySDL_SetWindowGrab is exposed in pygame, which grabs the mouse, and, optionally, the keyboard.
In situations where you only need to grab the keyboard, always being forced to grab the mouse may be undesirable. (Atleast it is in an application I am developing).
To fix this, I am exposing theSDL_SetWindowKeyboardGrab andSDL_GetWindowKeyboardGrab methods as
pygame.event.set_keyboard_grab(bool)andpygame.event.get_keyboard_grab()in this PR.