mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
text: Only paint cursor if we have key focus
If a Text actor does not have key focus then there's no point in showing the cursor at all.
This commit is contained in:
parent
ec5e910cd3
commit
605e8d6fb5
@ -146,6 +146,7 @@ struct _ClutterTextPrivate
|
||||
guint cursor_color_set : 1;
|
||||
guint preedit_set : 1;
|
||||
guint is_default_font : 1;
|
||||
guint has_focus : 1;
|
||||
|
||||
/* current cursor position */
|
||||
gint position;
|
||||
@ -1903,7 +1904,8 @@ clutter_text_paint (ClutterActor *self)
|
||||
|
||||
priv->text_x = text_x;
|
||||
|
||||
cursor_paint (text);
|
||||
if (priv->has_focus)
|
||||
cursor_paint (text);
|
||||
|
||||
real_opacity = clutter_actor_get_paint_opacity (self)
|
||||
* priv->text_color.alpha
|
||||
@ -2067,6 +2069,26 @@ clutter_text_allocate (ClutterActor *self,
|
||||
parent_class->allocate (self, box, flags);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_key_focus_in (ClutterActor *actor)
|
||||
{
|
||||
ClutterTextPrivate *priv = CLUTTER_TEXT (actor)->priv;
|
||||
|
||||
priv->has_focus = TRUE;
|
||||
|
||||
clutter_actor_queue_redraw (actor);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_key_focus_out (ClutterActor *actor)
|
||||
{
|
||||
ClutterTextPrivate *priv = CLUTTER_TEXT (actor)->priv;
|
||||
|
||||
priv->has_focus = FALSE;
|
||||
|
||||
clutter_actor_queue_redraw (actor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_text_real_move_left (ClutterText *self,
|
||||
const gchar *action,
|
||||
@ -2515,6 +2537,8 @@ clutter_text_class_init (ClutterTextClass *klass)
|
||||
actor_class->button_press_event = clutter_text_button_press;
|
||||
actor_class->button_release_event = clutter_text_button_release;
|
||||
actor_class->motion_event = clutter_text_motion;
|
||||
actor_class->key_focus_in = clutter_text_key_focus_in;
|
||||
actor_class->key_focus_out = clutter_text_key_focus_out;
|
||||
|
||||
/**
|
||||
* ClutterText:font-name:
|
||||
|
Loading…
Reference in New Issue
Block a user