WINGs: route DnD through view backend vtable

Adds drag_begin slot to W_ViewBackend. WMDragImageFromView dispatches
through it. X11 backend sets NULL (falls through to existing XDND
code). Wayland backend is a no-op — prevents crash without guards.
This commit is contained in:
Window Maker 2026-05-23 15:02:30 +02:00
parent cee271f2cd
commit 0083654d2e
4 changed files with 16 additions and 0 deletions

View File

@ -633,6 +633,9 @@ typedef struct W_ViewBackend {
/* Clipboard (cut buffer) */
void (*clipboard_store)(void *vctx, const char *text, int len);
char *(*clipboard_fetch)(void *vctx, int *len_out);
/* Drag and drop */
void (*drag_begin)(void *vctx, struct W_View *view, WMEvent *event);
} W_ViewBackend;
extern const W_ViewBackend W_ViewBackendX11;

View File

@ -860,6 +860,12 @@ Bool WMIsDraggingFromView(WMView * view)
void WMDragImageFromView(WMView * view, WMEvent * event)
{
const W_ViewBackend *vb = W_VIEW_SCREEN(view)->viewBackend;
if (vb && vb->drag_begin) {
vb->drag_begin(W_VIEW_SCREEN(view)->viewBackendCtx, view, event);
return;
}
WMDraggingInfo *info = &W_VIEW_SCREEN(view)->dragInfo;
WMPoint mouseLocation;

View File

@ -531,6 +531,11 @@ static char *wl_clipboard_fetch(void *vctx, int *len_out)
return NULL;
}
static void wl_drag_begin(void *vctx, W_View *view, WMEvent *event)
{
(void)vctx; (void)view; (void)event;
}
static void wl_flush(void *vctx)
{
(void)vctx;
@ -561,4 +566,5 @@ const W_ViewBackend W_ViewBackendWL = {
.flush = wl_flush,
.clipboard_store = wl_clipboard_store,
.clipboard_fetch = wl_clipboard_fetch,
.drag_begin = wl_drag_begin,
};

View File

@ -253,4 +253,5 @@ const W_ViewBackend W_ViewBackendX11 = {
.flush = x11_flush,
.clipboard_store = x11_clipboard_store,
.clipboard_fetch = x11_clipboard_fetch,
.drag_begin = NULL,
};