diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c index 6b514ea2d8..edbc3eb5f1 100644 --- a/gdk/broadway/gdkdevice-broadway.c +++ b/gdk/broadway/gdkdevice-broadway.c @@ -234,6 +234,41 @@ gdk_broadway_device_query_state (GdkDevice *device, return TRUE; } +void +_gdk_broadway_window_grab_check_destroy (GdkWindow *window) +{ + GdkDisplay *display = gdk_window_get_display (window); + GdkBroadwayDisplay *broadway_display; + GdkDeviceManager *device_manager; + GdkDeviceGrabInfo *grab; + GList *devices, *d; + + broadway_display = GDK_BROADWAY_DISPLAY (display); + + device_manager = gdk_display_get_device_manager (display); + + /* Get all devices */ + devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER); + + for (d = devices; d; d = d->next) + { + /* Make sure there is no lasting grab in this native window */ + grab = _gdk_display_get_last_device_grab (display, d->data); + + if (grab && grab->native_window == window) + { + grab->serial_end = grab->serial_start; + grab->implicit_ungrab = TRUE; + + broadway_display->pointer_grab_window = NULL; + } + + } + + g_list_free (devices); +} + + static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device, GdkWindow *window, diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h index 4956894a7c..4450e7665c 100644 --- a/gdk/broadway/gdkprivate-broadway.h +++ b/gdk/broadway/gdkprivate-broadway.h @@ -87,7 +87,9 @@ void _gdk_broadway_window_change_property (GdkWindow *window, void _gdk_broadway_window_delete_property (GdkWindow *window, GdkAtom property); -void _gdk_broadway_selection_window_destroyed (GdkWindow *window); + +void _gdk_broadway_selection_window_destroyed (GdkWindow *window); +void _gdk_broadway_window_grab_check_destroy (GdkWindow *window); void _gdk_keymap_keys_changed (GdkDisplay *display); gint _gdk_broadway_get_group_for_state (GdkDisplay *display, diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c index 6b0a71392e..aa6973da2e 100644 --- a/gdk/broadway/gdkwindow-broadway.c +++ b/gdk/broadway/gdkwindow-broadway.c @@ -273,6 +273,8 @@ gdk_window_impl_broadway_finalize (GObject *object) wrapper = impl->wrapper; + _gdk_broadway_window_grab_check_destroy (wrapper); + broadway_display = GDK_BROADWAY_DISPLAY (gdk_window_get_display (impl->wrapper)); if (broadway_display->mouse_in_toplevel == GDK_WINDOW (wrapper)) @@ -472,6 +474,7 @@ _gdk_broadway_window_destroy (GdkWindow *window, impl = GDK_WINDOW_IMPL_BROADWAY (window->impl); _gdk_broadway_selection_window_destroyed (window); + _gdk_broadway_window_grab_check_destroy (window); if (impl->ref_surface) {