G_DEFINE_TYPE (BusInputContext, bus_input_context, IBUS_TYPE_SERVICE)
-static inline gboolean is_embed_preedit_text(){
- BusIBusImpl * ibusimpl = BUS_DEFAULT_IBUS;
- return ibusimpl->embed_preedit_text;
-}
-
-#define IS_CLIENT_CAPABLE_PREEDIT(context) \
- ((context->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT)
-
-#define IS_CLIENT_FORCE_PREEDIT(context) \
- (IS_CLIENT_CAPABLE_PREEDIT(context) && (context->capabilities & IBUS_CAP_FOCUS) == 0)
+/* when send preedit to client */
+#define PREEDIT_CONDITION \
+ ((context->capabilities & IBUS_CAP_PREEDIT_TEXT) && \
+ (BUS_DEFAULT_IBUS->embed_preedit_text || (context->capabilities & IBUS_CAP_FOCUS) == 0))
static void
_connection_destroy_cb (BusConnection *connection,
if (context->capabilities & IBUS_CAP_FOCUS) {
g_signal_emit (context, context_signals[FOCUS_IN], 0);
if (context->engine && context->enabled) {
- if (context->preedit_visible && !(is_embed_preedit_text() && IS_CLIENT_CAPABLE_PREEDIT(context)) && !IS_CLIENT_FORCE_PREEDIT(context)) {
+ if (context->preedit_visible && !PREEDIT_CONDITION) {
g_signal_emit (context,
context_signals[UPDATE_PREEDIT_TEXT],
0,
context->has_focus = FALSE;
if (context->capabilities & IBUS_CAP_FOCUS) {
- if (context->preedit_visible && !(is_embed_preedit_text() && IS_CLIENT_CAPABLE_PREEDIT(context)) && !IS_CLIENT_FORCE_PREEDIT(context) ) {
+ if (context->preedit_visible && !PREEDIT_CONDITION) {
g_signal_emit (context, context_signals[HIDE_PREEDIT_TEXT], 0);
}
if (context->auxiliary_visible && (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
context->preedit_cursor_pos = cursor_pos;
context->preedit_visible = visible;
- if ((is_embed_preedit_text() && IS_CLIENT_CAPABLE_PREEDIT(context)) || IS_CLIENT_FORCE_PREEDIT(context)) {
+ if (PREEDIT_CONDITION) {
bus_input_context_send_signal (context,
"UpdatePreeditText",
IBUS_TYPE_TEXT, &(context->preedit_text),
context->preedit_visible = TRUE;
- if ((is_embed_preedit_text() && IS_CLIENT_CAPABLE_PREEDIT(context)) || IS_CLIENT_FORCE_PREEDIT(context)) {
+ if (PREEDIT_CONDITION) {
bus_input_context_send_signal (context,
"ShowPreeditText",
G_TYPE_INVALID);
context->preedit_visible = FALSE;
- if (is_embed_preedit_text() && (context->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT) {
+ if (PREEDIT_CONDITION) {
bus_input_context_send_signal (context,
"HidePreeditText",
G_TYPE_INVALID);