slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 601 forks source link

Live-Preview steals focus at unexpected time #2414

Closed tronical closed 9 months ago

tronical commented 1 year ago

Try the following sequence:

  1. Open examples/energy-monitor in a new VS Code window.
  2. Open desktop_window.slint.
  3. Place the cursor on the MidMain element use.
  4. Choose "Goto Definition" (shortcut or context menu)
  5. Press cursor down -> VS Code looses the focus and a preview window pops up.

It is very annoying and unexpected that the focus is lost when pressing "Cursor down".

Screencast to show the bug - note how the cursor disappears at the end of the clip:

https://user-images.githubusercontent.com/1486/227930563-104be107-efa0-45ae-ad00-13a0d698a49f.mov

tronical commented 1 year ago

I can't reproduce this on Linux or Windows. This seems macOS specific, perhaps winit related.

ogoffart commented 1 year ago

I bet this happens when the preview is reloaded (and the preview is reloaded because we open a new file so the text editor send that file to the LSP)

I wonder what's the value of post_load_behavior in https://github.com/slint-ui/slint/blob/053b990f2a5fb4de5cb93d28ed7796128fd3228e/tools/lsp/preview.rs#L318-L320

tronical commented 9 months ago

It still happens that these steps reproduce a slint preview window showing up in the macOS doc (i.e. preview is triggered), but the focus is not transferred anymore. That was the biggest annoying bug and the reason for this ticket. As it doesn't happen anymore, let's close it.