static gboolean
st_im_text_key_release_event (ClutterActor    *actor,
                              ClutterKeyEvent *event)
{
  StIMText *self = ST_IM_TEXT (actor);
  StIMTextPrivate *priv = self->priv;
  ClutterText *clutter_text = CLUTTER_TEXT (actor);
  GdkEventKey *event_gdk;
  gboolean result = FALSE;

  if (clutter_text_get_editable (clutter_text))
    {
      event_gdk = key_event_to_gdk (event);

      if (gtk_im_context_filter_keypress (priv->im_context, event_gdk))
        {
          priv->need_im_reset = TRUE;
          result = TRUE;
        }

      gdk_event_free ((GdkEvent *)event_gdk);
    }

  if (!result &&
      CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->key_release_event)
    result = CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->key_release_event (actor, event);

  return result;
}
Esempio n. 2
0
static void
st_im_text_paint (ClutterActor *actor)
{
  StIMText *self = ST_IM_TEXT (actor);
  ClutterText *clutter_text = CLUTTER_TEXT (actor);

  /* This updates the cursor position as a side-effect */
  if (CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->paint)
    CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->paint (actor);

  if (clutter_text_get_editable (clutter_text))
    update_im_cursor_location (self);
}
Esempio n. 3
0
static void
st_im_text_commit_cb (GtkIMContext *context,
                      const gchar  *str,
                      StIMText     *imtext)
{
  ClutterText *clutter_text = CLUTTER_TEXT (imtext);

  if (clutter_text_get_editable (clutter_text))
    {
      clutter_text_delete_selection (clutter_text);
      clutter_text_insert_text (clutter_text, str,
                                clutter_text_get_cursor_position (clutter_text));
    }
}
Esempio n. 4
0
static void
st_im_text_key_focus_out (ClutterActor *actor)
{
  StIMTextPrivate *priv = ST_IM_TEXT (actor)->priv;
  ClutterText *clutter_text = CLUTTER_TEXT (actor);

  if (clutter_text_get_editable (clutter_text))
    {
      priv->need_im_reset = TRUE;
      gtk_im_context_focus_out (priv->im_context);
    }

  if (CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->key_focus_out)
    CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->key_focus_out (actor);
}
Esempio n. 5
0
static gboolean
st_im_text_delete_surrounding_cb (GtkIMContext *context,
                                  gint          offset,
                                  gint          n_chars,
                                  StIMText     *imtext)
{
  ClutterText *clutter_text = CLUTTER_TEXT (imtext);

  if (clutter_text_get_editable (clutter_text))
    {
      gint cursor_pos = clutter_text_get_cursor_position (clutter_text);
      clutter_text_delete_text (clutter_text,
                                cursor_pos + offset,
                                cursor_pos + offset + n_chars);
    }

  return TRUE;
}
Esempio n. 6
0
static gboolean
st_im_text_captured_event (ClutterActor *actor,
                           ClutterEvent *event)
{
  StIMText *self = ST_IM_TEXT (actor);
  StIMTextPrivate *priv = self->priv;
  ClutterText *clutter_text = CLUTTER_TEXT (actor);
  ClutterEventType type = clutter_event_type (event);
  gboolean result = FALSE;
  int old_position;

  if (type != CLUTTER_KEY_PRESS && type != CLUTTER_KEY_RELEASE)
    return FALSE;

  if (clutter_text_get_editable (clutter_text))
    {
      GdkEventKey *event_gdk = key_event_to_gdk ((ClutterKeyEvent *)event);

      if (gtk_im_context_filter_keypress (priv->im_context, event_gdk))
        {
          priv->need_im_reset = TRUE;
          result = TRUE;
        }

      gdk_event_free ((GdkEvent *)event_gdk);
    }

  old_position = clutter_text_get_cursor_position (clutter_text);

  if (!result &&
      CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->captured_event)
    result = CLUTTER_ACTOR_CLASS (st_im_text_parent_class)->captured_event (actor, event);

  if (type == CLUTTER_KEY_PRESS &&
      clutter_text_get_cursor_position (clutter_text) != old_position)
    reset_im_context (self);

  return result;
}