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

Win32: Prevent calling of GetClientRect each frame. #8353

Closed
wants to merge 1 commit into from

Conversation

sneakyevil
Copy link
Contributor

I don't understand why this exist in NewFrame function for years as this is wasted api call overhead.
There is windows procedure message that tells to the window that it was resized as mentioned here: https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-size
This pull request just simply moves the function that exist in NewFrame function to initialization function and implements the WM_SIZE message handler to get window size from lParam as described at the Microsoft docs.

@ocornut
Copy link
Owner

ocornut commented Jan 28, 2025

years as this is wasted api call overhead.

Sorry but afaik unless i am missing out on some bizarre edge case, this is going to be hard if not impossible to measure, and certainly not meaningful. I see no value making that change.

@PathogenDavid
Copy link
Contributor

WM_SIZE is also just a convenience message sent by the DefWindowProc for WM_WINDOWPOSCHANGED, so this PR creates problems for those who use it instead.

@sneakyevil
Copy link
Contributor Author

years as this is wasted api call overhead.

Sorry but afaik unless i am missing out on some bizarre edge case, this is going to be hard if not impossible to measure, and certainly not meaningful. I see no value making that change.

Yeah it's not really about that it would do any big performance impact, but I feel like it's kind of weird to call it each frame just to obtain same data when windows provide proper way to retrieve the message when window size has been changed. It would be same scenario as calling GetAsyncKeyState winapi just to obtain all keys data instead using WM_KEYDOWN and WM_KEYUP messages.

@ocornut
Copy link
Owner

ocornut commented Jan 28, 2025

It would be same scenario as calling GetAsyncKeyState winapi just to obtain all keys data instead using WM_KEYDOWN and WM_KEYUP messages.

Doing so we would actually miss fast events happening during a slow frame, which is not desired. Whereas intermediate resize events are of no values to us. So it’s a little different.

I’m not saying your change is wrong per-se, but it brings no added value. There’s now two locations setting io.DisplaySize, code is less linear, and it also means that newcomers who forget to call the WndProc handler - which is a frequent mistake by new users - would get visual issues rather than just missing inputs events. For that alone it doesn’t seem like a good tradeoff.

@ocornut ocornut closed this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants