From bc3634010c096dffd1935c0c6cf8ba37534ae3d8 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 12 Feb 2016 11:59:52 +0000 Subject: dix: Add ClientSignalAll() This is a variant of ClientSignal() that signals all clients with an optional matching sleeping client, function and closure. Reviewed-by: Adam Jackson Signed-off-by: Chris Wilson --- dix/dixutils.c | 22 ++++++++++++++++++++++ include/dix.h | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/dix/dixutils.c b/dix/dixutils.c index 205550eb4..b6b002385 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -620,6 +620,28 @@ ClientSignal(ClientPtr client) return FALSE; } +int +ClientSignalAll(ClientPtr client, ClientSleepProcPtr function, void *closure) +{ + SleepQueuePtr q; + int count = 0; + + for (q = sleepQueue; q; q = q->next) { + if (!(client == CLIENT_SIGNAL_ANY || q->client == client)) + continue; + + if (!(function == CLIENT_SIGNAL_ANY || q->function == function)) + continue; + + if (!(closure == CLIENT_SIGNAL_ANY || q->closure == closure)) + continue; + + count += QueueWorkProc(q->function, q->client, q->closure); + } + + return count; +} + void ClientWakeup(ClientPtr client) { diff --git a/include/dix.h b/include/dix.h index 921156b4c..d49d05569 100644 --- a/include/dix.h +++ b/include/dix.h @@ -255,6 +255,14 @@ extern _X_EXPORT Bool ClientSleep(ClientPtr client, extern _X_EXPORT Bool ClientSignal(ClientPtr /*client */ ); #endif /* ___CLIENTSIGNAL_DEFINED___ */ +#ifndef ___CLIENTSIGNALALL_DEFINED___ +#define ___CLIENTSIGNALALL_DEFINED___ +#define CLIENT_SIGNAL_ANY ((void *)-1) +extern _X_EXPORT int ClientSignalAll(ClientPtr /*client*/, + ClientSleepProcPtr /*function*/, + void * /*closure*/); +#endif /* ___CLIENTSIGNALALL_DEFINED___ */ + extern _X_EXPORT void ClientWakeup(ClientPtr /*client */ ); extern _X_EXPORT Bool ClientIsAsleep(ClientPtr /*client */ ); -- cgit v1.2.3