[PATCH 4/4] dix: Modify callers of property and selection API to use new interfaces.

Eamon Walsh ewalsh at tycho.nsa.gov
Wed Feb 27 20:41:48 PST 2008


Signed-off-by: Eamon Walsh <ewalsh at moss-charon.epoch.ncsc.mil>
---
 hw/xfree86/common/xf86Init.c    |   11 ++++-----
 hw/xprint/pcl/PclMisc.c         |   17 +++++--------
 hw/xprint/pcl/PclWindow.c       |    6 ++--
 hw/xprint/ps/PsMisc.c           |   17 +++++--------
 hw/xprint/ps/PsWindow.c         |    6 ++--
 hw/xquartz/applewm.c            |   14 ++++-------
 hw/xquartz/quartzPasteboard.c   |   48 ++++++++++++++++----------------------
 hw/xquartz/xpr/xprFrame.c       |    4 +-
 hw/xwin/winwin32rootless.c      |    4 +-
 miext/rootless/rootlessWindow.c |    4 +-
 xkb/xkbInit.c                   |    4 +-
 11 files changed, 58 insertions(+), 77 deletions(-)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index d1603c0..6d5eaad 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -172,12 +172,11 @@ xf86CreateRootWindow(WindowPtr pWin)
 	  Atom prop;
 
 	  prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
-	  err = ChangeWindowProperty(pWin,
-				     prop, pProp->type,
-				     pProp->format, PropModeReplace,
-				     pProp->size, pProp->data,
-				     FALSE
-				     );
+	  err = dixChangeWindowProperty(serverClient, pWin,
+					prop, pProp->type,
+					pProp->format, PropModeReplace,
+					pProp->size, pProp->data,
+					FALSE);
 	}
       
       /* Look at err */
diff --git a/hw/xprint/pcl/PclMisc.c b/hw/xprint/pcl/PclMisc.c
index e0b7dce..0b37836 100644
--- a/hw/xprint/pcl/PclMisc.c
+++ b/hw/xprint/pcl/PclMisc.c
@@ -115,7 +115,7 @@ GetPropString(
     if(atom != BAD_RESOURCE)
     {
         WindowPtr pPropWin;
-	int n;
+	int rc, n;
 
 	/*
 	 * The atom has been defined, but it might only exist as a
@@ -124,15 +124,12 @@ GetPropString(
         for(pPropWin = pWin; pPropWin != (WindowPtr)NULL; 
 	    pPropWin = pPropWin->parent)
         {
-	    for(pProp = (PropertyPtr)(wUserProps(pPropWin)); 
-		pProp != (PropertyPtr)NULL;
-	        pProp = pProp->next)
-	    {
-                if (pProp->propertyName == atom)
-                    break;
-	    }
-	    if(pProp != (PropertyPtr)NULL)
-	        break;
+	    rc = dixLookupProperty(&pProp, pPropWin, atom,
+				   serverClient, DixReadAccess);
+	    if (rc == Success)
+		break;
+	    else
+		pProp = NULL;
         }
 	if(pProp == (PropertyPtr)NULL)
 	    return (char *)NULL;
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index a87dc0e..950933e 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -128,9 +128,9 @@ PclCreateWindow(
 	    {
                 propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
 				    TRUE);
-	        ChangeWindowProperty(pWin, propName, XA_STRING, 8, 
-			             PropModeReplace,  strlen(propVal), 
-			             (pointer)propVal, FALSE);
+	        dixChangeWindowProperty(serverClient, pWin, propName, XA_STRING,
+					8, PropModeReplace, strlen(propVal),
+					(pointer)propVal, FALSE);
 	        xfree(propVal);
 	    }
 	}
diff --git a/hw/xprint/ps/PsMisc.c b/hw/xprint/ps/PsMisc.c
index 0df039e..8d5005f 100644
--- a/hw/xprint/ps/PsMisc.c
+++ b/hw/xprint/ps/PsMisc.c
@@ -175,7 +175,7 @@ GetPropString(
     if(atom != BAD_RESOURCE)
     {
         WindowPtr pPropWin;
-	int n;
+	int rc, n;
 */
 
 	/*
@@ -186,15 +186,12 @@ GetPropString(
         for(pPropWin = pWin; pPropWin != (WindowPtr)NULL; 
 	    pPropWin = pPropWin->parent)
         {
-	    for(pProp = (PropertyPtr)(wUserProps(pPropWin)); 
-		pProp != (PropertyPtr)NULL;
-	        pProp = pProp->next)
-	    {
-                if (pProp->propertyName == atom)
-                    break;
-	    }
-	    if(pProp != (PropertyPtr)NULL)
-	        break;
+	    rc = dixLookupProperty(&pProp, pPropWin, atom,
+				   serverClient, DixReadAccess);
+	    if (rc == Success)
+		break;
+	    else
+		pProp = NULL;
         }
 	if(pProp == (PropertyPtr)NULL)
 	    return (char *)NULL;
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index d17cf8c..8bfde4b 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -154,9 +154,9 @@ PsCreateWindow(WindowPtr pWin)
 	    {
                 propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
 				    TRUE);
-	        ChangeWindowProperty(pWin, propName, XA_STRING, 8, 
-			             PropModeReplace,  strlen(propVal), 
-			             (pointer)propVal, FALSE);
+	        dixChangeWindowProperty(serverClient, pWin, propName, XA_STRING,
+					8, PropModeReplace, strlen(propVal),
+					(pointer)propVal, FALSE);
 	        xfree(propVal);
 	    }
 	}
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index c460ec6..072e57f 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -154,8 +154,8 @@ AppleWMSetScreenOrigin(
     data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
                 + darwinMainScreenY);
 
-    ChangeWindowProperty(pWin, xa_native_screen_origin(), XA_INTEGER,
-                         32, PropModeReplace, 2, data, TRUE);
+    dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
+			    XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
 }
 
 /* Window managers can set the _APPLE_NO_ORDER_IN property on windows
@@ -169,15 +169,11 @@ AppleWMDoReorderWindow(
 {
     Atom atom;
     PropertyPtr prop;
+    int rc;
 
     atom = xa_apple_no_order_in();
-    for (prop = wUserProps(pWin); prop != NULL; prop = prop->next)
-    {
-        if (prop->propertyName == atom && prop->type == atom)
-            return FALSE;
-    }
-
-    return TRUE;
+    rc = dixLookupProperty(&prop, pWin, atom, serverClient, DixReadAccess);
+    return (rc == Success) && (prop->type == atom);
 }
 
 
diff --git a/hw/xquartz/quartzPasteboard.c b/hw/xquartz/quartzPasteboard.c
index 0cecff5..0bf84f5 100644
--- a/hw/xquartz/quartzPasteboard.c
+++ b/hw/xquartz/quartzPasteboard.c
@@ -43,9 +43,6 @@
 #include "selection.h"
 #include "globals.h"
 
-extern Selection *CurrentSelections;
-extern int NumCurrentSelections;
-
 
 // Helper function to read the X11 cut buffer
 // FIXME: What about multiple screens? Currently, this reads the first
@@ -54,18 +51,16 @@ extern int NumCurrentSelections;
 // Returns NULL if there is no cut text or there is not enough memory.
 static char * QuartzReadCutBuffer(void)
 {
-    int i;
+    int rc, i;
     char *text = NULL;
 
     for (i = 0; i < screenInfo.numScreens; i++) {
         ScreenPtr pScreen = screenInfo.screens[i];
         PropertyPtr pProp;
 
-        pProp = wUserProps (WindowTable[pScreen->myNum]);
-        while (pProp && pProp->propertyName != XA_CUT_BUFFER0) {
-	    pProp = pProp->next;
-        }
-        if (! pProp) continue;
+	rc = dixLookupProperty(&pProp, WindowTable[pScreen->myNum],
+			       XA_CUT_BUFFER0, serverClient, DixReadAccess);
+        if (rc != Success) continue;
         if (pProp->type != XA_STRING) continue;
         if (pProp->format != 8) continue;
 
@@ -108,43 +103,40 @@ void QuartzReadPasteboard(void)
 
     if ((text && oldText && !strequal(text, oldText)) ||
         (text && !oldText)) {
-        int scrn, sel;
+        int scrn, rc;
+	Selection *pSel;
 
         for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
 	    ScreenPtr pScreen = screenInfo.screens[scrn];
 	    // Set the cut buffers on each screen
 	    // fixme really on each screen?
-	    ChangeWindowProperty(WindowTable[pScreen->myNum], XA_CUT_BUFFER0,
-				 XA_STRING, 8, PropModeReplace,
-				 strlen(text), (pointer)text, TRUE);
+	    dixChangeWindowProperty(serverClient, WindowTable[pScreen->myNum],
+				    XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace,
+				    strlen(text), (pointer)text, TRUE);
         }
 
         // Undo any current X selection (similar to code in dispatch.c)
         // FIXME: what about secondary selection?
         // FIXME: only touch first XA_PRIMARY selection?
-        sel = 0;
-        while ((sel < NumCurrentSelections)  &&
-	       CurrentSelections[sel].selection != XA_PRIMARY)
-	    sel++;
-        if (sel < NumCurrentSelections) {
+	rc = dixLookupSelection(&pSel, XA_PRIMARY, serverClient,
+				DixSetAttrAccess);
+        if (rc == Success) {
 	    // Notify client if necessary
-	    if (CurrentSelections[sel].client) {
+	    if (pSel->client) {
 	        xEvent event;
 
 	        event.u.u.type = SelectionClear;
 		event.u.selectionClear.time = GetTimeInMillis();
-		event.u.selectionClear.window = CurrentSelections[sel].window;
-		event.u.selectionClear.atom = CurrentSelections[sel].selection;
-		TryClientEvents(CurrentSelections[sel].client, &event, 1,
-				NoEventMask, NoEventMask /*CantBeFiltered*/,
-				NullGrab);
+		event.u.selectionClear.window = pSel->window;
+		event.u.selectionClear.atom = pSel->selection;
+		TryClientEvents(pSel->client, &event, 1, NoEventMask,
+				NoEventMask /*CantBeFiltered*/, NullGrab);
 	    }
 
 	    // Erase it
-	    // FIXME: need to erase .selection too? dispatch.c doesn't
-	    CurrentSelections[sel].pWin = NullWindow;
-	    CurrentSelections[sel].window = None;
-	    CurrentSelections[sel].client = NullClient;
+	    pSel->pWin = NullWindow;
+	    pSel->window = None;
+	    pSel->client = NullClient;
         }
     }
 
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index b9a33de..864ef0d 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -90,8 +90,8 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
         /* FIXME: move this to AppleWM extension */
 
         data = native_id;
-        ChangeWindowProperty(pFrame->win, xa_native_window_id(),
-                             XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+        dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
+				XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
     }
 }
 
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 4b4cd3d..6f4e2c9 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -1087,6 +1087,6 @@ winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
   /* FIXME: move this to WindowsWM extension */
 
   lData = (long) pRLWinPriv->hWnd;
-  ChangeWindowProperty (pFrame->win, AtmWindowsWmNativeHwnd (),
-			XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
+  dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
+			  XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
 }
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 7285f95..0dad44a 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -181,8 +181,8 @@ set_screen_origin (WindowPtr pWin)
   data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
 	     + darwinMainScreenY);
 
-  ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER,
-			32, PropModeReplace, 2, data, TRUE);
+  dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
+			  XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
 }
 
 /*
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 2b5f1fb..c0afad0 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -222,8 +222,8 @@ char *			pval;
 	ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
 								out,len);
     }
-    ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
-							len,pval,True);
+    dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8,
+			    PropModeReplace, len, pval, True);
     xfree(pval);
     return True;
 }
-- 
1.5.4.3




More information about the xorg mailing list