Index: gtk/gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.255
diff -u -p -r1.255 gtkwindow.c
--- gtk/gtkwindow.c	7 Nov 2003 21:57:20 -0000	1.255
+++ gtk/gtkwindow.c	4 Dec 2003 20:59:47 -0000
@@ -73,6 +73,7 @@ enum {
   PROP_TYPE_HINT,
   PROP_SKIP_TASKBAR_HINT,
   PROP_SKIP_PAGER_HINT,
+  PROP_ACCEPT_FOCUS,
   PROP_DECORATED,
   PROP_GRAVITY,
   
@@ -159,6 +160,7 @@ struct _GtkWindowPrivate
   guint fullscreen_initially : 1;
   guint skips_taskbar : 1;
   guint skips_pager : 1;
+  guint accept_focus : 1;
 };
 
 static void gtk_window_class_init         (GtkWindowClass    *klass);
@@ -584,6 +586,21 @@ gtk_window_class_init (GtkWindowClass *k
                                                          G_PARAM_READWRITE));  
 
   /**
+   * GtkWindow:accept-focus-hint:
+   *
+   * Whether the window should receive input focus.
+   *
+   * Since: 2.4
+   */
+  g_object_class_install_property (gobject_class,
+				   PROP_ACCEPT_FOCUS,
+				   g_param_spec_boolean ("accept_focus",
+                                                         _("Accept focus"),
+                                                         _("TRUE if the window should receive input focus."),
+                                                         TRUE,
+                                                         G_PARAM_READWRITE));  
+
+  /**
    * GtkWindow:decorated:
    *
    * Whether the window should be decorated by the window manager.
@@ -708,6 +725,7 @@ static void
 gtk_window_init (GtkWindow *window)
 {
   GdkColormap *colormap;
+  GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
   
   GTK_WIDGET_UNSET_FLAGS (window, GTK_NO_WINDOW);
   GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
@@ -743,7 +761,9 @@ gtk_window_init (GtkWindow *window)
   window->decorated = TRUE;
   window->mnemonic_modifier = GDK_MOD1_MASK;
   window->screen = gdk_screen_get_default ();
-  
+
+  priv->accept_focus = 1;
+
   colormap = _gtk_widget_peek_colormap ();
   if (colormap)
     gtk_widget_set_colormap (GTK_WIDGET (window), colormap);
@@ -834,6 +854,10 @@ gtk_window_set_property (GObject      *o
       gtk_window_set_skip_pager_hint (window,
                                       g_value_get_boolean (value));
       break;
+    case PROP_ACCEPT_FOCUS:
+      gtk_window_set_accept_focus (window,
+				   g_value_get_boolean (value));
+      break;
     case PROP_DECORATED:
       gtk_window_set_decorated (window, g_value_get_boolean (value));
       break;
@@ -923,6 +947,10 @@ gtk_window_get_property (GObject      *o
       g_value_set_boolean (value,
                            gtk_window_get_skip_pager_hint (window));
       break;
+    case PROP_ACCEPT_FOCUS:
+      g_value_set_boolean (value,
+                           gtk_window_get_accept_focus (window));
+      break;
     case PROP_DECORATED:
       g_value_set_boolean (value, gtk_window_get_decorated (window));
       break;
@@ -2075,6 +2103,60 @@ gtk_window_get_skip_pager_hint (GtkWindo
 }
 
 /**
+ * gtk_window_set_accept_focus:
+ * @window: a #GtkWindow 
+ * @setting: %TRUE to let this window receive input focus
+ * 
+ * Windows may set a hint asking the window manager not set input
+ * focus on this window. This function toggles this hint.
+ * 
+ * Since: 2.4
+ **/
+void
+gtk_window_set_accept_focus (GtkWindow *window,
+			     gboolean   setting)
+{
+  GtkWindowPrivate *priv;
+
+  g_return_if_fail (GTK_IS_WINDOW (window));
+  
+  priv = GTK_WINDOW_GET_PRIVATE (window);
+
+  setting = setting != FALSE;
+
+  if (priv->accept_focus != setting)
+    {
+      priv->accept_focus = setting;
+      if (GTK_WIDGET_REALIZED (window))
+        gdk_window_set_accept_focus (GTK_WIDGET (window)->window,
+				     priv->accept_focus);
+      g_object_notify (G_OBJECT (window), "accept_focus");
+    }
+}
+
+/**
+ * gtk_window_get_accept_focus:
+ * @window: a #GtkWindow
+ * 
+ * Gets the value set by gtk_window_set_accept_focus().
+ * 
+ * Return value: %TRUE if window should receive input focus
+ * 
+ * Since: 2.4
+ **/
+gboolean
+gtk_window_get_accept_focus (GtkWindow *window)
+{
+  GtkWindowPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
+  
+  priv = GTK_WINDOW_GET_PRIVATE (window);
+
+  return priv->accept_focus;
+}
+
+/**
  * gtk_window_set_destroy_with_parent:
  * @window: a #GtkWindow
  * @setting: whether to destroy @window with its transient parent
@@ -3833,13 +3915,15 @@ gtk_window_realize (GtkWidget *widget)
   gdk_window_set_type_hint (widget->window, window->type_hint);
 
   if (gtk_window_get_skip_pager_hint (window))
-    {
-      g_print ("setting skip pager when realizing\n");
     gdk_window_set_skip_pager_hint (widget->window, TRUE);
-    }
 
   if (gtk_window_get_skip_taskbar_hint (window))
     gdk_window_set_skip_taskbar_hint (widget->window, TRUE);
+
+  if (gtk_window_get_accept_focus (window))
+    gdk_window_set_accept_focus (widget->window, TRUE);
+  else
+    gdk_window_set_accept_focus (widget->window, FALSE);
   
   if (window->modal)
     gdk_window_set_modal_hint (widget->window, TRUE);
Index: gtk/gtkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.h,v
retrieving revision 1.72
diff -u -p -r1.72 gtkwindow.h
--- gtk/gtkwindow.h	3 Nov 2003 19:41:03 -0000	1.72
+++ gtk/gtkwindow.h	4 Dec 2003 20:59:47 -0000
@@ -201,6 +201,9 @@ gboolean   gtk_window_get_skip_taskbar_h
 void       gtk_window_set_skip_pager_hint      (GtkWindow           *window,
                                                 gboolean             setting);
 gboolean   gtk_window_get_skip_pager_hint      (GtkWindow           *window);
+void       gtk_window_set_accept_focus         (GtkWindow           *window,
+                                                gboolean             setting);
+gboolean   gtk_window_get_accept_focus         (GtkWindow           *window);
 void       gtk_window_set_destroy_with_parent  (GtkWindow           *window,
                                                 gboolean             setting);
 gboolean   gtk_window_get_destroy_with_parent  (GtkWindow           *window);
Index: gdk/gdkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.h,v
retrieving revision 1.46
diff -u -p -r1.46 gdkwindow.h
--- gdk/gdkwindow.h	10 Aug 2003 23:37:29 -0000	1.46
+++ gdk/gdkwindow.h	4 Dec 2003 20:59:47 -0000
@@ -68,7 +68,8 @@ typedef enum
   GDK_WA_COLORMAP = 1 << 5,
   GDK_WA_VISUAL	  = 1 << 6,
   GDK_WA_WMCLASS  = 1 << 7,
-  GDK_WA_NOREDIR  = 1 << 8
+  GDK_WA_NOREDIR  = 1 << 8,
+  GDK_WA_NOFOCUS  = 1 << 9
 } GdkWindowAttributesType;
 
 /* Size restriction enumeration.
@@ -184,6 +185,7 @@ struct _GdkWindowAttr
   gchar *wmclass_name;
   gchar *wmclass_class;
   gboolean override_redirect;
+  gboolean accept_focus;
 };
 
 struct _GdkGeometry
@@ -260,6 +262,8 @@ struct _GdkWindowObject
   guint modal_hint : 1;
   
   guint destroyed : 2;
+
+  guint accept_focus : 1;
   
   GdkEventMask event_mask;
 };
@@ -317,6 +321,8 @@ void          gdk_window_set_user_data  
                                                 gpointer       user_data);
 void          gdk_window_set_override_redirect (GdkWindow     *window,
                                                 gboolean       override_redirect);
+void          gdk_window_set_accept_focus      (GdkWindow     *window,
+					        gboolean       accept_focus);
 void          gdk_window_add_filter            (GdkWindow     *window,
                                                 GdkFilterFunc  function,
                                                 gpointer       data);
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.195
diff -u -p -r1.195 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	23 Oct 2003 18:50:40 -0000	1.195
+++ gdk/x11/gdkwindow-x11.c	4 Dec 2003 20:59:48 -0000
@@ -343,6 +343,7 @@ _gdk_windowing_window_init (GdkScreen * 
 static void
 set_wm_protocols (GdkWindow *window)
 {
+  GdkWindowObject *private = (GdkWindowObject *)window;
   GdkDisplay *display = gdk_drawable_get_display (window);
   Atom protocols[3];
   
@@ -524,6 +525,11 @@ gdk_window_new (GdkWindow     *parent,
   else
     xattributes.override_redirect = False;
 
+  if (attributes_mask & GDK_WA_NOFOCUS)
+    private->accept_focus = attributes->accept_focus;
+  else
+    private->accept_focus = TRUE;
+
   if (private->parent && private->parent->guffaw_gravity)
     {
       xattributes.win_gravity = StaticGravity;
@@ -989,8 +995,8 @@ update_wm_hints (GdkWindow *window,
       private->state & GDK_WINDOW_STATE_WITHDRAWN)
     return;
 
-  wm_hints.flags = StateHint;
-  wm_hints.input = True;
+  wm_hints.flags = StateHint | InputHint;
+  wm_hints.input = private->accept_focus ? True : False;
   wm_hints.initial_state = NormalState;
   
   if (private->state & GDK_WINDOW_STATE_ICONIFIED)
@@ -3223,6 +3229,38 @@ gdk_window_set_override_redirect (GdkWin
     }
 }
 
+/**
+ * gdk_window_set_accept_focus:
+ * @window: a toplevel #GdkWindow
+ * @accept_focus: %TRUE if the window should receive input focus
+ *
+ * Setting @accept_focus to %FALSE hints the window manager that the
+ * window doesn't want to receive input focus. ICCCM-compliant window
+ * manager usually respect this hint.
+ *
+ * Since: 2.4 
+ **/
+void
+gdk_window_set_accept_focus (GdkWindow *window,
+			     gboolean accept_focus)
+{
+  GdkWindowObject *private;
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (GDK_IS_WINDOW (window));
+
+  private = (GdkWindowObject *)window;  
+  
+  accept_focus = accept_focus != FALSE;
+
+  if (private->accept_focus != accept_focus)
+    {
+      private->accept_focus = accept_focus;
+
+      if (!GDK_WINDOW_DESTROYED (window))
+	update_wm_hints (window, FALSE);
+    }
+}
+
 
 /**
  * gdk_window_set_icon_list:
Index: gdk/x11/gdkevents-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkevents-x11.c,v
retrieving revision 1.118
diff -u -p -r1.118 gdkevents-x11.c
--- gdk/x11/gdkevents-x11.c	11 Aug 2003 16:08:27 -0000	1.118
+++ gdk/x11/gdkevents-x11.c	4 Dec 2003 20:59:49 -0000
@@ -1969,11 +1969,12 @@ gdk_wm_protocols_filter (GdkXEvent *xev,
   else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
     {
       GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
+      GdkWindowObject *private = (GdkWindowObject *)win;
 
       /* There is no way of knowing reliably whether we are viewable;
        * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
        */
-      if (toplevel)
+      if (toplevel && private->accept_focus)
 	_gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
 				       RevertToParent,
 				       xevent->xclient.data.l[1]);
