Xnamespace: add per-client private data
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
bc4c35d045
commit
33a66a7810
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <X11/Xmd.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "include/extinit_priv.h"
|
||||
#include "include/os.h"
|
||||
|
||||
|
@ -10,6 +11,8 @@
|
|||
|
||||
Bool noNamespaceExtension = TRUE;
|
||||
|
||||
DevPrivateKeyRec namespaceClientPrivKeyRec = { 0 };
|
||||
|
||||
void
|
||||
NamespaceExtensionInit(void)
|
||||
{
|
||||
|
@ -20,4 +23,34 @@ NamespaceExtensionInit(void)
|
|||
XNS_LOG("No config file. disabling Xns extension\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(&namespaceClientPrivKeyRec, PRIVATE_CLIENT, sizeof(struct XnamespaceClientPriv)))
|
||||
FatalError("NamespaceExtensionInit: allocation failure\n");
|
||||
|
||||
/* Do the serverClient */
|
||||
struct XnamespaceClientPriv *srv = XnsClientPriv(serverClient);
|
||||
*srv = (struct XnamespaceClientPriv) { .isServer = TRUE };
|
||||
XnamespaceAssignClient(srv, &ns_root);
|
||||
}
|
||||
|
||||
void XnamespaceAssignClient(struct XnamespaceClientPriv *priv, struct Xnamespace *newns)
|
||||
{
|
||||
if (priv->ns != NULL)
|
||||
priv->ns->refcnt--;
|
||||
|
||||
priv->ns = newns;
|
||||
|
||||
if (newns != NULL)
|
||||
newns->refcnt++;
|
||||
}
|
||||
|
||||
void XnamespaceAssignClientByName(struct XnamespaceClientPriv *priv, const char *name)
|
||||
{
|
||||
struct Xnamespace *newns = XnsFindByName(name);
|
||||
|
||||
if (newns == NULL)
|
||||
newns = &ns_anon;
|
||||
|
||||
XnamespaceAssignClient(priv, newns);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include <stdio.h>
|
||||
#include <X11/Xmd.h>
|
||||
|
||||
#include "include/dixstruct.h"
|
||||
#include "include/list.h"
|
||||
#include "include/privates.h"
|
||||
#include "include/window.h"
|
||||
|
||||
struct Xnamespace {
|
||||
|
@ -19,11 +21,35 @@ extern struct xorg_list ns_list;
|
|||
extern struct Xnamespace ns_root;
|
||||
extern struct Xnamespace ns_anon;
|
||||
|
||||
struct XnamespaceClientPriv {
|
||||
Bool isServer;
|
||||
XID authId;
|
||||
struct Xnamespace* ns;
|
||||
};
|
||||
|
||||
#define NS_NAME_ROOT "root"
|
||||
#define NS_NAME_ANONYMOUS "anon"
|
||||
|
||||
extern DevPrivateKeyRec namespaceClientPrivKeyRec;
|
||||
|
||||
Bool XnsLoadConfig(void);
|
||||
struct Xnamespace *XnsFindByName(const char* name);
|
||||
void XnamespaceAssignClient(struct XnamespaceClientPriv *priv, struct Xnamespace *ns);
|
||||
void XnamespaceAssignClientByName(struct XnamespaceClientPriv *priv, const char *name);
|
||||
|
||||
static inline struct XnamespaceClientPriv *XnsClientPriv(ClientPtr client) {
|
||||
if (client == NULL) return NULL;
|
||||
return dixLookupPrivate(&client->devPrivates, &namespaceClientPrivKeyRec);
|
||||
}
|
||||
|
||||
static inline Bool XnsClientSameNS(struct XnamespaceClientPriv *p1, struct XnamespaceClientPriv *p2)
|
||||
{
|
||||
if (!p1 && !p2)
|
||||
return TRUE;
|
||||
if (!p1 || !p2)
|
||||
return FALSE;
|
||||
return (p1->ns == p2->ns);
|
||||
}
|
||||
|
||||
#define XNS_LOG(...) do { printf("XNS "); printf(__VA_ARGS__); } while (0)
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ static const char *key_names[PRIVATE_LAST] = {
|
|||
[PRIVATE_GLYPHSET] = "GLYPHSET",
|
||||
[PRIVATE_PICTURE] = "PICTURE",
|
||||
[PRIVATE_SYNC_FENCE] = "SYNC_FENCE",
|
||||
[PRIVATE_NAMESPACE] = "NAMESPACE",
|
||||
};
|
||||
|
||||
static const Bool screen_specific_private[PRIVATE_LAST] = {
|
||||
|
|
|
@ -51,6 +51,7 @@ typedef enum {
|
|||
PRIVATE_GLYPHSET,
|
||||
PRIVATE_PICTURE,
|
||||
PRIVATE_SYNC_FENCE,
|
||||
PRIVATE_NAMESPACE,
|
||||
|
||||
/* last private type */
|
||||
PRIVATE_LAST,
|
||||
|
|
Loading…
Reference in New Issue