Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Peru-S
Copy link

@Peru-S Peru-S commented Jul 29, 2025

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.

  • Verified on Windows - message pump is stable with this fix (once I was able to repro this issue).

Peru-S added 2 commits July 29, 2025 12:53
**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).
Copilot AI review requested due to automatic review settings July 29, 2025 20:01
@Peru-S Peru-S requested a review from elmindreda as a code owner July 29, 2025 20:01
@Peru-S Peru-S changed the title Fix windowProc not working when SetPropW() fails silently [Win32] Fix windowProc not working when SetPropW() fails silently Jul 29, 2025
Copy link

Copilot AI left a 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 windowProc to search the global window list when GetPropW fails
  • Improves error handling by checking SetPropW return 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

@dougbinks dougbinks added bug Bug reports and bugfix pull requests Windows Win32 specific (not Cygwin or WSL) labels Aug 13, 2025
@dougbinks
Copy link
Contributor

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.

@dougbinks dougbinks self-requested a review August 13, 2025 08:45
@dougbinks dougbinks self-assigned this Aug 13, 2025
@Peru-S
Copy link
Author

Peru-S commented Aug 13, 2025

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug reports and bugfix pull requests Windows Win32 specific (not Cygwin or WSL)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants