datadevice: guard surface in dnd for null

fixes #6076
This commit is contained in:
Vaxry 2024-05-15 16:25:56 +01:00
parent 7fbe05a250
commit 3381e2b55b

View file

@ -233,7 +233,7 @@ CWLDataDeviceResource::CWLDataDeviceResource(SP<CWlDataDevice> resource_) : reso
source->dnd = true; source->dnd = true;
PROTO::data->initiateDrag(source, wlr_surface_from_resource(icon), wlr_surface_from_resource(origin)); PROTO::data->initiateDrag(source, icon ? wlr_surface_from_resource(icon) : nullptr, wlr_surface_from_resource(origin));
}); });
} }
@ -471,6 +471,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
dnd.currentSource = currentSource; dnd.currentSource = currentSource;
dnd.originSurface = origin; dnd.originSurface = origin;
dnd.dndSurface = dragSurface; dnd.dndSurface = dragSurface;
if (dragSurface) {
dnd.hyprListener_dndSurfaceDestroy.initCallback( dnd.hyprListener_dndSurfaceDestroy.initCallback(
&dragSurface->events.destroy, [this](void* owner, void* data) { abortDrag(); }, nullptr, "CWLDataDeviceProtocol::drag"); &dragSurface->events.destroy, [this](void* owner, void* data) { abortDrag(); }, nullptr, "CWLDataDeviceProtocol::drag");
dnd.hyprListener_dndSurfaceCommit.initCallback( dnd.hyprListener_dndSurfaceCommit.initCallback(
@ -487,6 +488,7 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
} }
}, },
nullptr, "CWLDataDeviceProtocol::drag"); nullptr, "CWLDataDeviceProtocol::drag");
}
dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) { dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
auto E = std::any_cast<IPointer::SButtonEvent>(e); auto E = std::any_cast<IPointer::SButtonEvent>(e);