Skip to content

Commit

Permalink
code refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
seflerZ committed Apr 17, 2024
1 parent c46d89e commit 301d579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions sesman/chansrv/chansrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ process_message_unicode_data(struct stream *s)
{
int rv = 0;
int key_down;
uint32_t unicode;
char32_t unicode;

LOG_DEVEL(LOG_LEVEL_DEBUG, "process_message_unicode_keypress:");
if (!s_check_rem(s, 8))
Expand Down Expand Up @@ -870,7 +870,7 @@ process_message_unicode_shutdown(struct stream *s)
{
return xrdp_input_unicode_destory();
}
#endif // XRDP_IBUS
#endif

/*****************************************************************************/
/* returns error */
Expand Down
18 changes: 9 additions & 9 deletions sesman/chansrv/input_ibus.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
static IBusBus *bus;
static IBusEngine *g_engine;
/* This is the engine name enabled before unicode engine enabled */
static const gchar *ori_name;
static const gchar *last_input_name;
static int id = 0;

int
Expand All @@ -40,7 +40,7 @@ xrdp_input_enable()
IBusEngineDesc *desc;
const gchar *name;

if (ori_name)
if (last_input_name)
{
/* already enabled */
return 0;
Expand All @@ -60,21 +60,21 @@ xrdp_input_enable()
}

/* remember user's input method, will switch back when disconnect */
ori_name = name;
last_input_name = name;

if (!ibus_bus_set_global_engine(bus, "XrdpIme"))
{
LOG(LOG_LEVEL_ERROR, "xrdp_input_enable: input method enable failed");
return 1;
}

LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: input method switched sucessfully, old input name: %s", ori_name);
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: input method switched sucessfully, old input name: %s", last_input_name);

return 0;
}

int
xrdp_input_send_unicode(uint32_t unicode)
xrdp_input_send_unicode(char32_t unicode)
{
LOG(LOG_LEVEL_DEBUG, "xrdp_input_send_unicode: received unicode input %i", unicode);

Expand Down Expand Up @@ -194,16 +194,16 @@ int
xrdp_input_unicode_destory()
{
LOG(LOG_LEVEL_DEBUG, "xrdp_input_unicode_destory: ibus input is under destory");
if (ori_name)
if (last_input_name)
{
LOG(LOG_LEVEL_INFO, "xrdp_input_unicode_destory: ibus engine rolling back to origin: %s", ori_name);
ibus_bus_set_global_engine(bus, ori_name);
LOG(LOG_LEVEL_INFO, "xrdp_input_unicode_destory: ibus engine rolling back to origin: %s", last_input_name);
ibus_bus_set_global_engine(bus, last_input_name);
}

g_object_unref(g_engine);
g_object_unref(bus);

ori_name = NULL;
last_input_name = NULL;
bus = NULL;
g_engine = NULL;

Expand Down

0 comments on commit 301d579

Please sign in to comment.