Add IBUS_IGNORED_MASK and IBUS_HANDLED_MASK.

This commit is contained in:
Peng Huang 2009-04-15 07:48:06 +08:00
Родитель 44fe663295
Коммит 590bb3a899
4 изменённых файлов: 41 добавлений и 12 удалений

Просмотреть файл

@ -190,33 +190,44 @@ _key_snooper_cb (GtkWidget *widget,
IBusIMContext *ibusimcontext;
ibusimcontext = (IBusIMContext *) _focus_im_context;
if (!_use_key_snooper)
if (G_UNLIKELY (!_use_key_snooper))
return retval;
if (ibusimcontext == NULL)
return retval;
return FALSE;
if (ibusimcontext->ibuscontext == NULL || ibusimcontext->has_focus == FALSE)
return retval;
if (G_UNLIKELY (ibusimcontext->ibuscontext == NULL || ibusimcontext->has_focus == FALSE))
return FALSE;
if (G_UNLIKELY (event->state & IBUS_HANDLED_MASK))
return TRUE;
if (G_UNLIKELY (event->state & IBUS_IGNORED_MASK))
return FALSE;
switch (event->type) {
case GDK_KEY_RELEASE:
retval = ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
event->keyval,
event->state | IBUS_RELEASE_MASK);
event->state |= IBUS_FORWARD_MASK;
break;
case GDK_KEY_PRESS:
retval = ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
event->keyval,
event->state);
event->state |= IBUS_FORWARD_MASK;
break;
default:
retval = FALSE;
break;
}
if (retval) {
event->state |= IBUS_HANDLED_MASK;
}
else {
event->state |= IBUS_IGNORED_MASK;
}
return retval;
}
@ -386,11 +397,18 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
IBusIMContext *ibusimcontext = (IBusIMContext *) context;
if (ibusimcontext->ibuscontext && ibusimcontext->has_focus) {
if (G_LIKELY (ibusimcontext->ibuscontext && ibusimcontext->has_focus)) {
/* If context does not have focus, ibus will process key event in sync mode.
* It is a workaround for increase search in treeview.
*/
gboolean retval;
gboolean retval = FALSE;
if (event->state & IBUS_HANDLED_MASK)
return TRUE;
if (event->state & IBUS_IGNORED_MASK)
return gtk_im_context_filter_keypress (ibusimcontext->slave, event);
switch (event->type) {
case GDK_KEY_RELEASE:
retval = ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
@ -407,9 +425,13 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
}
if (retval) {
event->state |= IBUS_HANDLED_MASK;
return TRUE;
}
return gtk_im_context_filter_keypress (ibusimcontext->slave, event);
else {
event->state |= IBUS_IGNORED_MASK;
return gtk_im_context_filter_keypress (ibusimcontext->slave, event);
}
}
else {
return gtk_im_context_filter_keypress (ibusimcontext->slave, event);

Просмотреть файл

@ -110,7 +110,9 @@ ibus_modifier_type_get_type (void)
{ IBUS_BUTTON3_MASK, "IBUS_BUTTON3_MASK", "button3-mask" },
{ IBUS_BUTTON4_MASK, "IBUS_BUTTON4_MASK", "button4-mask" },
{ IBUS_BUTTON5_MASK, "IBUS_BUTTON5_MASK", "button5-mask" },
{ IBUS_HANDLED_MASK, "IBUS_HANDLED_MASK", "handled-mask" },
{ IBUS_FORWARD_MASK, "IBUS_FORWARD_MASK", "forward-mask" },
{ IBUS_IGNORED_MASK, "IBUS_IGNORED_MASK", "ignored-mask" },
{ IBUS_SUPER_MASK, "IBUS_SUPER_MASK", "super-mask" },
{ IBUS_HYPER_MASK, "IBUS_HYPER_MASK", "hyper-mask" },
{ IBUS_META_MASK, "IBUS_META_MASK", "meta-mask" },

Просмотреть файл

@ -553,7 +553,10 @@ ibus_input_context_process_key_event (IBusInputContext *context,
IBusError *error = NULL;
gboolean retval;
if (state & IBUS_FORWARD_MASK)
if (state & IBUS_HANDLED_MASK)
return TRUE;
if (state & IBUS_IGNORED_MASK)
return FALSE;
retval = ibus_proxy_call_with_reply ((IBusProxy *) context,

Просмотреть файл

@ -69,11 +69,13 @@ typedef enum
IBUS_BUTTON5_MASK = 1 << 12,
/* The next few modifiers are used by XKB, so we skip to the end.
* Bits 15 - 24 are currently unused. Bit 29 is used internally.
* Bits 15 - 23 are currently unused. Bit 29 is used internally.
*/
/* forward mask */
/* ibus mask */
IBUS_HANDLED_MASK = 1 << 24,
IBUS_FORWARD_MASK = 1 << 25,
IBUS_IGNORED_MASK = IBUS_FORWARD_MASK,
IBUS_SUPER_MASK = 1 << 26,
IBUS_HYPER_MASK = 1 << 27,