Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.389
diff -u -r1.389 gtkhtml.c
--- src/gtkhtml.c	7 May 2002 14:54:42 -0000	1.389
+++ src/gtkhtml.c	13 May 2002 14:50:59 -0000
@@ -1023,6 +1023,9 @@
 			}
 		}
 
+		if (!GTK_WIDGET_HAS_FOCUS (widget))
+			gtk_widget_grab_focus (widget);
+
 		if (HTML_DIST ((x + engine->x_offset - html->selection_x1),
 			       (y + engine->y_offset - html->selection_y1)) 
 		    > html_painter_get_space_width (engine->painter, 
@@ -1324,8 +1327,9 @@
 	html   = GTK_HTML (widget);
 	engine = html->engine;
 
-	if (event->button == 1 || ((event->button == 2 || event->button == 3)
-				   && html_engine_get_editable (engine)))
+	if ((event->button == 1 && !html->avoid_focus) ||
+	    ((event->button == 2 || event->button == 3)
+	     && html_engine_get_editable (engine)))
 		gtk_widget_grab_focus (widget);
 
 	if (event->type == GDK_BUTTON_PRESS) {
@@ -1414,11 +1418,15 @@
 	} else if (event->button == 1 && html->allow_selection) {
 		if (event->type == GDK_2BUTTON_PRESS) {
 			html->button1_pressed = FALSE;
+			if (!GTK_WIDGET_HAS_FOCUS (widget))
+				gtk_widget_grab_focus (widget);
 			gtk_html_select_word (html);
 			html->in_selection = TRUE;
 		}
 		else if (event->type == GDK_3BUTTON_PRESS) {
 			html->button1_pressed = FALSE;
+			if (!GTK_WIDGET_HAS_FOCUS (widget))
+				gtk_widget_grab_focus (widget);
 			gtk_html_select_line (html);
 			html->in_selection = TRUE;
 		}
@@ -1442,14 +1450,20 @@
 	gtk_grab_remove (widget);
 	gdk_pointer_ungrab (0);
 
+	remove_scroll_timeout (html);
+
 	if (event->button == 1) {
 		html->button1_pressed = FALSE;
 		
 		if (!html->priv->dnd_in_progress
-		    && html->pointer_url != NULL && ! html->in_selection)
+		    && html->pointer_url != NULL && ! html->in_selection) {
 			gtk_signal_emit (GTK_OBJECT (widget), 
 					 signals[LINK_CLICKED], 
 					 html->pointer_url);
+			return TRUE;
+		}
+		if (!GTK_WIDGET_HAS_FOCUS (widget))
+			gtk_widget_grab_focus (widget);
 	}
 
 	if (html->in_selection) {
@@ -1458,8 +1472,6 @@
 		gtk_html_update_styles (html);
 	}
 
-	remove_scroll_timeout (html);
-
 	return TRUE;
 }
 
@@ -2518,6 +2530,7 @@
 	html->editor_api = NULL;
 	html->debug = FALSE;
 	html->allow_selection = TRUE;
+	html->avoid_focus = FALSE;
 
 	html->pointer_url = NULL;
 	html->hand_cursor = gdk_cursor_new (GDK_HAND2);
@@ -2673,6 +2686,17 @@
 	g_return_if_fail (GTK_IS_HTML (html));
 
 	html->debug = debug;
+}
+
+
+void
+gtk_html_avoid_focus (GtkHTML *html,
+		      gboolean avoid)
+{
+	g_return_if_fail (html != NULL);
+	g_return_if_fail (GTK_IS_HTML (html));
+
+	html->avoid_focus = avoid;
 }
 
 
Index: src/gtkhtml.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.h,v
retrieving revision 1.127
diff -u -r1.127 gtkhtml.h
--- src/gtkhtml.h	26 Feb 2002 18:48:25 -0000	1.127
+++ src/gtkhtml.h	13 May 2002 14:50:59 -0000
@@ -67,6 +67,7 @@
 
 	guint debug : 1;
 	guint allow_selection : 1;
+	guint avoid_focus : 1;
 
 	guint hadj_connection;
 	guint vadj_connection;
@@ -149,6 +150,8 @@
 								   gboolean                   debug);
 
 /* Behavior.  */
+void                       gtk_html_avoid_focus                   (GtkHTML                   *html,
+								   gboolean                   avoid);
 void                       gtk_html_allow_selection               (GtkHTML                   *html,
 								   gboolean                   allow);
 void                       gtk_html_select_word                   (GtkHTML                   *html);
