1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +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:
dan
2001-04-15 01:22:56 +00:00
parent a41b8993e5
commit 046403dbbb
27 changed files with 581 additions and 662 deletions

View File

@@ -20,6 +20,8 @@ Changes since version 0.64.0:
desktop level.
- Fixed incorrect parsing of display and screen number from $DISPLAY.
- Organized the inspector panel a bit better.
- Replaced bags with arrays wherever appropriate. This will improve
performance a bit.
Changes since version 0.63.1:

View File

@@ -19,6 +19,15 @@ Changes since wmaker 0.64.0:
- fixed secure textfields not to allow text selection, to avoid compromising
sensitive information by pasting it to a terminal.
- replaced wmkrange(), wmkpoint() and wmksize() functions with macros.
- 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 selection.c
changes since wmaker 0.63.1:

View File

@@ -337,7 +337,7 @@ typedef struct W_View {
struct W_View *nextSister; /* next on parent's children list */
WMBag *eventHandlers; /* event handlers for this window */
WMArray *eventHandlers; /* event handlers for this window */
unsigned long attribFlags;
XSetWindowAttributes attribs;
@@ -481,8 +481,6 @@ void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
WMReliefType relief,
GC black, GC dark, GC light, GC white);
void W_CleanUpEvents(W_View *view);
void W_CallDestroyHandlers(W_View *view);
void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,

View File

@@ -178,6 +178,7 @@ typedef struct {
} WMHashTableCallbacks;
typedef int WMArrayIterator;
typedef void *WMBagIterator;
@@ -415,7 +416,9 @@ void* WMReplaceInArray(WMArray *array, int index, void *item);
*/
int WMDeleteFromArray(WMArray *array, int index);
int WMRemoveFromArray(WMArray *array, void *item);
#define WMRemoveFromArray(array, item) WMRemoveFromArrayMatching(array, NULL, item)
int WMRemoveFromArrayMatching(WMArray *array, WMMatchDataProc *match, void *cdata);
void* WMGetFromArray(WMArray *array, int index);
@@ -442,6 +445,24 @@ void WMMapArray(WMArray *array, void (*function)(void*, void*), void *data);
WMArray* WMGetSubarrayWithRange(WMArray* array, WMRange aRange);
void* WMArrayFirst(WMArray *array, WMArrayIterator *iter);
void* WMArrayLast(WMArray *array, WMArrayIterator *iter);
/* The following 2 functions assume that the array doesn't change between calls */
void* WMArrayNext(WMArray *array, WMArrayIterator *iter);
void* WMArrayPrevious(WMArray *array, WMArrayIterator *iter);
/* The following 2 macros assume that the array doesn't change in the for loop */
#define WM_ITERATE_ARRAY(array, var, i) \
for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
var = WMArrayNext(array, &(i)))
#define WM_ETARETI_ARRAY(array, var, i) \
for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
var = WMArrayPrevious(array, &(i)))
/*..........................................................................*/
@@ -514,6 +535,7 @@ void* WMBagFirst(WMBag *bag, WMBagIterator *ptr);
void* WMBagLast(WMBag *bag, WMBagIterator *ptr);
/* The following 4 functions assume that the bag doesn't change between calls */
void* WMBagNext(WMBag *bag, WMBagIterator *ptr);
void* WMBagPrevious(WMBag *bag, WMBagIterator *ptr);
@@ -523,6 +545,7 @@ void* WMBagIteratorAtIndex(WMBag *bag, int index, WMBagIterator *ptr);
int WMBagIndexForIterator(WMBag *bag, WMBagIterator ptr);
/* The following 2 macros assume that the bag doesn't change in the for loop */
#define WM_ITERATE_BAG(bag, var, i) \
for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
var = WMBagNext(bag, &(i)))

View File

@@ -193,16 +193,25 @@ WMDeleteFromArray(WMArray *array, int index)
int
WMRemoveFromArray(WMArray *array, void *item)
WMRemoveFromArrayMatching(WMArray *array, WMMatchDataProc *match, void *cdata)
{
int i;
if (match != NULL) {
for (i = 0; i < array->itemCount; i++) {
if (array->items[i] == item) {
if ((*match)(array->items[i], cdata)) {
WMDeleteFromArray(array, i);
return 1;
}
}
} else {
for (i = 0; i < array->itemCount; i++) {
if (array->items[i] == cdata) {
WMDeleteFromArray(array, i);
return 1;
}
}
}
return 0;
}
@@ -304,3 +313,54 @@ WMGetSubarrayWithRange(WMArray* array, WMRange aRange)
}
void*
WMArrayFirst(WMArray *array, WMArrayIterator *iter)
{
if (array->itemCount == 0) {
*iter = WANotFound;
return NULL;
} else {
*iter = 0;
return array->items[0];
}
}
void*
WMArrayLast(WMArray *array, WMArrayIterator *iter)
{
if (array->itemCount == 0) {
*iter = WANotFound;
return NULL;
} else {
*iter = array->itemCount-1;
return array->items[*iter];
}
}
void*
WMArrayNext(WMArray *array, WMArrayIterator *iter)
{
if (*iter >= 0 && *iter < array->itemCount-1) {
return array->items[++(*iter)];
} else {
*iter = WANotFound;
return NULL;
}
}
void*
WMArrayPrevious(WMArray *array, WMArrayIterator *iter)
{
if (*iter > 0 && *iter < array->itemCount) {
return array->items[--(*iter)];
} else {
*iter = WANotFound;
return NULL;
}
}

View File

@@ -23,8 +23,7 @@
* TODO:
* - decide if we want to support connections with external sockets, else
* clean up the structure of the unneeded members.
* - decide what to do with all wsyserror() and wwarning() calls that are
* still there.
* - decide what to do with all wwarning() calls that are still there.
*
*/

View File

@@ -51,9 +51,9 @@ typedef struct InputHandler {
/* queue of timer event handlers */
static TimerHandler *timerHandler=NULL;
static WMBag *idleHandler=NULL;
static WMArray *idleHandler=NULL;
static WMBag *inputHandler=NULL;
static WMArray *inputHandler=NULL;
#define timerPending() (timerHandler)
@@ -248,9 +248,9 @@ WMAddIdleHandler(WMCallback *callback, void *cdata)
handler->clientData = cdata;
/* add handler at end of queue */
if (!idleHandler) {
idleHandler = WMCreateBag(16);
idleHandler = WMCreateArrayWithDestructor(16, wfree);
}
WMPutInBag(idleHandler, handler);
WMAddToArray(idleHandler, handler);
return handler;
}
@@ -265,11 +265,7 @@ WMDeleteIdleHandler(WMHandlerID handlerID)
if (!handler || !idleHandler)
return;
pos = WMGetFirstInBag(idleHandler, handler);
if (pos != WBNotFound) {
wfree(handler);
WMDeleteFromBag(idleHandler, pos);
}
WMRemoveFromArray(idleHandler, handler);
}
@@ -287,8 +283,8 @@ WMAddInputHandler(int fd, int condition, WMInputProc *proc, void *clientData)
handler->clientData = clientData;
if (!inputHandler)
inputHandler = WMCreateBag(16);
WMPutInBag(inputHandler, handler);
inputHandler = WMCreateArrayWithDestructor(16, wfree);
WMAddToArray(inputHandler, handler);
return handler;
}
@@ -304,11 +300,7 @@ WMDeleteInputHandler(WMHandlerID handlerID)
if (!handler || !inputHandler)
return;
pos = WMGetFirstInBag(inputHandler, handler);
if (pos != WBNotFound) {
wfree(handler);
WMDeleteFromBag(inputHandler, pos);
}
WMRemoveFromArray(inputHandler, handler);
}
@@ -316,35 +308,32 @@ Bool
W_CheckIdleHandlers(void)
{
IdleHandler *handler;
WMBag *handlerCopy;
WMBagIterator iter;
WMArray *handlerCopy;
WMArrayIterator iter;
if (!idleHandler || WMGetBagItemCount(idleHandler)==0) {
if (!idleHandler || WMGetArrayItemCount(idleHandler)==0) {
W_FlushIdleNotificationQueue();
/* make sure an observer in queue didn't added an idle handler */
return (idleHandler!=NULL && WMGetBagItemCount(idleHandler)>0);
return (idleHandler!=NULL && WMGetArrayItemCount(idleHandler)>0);
}
handlerCopy = WMCreateBag(WMGetBagItemCount(idleHandler));
WMAppendBag(handlerCopy, idleHandler);
handlerCopy = WMDuplicateArray(idleHandler);
for (handler = WMBagFirst(handlerCopy, &iter);
iter != NULL;
handler = WMBagNext(handlerCopy, &iter)) {
WM_ITERATE_ARRAY(handlerCopy, handler, iter) {
/* check if the handler still exist or was removed by a callback */
if (WMGetFirstInBag(idleHandler, handler) == WBNotFound)
if (WMGetFirstInArray(idleHandler, handler) == WANotFound)
continue;
(*handler->callback)(handler->clientData);
WMDeleteIdleHandler(handler);
}
WMFreeBag(handlerCopy);
WMFreeArray(handlerCopy);
W_FlushIdleNotificationQueue();
/* this is not necesarrily False, because one handler can re-add itself */
return (WMGetBagItemCount(idleHandler)>0);
return (WMGetArrayItemCount(idleHandler)>0);
}
@@ -433,7 +422,7 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
extrafd = (inputfd < 0) ? 0 : 1;
if (inputHandler)
nfds = WMGetBagItemCount(inputHandler);
nfds = WMGetArrayItemCount(inputHandler);
else
nfds = 0;
@@ -449,8 +438,9 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
fds[nfds].events = POLLIN;
}
/* use WM_ITERATE_ARRAY() here */
for (i = 0; i<nfds; i++) {
handler = WMGetFromBag(inputHandler, i);
handler = WMGetFromArray(inputHandler, i);
fds[i].fd = handler->fd;
fds[i].events = 0;
if (handler->mask & WIReadMask)
@@ -482,17 +472,14 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
count = poll(fds, nfds+extrafd, timeout);
if (count>0 && nfds>0) {
WMBag *handlerCopy = WMCreateBag(nfds);
for (i=0; i<nfds; i++)
WMPutInBag(handlerCopy, WMGetFromBag(inputHandler, i));
for (i=0; i<nfds; i++) {
WMArray *handlerCopy = WMDuplicateArray(inputHandler);
int mask;
handler = WMGetFromBag(handlerCopy, i);
/* use WM_ITERATE_ARRAY() here */
for (i=0; i<nfds; i++) {
handler = WMGetFromArray(handlerCopy, i);
/* check if the handler still exist or was removed by a callback */
if (WMGetFirstInBag(inputHandler, handler) == WBNotFound)
if (WMGetFirstInArray(inputHandler, handler) == WANotFound)
continue;
mask = 0;
@@ -515,12 +502,9 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
}
}
WMFreeBag(handlerCopy);
WMFreeArray(handlerCopy);
}
/* --oldway-- retval = ((inputfd < 0) ? (count > 0) :
fds[nfds].revents & (POLLIN|POLLRDNORM|POLLRDBAND|POLLPRI));*/
wfree(fds);
W_FlushASAPNotificationQueue();
@@ -536,7 +520,7 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
InputHandler *handler;
if (inputHandler)
nfds = WMGetBagItemCount(inputHandler);
nfds = WMGetArrayItemCount(inputHandler);
else
nfds = 0;
@@ -556,8 +540,9 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
maxfd = inputfd;
}
/* use WM_ITERATE_ARRAY() here */
for (i=0; i<nfds; i++) {
handler = WMGetFromBag(inputHandler, i);
handler = WMGetFromArray(inputHandler, i);
if (handler->mask & WIReadMask)
FD_SET(handler->fd, &rset);
@@ -588,17 +573,14 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
count = select(1 + maxfd, &rset, &wset, &eset, timeoutPtr);
if (count>0 && nfds>0) {
WMBag *handlerCopy = WMCreateBag(nfds);
for (i=0; i<nfds; i++)
WMPutInBag(handlerCopy, WMGetFromBag(inputHandler, i));
for (i=0; i<nfds; i++) {
WMArray *handlerCopy = WMDuplicateArray(inputHandler);
int mask;
handler = WMGetFromBag(handlerCopy, i);
/* use WM_ITERATE_ARRAY() here */
for (i=0; i<nfds; i++) {
handler = WMGetFromArray(handlerCopy, i);
/* check if the handler still exist or was removed by a callback */
if (WMGetFirstInBag(inputHandler, handler) == WBNotFound)
if (WMGetFirstInArray(inputHandler, handler) == WANotFound)
continue;
mask = 0;
@@ -618,7 +600,7 @@ W_HandleInputEvents(Bool waitForInput, int inputfd)
}
}
WMFreeBag(handlerCopy);
WMFreeArray(handlerCopy);
}
W_FlushASAPNotificationQueue();

View File

@@ -385,8 +385,8 @@ WMPostNotificationName(const char *name, void *object, void *clientData)
typedef struct W_NotificationQueue {
WMBag *asapQueue;
WMBag *idleQueue;
WMArray *asapQueue;
WMArray *idleQueue;
struct W_NotificationQueue *next;
} NotificationQueue;
@@ -415,8 +415,10 @@ WMCreateNotificationQueue(void)
queue = wmalloc(sizeof(NotificationQueue));
queue->asapQueue = WMCreateBag(8);
queue->idleQueue = WMCreateBag(8);
queue->asapQueue =
WMCreateArrayWithDestructor(8, (WMFreeDataProc*)WMReleaseNotification);
queue->idleQueue =
WMCreateArrayWithDestructor(8, (WMFreeDataProc*)WMReleaseNotification);
queue->next = notificationQueueList;
notificationQueueList = queue;
@@ -435,62 +437,50 @@ WMEnqueueNotification(WMNotificationQueue *queue, WMNotification *notification,
}
#define NOTIF ((WMNotification*)cdata)
#define ITEM ((WMNotification*)item)
static int
matchSenderAndName(void *item, void *cdata)
{
return (NOTIF->object==ITEM->object && strcmp(NOTIF->name, ITEM->name)==0);
}
static int
matchSender(void *item, void *cdata)
{
return (NOTIF->object == ITEM->object);
}
static int
matchName(void *item, void *cdata)
{
return (strcmp(NOTIF->name, ITEM->name)==0);
}
#undef NOTIF
#undef ITEM
void
WMDequeueNotificationMatching(WMNotificationQueue *queue,
WMNotification *notification, unsigned mask)
{
WMBagIterator i;
WMNotification *tmp;
WMMatchDataProc *matchFunc;
if ((mask & WNCOnName) && (mask & WNCOnSender)) {
WM_ITERATE_BAG(queue->asapQueue, tmp, i) {
if (notification->object == tmp->object &&
strcmp(notification->name, tmp->name) == 0) {
WMRemoveFromBag(queue->asapQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
WM_ITERATE_BAG(queue->idleQueue, tmp, i) {
if (notification->object == tmp->object &&
strcmp(notification->name, tmp->name) == 0) {
WMRemoveFromBag(queue->idleQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
} else if (mask & WNCOnName) {
WM_ITERATE_BAG(queue->asapQueue, tmp, i) {
if (strcmp(notification->name, tmp->name) == 0) {
WMRemoveFromBag(queue->asapQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
WM_ITERATE_BAG(queue->idleQueue, tmp, i) {
if (strcmp(notification->name, tmp->name) == 0) {
WMRemoveFromBag(queue->idleQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
} else if (mask & WNCOnSender) {
WM_ITERATE_BAG(queue->asapQueue, tmp, i) {
if (notification->object == tmp->object) {
WMRemoveFromBag(queue->asapQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
WM_ITERATE_BAG(queue->idleQueue, tmp, i) {
if (notification->object == tmp->object) {
WMRemoveFromBag(queue->idleQueue, tmp);
WMReleaseNotification(tmp);
break;
}
}
}
if ((mask & WNCOnName) && (mask & WNCOnSender))
matchFunc = matchSenderAndName;
else if (mask & WNCOnName)
matchFunc = matchName;
else if (mask & WNCOnSender)
matchFunc = matchSender;
else
return;
WMRemoveFromArrayMatching(queue->asapQueue, matchFunc, notification);
WMRemoveFromArrayMatching(queue->idleQueue, matchFunc, notification);
}
@@ -510,11 +500,11 @@ WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
break;
case WMPostASAP:
WMPutInBag(queue->asapQueue, notification);
WMAddToArray(queue->asapQueue, notification);
break;
case WMPostWhenIdle:
WMPutInBag(queue->idleQueue, notification);
WMAddToArray(queue->idleQueue, notification);
break;
}
}
@@ -526,12 +516,9 @@ W_FlushASAPNotificationQueue()
WMNotificationQueue *queue = notificationQueueList;
while (queue) {
while (WMGetBagItemCount(queue->asapQueue)) {
WMNotification *tmp = WMGetFromBag(queue->asapQueue, 0);
WMPostNotification(tmp);
WMReleaseNotification(tmp);
WMDeleteFromBag(queue->asapQueue, 0);
while (WMGetArrayItemCount(queue->asapQueue)) {
WMPostNotification(WMGetFromArray(queue->asapQueue, 0));
WMDeleteFromArray(queue->asapQueue, 0);
}
queue = queue->next;
@@ -545,12 +532,9 @@ W_FlushIdleNotificationQueue()
WMNotificationQueue *queue = notificationQueueList;
while (queue) {
while (WMGetBagItemCount(queue->idleQueue)) {
WMNotification *tmp = WMGetFromBag(queue->idleQueue, 0);
WMPostNotification(tmp);
WMReleaseNotification(tmp);
WMDeleteFromBag(queue->idleQueue, 0);
while (WMGetArrayItemCount(queue->idleQueue)) {
WMPostNotification(WMGetFromArray(queue->idleQueue, 0));
WMDeleteFromArray(queue->idleQueue, 0);
}
queue = queue->next;

View File

@@ -38,9 +38,9 @@ typedef struct SelectionCallback {
} SelectionCallback;
WMBag *selCallbacks = NULL;
WMArray *selCallbacks = NULL;
WMBag *selHandlers = NULL;
WMArray *selHandlers = NULL;
void
@@ -49,13 +49,13 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
SelectionHandler *handler;
Display *dpy = W_VIEW_SCREEN(view)->display;
Window win = W_VIEW_DRAWABLE(view);
WMBagIterator iter;
WMArrayIterator iter;
if (!selHandlers)
return;
WM_ITERATE_BAG(selHandlers, handler, iter) {
WM_ITERATE_ARRAY(selHandlers, handler, iter) {
if (handler->view == view
&& (handler->selection == selection || selection == None)
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
@@ -64,8 +64,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
handler->flags.delete_pending = 1;
return;
}
WMRemoveFromBag(selHandlers, handler);
wfree(handler);
WMRemoveFromArray(selHandlers, handler);
break;
}
}
@@ -83,12 +82,12 @@ void
WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp)
{
SelectionCallback *handler;
WMBagIterator iter;
WMArrayIterator iter;
if (!selCallbacks)
return;
WM_ITERATE_BAG(selCallbacks, handler, iter) {
WM_ITERATE_ARRAY(selCallbacks, handler, iter) {
if (handler->view == view
&& (handler->selection == selection || selection == 0)
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
@@ -97,8 +96,7 @@ WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp)
handler->flags.delete_pending = 1;
return;
}
WMRemoveFromBag(selCallbacks, handler);
wfree(handler);
WMRemoveFromArray(selCallbacks, handler);
break;
}
}
@@ -170,38 +168,15 @@ notifySelection(XEvent *event, Atom prop)
}
static void
deleteHandlers(WMBagIterator iter)
{
SelectionHandler *handler;
if (iter == NULL)
handler = WMBagFirst(selHandlers, &iter);
else
handler = WMBagNext(selHandlers, &iter);
if (handler == NULL)
return;
deleteHandlers(iter);
if (handler->flags.delete_pending) {
WMDeleteSelectionHandler(handler->view, handler->selection,
handler->timestamp);
}
}
static void
handleRequestEvent(XEvent *event)
{
SelectionHandler *handler;
WMBagIterator iter;
WMArrayIterator iter;
WMArray *copy;
Bool handledRequest = False;
WM_ITERATE_BAG(selHandlers, handler, iter) {
WM_ITERATE_ARRAY(selHandlers, handler, iter) {
switch (event->type) {
case SelectionClear:
@@ -285,33 +260,16 @@ handleRequestEvent(XEvent *event)
}
}
deleteHandlers(NULL);
}
static void
deleteCallbacks(WMBagIterator iter)
{
SelectionCallback *handler;
if (iter == NULL)
handler = WMBagFirst(selCallbacks, &iter);
else
handler = WMBagNext(selCallbacks, &iter);
if (handler == NULL)
return;
deleteCallbacks(iter);
if (handler->flags.delete_pending) {
WMDeleteSelectionCallback(handler->view, handler->selection,
/* delete handlers */
copy = WMDuplicateArray(selHandlers);
WM_ITERATE_ARRAY(copy, handler, iter) {
if (handler && handler->flags.delete_pending) {
WMDeleteSelectionHandler(handler->view, handler->selection,
handler->timestamp);
}
}
WMFreeArray(copy);
}
static WMData*
@@ -344,10 +302,11 @@ static void
handleNotifyEvent(XEvent *event)
{
SelectionCallback *handler;
WMBagIterator iter;
WMArrayIterator iter;
WMArray *copy;
WMData *data;
WM_ITERATE_BAG(selCallbacks, handler, iter) {
WM_ITERATE_ARRAY(selCallbacks, handler, iter) {
if (W_VIEW_DRAWABLE(handler->view) != event->xselection.requestor
&& handler->selection == event->xselection.selection) {
@@ -373,7 +332,16 @@ handleNotifyEvent(XEvent *event)
handler->flags.done_pending = 0;
handler->flags.delete_pending = 1;
}
deleteCallbacks(NULL);
/* delete callbacks */
copy = WMDuplicateArray(selCallbacks);
WM_ITERATE_ARRAY(copy, handler, iter) {
if (handler && handler->flags.delete_pending) {
WMDeleteSelectionCallback(handler->view, handler->selection,
handler->timestamp);
}
}
WMFreeArray(copy);
}
@@ -414,10 +382,10 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
memset(&handler->flags, 0, sizeof(handler->flags));
if (selHandlers == NULL) {
selHandlers = WMCreateTreeBag();
selHandlers = WMCreateArrayWithDestructor(4, wfree);
}
WMPutInBag(selHandlers, handler);
WMAddToArray(selHandlers, handler);
return True;
}
@@ -444,10 +412,10 @@ WMRequestSelection(WMView *view, Atom selection, Atom target, Time timestamp,
memset(&handler->flags, 0, sizeof(handler->flags));
if (selCallbacks == NULL) {
selCallbacks = WMCreateTreeBag();
selCallbacks = WMCreateArrayWithDestructor(4, wfree);
}
WMPutInBag(selCallbacks, handler);
WMAddToArray(selCallbacks, handler);
if (!XConvertSelection(W_VIEW_SCREEN(view)->display, selection, target,
W_VIEW_SCREEN(view)->clipboardAtom,

View File

@@ -71,13 +71,13 @@ WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
{
W_EventHandler *handler, *ptr;
unsigned long eventMask;
WMBagIterator iter;
WMArrayIterator iter;
handler = NULL;
eventMask = mask;
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
WM_ITERATE_ARRAY(view->eventHandlers, ptr, iter) {
if (ptr->clientData == clientData && ptr->proc == eventProc) {
handler = ptr;
eventMask |= ptr->eventMask;
@@ -86,7 +86,7 @@ WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
if (!handler) {
handler = wmalloc(sizeof(W_EventHandler));
WMPutInBag(view->eventHandlers, handler);
WMAddToArray(view->eventHandlers, handler);
}
/* select events for window */
handler->eventMask = eventMask;
@@ -95,6 +95,17 @@ WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
}
static int
matchHandler(void *item, void *cdata)
{
#define H1 ((W_EventHandler*)item)
#define H2 ((W_EventHandler*)cdata)
return (H1->eventMask==H2->eventMask && H1->proc==H2->proc &&
H1->clientData==H2->clientData);
}
/*
* WMDeleteEventHandler--
* Delete event handler matching arguments from windows
@@ -105,40 +116,13 @@ void
WMDeleteEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
void *clientData)
{
W_EventHandler *handler, *ptr;
WMBagIterator iter;
W_EventHandler tmp;
handler = NULL;
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
if (ptr->eventMask == mask && ptr->proc == eventProc
&& ptr->clientData == clientData) {
handler = ptr;
break;
tmp.eventMask = mask;
tmp.proc = eventProc;
tmp.clientData = clientData;
WMRemoveFromArrayMatching(view->eventHandlers, matchHandler, (void*)&tmp);
}
}
if (!handler)
return;
WMRemoveFromBag(view->eventHandlers, handler);
wfree(handler);
}
void
W_CleanUpEvents(WMView *view)
{
W_EventHandler *ptr;
WMBagIterator iter;
WM_ITERATE_BAG(view->eventHandlers, ptr, iter) {
wfree(ptr);
}
}
static Time
@@ -174,14 +158,15 @@ void
W_CallDestroyHandlers(W_View *view)
{
XEvent event;
WMBagIterator iter;
WMArrayIterator iter;
W_EventHandler *hPtr;
event.type = DestroyNotify;
event.xdestroywindow.window = view->window;
event.xdestroywindow.event = view->window;
WM_ITERATE_BAG(view->eventHandlers, hPtr, iter) {
WM_ITERATE_ARRAY(view->eventHandlers, hPtr, iter) {
if (hPtr->eventMask & StructureNotifyMask) {
(*hPtr->proc)(&event, hPtr->clientData);
}
@@ -208,9 +193,9 @@ WMRelayToNextResponder(WMView *view, XEvent *event)
if (view->nextResponder) {
WMView *next = view->nextResponder;
W_EventHandler *hPtr;
WMBagIterator iter;
WMArrayIterator iter;
WM_ITERATE_BAG(next->eventHandlers, hPtr, iter) {
WM_ITERATE_ARRAY(next->eventHandlers, hPtr, iter) {
if ((hPtr->eventMask & mask)) {
(*hPtr->proc)(event, hPtr->clientData);
}
@@ -226,7 +211,7 @@ WMHandleEvent(XEvent *event)
W_View *view, *vPtr, *toplevel;
unsigned long mask;
Window window;
WMBagIterator iter;
WMArrayIterator iter;
if (event->type == MappingNotify) {
XRefreshKeyboardMapping(&event->xmapping);
@@ -318,7 +303,7 @@ WMHandleEvent(XEvent *event)
* might destroy the widget. */
W_RetainView(toplevel);
WM_ITERATE_BAG(view->eventHandlers, hPtr, iter) {
WM_ITERATE_ARRAY(view->eventHandlers, hPtr, iter) {
if ((hPtr->eventMask & mask)) {
(*hPtr->proc)(event, hPtr->clientData);
}
@@ -331,7 +316,7 @@ WMHandleEvent(XEvent *event)
while (vPtr->parent != NULL)
vPtr = vPtr->parent;
WM_ITERATE_BAG(vPtr->eventHandlers, hPtr, iter) {
WM_ITERATE_ARRAY(vPtr->eventHandlers, hPtr, iter) {
if (hPtr->eventMask & mask) {
(*hPtr->proc)(event, hPtr->clientData);
}

View File

@@ -471,7 +471,7 @@ typedef struct {
char showSetWidth; /* when duplicated */
char showAddStyle; /* when duplicated */
WMBag *sizes;
WMArray *sizes;
} Typeface;
@@ -484,7 +484,7 @@ typedef struct {
char showFoundry; /* when duplicated */
char showRegistry; /* when duplicated */
WMBag *typefaces;
WMArray *typefaces;
} Family;
@@ -515,15 +515,15 @@ addSizeToTypeface(Typeface *face, int size)
for (j = 0; j < sizeof(scalableFontSizes)/sizeof(int); j++) {
size = scalableFontSizes[j];
if (!WMCountInBag(face->sizes, (void*)size)) {
WMPutInBag(face->sizes, (void*)size);
if (!WMCountInArray(face->sizes, (void*)size)) {
WMAddToArray(face->sizes, (void*)size);
}
}
WMSortBag(face->sizes, compare_int);
WMSortArray(face->sizes, compare_int);
} else {
if (!WMCountInBag(face->sizes, (void*)size)) {
WMPutInBag(face->sizes, (void*)size);
WMSortBag(face->sizes, compare_int);
if (!WMCountInArray(face->sizes, (void*)size)) {
WMAddToArray(face->sizes, (void*)size);
WMSortArray(face->sizes, compare_int);
}
}
}
@@ -534,12 +534,10 @@ static void
addTypefaceToFamily(Family *family, char fontFields[NUM_FIELDS][256])
{
Typeface *face;
WMBagIterator i;
WMArrayIterator i;
if (family->typefaces) {
for (face = WMBagFirst(family->typefaces, &i);
face != NULL;
face = WMBagNext(family->typefaces, &i)) {
WM_ITERATE_ARRAY(family->typefaces, face, i) {
int size;
if (strcmp(face->weight, fontFields[WEIGHT]) != 0) {
@@ -556,7 +554,7 @@ addTypefaceToFamily(Family *family, char fontFields[NUM_FIELDS][256])
return;
}
} else {
family->typefaces = WMCreateBag(4);
family->typefaces = WMCreateArray(4);
}
face = wmalloc(sizeof(Typeface));
@@ -567,16 +565,16 @@ addTypefaceToFamily(Family *family, char fontFields[NUM_FIELDS][256])
face->setWidth = wstrdup(fontFields[SETWIDTH]);
face->addStyle = wstrdup(fontFields[ADD_STYLE]);
face->sizes = WMCreateBag(4);
face->sizes = WMCreateArray(4);
addSizeToTypeface(face, atoi(fontFields[PIXEL_SIZE]));
WMPutInBag(family->typefaces, face);
WMAddToArray(family->typefaces, face);
}
/*
* families (same family name) (Hashtable of family -> bag)
* families (same family name) (Hashtable of family -> array)
* registries (same family but different registries)
*
*/
@@ -584,18 +582,16 @@ addTypefaceToFamily(Family *family, char fontFields[NUM_FIELDS][256])
static void
addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
{
WMBagIterator i;
WMArrayIterator i;
Family *fam;
WMBag *family;
WMArray *family;
family = WMHashGet(families, fontFields[FAMILY]);
if (family) {
/* look for same encoding/registry and foundry */
for (fam = WMBagFirst(family, &i);
fam != NULL;
fam = WMBagNext(family, &i)) {
WM_ITERATE_ARRAY(family, fam, i) {
int enc, reg, found;
enc = (strcmp(fam->encoding, fontFields[ENCODING]) == 0);
@@ -608,9 +604,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
}
}
/* look for same encoding/registry */
for (fam = WMBagFirst(family, &i);
fam != NULL;
fam = WMBagNext(family, &i)) {
WM_ITERATE_ARRAY(family, fam, i) {
int enc, reg;
enc = (strcmp(fam->encoding, fontFields[ENCODING]) == 0);
@@ -631,14 +625,12 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
addTypefaceToFamily(fam, fontFields);
WMPutInBag(family, fam);
WMAddToArray(family, fam);
return;
}
}
/* look for same foundry */
for (fam = WMBagFirst(family, &i);
fam != NULL;
fam = WMBagNext(family, &i)) {
WM_ITERATE_ARRAY(family, fam, i) {
int found;
found = (strcmp(fam->foundry, fontFields[FOUNDRY]) == 0);
@@ -658,7 +650,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
addTypefaceToFamily(fam, fontFields);
WMPutInBag(family, fam);
WMAddToArray(family, fam);
return;
}
}
@@ -675,11 +667,11 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
addTypefaceToFamily(fam, fontFields);
WMPutInBag(family, fam);
WMAddToArray(family, fam);
return;
}
family = WMCreateBag(8);
family = WMCreateArray(8);
fam = wmalloc(sizeof(Family));
memset(fam, 0, sizeof(Family));
@@ -691,7 +683,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256])
addTypefaceToFamily(fam, fontFields);
WMPutInBag(family, fam);
WMAddToArray(family, fam);
WMHashInsert(families, fam->name, family);
}
@@ -707,7 +699,7 @@ listFamilies(WMScreen *scr, WMFontPanel *panel)
WMHashTable *families = WMCreateHashTable(WMStringPointerHashCallbacks);
char fields[NUM_FIELDS][256];
WMHashEnumerator enumer;
WMBag *bag;
WMArray *array;
fontList = XListFonts(scr->display, ALL_FONTS_MASK, MAX_FONTS_TO_RETRIEVE,
&count);
@@ -739,16 +731,13 @@ listFamilies(WMScreen *scr, WMFontPanel *panel)
enumer = WMEnumerateHashTable(families);
while ((bag = WMNextHashEnumeratorItem(&enumer))) {
WMBagIterator i;
while ((array = WMNextHashEnumeratorItem(&enumer))) {
WMArrayIterator i;
Family *fam;
char buffer[256];
WMListItem *item;
for (fam = WMBagFirst(bag, &i);
fam != NULL;
fam = WMBagNext(bag, &i)) {
WM_ITERATE_ARRAY(array, fam, i) {
strcpy(buffer, fam->name);
if (fam->showFoundry) {
@@ -767,7 +756,8 @@ listFamilies(WMScreen *scr, WMFontPanel *panel)
item->clientData = fam;
}
WMFreeBag(bag);
/* Isn't this going to memleak since items weren't released? --Dan */
WMFreeArray(array);
}
WMSortListItems(panel->famLs);
@@ -835,7 +825,7 @@ familyClick(WMWidget *w, void *data)
Family *family;
FontPanel *panel = (FontPanel*)data;
Typeface *face;
WMBagIterator i;
WMArrayIterator i;
/* current typeface and size */
char *oface = NULL;
char *osize = NULL;
@@ -856,9 +846,7 @@ familyClick(WMWidget *w, void *data)
WMClearList(panel->typLs);
for (face = WMBagFirst(family->typefaces, &i);
face != NULL;
face = WMBagNext(family->typefaces, &i)) {
WM_ITERATE_ARRAY(family->typefaces, face, i) {
char buffer[256];
int top=0;
WMListItem *fitem;
@@ -933,12 +921,12 @@ typefaceClick(WMWidget *w, void *data)
FontPanel *panel = (FontPanel*)data;
WMListItem *item;
Typeface *face;
WMBagIterator i;
WMArrayIterator i;
char buffer[32];
char *osize = NULL;
int sizei = -1;
int size;
void *size;
osize = WMGetTextFieldText(panel->sizT);
@@ -948,12 +936,9 @@ typefaceClick(WMWidget *w, void *data)
WMClearList(panel->sizLs);
for (size = (int)WMBagFirst(face->sizes, &i);
i != NULL;
size = (int)WMBagNext(face->sizes, &i)) {
if (size != 0) {
sprintf(buffer, "%i", size);
WM_ITERATE_ARRAY(face->sizes, size, i) {
if ((int)size != 0) {
sprintf(buffer, "%i", (int)size);
WMAddListItem(panel->sizLs, buffer);
}

View File

@@ -14,7 +14,7 @@ typedef struct W_PopUpButton {
char *caption;
WMBag *items;
WMArray *items;
short selectedItemIndex;
@@ -91,7 +91,8 @@ WMCreatePopUpButton(WMWidget *parent)
bPtr->flags.enabled = 1;
bPtr->items = WMCreateBag(4);
bPtr->items =
WMCreateArrayWithDestructor(4, (WMFreeDataProc*)WMDestroyMenuItem);
bPtr->selectedItemIndex = -1;
@@ -128,7 +129,7 @@ WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title)
item = WMCreateMenuItem();
WMSetMenuItemTitle(item, title);
WMPutInBag(bPtr->items, item);
WMAddToArray(bPtr->items, item);
if (bPtr->menuView && bPtr->menuView->flags.realized)
resizeMenu(bPtr);
@@ -147,7 +148,7 @@ WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index, char *title)
item = WMCreateMenuItem();
WMSetMenuItemTitle(item, title);
WMInsertInBag(bPtr->items, index, item);
WMInsertInArray(bPtr->items, index, item);
/* if there is an selected item, update it's index to match the new
* position */
@@ -164,17 +165,12 @@ WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index, char *title)
void
WMRemovePopUpButtonItem(WMPopUpButton *bPtr, int index)
{
WMMenuItem *item;
CHECK_CLASS(bPtr, WC_PopUpButton);
wassertr(index >= 0 && index < WMGetBagItemCount(bPtr->items));
wassertr(index >= 0 && index < WMGetArrayItemCount(bPtr->items));
item = WMGetFromBag(bPtr->items, index);
WMDeleteFromBag(bPtr->items, index);
WMDestroyMenuItem(item);
WMDeleteFromArray(bPtr->items, index);
if (bPtr->selectedItemIndex >= 0 && !bPtr->flags.pullsDown) {
if (index < bPtr->selectedItemIndex)
@@ -213,9 +209,9 @@ void
WMSetPopUpButtonSelectedItem(WMPopUpButton *bPtr, int index)
{
wassertr(index < WMGetBagItemCount(bPtr->items));
wassertr(index < WMGetArrayItemCount(bPtr->items));
/* if (index >= WMGetBagCount(bPtr->items))
/* if (index >= WMGetArrayCount(bPtr->items))
index = -1;*/
bPtr->selectedItemIndex = index;
@@ -256,24 +252,14 @@ WMSetPopUpButtonText(WMPopUpButton *bPtr, char *text)
void
WMSetPopUpButtonItemEnabled(WMPopUpButton *bPtr, int index, Bool flag)
{
WMMenuItem *item;
item = WMGetFromBag(bPtr->items, index);
wassertr(item != NULL);
WMSetMenuItemEnabled(item, flag);
WMSetMenuItemEnabled(WMGetFromArray(bPtr->items, index), flag);
}
Bool
WMGetPopUpButtonItemEnabled(WMPopUpButton *bPtr, int index)
{
WMMenuItem *item;
item = WMGetFromBag(bPtr->items, index);
wassertrv(item != NULL, False);
return WMGetMenuItemEnabled(item);
return WMGetMenuItemEnabled(WMGetFromArray(bPtr->items, index));
}
@@ -293,34 +279,24 @@ WMSetPopUpButtonPullsDown(WMPopUpButton *bPtr, Bool flag)
int
WMGetPopUpButtonNumberOfItems(WMPopUpButton *bPtr)
{
return WMGetBagItemCount(bPtr->items);
return WMGetArrayItemCount(bPtr->items);
}
char*
WMGetPopUpButtonItem(WMPopUpButton *bPtr, int index)
{
WMMenuItem *item;
if (index >= WMGetBagItemCount(bPtr->items) || index < 0)
if (index >= WMGetArrayItemCount(bPtr->items) || index < 0)
return NULL;
item = WMGetFromBag(bPtr->items, index);
if (item == NULL)
return NULL;
return WMGetMenuItemTitle(item);
return WMGetMenuItemTitle(WMGetFromArray(bPtr->items, index));
}
WMMenuItem*
WMGetPopUpButtonMenuItem(WMPopUpButton *bPtr, int index)
{
WMMenuItem *item;
item = WMGetFromBag(bPtr->items, index);
return item;
return WMGetFromArray(bPtr->items, index);
}
@@ -419,7 +395,7 @@ paintMenuEntry(PopUpButton *bPtr, int index, int highlight)
int width, height, itemHeight, itemCount;
char *title;
itemCount = WMGetBagItemCount(bPtr->items);
itemCount = WMGetArrayItemCount(bPtr->items);
if (index < 0 || index >= itemCount)
return;
@@ -464,13 +440,13 @@ makeMenuPixmap(PopUpButton *bPtr)
Pixmap pixmap;
W_Screen *scr = bPtr->view->screen;
WMMenuItem *item;
WMBagIterator iter;
WMArrayIterator iter;
int yo, i;
int width, height, itemHeight;
itemHeight = bPtr->view->size.height;
width = bPtr->view->size.width;
height = itemHeight * WMGetBagItemCount(bPtr->items);
height = itemHeight * WMGetArrayItemCount(bPtr->items);
yo = (itemHeight - WMFontHeight(scr->normalFont))/2;
pixmap = XCreatePixmap(scr->display, bPtr->view->window, width, height,
@@ -480,7 +456,7 @@ makeMenuPixmap(PopUpButton *bPtr)
width, height);
i = 0;
WM_ITERATE_BAG(bPtr->items, item, iter) {
WM_ITERATE_ARRAY(bPtr->items, item, iter) {
GC gc;
char *text;
@@ -518,7 +494,7 @@ resizeMenu(PopUpButton *bPtr)
{
int height;
height = WMGetBagItemCount(bPtr->items) * bPtr->view->size.height;
height = WMGetArrayItemCount(bPtr->items) * bPtr->view->size.height;
if (height > 0)
W_ResizeView(bPtr->menuView, bPtr->view->size.width, height);
}
@@ -539,7 +515,7 @@ popUpMenu(PopUpButton *bPtr)
resizeMenu(bPtr);
}
if (WMGetBagItemCount(bPtr->items) < 1)
if (WMGetArrayItemCount(bPtr->items) < 1)
return;
XTranslateCoordinates(scr->display, bPtr->view->window, scr->rootWin,
@@ -619,7 +595,7 @@ autoScroll(void *data)
paintMenuEntry(bPtr, oldItem, False);
if (bPtr->highlightedItem >= 0 &&
bPtr->highlightedItem < WMGetBagItemCount(bPtr->items)) {
bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) {
item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem);
paintMenuEntry(bPtr, bPtr->highlightedItem,
WMGetMenuItemEnabled(item));
@@ -653,7 +629,7 @@ wheelScrollUp(PopUpButton *bPtr)
static void
wheelScrollDown(PopUpButton *bPtr)
{
int itemCount = WMGetBagItemCount(bPtr->items);
int itemCount = WMGetArrayItemCount(bPtr->items);
int testIndex = bPtr->selectedItemIndex + 1;
while (testIndex<itemCount && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
@@ -675,7 +651,7 @@ handleActionEvents(XEvent *event, void *data)
CHECK_CLASS(data, WC_PopUpButton);
if (WMGetBagItemCount(bPtr->items) < 1)
if (WMGetArrayItemCount(bPtr->items) < 1)
return;
switch (event->type) {
@@ -704,7 +680,7 @@ handleActionEvents(XEvent *event, void *data)
paintMenuEntry(bPtr, oldItem, False);
if (bPtr->highlightedItem >= 0 &&
bPtr->highlightedItem < WMGetBagItemCount(bPtr->items)) {
bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) {
item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem);
paintMenuEntry(bPtr, bPtr->highlightedItem,
WMGetMenuItemEnabled(item));
@@ -807,16 +783,12 @@ static void
destroyPopUpButton(PopUpButton *bPtr)
{
WMMenuItem *item;
WMBagIterator i;
if (bPtr->timer) {
WMDeleteTimerHandler(bPtr->timer);
}
WM_ITERATE_BAG(bPtr->items, item, i) {
WMDestroyMenuItem(item);
}
WMFreeBag(bPtr->items);
WMFreeArray(bPtr->items);
if (bPtr->caption)
wfree(bPtr->caption);

View File

@@ -11,20 +11,20 @@ char *WMSplitViewWillResizeSubviewsNotification
= "WMSplitViewWillResizeSubviewsNotification";
*/
typedef struct _T_SplitViewSubview {
typedef struct W_SplitViewSubview {
WMView *view;
int minSize;
int maxSize;
int size;
int pos;
} T_SplitViewSubview;
} W_SplitViewSubview;
typedef struct W_SplitView {
W_Class widgetClass;
W_View *view;
WMBag *subviewsBag;
WMArray *subviews;
WMSplitViewConstrainProc *constrainProc;
@@ -36,7 +36,7 @@ typedef struct W_SplitView {
/* WMSplitViewResizeSubviewsProc *resizeSubviewsProc; */
} SplitView;
} W_SplitView;
#define DIVIDER_THICKNESS 8
@@ -44,41 +44,42 @@ typedef struct W_SplitView {
#define MAX_SUBVIEW_SIZE -1
#define _GetSubviewsCount() WMGetBagItemCount(sPtr->subviewsBag)
/* TODO: rewrite --Dan */
#define _GetSubviewsCount() WMGetArrayItemCount(sPtr->subviews)
#define _AddPSubviewStruct(P) \
(WMPutInBag(sPtr->subviewsBag,((void*)P)))
(WMAddToArray(sPtr->subviews,((void*)P)))
#define _GetPSubviewStructAt(i) \
((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))
((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))
#define _GetSubviewAt(i) \
(((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))->view)
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view)
#define _GetMinSizeAt(i) \
(((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))->minSize)
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize)
#define _GetMaxSizeAt(i) \
(((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))->maxSize)
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize)
#define _GetSizeAt(i) \
(((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))->size)
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size)
#define _GetPosAt(i) \
(((T_SplitViewSubview*)WMGetFromBag(sPtr->subviewsBag,(i)))->pos)
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos)
#define _GetSplitViewSize() \
((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height)
static void destroySplitView(SplitView *sPtr);
static void paintSplitView(SplitView *sPtr);
static void destroySplitView(WMSplitView *sPtr);
static void paintSplitView(WMSplitView *sPtr);
static void handleEvents(XEvent *event, void *data);
static void handleActionEvents(XEvent *event, void *data);
static void
getConstraints(SplitView *sPtr, int index, int *minSize, int *maxSize)
getConstraints(WMSplitView *sPtr, int index, int *minSize, int *maxSize)
{
*minSize = MIN_SUBVIEW_SIZE;
*maxSize = MAX_SUBVIEW_SIZE;
@@ -97,9 +98,9 @@ getConstraints(SplitView *sPtr, int index, int *minSize, int *maxSize)
static void
updateConstraints(SplitView *sPtr)
updateConstraints(WMSplitView *sPtr)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count;
count = _GetSubviewsCount();
@@ -111,7 +112,7 @@ updateConstraints(SplitView *sPtr)
static void
resizeView(SplitView *sPtr, WMView *view, int size)
resizeView(WMSplitView *sPtr, WMView *view, int size)
{
int width, height;
@@ -131,7 +132,7 @@ resizeView(SplitView *sPtr, WMView *view, int size)
static void
reparentView(SplitView *sPtr, WMView *view, int pos)
reparentView(WMSplitView *sPtr, WMView *view, int pos)
{
int x, y;
@@ -148,7 +149,7 @@ reparentView(SplitView *sPtr, WMView *view, int pos)
static void
moveView(SplitView *sPtr, WMView *view, int pos)
moveView(WMSplitView *sPtr, WMView *view, int pos)
{
int x, y;
@@ -168,10 +169,10 @@ moveView(SplitView *sPtr, WMView *view, int pos)
static int
checkSizes(SplitView *sPtr)
checkSizes(WMSplitView *sPtr)
{
int i, count, offset;
T_SplitViewSubview *p;
W_SplitViewSubview *p;
count = _GetSubviewsCount();
offset = 0;
@@ -191,10 +192,10 @@ checkSizes(SplitView *sPtr)
static void
checkPositions(SplitView *sPtr)
checkPositions(WMSplitView *sPtr)
{
int i, count, pos;
T_SplitViewSubview *p;
W_SplitViewSubview *p;
count = _GetSubviewsCount();
pos = 0;
@@ -207,10 +208,10 @@ checkPositions(SplitView *sPtr)
static void
updateSubviewsGeom(SplitView *sPtr)
updateSubviewsGeom(WMSplitView *sPtr)
{
int i, count;
T_SplitViewSubview *p;
W_SplitViewSubview *p;
count = _GetSubviewsCount();
for (i = 0; i < count; i++) {
@@ -222,7 +223,7 @@ updateSubviewsGeom(SplitView *sPtr)
static int
getTotalSize(SplitView *sPtr)
getTotalSize(WMSplitView *sPtr)
{
int i, count, totSize;
@@ -239,9 +240,9 @@ getTotalSize(SplitView *sPtr)
static Bool
distributeOffsetEqually(SplitView *sPtr, int offset)
distributeOffsetEqually(WMSplitView *sPtr, int offset)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count, sizeChanged, forced;
if ((count = _GetSubviewsCount()) < 1)
@@ -280,9 +281,9 @@ distributeOffsetEqually(SplitView *sPtr, int offset)
static Bool
distributeOffsetFormEnd(SplitView *sPtr, int offset)
distributeOffsetFormEnd(WMSplitView *sPtr, int offset)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count, sizeTmp;
if ((count = _GetSubviewsCount()) < 1)
@@ -312,7 +313,7 @@ distributeOffsetFormEnd(SplitView *sPtr, int offset)
static void
adjustSplitViewSubviews(WMSplitView *sPtr)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count, adjSize, adjPad;
CHECK_CLASS(sPtr, WC_SplitView);
@@ -349,12 +350,12 @@ adjustSplitViewSubviews(WMSplitView *sPtr)
static void
handleSubviewResized(void *self, WMNotification *notif)
{
SplitView *sPtr = (SplitView*)self;
WMSplitView *sPtr = (WMSplitView*)self;
CHECK_CLASS(sPtr, WC_SplitView);
if (WMGetNotificationName(notif) == WMViewSizeDidChangeNotification) {
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count, done;
WMView *view = WMGetNotificationObject(notif);
@@ -380,7 +381,7 @@ handleSubviewResized(void *self, WMNotification *notif)
static void
handleViewResized(void *self, WMNotification *notification)
{
SplitView *sPtr = (SplitView*)self;
WMSplitView *sPtr = (WMSplitView*)self;
#if 0
printf("---- (handleViewResized - 1) ----\n");
@@ -407,9 +408,9 @@ handleViewResized(void *self, WMNotification *notification)
static void
paintSplitView(SplitView *sPtr)
paintSplitView(WMSplitView *sPtr)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
W_Screen *scr = sPtr->view->screen;
int x, y, i, count;
WMPixmap *dimple = scr->scrollerDimple;
@@ -469,7 +470,7 @@ paintSplitView(SplitView *sPtr)
static void
drawDragingRectangle(SplitView *sPtr, int pos)
drawDragingRectangle(WMSplitView *sPtr, int pos)
{
int x, y, w, h;
@@ -491,7 +492,7 @@ drawDragingRectangle(SplitView *sPtr, int pos)
static void
getMinMaxDividerCoord(SplitView *sPtr, int divider, int *minC, int *maxC)
getMinMaxDividerCoord(WMSplitView *sPtr, int divider, int *minC, int *maxC)
{
int relMinC, relMaxC;
int totSize = _GetSizeAt(divider) + _GetSizeAt(divider+1);
@@ -512,7 +513,7 @@ getMinMaxDividerCoord(SplitView *sPtr, int divider, int *minC, int *maxC)
static void
dragDivider(SplitView *sPtr, int clickX, int clickY)
dragDivider(WMSplitView *sPtr, int clickX, int clickY)
{
int divider, pos, ofs, done, dragging;
int i, count;
@@ -585,7 +586,7 @@ dragDivider(SplitView *sPtr, int clickX, int clickY)
}
if (dragging) {
T_SplitViewSubview *p1, *p2;
W_SplitViewSubview *p1, *p2;
int totSize;
p1 = _GetPSubviewStructAt(divider);
@@ -608,7 +609,7 @@ dragDivider(SplitView *sPtr, int clickX, int clickY)
static void
handleEvents(XEvent *event, void *data)
{
SplitView *sPtr = (SplitView*)data;
WMSplitView *sPtr = (WMSplitView*)data;
CHECK_CLASS(data, WC_SplitView);
@@ -644,14 +645,9 @@ handleActionEvents(XEvent *event, void *data)
static void
destroySplitView(SplitView *sPtr)
destroySplitView(WMSplitView *sPtr)
{
int i, count;
count = _GetSubviewsCount();
for (i = 0; i < count; i++)
wfree(WMGetFromBag(sPtr->subviewsBag, i));
WMFreeBag(sPtr->subviewsBag);
WMFreeArray(sPtr->subviews);
WMRemoveNotificationObserver(sPtr);
@@ -661,10 +657,10 @@ destroySplitView(SplitView *sPtr)
WMSplitView*
WMCreateSplitView(WMWidget *parent)
{
SplitView *sPtr;
WMSplitView *sPtr;
sPtr = wmalloc(sizeof(SplitView));
memset(sPtr, 0, sizeof(SplitView));
sPtr = wmalloc(sizeof(WMSplitView));
memset(sPtr, 0, sizeof(WMSplitView));
sPtr->widgetClass = WC_SplitView;
@@ -689,7 +685,7 @@ WMCreateSplitView(WMWidget *parent)
WMAddNotificationObserver(handleViewResized, sPtr,
WMViewSizeDidChangeNotification, sPtr->view);
sPtr->subviewsBag = WMCreateBag(8);
sPtr->subviews = WMCreateArrayWithDestructor(8, wfree);
return sPtr;
}
@@ -712,11 +708,11 @@ void
WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview)
{
int wasMapped, count;
T_SplitViewSubview *p;
W_SplitViewSubview *p;
CHECK_CLASS(sPtr, WC_SplitView);
if (!(p = (T_SplitViewSubview*)wmalloc(sizeof(T_SplitViewSubview))))
if (!(p = (W_SplitViewSubview*)wmalloc(sizeof(W_SplitViewSubview))))
return;
wasMapped = subview->flags.mapped;
@@ -731,7 +727,7 @@ WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview)
else
p->size = subview->size.height;
WMPutInBag(sPtr->subviewsBag,(void*)p);
WMAddToArray(sPtr->subviews, p);
reparentView(sPtr, subview, 0);
/*
@@ -772,17 +768,17 @@ WMGetSplitViewSubviewAt(WMSplitView *sPtr, int index)
void
WMRemoveSplitViewSubview(WMSplitView *sPtr, WMView *view)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
int i, count;
CHECK_CLASS(sPtr, WC_SplitView);
/* TODO: rewrite this. This code with macros is getting more complex than it worths */
count = _GetSubviewsCount();
for (i = 0; i < count; i++) {
p = _GetPSubviewStructAt(i);
if (p->view == view) {
wfree(p);
WMDeleteFromBag(sPtr->subviewsBag, i);
WMDeleteFromArray(sPtr->subviews, i);
sPtr->flags.adjustOnPaint = 1;
paintSplitView(sPtr);
break;
@@ -794,14 +790,14 @@ WMRemoveSplitViewSubview(WMSplitView *sPtr, WMView *view)
void
WMRemoveSplitViewSubviewAt(WMSplitView *sPtr, int index)
{
T_SplitViewSubview *p;
W_SplitViewSubview *p;
CHECK_CLASS(sPtr, WC_SplitView);
/* TODO: same about rewrite */
if (index >= 0 && index < _GetSubviewsCount()) {
p = _GetPSubviewStructAt(index);
wfree(p);
WMDeleteFromBag(sPtr->subviewsBag, index);
WMDeleteFromArray(sPtr->subviews, index);
sPtr->flags.adjustOnPaint = 1;
paintSplitView(sPtr);
}

View File

@@ -132,7 +132,7 @@ createView(W_Screen *screen, W_View *parent)
view->refCount = 1;
view->eventHandlers = WMCreateBag(4);
view->eventHandlers = WMCreateArrayWithDestructor(4, wfree);
return view;
}
@@ -441,9 +441,8 @@ destroyView(W_View *view)
/* remove self from parent's children list */
unparentView(view);
W_CleanUpEvents(view);
WMFreeBag(view->eventHandlers);
/* the array has a wfree() destructor that will be called automatically */
WMFreeArray(view->eventHandlers);
view->eventHandlers = NULL;
WMUnregisterViewDraggedTypes(view);

View File

@@ -56,7 +56,7 @@ typedef struct W_EditMenu {
struct W_EditMenu *parent;
WMBag *items; /* EditMenuItem */
WMArray *items; /* EditMenuItem */
EditMenuItem *selectedItem;
@@ -457,7 +457,7 @@ makeEditMenu(WMScreen *scr, WMWidget *parent, char *title)
WMAddNotificationObserver(itemSelectObserver, mPtr,
"EditMenuItemSelected", NULL);
mPtr->items = WMCreateBag(4);
mPtr->items = WMCreateArray(4);
WMCreateEventHandler(mPtr->view, ExposureMask|StructureNotifyMask,
handleEvents, mPtr);
@@ -467,7 +467,7 @@ makeEditMenu(WMScreen *scr, WMWidget *parent, char *title)
item = WCreateEditMenuItem(mPtr, title, True);
WMMapWidget(item);
WMPutInBag(mPtr->items, item);
WMAddToArray(mPtr->items, item);
mPtr->flags.isTitled = 1;
}
@@ -511,14 +511,14 @@ WInsertMenuItemWithTitle(WEditMenu *mPtr, int index, char *title)
WMMapWidget(item);
if (index >= WMGetBagItemCount(mPtr->items)) {
WMPutInBag(mPtr->items, item);
if (index >= WMGetArrayItemCount(mPtr->items)) {
WMAddToArray(mPtr->items, item);
} else {
if (index < 0)
index = 0;
if (mPtr->flags.isTitled)
index++;
WMInsertInBag(mPtr->items, index, item);
WMInsertInArray(mPtr->items, index, item);
}
updateMenuContents(mPtr);
@@ -530,17 +530,17 @@ WInsertMenuItemWithTitle(WEditMenu *mPtr, int index, char *title)
WEditMenuItem*
WGetEditMenuItem(WEditMenu *mPtr, int index)
{
if (index >= WMGetBagItemCount(mPtr->items))
if (index >= WMGetArrayItemCount(mPtr->items))
return NULL;
else
return WMGetFromBag(mPtr->items, index + (mPtr->flags.isTitled ? 1 : 0));
return WMGetFromArray(mPtr->items, index + (mPtr->flags.isTitled ? 1 : 0));
}
WEditMenuItem*
WAddMenuItemWithTitle(WEditMenu *mPtr, char *title)
{
return WInsertMenuItemWithTitle(mPtr, WMGetBagItemCount(mPtr->items),
return WInsertMenuItemWithTitle(mPtr, WMGetArrayItemCount(mPtr->items),
title);
}
@@ -551,7 +551,7 @@ WSetEditMenuTitle(WEditMenu *mPtr, char *title)
{
WEditMenuItem *item;
item = WMGetFromBag(mPtr->items, 0);
item = WMGetFromArray(mPtr->items, 0);
wfree(item->label);
item->label = wstrdup(title);
@@ -568,7 +568,7 @@ WGetEditMenuTitle(WEditMenu *mPtr)
{
WEditMenuItem *item;
item = WMGetFromBag(mPtr->items, 0);
item = WMGetFromArray(mPtr->items, 0);
return item->label;
}
@@ -598,28 +598,13 @@ WGetEditMenuSubmenu(WEditMenu *mPtr, WEditMenuItem *item)
}
static int
simpleMatch(void *a, void *b)
{
return ((a == b) ? 1 : 0);
}
void
WRemoveEditMenuItem(WEditMenu *mPtr, WEditMenuItem *item)
{
int index;
index = WMFindInBag(mPtr->items, simpleMatch, item);
if (index == WBNotFound) {
return;
}
WMDeleteFromBag(mPtr->items, index);
if (WMRemoveFromArray(mPtr->items, item) != 0) {
updateMenuContents(mPtr);
}
}
void
@@ -662,7 +647,7 @@ WSetEditMenuMaxSize(WEditMenu *mPtr, WMSize size)
WMPoint
WGetEditMenuLocationForSubmenu(WEditMenu *mPtr, WEditMenu *submenu)
{
WMBagIterator iter;
WMArrayIterator iter;
WEditMenuItem *item;
int y;
@@ -670,7 +655,7 @@ WGetEditMenuLocationForSubmenu(WEditMenu *mPtr, WEditMenu *submenu)
y = -mPtr->titleHeight;
else
y = 0;
WM_ITERATE_BAG(mPtr->items, item, iter) {
WM_ITERATE_ARRAY(mPtr->items, item, iter) {
if (item->submenu == submenu) {
WMPoint pt = WMGetViewScreenPosition(mPtr->view);
@@ -705,7 +690,7 @@ WTearOffEditMenu(WEditMenu *menu, WEditMenu *submenu)
submenu->flags.isTornOff = 1;
item = (WEditMenuItem*)WMGetFromBag(submenu->items, 0);
item = (WEditMenuItem*)WMGetFromArray(submenu->items, 0);
submenu->closeB = WMCreateCommandButton(item);
WMResizeWidget(submenu->closeB, 15, 15);
@@ -802,14 +787,14 @@ updateMenuContents(WEditMenu *mPtr)
int i;
int iheight = mPtr->itemHeight;
int offs = 1;
WMBagIterator iter;
WMArrayIterator iter;
WEditMenuItem *item;
newW = 0;
newH = offs;
i = 0;
WM_ITERATE_BAG(mPtr->items, item, iter) {
WM_ITERATE_ARRAY(mPtr->items, item, iter) {
w = getItemTextWidth(item);
newW = WMAX(w, newW);
@@ -847,7 +832,7 @@ updateMenuContents(WEditMenu *mPtr)
newW -= 2*offs;
i = 0;
WM_ITERATE_BAG(mPtr->items, item, iter) {
WM_ITERATE_ARRAY(mPtr->items, item, iter) {
if (i == 0 && mPtr->flags.isTitled) {
WMResizeWidget(item, newW, mPtr->titleHeight);
} else {
@@ -999,8 +984,8 @@ textEndedEditing(struct WMTextFieldDelegate *self, WMNotification *notif)
case WMTabTextMovement:
stopEditItem(menu, True);
i = WMFindInBag(menu->items, simpleMatch, menu->selectedItem);
item = WMGetFromBag(menu->items, i+1);
i = WMGetFirstInArray(menu->items, menu->selectedItem);
item = WMGetFromArray(menu->items, i+1);
if (item != NULL) {
selectItem(menu, item);
editItemLabel(item);
@@ -1010,8 +995,8 @@ textEndedEditing(struct WMTextFieldDelegate *self, WMNotification *notif)
case WMBacktabTextMovement:
stopEditItem(menu, True);
i = WMFindInBag(menu->items, simpleMatch, menu->selectedItem);
item = WMGetFromBag(menu->items, i-1);
i = WMGetFirstInArray(menu->items, menu->selectedItem);
item = WMGetFromArray(menu->items, i-1);
if (item != NULL) {
selectItem(menu, item);
editItemLabel(item);
@@ -1037,7 +1022,6 @@ editItemLabel(WEditMenuItem *item)
{
WEditMenu *mPtr = item->parent;
WMTextField *tf;
int i;
if (!mPtr->flags.isEditable) {
return;
@@ -1058,8 +1042,6 @@ editItemLabel(WEditMenuItem *item)
}
tf = mPtr->tfield;
i = WMFindInBag(mPtr->items, simpleMatch, item);
WMSetTextFieldText(tf, item->label);
WMSelectTextFieldRange(tf, wmkrange(0, strlen(item->label)));
WMResizeWidget(tf, mPtr->view->size.width, mPtr->itemHeight);
@@ -1210,10 +1192,10 @@ handleItemDrop(WEditMenu *menu, WEditMenuItem *item, int x, int y)
index++;
}
if (index > WMGetBagItemCount(menu->items)) {
WMPutInBag(menu->items, item);
if (index > WMGetArrayItemCount(menu->items)) {
WMAddToArray(menu->items, item);
} else {
WMInsertInBag(menu->items, index, item);
WMInsertInArray(menu->items, index, item);
}
W_ReparentView(item->view, menu->view, 0, index*menu->itemHeight);
@@ -1300,7 +1282,7 @@ duplicateMenu(WEditMenu *menu)
{
WEditMenu *nmenu;
WEditMenuItem *item;
WMBagIterator iter;
WMArrayIterator iter;
Bool first = menu->flags.isTitled;
nmenu = WCreateEditMenu(WMWidgetScreen(menu), WGetEditMenuTitle(menu));
@@ -1308,7 +1290,7 @@ duplicateMenu(WEditMenu *menu)
memcpy(&nmenu->flags, &menu->flags, sizeof(menu->flags));
nmenu->delegate = menu->delegate;
WM_ITERATE_BAG(menu->items, item, iter) {
WM_ITERATE_ARRAY(menu->items, item, iter) {
WEditMenuItem *nitem;
if (first) {
@@ -1536,17 +1518,17 @@ static void
destroyEditMenu(WEditMenu *mPtr)
{
WEditMenuItem *item;
WMBagIterator iter;
WMArrayIterator iter;
WMRemoveNotificationObserver(mPtr);
WM_ITERATE_BAG(mPtr->items, item, iter) {
WM_ITERATE_ARRAY(mPtr->items, item, iter) {
if (item->submenu) {
WMDestroyWidget(item->submenu);
}
}
WMFreeBag(mPtr->items);
WMFreeArray(mPtr->items);
wfree(mPtr->tdelegate);

View File

@@ -58,7 +58,7 @@ struct _ImageBrowser {
ImageBrowserDelegate *delegate;
WMBag *previews;
WMArray *previews;
};

View File

@@ -1699,8 +1699,8 @@ wSelectWindow(WWindow *wwin, Bool flag)
}
if (!scr->selected_windows)
scr->selected_windows = WMCreateBag(4);
WMPutInBag(scr->selected_windows, wwin);
scr->selected_windows = WMCreateArray(4);
WMAddToArray(scr->selected_windows, wwin);
} else {
wwin->flags.selected = 0;
XSetWindowBorder(dpy, wwin->frame->core->window,
@@ -1711,7 +1711,7 @@ wSelectWindow(WWindow *wwin, Bool flag)
}
if (scr->selected_windows) {
WMRemoveFromBag(scr->selected_windows, wwin);
WMRemoveFromArray(scr->selected_windows, wwin);
}
}
}

View File

@@ -292,17 +292,17 @@ numberOfSelectedIcons(WDock *dock)
}
static WMBag*
static WMArray*
getSelected(WDock *dock)
{
WMBag *ret = WMCreateBag(8);
WMArray *ret = WMCreateArray(8);
WAppIcon *btn;
int i;
for (i=1; i<dock->max_icons; i++) {
btn = dock->icon_array[i];
if (btn && btn->icon->selected) {
WMPutInBag(ret, btn);
WMAddToArray(ret, btn);
}
}
@@ -461,9 +461,9 @@ omnipresentCallback(WMenu *menu, WMenuEntry *entry)
WAppIcon *clickedIcon = entry->clientdata;
WAppIcon *aicon;
WDock *dock;
WMBag *selectedIcons;
WMArray *selectedIcons;
WMArrayIterator iter;
int failed;
int i;
assert(entry->clientdata!=NULL);
@@ -471,19 +471,17 @@ omnipresentCallback(WMenu *menu, WMenuEntry *entry)
selectedIcons = getSelected(dock);
if (!WMGetBagItemCount(selectedIcons))
WMPutInBag(selectedIcons, clickedIcon);
if (!WMGetArrayItemCount(selectedIcons))
WMAddToArray(selectedIcons, clickedIcon);
failed = 0;
for (i = 0; i < WMGetBagItemCount(selectedIcons); i++) {
aicon = WMGetFromBag(selectedIcons, i);
WM_ITERATE_ARRAY(selectedIcons, aicon, iter) {
if (wClipMakeIconOmnipresent(aicon, !aicon->omnipresent) == WO_FAILED)
failed++;
else if (aicon->icon->selected)
wIconSelect(aicon->icon);
}
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
if (failed > 1) {
wMessageDialog(dock->screen_ptr, _("Warning"),
@@ -511,9 +509,9 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry)
WAppIcon *clickedIcon = (WAppIcon*)entry->clientdata;
WDock *dock;
WAppIcon *aicon;
WMBag *selectedIcons;
WMArray *selectedIcons;
int keepit;
WMBagIterator it;
WMArrayIterator it;
assert(clickedIcon!=NULL);
@@ -521,22 +519,22 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry)
selectedIcons = getSelected(dock);
if (WMGetBagItemCount(selectedIcons)) {
if (WMGetArrayItemCount(selectedIcons)) {
if (wMessageDialog(dock->screen_ptr, _("Workspace Clip"),
_("All selected icons will be removed!"),
_("OK"), _("Cancel"), NULL)!=WAPRDefault) {
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
return;
}
} else {
if (clickedIcon->xindex==0 && clickedIcon->yindex==0) {
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
return;
}
WMPutInBag(selectedIcons, clickedIcon);
WMAddToArray(selectedIcons, clickedIcon);
}
WM_ITERATE_BAG(selectedIcons, aicon, it) {
WM_ITERATE_ARRAY(selectedIcons, aicon, it) {
keepit = aicon->running && wApplicationOf(aicon->main_window);
wDockDetach(dock, aicon);
if (keepit) {
@@ -547,7 +545,7 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry)
XMapWindow(dpy, aicon->icon->core->window);
}
}
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
if (wPreferences.auto_arrange_icons)
wArrangeIcons(dock->screen_ptr, True);
@@ -560,15 +558,15 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry)
WAppIcon *clickedIcon = (WAppIcon*)entry->clientdata;
WDock *dock;
WAppIcon *aicon;
WMBag *selectedIcons;
WMBagIterator it;
WMArray *selectedIcons;
WMArrayIterator it;
assert(clickedIcon!=NULL);
dock = clickedIcon->dock;
selectedIcons = getSelected(dock);
if (!WMGetBagItemCount(selectedIcons)
if (!WMGetArrayItemCount(selectedIcons)
&& clickedIcon!=dock->screen_ptr->clip_icon) {
char *command = NULL;
@@ -588,15 +586,15 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry)
clickedIcon->editing = 0;
if (command)
wfree(command);
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
return;
}
}
WMPutInBag(selectedIcons, clickedIcon);
WMAddToArray(selectedIcons, clickedIcon);
}
WM_ITERATE_BAG(selectedIcons, aicon, it) {
WM_ITERATE_ARRAY(selectedIcons, aicon, it) {
if (aicon->icon->selected)
wIconSelect(aicon->icon);
if (aicon && aicon->attracted && aicon->command) {
@@ -608,7 +606,7 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry)
}
}
}
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
}
@@ -695,7 +693,8 @@ selectIconsCallback(WMenu *menu, WMenuEntry *entry)
{
WAppIcon *clickedIcon = (WAppIcon*)entry->clientdata;
WDock *dock;
WMBag *selectedIcons;
WMArray *selectedIcons;
WMArrayIterator iter;
WAppIcon *btn;
int i;
@@ -704,7 +703,7 @@ selectIconsCallback(WMenu *menu, WMenuEntry *entry)
selectedIcons = getSelected(dock);
if (!WMGetBagItemCount(selectedIcons)) {
if (!WMGetArrayItemCount(selectedIcons)) {
for (i=1; i<dock->max_icons; i++) {
btn = dock->icon_array[i];
if (btn && !btn->icon->selected) {
@@ -712,12 +711,11 @@ selectIconsCallback(WMenu *menu, WMenuEntry *entry)
}
}
} else {
for (i = 0; i < WMGetBagItemCount(selectedIcons); i++) {
btn = WMGetFromBag(selectedIcons, i);
WM_ITERATE_ARRAY(selectedIcons, btn, iter) {
wIconSelect(btn->icon);
}
}
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
wMenuPaint(menu);
}
@@ -861,7 +859,7 @@ switchWSCommand(WMenu *menu, WMenuEntry *entry)
WAppIcon *btn, *icon = (WAppIcon*) entry->clientdata;
WScreen *scr = icon->icon->core->screen_ptr;
WDock *src, *dest;
WMBag *selectedIcons;
WMArray *selectedIcons;
int x, y;
if (entry->order == scr->current_workspace)
@@ -871,10 +869,10 @@ switchWSCommand(WMenu *menu, WMenuEntry *entry)
selectedIcons = getSelected(src);
if (WMGetBagItemCount(selectedIcons)) {
int i;
for (i = 0; i < WMGetBagItemCount(selectedIcons); i++) {
btn = WMGetFromBag(selectedIcons, i);
if (WMGetArrayItemCount(selectedIcons)) {
WMArrayIterator iter;
WM_ITERATE_ARRAY(selectedIcons, btn, iter) {
if (wDockFindFreeSlot(dest, &x, &y)) {
moveIconBetweenDocks(src, dest, btn, x, y);
XUnmapWindow(dpy, btn->icon->core->window);
@@ -886,7 +884,7 @@ switchWSCommand(WMenu *menu, WMenuEntry *entry)
XUnmapWindow(dpy, icon->icon->core->window);
}
}
WMFreeBag(selectedIcons);
WMFreeArray(selectedIcons);
}

View File

@@ -156,7 +156,7 @@ typedef struct DeathHandler {
void *client_data;
} DeathHandler;
static WMBag *deathHandlers=NULL;
static WMArray *deathHandlers=NULL;
@@ -174,9 +174,9 @@ wAddDeathHandler(pid_t pid, WDeathHandler *callback, void *cdata)
handler->client_data = cdata;
if (!deathHandlers)
deathHandlers = WMCreateBag(8);
deathHandlers = WMCreateArrayWithDestructor(8, wfree);
WMPutInBag(deathHandlers, handler);
WMAddToArray(deathHandlers, handler);
return handler;
}
@@ -191,9 +191,8 @@ wDeleteDeathHandler(WMagicNumber id)
if (!handler || !deathHandlers)
return;
WMRemoveFromBag(deathHandlers, handler);
wfree(handler);
/* array destructor will call wfree(handler) */
WMRemoveFromArray(deathHandlers, handler);
}
@@ -384,8 +383,8 @@ handleDeadProcess(void *foo)
while (deadProcessPtr>0) {
deadProcessPtr--;
for (i = WMGetBagItemCount(deathHandlers)-1; i >= 0; i--) {
tmp = WMGetFromBag(deathHandlers, i);
for (i = WMGetArrayItemCount(deathHandlers)-1; i >= 0; i--) {
tmp = WMGetFromArray(deathHandlers, i);
if (!tmp)
continue;
@@ -1514,25 +1513,20 @@ handleKeyPress(XEvent *event)
case WKBD_WINDOW9:
case WKBD_WINDOW10:
#define INITBAG(bag) if (bag) WMEmptyBag(bag); else bag = WMCreateBag(4)
index = command-WKBD_WINDOW1;
if (scr->shortcutWindows[index]) {
WMBag *list = scr->shortcutWindows[index];
WMArray *list = scr->shortcutWindows[index];
int cw;
int count = WMGetBagItemCount(list);
int count = WMGetArrayItemCount(list);
WWindow *twin;
WMBagIterator iter;
WMArrayIterator iter;
WWindow *wwin;
wUnselectWindows(scr);
cw = scr->current_workspace;
for (wwin = WMBagLast(list, &iter);
iter != NULL;
wwin = WMBagPrevious(list, &iter)) {
WM_ETARETI_ARRAY(list, wwin, iter) {
if (count > 1)
wWindowChangeWorkspace(wwin, cw);
@@ -1543,26 +1537,26 @@ handleKeyPress(XEvent *event)
}
/* rotate the order of windows, to create a cycling effect */
twin = WMBagFirst(list, &iter);
WMRemoveFromBag(list, twin);
WMPutInBag(list, twin);
twin = WMGetFromArray(list, 0);
WMDeleteFromArray(list, 0);
WMAddToArray(list, twin);
} else if (wwin && ISMAPPED(wwin) && ISFOCUSED(wwin)) {
INITBAG(scr->shortcutWindows[index]);
WMPutInBag(scr->shortcutWindows[index], wwin);
if (scr->shortcutWindows[index]) {
WMFreeArray(scr->shortcutWindows[index]);
scr->shortcutWindows[index] = NULL;
}
if (wwin->flags.selected && scr->selected_windows) {
WMBag *selwins = scr->selected_windows;
int i;
for (i = 0; i < WMGetBagItemCount(selwins); i++) {
WWindow *tmp = WMGetFromBag(selwins, i);
if (tmp != wwin)
WMPutInBag(scr->shortcutWindows[index], tmp);
}
scr->shortcutWindows[index] =
WMDuplicateArray(scr->selected_windows);
/*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
} else {
scr->shortcutWindows[index] = WMCreateArray(4);
WMAddToArray(scr->shortcutWindows[index], wwin);
}
wSelectWindow(wwin, !wwin->flags.selected);
XFlush(dpy);
wusleep(3000);
@@ -1570,22 +1564,16 @@ handleKeyPress(XEvent *event)
XFlush(dpy);
} else if (scr->selected_windows
&& WMGetBagItemCount(scr->selected_windows)) {
&& WMGetArrayItemCount(scr->selected_windows)) {
if (wwin->flags.selected && scr->selected_windows) {
WMBag *selwins = scr->selected_windows;
int i;
INITBAG(scr->shortcutWindows[index]);
for (i = 0; i < WMGetBagItemCount(selwins); i++) {
WWindow *tmp = WMGetFromBag(selwins, i);
WMPutInBag(scr->shortcutWindows[index], tmp);
if (scr->shortcutWindows[index]) {
WMFreeArray(scr->shortcutWindows[index]);
}
scr->shortcutWindows[index] =
WMDuplicateArray(scr->selected_windows);
}
}
}
#undef INITBAG
break;

View File

@@ -390,19 +390,19 @@ mapGeometryDisplay(WWindow *wwin, int x, int y, int w, int h)
static void
doWindowMove(WWindow *wwin, WMBag *bag, int dx, int dy)
doWindowMove(WWindow *wwin, WMArray *array, int dx, int dy)
{
WWindow *tmpw;
int x, y;
int scr_width = wwin->screen_ptr->scr_width;
int scr_height = wwin->screen_ptr->scr_height;
if (!bag || !WMGetBagItemCount(bag)) {
if (!array || !WMGetArrayItemCount(array)) {
wWindowMove(wwin, wwin->frame_x + dx, wwin->frame_y + dy);
} else {
int i;
for (i = 0; i < WMGetBagItemCount(bag); i++) {
tmpw = WMGetFromBag(bag, i);
WMArrayIterator iter;
WM_ITERATE_ARRAY(array, tmpw, iter) {
x = tmpw->frame_x + dx;
y = tmpw->frame_y + dy;
@@ -455,14 +455,14 @@ drawTransparentFrame(WWindow *wwin, int x, int y, int width, int height)
static void
drawFrames(WWindow *wwin, WMBag *bag, int dx, int dy)
drawFrames(WWindow *wwin, WMArray *array, int dx, int dy)
{
WWindow *tmpw;
int scr_width = wwin->screen_ptr->scr_width;
int scr_height = wwin->screen_ptr->scr_height;
int x, y;
if (!bag) {
if (!array) {
x = wwin->frame_x + dx;
y = wwin->frame_y + dy;
@@ -472,9 +472,9 @@ drawFrames(WWindow *wwin, WMBag *bag, int dx, int dy)
wwin->frame->core->height);
} else {
int i;
for (i = 0; i < WMGetBagItemCount(bag); i++) {
tmpw = WMGetFromBag(bag, i);
WMArrayIterator iter;
WM_ITERATE_ARRAY(array, tmpw, iter) {
x = tmpw->frame_x + dx;
y = tmpw->frame_y + dy;
@@ -1492,11 +1492,13 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
wWindowMove(wwin, src_x+off_x, src_y+off_y);
wWindowSynthConfigureNotify(wwin);
} else {
int i;
WMBag *bag = scr->selected_windows;
WMArrayIterator iter;
WWindow *foo;
doWindowMove(wwin, scr->selected_windows, off_x, off_y);
for (i = 0; i < WMGetBagItemCount(bag); i++) {
wWindowSynthConfigureNotify(WMGetFromBag(bag, i));
WM_ITERATE_ARRAY(scr->selected_windows, foo, iter) {
wWindowSynthConfigureNotify(foo);
}
}
} else {
@@ -2096,16 +2098,14 @@ wUnselectWindows(WScreen *scr)
if (!scr->selected_windows)
return;
while (WMGetBagItemCount(scr->selected_windows)) {
WMBagIterator dummy;
wwin = WMBagFirst(scr->selected_windows, &dummy);
while (WMGetArrayItemCount(scr->selected_windows)) {
wwin = WMGetFromArray(scr->selected_windows, 0);
if (wwin->flags.miniaturized && wwin->icon && wwin->icon->selected)
wIconSelect(wwin->icon);
wSelectWindow(wwin, False);
}
WMFreeBag(scr->selected_windows);
WMFreeArray(scr->selected_windows);
scr->selected_windows = NULL;
}

View File

@@ -601,7 +601,7 @@ static void
separateCommand(char *line, char ***file, char **command)
{
char *token, *tmp = line;
WMBag *bag = WMCreateBag(4);
WMArray *array = WMCreateArray(4);
int count, i;
*file = NULL;
@@ -616,19 +616,19 @@ separateCommand(char *line, char ***file, char **command)
wwarning(_("%s: missing command"), line);
break;
}
WMPutInBag(bag, token);
WMAddToArray(array, token);
}
} while (token!=NULL && tmp!=NULL);
count = WMGetBagItemCount(bag);
count = WMGetArrayItemCount(array);
if (count>0) {
*file = wmalloc(sizeof(char*)*(count+1));
(*file)[count] = NULL;
for (i = 0; i < count; i++) {
(*file)[i] = WMGetFromBag(bag, i);
(*file)[i] = WMGetFromArray(array, i);
}
}
WMFreeBag(bag);
WMFreeArray(array);
}
@@ -1334,14 +1334,15 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
struct stat stat_buf;
WMenu *menu=NULL;
char *buffer;
WMBag *dirs = NULL, *files = NULL;
WMArray *dirs = NULL, *files = NULL;
WMArrayIterator iter;
int length, i, have_space=0;
dir_data *data;
int stripExtension = 0;
dirs = WMCreateBag(16);
files = WMCreateBag(16);
dirs = WMCreateArray(16);
files = WMCreateArray(16);
i=0;
while (path[i]!=NULL) {
@@ -1395,7 +1396,7 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
data->name = wstrdup(dentry->d_name);
data->index = i;
WMPutInBag(dirs, data);
WMAddToArray(dirs, data);
}
} else if (S_ISREG(stat_buf.st_mode) || isFilePack) {
/* Hack because access always returns X_OK success for user root */
@@ -1408,7 +1409,7 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
data->name = wstrdup(dentry->d_name);
data->index = i;
WMPutInBag(files, data);
WMAddToArray(files, data);
}
}
}
@@ -1419,24 +1420,22 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
i++;
}
if (!WMGetBagItemCount(dirs) && !WMGetBagItemCount(files)) {
WMFreeBag(dirs);
WMFreeBag(files);
if (!WMGetArrayItemCount(dirs) && !WMGetArrayItemCount(files)) {
WMFreeArray(dirs);
WMFreeArray(files);
return NULL;
}
WMSortBag(dirs, myCompare);
WMSortBag(files, myCompare);
WMSortArray(dirs, myCompare);
WMSortArray(files, myCompare);
menu = wMenuCreate(scr, title, False);
menu->on_destroy = removeShortcutsForMenu;
for (i = 0; i < WMGetBagItemCount(dirs); i++) {
WM_ITERATE_ARRAY(dirs, data, iter) {
/* New directory. Use same OPEN_MENU command that was used
* for the current directory. */
dir_data *d = (dir_data*)WMGetFromBag(dirs, i);
length = strlen(path[d->index])+strlen(d->name)+6;
length = strlen(path[data->index])+strlen(data->name)+6;
if (stripExtension)
length += 7;
if (command)
@@ -1444,7 +1443,7 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
buffer = malloc(length);
if (!buffer) {
wsyserror(_("out of memory while constructing directory menu %s"),
path[d->index]);
path[data->index]);
break;
}
@@ -1452,15 +1451,15 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
if (stripExtension)
strcat(buffer, "-noext ");
have_space = strchr(path[d->index], ' ')!=NULL ||
strchr(d->name, ' ')!=NULL;
have_space = strchr(path[data->index], ' ')!=NULL ||
strchr(data->name, ' ')!=NULL;
if (have_space)
strcat(buffer, "\"");
strcat(buffer, path[d->index]);
strcat(buffer, path[data->index]);
strcat(buffer, "/");
strcat(buffer, d->name);
strcat(buffer, data->name);
if (have_space)
strcat(buffer, "\"");
if (command) {
@@ -1468,66 +1467,64 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command)
strcat(buffer, command);
}
addMenuEntry(menu, d->name, NULL, "OPEN_MENU", buffer, path[d->index]);
addMenuEntry(menu, data->name, NULL, "OPEN_MENU", buffer, path[data->index]);
wfree(buffer);
if (d->name)
wfree(d->name);
wfree(d);
if (data->name)
wfree(data->name);
wfree(data);
}
for (i = 0; i < WMGetBagItemCount(files); i++) {
WM_ITERATE_ARRAY(files, data, iter) {
/* executable: add as entry */
dir_data *f = (dir_data*)WMGetFromBag(files, i);
length = strlen(path[f->index])+strlen(f->name)+6;
length = strlen(path[data->index])+strlen(data->name)+6;
if (command)
length += strlen(command);
buffer = malloc(length);
if (!buffer) {
wsyserror(_("out of memory while constructing directory menu %s"),
path[f->index]);
path[data->index]);
break;
}
have_space = strchr(path[f->index], ' ')!=NULL ||
strchr(f->name, ' ')!=NULL;
have_space = strchr(path[data->index], ' ')!=NULL ||
strchr(data->name, ' ')!=NULL;
if (command!=NULL) {
strcpy(buffer, command);
strcat(buffer, " ");
if (have_space)
strcat(buffer, "\"");
strcat(buffer, path[f->index]);
strcat(buffer, path[data->index]);
} else {
if (have_space) {
buffer[0] = '"';
buffer[1] = 0;
strcat(buffer, path[f->index]);
strcat(buffer, path[data->index]);
} else {
strcpy(buffer, path[f->index]);
strcpy(buffer, path[data->index]);
}
}
strcat(buffer, "/");
strcat(buffer, f->name);
strcat(buffer, data->name);
if (have_space)
strcat(buffer, "\"");
if (stripExtension) {
char *ptr = strrchr(f->name, '.');
if (ptr && ptr!=f->name)
char *ptr = strrchr(data->name, '.');
if (ptr && ptr!=data->name)
*ptr = 0;
}
addMenuEntry(menu, f->name, NULL, "SHEXEC", buffer, path[f->index]);
addMenuEntry(menu, data->name, NULL, "SHEXEC", buffer, path[data->index]);
wfree(buffer);
if (f->name)
wfree(f->name);
wfree(f);
if (data->name)
wfree(data->name);
wfree(data);
}
WMFreeBag(files);
WMFreeBag(dirs);
WMFreeArray(files);
WMFreeArray(dirs);
return menu;
}

View File

@@ -108,7 +108,7 @@ typedef struct _WScreen {
* traverse the entire window list
*/
WMBag *selected_windows;
WMArray *selected_windows;
struct WAppIcon *app_icon_list; /* list of all app-icons on screen */
@@ -291,7 +291,7 @@ typedef struct _WScreen {
scrolled down for titlebar access */
/* for window shortcuts */
WMBag *shortcutWindows[MAX_WINDOW_SHORTCUTS];
WMArray *shortcutWindows[MAX_WINDOW_SHORTCUTS];
#ifdef XDND
char *xdestring;

View File

@@ -256,7 +256,7 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
for (mask = 0, i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (scr->shortcutWindows[i] != NULL &&
WMGetFirstInBag(scr->shortcutWindows[i], wwin) != WBNotFound) {
WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) {
mask |= 1<<i;
}
}
@@ -314,7 +314,7 @@ wSessionSaveState(WScreen *scr)
WWindow *wwin = scr->focused_window;
proplist_t win_info, wks;
proplist_t list=NULL;
WMBag *wapp_list=NULL;
WMArray *wapp_list=NULL;
make_keys();
@@ -327,13 +327,13 @@ wSessionSaveState(WScreen *scr)
list = PLMakeArrayFromElements(NULL);
wapp_list = WMCreateBag(16);
wapp_list = WMCreateArray(16);
while (wwin) {
WApplication *wapp=wApplicationOf(wwin->main_window);
if (wwin->transient_for==None
&& WMGetFirstInBag(wapp_list, wapp)==WBNotFound
&& WMGetFirstInArray(wapp_list, wapp)==WANotFound
&& !WFLAGP(wwin, dont_save_session)) {
/* A entry for this application was not yet saved. Save one. */
if ((win_info = makeWindowState(wwin, wapp))!=NULL) {
@@ -344,7 +344,7 @@ wSessionSaveState(WScreen *scr)
* application list, so no multiple entries for the same
* application are saved.
*/
WMPutInBag(wapp_list, wapp);
WMAddToArray(wapp_list, wapp);
}
}
wwin = wwin->prev;
@@ -357,7 +357,7 @@ wSessionSaveState(WScreen *scr)
PLInsertDictionaryEntry(scr->session_state, sWorkspace, wks);
PLRelease(wks);
WMFreeBag(wapp_list);
WMFreeArray(wapp_list);
}

View File

@@ -227,10 +227,10 @@ wWindowDestroy(WWindow *wwin)
if (!wwin->screen_ptr->shortcutWindows[i])
continue;
WMRemoveFromBag(wwin->screen_ptr->shortcutWindows[i], wwin);
WMRemoveFromArray(wwin->screen_ptr->shortcutWindows[i], wwin);
if (!WMGetBagItemCount(wwin->screen_ptr->shortcutWindows[i])) {
WMFreeBag(wwin->screen_ptr->shortcutWindows[i]);
if (!WMGetArrayItemCount(wwin->screen_ptr->shortcutWindows[i])) {
WMFreeArray(wwin->screen_ptr->shortcutWindows[i]);
wwin->screen_ptr->shortcutWindows[i] = NULL;
}
}
@@ -862,9 +862,9 @@ wManageWindow(WScreen *scr, Window window)
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (mask & (1<<i)) {
if (!scr->shortcutWindows[i])
scr->shortcutWindows[i] = WMCreateBag(4);
scr->shortcutWindows[i] = WMCreateArray(4);
WMPutInBag(scr->shortcutWindows[i], wwin);
WMAddToArray(scr->shortcutWindows[i], wwin);
}
}
}
@@ -2372,7 +2372,7 @@ wWindowSaveState(WWindow *wwin)
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (wwin->screen_ptr->shortcutWindows[i] &&
WMCountInBag(wwin->screen_ptr->shortcutWindows[i], wwin))
WMCountInArray(wwin->screen_ptr->shortcutWindows[i], wwin))
data[9] |= 1<<i;
}
XChangeProperty(dpy, wwin->client_win, _XA_WINDOWMAKER_STATE,

View File

@@ -203,25 +203,17 @@ makeShortcutCommand(WMenu *menu, WMenuEntry *entry)
int index = entry->order-WO_ENTRIES;
if (scr->shortcutWindows[index]) {
WMFreeBag(scr->shortcutWindows[index]);
WMFreeArray(scr->shortcutWindows[index]);
scr->shortcutWindows[index] = NULL;
}
if (wwin->flags.selected && scr->selected_windows) {
WMBag *selwin = scr->selected_windows;
int i;
scr->shortcutWindows[index] = WMCreateBag(4);
for (i = 0; i < WMGetBagItemCount(selwin); i++) {
WWindow *tmp = WMGetFromBag(selwin, i);
WMPutInBag(scr->shortcutWindows[index], tmp);
}
scr->shortcutWindows[index] = WMDuplicateArray(scr->selected_windows);
/*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
} else {
scr->shortcutWindows[index] = WMCreateBag(4);
WMPutInBag(scr->shortcutWindows[index], wwin);
scr->shortcutWindows[index] = WMCreateArray(4);
WMAddToArray(scr->shortcutWindows[index], wwin);
}
wSelectWindow(wwin, !wwin->flags.selected);
@@ -281,7 +273,7 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
char *tmp;
int shortcutNo = i-WO_ENTRIES;
WMenuEntry *entry = smenu->entries[i];
WMBag *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];
WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];
sprintf(buffer, "%s %i", _("Set Shortcut"), shortcutNo+1);
@@ -289,7 +281,7 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
entry->flags.indicator_on = 0;
} else {
entry->flags.indicator_on = 1;
if (WMCountInBag(shortSelWindows, wwin))
if (WMCountInArray(shortSelWindows, wwin))
entry->flags.indicator_type = MI_DIAMOND;
else
entry->flags.indicator_type = MI_CHECK;

View File

@@ -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 ");