Initial support for ibus input from chansrv

This commit is contained in:
matt335672 2024-03-25 10:35:58 +00:00 committed by sefler
parent 67ace5c59d
commit 20b90c1098
7 changed files with 87 additions and 0 deletions

View File

@ -164,6 +164,10 @@ AC_ARG_ENABLE(mp3lame, AS_HELP_STRING([--enable-mp3lame],
[Build lame mp3(audio codec) (default: no)]),
[], [enable_mp3lame=no])
AM_CONDITIONAL(XRDP_MP3LAME, [test x$enable_mp3lame = xyes])
AC_ARG_ENABLE(ibus, AS_HELP_STRING([--enable-ibus],
[Allow unicode input via IBus) (default: no)]),
[], [enable_ibus=no])
AM_CONDITIONAL(XRDP_IBUS, [test x$enable_ibus = xyes])
AC_ARG_ENABLE(pixman, AS_HELP_STRING([--enable-pixman],
[Use pixman library (default: no)]),
[], [enable_pixman=no])
@ -472,6 +476,13 @@ then
[AC_MSG_ERROR([please install libmp3lame-dev or lamemp3-devel])])
fi
# checking for ibus includes
if test "x$enable_ibus" = "xyes"
then
PKG_CHECK_MODULES([IBUS], [ibus-1.0 >= 1.5], [],
[AC_MSG_ERROR([please install libibus-1.0-dev or ibus-devel])])
fi
AS_IF( [test "x$enable_pixman" = "xyes"] , [PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.1.0)] )
# checking for TurboJPEG
@ -646,6 +657,7 @@ echo " fuse $enable_fuse"
echo " ipv6 $enable_ipv6"
echo " ipv6only $enable_ipv6only"
echo " vsock $enable_vsock"
echo " ibus $enable_ibus"
echo " auth mechanism $auth_mech"
echo " rdpsndaudin $enable_rdpsndaudin"
echo " utmp support $enable_utmp"

View File

@ -38,6 +38,11 @@ if XRDP_RDPSNDAUDIN
AM_CPPFLAGS += -DXRDP_RDPSNDAUDIN
endif
if XRDP_IBUS
AM_CPPFLAGS += -DXRDP_IBUS $(IBUS_CFLAGS)
CHANSRV_EXTRA_LIBS += $(IBUS_LIBS)
endif
AM_CFLAGS = $(X_CFLAGS)
sbin_PROGRAMS = \

View File

@ -823,6 +823,31 @@ chansrv_drdynvc_send_data(int chan_id, const char *data, int data_bytes)
return 0;
}
/*****************************************************************************/
#ifdef XRDP_IBUS
static int
process_message_unicode_key_press(struct stream *s)
{
int rv = 0;
int key_down;
char32_t unicode_char;
LOG_DEVEL(LOG_LEVEL_DEBUG, "process_message_unicode_keypress:");
if (!s_check_rem(s, 8))
{
rv = 1;
}
else
{
in_uint32_le(s, key_down);
in_uint32_le(s, unicode_char);
LOG(LOG_LEVEL_INFO, "Unicode char 0x%08x received down=%d",
unicode_char, key_down);
}
return rv;
}
#endif // XRDP_IBUS
/*****************************************************************************/
/* returns error */
static int
@ -875,6 +900,11 @@ process_message(void)
case 19: /* drdynvc data */
rv = process_message_drdynvc_data(s);
break;
#ifdef XRDP_IBUS
case 21: /* Unicode key press */
rv = process_message_unicode_key_press(s);
break;
#endif
default:
LOG_DEVEL(LOG_LEVEL_ERROR, "process_message: unknown msg %d", id);
break;

View File

@ -38,6 +38,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/libpainter/include
XRDP_EXTRA_LIBS += $(top_builddir)/libpainter/src/.libs/libpainter.a
endif
if XRDP_IBUS
AM_CPPFLAGS += -DXRDP_IBUS
endif
sbin_PROGRAMS = \
xrdp

View File

@ -483,6 +483,10 @@ xrdp_mm_suppress_output(struct xrdp_mm *self, int suppress,
int left, int top, int right, int bottom);
int
xrdp_mm_up_and_running(struct xrdp_mm *self);
int
xrdp_mm_send_unicode_to_chansrv(struct xrdp_mm *self,
int key_down,
char32_t unicode);
struct xrdp_mm *
xrdp_mm_create(struct xrdp_wm *owner);
void

View File

@ -2103,6 +2103,26 @@ xrdp_mm_up_and_running(struct xrdp_mm *self)
return 0;
}
/******************************************************************************/
int
xrdp_mm_send_unicode_to_chansrv(struct xrdp_mm *self,
int key_down,
char32_t unicode)
{
struct stream *s = trans_get_out_s(self->chan_trans, 8192);
if (s == NULL)
{
return 1;
}
out_uint32_le(s, 0); /* version */
out_uint32_le(s, 8 + 4 + 4 + 4);
out_uint32_le(s, 21); /* msg id */
out_uint32_le(s, key_down);
out_uint32_le(s, unicode);
s_mark_end(s);
return trans_write_copy(self->chan_trans);
}
/*****************************************************************************/
/* open response from client going to channel server */
static int

View File

@ -1678,6 +1678,18 @@ xrdp_wm_key_sync(struct xrdp_wm *self, int device_flags, int key_flags)
static int
xrdp_wm_key_unicode(struct xrdp_wm *self, int device_flags, char32_t unicode)
{
#ifdef XRDP_IBUS
// Test code for ibus Unicode forwarding
if (self->mm->chan_trans != NULL &&
self->mm->chan_trans->status == TRANS_STATUS_UP)
{
xrdp_mm_send_unicode_to_chansrv(self->mm,
(device_flags & KBD_FLAG_UP) == 0,
unicode);
return 0;
}
#endif
int index;
for (index = XR_MIN_KEY_CODE; index < XR_MAX_KEY_CODE; index++)