imgui-rs icon indicating copy to clipboard operation
imgui-rs copied to clipboard

Cursor blinked on window borders

Open coolit opened this issue 6 years ago • 4 comments

Running examples on win10 64. Thanks.

coolit avatar Oct 20 '19 09:10 coolit

I think I might understand what @coolit was trying to say.

Let's say you hover your mouse over the top border of a window. Windows will set the cursor to ResizeNS:

Every frame, you are supposed to call WinitPlatform::prepare_render. That function sets the cursor again, back to Arrow. End result is, the cursor will flicker to ResizeNS but immediately go back to Arrow. This makes it look like imgui is "fighting" with Windows about what the cursor should be.

I can repro this in the gfx hello_world example:

cd imgui-gfx-examples
cargo run --example hello_world

My proposed fix: inside prepare_render, only set the cursor if the mouse position is inside the client area of the window. (as opposed to the non-client area, which is the title bar and window borders)

whatisaphone avatar Feb 26 '20 02:02 whatisaphone

Reproduces for us too. Going to try the fix suggested above in our vendored version of imgui-winit-support (don't ask 🙈).

If it pans out well, I am happy to send a PR with the change to imgui-rs as well. @Gekkio ?

yanchith avatar Mar 30 '20 21:03 yanchith

Don't call prepare_render unless the mouse cursor has changed.

https://github.com/Yatekii/imgui-wgpu-rs/blob/85fe1e4e66d057b174ab3023b79a91c8f50f28f2/examples/hello_world.rs#L203-L206

aloucks avatar Apr 03 '20 23:04 aloucks

Don't call prepare_render unless the mouse cursor has changed.

If that's the case, perhaps the docs should be updated with info when is it valid to call prepare_render? Currently they say "every frame".

yanchith avatar Apr 06 '20 12:04 yanchith