+
+static void
+window_update_has_focus (GtkWindow *window)
+{
+ GtkWidget *widget = GTK_WIDGET (window);
+ gboolean has_focus = window->has_toplevel_focus && window->is_active;
+
+ if (has_focus != window->has_focus)
+ {
+ window->has_focus = has_focus;
+
+ if (has_focus)
+ {
+ if (window->focus_widget &&
+ window->focus_widget != widget &&
+ !GTK_WIDGET_HAS_FOCUS (window->focus_widget))
+ do_focus_change (window->focus_widget, TRUE);
+ }
+ else
+ {
+ if (window->focus_widget &&
+ window->focus_widget != widget &&
+ GTK_WIDGET_HAS_FOCUS (window->focus_widget))
+ do_focus_change (window->focus_widget, FALSE);
+ }
+ }
+}
+
+/**
+ * _gtk_window_set_is_active:
+ * @window: a #GtkWindow
+ * @is_active: %TRUE if the window is in the currently active toplevel
+ *
+ * Internal function that sets whether the #GtkWindow is part
+ * of the currently active toplevel window (taking into account inter-process
+ * embedding.)
+ **/
+void
+_gtk_window_set_is_active (GtkWindow *window,
+ gboolean is_active)
+{
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ is_active = is_active != FALSE;
+
+ if (is_active != window->is_active)
+ {
+ window->is_active = is_active;
+ window_update_has_focus (window);
+
+ g_object_notify (G_OBJECT (window), "is_active");
+ }
+}
+
+/**
+ * _gtk_window_set_has_toplevel_focus:
+ * @window: a #GtkWindow
+ * @has_toplevel_focus: %TRUE if the in
+ *
+ * Internal function that sets whether the keyboard focus for the
+ * toplevel window (taking into account inter-process embedding.)
+ **/
+void
+_gtk_window_set_has_toplevel_focus (GtkWindow *window,
+ gboolean has_toplevel_focus)
+{
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ has_toplevel_focus = has_toplevel_focus != FALSE;
+
+ if (has_toplevel_focus != window->has_toplevel_focus)
+ {
+ window->has_toplevel_focus = has_toplevel_focus;
+ window_update_has_focus (window);
+
+ g_object_notify (G_OBJECT (window), "has_toplevel_focus");
+ }
+}