format code

This commit is contained in:
seflerZ 2024-04-17 13:56:52 +08:00 committed by sefler
parent d4e2e0a093
commit 3b1cc551e4
4 changed files with 73 additions and 74 deletions

View File

@ -21,6 +21,10 @@
#include <config_ac.h>
#endif
#ifdef XRDP_IBUS
#include "input.h"
#endif
#include "arch.h"
#include "os_calls.h"
#include "string_calls.h"
@ -40,7 +44,6 @@
#include "chansrv_config.h"
#include "xrdp_sockets.h"
#include "audin.h"
#include "input.h"
#include "ms-rdpbcgr.h"

View File

@ -30,7 +30,7 @@
static IBusBus *bus;
static IBusEngine *g_engine;
// This is the engine name enabled before unicode engine enabled
/* This is the engine name enabled before unicode engine enabled */
static const gchar *ori_name;
static int id = 0;
@ -42,7 +42,7 @@ xrdp_input_enable()
if (ori_name)
{
// already enabled
/* already enabled */
return 0;
}
@ -59,7 +59,7 @@ xrdp_input_enable()
return 0;
}
// remember user's input method, will switch back when disconnect
/* remember user's input method, will switch back when disconnect */
ori_name = name;
if (!ibus_bus_set_global_engine(bus, "XrdpIme"))
@ -115,7 +115,7 @@ gboolean engine_process_key_event_cb(IBusEngine *engine,
guint keycode,
guint state)
{
// Pass the keyboard event to system
/* Pass the keyboard event to system */
return FALSE;
}
@ -160,14 +160,14 @@ xrdp_input_main_loop()
ibus_factory_add_engine(factory, "XrdpIme", IBUS_TYPE_ENGINE);
component = ibus_component_new("org.freedesktop.IBus.XrdpIme", // name
"Xrdp input method", // description
"1.1", // version
"MIT", // license
"seflerZ", // author
"fake_page", // homepage
"/exec/fake_path", // cmd
"xrdpime"); // text domain
component = ibus_component_new("org.freedesktop.IBus.XrdpIme", /* name */
"Xrdp input method", /* description */
"1.1", /* version */
"MIT", /* license */
"seflerZ", /* author */
"default", /* homepage */
"default", /* cmd */
"xrdpime"); /* text domain */
desc = ibus_engine_desc_new("XrdpIme",
"unicode input method for xrdp",
@ -175,8 +175,8 @@ xrdp_input_main_loop()
"unicode",
"MIT",
"seflerZ",
"fake_icon.png",
"default"); // layout
"default", /* icon */
"default"); /* layout */
ibus_component_add_engine(component, desc);
ibus_bus_register_component(bus, component);
@ -213,16 +213,15 @@ xrdp_input_unicode_destory()
int
xrdp_input_unicode_init()
{
int retry = 10;
if (bus)
{
// Already initialized, just re-enable it
/* Already initialized, just re-enable it */
xrdp_input_enable();
return 0;
}
sleep(5);
/* Wait becasue ibus daemon may not be ready in first login. Do we have a flag to avoid busy waiting? */
sleep(3);
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: Initializing the iBus engine");
ibus_init();
@ -239,20 +238,9 @@ xrdp_input_unicode_init()
tc_thread_create(xrdp_input_main_loop, NULL);
// session may not be ready, repeat until input method enabled
while (retry--)
if (!ibus_bus_get_global_engine(bus))
{
if (ibus_bus_get_global_engine(bus))
{
break;
}
sleep(1);
}
if (retry == 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: failed to connect to ibus");
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: failed to get origin global engine");
return 1;
}

View File

@ -42,8 +42,11 @@ static int
xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port);
static void
xrdp_mm_connect_sm(struct xrdp_mm *self);
#ifdef XRDP_IBUS
static int
xrdp_mm_send_unicode_shutdown(struct xrdp_mm *self, struct trans *trans);
#endif
/*****************************************************************************/
struct xrdp_mm *
@ -148,8 +151,10 @@ xrdp_mm_delete(struct xrdp_mm *self)
return;
}
#ifdef XRDP_IBUS
/* shutdown input method */
xrdp_mm_send_unicode_shutdown(self, self->chan_trans);
#endif
/* free any module stuff */
xrdp_mm_module_cleanup(self);
@ -662,7 +667,7 @@ xrdp_mm_trans_process_channel_data(struct xrdp_mm *self, struct stream *s)
return rv;
}
#ifdef XRDP_IBUS
/*****************************************************************************/
static int
xrdp_mm_send_unicode_shutdown(struct xrdp_mm *self, struct trans *trans)
@ -701,6 +706,27 @@ xrdp_mm_send_unicode_setup(struct xrdp_mm *self, struct trans *trans)
return trans_write_copy(self->chan_trans);
}
/******************************************************************************/
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, 24); /* size */
out_uint32_le(s, 23); /* msg id */
out_uint32_le(s, 16); /* size */
out_uint32_le(s, key_down);
out_uint32_le(s, unicode);
s_mark_end(s);
return trans_write_copy(self->chan_trans);
}
#endif
/*****************************************************************************/
/* returns error
process rail create window order */
@ -2147,26 +2173,6 @@ 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, 24); /* size */
out_uint32_le(s, 23); /* msg id */
out_uint32_le(s, 16); /* size */
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
@ -3034,6 +3040,7 @@ xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port)
"connect successful");
}
#ifdef XRDP_IBUS
/* if client supports unicode input, initialize the input method */
if (1)
{
@ -3049,6 +3056,7 @@ xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port)
// self->wm->client_info->unicode_input = 0;
}
}
#endif
return 0;
}