1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-02 14:15:46 +01:00

changed indentation to use spaces only

This commit is contained in:
dan
2004-10-12 21:28:27 +00:00
parent 5912898b06
commit 6830b05716
240 changed files with 35951 additions and 35773 deletions

View File

@@ -43,15 +43,15 @@ WMNotification*
WMCreateNotification(const char *name, void *object, void *clientData)
{
Notification *nPtr;
nPtr = wmalloc(sizeof(Notification));
nPtr->name = name;
nPtr->object = object;
nPtr->clientData = clientData;
nPtr->refCount = 1;
return nPtr;
}
@@ -60,9 +60,9 @@ void
WMReleaseNotification(WMNotification *notification)
{
notification->refCount--;
if (notification->refCount < 1) {
wfree(notification);
wfree(notification);
}
}
@@ -71,7 +71,7 @@ WMNotification*
WMRetainNotification(WMNotification *notification)
{
notification->refCount++;
return notification;
}
@@ -95,7 +95,7 @@ typedef struct W_NotificationCenter {
WMHashTable *nameTable; /* names -> observer lists */
WMHashTable *objectTable; /* object -> observer lists */
NotificationObserver *nilList; /* obervers that catch everything */
WMHashTable *observerTable; /* observer -> NotificationObserver */
} NotificationCenter;
@@ -108,21 +108,21 @@ void
W_InitNotificationCenter(void)
{
notificationCenter = wmalloc(sizeof(NotificationCenter));
notificationCenter->nameTable = WMCreateHashTable(WMStringPointerHashCallbacks);
notificationCenter->objectTable = WMCreateHashTable(WMIntHashCallbacks);
notificationCenter->nilList = NULL;
notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks);
}
void
WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
void *observer, const char *name, void *object)
void *observer, const char *name, void *object)
{
NotificationObserver *oRec, *rec;
oRec = wmalloc(sizeof(NotificationObserver));
oRec->observerAction = observerAction;
oRec->observer = observer;
@@ -130,42 +130,42 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
oRec->object = object;
oRec->next = NULL;
oRec->prev = NULL;
/* put this action in the list of actions for this observer */
rec = (NotificationObserver*)WMHashInsert(notificationCenter->observerTable,
observer, oRec);
observer, oRec);
if (rec) {
/* if this is not the first action for the observer */
oRec->nextAction = rec;
/* if this is not the first action for the observer */
oRec->nextAction = rec;
} else {
oRec->nextAction = NULL;
oRec->nextAction = NULL;
}
if (!name && !object) {
/* catch-all */
oRec->next = notificationCenter->nilList;
if (notificationCenter->nilList) {
notificationCenter->nilList->prev = oRec;
}
notificationCenter->nilList = oRec;
/* catch-all */
oRec->next = notificationCenter->nilList;
if (notificationCenter->nilList) {
notificationCenter->nilList->prev = oRec;
}
notificationCenter->nilList = oRec;
} else if (!name) {
/* any message coming from object */
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
object, oRec);
oRec->next = rec;
if (rec) {
rec->prev = oRec;
}
/* any message coming from object */
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
object, oRec);
oRec->next = rec;
if (rec) {
rec->prev = oRec;
}
} else {
/* name && (object || !object) */
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
name, oRec);
oRec->next = rec;
if (rec) {
rec->prev = oRec;
}
/* name && (object || !object) */
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
name, oRec);
oRec->next = rec;
if (rec) {
rec->prev = oRec;
}
}
}
@@ -176,49 +176,49 @@ WMPostNotification(WMNotification *notification)
NotificationObserver *orec, *tmp;
WMRetainNotification(notification);
/* tell the observers that want to know about a particular message */
orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
notification->name);
while (orec) {
tmp = orec->next;
if (!orec->object || !notification->object
|| orec->object == notification->object) {
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
}
orec = tmp;
/* tell the observers that want to know about a particular message */
orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
notification->name);
while (orec) {
tmp = orec->next;
if (!orec->object || !notification->object
|| orec->object == notification->object) {
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
}
orec = tmp;
}
/* tell the observers that want to know about an object */
orec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
notification->object);
notification->object);
while (orec) {
tmp = orec->next;
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
orec = tmp;
tmp = orec->next;
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
orec = tmp;
}
/* tell the catch all observers */
orec = notificationCenter->nilList;
while (orec) {
tmp = orec->next;
tmp = orec->next;
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
orec = tmp;
/* tell the observer */
if (orec->observerAction) {
(*orec->observerAction)(orec->observer, notification);
}
orec = tmp;
}
WMReleaseNotification(notification);
@@ -232,7 +232,7 @@ WMRemoveNotificationObserver(void *observer)
/* get the list of actions the observer is doing */
orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable,
observer);
observer);
/*
* FOREACH orec IN actionlist for observer
@@ -242,47 +242,47 @@ WMRemoveNotificationObserver(void *observer)
* END
*/
while (orec) {
tmp = orec->nextAction;
tmp = orec->nextAction;
if (!orec->name && !orec->object) {
/* catch-all */
if (notificationCenter->nilList==orec)
notificationCenter->nilList = orec->next;
} else if (!orec->name) {
/* any message coming from object */
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
orec->object);
if (rec==orec) {
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->objectTable, orec->object,
orec->next);
} else {
WMHashRemove(notificationCenter->objectTable, orec->object);
}
}
} else {
/* name && (object || !object) */
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
orec->name);
if (rec==orec) {
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->nameTable, orec->name,
orec->next);
} else {
WMHashRemove(notificationCenter->nameTable, orec->name);
}
}
}
if (orec->prev)
orec->prev->next = orec->next;
if (orec->next)
orec->next->prev = orec->prev;
if (!orec->name && !orec->object) {
/* catch-all */
if (notificationCenter->nilList==orec)
notificationCenter->nilList = orec->next;
} else if (!orec->name) {
/* any message coming from object */
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
orec->object);
if (rec==orec) {
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->objectTable, orec->object,
orec->next);
} else {
WMHashRemove(notificationCenter->objectTable, orec->object);
}
}
} else {
/* name && (object || !object) */
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
orec->name);
if (rec==orec) {
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->nameTable, orec->name,
orec->next);
} else {
WMHashRemove(notificationCenter->nameTable, orec->name);
}
}
}
if (orec->prev)
orec->prev->next = orec->next;
if (orec->next)
orec->next->prev = orec->prev;
wfree(orec);
orec = tmp;
wfree(orec);
orec = tmp;
}
WMHashRemove(notificationCenter->observerTable, observer);
@@ -303,66 +303,66 @@ WMRemoveNotificationObserverWithName(void *observer, const char *name, void *obj
/* rebuild the list of actions for the observer */
while (orec) {
tmp = orec->nextAction;
if (orec->name == name && orec->object == object) {
if (!name && !object) {
if (notificationCenter->nilList == orec)
notificationCenter->nilList = orec->next;
} else if (!name) {
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
if (rec==orec) {
assert(rec->prev==NULL);
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->objectTable,
orec->object, orec->next);
} else {
WMHashRemove(notificationCenter->objectTable,
orec->object);
}
}
} else {
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
orec->name);
if (rec==orec) {
assert(rec->prev==NULL);
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->nameTable,
orec->name, orec->next);
} else {
WMHashRemove(notificationCenter->nameTable,
orec->name);
}
}
}
tmp = orec->nextAction;
if (orec->name == name && orec->object == object) {
if (!name && !object) {
if (notificationCenter->nilList == orec)
notificationCenter->nilList = orec->next;
} else if (!name) {
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
if (rec==orec) {
assert(rec->prev==NULL);
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->objectTable,
orec->object, orec->next);
} else {
WMHashRemove(notificationCenter->objectTable,
orec->object);
}
}
} else {
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
orec->name);
if (rec==orec) {
assert(rec->prev==NULL);
/* replace table entry */
if (orec->next) {
WMHashInsert(notificationCenter->nameTable,
orec->name, orec->next);
} else {
WMHashRemove(notificationCenter->nameTable,
orec->name);
}
}
}
if (orec->prev)
orec->prev->next = orec->next;
if (orec->next)
orec->next->prev = orec->prev;
wfree(orec);
if (orec->prev)
orec->prev->next = orec->next;
if (orec->next)
orec->next->prev = orec->prev;
wfree(orec);
} else {
/* append this action in the new action list */
orec->nextAction = NULL;
if (!newList) {
newList = orec;
} else {
NotificationObserver *p;
/* append this action in the new action list */
orec->nextAction = NULL;
if (!newList) {
newList = orec;
} else {
NotificationObserver *p;
p = newList;
while (p->nextAction) {
p = p->nextAction;
}
p->nextAction = orec;
}
}
orec = tmp;
p = newList;
while (p->nextAction) {
p = p->nextAction;
}
p->nextAction = orec;
}
}
orec = tmp;
}
/* reinsert the list to the table */
if (newList) {
WMHashInsert(notificationCenter->observerTable, observer, newList);
WMHashInsert(notificationCenter->observerTable, observer, newList);
}
}
@@ -373,7 +373,7 @@ WMPostNotificationName(const char *name, void *object, void *clientData)
WMNotification *notification;
notification = WMCreateNotification(name, object, clientData);
WMPostNotification(notification);
WMReleaseNotification(notification);
@@ -402,7 +402,7 @@ WMNotificationQueue*
WMGetDefaultNotificationQueue(void)
{
if (!notificationQueue)
notificationQueue = WMCreateNotificationQueue();
notificationQueue = WMCreateNotificationQueue();
return notificationQueue;
}
@@ -430,10 +430,10 @@ WMCreateNotificationQueue(void)
void
WMEnqueueNotification(WMNotificationQueue *queue, WMNotification *notification,
WMPostingStyle postingStyle)
WMPostingStyle postingStyle)
{
WMEnqueueCoalesceNotification(queue, notification, postingStyle,
WNCOnName|WNCOnSender);
WNCOnName|WNCOnSender);
}
@@ -465,8 +465,8 @@ matchName(void *item, void *cdata)
void
WMDequeueNotificationMatching(WMNotificationQueue *queue,
WMNotification *notification, unsigned mask)
WMDequeueNotificationMatching(WMNotificationQueue *queue,
WMNotification *notification, unsigned mask)
{
WMMatchDataProc *matchFunc;
@@ -485,27 +485,27 @@ WMDequeueNotificationMatching(WMNotificationQueue *queue,
void
WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
WMNotification *notification,
WMPostingStyle postingStyle,
unsigned coalesceMask)
WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
WMNotification *notification,
WMPostingStyle postingStyle,
unsigned coalesceMask)
{
if (coalesceMask != WNCNone)
WMDequeueNotificationMatching(queue, notification, coalesceMask);
WMDequeueNotificationMatching(queue, notification, coalesceMask);
switch (postingStyle) {
case WMPostNow:
WMPostNotification(notification);
case WMPostNow:
WMPostNotification(notification);
WMReleaseNotification(notification);
break;
case WMPostASAP:
WMAddToArray(queue->asapQueue, notification);
break;
case WMPostASAP:
WMAddToArray(queue->asapQueue, notification);
break;
case WMPostWhenIdle:
WMAddToArray(queue->idleQueue, notification);
break;
case WMPostWhenIdle:
WMAddToArray(queue->idleQueue, notification);
break;
}
}
@@ -516,12 +516,12 @@ W_FlushASAPNotificationQueue()
WMNotificationQueue *queue = notificationQueueList;
while (queue) {
while (WMGetArrayItemCount(queue->asapQueue)) {
while (WMGetArrayItemCount(queue->asapQueue)) {
WMPostNotification(WMGetFromArray(queue->asapQueue, 0));
WMDeleteFromArray(queue->asapQueue, 0);
}
}
queue = queue->next;
queue = queue->next;
}
}
@@ -532,12 +532,12 @@ W_FlushIdleNotificationQueue()
WMNotificationQueue *queue = notificationQueueList;
while (queue) {
while (WMGetArrayItemCount(queue->idleQueue)) {
WMPostNotification(WMGetFromArray(queue->idleQueue, 0));
WMDeleteFromArray(queue->idleQueue, 0);
}
while (WMGetArrayItemCount(queue->idleQueue)) {
WMPostNotification(WMGetFromArray(queue->idleQueue, 0));
WMDeleteFromArray(queue->idleQueue, 0);
}
queue = queue->next;
queue = queue->next;
}
}