New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input: Handling multiple surfaces for the text-input-v1 protocol implementation and imporve InputMethodRelay logic #5147
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good, though needs a clang-format for sure.
8c194a3
to
207abc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also it's still not clang-format
ted
207abc0
to
516061f
Compare
Sorry, It seems that I've picked up some bad habits from writing too much Go. |
generally lgtm, but I'll clang-format it for you cuz it still isn't, lol |
…ementation and imporve InputMethodRelay logic fixes hyprwm#2708
01f26f6
to
0772eb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot!
I've ran clang-format, rebased and fixed a few style nits. Should be gtg once tests pass.
good job👍🏻 |
* input: Handling multiple surfaces for the text-input-v1 protocol implementation and imporve InputMethodRelay logic fixes hyprwm#2708 * clang-format * minor style nits --------- Co-authored-by: Vaxry <vaxry@vaxry.net>
Describe your PR, what does it fix/add?
This PR addresses the issue where the text-input-v1 protocol could not handle cases where a client creates multiple
TextInput
.The case one client creates multiple
TextInput
is common. e.g. chromium-based client applications create aTextInput
for each separate surface. They then sendactivate
request withsurface
param which indirectly specifies theTextInput
. Because everyTextInput
object is bind to specificsurface
.Previously, the code iterated through a linked list and returned upon finding a match by comparing the current focus surface's client with
TextInput
's client. This approach always returned the first matchedTextInput
, whose internal surface pointed to a different surface rather than the current focus surface. This was the root cause of issue #2708.Moreover, the original code heavily relied on iterating through linked list is not so efficient comparing to a hash lookup way. Therefore, in the
InputMethodRelay
, a map fromsurface -> TextInput
has been established, centered around thesurface.
TheInputMethodRelay
now records the current focussurface
, enabling the retrieval ofTextInput
based on the surface. Consequently, the logic forpendingSurface
in the original code has been removed, as theTextInput
can now be obtained at any time through the focused surface.About issue #2708 mentioned
yeah it's the same problem. It seems that electron below electron 21 will create a transparent surface. So in former implementation, we always caught that transparent surface's
TextInput
.Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Firstly, I rarely write C++, so there might be some naive mistakes. Please forgive me ~. Though this patch has been running on my main computer for two days without any issues.
Secondly, there's a comment in the
InputMethodRelay.cpp
code marked "BUG POSSIBLE". This is because the logic for handling surfaces intext-input-v3
is quite different fromv1
. It requires the server to proactively inform the client. Apart from using the client for matching, I can't think of a better method. However, using the client for matching is the original code's method, so the issue mentioned for text-input-v3 still persists. But as far as the user experience with Kitty is concerned, there doesn't seem to be any major problem.Is it ready for merging, or does it need work?
yeah
test_text-input-v1.mp4