JetBrains: Force the popup into persistent mode and manually detect clicks into the main IDE window
Created by: philipp-spiess
Closes #34969 (closed)
Note: @madppiper and me have been looking into #34969 today. This PR is a potential workaround (I wanted to persist this idea until after the long weekend). This is not intended to be merged like this.
We noticed that the default JBPopup implementation has a "persisted" mode which, when enabled, uses a different implementation for the popup. One that is intended to stay active for longer.
In this PR we create a popup with this mode so that there is no automatic handling for deactivating the popup enabled at all (hats off to @madppiper for discovering this).
With this behavior, we need to manually add the triggers for hiding the popover. We have already done this for esc
and there is currently only one second closing method that we want: Closing when the IDE window behind the popup is clicked.
I've taken a very stupid and hacky attempt at doing this in this PR. It's a hack built on top of another hack and is likely causing more headache in the long-run, but it also unblocks the problem to some extend
I also already discovered an issue with this method: When the focus inside the project jumps to another popover (e.g. when you open find everywhere), we don't have a focus event on the main window and our modal stays open. We probably instead want to add a focus handler for every window in the project (if this is possible somehow?) and detect if anything outside our popup is focused.
Test plan
Manual testing including jumping to other JetBrains project and non JetBrains applications:
https://user-images.githubusercontent.com/458591/172340419-9c927aa1-1b40-48b8-890b-7ef281baf428.mov
App preview:
Check out the client app preview documentation to learn more.