-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[Win32] Fix windowProc not working when SetPropW() fails silently #2749
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
base: master
Are you sure you want to change the base?
Conversation
**Issue** In some cases, on Windows, `SetPropW` returns `FALSE`. glfw currently silently ignores the result. This means that the message pump `windowProc` fails to work (does not receive keyboard events for example). Drawing is fine though as it's a different GLFW mechanism. I had this failure frequently infrequently and it was frustrating to deal with (just have to rerun the program a few times and hope `SetPropW` doesn't return `FALSE`). So sending this fix in case others are facing the issue on Windows. **Fix** On Windows+GLFW, `windowProc` will fallback to looking up the GLFW window list (just like `PollEvents` does). Also added the error code to `_glfwInputError` message to aid debugging in the future. My suggestion is to get rid of `SetPropW`/`GetPropW` as it is a string-based Windows API (slow/fragile) - we already have the lightweight linked list, might as well just use it always - also it's usually just the one or two windows we deal with. - [x] Verified on Windows - message pump is stable with this fix (once I was able to repro this issue).
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.
Pull Request Overview
This PR fixes a Windows-specific bug where SetPropW() sometimes fails silently, causing the window message pump to lose keyboard event handling. The fix implements a fallback mechanism to look up windows using the existing global window list when property lookup fails.
- Adds fallback logic in
windowProcto search the global window list whenGetPropWfails - Improves error handling by checking
SetPropWreturn value and adding detailed error codes to diagnostic messages - Updates changelog and contributors list to document the fix
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/win32_window.c | Implements fallback window lookup mechanism and improved SetPropW error handling |
| src/win32_init.c | Enhances error reporting with detailed error codes |
| README.md | Documents the bugfix in changelog |
| CONTRIBUTORS.md | Adds contributor credit |
|
This PR has Copilot added as a reviewer. I can't seem to remove it, so I'm guessing you've added it as a reviewer. Could you remove it as it is confusing the PR with AI slop. |
|
Apparently I have this setting enabled for myself automatically? Sorry about that! I have disabled it, but I couldn't actually remove the robot from this review (isn't that like some Asimov rule)? Hopefully it won't add more comments... |
Issue
In some cases, on Windows,
SetPropWreturnsFALSE.glfw currently silently ignores the result.
This means that the message pump
windowProcfails to work (does not receive keyboard events for example). Drawing is fine though as it's a different GLFW mechanism.I had this failure frequently infrequently and it was frustrating to deal with (just have to rerun the program a few times and hope
SetPropWdoesn't returnFALSE). So sending this fix in case others are facing the issue on Windows.Fix
On Windows+GLFW,
windowProcwill fallback to looking up the GLFW window list (just likePollEventsdoes).Also added the error code to
_glfwInputErrormessage to aid debugging in the future.My suggestion is to get rid of
SetPropW/GetPropWas it is a string-based Windows API (slow/fragile) - we already have the lightweight linked list, might as well just use it always - also it's usually just the one or two windows we deal with.