/* * XdbeGetBackBufferAttributes - * This function returns the attributes associated with the specified * buffer. */ XdbeBackBufferAttributes *XdbeGetBackBufferAttributes( Display *dpy, XdbeBackBuffer buffer) { XExtDisplayInfo *info = find_display(dpy); register xDbeGetBackBufferAttributesReq *req; xDbeGetBackBufferAttributesReply rep; XdbeBackBufferAttributes *attr; DbeCheckExtension(dpy, info, (XdbeBackBufferAttributes *)NULL); if (!(attr = (XdbeBackBufferAttributes *)Xmalloc(sizeof(XdbeBackBufferAttributes)))) { return NULL; } LockDisplay(dpy); DbeGetReq(DbeGetBackBufferAttributes, req, info); req->buffer = buffer; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return NULL; } attr->window = rep.attributes; UnlockDisplay (dpy); SyncHandle (); return attr; }
/* * XdbeSwapBuffers - * This function swaps the front and back buffers for a list of windows. * The argument num_windows specifies how many windows are to have their * buffers swapped; it is the number of elements in the swap_info array. * The argument swap_info specifies the information needed per window * to do the swap. */ Status XdbeSwapBuffers ( Display *dpy, XdbeSwapInfo *swap_info, int num_windows) { XExtDisplayInfo *info = find_display (dpy); register xDbeSwapBuffersReq *req; int i; DbeCheckExtension (dpy, info, (Status)0 /* failure */); LockDisplay (dpy); DbeGetReq (DbeSwapBuffers, req, info); req->length += 2*num_windows; req->n = num_windows; /* We need to handle 64-bit machines, where we can not use PackData32 * directly because info would be lost in translating from 32- to 64-bit. * Instead we send data via a loop that accounts for the translation. */ for (i = 0; i < num_windows; i++) { char tmp[4]; Data32 (dpy, (long *)&swap_info[i].swap_window, 4); tmp[0] = swap_info[i].swap_action; Data (dpy, (char *)tmp, 4); } UnlockDisplay (dpy); SyncHandle (); return (Status)1; /* success */ } /* XdbeSwapBuffers() */
XdbeBackBuffer XdbeAllocateBackBufferName( Display *dpy, Window window, XdbeSwapAction swap_action) { XExtDisplayInfo *info = find_display (dpy); register xDbeAllocateBackBufferNameReq *req; XdbeBackBuffer buffer; /* make sure extension is available; if not, return the * third parameter (0). */ DbeCheckExtension (dpy, info, (XdbeBackBuffer)0); /* allocate the id */ buffer = XAllocID (dpy); LockDisplay(dpy); DbeGetReq(DbeAllocateBackBufferName, req, info); req->window = window; req->swapAction = (unsigned char)swap_action; req->buffer = buffer; UnlockDisplay (dpy); SyncHandle (); return buffer; } /* XdbeAllocateBackBufferName() */
/* * XdbeEndIdiom - * This function marks the end of an idiom sequence. */ Status XdbeEndIdiom (Display *dpy) { XExtDisplayInfo *info = find_display(dpy); register xDbeEndIdiomReq *req; DbeCheckExtension (dpy, info, (Status)0 /* failure */); LockDisplay (dpy); DbeGetReq (DbeEndIdiom, req, info); UnlockDisplay (dpy); SyncHandle (); return (Status)1; /* success */ }
/* * XdbeDeallocateBackBufferName - * This function frees a drawable ID, buffer, that was obtained via * XdbeAllocateBackBufferName. The buffer must refer to the back buffer * of the specified window, or a protocol error results. */ Status XdbeDeallocateBackBufferName ( Display *dpy, XdbeBackBuffer buffer) { XExtDisplayInfo *info = find_display (dpy); register xDbeDeallocateBackBufferNameReq *req; DbeCheckExtension (dpy, info, (Status)0 /* failure */); LockDisplay (dpy); DbeGetReq (DbeDeallocateBackBufferName, req, info); req->buffer = buffer; UnlockDisplay (dpy); SyncHandle (); return (Status)1; /* success */ }
/* * XdbeGetVisualInfo - * This function returns information about which visuals support * double buffering. The argument num_screens specifies how many * elements there are in the screen_specifiers list. Each drawable * in screen_specifiers designates a screen for which the supported * visuals are being requested. If num_screens is zero, information * for all screens is requested. In this case, upon return from this * function, num_screens will be set to the number of screens that were * found. If an error occurs, this function returns NULL, else it returns * a pointer to a list of XdbeScreenVisualInfo structures of length * num_screens. The nth element in the returned list corresponds to the * nth drawable in the screen_specifiers list, unless num_screens was * passed in with the value zero, in which case the nth element in the * returned list corresponds to the nth screen of the server, starting * with screen zero. */ XdbeScreenVisualInfo *XdbeGetVisualInfo ( Display *dpy, Drawable *screen_specifiers, int *num_screens) /* SEND and RETURN */ { XExtDisplayInfo *info = find_display(dpy); register xDbeGetVisualInfoReq *req; xDbeGetVisualInfoReply rep; XdbeScreenVisualInfo *scrVisInfo; int i; DbeCheckExtension (dpy, info, (XdbeScreenVisualInfo *)NULL); LockDisplay (dpy); DbeGetReq(DbeGetVisualInfo, req, info); req->length = 2 + *num_screens; req->n = *num_screens; Data32 (dpy, screen_specifiers, (*num_screens * sizeof (CARD32))); if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return NULL; } /* return the number of screens actually found if we * requested information about all screens (*num_screens == 0) */ if (*num_screens == 0) *num_screens = rep.m; /* allocate list of visual information to be returned */ if (!(scrVisInfo = (XdbeScreenVisualInfo *)Xmalloc( (unsigned)(*num_screens * sizeof(XdbeScreenVisualInfo))))) { UnlockDisplay (dpy); SyncHandle (); return NULL; } for (i = 0; i < *num_screens; i++) { int nbytes; int j; long c; _XRead32 (dpy, &c, sizeof(CARD32)); scrVisInfo[i].count = c; nbytes = scrVisInfo[i].count * sizeof(XdbeVisualInfo); /* if we can not allocate the list of visual/depth info * then free the lists that we already allocate as well * as the visual info list itself */ if (!(scrVisInfo[i].visinfo = (XdbeVisualInfo *)Xmalloc( (unsigned)nbytes))) { for (j = 0; j < i; j++) { Xfree ((char *)scrVisInfo[j].visinfo); } Xfree ((char *)scrVisInfo); UnlockDisplay (dpy); SyncHandle (); return NULL; } /* Read the visual info item into the wire structure. Then copy each * element into the library structure. The element sizes and/or * padding may be different in the two structures. */ for (j = 0; j < scrVisInfo[i].count; j++) { xDbeVisInfo xvi; _XRead (dpy, (char *)&xvi, sizeof(xDbeVisInfo)); scrVisInfo[i].visinfo[j].visual = xvi.visualID; scrVisInfo[i].visinfo[j].depth = xvi.depth; scrVisInfo[i].visinfo[j].perflevel = xvi.perfLevel; } } UnlockDisplay (dpy); SyncHandle (); return scrVisInfo; } /* XdbeGetVisualInfo() */