From 0f834b91a4768673833ab4917e87d86c237bb1a6 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 23 Mar 2012 10:05:55 +0100 Subject: libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update 23 Mar 2012 --- xorg-server/hw/dmx/dmxprop.c | 241 ++++++++++++++++++++++++------------------- 1 file changed, 134 insertions(+), 107 deletions(-) (limited to 'xorg-server/hw/dmx/dmxprop.c') diff --git a/xorg-server/hw/dmx/dmxprop.c b/xorg-server/hw/dmx/dmxprop.c index b4695dd5d..4be2dbd4c 100644 --- a/xorg-server/hw/dmx/dmxprop.c +++ b/xorg-server/hw/dmx/dmxprop.c @@ -62,7 +62,7 @@ #include "dmx.h" #include "dmxprop.h" #include "dmxlog.h" -#include /* For XmuGetHostname */ +#include /* For XmuGetHostname */ /** Holds the window id of all DMX windows on the backend X server. */ #define DMX_ATOMNAME "DMX_NAME" @@ -72,95 +72,108 @@ extern char *display; -static int dmxPropertyErrorHandler(Display *dpy, XErrorEvent *ev) +static int +dmxPropertyErrorHandler(Display * dpy, XErrorEvent * ev) { return 0; } -static const unsigned char *dmxPropertyIdentifier(void) +static const unsigned char * +dmxPropertyIdentifier(void) { - /* RATS: These buffers are only used in - * length-limited calls. */ - char hostname[256]; - static char buf[128]; - static int initialized = 0; - - if (initialized++) return (unsigned char *)buf; - + /* RATS: These buffers are only used in + * length-limited calls. */ + char hostname[256]; + static char buf[128]; + static int initialized = 0; + + if (initialized++) + return (unsigned char *) buf; + XmuGetHostname(hostname, sizeof(hostname)); snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display); - return (unsigned char *)buf; + return (unsigned char *) buf; } /** Starting with the \a start screen, iterate over all of the screens * on the same physical X server as \a start, calling \a f with the * screen and the \a closure. (The common case is that \a start is the * only DMX window on the backend X server.) */ -void *dmxPropertyIterate(DMXScreenInfo *start, - void *(*f)(DMXScreenInfo *dmxScreen, void *), - void *closure) +void * +dmxPropertyIterate(DMXScreenInfo * start, + void *(*f) (DMXScreenInfo * dmxScreen, void *), + void *closure) { DMXScreenInfo *pt; if (!start->next) { - if (!start->beDisplay) return NULL; + if (!start->beDisplay) + return NULL; return f(start, closure); } - for (pt = start->next; /* condition at end of loop */; pt = pt->next) { + for (pt = start->next; /* condition at end of loop */ ; pt = pt->next) { void *retval; + /* beDisplay ban be NULL if a screen was detached */ dmxLog(dmxDebug, "pt = %p\n", pt); dmxLog(dmxDebug, "pt->beDisplay = %p\n", pt->beDisplay); - if (pt->beDisplay && (retval = f(pt, closure))) return retval; - if (pt == start) break; + if (pt->beDisplay && (retval = f(pt, closure))) + return retval; + if (pt == start) + break; } return NULL; } /** Returns 0 if this is the only Xdmx session on the display; 1 * otherwise. */ -static int dmxPropertyCheckOtherServers(DMXScreenInfo *dmxScreen, Atom atom) +static int +dmxPropertyCheckOtherServers(DMXScreenInfo * dmxScreen, Atom atom) { - Display *dpy = dmxScreen->beDisplay; + Display *dpy = dmxScreen->beDisplay; XTextProperty tp; XTextProperty tproot; - const char *pt; - int retcode = 0; - char **list = NULL; - int count = 0; - int i; - int (*dmxOldHandler)(Display *, XErrorEvent *); + const char *pt; + int retcode = 0; + char **list = NULL; + int count = 0; + int i; + int (*dmxOldHandler) (Display *, XErrorEvent *); if (!dpy) - return 0; - - if (!XGetTextProperty(dpy, RootWindow(dpy,0), &tproot, atom) - || !tproot.nitems) return 0; - - /* Ignore BadWindow errors for this - * routine because the window id stored - * in the property might be old */ + return 0; + + if (!XGetTextProperty(dpy, RootWindow(dpy, 0), &tproot, atom) + || !tproot.nitems) + return 0; + + /* Ignore BadWindow errors for this + * routine because the window id stored + * in the property might be old */ dmxOldHandler = XSetErrorHandler(dmxPropertyErrorHandler); - for (pt = (const char *)tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) { + for (pt = (const char *) tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) { if ((pt = strchr(pt, ','))) { - Window win = strtol(pt+1, NULL, 10); + Window win = strtol(pt + 1, NULL, 10); + if (XGetTextProperty(dpy, win, &tp, atom) && tp.nitems) { - if (!strncmp((char *)tp.value, DMX_IDENT, strlen(DMX_IDENT))) { + if (!strncmp((char *) tp.value, DMX_IDENT, strlen(DMX_IDENT))) { int flag = 0; + for (i = 0; i < count; i++) - if (!strcmp(list[i], (char *)tp.value)) { + if (!strcmp(list[i], (char *) tp.value)) { ++flag; break; } - if (flag) continue; + if (flag) + continue; ++retcode; dmxLogOutputWarning(dmxScreen, "%s also running on %s\n", tp.value, dmxScreen->name); list = realloc(list, ++count * sizeof(*list)); - list[count-1] = malloc(tp.nitems + 2); - strncpy(list[count-1], (char *)tp.value, tp.nitems + 1); + list[count - 1] = malloc(tp.nitems + 2); + strncpy(list[count - 1], (char *) tp.value, tp.nitems + 1); } XFree(tp.value); } @@ -168,7 +181,8 @@ static int dmxPropertyCheckOtherServers(DMXScreenInfo *dmxScreen, Atom atom) } XSetErrorHandler(dmxOldHandler); - for (i = 0; i < count; i++) free(list[i]); + for (i = 0; i < count; i++) + free(list[i]); free(list); XFree(tproot.value); if (!retcode) @@ -179,40 +193,45 @@ static int dmxPropertyCheckOtherServers(DMXScreenInfo *dmxScreen, Atom atom) /** Returns NULL if this is the only Xdmx window on the display. * Otherwise, returns a pointer to the dmxScreen of the other windows on * the display. */ -static DMXScreenInfo *dmxPropertyCheckOtherWindows(DMXScreenInfo *dmxScreen, - Atom atom) +static DMXScreenInfo * +dmxPropertyCheckOtherWindows(DMXScreenInfo * dmxScreen, Atom atom) { - Display *dpy = dmxScreen->beDisplay; - const unsigned char *id = dmxPropertyIdentifier(); - XTextProperty tproot; - XTextProperty tp; - const char *pt; - int (*dmxOldHandler)(Display *, XErrorEvent *); + Display *dpy = dmxScreen->beDisplay; + const unsigned char *id = dmxPropertyIdentifier(); + XTextProperty tproot; + XTextProperty tp; + const char *pt; + int (*dmxOldHandler) (Display *, XErrorEvent *); if (!dpy) - return NULL; + return NULL; - if (!XGetTextProperty(dpy, RootWindow(dpy,0), &tproot, atom) - || !tproot.nitems) return 0; + if (!XGetTextProperty(dpy, RootWindow(dpy, 0), &tproot, atom) + || !tproot.nitems) + return 0; - /* Ignore BadWindow errors for this - * routine because the window id stored - * in the property might be old */ + /* Ignore BadWindow errors for this + * routine because the window id stored + * in the property might be old */ dmxOldHandler = XSetErrorHandler(dmxPropertyErrorHandler); - for (pt = (const char *)tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) { + for (pt = (const char *) tproot.value; pt && *pt; pt = pt ? pt + 1 : NULL) { if ((pt = strchr(pt, ','))) { - Window win = strtol(pt+1, NULL, 10); + Window win = strtol(pt + 1, NULL, 10); + if (XGetTextProperty(dpy, win, &tp, atom) && tp.nitems) { - dmxLog(dmxDebug,"On %s/%lu: %s\n", + dmxLog(dmxDebug, "On %s/%lu: %s\n", dmxScreen->name, win, tp.value); - if (!strncmp((char *)tp.value, (char *)id, - strlen((char *)id))) { + if (!strncmp((char *) tp.value, (char *) id, + strlen((char *) id))) { int idx; - - if (!(pt = strchr((char *)tp.value, ','))) continue; - idx = strtol(pt+1, NULL, 10); - if (idx < 0 || idx >= dmxNumScreens) continue; - if (dmxScreens[idx].scrnWin != win) continue; + + if (!(pt = strchr((char *) tp.value, ','))) + continue; + idx = strtol(pt + 1, NULL, 10); + if (idx < 0 || idx >= dmxNumScreens) + continue; + if (dmxScreens[idx].scrnWin != win) + continue; XSetErrorHandler(dmxOldHandler); return &dmxScreens[idx]; } @@ -227,22 +246,23 @@ static DMXScreenInfo *dmxPropertyCheckOtherWindows(DMXScreenInfo *dmxScreen, /** Returns 0 if this is the only Xdmx session on the display; 1 * otherwise. */ -int dmxPropertyDisplay(DMXScreenInfo *dmxScreen) +int +dmxPropertyDisplay(DMXScreenInfo * dmxScreen) { - Atom atom; - const unsigned char *id = dmxPropertyIdentifier(); - Display *dpy = dmxScreen->beDisplay; + Atom atom; + const unsigned char *id = dmxPropertyIdentifier(); + Display *dpy = dmxScreen->beDisplay; if (!dpy) - return 0; + return 0; atom = XInternAtom(dpy, DMX_ATOMNAME, False); if (dmxPropertyCheckOtherServers(dmxScreen, atom)) { dmxScreen->shared = 1; return 1; } - XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8, - PropModeReplace, id, strlen((char *)id)); + XChangeProperty(dpy, RootWindow(dpy, 0), atom, XA_STRING, 8, + PropModeReplace, id, strlen((char *) id)); return 0; } @@ -251,18 +271,19 @@ int dmxPropertyDisplay(DMXScreenInfo *dmxScreen) * names because there can be multiple synonyms for the same display, * some of which cannot be determined without accessing the display * itself (e.g., domain aliases or machines with multiple NICs). */ -int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name) +int +dmxPropertySameDisplay(DMXScreenInfo * dmxScreen, const char *name) { - Display *dpy0 = dmxScreen->beDisplay; - Atom atom0; - XTextProperty tp0; - Display *dpy1 = NULL; - Atom atom1; - XTextProperty tp1; - int retval = 0; + Display *dpy0 = dmxScreen->beDisplay; + Atom atom0; + XTextProperty tp0; + Display *dpy1 = NULL; + Atom atom1; + XTextProperty tp1; + int retval = 0; if (!dpy0) - return 0; + return 0; tp0.nitems = 0; tp1.nitems = 0; @@ -271,7 +292,7 @@ int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name) dmxLog(dmxWarning, "No atom on %s\n", dmxScreen->name); return 0; } - if (!XGetTextProperty(dpy0, RootWindow(dpy0,0), &tp0, atom0) + if (!XGetTextProperty(dpy0, RootWindow(dpy0, 0), &tp0, atom0) || !tp0.nitems) { dmxLog(dmxWarning, "No text property on %s\n", dmxScreen->name); return 0; @@ -286,17 +307,21 @@ int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name) dmxLog(dmxDebug, "No atom on %s\n", name); goto cleanup; } - if (!XGetTextProperty(dpy1, RootWindow(dpy1,0), &tp1, atom1) + if (!XGetTextProperty(dpy1, RootWindow(dpy1, 0), &tp1, atom1) || !tp1.nitems) { dmxLog(dmxDebug, "No text property on %s\n", name); goto cleanup; } - if (!strcmp((char *)tp0.value, (char *)tp1.value)) retval = 1; - - cleanup: - if (tp0.nitems) XFree(tp0.value); - if (tp1.nitems) XFree(tp1.value); - if (dpy1) XCloseDisplay(dpy1); + if (!strcmp((char *) tp0.value, (char *) tp1.value)) + retval = 1; + + cleanup: + if (tp0.nitems) + XFree(tp0.value); + if (tp1.nitems) + XFree(tp1.value); + if (dpy1) + XCloseDisplay(dpy1); return retval; } @@ -313,36 +338,38 @@ int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name) * * "#DMX_IDENT::," */ -void dmxPropertyWindow(DMXScreenInfo *dmxScreen) +void +dmxPropertyWindow(DMXScreenInfo * dmxScreen) { - Atom atom; - const unsigned char *id = dmxPropertyIdentifier(); - Display *dpy = dmxScreen->beDisplay; - Window win = dmxScreen->scrnWin; - DMXScreenInfo *other; - char buf[128]; /* RATS: only used with snprintf */ + Atom atom; + const unsigned char *id = dmxPropertyIdentifier(); + Display *dpy = dmxScreen->beDisplay; + Window win = dmxScreen->scrnWin; + DMXScreenInfo *other; + char buf[128]; /* RATS: only used with snprintf */ if (!dpy) - return; /* FIXME: What should be done here if Xdmx is started - * with this screen initially detached? - */ + return; /* FIXME: What should be done here if Xdmx is started + * with this screen initially detached? + */ atom = XInternAtom(dpy, DMX_ATOMNAME, False); if ((other = dmxPropertyCheckOtherWindows(dmxScreen, atom))) { DMXScreenInfo *tmp = dmxScreen->next; - dmxScreen->next = (other->next ? other->next : other); - other->next = (tmp ? tmp : dmxScreen); + + dmxScreen->next = (other->next ? other->next : other); + other->next = (tmp ? tmp : dmxScreen); dmxLog(dmxDebug, "%d/%s/%lu and %d/%s/%lu are on the same backend\n", dmxScreen->index, dmxScreen->name, dmxScreen->scrnWin, other->index, other->name, other->scrnWin); } snprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index, - (long unsigned)win); - XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8, - PropModeAppend, (unsigned char *)buf, strlen(buf)); + (long unsigned) win); + XChangeProperty(dpy, RootWindow(dpy, 0), atom, XA_STRING, 8, + PropModeAppend, (unsigned char *) buf, strlen(buf)); snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index); XChangeProperty(dpy, win, atom, XA_STRING, 8, - PropModeAppend, (unsigned char *)buf, strlen(buf)); + PropModeAppend, (unsigned char *) buf, strlen(buf)); } -- cgit v1.2.3