Bug 492064 - The LSP plugin's popup box disappears almost immediately when it loses focus, even if the cursor never had time to enter the box
Summary: The LSP plugin's popup box disappears almost immediately when it loses focus,...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 24.08.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-23 05:07 UTC by Adam Fontenot
Modified: 2024-09-26 16:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
recording of issue with widget closing fix (622.20 KB, video/webm)
2024-09-26 15:15 UTC, Adam Fontenot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Fontenot 2024-08-23 05:07:59 UTC
SUMMARY

I use focus follows mouse (mouse precedence). Most popups in KDE work fine with this. The popups created by the LSP plugin, however, disappear when after a mouse movement, the mouse is hovering over the Kate window. This is very hard to avoid because the popups are actually created a slight distance away from the cursor, meaning that to click or scroll on them you have to move the cursor quickly over the Kate window hoping to get to the popup before the "hover" is registered.

I have focus stealing prevention set to "extreme".

STEPS TO REPRODUCE
1. Hover over a symbol in an LSP client supported file to get the popup box for it.
2. Move the cursor.

OBSERVED RESULT

See summary.

EXPECTED RESULT

When a popup for a window appears, the window shouldn't steal focus from it. The popup should only be closed on a click or when the window is actually focused, e.g. by moving the cursor to another window and then back. 

This problem used to apply to e.g. Plasma applets, but I haven't had any issue with those in a long time now. Mostly hover-to-focus just works as expected.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.5-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 1 Waqar Ahmed 2024-08-23 08:58:16 UTC
> The popup should only be closed on a click or when the window is actually focused, e.g. by moving the cursor to another window and then back. 

Yeah, not sure that is a good idea. But perhaps we should increase the timeout for hiding the popup a bit.

Also, you can invoke the popup manually via context menu, that one is more persistent, LSPClient -> Symbol info. In the future, there will be a separate panel  at the bottom which will show the contents of hover (currently a wip)
Comment 2 Bug Janitor Service 2024-08-23 09:03:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1563
Comment 3 Adam Fontenot 2024-08-23 11:53:10 UTC
(In reply to Waqar Ahmed from comment #1)
> > The popup should only be closed on a click or when the window is actually focused, e.g. by moving the cursor to another window and then back. 
> 
> Yeah, not sure that is a good idea. But perhaps we should increase the
> timeout for hiding the popup a bit.

One thought I had was that you could set a variable timeout - if the cursor is within a certain small distance of the box, only hide it after 1s or 1.5s. This would help deal with the fact that the margins on the box are really tight and it's very easy to go slightly outside it. Your change of 100ms to 300ms will help with that, but it feels more appropriate in the case when the user has *definitely* left the box, not when the cursor ventures 10 pixels outside it.

Also, I think it would be a *major* QoL improvement to check whether the cursor is hovering over the *same* symbol as triggered the popup box, both at the beginning of the hover (when we start the timer) and at the end (when we close the box). If the user has their finger on a trackpad and just barely moved it after activating the popup, Kate LSP will close and then immediately reopen the box! By checking whether the same symbol as before is the hover target, we can avoid that. It's the little details that make the difference.

When I wrote this bug report I tested it without hover to focus, and I felt that the behavior was much better - but trying it now I'm not sure at all that that's the case. So the whole premise of this bug report (that hover to focus is the source of the problem) may be a mistake, and in that case of course my suggestion of changing the behavior to only deactivate the box when leaving the window would be incorrect!
Comment 4 Waqar Ahmed 2024-09-26 05:20:14 UTC
Git commit f7520e77ed40b618d5913636bec480f7fec64530 by Waqar Ahmed.
Committed on 26/09/2024 at 05:00.
Pushed by waqar into branch 'master'.

Dont hide the tooltip if cursor is moving towards the tooltip

It can be hard to reach the tooltip sometimes as the time limit is 100ms.

M  +25   -1    apps/lib/texthint/tooltip.cpp

https://invent.kde.org/utilities/kate/-/commit/f7520e77ed40b618d5913636bec480f7fec64530
Comment 5 Adam Fontenot 2024-09-26 15:15:55 UTC
Created attachment 174111 [details]
recording of issue with widget closing fix

Reopening this because the commit doesn't seem to work consistently as expected. It sort of works sometimes but you can see frequent cases in the attached screen recording where the cursor is moving toward the box and it then closes and immediately reopens.
Comment 6 Bug Janitor Service 2024-09-26 16:37:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1595
Comment 7 Waqar Ahmed 2024-09-26 16:54:28 UTC
Git commit 72270894a672b3e09b53b4d8cc67f3582771a714 by Waqar Ahmed.
Committed on 26/09/2024 at 16:54.
Pushed by waqar into branch 'master'.

tooltip: Dont hide if hovering over the same word

... otherwise hide immediately

M  +14   -1    apps/lib/texthint/KateTextHintManager.cpp
M  +2    -0    apps/lib/texthint/KateTextHintManager.h
M  +21   -28   apps/lib/texthint/tooltip.cpp
M  +2    -1    apps/lib/texthint/tooltip.h

https://invent.kde.org/utilities/kate/-/commit/72270894a672b3e09b53b4d8cc67f3582771a714