9494
9595#define ST_ENTRY_PRIV (x ) ((StEntry *) x)->priv
9696
97- static void st_entry_check_cursor_blink (StEntry * entry );
98- static void st_entry_pend_cursor_blink (StEntry * entry );
99- static void st_entry_reset_blink_time (StEntry * entry );
100-
10197struct _StEntryPrivate
10298{
10399 ClutterActor * entry ;
@@ -112,9 +108,6 @@ struct _StEntryPrivate
112108
113109 gboolean hint_visible ;
114110 gboolean capslock_warning_shown ;
115- guint blink_time ;
116- guint blink_timeout ;
117- gboolean cursor_visible ;
118111
119112 CoglPipeline * text_shadow_material ;
120113 gfloat shadow_width ;
@@ -238,12 +231,6 @@ st_entry_dispose (GObject *object)
238231
239232 cogl_clear_object (& priv -> text_shadow_material );
240233
241- if (priv -> blink_timeout )
242- {
243- g_source_remove (priv -> blink_timeout );
244- priv -> blink_timeout = 0 ;
245- }
246-
247234 seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
248235 keymap = clutter_seat_get_keymap (seat );
249236 g_signal_handlers_disconnect_by_func (keymap , keymap_state_changed , entry );
@@ -523,183 +510,6 @@ st_entry_allocate (ClutterActor *actor,
523510 clutter_actor_allocate (priv -> entry , & child_box , flags );
524511}
525512
526- #define CURSOR_ON_MULTIPLIER 2
527- #define CURSOR_OFF_MULTIPLIER 1
528- #define CURSOR_PEND_MULTIPLIER 3
529- #define CURSOR_DIVIDER 3
530-
531- static gboolean
532- cursor_blinks (StEntry * entry )
533- {
534- StEntryPrivate * priv = entry -> priv ;
535-
536- return FALSE;
537-
538- if (clutter_actor_has_key_focus (CLUTTER_ACTOR (priv -> entry )) &&
539- clutter_text_get_editable (CLUTTER_TEXT (priv -> entry )) &&
540- clutter_text_get_selection_bound (CLUTTER_TEXT (priv -> entry )) == clutter_text_get_cursor_position (CLUTTER_TEXT (priv -> entry )))
541- {
542- gboolean blink ;
543- g_object_get (gtk_settings_get_default (), "gtk-cursor-blink" , & blink , NULL );
544-
545- return blink ;
546- }
547- else
548- return FALSE;
549- }
550-
551- static gint
552- get_cursor_time (StEntry * entry )
553- {
554- gint time ;
555- g_object_get (gtk_settings_get_default (), "gtk-cursor-blink-time" , & time , NULL );
556-
557- return time ;
558- }
559-
560- static gint
561- get_cursor_blink_timeout (StEntry * entry )
562- {
563- gint timeout ;
564- g_object_get (gtk_settings_get_default (), "gtk-cursor-blink-timeout" , & timeout , NULL );
565-
566- return timeout ;
567- }
568-
569- static void
570- show_cursor (StEntry * entry )
571- {
572- StEntryPrivate * priv = entry -> priv ;
573-
574- if (!priv -> cursor_visible )
575- {
576- priv -> cursor_visible = TRUE;
577- clutter_text_set_cursor_visible (CLUTTER_TEXT (priv -> entry ), TRUE);
578- }
579- }
580-
581- static void
582- hide_cursor (StEntry * entry )
583- {
584- StEntryPrivate * priv = entry -> priv ;
585-
586- if (priv -> cursor_visible )
587- {
588- priv -> cursor_visible = FALSE;
589- clutter_text_set_cursor_visible (CLUTTER_TEXT (priv -> entry ), FALSE);
590- }
591- }
592-
593- /*
594- * Blink!
595- */
596- static gint
597- blink_cb (gpointer data )
598- {
599- StEntry * entry ;
600- StEntryPrivate * priv ;
601- guint blink_timeout ;
602-
603- entry = ST_ENTRY (data );
604- priv = entry -> priv ;
605-
606- if (!clutter_actor_has_key_focus (priv -> entry ))
607- {
608- g_warning ("StEntry - did not receive key-focus-out event. If you\n"
609- "connect a handler to this signal, it must return\n"
610- "FALSE so the StEntry gets the event as well" );
611-
612- st_entry_check_cursor_blink (entry );
613-
614- return FALSE;
615- }
616-
617- if (clutter_text_get_selection_bound (CLUTTER_TEXT (priv -> entry )) != clutter_text_get_cursor_position (CLUTTER_TEXT (priv -> entry )))
618- {
619- st_entry_check_cursor_blink (entry );
620- return FALSE;
621- }
622-
623- blink_timeout = get_cursor_blink_timeout (entry );
624- if (priv -> blink_time > 1000 * blink_timeout &&
625- blink_timeout < G_MAXINT /1000 )
626- {
627- /* we've blinked enough without the user doing anything, stop blinking */
628- show_cursor (entry );
629- priv -> blink_timeout = 0 ;
630- }
631- else if (priv -> cursor_visible )
632- {
633- hide_cursor (entry );
634- priv -> blink_timeout = clutter_threads_add_timeout (get_cursor_time (entry ) * CURSOR_OFF_MULTIPLIER / CURSOR_DIVIDER ,
635- blink_cb ,
636- entry );
637- }
638- else
639- {
640- show_cursor (entry );
641- priv -> blink_time += get_cursor_time (entry );
642- priv -> blink_timeout = clutter_threads_add_timeout (get_cursor_time (entry ) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER ,
643- blink_cb ,
644- entry );
645- }
646-
647- /* Remove ourselves */
648- return FALSE;
649- }
650-
651- static void
652- st_entry_check_cursor_blink (StEntry * entry )
653- {
654- StEntryPrivate * priv = entry -> priv ;
655-
656- if (cursor_blinks (entry ))
657- {
658- if (!priv -> blink_timeout )
659- {
660- show_cursor (entry );
661- priv -> blink_timeout = clutter_threads_add_timeout (get_cursor_time (entry ) * CURSOR_ON_MULTIPLIER / CURSOR_DIVIDER ,
662- blink_cb ,
663- entry );
664- }
665- }
666- else
667- {
668- if (priv -> blink_timeout )
669- {
670- g_source_remove (priv -> blink_timeout );
671- priv -> blink_timeout = 0 ;
672- }
673-
674- show_cursor (entry );
675- }
676- }
677-
678- static void
679- st_entry_pend_cursor_blink (StEntry * entry )
680- {
681- StEntryPrivate * priv = entry -> priv ;
682-
683- if (cursor_blinks (entry ))
684- {
685- if (priv -> blink_timeout != 0 )
686- g_source_remove (priv -> blink_timeout );
687-
688- priv -> blink_timeout = clutter_threads_add_timeout (get_cursor_time (entry ) * CURSOR_PEND_MULTIPLIER / CURSOR_DIVIDER ,
689- blink_cb ,
690- entry );
691- show_cursor (entry );
692- }
693- }
694-
695- static void
696- st_entry_reset_blink_time (StEntry * entry )
697- {
698- StEntryPrivate * priv = entry -> priv ;
699-
700- priv -> blink_time = 0 ;
701- }
702-
703513static void
704514clutter_text_focus_in_cb (ClutterText * text ,
705515 ClutterActor * actor )
@@ -716,9 +526,7 @@ clutter_text_focus_in_cb (ClutterText *text,
716526 G_CALLBACK (keymap_state_changed ), entry );
717527
718528 st_widget_add_style_pseudo_class (ST_WIDGET (actor ), "focus" );
719-
720- st_entry_reset_blink_time (entry );
721- st_entry_check_cursor_blink (entry );
529+ clutter_text_set_cursor_visible (text , TRUE);
722530}
723531
724532static void
@@ -730,8 +538,8 @@ clutter_text_focus_out_cb (ClutterText *text,
730538 ClutterSeat * seat ;
731539
732540 st_widget_remove_style_pseudo_class (ST_WIDGET (actor ), "focus" );
541+ clutter_text_set_cursor_visible (text , FALSE);
733542
734- st_entry_check_cursor_blink (entry );
735543 remove_capslock_feedback (entry );
736544
737545 seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
@@ -750,24 +558,6 @@ clutter_text_password_char_cb (GObject *object,
750558 remove_capslock_feedback (entry );
751559}
752560
753- static void
754- clutter_text_selection_bound_cb (GObject * object ,
755- GParamSpec * pspec ,
756- gpointer user_data )
757- {
758- StEntry * entry = ST_ENTRY (user_data );
759-
760- st_entry_reset_blink_time (entry );
761- st_entry_pend_cursor_blink (entry );
762- }
763-
764- static void
765- clutter_text_cursor_changed (ClutterText * text , ClutterActor * actor )
766- {
767- st_entry_reset_blink_time (ST_ENTRY (actor ));
768- st_entry_pend_cursor_blink (ST_ENTRY (actor ));
769- }
770-
771561static void
772562clutter_text_changed_cb (GObject * object ,
773563 GParamSpec * pspec ,
@@ -846,9 +636,6 @@ st_entry_key_press_event (ClutterActor *actor,
846636{
847637 StEntryPrivate * priv = ST_ENTRY_PRIV (actor );
848638
849- st_entry_reset_blink_time (ST_ENTRY (actor ));
850- st_entry_pend_cursor_blink (ST_ENTRY (actor ));
851-
852639 /* This is expected to handle events that were emitted for the inner
853640 ClutterText. They only reach this function if the ClutterText
854641 didn't handle them */
@@ -1111,12 +898,6 @@ st_entry_init (StEntry *entry)
1111898 g_signal_connect (priv -> entry , "button-press-event" ,
1112899 G_CALLBACK (clutter_text_button_press_event ), entry );
1113900
1114- g_signal_connect (priv -> entry , "notify::selection-bound" ,
1115- G_CALLBACK (clutter_text_selection_bound_cb ), entry );
1116-
1117- g_signal_connect (priv -> entry , "cursor-changed" ,
1118- G_CALLBACK (clutter_text_cursor_changed ), entry );
1119-
1120901 g_signal_connect (priv -> entry , "notify::text" ,
1121902 G_CALLBACK (clutter_text_changed_cb ), entry );
1122903
@@ -1130,9 +911,6 @@ st_entry_init (StEntry *entry)
1130911 clutter_actor_set_reactive ((ClutterActor * ) entry , TRUE);
1131912
1132913 /* set cursor hidden until we receive focus */
1133- priv -> blink_timeout = 0 ;
1134- priv -> blink_time = 0 ;
1135- priv -> cursor_visible = FALSE;
1136914 clutter_text_set_cursor_visible ((ClutterText * ) priv -> entry , FALSE);
1137915}
1138916
0 commit comments