mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-07 00:35:53 +01:00
- added WMRemoveFromArrayMatching(array, match, cdata), which will remove the
first element in the array that is matched by match(item, cdata)==True. - added WMArrayFirst(), WMArrayLast(), WMArrayNext() and WMArrayPrevious() functions and also WM_ITERATE_ARRAY() and WM_ETARETI_ARRAY() macros, to make interfaces to WMBag and WMArray similar and to make life a little simpler when iterating through all elements of an array. - replaced bags with arrays wherever appropriate. This will improve performance a bit. - replaced some recursive code with iterative code in WINGs/selection.c - some code cleanup is src/
This commit is contained in:
18
src/xdnd.c
18
src/xdnd.c
@@ -102,7 +102,7 @@ wXDNDProcessSelection(XEvent *event)
|
||||
char * delme;
|
||||
XEvent xevent;
|
||||
Window selowner = XGetSelectionOwner(dpy,_XA_XdndSelection);
|
||||
WMBag *items;
|
||||
WMArray *items;
|
||||
|
||||
|
||||
XGetWindowProperty(dpy, event->xselection.requestor,
|
||||
@@ -125,11 +125,12 @@ wXDNDProcessSelection(XEvent *event)
|
||||
|
||||
/*process dropping*/
|
||||
if (scr->xdestring) {
|
||||
WMArrayIterator iter;
|
||||
int length, str_size;
|
||||
int total_size = 0;
|
||||
char *tmp;
|
||||
|
||||
items = WMCreateBag(1);
|
||||
items = WMCreateArray(4);
|
||||
retain = wstrdup(scr->xdestring);
|
||||
XFree(scr->xdestring); /* since xdestring was created by Xlib */
|
||||
|
||||
@@ -143,24 +144,23 @@ wXDNDProcessSelection(XEvent *event)
|
||||
if (retain[length] == '\n') {
|
||||
str_size = strlen(&retain[length + 1]);
|
||||
if(str_size) {
|
||||
WMPutInBag(items, wstrdup(&retain[length + 1]));
|
||||
WMAddToArray(items, wstrdup(&retain[length + 1]));
|
||||
total_size += str_size + 3; /* reserve for " \"\"" */
|
||||
if (length)
|
||||
WMAppendBag(items, WMCreateBag(1));
|
||||
/* this is nonsense -- if (length)
|
||||
WMAppendArray(items, WMCreateArray(1));*/
|
||||
}
|
||||
retain[length] = 0;
|
||||
}
|
||||
}
|
||||
/* final one */
|
||||
WMPutInBag(items, wstrdup(retain));
|
||||
WMAddToArray(items, wstrdup(retain));
|
||||
total_size += strlen(retain) + 3;
|
||||
wfree(retain);
|
||||
|
||||
/* now pack new string */
|
||||
scr->xdestring = wmalloc(total_size);
|
||||
scr->xdestring[0]=0; /* empty string */
|
||||
for(length = WMGetBagItemCount(items)-1; length >=0; length--) {
|
||||
tmp = WMGetFromBag(items, length);
|
||||
WM_ETARETI_ARRAY(items, tmp, iter) {
|
||||
if (!strncmp(tmp,"file:",5)) {
|
||||
/* add more 2 chars while removing 5 is harmless */
|
||||
strcat(scr->xdestring, " \"");
|
||||
@@ -172,7 +172,7 @@ wXDNDProcessSelection(XEvent *event)
|
||||
}
|
||||
wfree(tmp);
|
||||
}
|
||||
WMFreeBag(items);
|
||||
WMFreeArray(items);
|
||||
wDockReceiveDNDDrop(scr,event);
|
||||
/*
|
||||
printf("free ");
|
||||
|
||||
Reference in New Issue
Block a user