David Zeuthen 62183e
Index: gui/greeter/greeter_item_ulist.c
David Zeuthen 62183e
===================================================================
David Zeuthen 62183e
--- gui/greeter/greeter_item_ulist.c	(revision 4626)
David Zeuthen 62183e
+++ gui/greeter/greeter_item_ulist.c	(working copy)
David Zeuthen 62183e
@@ -217,18 +217,41 @@
David Zeuthen 62183e
 void 
David Zeuthen 62183e
 greeter_item_ulist_select_user (gchar *login)
David Zeuthen 62183e
 {
David Zeuthen 62183e
-	printf ("%c%c%c%s\n", STX, BEL,
David Zeuthen 62183e
-		GDM_INTERRUPT_SELECT_USER, login);
David Zeuthen 62183e
+	/*printf ("%c%c%c%s\n", STX, BEL,
David Zeuthen 62183e
+	  GDM_INTERRUPT_SELECT_USER, login);*/
David Zeuthen 62183e
+	printf ("%c%s\n", STX, login);
David Zeuthen 62183e
 
David Zeuthen 62183e
 	fflush (stdout);
David Zeuthen 62183e
 }
David Zeuthen 62183e
 
David Zeuthen 62183e
+
David Zeuthen 62183e
+static GTimeVal last_key_press = {0, 0};
David Zeuthen 62183e
+static GTimeVal last_button_press = {0, 0};
David Zeuthen 62183e
+
David Zeuthen 62183e
 static void
David Zeuthen 62183e
 user_selected (GtkTreeSelection *selection, gpointer data)
David Zeuthen 62183e
 {
David Zeuthen 62183e
 	GtkTreeModel *tm = NULL;
David Zeuthen 62183e
 	GtkTreeIter iter = {0};
David Zeuthen 62183e
+	gboolean is_button_press;
David Zeuthen 62183e
+	guint64 button_msec;
David Zeuthen 62183e
+	guint64 key_msec;
David Zeuthen 62183e
 
David Zeuthen 62183e
+	/* HACK: determine whether selection changed because of key or
David Zeuthen 62183e
+	 * button press
David Zeuthen 62183e
+	 *
David Zeuthen 62183e
+	 * The rationale is this: if a face is pressed with the mouse
David Zeuthen 62183e
+	 * we should start authenticating that user right away. But if
David Zeuthen 62183e
+	 * the user uses keynav in the user list (think accessibility
David Zeuthen 62183e
+	 * and blind users) we shouldn't.
David Zeuthen 62183e
+	 */
David Zeuthen 62183e
+	button_msec = last_button_press.tv_sec * 1000 + last_button_press.tv_usec / 1000;
David Zeuthen 62183e
+	key_msec = last_key_press.tv_sec * 1000 + last_key_press.tv_usec / 1000;
David Zeuthen 62183e
+	is_button_press = FALSE;
David Zeuthen 62183e
+	if (button_msec > key_msec) {
David Zeuthen 62183e
+		is_button_press = TRUE;
David Zeuthen 62183e
+	}
David Zeuthen 62183e
+
David Zeuthen 62183e
 	if (gtk_tree_selection_get_selected (selection, &tm, &iter)) {
David Zeuthen 62183e
 		char *login;
David Zeuthen 62183e
 
David Zeuthen 62183e
@@ -236,14 +259,19 @@
David Zeuthen 62183e
 				    &login, -1);
David Zeuthen 62183e
 		if (login != NULL) {
David Zeuthen 62183e
 			if (selecting_user && greeter_probably_login_prompt) {
David Zeuthen 62183e
-				gtk_entry_set_text (GTK_ENTRY (pam_entry), login);
David Zeuthen 62183e
+				if (is_button_press) {
David Zeuthen 62183e
+					gtk_entry_set_text (GTK_ENTRY (pam_entry), login);
David Zeuthen 62183e
+				} else {
David Zeuthen 62183e
+					gtk_entry_set_text (GTK_ENTRY (pam_entry), "");
David Zeuthen 62183e
+				}
David Zeuthen 62183e
 			}
David Zeuthen 62183e
 			if (selecting_user) {
David Zeuthen 62183e
 				GreeterItemInfo *pamlabel = greeter_lookup_id ("pam-message");
David Zeuthen 62183e
 				if (pamlabel == NULL) {
David Zeuthen 62183e
 					gdm_common_warning ("Theme broken: must have pam-message label!");
David Zeuthen 62183e
 				}
David Zeuthen 62183e
-				greeter_item_ulist_select_user (login);
David Zeuthen 62183e
+				if (is_button_press)
David Zeuthen 62183e
+					greeter_item_ulist_select_user (login);
David Zeuthen 62183e
 				if (selected_user != NULL)
David Zeuthen 62183e
 					g_free (selected_user);
David Zeuthen 62183e
 				selected_user = g_strdup (login);
David Zeuthen 62183e
@@ -253,11 +281,28 @@
David Zeuthen 62183e
 }
David Zeuthen 62183e
 
David Zeuthen 62183e
 static void
David Zeuthen 62183e
-browser_change_focus (GtkWidget *widget, GdkEventButton *event, gpointer data)
David Zeuthen 62183e
+row_activated (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
David Zeuthen 62183e
 {
David Zeuthen 62183e
-	gtk_widget_grab_focus (pam_entry);
David Zeuthen 62183e
+	if (selecting_user && greeter_probably_login_prompt) {
David Zeuthen 62183e
+		greeter_item_ulist_select_user (selected_user);
David Zeuthen 62183e
+	}
David Zeuthen 62183e
 }
David Zeuthen 62183e
 
David Zeuthen 62183e
+static gboolean
David Zeuthen 62183e
+tv_key_press (GtkWidget *entry, GdkEventKey *event, gpointer data)
David Zeuthen 62183e
+{
David Zeuthen 62183e
+	g_get_current_time (&last_key_press);
David Zeuthen 62183e
+	return FALSE;
David Zeuthen 62183e
+}
David Zeuthen 62183e
+
David Zeuthen 62183e
+
David Zeuthen 62183e
+static gboolean
David Zeuthen 62183e
+tv_button_press (GtkWidget *entry, GdkEventKey *event, gpointer data)
David Zeuthen 62183e
+{
David Zeuthen 62183e
+	g_get_current_time (&last_button_press);
David Zeuthen 62183e
+	return FALSE;
David Zeuthen 62183e
+}
David Zeuthen 62183e
+
David Zeuthen 62183e
 static void
David Zeuthen 62183e
 greeter_generate_userlist (GtkWidget *tv)
David Zeuthen 62183e
 {
David Zeuthen 62183e
@@ -267,6 +312,12 @@
David Zeuthen 62183e
 	GreeterItemInfo *info;
David Zeuthen 62183e
 	GList *list, *li;
David Zeuthen 62183e
 
David Zeuthen 62183e
+	AtkObject *atk_widget;
David Zeuthen 62183e
+	atk_widget = gtk_widget_get_accessible (tv);
David Zeuthen 62183e
+	if (atk_widget != NULL) {
David Zeuthen 62183e
+		atk_object_set_name (atk_widget, _("Select user to log in"));
David Zeuthen 62183e
+	}
David Zeuthen 62183e
+
David Zeuthen 62183e
 	gdm_greeter_users_init ();
David Zeuthen 62183e
 
David Zeuthen 62183e
 	check_for_displays ();
David Zeuthen 62183e
@@ -279,11 +330,14 @@
David Zeuthen 62183e
 		g_signal_connect (selection, "changed",
David Zeuthen 62183e
 				  G_CALLBACK (user_selected),
David Zeuthen 62183e
 				  NULL);
David Zeuthen 62183e
-
David Zeuthen 62183e
-		g_signal_connect (GTK_TREE_VIEW (tv), "button_release_event",
David Zeuthen 62183e
-				  G_CALLBACK (browser_change_focus),
David Zeuthen 62183e
+		g_signal_connect (G_OBJECT (tv), "row-activated",
David Zeuthen 62183e
+				  G_CALLBACK (row_activated),
David Zeuthen 62183e
 				  NULL);
David Zeuthen 62183e
+		g_signal_connect (G_OBJECT (tv), "key-press-event",
David Zeuthen 62183e
+				  G_CALLBACK (tv_key_press), user_list);
David Zeuthen 62183e
+		g_signal_connect (G_OBJECT (tv), "button-press-event",
David Zeuthen 62183e
+				  G_CALLBACK (tv_button_press), user_list);
David Zeuthen 62183e
 
David Zeuthen 62183e
 		tm = (GtkTreeModel *)gtk_list_store_new (4,
David Zeuthen 62183e
 							 GDK_TYPE_PIXBUF,
David Zeuthen 62183e
 
David Zeuthen 62183e
Index: gui/greeter/greeter_item_pam.c
David Zeuthen 62183e
===================================================================
David Zeuthen 62183e
--- gui/greeter/greeter_item_pam.c	(revision 4626)
David Zeuthen 62183e
+++ gui/greeter/greeter_item_pam.c	(working copy)
David Zeuthen 62183e
@@ -184,14 +184,6 @@
David Zeuthen 62183e
        const char *login_string;
David Zeuthen 62183e
 	GtkWidget *entry = GNOME_CANVAS_WIDGET (entry_info->item)->widget;
David Zeuthen 62183e
 
David Zeuthen 62183e
-       if ((event->keyval == GDK_Tab ||
David Zeuthen 62183e
-            event->keyval == GDK_KP_Tab) &&
David Zeuthen 62183e
-           (event->state & (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SHIFT_MASK)) == 0)
David Zeuthen 62183e
-          {
David Zeuthen 62183e
-		greeter_item_pam_login (GTK_ENTRY (entry), entry_info);
David Zeuthen 62183e
-		return TRUE;
David Zeuthen 62183e
-           }
David Zeuthen 62183e
-
David Zeuthen 62183e
        if (gtk_ok_button != NULL)
David Zeuthen 62183e
           {
David Zeuthen 62183e
              /*
David Zeuthen 62183e
@@ -208,6 +200,19 @@
David Zeuthen 62183e
   return FALSE;
David Zeuthen 62183e
 }
David Zeuthen 62183e
 
David Zeuthen 62183e
+/* We *never* want to lose focus when we are in the process of
David Zeuthen 62183e
+ * authenticating the user */
David Zeuthen 62183e
+static gboolean 
David Zeuthen 62183e
+pam_focus_out_event (GtkWidget     *widget,
David Zeuthen 62183e
+		     GdkEventFocus *event,
David Zeuthen 62183e
+		     gpointer       user_data)
David Zeuthen 62183e
+{
David Zeuthen 62183e
+	if (!greeter_probably_login_prompt) {
David Zeuthen 62183e
+		gtk_widget_grab_focus (widget);
David Zeuthen 62183e
+	}
David Zeuthen 62183e
+	return FALSE;
David Zeuthen 62183e
+}
David Zeuthen 62183e
+
David Zeuthen 62183e
 gboolean
David Zeuthen 62183e
 greeter_item_pam_setup (void)
David Zeuthen 62183e
 {
David Zeuthen 62183e
@@ -238,7 +243,9 @@
David Zeuthen 62183e
       g_signal_connect (entry, "activate",
David Zeuthen 62183e
 			G_CALLBACK (greeter_item_pam_login), entry_info);
David Zeuthen 62183e
       g_signal_connect (G_OBJECT (entry), "key_release_event",
David Zeuthen 62183e
-		        G_CALLBACK (pam_key_release_event), NULL);
David Zeuthen 62183e
+			G_CALLBACK (pam_key_release_event), NULL);
David Zeuthen 62183e
+      g_signal_connect (G_OBJECT (entry), "focus-out-event",
David Zeuthen 62183e
+			G_CALLBACK (pam_focus_out_event), NULL);
David Zeuthen 62183e
     }
David Zeuthen 62183e
 
David Zeuthen 62183e
   return TRUE;
David Zeuthen 62183e
@@ -260,6 +267,21 @@
David Zeuthen 62183e
   if (conversation_info)
David Zeuthen 62183e
     {
David Zeuthen 62183e
       set_text (conversation_info, message);
David Zeuthen 62183e
+
David Zeuthen 62183e
+      if (entry_info != NULL) {
David Zeuthen 62183e
+	      GnomeCanvasWidget *item = GNOME_CANVAS_WIDGET (entry_info->item);
David Zeuthen 62183e
+	      if (item != NULL) {
David Zeuthen 62183e
+		      GtkWidget *widget = item->widget;
David Zeuthen 62183e
+		      if (widget != NULL) {
David Zeuthen 62183e
+			      AtkObject *atk_widget;
David Zeuthen 62183e
+			      atk_widget = gtk_widget_get_accessible (widget);
David Zeuthen 62183e
+			      if (atk_widget != NULL) {
David Zeuthen 62183e
+				      atk_object_set_name (atk_widget, message);
David Zeuthen 62183e
+			      }
David Zeuthen 62183e
+		      }
David Zeuthen 62183e
+	      }
David Zeuthen 62183e
+      }
David Zeuthen 62183e
+
David Zeuthen 62183e
     }
David Zeuthen 62183e
   
David Zeuthen 62183e
   if (entry_info && entry_info->item &&
David Zeuthen 62183e