Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ibus unicode input support #3058

Merged
merged 21 commits into from
May 20, 2024
Merged

Conversation

seflerZ
Copy link
Contributor

@seflerZ seflerZ commented May 5, 2024

Close #1990 . This PR was made by me and @matt335672. It introduced serveral unicode input interfaces and has the ibus interface implemented (That means you should have ibus configured in the server side first).

The unicode input is a kind of method of sending unicode codes directly from the client to the server. With it, you can input any characters or glyphs (like Emoji 馃榿) even if they are not present in the keymap of the keyboard. It is typically used by mobile devices like Android\iOS phones, especially in Asia languages.

Another benifit of the unicode input is you can use your device's voice input to generate a bunch of texts quickly. Although we only have the ibus implemented now, it is easy to do for other input services like fcitx.

@matt335672 This is the latest rebased. Sorry I made merge before.

matt335672 and others added 18 commits May 5, 2024 10:44
Fixes a packet in the format send between xrdp and chansrv.
UTF-16 surrogate pairs sent from the client are remapped
to full unicode characters.
- xrdp is not now built with XRDP_IBUS to allow other input
  methods to be more easily supported.
- chansrv is only aked to start an input method if the client
  supports it.
- chansrv sends a status report back to xrdp when asked to start
  and input method.
- ./configure without --enable-ibus now works.
// we can use it
if ((inputFlags & INPUT_FLAG_UNICODE) != 0)
{
self->client_info.unicode_input_support = UIS_SUPPORTED;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my client, resizing the window repeatedly triggers the function xrdp_caps_process_input. The original UIS_ACTIVE state is reset to UIS_SUPPORTED, which results in subsequent failure to deliver.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @poetic-edge - that's a good spot.

The way we're currently doing client resizes involves using the RDP Deactivation-Reactivation Sequence

Can you try this patch? I've run out of time today.

--- a/libxrdp/xrdp_caps.c
+++ b/libxrdp/xrdp_caps.c
@@ -424,16 +424,23 @@ xrdp_caps_process_input(struct xrdp_rdp *self, struct stream *s,
     }
 
     // We always advertise Unicode support, so if the client supports it too,
-    // we can use it
-    if ((inputFlags & INPUT_FLAG_UNICODE) != 0)
+    // we can use it.
+    //
+    // If Unicode support is already active, the CAPSTYPE_INPUT
+    // PDU has been received as part of a Deactivation-Reactivation sequence.
+    // In this case, ignore the flag.
+    if (self->client_info.unicode_input_support != UIS_ACTIVE)
     {
-        self->client_info.unicode_input_support = UIS_SUPPORTED;
-        LOG(LOG_LEVEL_INFO, "Client supports Unicode input");
-    }
-    else
-    {
-        self->client_info.unicode_input_support = UIS_UNSUPPORTED;
-        LOG(LOG_LEVEL_INFO, "Client does not support Unicode input");
+        if ((inputFlags & INPUT_FLAG_UNICODE) != 0)
+        {
+            self->client_info.unicode_input_support = UIS_SUPPORTED;
+            LOG(LOG_LEVEL_INFO, "Client supports Unicode input");
+        }
+        else
+        {
+            self->client_info.unicode_input_support = UIS_UNSUPPORTED;
+            LOG(LOG_LEVEL_INFO, "Client does not support Unicode input");
+        }
     }
 
     return 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. It is now functioning properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll apply the patch.

@matt335672
Copy link
Member

@seflerZ - I've had a weekend break and have come back to discover a slightly fuller inbox than I was expecting. I'll got on to this as soon as I've cleared the backlog. Sorry.

@seflerZ
Copy link
Contributor Author

seflerZ commented May 9, 2024 via email

xrdp/xrdp_mm.c Outdated
@@ -2447,6 +2559,9 @@ xrdp_mm_chan_process_msg(struct xrdp_mm *self, struct trans *trans,
case 18:
rv = xrdp_mm_trans_process_drdynvc_data(self, s);
break;
case 20:
rv = xrdp_mm_trans_process_unicode_ack(self, s);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break; lost here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cactch!

@matt335672
Copy link
Member

Great to see people using this before we've merged it into devel.

@seflerZ - thanks again for driving this.

@matt335672 matt335672 merged commit 98d0003 into neutrinolabs:devel May 20, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Unicode Keyboard events in xrdp
4 participants