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

The "SDL_WindowsMessageHook" is not called during resizing the window. #12029

Closed
flowCRANE opened this issue Jan 20, 2025 · 3 comments · Fixed by #12033
Closed

The "SDL_WindowsMessageHook" is not called during resizing the window. #12029

flowCRANE opened this issue Jan 20, 2025 · 3 comments · Fixed by #12033
Assignees
Milestone

Comments

@flowCRANE
Copy link

flowCRANE commented Jan 20, 2025

I need to implement the ability to change the window size using the mouse in my project, ensuring that its proportions match the proportions of the game frame.

In SDL2, it was enough to watch system events and if it was about the WM_SIZING message, you could modify the window area given in lParam in the message structure. Everything worked fine, I tested it and even posted the solution on the forum.

SDL3, however, no longer supports system events, and instead we can register a message hook, using the SDL_SetWindowsMessageHook function. This way we can watch and manipulate system messages before they are processed by SDL. So I can catch the WM_SIZING message in this callback, modify the window size/position, and then SDL will use that message to generate an SDL_EVENT_WINDOW_RESIZED event.

The problem, however, is that when resizing the window with the mouse, the hook callback is not called at all. I checked under the debugger and the hook callback is called for all window messages, but not when resizing the window with the mouse:

Image

I don't know why when resizing a window with the mouse, the hook callback is not called, but it should be so that the application can watch all system messages and react to them.


Just in case, if it matters, I have three callbacks registered in my project:

  1. Hit-test callback — using the SDL_SetWindowHitTest function, to be able to handle borderless window with custom decoration.
  2. Message hook — using the SDL_SetWindowsMessageHook function, to be able to control the window size/position when resizing the window using the mouse.
  3. Event watcher — using the SDL_AddEventWatch function, to be able to re-render the game window during resizing the window with the mouse.
@slouken
Copy link
Collaborator

slouken commented Jan 20, 2025

@flowCRANE, can you try out #12033 and see if it works for you?

@flowCRANE
Copy link
Author

Yes, now the callback is called in a modal loop, thanks for the fix!

@slouken
Copy link
Collaborator

slouken commented Jan 21, 2025

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants