summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2008-03-07 11:32:19 -0500
committerDavid Reveman <davidr@novell.com>2008-03-10 12:17:30 -0400
commit1af2bbb950bbb84627f221155c51d0a6b2ce72cb (patch)
tree30ae003f2f58acbf1f921d15d906b415b6f1cc16
parentc84204536d6883395ab2572dd0a85e318a0422eb (diff)
Add iDelegate type.
-rw-r--r--include/compiz/delegate.h29
-rw-r--r--src/delegate.c125
-rw-r--r--src/main.c1
3 files changed, 149 insertions, 6 deletions
diff --git a/include/compiz/delegate.h b/include/compiz/delegate.h
index 82f79767..4bd6d09c 100644
--- a/include/compiz/delegate.h
+++ b/include/compiz/delegate.h
@@ -102,6 +102,35 @@ struct _CompVoidDelegate {
const CompObjectType *
getVoidDelegateObjectType (void);
+
+typedef struct _CompIDelegate CompIDelegate;
+
+typedef void (*INotifyProc) (CompIDelegate *id,
+ int32_t value0);
+
+typedef struct _CompIDelegateVTable {
+ CompDelegateVTable base;
+
+ INotifyProc notify;
+} CompIDelegateVTable;
+
+struct _CompIDelegate {
+ union {
+ CompDelegate base;
+ const CompIDelegateVTable *vTable;
+ } u;
+
+ CompObjectData data;
+};
+
+#define COMPIZ_I_DELEGATE_TYPE_NAME "org.compiz.delegate.i"
+
+#define GET_I_DELEGATE(object) ((CompIDelegate *) (object))
+#define I_DELEGATE(object) CompIDelegate *id = GET_I_DELEGATE (object)
+
+const CompObjectType *
+getIDelegateObjectType (void);
+
COMPIZ_END_DECLS
#endif
diff --git a/src/delegate.c b/src/delegate.c
index 323eae2d..cf5f1efe 100644
--- a/src/delegate.c
+++ b/src/delegate.c
@@ -188,7 +188,6 @@ delegateObjectTypeFromTemplate (const CObjectInterface *template)
return cObjectTypeFromTemplate (&delegateTemplate);
}
-
static void
voidDelegateGetProp (CompObject *object,
unsigned int what,
@@ -233,7 +232,7 @@ voidDelegateProcessSignal (CompDelegate *d,
nValue,
"",
NULL))
- (vd->u.vTable->notify) (vd);
+ (*vd->u.vTable->notify) (vd);
}
}
@@ -247,14 +246,14 @@ voidDelegateProcessSignal (CompDelegate *d,
}
static void
-notify (CompVoidDelegate *vd)
+voidNotify (CompVoidDelegate *vd)
{
C_EMIT_SIGNAL (&vd->u.base.u.base, VoidNotifyProc,
offsetof (CompVoidDelegateVTable, notify));
}
static void
-noopNotify (CompVoidDelegate *vd)
+noopVoidNotify (CompVoidDelegate *vd)
{
FOR_BASE (&vd->u.base.u.base, (*vd->u.vTable->notify) (vd));
}
@@ -263,11 +262,11 @@ static const CompVoidDelegateVTable voidDelegateObjectVTable = {
.base.base.getProp = voidDelegateGetProp,
.base.processSignal = voidDelegateProcessSignal,
- .notify = notify
+ .notify = voidNotify
};
static const CompVoidDelegateVTable noopVoidDelegateObjectVTable = {
- .notify = noopNotify
+ .notify = noopVoidNotify
};
static const CSignal voidDelegateTypeSignal[] = {
@@ -297,3 +296,117 @@ getVoidDelegateObjectType (void)
return type;
}
+
+static void
+iDelegateGetProp (CompObject *object,
+ unsigned int what,
+ void *value)
+{
+ cGetObjectProp (&GET_I_DELEGATE (object)->data,
+ getIDelegateObjectType (),
+ what, value);
+}
+
+static void
+iDelegateProcessSignal (CompDelegate *d,
+ const char *path,
+ const char *interface,
+ const char *name,
+ const char *signature,
+ CompAnyValue *value,
+ int nValue)
+{
+ int i;
+
+ I_DELEGATE (d);
+
+ for (i = 0; i < d->data.matches.nChild; i++)
+ {
+ CompSignalMatch *sm;
+
+ if (d->data.compress && d->pending)
+ break;
+
+ sm = COMP_TYPE_CAST (d->data.matches.child[i].ref,
+ getSignalMatchObjectType (),
+ CompSignalMatch);
+ if (sm)
+ {
+ CompAnyValue args;
+
+ if ((*sm->u.vTable->match) (sm,
+ path,
+ interface,
+ name,
+ signature,
+ value,
+ nValue,
+ "i",
+ &args))
+ (*id->u.vTable->notify) (id, args.i);
+ }
+ }
+
+ FOR_BASE (&d->u.base, (*d->u.vTable->processSignal) (d,
+ path,
+ interface,
+ name,
+ signature,
+ value,
+ nValue));
+}
+
+static void
+iNotify (CompIDelegate *id,
+ int32_t value0)
+{
+ C_EMIT_SIGNAL (&id->u.base.u.base, INotifyProc,
+ offsetof (CompIDelegateVTable, notify),
+ value0);
+}
+
+static void
+noopINotify (CompIDelegate *id,
+ int32_t value0)
+{
+ FOR_BASE (&id->u.base.u.base, (*id->u.vTable->notify) (id, value0));
+}
+
+static const CompIDelegateVTable iDelegateObjectVTable = {
+ .base.base.getProp = iDelegateGetProp,
+ .base.processSignal = iDelegateProcessSignal,
+
+ .notify = iNotify
+};
+
+static const CompIDelegateVTable noopIDelegateObjectVTable = {
+ .notify = noopINotify
+};
+
+static const CSignal iDelegateTypeSignal[] = {
+ C_SIGNAL (notify, "i", CompIDelegateVTable)
+};
+
+const CompObjectType *
+getIDelegateObjectType (void)
+{
+ static CompObjectType *type = NULL;
+
+ if (!type)
+ {
+ static const CObjectInterface template = {
+ .i.name = COMPIZ_I_DELEGATE_TYPE_NAME,
+ .i.vTable.impl = &iDelegateObjectVTable.base.base,
+ .i.vTable.noop = &noopIDelegateObjectVTable.base.base,
+ .i.vTable.size = sizeof (iDelegateObjectVTable),
+ .i.instance.size = sizeof (CompIDelegate),
+
+ .signal = iDelegateTypeSignal,
+ .nSignal = N_ELEMENTS (iDelegateTypeSignal)
+ };
+
+ type = delegateObjectTypeFromTemplate (&template);
+ }
+
+ return type;
+}
diff --git a/src/main.c b/src/main.c
index 5fd22e04..0672b09e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -473,6 +473,7 @@ main (int argc, char **argv)
getStructureNotifySignalMatchObjectType (),
getDelegateObjectType (),
getVoidDelegateObjectType (),
+ getIDelegateObjectType (),
getRootObjectType (),
getTimerObjectType (),
getFileDescriptorObjectType (),