Skip to content

Conversation

JktuJQ
Copy link
Contributor

@JktuJQ JktuJQ commented Jun 18, 2025

Provided documentation for most of the sdl2::video functions.

Mostly did that to resolve some uncertanties in functions purposes (grab/keyboard_grab/mouse_grab, minimize).
Apparently, grab only grabs the mouse.

SDL documentation:
when input is grabbed, the mouse is confined to the window. This function will also grab the keyboard if SDL_HINT_GRAB_KEYBOARD is set. To grab the keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab().

Since we can't set SDL_HINT_GRAB_KEYBOARD and by default it is set to 0, grab operates exactly as mouse_grab (which makes it kinda pointless).
minimize does not set the minimal size of window's client area (minimum_size), it minimizes the window to its iconic representation (without docs it would be confusing).

Looked at SDL_SetWindowData/SDL_GetWindowData ToDo.
Those functions allow to store pointer to an arbitrary data (userdata) within the window (similar to hashmap) and to access it through the window.
I don't think that it is possible to safely implement using those functions - there is simply no way to tell the exact type of value that is returned by SDL_GetWindowData.
If needed, I could remove that ToDo in further commit and maybe implement that as an unsafe API.

Two more ToDos in *_load_library functions tell to use OsStr::to_cstring() once it's stable - seems like it would never be stabilized
because, for example, Windows uses WTF-8 encoding which is considered a private implementation detail.
Seems like those ToDos might be removed as well.

Provided documentation for most of the `sdl2::video` functions.

Mostly did that to resolve some uncertanties in functions purpose (`grab`/`keyboard_grab`/`mouse_grab`, `minimize`).

Looked at `SDL_SetWindowData`/`SDL_GetWindowData` ToDo: think that those functions should be removed.
@JktuJQ
Copy link
Contributor Author

JktuJQ commented Jun 18, 2025

This is indirectly related to #1199 issue which could now be closed (set_keyboard_grab is now implemented).

Copy link
Contributor

@jagprog5 jagprog5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cobrand @antonilol Looks good to me but I want a second opinion - please approve only if ok.

@JktuJQ thanks for adding this

@jagprog5
Copy link
Contributor

@JktuJQ minor feedback: looks like you're adding an extra /// at the end. I'd prefer if it's consistent with the surrounding codebase. it doesn't really matter and this isn't a blocker

@JktuJQ
Copy link
Contributor Author

JktuJQ commented Jun 22, 2025

@JktuJQ minor feedback: looks like you're adding an extra /// at the end. I'd prefer if it's consistent with the surrounding codebase. it doesn't really matter and this isn't a blocker

Not a problem for me, will fix that

Copy link
Contributor

@antonilol antonilol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@JktuJQ
Copy link
Contributor Author

JktuJQ commented Jun 22, 2025

I think now it could be merged with the main branch

@antonilol antonilol merged commit 7cae29b into Rust-SDL2:master Jun 22, 2025
26 of 33 checks passed
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.

4 participants