summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-09-18 22:07:29 -0400
committerKristian Høgsberg <krh@redhat.com>2009-09-18 22:07:29 -0400
commitc63fb2de8457b63078afc589ef13e419f06f6a95 (patch)
tree82a0515f4501708a3b1697e53e4a10e321d37258
parent26b8fe8649eccd0bb3ed1b21086e7813d20963f8 (diff)
Add and export AddSelection
-rw-r--r--dix/selection.c46
-rw-r--r--include/selection.h3
2 files changed, 32 insertions, 17 deletions
diff --git a/dix/selection.c b/dix/selection.c
index d72f381ca..07092691e 100644
--- a/dix/selection.c
+++ b/dix/selection.c
@@ -86,6 +86,34 @@ dixLookupSelection(Selection **result, Atom selectionName,
return rc;
}
+int
+AddSelection(Selection **result, Atom name, ClientPtr client)
+{
+ Selection *pSel;
+ int rc;
+
+ pSel = xalloc(sizeof(Selection));
+ if (!pSel)
+ return BadAlloc;
+
+ pSel->selection = name;
+ pSel->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHookSelectionAccess(client, &pSel,
+ DixCreateAccess|DixSetAttrAccess);
+ if (rc != Success) {
+ xfree(pSel);
+ return rc;
+ }
+
+ pSel->next = CurrentSelections;
+ CurrentSelections = pSel;
+ *result = pSel;
+
+ return Success;
+}
+
void
InitSelections(void)
{
@@ -198,23 +226,7 @@ ProcSetSelectionOwner(ClientPtr client)
/*
* It doesn't exist, so add it...
*/
- pSel = xalloc(sizeof(Selection));
- if (!pSel)
- return BadAlloc;
-
- pSel->selection = stuff->selection;
- pSel->devPrivates = NULL;
-
- /* security creation/labeling check */
- rc = XaceHookSelectionAccess(client, &pSel,
- DixCreateAccess|DixSetAttrAccess);
- if (rc != Success) {
- xfree(pSel);
- return rc;
- }
-
- pSel->next = CurrentSelections;
- CurrentSelections = pSel;
+ rc = AddSelection(&pSel, stuff->selection, client);
}
else
return rc;
diff --git a/include/selection.h b/include/selection.h
index 3271f6abb..249715e74 100644
--- a/include/selection.h
+++ b/include/selection.h
@@ -73,6 +73,9 @@ typedef struct _Selection {
extern _X_EXPORT int dixLookupSelection(Selection **result, Atom name,
ClientPtr client, Mask access_mode);
+extern _X_EXPORT int AddSelection(Selection **result,
+ Atom name, ClientPtr client);
+
extern _X_EXPORT Selection *CurrentSelections;
extern _X_EXPORT CallbackListPtr SelectionCallback;