godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix caret can disappear from script editor

Open Hilderin opened this issue 1 year ago • 0 comments

Fixes #92821 Also probably fixes #92634 but did not find a way to reproduce more than once.

This was not easy to reproduce! To reproduce I did Alt-Tab while resizing the editor windows. And even then, it takes multiple retries to reproduce the problem.

I’m pretty certain that the problem came from a situation where a new SetTimer was called before the timer was actually triggered resulting in a situation where activate_timer_id and move_timer_id had the same timer_id. Both SetTimer for activate_timer_id and move_timer_id had the same nIDEvent, so the second SetTimer replaced the first timer.

Documentation for SetTimer from Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-settimer image

With some debug print line, we can see that the activate timer can in some situations be created before the resize is triggered: image

I did 2 modifications:

  • Changed the nIDEvent for activate_timer_id to 2.
  • When WM_ACTIVATE is received but activate_timer_id != 0, a new SetTimer is created anyway, replacing the first one. That should prevent the weird case where activate_timer_id was never triggered and resetted.

Hilderin avatar Jul 05 '24 15:07 Hilderin