diff --git a/platform/wayland/cog-platform-wl.c b/platform/wayland/cog-platform-wl.c index c6fc2e3c..5722973d 100644 --- a/platform/wayland/cog-platform-wl.c +++ b/platform/wayland/cog-platform-wl.c @@ -768,7 +768,7 @@ touch_on_down(void *data, CogWlViewport *viewport = wl_surface_get_user_data( surface); // Viewport is attached the context of the wl_surface. Check cog_wl_viewport_create_window(); - seat->touch_target = viewport; + g_set_weak_pointer(&seat->touch_target, viewport); seat->touch.serial = serial; seat->touch.surface = surface; @@ -820,13 +820,7 @@ touch_on_up(void *data, struct wl_touch *touch, uint32_t serial, uint32_t time, return; } - g_assert(seat->touch_target); - CogWlViewport *viewport = COG_WL_VIEWPORT(seat->touch_target); - - struct wl_surface *target_surface = seat->touch.surface; - seat->touch_target = NULL; seat->touch.serial = serial; - seat->touch.surface = NULL; if (id < 0 || id >= 10) return; @@ -838,6 +832,7 @@ touch_on_up(void *data, struct wl_touch *touch, uint32_t serial, uint32_t time, CogWlPlatform *platform = (CogWlPlatform *) cog_platform_get(); CogWlPopup *popup = platform->popup; + struct wl_surface *target_surface = seat->touch.surface; if (popup && popup->wl_surface) { if (target_surface == popup->wl_surface) { cog_popup_menu_handle_event(popup->popup_menu, COG_POPUP_MENU_EVENT_STATE_RELEASED, raw_event.x, @@ -853,7 +848,8 @@ touch_on_up(void *data, struct wl_touch *touch, uint32_t serial, uint32_t time, struct wpe_input_touch_event event = {seat->touch.points, 10, raw_event.type, raw_event.id, raw_event.time}; - CogView *view = cog_viewport_get_visible_view((CogViewport *) viewport); + CogWlViewport *viewport = COG_WL_VIEWPORT(seat->touch_target); + CogView *view = cog_viewport_get_visible_view((CogViewport *) viewport); if (view) wpe_view_backend_dispatch_touch_event(cog_view_get_backend(view), &event);