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

Add SDL_SetModalLoopCallback, SDL_SetModalLoopResizeCallback and SDL_SetModalLoopMoveCallback functions #4836

Closed
wants to merge 1 commit into from

Conversation

RT2Code
Copy link
Contributor

@RT2Code RT2Code commented Oct 13, 2021

Add three functions to set callbacks to be called during a window modal loop, allowing the user to keep his app running when it happens.

The message handling require more work to ensure it is robust enough and that there's no corner case left out.

Fix #1059

@RT2Code RT2Code marked this pull request as ready for review October 13, 2021 15:11
@RT2Code
Copy link
Contributor Author

RT2Code commented Oct 13, 2021

I think it is ready to be reviewed.

@MyreMylar
Copy link

Looks like this needs to be updated for 2.0.22 now since it didn't make it in for 2.0.18 or 2.0.20.

@RT2Code
Copy link
Contributor Author

RT2Code commented Jan 15, 2022

Done. 😉

include/SDL_events.h Outdated Show resolved Hide resolved
include/SDL_events.h Outdated Show resolved Hide resolved
@sezero
Copy link
Contributor

sezero commented Jun 21, 2022

Can you please rebase to current master squash into a single commit?

@slouken, @icculus: yours to review.

@hstormo
Copy link

hstormo commented Jun 22, 2022

Perhaps there should also be a callback specifically for WM_MOVE. The window enters the same modal loop when being dragged, and some applications may want to update the window contents based on the window's position on the screen as well as its size.

@RT2Code RT2Code changed the title Add SDL_SetModalLoopCallback and SDL_SetModalLoopResizeCallback functions Add SDL_SetModalLoopCallback, SDL_SetModalLoopResizeCallback and SDL_SetModalLoopMoveCallback functions Jun 24, 2022
@RT2Code
Copy link
Contributor Author

RT2Code commented Jun 24, 2022

@sezero Sure ;)

@hstormo I agree with you. I added the SDL_SetModalLoopMoveCallback function.

@tsedan
Copy link

tsedan commented Jul 19, 2022

Sorry, just checking if there's something blocking this? Would love to see this issue closed after nearly nine years 😅

@slouken
Copy link
Collaborator

slouken commented Nov 23, 2022

This is interesting, but ideally we would find a way to handle this so you don't need specialized callbacks to deal with move and resize.

Here is another thread with more info on this that I would like to research for SDL 3.0:
#1059

@slouken slouken added this to the 3.0 milestone Nov 23, 2022
@slouken slouken self-assigned this Nov 23, 2022
@RT2Code
Copy link
Contributor Author

RT2Code commented Nov 23, 2022

Fair enough, if you can implement this without the need to use callbacks, it would be perfect indeed. 😃

Should we close this PR?

@slouken
Copy link
Collaborator

slouken commented Nov 23, 2022

No, let's leave it open because it might end up being the best solution.

@slouken slouken closed this in 02f3564 Nov 8, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 8, 2023

I've added a solution that dovetails nicely with the new main callbacks in SDL 3.0.

Thanks for the example and all the feedback!

slouken added a commit that referenced this pull request Nov 8, 2023
… loop

SDL will send an SDL_EVENT_WINDOW_EXPOSED event for your window during the modal interaction and you can use an event watcher to redraw your window directly from the callback.

Fixes #1059
Closes #4836
@RT2Code RT2Code deleted the modal-loop-callback branch November 8, 2023 23:33
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 this pull request may close these issues.

Windows: main thread is blocked when user resizes or moves a window
6 participants