MetaWaylandPointerConstraint: Maybe enable on window 'raise'

If a MetaWindow's 'appears-focused' state changed to true, but the
window did not have pointer focus, the constraint did not enable. Thus,
make it possible for the user to also click the window to enable it.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
This commit is contained in:
Jonas Ådahl 2016-02-25 11:27:27 +08:00
parent 517078d142
commit d4b0c21d06

View File

@ -70,6 +70,7 @@ typedef struct _MetaWaylandSurfacePointerConstraintsData
GList *pointer_constraints; GList *pointer_constraints;
MetaWindow *window; MetaWindow *window;
gulong appears_changed_handler_id; gulong appears_changed_handler_id;
gulong raised_handler_id;
} MetaWaylandSurfacePointerConstraintsData; } MetaWaylandSurfacePointerConstraintsData;
typedef struct typedef struct
@ -126,6 +127,12 @@ appears_focused_changed (MetaWindow *window,
meta_wayland_pointer_constraint_maybe_enable_for_window (window); meta_wayland_pointer_constraint_maybe_enable_for_window (window);
} }
static void
window_raised (MetaWindow *window)
{
meta_wayland_pointer_constraint_maybe_enable_for_window (window);
}
static MetaWaylandSurfacePointerConstraintsData * static MetaWaylandSurfacePointerConstraintsData *
surface_constraint_data_new (MetaWaylandSurface *surface) surface_constraint_data_new (MetaWaylandSurface *surface)
{ {
@ -141,6 +148,9 @@ surface_constraint_data_new (MetaWaylandSurface *surface)
data->appears_changed_handler_id = data->appears_changed_handler_id =
g_signal_connect (data->window, "notify::appears-focused", g_signal_connect (data->window, "notify::appears-focused",
G_CALLBACK (appears_focused_changed), NULL); G_CALLBACK (appears_focused_changed), NULL);
data->raised_handler_id =
g_signal_connect (data->window, "raised",
G_CALLBACK (window_raised), NULL);
} }
else else
{ {
@ -158,6 +168,8 @@ surface_constraint_data_free (MetaWaylandSurfacePointerConstraintsData *data)
{ {
g_signal_handler_disconnect (data->window, g_signal_handler_disconnect (data->window,
data->appears_changed_handler_id); data->appears_changed_handler_id);
g_signal_handler_disconnect (data->window,
data->raised_handler_id);
g_object_remove_weak_pointer (G_OBJECT (data->window), g_object_remove_weak_pointer (G_OBJECT (data->window),
(gpointer *) &data->window); (gpointer *) &data->window);
} }