gint offset_from_cursor,
guint nchars,
IBusIMContext *context);
-static void _request_surrounding_text (IBusIMContext *context,
- gboolean force);
+static void _request_surrounding_text (IBusIMContext *context);
static void _create_fake_input_context (void);
/* emit "retrieve-surrounding" glib signal of GtkIMContext, if
* context->caps has IBUS_CAP_SURROUNDING_TEXT and the current IBus
* engine needs surrounding-text.
- *
- * if "force" is TRUE, emit the signal regardless of whether the
- * engine needs surrounding-text.
*/
static void
-_request_surrounding_text (IBusIMContext *context, gboolean force)
+_request_surrounding_text (IBusIMContext *context)
{
if (context && context->enable &&
(context->caps & IBUS_CAP_SURROUNDING_TEXT) != 0 &&
- (force ||
- ibus_input_context_needs_surrounding_text (context->ibuscontext))) {
+ ibus_input_context_needs_surrounding_text (context->ibuscontext)) {
gboolean return_value;
IDEBUG ("requesting surrounding text");
g_signal_emit (context, _signal_retrieve_surrounding_id, 0,
} while (0);
if (ibusimcontext != NULL) {
- _request_surrounding_text (ibusimcontext, FALSE);
+ _request_surrounding_text (ibusimcontext);
ibusimcontext->time = event->time;
}
if (ibusimcontext->client_window == NULL && event->window != NULL)
gtk_im_context_set_client_window ((GtkIMContext *)ibusimcontext, event->window);
- _request_surrounding_text (ibusimcontext, FALSE);
+ _request_surrounding_text (ibusimcontext);
if (ibusimcontext != NULL) {
ibusimcontext->time = event->time;
/* retrieve the initial surrounding-text (regardless of whether
* the current IBus engine needs surrounding-text) */
- _request_surrounding_text (ibusimcontext, TRUE);
+ _request_surrounding_text (ibusimcontext);
g_object_add_weak_pointer ((GObject *) context,
(gpointer *) &_focus_im_context);
g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text);
- _request_surrounding_text (ibusimcontext, FALSE);
+ _request_surrounding_text (ibusimcontext);
}
static gboolean
g_signal_emit (ibusimcontext, _signal_preedit_start_id, 0);
g_signal_emit (ibusimcontext, _signal_preedit_changed_id, 0);
- _request_surrounding_text (ibusimcontext, FALSE);
+ _request_surrounding_text (ibusimcontext);
}
static void
/* retrieve the initial surrounding-text (regardless of whether
* the current IBus engine needs surrounding-text) */
- _request_surrounding_text (ibusimcontext, TRUE);
+ _request_surrounding_text (ibusimcontext);
}
static void
IBusEnginePrivate *priv;
g_return_if_fail (IBUS_IS_ENGINE (engine));
- g_return_if_fail (text != NULL);
- g_return_if_fail (cursor_pos != NULL);
+ g_return_if_fail ((text != NULL && cursor_pos != NULL) ||
+ (text == NULL && cursor_pos == NULL));
priv = IBUS_ENGINE_GET_PRIVATE (engine);
- *text = g_object_ref (priv->surrounding_text);
- *cursor_pos = priv->surrounding_cursor_pos;
+ if (text && cursor_pos) {
+ *text = g_object_ref (priv->surrounding_text);
+ *cursor_pos = priv->surrounding_cursor_pos;
+ }
/* tell the client that this engine will utilize surrounding-text
* feature, which causes periodical update. Note that the client
/**
* ibus_engine_get_surrounding_text:
* @engine: An IBusEngine.
- * @text: Location to store surrounding text.
- * @cursor_pos: Cursor position in characters in @text.
+ * @text: (allow-none): Location to store surrounding text.
+ * @cursor_pos: (allow-none): Cursor position in characters in @text.
*
* Get surrounding text.
*
+ * It is also used to tell the input-context that the engine will
+ * utilize surrounding-text. In that case, it must be called in
+ * #IBusEngine::enable handler, with both @text and @cursor set to
+ * %NULL.
+ *
* @see_also #IBusEngine::set-surrounding-text
*/
void ibus_engine_get_surrounding_text(IBusEngine *engine,