dix: Modify callers of property and selection API to use new interfaces.

This commit is contained in:
Eamon Walsh 2008-02-29 18:00:27 -05:00 committed by Eamon Walsh
parent cc76ea6e3a
commit ef60632e20
11 changed files with 58 additions and 77 deletions

View File

@ -172,12 +172,11 @@ xf86CreateRootWindow(WindowPtr pWin)
Atom prop; Atom prop;
prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE); prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
err = ChangeWindowProperty(pWin, err = dixChangeWindowProperty(serverClient, pWin,
prop, pProp->type, prop, pProp->type,
pProp->format, PropModeReplace, pProp->format, PropModeReplace,
pProp->size, pProp->data, pProp->size, pProp->data,
FALSE FALSE);
);
} }
/* Look at err */ /* Look at err */

View File

@ -115,7 +115,7 @@ GetPropString(
if(atom != BAD_RESOURCE) if(atom != BAD_RESOURCE)
{ {
WindowPtr pPropWin; WindowPtr pPropWin;
int n; int rc, n;
/* /*
* The atom has been defined, but it might only exist as a * The atom has been defined, but it might only exist as a
@ -124,15 +124,12 @@ GetPropString(
for(pPropWin = pWin; pPropWin != (WindowPtr)NULL; for(pPropWin = pWin; pPropWin != (WindowPtr)NULL;
pPropWin = pPropWin->parent) pPropWin = pPropWin->parent)
{ {
for(pProp = (PropertyPtr)(wUserProps(pPropWin)); rc = dixLookupProperty(&pProp, pPropWin, atom,
pProp != (PropertyPtr)NULL; serverClient, DixReadAccess);
pProp = pProp->next) if (rc == Success)
{
if (pProp->propertyName == atom)
break;
}
if(pProp != (PropertyPtr)NULL)
break; break;
else
pProp = NULL;
} }
if(pProp == (PropertyPtr)NULL) if(pProp == (PropertyPtr)NULL)
return (char *)NULL; return (char *)NULL;

View File

@ -128,8 +128,8 @@ PclCreateWindow(
{ {
propName = MakeAtom(propStrings[i], strlen(propStrings[i]), propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
TRUE); TRUE);
ChangeWindowProperty(pWin, propName, XA_STRING, 8, dixChangeWindowProperty(serverClient, pWin, propName, XA_STRING,
PropModeReplace, strlen(propVal), 8, PropModeReplace, strlen(propVal),
(pointer)propVal, FALSE); (pointer)propVal, FALSE);
xfree(propVal); xfree(propVal);
} }

View File

@ -175,7 +175,7 @@ GetPropString(
if(atom != BAD_RESOURCE) if(atom != BAD_RESOURCE)
{ {
WindowPtr pPropWin; WindowPtr pPropWin;
int n; int rc, n;
*/ */
/* /*
@ -186,15 +186,12 @@ GetPropString(
for(pPropWin = pWin; pPropWin != (WindowPtr)NULL; for(pPropWin = pWin; pPropWin != (WindowPtr)NULL;
pPropWin = pPropWin->parent) pPropWin = pPropWin->parent)
{ {
for(pProp = (PropertyPtr)(wUserProps(pPropWin)); rc = dixLookupProperty(&pProp, pPropWin, atom,
pProp != (PropertyPtr)NULL; serverClient, DixReadAccess);
pProp = pProp->next) if (rc == Success)
{
if (pProp->propertyName == atom)
break;
}
if(pProp != (PropertyPtr)NULL)
break; break;
else
pProp = NULL;
} }
if(pProp == (PropertyPtr)NULL) if(pProp == (PropertyPtr)NULL)
return (char *)NULL; return (char *)NULL;

View File

@ -154,8 +154,8 @@ PsCreateWindow(WindowPtr pWin)
{ {
propName = MakeAtom(propStrings[i], strlen(propStrings[i]), propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
TRUE); TRUE);
ChangeWindowProperty(pWin, propName, XA_STRING, 8, dixChangeWindowProperty(serverClient, pWin, propName, XA_STRING,
PropModeReplace, strlen(propVal), 8, PropModeReplace, strlen(propVal),
(pointer)propVal, FALSE); (pointer)propVal, FALSE);
xfree(propVal); xfree(propVal);
} }

View File

@ -154,8 +154,8 @@ AppleWMSetScreenOrigin(
data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+ darwinMainScreenY); + darwinMainScreenY);
ChangeWindowProperty(pWin, xa_native_screen_origin(), XA_INTEGER, dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
32, PropModeReplace, 2, data, TRUE); XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
} }
/* Window managers can set the _APPLE_NO_ORDER_IN property on windows /* Window managers can set the _APPLE_NO_ORDER_IN property on windows
@ -169,15 +169,11 @@ AppleWMDoReorderWindow(
{ {
Atom atom; Atom atom;
PropertyPtr prop; PropertyPtr prop;
int rc;
atom = xa_apple_no_order_in(); atom = xa_apple_no_order_in();
for (prop = wUserProps(pWin); prop != NULL; prop = prop->next) rc = dixLookupProperty(&prop, pWin, atom, serverClient, DixReadAccess);
{ return (rc == Success) && (prop->type == atom);
if (prop->propertyName == atom && prop->type == atom)
return FALSE;
}
return TRUE;
} }

View File

@ -43,9 +43,6 @@
#include "selection.h" #include "selection.h"
#include "globals.h" #include "globals.h"
extern Selection *CurrentSelections;
extern int NumCurrentSelections;
// Helper function to read the X11 cut buffer // Helper function to read the X11 cut buffer
// FIXME: What about multiple screens? Currently, this reads the first // 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. // Returns NULL if there is no cut text or there is not enough memory.
static char * QuartzReadCutBuffer(void) static char * QuartzReadCutBuffer(void)
{ {
int i; int rc, i;
char *text = NULL; char *text = NULL;
for (i = 0; i < screenInfo.numScreens; i++) { for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i]; ScreenPtr pScreen = screenInfo.screens[i];
PropertyPtr pProp; PropertyPtr pProp;
pProp = wUserProps (WindowTable[pScreen->myNum]); rc = dixLookupProperty(&pProp, WindowTable[pScreen->myNum],
while (pProp && pProp->propertyName != XA_CUT_BUFFER0) { XA_CUT_BUFFER0, serverClient, DixReadAccess);
pProp = pProp->next; if (rc != Success) continue;
}
if (! pProp) continue;
if (pProp->type != XA_STRING) continue; if (pProp->type != XA_STRING) continue;
if (pProp->format != 8) continue; if (pProp->format != 8) continue;
@ -108,43 +103,40 @@ void QuartzReadPasteboard(void)
if ((text && oldText && !strequal(text, oldText)) || if ((text && oldText && !strequal(text, oldText)) ||
(text && !oldText)) { (text && !oldText)) {
int scrn, sel; int scrn, rc;
Selection *pSel;
for (scrn = 0; scrn < screenInfo.numScreens; scrn++) { for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
ScreenPtr pScreen = screenInfo.screens[scrn]; ScreenPtr pScreen = screenInfo.screens[scrn];
// Set the cut buffers on each screen // Set the cut buffers on each screen
// fixme really on each screen? // fixme really on each screen?
ChangeWindowProperty(WindowTable[pScreen->myNum], XA_CUT_BUFFER0, dixChangeWindowProperty(serverClient, WindowTable[pScreen->myNum],
XA_STRING, 8, PropModeReplace, XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace,
strlen(text), (pointer)text, TRUE); strlen(text), (pointer)text, TRUE);
} }
// Undo any current X selection (similar to code in dispatch.c) // Undo any current X selection (similar to code in dispatch.c)
// FIXME: what about secondary selection? // FIXME: what about secondary selection?
// FIXME: only touch first XA_PRIMARY selection? // FIXME: only touch first XA_PRIMARY selection?
sel = 0; rc = dixLookupSelection(&pSel, XA_PRIMARY, serverClient,
while ((sel < NumCurrentSelections) && DixSetAttrAccess);
CurrentSelections[sel].selection != XA_PRIMARY) if (rc == Success) {
sel++;
if (sel < NumCurrentSelections) {
// Notify client if necessary // Notify client if necessary
if (CurrentSelections[sel].client) { if (pSel->client) {
xEvent event; xEvent event;
event.u.u.type = SelectionClear; event.u.u.type = SelectionClear;
event.u.selectionClear.time = GetTimeInMillis(); event.u.selectionClear.time = GetTimeInMillis();
event.u.selectionClear.window = CurrentSelections[sel].window; event.u.selectionClear.window = pSel->window;
event.u.selectionClear.atom = CurrentSelections[sel].selection; event.u.selectionClear.atom = pSel->selection;
TryClientEvents(CurrentSelections[sel].client, &event, 1, TryClientEvents(pSel->client, &event, 1, NoEventMask,
NoEventMask, NoEventMask /*CantBeFiltered*/, NoEventMask /*CantBeFiltered*/, NullGrab);
NullGrab);
} }
// Erase it // Erase it
// FIXME: need to erase .selection too? dispatch.c doesn't pSel->pWin = NullWindow;
CurrentSelections[sel].pWin = NullWindow; pSel->window = None;
CurrentSelections[sel].window = None; pSel->client = NullClient;
CurrentSelections[sel].client = NullClient;
} }
} }

View File

@ -90,7 +90,7 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
/* FIXME: move this to AppleWM extension */ /* FIXME: move this to AppleWM extension */
data = native_id; data = native_id;
ChangeWindowProperty(pFrame->win, xa_native_window_id(), dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE); XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
} }
} }

View File

@ -1087,6 +1087,6 @@ winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
/* FIXME: move this to WindowsWM extension */ /* FIXME: move this to WindowsWM extension */
lData = (long) pRLWinPriv->hWnd; lData = (long) pRLWinPriv->hWnd;
ChangeWindowProperty (pFrame->win, AtmWindowsWmNativeHwnd (), dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE); XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
} }

View File

@ -181,8 +181,8 @@ set_screen_origin (WindowPtr pWin)
data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+ darwinMainScreenY); + darwinMainScreenY);
ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER, dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
32, PropModeReplace, 2, data, TRUE); XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
} }
/* /*

View File

@ -222,8 +222,8 @@ char * pval;
ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n", ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
out,len); out,len);
} }
ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace, dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8,
len,pval,True); PropModeReplace, len, pval, True);
xfree(pval); xfree(pval);
return True; return True;
} }