diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-20 11:14:36 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-09-20 11:14:36 +0800 |
commit | 6789a1f6f8bb59037206f46cbeed1a5bc552b1ea (patch) | |
tree | 9a0d1d318c0394dee3e1e04d5b77114edde914ae /client | |
parent | 54c52e2f73805029cecf34c5af5e577ba5845ab8 (diff) | |
download | ibus-6789a1f6f8bb59037206f46cbeed1a5bc552b1ea.tar.gz ibus-6789a1f6f8bb59037206f46cbeed1a5bc552b1ea.tar.xz ibus-6789a1f6f8bb59037206f46cbeed1a5bc552b1ea.zip |
set_capabilities when frontend establishs ibus connection.
Diffstat (limited to 'client')
-rw-r--r-- | client/gtk2/ibusimcontext.c | 17 | ||||
-rw-r--r-- | client/qt4/ibus-input-context.cpp | 14 | ||||
-rw-r--r-- | client/qt4/ibus-input-context.h | 1 |
3 files changed, 23 insertions, 9 deletions
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index 9923c43..78f6788 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -1,4 +1,4 @@ -/* vim:set et ts=4: */ +/* vim:set et sts=4: */ /* ibus - The Input Bus * Copyright (C) 2008-2009 Huang Peng <shawn.p.huang@gmail.com> * @@ -43,6 +43,8 @@ struct _IBusIMContextPrivate { GdkRectangle cursor_area; gboolean has_focus; + + gint caps; }; static guint _signal_commit_id = 0; @@ -237,6 +239,7 @@ ibus_im_context_init (IBusIMContext *obj) priv->ic = NULL; priv->has_focus = FALSE; + priv->caps = IBUS_CAP_PREEDIT | IBUS_CAP_FOCUS; // Create slave im context @@ -499,11 +502,12 @@ ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit) if(priv->ic) { if (use_preedit) { - ibus_im_client_set_capabilities (_client, priv->ic, IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT); + priv->caps |= IBUS_CAP_PREEDIT; } else { - ibus_im_client_set_capabilities (_client, priv->ic, IBUS_CAP_FOCUS); + priv->caps &= ~IBUS_CAP_PREEDIT; } + ibus_im_client_set_capabilities (_client, priv->ic, priv->caps); } gtk_im_context_set_use_preedit (priv->slave, use_preedit); } @@ -799,8 +803,11 @@ ibus_im_context_set_ic (IBusIMContext *context, const gchar *ic) if (priv->ic == NULL) { priv->enable = FALSE; } - else if (priv->has_focus) { - ibus_im_context_focus_in (GTK_IM_CONTEXT (context)); + else { + ibus_im_client_set_capabilities (_client, priv->ic, priv->caps); + if (priv->has_focus) { + ibus_im_context_focus_in (GTK_IM_CONTEXT (context)); + } } } diff --git a/client/qt4/ibus-input-context.cpp b/client/qt4/ibus-input-context.cpp index ed06baa..869c9f3 100644 --- a/client/qt4/ibus-input-context.cpp +++ b/client/qt4/ibus-input-context.cpp @@ -33,7 +33,8 @@ IBusInputContext::IBusInputContext (QObject *parent, IBusClient *client, QString client (client), ic (ic), preedit_visible (false), - has_focus (false) + has_focus (false), + caps (IBUS_CAP_PREEDIT | IBUS_CAP_FOCUS) { } @@ -136,11 +137,12 @@ IBusInputContext::setFocusWidget (QWidget *widget) else { /* KateView can not support preedit well. */ if (widget->inherits("KateViewInternal")) { - client->setCapabilities (this, IBUS_CAP_FOCUS); + caps &= ~IBUS_CAP_PREEDIT; } else { - client->setCapabilities (this, IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT); + caps |= IBUS_CAP_PREEDIT; } + client->setCapabilities (this, caps); has_focus = true; client->focusIn (this); @@ -175,7 +177,11 @@ void IBusInputContext::setIC (QString ic) { this->ic = ic; - if (has_focus && !ic.isEmpty ()) { + if (ic.isEmpty ()) + return; + + client->setCapabilities (this, caps); + if (has_focus) { client->focusIn (this); } } diff --git a/client/qt4/ibus-input-context.h b/client/qt4/ibus-input-context.h index a17e594..01545b0 100644 --- a/client/qt4/ibus-input-context.h +++ b/client/qt4/ibus-input-context.h @@ -64,6 +64,7 @@ private: bool preedit_visible; int preedit_cursor_pos; bool has_focus; + int caps; QList <QList <quint32> > preedit_attrs; }; |