Merge branch 'focus-fixes' into 'master'

Focus fixes

See merge request GNOME/gtk!819
This commit is contained in:
Matthias Clasen 2019-05-05 14:20:04 +00:00
commit 84d3848c01
2 changed files with 9 additions and 72 deletions

View File

@ -503,6 +503,8 @@ static void gtk_window_do_popup (GtkWindow *window,
static void gtk_window_style_updated (GtkWidget *widget);
static void gtk_window_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
static GListStore *toplevel_list = NULL;
static guint window_signals[LAST_SIGNAL] = { 0 };
@ -6230,47 +6232,6 @@ get_active_region_type (GtkWindow *window, gint x, gint y)
return GTK_WINDOW_REGION_CONTENT;
}
static void
do_focus_change (GtkWidget *widget,
gboolean in)
{
GdkSeat *seat;
GdkDevice *device;
GdkEvent *event;
GtkRoot *root;
GtkStateFlags flags;
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
device = gdk_seat_get_keyboard (seat);
event = gdk_event_new (GDK_FOCUS_CHANGE);
gdk_event_set_display (event, gtk_widget_get_display (widget));
gdk_event_set_device (event, device);
event->any.type = GDK_FOCUS_CHANGE;
event->any.surface = _gtk_widget_get_surface (widget);
if (event->any.surface)
g_object_ref (event->any.surface);
event->focus_change.in = in;
event->focus_change.mode = GDK_CROSSING_STATE_CHANGED;
event->focus_change.detail = GDK_NOTIFY_ANCESTOR;
flags = GTK_STATE_FLAG_FOCUSED;
root = gtk_widget_get_root (widget);
if (!GTK_IS_WINDOW (root) || gtk_window_get_focus_visible (GTK_WINDOW (root)))
flags |= GTK_STATE_FLAG_FOCUS_VISIBLE;
if (in)
gtk_widget_set_state_flags (widget, flags, FALSE);
else
gtk_widget_unset_state_flags (widget, flags);
gtk_widget_set_has_focus (widget, in);
gtk_widget_event (widget, event);
g_object_unref (event);
}
static gboolean
gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
{
@ -8946,7 +8907,7 @@ gtk_window_activate_key (GtkWindow *window,
return gtk_window_activate_menubar (window, event);
}
/**
/*
* _gtk_window_set_is_active:
* @window: a #GtkWindow
* @is_active: %TRUE if the window is in the currently active toplevel
@ -8955,40 +8916,19 @@ gtk_window_activate_key (GtkWindow *window,
* of the currently active toplevel window (taking into account inter-process
* embedding.)
**/
void
static void
_gtk_window_set_is_active (GtkWindow *window,
gboolean is_active)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
if (priv->is_active == is_active)
return;
is_active = is_active != FALSE;
priv->is_active = is_active;
if (is_active != priv->is_active)
{
GtkWidget *widget = GTK_WIDGET (window);
priv->is_active = is_active;
if (is_active)
{
if (priv->focus_widget &&
priv->focus_widget != widget &&
!gtk_widget_has_focus (priv->focus_widget))
do_focus_change (priv->focus_widget, TRUE);
}
else
{
if (priv->focus_widget &&
priv->focus_widget != widget &&
gtk_widget_has_focus (priv->focus_widget))
do_focus_change (priv->focus_widget, FALSE);
}
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]);
_gtk_window_accessible_set_is_active (window, is_active);
}
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]);
_gtk_window_accessible_set_is_active (window, is_active);
}
/**

View File

@ -47,9 +47,6 @@ gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *
void _gtk_window_unset_focus_and_default (GtkWindow *window,
GtkWidget *widget);
void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
void _gtk_window_set_allocation (GtkWindow *window,
int width,
int height,