Adding drag-n-drop patch

This commit is contained in:
Bakkeby 2025-02-20 10:18:17 +01:00 committed by Antoine Vaure
parent 48f696499d
commit 137bb152b3
9 changed files with 292 additions and 0 deletions

44
x.c
View file

@ -603,6 +603,13 @@ selnotify(XEvent *e)
if (property == None)
return;
#if DRAG_AND_DROP_PATCH
if (property == xw.XdndSelection) {
xdndsel(e);
return;
}
#endif // DRAG_AND_DROP_PATCH
do {
if (XGetWindowProperty(xw.dpy, xw.win, property, ofs,
BUFSIZ/4, False, AnyPropertyType,
@ -1683,6 +1690,28 @@ xinit(int cols, int rows)
xw.netwmfullscreen = XInternAtom(xw.dpy, "_NET_WM_STATE_FULLSCREEN", False);
#endif // FULLSCREEN_PATCH
#if DRAG_AND_DROP_PATCH
/* Xdnd setup */
xw.XdndTypeList = XInternAtom(xw.dpy, "XdndTypeList", 0);
xw.XdndSelection = XInternAtom(xw.dpy, "XdndSelection", 0);
xw.XdndEnter = XInternAtom(xw.dpy, "XdndEnter", 0);
xw.XdndPosition = XInternAtom(xw.dpy, "XdndPosition", 0);
xw.XdndStatus = XInternAtom(xw.dpy, "XdndStatus", 0);
xw.XdndLeave = XInternAtom(xw.dpy, "XdndLeave", 0);
xw.XdndDrop = XInternAtom(xw.dpy, "XdndDrop", 0);
xw.XdndFinished = XInternAtom(xw.dpy, "XdndFinished", 0);
xw.XdndActionCopy = XInternAtom(xw.dpy, "XdndActionCopy", 0);
xw.XdndActionMove = XInternAtom(xw.dpy, "XdndActionMove", 0);
xw.XdndActionLink = XInternAtom(xw.dpy, "XdndActionLink", 0);
xw.XdndActionAsk = XInternAtom(xw.dpy, "XdndActionAsk", 0);
xw.XdndActionPrivate = XInternAtom(xw.dpy, "XdndActionPrivate", 0);
xw.XtextUriList = XInternAtom((Display*) xw.dpy, "text/uri-list", 0);
xw.XtextPlain = XInternAtom((Display*) xw.dpy, "text/plain", 0);
xw.XdndAware = XInternAtom(xw.dpy, "XdndAware", 0);
XChangeProperty(xw.dpy, xw.win, xw.XdndAware, 4, 32, PropModeReplace,
&XdndVersion, 1);
#endif // DRAG_AND_DROP_PATCH
win.mode = MODE_NUMLOCK;
resettitle();
xhints();
@ -3713,6 +3742,21 @@ cmessage(XEvent *e)
} else if (e->xclient.data.l[0] == xw.wmdeletewin) {
ttyhangup();
exit(0);
#if DRAG_AND_DROP_PATCH
} else if (e->xclient.message_type == xw.XdndEnter) {
xw.XdndSourceWin = e->xclient.data.l[0];
xw.XdndSourceVersion = e->xclient.data.l[1] >> 24;
xw.XdndSourceFormat = None;
if (xw.XdndSourceVersion > 5)
return;
xdndenter(e);
} else if (e->xclient.message_type == xw.XdndPosition
&& xw.XdndSourceVersion <= 5) {
xdndpos(e);
} else if (e->xclient.message_type == xw.XdndDrop
&& xw.XdndSourceVersion <= 5) {
xdnddrop(e);
#endif // DRAG_AND_DROP_PATCH
}
}