diff options
Diffstat (limited to 'nx-X11/lib/X11')
27 files changed, 0 insertions, 28470 deletions
diff --git a/nx-X11/lib/X11/ChkIfEv.c.NX.original b/nx-X11/lib/X11/ChkIfEv.c.NX.original deleted file mode 100644 index 0217af830..000000000 --- a/nx-X11/lib/X11/ChkIfEv.c.NX.original +++ /dev/null @@ -1,138 +0,0 @@ -/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1985, 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86$ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Check existing events in queue to find if any match. If so, return. - * If not, flush buffer and see if any more events are readable. If one - * matches, return. If all else fails, tell the user no events found. - */ - -Bool XCheckIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 3; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 2: - _XEventsQueued(dpy, QueuedAfterReading); - break; - case 1: - _XFlush(dpy); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} - -#ifdef NX_TRANS_SOCKET - -/* - * This is just like XCheckIfEvent() but doesn't - * flush the output buffer if it can't read new - * events. - */ - -Bool XCheckIfEventNoFlush (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 2; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 1: - _XEventsQueued(dpy, QueuedAfterReading); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} - -#endif diff --git a/nx-X11/lib/X11/ChkIfEv.c.X.original b/nx-X11/lib/X11/ChkIfEv.c.X.original deleted file mode 100644 index ff74bcd73..000000000 --- a/nx-X11/lib/X11/ChkIfEv.c.X.original +++ /dev/null @@ -1,85 +0,0 @@ -/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1985, 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86$ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Check existing events in queue to find if any match. If so, return. - * If not, flush buffer and see if any more events are readable. If one - * matches, return. If all else fails, tell the user no events found. - */ - -Bool XCheckIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 3; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 2: - _XEventsQueued(dpy, QueuedAfterReading); - break; - case 1: - _XFlush(dpy); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} diff --git a/nx-X11/lib/X11/ConnDis.c.NX.original b/nx-X11/lib/X11/ConnDis.c.NX.original deleted file mode 100644 index 30146a9f1..000000000 --- a/nx-X11/lib/X11/ConnDis.c.NX.original +++ /dev/null @@ -1,1465 +0,0 @@ -/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */ -/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */ - -/* - * This file contains operating system dependencies. - */ - -#define NEED_EVENTS - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xauth.h> -#include <X11/Xdmcp.h> -#include <stdio.h> -#include <ctype.h> - -#if !defined(WIN32) -#ifndef Lynx -#include <sys/socket.h> -#else -#include <socket.h> -#endif -#else -#include <X11/Xwindows.h> -#endif - -#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */ -#define X_CONNECTION_RETRIES 5 -#endif - -#ifdef LOCALCONN -#include <sys/utsname.h> -#endif - -#include "Xintconn.h" - -/* prototypes */ -static void GetAuthorization( - XtransConnInfo trans_conn, - int family, - char *saddr, - int saddrlen, - int idisplay, - char **auth_namep, - int *auth_namelenp, - char **auth_datap, - int *auth_datalenp); - -/* functions */ -static char *copystring (char *src, int len) -{ - char *dst = Xmalloc (len + 1); - - if (dst) { - strncpy (dst, src, len); - dst[len] = '\0'; - } - - return dst; -} - - -/* - * Attempts to connect to server, given display name. Returns file descriptor - * (network socket) or -1 if connection fails. Display names may be of the - * following format: - * - * [protocol/] [hostname] : [:] displaynumber [.screennumber] - * - * A string with exactly two colons seperating hostname from the display - * indicates a DECnet style name. Colons in the hostname may occur if an - * IPv6 numeric address is used as the hostname. An IPv6 numeric address - * may also end in a double colon, so three colons in a row indicates an - * IPv6 address ending in :: followed by :display. To make it easier for - * people to read, an IPv6 numeric address hostname may be surrounded by - * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined - * by IETF RFC 2732. - * - * If no hostname and no protocol is specified, the string is interpreted - * as the most efficient local connection to a server on the same machine. - * This is usually: - * - * o shared memory - * o local stream - * o UNIX domain socket - * o TCP to local host - * - * This function will eventually call the X Transport Interface functions - * which expects the hostname in the format: - * - * [protocol/] [hostname] : [:] displaynumber - * - */ -XtransConnInfo -_X11TransConnectDisplay ( - char *display_name, - char **fullnamep, /* RETURN */ - int *dpynump, /* RETURN */ - int *screenp, /* RETURN */ - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ - int family; - int saddrlen; - Xtransaddr *saddr; - char *lastp, *lastc, *p; /* char pointers */ - char *pprotocol = NULL; /* start of protocol name */ - char *phostname = NULL; /* start of host of display */ - char *pdpynum = NULL; /* start of dpynum of display */ - char *pscrnum = NULL; /* start of screen of display */ - Bool dnet = False; /* if true, then DECnet format */ - int idisplay = 0; /* required display number */ - int iscreen = 0; /* optional screen number */ - /* int (*connfunc)(); */ /* method to create connection */ - int len, hostlen; /* length tmp variable */ - int retry; /* retry counter */ - char addrbuf[128]; /* final address passed to - X Transport Interface */ - char* address = addrbuf; - XtransConnInfo trans_conn = NULL; /* transport connection object */ - int connect_stat; -#ifdef LOCALCONN - struct utsname sys; -#endif -#ifdef TCPCONN - char *tcphostname = NULL; /* A place to save hostname pointer */ -#endif - - p = display_name; - - saddrlen = 0; /* set so that we can clear later */ - saddr = NULL; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Called with display_name [%s].\n", display_name); -#endif - -#ifdef NX_TRANS_SOCKET - - /* - * Check if user selected the "nx" - * protocol or an "nx" hostname. - */ - - if (!strncasecmp(p, "nx/", 3) || !strcasecmp(p, "nx") || - !strncasecmp(p, "nx:", 3) || !strncasecmp(p, "nx,", 3)) - { - if (*(display_name + 2) == '/') - { - p += 3; - } - - pprotocol = copystring ("nx", 2); - - if (!pprotocol) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Forced protocol to [%s].\n", pprotocol); -#endif - - } - else - { - -#endif - - /* - * Step 0, find the protocol. This is delimited by the optional - * slash ('/'). - */ - for (lastp = p; *p && *p != ':' && *p != '/'; p++) ; - if (!*p) return NULL; /* must have a colon */ - - if (p != lastp && *p != ':') { /* protocol given? */ - pprotocol = copystring (lastp, p - lastp); - if (!pprotocol) goto bad; /* no memory */ - p++; /* skip the '/' */ - } else - p = display_name; /* reset the pointer in - case no protocol was given */ -#ifdef NX_TRANS_SOCKET - - } /* End of step 0. */ - - /* - * Check if user specified the "nx" protocol or - * hostname is "nx" or in the form "nx,...". - */ - - if (pprotocol && !strcasecmp(pprotocol, "nx")) - { - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Checking hostname [%s].\n", p); -#endif - - /* - * Options can include a "display=" tuple so - * need to scan right to left. - */ - - lastp = p; - lastc = NULL; - - for (; *p; p++) - if (*p == ':') - lastc = p; - - /* - * Don't complain if no screen was provided. - */ - - if (lastc) - { - phostname = copystring (lastp, lastc - lastp); - - p = lastc; - } - else - { - phostname = copystring (lastp, strlen(lastp)); - } - - if (!phostname) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Forced hostname [%s].\n", phostname); -#endif - - } - else - { - -#endif - - /* - * Step 1, find the hostname. This is delimited by either one colon, - * or two colons in the case of DECnet (DECnet Phase V allows a single - * colon in the hostname). (See note above regarding IPv6 numeric - * addresses with triple colons or [] brackets.) - */ - - lastp = p; - lastc = NULL; - for (; *p; p++) - if (*p == ':') - lastc = p; - - if (!lastc) return NULL; /* must have a colon */ - - if ((lastp != lastc) && (*(lastc - 1) == ':') -#if defined(IPv6) && defined(AF_INET6) - && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':')) -#endif - ) { - /* DECnet display specified */ - -#ifndef DNETCONN - goto bad; -#else - dnet = True; - /* override the protocol specified */ - if (pprotocol) - Xfree (pprotocol); - pprotocol = copystring ("dnet", 4); - hostlen = lastc - 1 - lastp; -#endif - } - else - hostlen = lastc - lastp; - - if (hostlen > 0) { /* hostname given? */ - phostname = copystring (lastp, hostlen); - if (!phostname) goto bad; /* no memory */ - } - - p = lastc; - -#ifdef LOCALCONN - /* check if phostname == localnodename AND protocol not specified */ - if (!pprotocol && phostname && uname(&sys) >= 0 && - !strncmp(phostname, sys.nodename, - (strlen(sys.nodename) < strlen(phostname) ? - strlen(phostname) : strlen(sys.nodename)))) - { -#ifdef TCPCONN - /* - * We'll first attempt to connect using the local transport. If - * this fails (which is the case if sshd X protocol forwarding is - * being used), retry using tcp and this hostname. - */ - tcphostname = copystring(phostname, strlen(phostname)); -#endif - Xfree (phostname); - phostname = copystring ("unix", 4); - } -#endif - -#ifdef NX_TRANS_SOCKET - - } /* End of step 1. */ - - /* - * Check if no display was specified. In this case - * search the "port=n" option in NX host string. - */ - - if (*p) - { - -#endif - - - /* - * Step 2, find the display number. This field is required and is - * delimited either by a nul or a period, depending on whether or not - * a screen number is present. - */ - - for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ; - if ((p == lastp) || /* required field */ - (*p != '\0' && *p != '.') || /* invalid non-digit terminator */ - !(pdpynum = copystring (lastp, p - lastp))) /* no memory */ - goto bad; - idisplay = atoi (pdpynum); - -#ifdef NX_TRANS_SOCKET - - } - else - { - char *host = NULL; - char *name = NULL; - char *value = NULL; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Searching port in port [%s].\n", phostname); -#endif - - if (!strncasecmp(phostname, "nx,", 3)) - { - host = copystring(phostname + 3, strlen(phostname) - 3); - } - - if (!host) goto bad; - - idisplay = -1; - - name = strtok(host, "="); - - while (name) - { - value = strtok(NULL, ","); - - if (value == NULL || strstr(value, "=") != NULL || - strstr(name, ",") != NULL || strlen(value) >= 128) - { - Xfree(host); - - goto bad; - } - else if (strcasecmp(name, "port") == 0) - { - idisplay = atoi(value); - - pdpynum = copystring(value, strlen(value)); - - if (!pdpynum) goto bad; - - break; - } - - name = strtok(NULL, "="); - } - - Xfree(host); - - if (idisplay == -1) - { - goto bad; - } - - } /* End of step 2. */ - -#endif - - - /* - * Step 3, find the screen number. This field is optional. It is - * present only if the display number was followed by a period (which - * we've already verified is the only non-nul character). - */ - - if (*p) { - for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ; - if (p != lastp) { - if (*p || /* non-digits */ - !(pscrnum = copystring (lastp, p - lastp))) /* no memory */ - goto bad; - iscreen = atoi (lastp); - } - } - - /* - * At this point, we know the following information: - * - * pprotocol protocol string or NULL - * phostname hostname string or NULL - * idisplay display number - * iscreen screen number - * dnet DECnet boolean - * - * We can now decide which transport to use based on the ConnectionFlags - * build parameter the hostname string. If phostname is NULL or equals - * the string "local", then choose the best transport. If phostname - * is "unix", then choose BSD UNIX domain sockets (if configured). - */ - -#ifdef NX_TRANS_SOCKET - - /* - * If user selected the "nx" protocol - * force "local" transport. - */ - - if (pprotocol && !strcasecmp(pprotocol, "nx")) - { - pprotocol = copystring ("local", 5); - - if (!pprotocol) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Converted protocol to [%s].\n", pprotocol); -#endif - - } - -#endif - -#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN) - if (!pprotocol) { - if (!phostname) { -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - pprotocol = copystring ("local", 5); -#if defined(TCPCONN) - tcphostname = copystring("localhost", 9); -#endif - } - else - { -#endif - pprotocol = copystring ("tcp", 3); - } - } -#endif - -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - /* - * Now that the defaults have been established, see if we have any - * special names that we have to override: - * - * :N => if UNIXCONN then unix-domain-socket - * ::N => if UNIXCONN then unix-domain-socket - * unix:N => if UNIXCONN then unix-domain-socket - * - * Note that if UNIXCONN isn't defined, then we can use the default - * transport connection function set above. - */ - - if (!phostname) { -#ifdef apollo - ; /* Unix domain sockets are *really* bad on apollos */ -#else - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); -#endif - } - else if (strcmp (phostname, "unix") == 0) { - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); - } -#endif - -#if defined(TCPCONN) - connect: -#endif - /* - * This seems kind of backwards, but we need to put the protocol, - * host, and port back together to pass to _X11TransOpenCOTSClient(). - */ - - { - int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) + - (phostname ? strlen(phostname) : 0) + - (pdpynum ? strlen(pdpynum) : 0); - if (olen > sizeof addrbuf) address = Xmalloc (olen); - } - if (!address) goto bad; - - sprintf(address,"%s/%s:%d", - pprotocol ? pprotocol : "", - phostname ? phostname : "", - idisplay ); - - /* - * Make the connection, also need to get the auth address info for - * the connection. Do retries in case server host has hit its - * backlog (which, unfortunately, isn't distinguishable from there not - * being a server listening at all, which is why we have to not retry - * too many times). - */ -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Entering connection loop.\n"); -#endif - for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- ) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransOpenCOTSClient(address) with address [%s].\n", address); -#endif - if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) - { - break; - } -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConnect(trans_conn,address).\n"); -#endif - if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 ) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransClose(trans_conn).\n"); -#endif - _X11TransClose(trans_conn); - trans_conn = NULL; - - if (connect_stat == TRANS_TRY_CONNECT_AGAIN) - { - sleep(1); - continue; - } - else - break; - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr).\n"); -#endif - _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr); - - /* - * The family is given in a socket format (ie AF_INET). This - * will convert it to the format used by the authorization and - * X protocol (ie FamilyInternet). - */ - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConvertAddress(&family, &saddrlen, &saddr).\n"); -#endif - if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 ) - { - _X11TransClose(trans_conn); - trans_conn = NULL; - sleep(1); - if (saddr) - { - free ((char *) saddr); - saddr = NULL; - } - continue; - } - - break; - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Out of connection loop.\n"); -#endif - if (address != addrbuf) Xfree (address); - address = addrbuf; - - if( trans_conn == NULL ) - goto bad; - - /* - * Set close-on-exec so that programs that fork() doesn't get confused. - */ - - _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1); - - /* - * Build the expanded display name: - * - * [host] : [:] dpy . scr \0 - */ - len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) + - strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1); - *fullnamep = (char *) Xmalloc (len); - if (!*fullnamep) goto bad; - - sprintf (*fullnamep, "%s%s%d.%d", - (phostname ? phostname : ""), - (dnet ? "::" : ":"), - idisplay, iscreen); - - *dpynump = idisplay; - *screenp = iscreen; - if (pprotocol) Xfree (pprotocol); - if (phostname) Xfree (phostname); - if (pdpynum) Xfree (pdpynum); - if (pscrnum) Xfree (pscrnum); -#ifdef TCPCONN - if (tcphostname) Xfree (tcphostname); -#endif - - GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay, - auth_namep, auth_namelenp, auth_datap, auth_datalenp); - return trans_conn; - - - /* - * error return; make sure everything is cleaned up. - */ - bad: - if (trans_conn) (void)_X11TransClose(trans_conn); - if (saddr) free ((char *) saddr); - if (pprotocol) Xfree (pprotocol); - if (phostname) Xfree (phostname); - if (address && address != addrbuf) { Xfree(address); address = addrbuf; } - -#if defined(TCPCONN) - if (tcphostname) { - pprotocol = copystring("tcp", 3); - phostname = tcphostname; - tcphostname = NULL; - goto connect; - } -#endif - - if (pdpynum) Xfree (pdpynum); - if (pscrnum) Xfree (pscrnum); - return NULL; - -} - -/* - * This is gross, but we need it for compatiblity. - * The test suite relies on the following interface. - * - */ - -int _XConnectDisplay ( - char *display_name, - char **fullnamep, /* RETURN */ - int *dpynump, /* RETURN */ - int *screenp, /* RETURN */ - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ - XtransConnInfo trans_conn; - - trans_conn = _X11TransConnectDisplay ( - display_name, fullnamep, dpynump, screenp, - auth_namep, auth_namelenp, auth_datap, auth_datalenp); - - if (trans_conn) - { - int fd = _X11TransGetConnectionNumber (trans_conn); - _X11TransFreeConnInfo (trans_conn); - return (fd); - } - else - return (-1); -} - - -/***************************************************************************** - * * - * Connection Utility Routines * - * * - *****************************************************************************/ - -/* - * Disconnect from server. - */ - -int _XDisconnectDisplay (trans_conn) - -XtransConnInfo trans_conn; - -{ - _X11TransDisconnect(trans_conn); - _X11TransClose(trans_conn); - return 0; -} - - - -Bool -_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix) - Display *dpy; - xConnClientPrefix *client; /* contains count for auth_* */ - char *auth_proto, *auth_string; /* NOT null-terminated */ - xConnSetupPrefix *prefix; /* prefix information */ -{ - int auth_length = client->nbytesAuthProto; - int auth_strlen = client->nbytesAuthString; - static char padbuf[3]; /* for padding to 4x bytes */ - int pad; - struct iovec iovarray[5], *iov = iovarray; - int niov = 0; - int len = 0; - -#define add_to_iov(b,l) \ - { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); } - - add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix)); - - /* - * write authorization protocol name and data - */ - if (auth_length > 0) { - add_to_iov (auth_proto, auth_length); - pad = -auth_length & 3; /* pad auth_length to a multiple of 4 */ - if (pad) add_to_iov (padbuf, pad); - } - if (auth_strlen > 0) { - add_to_iov (auth_string, auth_strlen); - pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */ - if (pad) add_to_iov (padbuf, pad); - } - -#undef add_to_iov - - len -= _X11TransWritev (dpy->trans_conn, iovarray, niov); - - /* - * Set the connection non-blocking since we use select() to block. - */ - - _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1); - - if (len != 0) - return -1; -#ifdef NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, len); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - -#ifdef K5AUTH - if (auth_length == 14 && - !strncmp(auth_proto, "MIT-KERBEROS-5", 14)) - { - return k5_clientauth(dpy, prefix); - } else -#endif - return 0; -} - - -#ifdef STREAMSCONN -#ifdef SVR4 -#include <tiuser.h> -#else -#undef HASXDMAUTH -#endif -#endif - -#ifdef SECURE_RPC -#include <rpc/rpc.h> -#ifdef ultrix -#include <time.h> -#include <rpc/auth_des.h> -#endif -#endif - -#ifdef HASXDMAUTH -#include <time.h> -#define Time_t time_t -#endif - -/* - * First, a routine for setting authorization data - */ -static int xauth_namelen = 0; -static char *xauth_name = NULL; /* NULL means use default mechanism */ -static int xauth_datalen = 0; -static char *xauth_data = NULL; /* NULL means get default data */ - -/* - * This is a list of the authorization names which Xlib currently supports. - * Xau will choose the file entry which matches the earliest entry in this - * array, allowing us to prioritize these in terms of the most secure first - */ - -static char *default_xauth_names[] = { -#ifdef K5AUTH - "MIT-KERBEROS-5", -#endif -#ifdef SECURE_RPC - "SUN-DES-1", -#endif -#ifdef HASXDMAUTH - "XDM-AUTHORIZATION-1", -#endif - "MIT-MAGIC-COOKIE-1" -}; - -static _Xconst int default_xauth_lengths[] = { -#ifdef K5AUTH - 14, /* strlen ("MIT-KERBEROS-5") */ -#endif -#ifdef SECURE_RPC - 9, /* strlen ("SUN-DES-1") */ -#endif -#ifdef HASXDMAUTH - 19, /* strlen ("XDM-AUTHORIZATION-1") */ -#endif - 18 /* strlen ("MIT-MAGIC-COOKIE-1") */ -}; - -#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0])) - -static char **xauth_names = default_xauth_names; -static _Xconst int *xauth_lengths = default_xauth_lengths; - -static int xauth_names_length = NUM_DEFAULT_AUTH; - -void XSetAuthorization (name, namelen, data, datalen) - int namelen, datalen; /* lengths of name and data */ - char *name, *data; /* NULL or arbitrary array of bytes */ -{ - char *tmpname, *tmpdata; - - _XLockMutex(_Xglobal_lock); - if (xauth_name) Xfree (xauth_name); /* free any existing data */ - if (xauth_data) Xfree (xauth_data); - - xauth_name = xauth_data = NULL; /* mark it no longer valid */ - xauth_namelen = xauth_datalen = 0; - _XUnlockMutex(_Xglobal_lock); - - if (namelen < 0) namelen = 0; /* check for bogus inputs */ - if (datalen < 0) datalen = 0; /* maybe should return? */ - - if (namelen > 0) { /* try to allocate space */ - tmpname = Xmalloc ((unsigned) namelen); - if (!tmpname) return; - memcpy (tmpname, name, namelen); - } else { - tmpname = NULL; - } - - if (datalen > 0) { - tmpdata = Xmalloc ((unsigned) datalen); - if (!tmpdata) { - if (tmpname) (void) Xfree (tmpname); - return; - } - memcpy (tmpdata, data, datalen); - } else { - tmpdata = NULL; - } - - _XLockMutex(_Xglobal_lock); - xauth_name = tmpname; /* and store the suckers */ - xauth_namelen = namelen; - if (tmpname) - { - xauth_names = &xauth_name; - xauth_lengths = &xauth_namelen; - xauth_names_length = 1; - } - else - { - xauth_names = default_xauth_names; - xauth_lengths = default_xauth_lengths; - xauth_names_length = NUM_DEFAULT_AUTH; - } - xauth_data = tmpdata; - xauth_datalen = datalen; - _XUnlockMutex(_Xglobal_lock); - return; -} - -#ifdef SECURE_RPC -/* - * Create a credential that we can send to the X server. - */ -static int -auth_ezencode(servername, window, cred_out, len) - char *servername; - int window; - char *cred_out; - int *len; -{ - AUTH *a; - XDR xdr; - -#if defined(SVR4) && defined(sun) - a = authdes_seccreate(servername, window, NULL, NULL); -#else - a = (AUTH *)authdes_create(servername, window, NULL, NULL); -#endif - if (a == (AUTH *)NULL) { - perror("auth_create"); - return 0; - } - xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE); - if (AUTH_MARSHALL(a, &xdr) == FALSE) { - perror("auth_marshall"); - AUTH_DESTROY(a); - return 0; - } - *len = xdr_getpos(&xdr); - AUTH_DESTROY(a); - return 1; -} -#endif - -#ifdef K5AUTH -#include <com_err.h> - -extern krb5_flags krb5_kdc_default_options; - -/* - * k5_clientauth - * - * Returns non-zero if the setup prefix has been read, - * so we can tell XOpenDisplay to not bother looking for it by - * itself. - */ -static int k5_clientauth(dpy, sprefix) - Display *dpy; - xConnSetupPrefix *sprefix; -{ - krb5_error_code retval; - xReq prefix; - char *buf; - CARD16 plen, tlen; - krb5_data kbuf; - krb5_ccache cc; - krb5_creds creds; - krb5_principal cprinc, sprinc; - krb5_ap_rep_enc_part *repl; - - krb5_init_ets(); - /* - * stage 0: get encoded principal and tgt from server - */ - _XRead(dpy, (char *)&prefix, sz_xReq); - if (prefix.reqType != 2 && prefix.reqType != 3) - /* not an auth packet... so deal */ - if (prefix.reqType == 0 || prefix.reqType == 1) - { - memcpy((char *)sprefix, (char *)&prefix, sz_xReq); - _XRead(dpy, (char *)sprefix + sz_xReq, - sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */ - return 1; - } - else - { - fprintf(stderr, - "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n", - prefix.reqType); - return -1; - } - if (prefix.data != 0) - { - fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n", - prefix.data); - return -1; - } - buf = (char *)malloc((prefix.length << 2) - sz_xReq); - if (buf == NULL) /* malloc failed. Run away! */ - { - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - tlen = (prefix.length << 2) - sz_xReq; - _XRead(dpy, buf, tlen); - if (prefix.reqType == 2 && tlen < 6) - { - fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n"); - free(buf); - return -1; - } - if (prefix.reqType == 2) - { - plen = *(CARD16 *)buf; - kbuf.data = buf + 2; - kbuf.length = (plen > tlen) ? tlen : plen; - } - else - { - kbuf.data = buf; - kbuf.length = tlen; - } - if (XauKrb5Decode(kbuf, &sprinc)) - { - free(buf); - fprintf(stderr, "Xlib: XauKrb5Decode bombed\n"); - return -1; - } - if (prefix.reqType == 3) /* do some special stuff here */ - { - char *sname, *hostname = NULL; - - sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1); - if (sname == NULL) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - memcpy(sname, krb5_princ_component(sprinc, 0)->data, - krb5_princ_component(sprinc, 0)->length); - sname[krb5_princ_component(sprinc, 0)->length] = '\0'; - krb5_free_principal(sprinc); - if (dpy->display_name[0] != ':') /* hunt for a hostname */ - { - char *t; - - if ((hostname = (char *)malloc(strlen(dpy->display_name))) - == NULL) - { - free(buf); - free(sname); - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - strcpy(hostname, dpy->display_name); - t = strchr(hostname, ':'); - if (t == NULL) - { - free(buf); - free(sname); - free(hostname); - fprintf(stderr, - "Xlib: shouldn't get here! malformed display name."); - return -1; - } - if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':') - t++; - *t = '\0'; /* truncate the dpy number out */ - } - retval = krb5_sname_to_principal(hostname, sname, - KRB5_NT_SRV_HST, &sprinc); - free(sname); - if (hostname) - free(hostname); - if (retval) - { - free(buf); - fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n", - error_message(retval)); - return -1; - } - } - if (retval = krb5_cc_default(&cc)) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n", - error_message(retval)); - return -1; - } - if (retval = krb5_cc_get_principal(cc, &cprinc)) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n", - krb5_cc_default_name(), error_message(retval)); - return -1; - } - bzero((char *)&creds, sizeof(creds)); - creds.server = sprinc; - creds.client = cprinc; - if (prefix.reqType == 2) - { - creds.second_ticket.length = tlen - plen - 2; - creds.second_ticket.data = buf + 2 + plen; - retval = krb5_get_credentials(KRB5_GC_USER_USER | - krb5_kdc_default_options, - cc, &creds); - } - else - retval = krb5_get_credentials(krb5_kdc_default_options, - cc, &creds); - if (retval) - { - free(buf); - krb5_free_cred_contents(&creds); - fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n", - error_message(retval)); - return -1; - } - /* - * now format the ap_req to send to the server - */ - if (prefix.reqType == 2) - retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY | - AP_OPTS_MUTUAL_REQUIRED, NULL, - 0, 0, NULL, cc, - &creds, NULL, &kbuf); - else - retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL, - 0, 0, NULL, cc, &creds, NULL, - &kbuf); - free(buf); - if (retval) /* Some manner of Kerberos lossage */ - { - krb5_free_cred_contents(&creds); - fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n", - error_message(retval)); - return -1; - } - prefix.reqType = 1; - prefix.data = 0; - prefix.length = (kbuf.length + sz_xReq + 3) >> 2; - /* - * stage 1: send ap_req to server - */ - _XSend(dpy, (char *)&prefix, sz_xReq); - _XSend(dpy, (char *)kbuf.data, kbuf.length); - free(kbuf.data); - /* - * stage 2: get ap_rep from server to mutually authenticate - */ - _XRead(dpy, (char *)&prefix, sz_xReq); - if (prefix.reqType != 2) - if (prefix.reqType == 0 || prefix.reqType == 1) - { - memcpy((char *)sprefix, (char *)&prefix, sz_xReq); - _XRead(dpy, (char *)sprefix + sz_xReq, - sz_xConnSetupPrefix - sz_xReq); - return 1; - } - else - { - fprintf(stderr, - "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n", - prefix.reqType); - return -1; - } - if (prefix.data != 2) - return -1; - kbuf.length = (prefix.length << 2) - sz_xReq; - kbuf.data = (char *)malloc(kbuf.length); - if (kbuf.data == NULL) - { - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - _XRead(dpy, (char *)kbuf.data, kbuf.length); - retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl); - if (retval) - { - free(kbuf.data); - fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n", - error_message(retval)); - return -1; - } - free(kbuf.data); - /* - * stage 3: send a short ack to the server and return - */ - prefix.reqType = 3; - prefix.data = 0; - prefix.length = sz_xReq >> 2; - _XSend(dpy, (char *)&prefix, sz_xReq); - return 0; -} -#endif /* K5AUTH */ - -static void -GetAuthorization( - XtransConnInfo trans_conn, - int family, - char *saddr, - int saddrlen, - int idisplay, - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ -#ifdef SECURE_RPC - char rpc_cred[MAX_AUTH_BYTES]; -#endif -#ifdef HASXDMAUTH - unsigned char xdmcp_data[192/8]; -#endif - char *auth_name; - int auth_namelen; - unsigned char *auth_data; - int auth_datalen; - Xauth *authptr = NULL; - -/* - * Look up the authorization protocol name and data if necessary. - */ - if (xauth_name && xauth_data) { - auth_namelen = xauth_namelen; - auth_name = xauth_name; - auth_datalen = xauth_datalen; - auth_data = (unsigned char *) xauth_data; - } else { - char dpynumbuf[40]; /* big enough to hold 2^64 and more */ - (void) sprintf (dpynumbuf, "%d", idisplay); - - authptr = XauGetBestAuthByAddr ((unsigned short) family, - (unsigned short) saddrlen, - saddr, - (unsigned short) strlen (dpynumbuf), - dpynumbuf, - xauth_names_length, - xauth_names, - xauth_lengths); - if (authptr) { - auth_namelen = authptr->name_length; - auth_name = (char *)authptr->name; - auth_datalen = authptr->data_length; - auth_data = (unsigned char *) authptr->data; - } else { - auth_namelen = 0; - auth_name = NULL; - auth_datalen = 0; - auth_data = NULL; - } - } -#ifdef HASXDMAUTH - /* - * build XDM-AUTHORIZATION-1 data - */ - if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19)) - { - int i, j; - Time_t now; - int family, addrlen; - Xtransaddr *addr = NULL; - - for (j = 0; j < 8; j++) - xdmcp_data[j] = auth_data[j]; - - _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr); - - switch( family ) - { -#ifdef AF_INET - case AF_INET: - { - /* - * addr will contain a sockaddr_in with all - * of the members already in network byte order. - */ - - for(i=4; i<8; i++) /* do sin_addr */ - xdmcp_data[j++] = ((char *)addr)[i]; - for(i=2; i<4; i++) /* do sin_port */ - xdmcp_data[j++] = ((char *)addr)[i]; - break; - } -#endif /* AF_INET */ -#if defined(IPv6) && defined(AF_INET6) - case AF_INET6: - /* XXX This should probably never happen */ - { - unsigned char ipv4mappedprefix[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; - - /* In the case of v4 mapped addresses send the v4 - part of the address - addr is already in network byte order */ - if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) { - for (i = 20 ; i < 24; i++) - xdmcp_data[j++] = ((char *)addr)[i]; - - /* Port number */ - for (i=2; i<4; i++) - xdmcp_data[j++] = ((char *)addr)[i]; - } else { - /* Fake data to keep the data aligned. Otherwise the - the server will bail about incorrect timing data */ - for (i = 0; i < 6; i++) { - xdmcp_data[j++] = 0; - } - } - break; - } -#endif /* AF_INET6 */ -#ifdef AF_UNIX - case AF_UNIX: - { - /* - * We don't use the sockaddr_un for this encoding. - * Instead, we create a sockaddr_in filled with - * a decreasing counter for the address, and the - * pid for the port. - */ - - static unsigned long unix_addr = 0xFFFFFFFF; - unsigned long the_addr; - unsigned short the_port; - unsigned long the_utime; - struct timeval tp; - - X_GETTIMEOFDAY(&tp); - _XLockMutex(_Xglobal_lock); - the_addr = unix_addr--; - _XUnlockMutex(_Xglobal_lock); - the_utime = (unsigned long) tp.tv_usec; - the_port = getpid (); - - xdmcp_data[j++] = (the_utime >> 24) & 0xFF; - xdmcp_data[j++] = (the_utime >> 16) & 0xFF; - xdmcp_data[j++] = ((the_utime >> 8) & 0xF0) - | ((the_addr >> 8) & 0x0F); - xdmcp_data[j++] = (the_addr >> 0) & 0xFF; - xdmcp_data[j++] = (the_port >> 8) & 0xFF; - xdmcp_data[j++] = (the_port >> 0) & 0xFF; - break; - } -#endif /* AF_UNIX */ -#ifdef AF_DECnet - case AF_DECnet: - /* - * What is the defined encoding for this? - */ - break; -#endif /* AF_DECnet */ - default: - /* - * Need to return some kind of errro status here. - * maybe a NULL auth?? - */ - break; - } /* switch */ - - if (addr) - free ((char *) addr); - - time (&now); - xdmcp_data[j++] = (now >> 24) & 0xFF; - xdmcp_data[j++] = (now >> 16) & 0xFF; - xdmcp_data[j++] = (now >> 8) & 0xFF; - xdmcp_data[j++] = (now >> 0) & 0xFF; - while (j < 192 / 8) - xdmcp_data[j++] = 0; - _XLockMutex(_Xglobal_lock); - /* this function might use static data, hence the lock around it */ - XdmcpWrap (xdmcp_data, auth_data + 8, - xdmcp_data, j); - _XUnlockMutex(_Xglobal_lock); - auth_data = xdmcp_data; - auth_datalen = j; - } -#endif /* HASXDMAUTH */ -#ifdef SECURE_RPC - /* - * The SUN-DES-1 authorization protocol uses the - * "secure RPC" mechanism in SunOS 4.0+. - */ - if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) { - char servernetname[MAXNETNAMELEN + 1]; - - /* - * Copy over the server's netname from the authorization - * data field filled in by XauGetAuthByAddr(). - */ - if (auth_datalen > MAXNETNAMELEN) { - auth_datalen = 0; - auth_data = NULL; - } else { - memcpy(servernetname, auth_data, auth_datalen); - servernetname[auth_datalen] = '\0'; - - auth_datalen = sizeof (rpc_cred); - if (auth_ezencode(servernetname, 100, rpc_cred, - &auth_datalen)) - auth_data = (unsigned char *) rpc_cred; - else { - auth_datalen = 0; - auth_data = NULL; - } - } - } -#endif - if (saddr) free ((char *) saddr); - if ((*auth_namelenp = auth_namelen)) - { - if ((*auth_namep = Xmalloc(auth_namelen))) - memcpy(*auth_namep, auth_name, auth_namelen); - else - *auth_namelenp = 0; - } - else - *auth_namep = NULL; - if ((*auth_datalenp = auth_datalen)) - { - if ((*auth_datap = Xmalloc(auth_datalen))) - memcpy(*auth_datap, auth_data, auth_datalen); - else - *auth_datalenp = 0; - } - else - *auth_datap = NULL; - if (authptr) XauDisposeAuth (authptr); -} diff --git a/nx-X11/lib/X11/ConnDis.c.X.original b/nx-X11/lib/X11/ConnDis.c.X.original deleted file mode 100644 index 30616d207..000000000 --- a/nx-X11/lib/X11/ConnDis.c.X.original +++ /dev/null @@ -1,1233 +0,0 @@ -/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */ -/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */ - -/* - * This file contains operating system dependencies. - */ - -#define NEED_EVENTS - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xauth.h> -#include <X11/Xdmcp.h> -#include <stdio.h> -#include <ctype.h> - -#if !defined(WIN32) -#ifndef Lynx -#include <sys/socket.h> -#else -#include <socket.h> -#endif -#else -#include <X11/Xwindows.h> -#endif - -#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */ -#define X_CONNECTION_RETRIES 5 -#endif - -#ifdef LOCALCONN -#include <sys/utsname.h> -#endif - -#include "Xintconn.h" - -/* prototypes */ -static void GetAuthorization( - XtransConnInfo trans_conn, - int family, - char *saddr, - int saddrlen, - int idisplay, - char **auth_namep, - int *auth_namelenp, - char **auth_datap, - int *auth_datalenp); - -/* functions */ -static char *copystring (char *src, int len) -{ - char *dst = Xmalloc (len + 1); - - if (dst) { - strncpy (dst, src, len); - dst[len] = '\0'; - } - - return dst; -} - - -/* - * Attempts to connect to server, given display name. Returns file descriptor - * (network socket) or -1 if connection fails. Display names may be of the - * following format: - * - * [protocol/] [hostname] : [:] displaynumber [.screennumber] - * - * A string with exactly two colons seperating hostname from the display - * indicates a DECnet style name. Colons in the hostname may occur if an - * IPv6 numeric address is used as the hostname. An IPv6 numeric address - * may also end in a double colon, so three colons in a row indicates an - * IPv6 address ending in :: followed by :display. To make it easier for - * people to read, an IPv6 numeric address hostname may be surrounded by - * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined - * by IETF RFC 2732. - * - * If no hostname and no protocol is specified, the string is interpreted - * as the most efficient local connection to a server on the same machine. - * This is usually: - * - * o shared memory - * o local stream - * o UNIX domain socket - * o TCP to local host - * - * This function will eventually call the X Transport Interface functions - * which expects the hostname in the format: - * - * [protocol/] [hostname] : [:] displaynumber - * - */ -XtransConnInfo -_X11TransConnectDisplay ( - char *display_name, - char **fullnamep, /* RETURN */ - int *dpynump, /* RETURN */ - int *screenp, /* RETURN */ - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ - int family; - int saddrlen; - Xtransaddr *saddr; - char *lastp, *lastc, *p; /* char pointers */ - char *pprotocol = NULL; /* start of protocol name */ - char *phostname = NULL; /* start of host of display */ - char *pdpynum = NULL; /* start of dpynum of display */ - char *pscrnum = NULL; /* start of screen of display */ - Bool dnet = False; /* if true, then DECnet format */ - int idisplay = 0; /* required display number */ - int iscreen = 0; /* optional screen number */ - /* int (*connfunc)(); */ /* method to create connection */ - int len, hostlen; /* length tmp variable */ - int retry; /* retry counter */ - char addrbuf[128]; /* final address passed to - X Transport Interface */ - char* address = addrbuf; - XtransConnInfo trans_conn = NULL; /* transport connection object */ - int connect_stat; -#ifdef LOCALCONN - struct utsname sys; -#endif -#ifdef TCPCONN - char *tcphostname = NULL; /* A place to save hostname pointer */ -#endif - - p = display_name; - - saddrlen = 0; /* set so that we can clear later */ - saddr = NULL; - - /* - * Step 0, find the protocol. This is delimited by the optional - * slash ('/'). - */ - for (lastp = p; *p && *p != ':' && *p != '/'; p++) ; - if (!*p) return NULL; /* must have a colon */ - - if (p != lastp && *p != ':') { /* protocol given? */ - pprotocol = copystring (lastp, p - lastp); - if (!pprotocol) goto bad; /* no memory */ - p++; /* skip the '/' */ - } else - p = display_name; /* reset the pointer in - case no protocol was given */ - - /* - * Step 1, find the hostname. This is delimited by either one colon, - * or two colons in the case of DECnet (DECnet Phase V allows a single - * colon in the hostname). (See note above regarding IPv6 numeric - * addresses with triple colons or [] brackets.) - */ - - lastp = p; - lastc = NULL; - for (; *p; p++) - if (*p == ':') - lastc = p; - - if (!lastc) return NULL; /* must have a colon */ - - if ((lastp != lastc) && (*(lastc - 1) == ':') -#if defined(IPv6) && defined(AF_INET6) - && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':')) -#endif - ) { - /* DECnet display specified */ - -#ifndef DNETCONN - goto bad; -#else - dnet = True; - /* override the protocol specified */ - if (pprotocol) - Xfree (pprotocol); - pprotocol = copystring ("dnet", 4); - hostlen = lastc - 1 - lastp; -#endif - } - else - hostlen = lastc - lastp; - - if (hostlen > 0) { /* hostname given? */ - phostname = copystring (lastp, hostlen); - if (!phostname) goto bad; /* no memory */ - } - - p = lastc; - -#ifdef LOCALCONN - /* check if phostname == localnodename AND protocol not specified */ - if (!pprotocol && phostname && uname(&sys) >= 0 && - !strncmp(phostname, sys.nodename, - (strlen(sys.nodename) < strlen(phostname) ? - strlen(phostname) : strlen(sys.nodename)))) - { -#ifdef TCPCONN - /* - * We'll first attempt to connect using the local transport. If - * this fails (which is the case if sshd X protocol forwarding is - * being used), retry using tcp and this hostname. - */ - tcphostname = copystring(phostname, strlen(phostname)); -#endif - Xfree (phostname); - phostname = copystring ("unix", 4); - } -#endif - - - /* - * Step 2, find the display number. This field is required and is - * delimited either by a nul or a period, depending on whether or not - * a screen number is present. - */ - - for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ; - if ((p == lastp) || /* required field */ - (*p != '\0' && *p != '.') || /* invalid non-digit terminator */ - !(pdpynum = copystring (lastp, p - lastp))) /* no memory */ - goto bad; - idisplay = atoi (pdpynum); - - - /* - * Step 3, find the screen number. This field is optional. It is - * present only if the display number was followed by a period (which - * we've already verified is the only non-nul character). - */ - - if (*p) { - for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ; - if (p != lastp) { - if (*p || /* non-digits */ - !(pscrnum = copystring (lastp, p - lastp))) /* no memory */ - goto bad; - iscreen = atoi (lastp); - } - } - - /* - * At this point, we know the following information: - * - * pprotocol protocol string or NULL - * phostname hostname string or NULL - * idisplay display number - * iscreen screen number - * dnet DECnet boolean - * - * We can now decide which transport to use based on the ConnectionFlags - * build parameter the hostname string. If phostname is NULL or equals - * the string "local", then choose the best transport. If phostname - * is "unix", then choose BSD UNIX domain sockets (if configured). - */ - -#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN) - if (!pprotocol) { - if (!phostname) { -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - pprotocol = copystring ("local", 5); -#if defined(TCPCONN) - tcphostname = copystring("localhost", 9); -#endif - } - else - { -#endif - pprotocol = copystring ("tcp", 3); - } - } -#endif - -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - /* - * Now that the defaults have been established, see if we have any - * special names that we have to override: - * - * :N => if UNIXCONN then unix-domain-socket - * ::N => if UNIXCONN then unix-domain-socket - * unix:N => if UNIXCONN then unix-domain-socket - * - * Note that if UNIXCONN isn't defined, then we can use the default - * transport connection function set above. - */ - - if (!phostname) { -#ifdef apollo - ; /* Unix domain sockets are *really* bad on apollos */ -#else - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); -#endif - } - else if (strcmp (phostname, "unix") == 0) { - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); - } -#endif - -#if defined(TCPCONN) - connect: -#endif - /* - * This seems kind of backwards, but we need to put the protocol, - * host, and port back together to pass to _X11TransOpenCOTSClient(). - */ - - { - int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) + - (phostname ? strlen(phostname) : 0) + - (pdpynum ? strlen(pdpynum) : 0); - if (olen > sizeof addrbuf) address = Xmalloc (olen); - } - if (!address) goto bad; - - sprintf(address,"%s/%s:%d", - pprotocol ? pprotocol : "", - phostname ? phostname : "", - idisplay ); - - /* - * Make the connection, also need to get the auth address info for - * the connection. Do retries in case server host has hit its - * backlog (which, unfortunately, isn't distinguishable from there not - * being a server listening at all, which is why we have to not retry - * too many times). - */ - for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- ) - { - if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) - { - break; - } - if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 ) - { - _X11TransClose(trans_conn); - trans_conn = NULL; - - if (connect_stat == TRANS_TRY_CONNECT_AGAIN) - { - sleep(1); - continue; - } - else - break; - } - - _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr); - - /* - * The family is given in a socket format (ie AF_INET). This - * will convert it to the format used by the authorization and - * X protocol (ie FamilyInternet). - */ - - if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 ) - { - _X11TransClose(trans_conn); - trans_conn = NULL; - sleep(1); - if (saddr) - { - free ((char *) saddr); - saddr = NULL; - } - continue; - } - - break; - } - - if (address != addrbuf) Xfree (address); - address = addrbuf; - - if( trans_conn == NULL ) - goto bad; - - /* - * Set close-on-exec so that programs that fork() doesn't get confused. - */ - - _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1); - - /* - * Build the expanded display name: - * - * [host] : [:] dpy . scr \0 - */ - len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) + - strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1); - *fullnamep = (char *) Xmalloc (len); - if (!*fullnamep) goto bad; - - sprintf (*fullnamep, "%s%s%d.%d", - (phostname ? phostname : ""), - (dnet ? "::" : ":"), - idisplay, iscreen); - - *dpynump = idisplay; - *screenp = iscreen; - if (pprotocol) Xfree (pprotocol); - if (phostname) Xfree (phostname); - if (pdpynum) Xfree (pdpynum); - if (pscrnum) Xfree (pscrnum); -#ifdef TCPCONN - if (tcphostname) Xfree (tcphostname); -#endif - - GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay, - auth_namep, auth_namelenp, auth_datap, auth_datalenp); - return trans_conn; - - - /* - * error return; make sure everything is cleaned up. - */ - bad: - if (trans_conn) (void)_X11TransClose(trans_conn); - if (saddr) free ((char *) saddr); - if (pprotocol) Xfree (pprotocol); - if (phostname) Xfree (phostname); - if (address && address != addrbuf) { Xfree(address); address = addrbuf; } - -#if defined(TCPCONN) - if (tcphostname) { - pprotocol = copystring("tcp", 3); - phostname = tcphostname; - tcphostname = NULL; - goto connect; - } -#endif - - if (pdpynum) Xfree (pdpynum); - if (pscrnum) Xfree (pscrnum); - return NULL; - -} - -/* - * This is gross, but we need it for compatiblity. - * The test suite relies on the following interface. - * - */ - -int _XConnectDisplay ( - char *display_name, - char **fullnamep, /* RETURN */ - int *dpynump, /* RETURN */ - int *screenp, /* RETURN */ - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ - XtransConnInfo trans_conn; - - trans_conn = _X11TransConnectDisplay ( - display_name, fullnamep, dpynump, screenp, - auth_namep, auth_namelenp, auth_datap, auth_datalenp); - - if (trans_conn) - { - int fd = _X11TransGetConnectionNumber (trans_conn); - _X11TransFreeConnInfo (trans_conn); - return (fd); - } - else - return (-1); -} - - -/***************************************************************************** - * * - * Connection Utility Routines * - * * - *****************************************************************************/ - -/* - * Disconnect from server. - */ - -int _XDisconnectDisplay (trans_conn) - -XtransConnInfo trans_conn; - -{ - _X11TransDisconnect(trans_conn); - _X11TransClose(trans_conn); - return 0; -} - - - -Bool -_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix) - Display *dpy; - xConnClientPrefix *client; /* contains count for auth_* */ - char *auth_proto, *auth_string; /* NOT null-terminated */ - xConnSetupPrefix *prefix; /* prefix information */ -{ - int auth_length = client->nbytesAuthProto; - int auth_strlen = client->nbytesAuthString; - static char padbuf[3]; /* for padding to 4x bytes */ - int pad; - struct iovec iovarray[5], *iov = iovarray; - int niov = 0; - int len = 0; - -#define add_to_iov(b,l) \ - { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); } - - add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix)); - - /* - * write authorization protocol name and data - */ - if (auth_length > 0) { - add_to_iov (auth_proto, auth_length); - pad = -auth_length & 3; /* pad auth_length to a multiple of 4 */ - if (pad) add_to_iov (padbuf, pad); - } - if (auth_strlen > 0) { - add_to_iov (auth_string, auth_strlen); - pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */ - if (pad) add_to_iov (padbuf, pad); - } - -#undef add_to_iov - - len -= _X11TransWritev (dpy->trans_conn, iovarray, niov); - - /* - * Set the connection non-blocking since we use select() to block. - */ - - _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1); - - if (len != 0) - return -1; - -#ifdef K5AUTH - if (auth_length == 14 && - !strncmp(auth_proto, "MIT-KERBEROS-5", 14)) - { - return k5_clientauth(dpy, prefix); - } else -#endif - return 0; -} - - -#ifdef STREAMSCONN -#ifdef SVR4 -#include <tiuser.h> -#else -#undef HASXDMAUTH -#endif -#endif - -#ifdef SECURE_RPC -#include <rpc/rpc.h> -#ifdef ultrix -#include <time.h> -#include <rpc/auth_des.h> -#endif -#endif - -#ifdef HASXDMAUTH -#include <time.h> -#define Time_t time_t -#endif - -/* - * First, a routine for setting authorization data - */ -static int xauth_namelen = 0; -static char *xauth_name = NULL; /* NULL means use default mechanism */ -static int xauth_datalen = 0; -static char *xauth_data = NULL; /* NULL means get default data */ - -/* - * This is a list of the authorization names which Xlib currently supports. - * Xau will choose the file entry which matches the earliest entry in this - * array, allowing us to prioritize these in terms of the most secure first - */ - -static char *default_xauth_names[] = { -#ifdef K5AUTH - "MIT-KERBEROS-5", -#endif -#ifdef SECURE_RPC - "SUN-DES-1", -#endif -#ifdef HASXDMAUTH - "XDM-AUTHORIZATION-1", -#endif - "MIT-MAGIC-COOKIE-1" -}; - -static _Xconst int default_xauth_lengths[] = { -#ifdef K5AUTH - 14, /* strlen ("MIT-KERBEROS-5") */ -#endif -#ifdef SECURE_RPC - 9, /* strlen ("SUN-DES-1") */ -#endif -#ifdef HASXDMAUTH - 19, /* strlen ("XDM-AUTHORIZATION-1") */ -#endif - 18 /* strlen ("MIT-MAGIC-COOKIE-1") */ -}; - -#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0])) - -static char **xauth_names = default_xauth_names; -static _Xconst int *xauth_lengths = default_xauth_lengths; - -static int xauth_names_length = NUM_DEFAULT_AUTH; - -void XSetAuthorization (name, namelen, data, datalen) - int namelen, datalen; /* lengths of name and data */ - char *name, *data; /* NULL or arbitrary array of bytes */ -{ - char *tmpname, *tmpdata; - - _XLockMutex(_Xglobal_lock); - if (xauth_name) Xfree (xauth_name); /* free any existing data */ - if (xauth_data) Xfree (xauth_data); - - xauth_name = xauth_data = NULL; /* mark it no longer valid */ - xauth_namelen = xauth_datalen = 0; - _XUnlockMutex(_Xglobal_lock); - - if (namelen < 0) namelen = 0; /* check for bogus inputs */ - if (datalen < 0) datalen = 0; /* maybe should return? */ - - if (namelen > 0) { /* try to allocate space */ - tmpname = Xmalloc ((unsigned) namelen); - if (!tmpname) return; - memcpy (tmpname, name, namelen); - } else { - tmpname = NULL; - } - - if (datalen > 0) { - tmpdata = Xmalloc ((unsigned) datalen); - if (!tmpdata) { - if (tmpname) (void) Xfree (tmpname); - return; - } - memcpy (tmpdata, data, datalen); - } else { - tmpdata = NULL; - } - - _XLockMutex(_Xglobal_lock); - xauth_name = tmpname; /* and store the suckers */ - xauth_namelen = namelen; - if (tmpname) - { - xauth_names = &xauth_name; - xauth_lengths = &xauth_namelen; - xauth_names_length = 1; - } - else - { - xauth_names = default_xauth_names; - xauth_lengths = default_xauth_lengths; - xauth_names_length = NUM_DEFAULT_AUTH; - } - xauth_data = tmpdata; - xauth_datalen = datalen; - _XUnlockMutex(_Xglobal_lock); - return; -} - -#ifdef SECURE_RPC -/* - * Create a credential that we can send to the X server. - */ -static int -auth_ezencode(servername, window, cred_out, len) - char *servername; - int window; - char *cred_out; - int *len; -{ - AUTH *a; - XDR xdr; - -#if defined(SVR4) && defined(sun) - a = authdes_seccreate(servername, window, NULL, NULL); -#else - a = (AUTH *)authdes_create(servername, window, NULL, NULL); -#endif - if (a == (AUTH *)NULL) { - perror("auth_create"); - return 0; - } - xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE); - if (AUTH_MARSHALL(a, &xdr) == FALSE) { - perror("auth_marshall"); - AUTH_DESTROY(a); - return 0; - } - *len = xdr_getpos(&xdr); - AUTH_DESTROY(a); - return 1; -} -#endif - -#ifdef K5AUTH -#include <com_err.h> - -extern krb5_flags krb5_kdc_default_options; - -/* - * k5_clientauth - * - * Returns non-zero if the setup prefix has been read, - * so we can tell XOpenDisplay to not bother looking for it by - * itself. - */ -static int k5_clientauth(dpy, sprefix) - Display *dpy; - xConnSetupPrefix *sprefix; -{ - krb5_error_code retval; - xReq prefix; - char *buf; - CARD16 plen, tlen; - krb5_data kbuf; - krb5_ccache cc; - krb5_creds creds; - krb5_principal cprinc, sprinc; - krb5_ap_rep_enc_part *repl; - - krb5_init_ets(); - /* - * stage 0: get encoded principal and tgt from server - */ - _XRead(dpy, (char *)&prefix, sz_xReq); - if (prefix.reqType != 2 && prefix.reqType != 3) - /* not an auth packet... so deal */ - if (prefix.reqType == 0 || prefix.reqType == 1) - { - memcpy((char *)sprefix, (char *)&prefix, sz_xReq); - _XRead(dpy, (char *)sprefix + sz_xReq, - sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */ - return 1; - } - else - { - fprintf(stderr, - "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n", - prefix.reqType); - return -1; - } - if (prefix.data != 0) - { - fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n", - prefix.data); - return -1; - } - buf = (char *)malloc((prefix.length << 2) - sz_xReq); - if (buf == NULL) /* malloc failed. Run away! */ - { - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - tlen = (prefix.length << 2) - sz_xReq; - _XRead(dpy, buf, tlen); - if (prefix.reqType == 2 && tlen < 6) - { - fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n"); - free(buf); - return -1; - } - if (prefix.reqType == 2) - { - plen = *(CARD16 *)buf; - kbuf.data = buf + 2; - kbuf.length = (plen > tlen) ? tlen : plen; - } - else - { - kbuf.data = buf; - kbuf.length = tlen; - } - if (XauKrb5Decode(kbuf, &sprinc)) - { - free(buf); - fprintf(stderr, "Xlib: XauKrb5Decode bombed\n"); - return -1; - } - if (prefix.reqType == 3) /* do some special stuff here */ - { - char *sname, *hostname = NULL; - - sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1); - if (sname == NULL) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - memcpy(sname, krb5_princ_component(sprinc, 0)->data, - krb5_princ_component(sprinc, 0)->length); - sname[krb5_princ_component(sprinc, 0)->length] = '\0'; - krb5_free_principal(sprinc); - if (dpy->display_name[0] != ':') /* hunt for a hostname */ - { - char *t; - - if ((hostname = (char *)malloc(strlen(dpy->display_name))) - == NULL) - { - free(buf); - free(sname); - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - strcpy(hostname, dpy->display_name); - t = strchr(hostname, ':'); - if (t == NULL) - { - free(buf); - free(sname); - free(hostname); - fprintf(stderr, - "Xlib: shouldn't get here! malformed display name."); - return -1; - } - if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':') - t++; - *t = '\0'; /* truncate the dpy number out */ - } - retval = krb5_sname_to_principal(hostname, sname, - KRB5_NT_SRV_HST, &sprinc); - free(sname); - if (hostname) - free(hostname); - if (retval) - { - free(buf); - fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n", - error_message(retval)); - return -1; - } - } - if (retval = krb5_cc_default(&cc)) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n", - error_message(retval)); - return -1; - } - if (retval = krb5_cc_get_principal(cc, &cprinc)) - { - free(buf); - krb5_free_principal(sprinc); - fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n", - krb5_cc_default_name(), error_message(retval)); - return -1; - } - bzero((char *)&creds, sizeof(creds)); - creds.server = sprinc; - creds.client = cprinc; - if (prefix.reqType == 2) - { - creds.second_ticket.length = tlen - plen - 2; - creds.second_ticket.data = buf + 2 + plen; - retval = krb5_get_credentials(KRB5_GC_USER_USER | - krb5_kdc_default_options, - cc, &creds); - } - else - retval = krb5_get_credentials(krb5_kdc_default_options, - cc, &creds); - if (retval) - { - free(buf); - krb5_free_cred_contents(&creds); - fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n", - error_message(retval)); - return -1; - } - /* - * now format the ap_req to send to the server - */ - if (prefix.reqType == 2) - retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY | - AP_OPTS_MUTUAL_REQUIRED, NULL, - 0, 0, NULL, cc, - &creds, NULL, &kbuf); - else - retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL, - 0, 0, NULL, cc, &creds, NULL, - &kbuf); - free(buf); - if (retval) /* Some manner of Kerberos lossage */ - { - krb5_free_cred_contents(&creds); - fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n", - error_message(retval)); - return -1; - } - prefix.reqType = 1; - prefix.data = 0; - prefix.length = (kbuf.length + sz_xReq + 3) >> 2; - /* - * stage 1: send ap_req to server - */ - _XSend(dpy, (char *)&prefix, sz_xReq); - _XSend(dpy, (char *)kbuf.data, kbuf.length); - free(kbuf.data); - /* - * stage 2: get ap_rep from server to mutually authenticate - */ - _XRead(dpy, (char *)&prefix, sz_xReq); - if (prefix.reqType != 2) - if (prefix.reqType == 0 || prefix.reqType == 1) - { - memcpy((char *)sprefix, (char *)&prefix, sz_xReq); - _XRead(dpy, (char *)sprefix + sz_xReq, - sz_xConnSetupPrefix - sz_xReq); - return 1; - } - else - { - fprintf(stderr, - "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n", - prefix.reqType); - return -1; - } - if (prefix.data != 2) - return -1; - kbuf.length = (prefix.length << 2) - sz_xReq; - kbuf.data = (char *)malloc(kbuf.length); - if (kbuf.data == NULL) - { - fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n"); - return -1; - } - _XRead(dpy, (char *)kbuf.data, kbuf.length); - retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl); - if (retval) - { - free(kbuf.data); - fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n", - error_message(retval)); - return -1; - } - free(kbuf.data); - /* - * stage 3: send a short ack to the server and return - */ - prefix.reqType = 3; - prefix.data = 0; - prefix.length = sz_xReq >> 2; - _XSend(dpy, (char *)&prefix, sz_xReq); - return 0; -} -#endif /* K5AUTH */ - -static void -GetAuthorization( - XtransConnInfo trans_conn, - int family, - char *saddr, - int saddrlen, - int idisplay, - char **auth_namep, /* RETURN */ - int *auth_namelenp, /* RETURN */ - char **auth_datap, /* RETURN */ - int *auth_datalenp) /* RETURN */ -{ -#ifdef SECURE_RPC - char rpc_cred[MAX_AUTH_BYTES]; -#endif -#ifdef HASXDMAUTH - unsigned char xdmcp_data[192/8]; -#endif - char *auth_name; - int auth_namelen; - unsigned char *auth_data; - int auth_datalen; - Xauth *authptr = NULL; - -/* - * Look up the authorization protocol name and data if necessary. - */ - if (xauth_name && xauth_data) { - auth_namelen = xauth_namelen; - auth_name = xauth_name; - auth_datalen = xauth_datalen; - auth_data = (unsigned char *) xauth_data; - } else { - char dpynumbuf[40]; /* big enough to hold 2^64 and more */ - (void) sprintf (dpynumbuf, "%d", idisplay); - - authptr = XauGetBestAuthByAddr ((unsigned short) family, - (unsigned short) saddrlen, - saddr, - (unsigned short) strlen (dpynumbuf), - dpynumbuf, - xauth_names_length, - xauth_names, - xauth_lengths); - if (authptr) { - auth_namelen = authptr->name_length; - auth_name = (char *)authptr->name; - auth_datalen = authptr->data_length; - auth_data = (unsigned char *) authptr->data; - } else { - auth_namelen = 0; - auth_name = NULL; - auth_datalen = 0; - auth_data = NULL; - } - } -#ifdef HASXDMAUTH - /* - * build XDM-AUTHORIZATION-1 data - */ - if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19)) - { - int i, j; - Time_t now; - int family, addrlen; - Xtransaddr *addr = NULL; - - for (j = 0; j < 8; j++) - xdmcp_data[j] = auth_data[j]; - - _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr); - - switch( family ) - { -#ifdef AF_INET - case AF_INET: - { - /* - * addr will contain a sockaddr_in with all - * of the members already in network byte order. - */ - - for(i=4; i<8; i++) /* do sin_addr */ - xdmcp_data[j++] = ((char *)addr)[i]; - for(i=2; i<4; i++) /* do sin_port */ - xdmcp_data[j++] = ((char *)addr)[i]; - break; - } -#endif /* AF_INET */ -#if defined(IPv6) && defined(AF_INET6) - case AF_INET6: - /* XXX This should probably never happen */ - { - unsigned char ipv4mappedprefix[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; - - /* In the case of v4 mapped addresses send the v4 - part of the address - addr is already in network byte order */ - if (memcmp(addr+8, ipv4mappedprefix, 12) == 0) { - for (i = 20 ; i < 24; i++) - xdmcp_data[j++] = ((char *)addr)[i]; - - /* Port number */ - for (i=2; i<4; i++) - xdmcp_data[j++] = ((char *)addr)[i]; - } else { - /* Fake data to keep the data aligned. Otherwise the - the server will bail about incorrect timing data */ - for (i = 0; i < 6; i++) { - xdmcp_data[j++] = 0; - } - } - break; - } -#endif /* AF_INET6 */ -#ifdef AF_UNIX - case AF_UNIX: - { - /* - * We don't use the sockaddr_un for this encoding. - * Instead, we create a sockaddr_in filled with - * a decreasing counter for the address, and the - * pid for the port. - */ - - static unsigned long unix_addr = 0xFFFFFFFF; - unsigned long the_addr; - unsigned short the_port; - unsigned long the_utime; - struct timeval tp; - - X_GETTIMEOFDAY(&tp); - _XLockMutex(_Xglobal_lock); - the_addr = unix_addr--; - _XUnlockMutex(_Xglobal_lock); - the_utime = (unsigned long) tp.tv_usec; - the_port = getpid (); - - xdmcp_data[j++] = (the_utime >> 24) & 0xFF; - xdmcp_data[j++] = (the_utime >> 16) & 0xFF; - xdmcp_data[j++] = ((the_utime >> 8) & 0xF0) - | ((the_addr >> 8) & 0x0F); - xdmcp_data[j++] = (the_addr >> 0) & 0xFF; - xdmcp_data[j++] = (the_port >> 8) & 0xFF; - xdmcp_data[j++] = (the_port >> 0) & 0xFF; - break; - } -#endif /* AF_UNIX */ -#ifdef AF_DECnet - case AF_DECnet: - /* - * What is the defined encoding for this? - */ - break; -#endif /* AF_DECnet */ - default: - /* - * Need to return some kind of errro status here. - * maybe a NULL auth?? - */ - break; - } /* switch */ - - if (addr) - free ((char *) addr); - - time (&now); - xdmcp_data[j++] = (now >> 24) & 0xFF; - xdmcp_data[j++] = (now >> 16) & 0xFF; - xdmcp_data[j++] = (now >> 8) & 0xFF; - xdmcp_data[j++] = (now >> 0) & 0xFF; - while (j < 192 / 8) - xdmcp_data[j++] = 0; - _XLockMutex(_Xglobal_lock); - /* this function might use static data, hence the lock around it */ - XdmcpWrap (xdmcp_data, auth_data + 8, - xdmcp_data, j); - _XUnlockMutex(_Xglobal_lock); - auth_data = xdmcp_data; - auth_datalen = j; - } -#endif /* HASXDMAUTH */ -#ifdef SECURE_RPC - /* - * The SUN-DES-1 authorization protocol uses the - * "secure RPC" mechanism in SunOS 4.0+. - */ - if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) { - char servernetname[MAXNETNAMELEN + 1]; - - /* - * Copy over the server's netname from the authorization - * data field filled in by XauGetAuthByAddr(). - */ - if (auth_datalen > MAXNETNAMELEN) { - auth_datalen = 0; - auth_data = NULL; - } else { - memcpy(servernetname, auth_data, auth_datalen); - servernetname[auth_datalen] = '\0'; - - auth_datalen = sizeof (rpc_cred); - if (auth_ezencode(servernetname, 100, rpc_cred, - &auth_datalen)) - auth_data = (unsigned char *) rpc_cred; - else { - auth_datalen = 0; - auth_data = NULL; - } - } - } -#endif - if (saddr) free ((char *) saddr); - if ((*auth_namelenp = auth_namelen)) - { - if ((*auth_namep = Xmalloc(auth_namelen))) - memcpy(*auth_namep, auth_name, auth_namelen); - else - *auth_namelenp = 0; - } - else - *auth_namep = NULL; - if ((*auth_datalenp = auth_datalen)) - { - if ((*auth_datap = Xmalloc(auth_datalen))) - memcpy(*auth_datap, auth_data, auth_datalen); - else - *auth_datalenp = 0; - } - else - *auth_datap = NULL; - if (authptr) XauDisposeAuth (authptr); -} diff --git a/nx-X11/lib/X11/IfEvent.c.NX.original b/nx-X11/lib/X11/IfEvent.c.NX.original deleted file mode 100644 index a7c0cb188..000000000 --- a/nx-X11/lib/X11/IfEvent.c.NX.original +++ /dev/null @@ -1,80 +0,0 @@ -/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Flush output and (wait for and) return the next event matching the - * predicate in the queue. - */ - -int -XIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; - char *arg; -{ - register _XQEvent *qelt, *prev; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} diff --git a/nx-X11/lib/X11/IfEvent.c.X.original b/nx-X11/lib/X11/IfEvent.c.X.original deleted file mode 100644 index 55e7829ca..000000000 --- a/nx-X11/lib/X11/IfEvent.c.X.original +++ /dev/null @@ -1,75 +0,0 @@ -/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Flush output and (wait for and) return the next event matching the - * predicate in the queue. - */ - -int -XIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; - char *arg; -{ - register _XQEvent *qelt, *prev; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} diff --git a/nx-X11/lib/X11/Imakefile.NX.original b/nx-X11/lib/X11/Imakefile.NX.original deleted file mode 100644 index d8d0601b8..000000000 --- a/nx-X11/lib/X11/Imakefile.NX.original +++ /dev/null @@ -1,1237 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $ - - - - HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \ - Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h - -#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer && !NXAgentServer -all:: - -BuildIncludes($(HEADERS),IncSubdir,..) - -#else - -#if NXLibraries - -#ifdef SunArchitecture -NX_INCLUDES = -I../../../nxcomp -I/usr/sfw/include -#else -NX_INCLUDES = -I../../../nxcomp -#endif - -NX_DEFINES = -DNX_TRANS_SOCKET \ - -DNX_TRANS_EXIT - -# -DNX_TRANS_CHANGE \ -# -DNX_TRANS_WARN \ -# -DNX_TRANS_INFO \ -# -DNX_TRANS_TEST \ -# -DNX_TRANS_DEBUG \ - -#ifdef cygwinArchitecture -NX_XCOMPLIBNAME = cygXcomp.dll -NX_XCOMPEXTLIBNAME = cygXcompext.dll -#else -NX_XCOMPLIBNAME = libXcomp.so -NX_XCOMPEXTLIBNAME = libXcompext.so -#endif - -NX_XCOMPLIBDIR = $(XTOP)/../nxcomp -NX_XCOMPLIBLINK = Xcomp -NX_XCOMPLIBTARGET = $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) -NX_REQUIREDLIBS = -L$(NX_XCOMPLIBDIR) -l$(NX_XCOMPLIBLINK) -NX_XCOMPDEPTARGET = $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) -NX_XCOMPCONFIGTARGET = $(NX_XCOMPLIBDIR)/config.status - -NX_XCOMPEXTLIBDIR = $(XTOP)/../nxcompext -NX_XCOMPEXTLIBTARGET = $(NX_XCOMPEXTLIBDIR)/$(NX_XCOMPEXTLIBNAME) -NX_XCOMPEXTCONFIGTARGET = $(NX_XCOMPEXTLIBDIR)/config.status - -#endif - -#if BuildLoadableXlibI18n -#define IHaveSubdirs -#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" -#define NoLibSubdirs -#endif - -#define DoNormalLib NormalLibX11 -#define DoSharedLib SharedLibX11 -#define DoExtraLib SharedLibX11 -#define DoDebugLib DebugLibX11 -#define DoProfileLib ProfileLibX11 -#define LibName X11 -#define SoRev SOXLIBREV -#define HugeLibrary YES -#define IncSubdir X11 - -#if BuildLoadableXlibI18n -SUBDIRS = xlibi18n -#endif - -#include <Threads.tmpl> - -#ifndef MotifBC -#define MotifBC NO -#endif - -#ifdef SharedX11Reqs -REQUIREDX11LIBS = SharedX11Reqs -#endif -#if BuildLoadableXlibI18n -REQUIREDI18NLIBS = DlLibrary -#endif -#ifdef cygwinArchitecture -EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity -#endif - -REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) $(NX_REQUIREDLIBS) - -#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture) -XBSDLIB = /**/ -#endif -#if defined(LunaArchitecture) && defined(Mc88000Architecture) -EXTRA_LIBRARIES = /**/ -#endif -#if Malloc0ReturnsNull - MALLOC_DEFINES = XMalloc0ReturnsNullDefines -#endif -#if HasXdmAuth - XDMAUTHDEFS = -DHASXDMAUTH - XDMAUTHOBJS = Wrap.o Wraphelp.o - XDMAUTHSRCS = Wrap.c Wraphelp.c -#endif -#if BuildXKBlib - XKB_DEFINES = -DXKB - XKBSRCS = XKB.c XKBBind.c XKBCompat.c XKBCtrls.c XKBCvt.c XKBGetMap.c \ - XKBGetByName.c XKBNames.c XKBRdBuf.c XKBSetMap.c XKBUse.c \ - XKBleds.c XKBBell.c XKBGeom.c XKBSetGeom.c XKBExtDev.c \ - XKBList.c XKBMisc.c \ - XKBMAlloc.c XKBGAlloc.c XKBAlloc.c - XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \ - XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \ - XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \ - XKBList.o XKBMisc.o \ - XKBMAlloc.o XKBGAlloc.o XKBAlloc.o -#endif -#if HasSecureRPC - RPCDEFS = -DSECURE_RPC -#endif -#if HasPoll - POLL_DEFINES = -DUSE_POLL -#endif - CONN_DEFINES = $(CONNECTION_FLAGS) - XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) - XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) -#if HasBSD44Sockets - SOCK_DEFINES = -DBSD44SOCKETS -#endif -#if HasShm - SHM_DEFINES = -DHAS_SHM -#endif - - XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines - - EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\" - KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\" - CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\" -#if HasSnprintf - MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11 -#endif -#if MotifBC - BC_DEFINES = -DMOTIFBC -#endif -#if NoRConst - RCONST_DEFINES = -DNORCONST -#endif -#if DisableXLocaleDirEnv - SETID_DEFINES = -DNO_XLOCALEDIR -#elif HasIssetugid - SETID_DEFINES = -DHASSETUGID -#elif HasGetresuid - SETID_DEFINES = -DHASGETRESUID -#endif - XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\" -#if HasKrb5 - K5OBJS = k5encode.o - K5SRCS = k5encode.c - K5INCL = Krb5Includes - K5DEFS = Krb5Defines -#endif -#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \ - defined(OpenBSDArchitecture) -THRSTUBSRCS = UIThrStubs.c -THRSTUBOBJS = UIThrStubs.o -#endif -#if BuildLoadableXlibXcursor -XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\" -#endif -#if NeedLibInsideFlag - LIB_DEFINES = -D_XLIBINT_ -#endif -#if defined(LibDirName) - POSTLOCALELIBDIR = LibDirName - POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\" -#endif - DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\ - $(POSTLOCALELIBDEFINES) $(NX_INCLUDES) $(NX_DEFINES) - OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS) - DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines - AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o - AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c - SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */ - LINTLIBS = - -#if BuildLoadableXlibI18n && DoSharedLib -EXTRASHAREDSRC = $(SHAREDLCSRCS) -#endif -#if !BuildLoadableXlibI18n || DoNormalLib -EXTRASTATICSRC = $(STATICLCSRCS) -#endif - -EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC) - -SRCS1 = \ - Context.c \ - Depths.c \ - ParseCmd.c \ - Quarks.c \ - AllCells.c \ - AllPlanes.c \ - AllowEv.c \ - AutoRep.c \ - Backgnd.c \ - BdrWidth.c \ - Bell.c \ - Border.c \ - ChAccCon.c \ - ChClMode.c \ - ChActPGb.c \ - ChCmap.c \ - ChGC.c \ - ChKeyCon.c \ - ChPntCon.c \ - ChProp.c \ - ChSaveSet.c \ - ChWAttrs.c \ - ChWindow.c \ - ChkIfEv.c \ - ChkMaskEv.c \ - ChkWinEv.c \ - ChkTypEv.c \ - ChkTypWEv.c \ - CirWin.c \ - CirWinDn.c \ - CirWinUp.c \ - ClDisplay.c \ - Clear.c \ - ClearArea.c \ - ConfWind.c \ - ConnDis.c \ - ConvSel.c \ - CopyArea.c \ - CopyCmap.c \ - CopyGC.c \ - CopyPlane.c \ - CrBFData.c \ - CrCmap.c \ - CrCursor.c \ - CrGC.c \ - CrGlCur.c \ - CrPFBData.c \ - CrPixmap.c \ - CrWindow.c \ - Cursor.c \ - DefCursor.c \ - DelProp.c \ - DestSubs.c \ - DestWind.c \ - DisName.c \ - DrArc.c \ - DrArcs.c \ - DrLine.c \ - DrLines.c \ - DrPoint.c \ - DrPoints.c \ - DrRect.c \ - DrRects.c \ - DrSegs.c \ - ErrDes.c \ - ErrHndlr.c \ - EvToWire.c \ - FetchName.c \ - FillArc.c \ - FillArcs.c \ - FillPoly.c \ - FillRct.c \ - FillRcts.c \ - Flush.c \ - Font.c \ - FontNames.c \ - FontInfo.c \ - FreeCmap.c \ - FreeCols.c \ - FreeCurs.c \ - FreeEData.c \ - FreeGC.c \ - FreePix.c \ - FSSaver.c \ - GCMisc.c \ - Geom.c \ - GetAtomNm.c \ - GetColor.c \ - GetDflt.c \ - GetFPath.c \ - GetFProp.c \ - GetGeom.c \ - GetHColor.c \ - GetHints.c \ - GetIFocus.c \ - GetImage.c \ - GetKCnt.c \ - GetMoEv.c \ - GetPCnt.c \ - GetPntMap.c \ - GetProp.c \ - GetSOwner.c \ - GetSSaver.c \ - GetStCmap.c \ - GetWAttrs.c \ - GrButton.c \ - GrKey.c \ - GrKeybd.c \ - GrPointer.c \ - GrServer.c \ - Host.c \ - IfEvent.c \ - ImUtil.c \ - ImText.c \ - ImText16.c \ - InitExt.c \ - InsCmap.c \ - IntAtom.c \ - KeyBind.c \ - KeysymStr.c \ - KillCl.c \ - LiHosts.c \ - LiICmaps.c \ - LiProps.c \ - ListExt.c \ - LoadFont.c \ - LookupCol.c \ - LowerWin.c - -OBJS1 = \ - Context.o \ - Depths.o \ - ParseCmd.o \ - Quarks.o \ - AllCells.o \ - AllPlanes.o \ - AllowEv.o \ - AutoRep.o \ - Backgnd.o \ - BdrWidth.o \ - Bell.o \ - Border.o \ - ChAccCon.o \ - ChClMode.o \ - ChActPGb.o \ - ChCmap.o \ - ChGC.o \ - ChKeyCon.o \ - ChPntCon.o \ - ChProp.o \ - ChSaveSet.o \ - ChWAttrs.o \ - ChWindow.o \ - ChkIfEv.o \ - ChkMaskEv.o \ - ChkWinEv.o \ - ChkTypEv.o \ - ChkTypWEv.o \ - CirWin.o \ - CirWinDn.o \ - CirWinUp.o \ - ClDisplay.o \ - Clear.o \ - ClearArea.o \ - ConfWind.o \ - ConnDis.o \ - ConvSel.o \ - CopyArea.o \ - CopyCmap.o \ - CopyGC.o \ - CopyPlane.o \ - CrBFData.o \ - CrCmap.o \ - CrCursor.o \ - CrGC.o \ - CrGlCur.o \ - CrPFBData.o \ - CrPixmap.o \ - CrWindow.o \ - Cursor.o \ - DefCursor.o \ - DelProp.o \ - DestSubs.o \ - DestWind.o \ - DisName.o \ - DrArc.o \ - DrArcs.o \ - DrLine.o \ - DrLines.o \ - DrPoint.o \ - DrPoints.o \ - DrRect.o \ - DrRects.o \ - DrSegs.o \ - ErrDes.o \ - ErrHndlr.o \ - EvToWire.o \ - FetchName.o \ - FillArc.o \ - FillArcs.o \ - FillPoly.o \ - FillRct.o \ - FillRcts.o \ - Flush.o \ - Font.o \ - FontNames.o \ - FontInfo.o \ - FreeCmap.o \ - FreeCols.o \ - FreeCurs.o \ - FreeEData.o \ - FreeGC.o \ - FreePix.o \ - FSSaver.o \ - GCMisc.o \ - Geom.o \ - GetAtomNm.o \ - GetColor.o \ - GetDflt.o \ - GetFPath.o \ - GetFProp.o \ - GetGeom.o \ - GetHColor.o \ - GetHints.o \ - GetIFocus.o \ - GetImage.o \ - GetKCnt.o \ - GetMoEv.o \ - GetPCnt.o \ - GetPntMap.o \ - GetProp.o \ - GetSOwner.o \ - GetSSaver.o \ - GetStCmap.o \ - GetWAttrs.o \ - GrButton.o \ - GrKey.o \ - GrKeybd.o \ - GrPointer.o \ - GrServer.o \ - Host.o \ - IfEvent.o \ - ImUtil.o \ - ImText.o \ - ImText16.o \ - InitExt.o \ - InsCmap.o \ - IntAtom.o \ - KeyBind.o \ - KeysymStr.o \ - KillCl.o \ - LiHosts.o \ - LiICmaps.o \ - LiProps.o \ - ListExt.o \ - LoadFont.o \ - LookupCol.o \ - LowerWin.o - -SRCS2 = \ - Macros.c \ - MapRaised.c \ - MapSubs.c \ - MapWindow.c \ - MaskEvent.c \ - Misc.c \ - ModMap.c \ - MoveWin.c \ - NextEvent.c \ - OpenDis.c \ - ParseCol.c \ - ParseGeom.c \ - PeekEvent.c \ - PeekIfEv.c \ - Pending.c \ - PmapBgnd.c \ - PmapBord.c \ - PolyReg.c \ - PolyTxt.c \ - PolyTxt16.c \ - PutBEvent.c \ - PutImage.c \ - QuBest.c \ - QuColor.c \ - QuColors.c \ - QuCurShp.c \ - QuExt.c \ - QuKeybd.c \ - QuPntr.c \ - QuStipShp.c \ - QuTextE16.c \ - QuTextExt.c \ - QuTileShp.c \ - QuTree.c \ - RaiseWin.c \ - RdBitF.c \ - RecolorC.c \ - ReconfWin.c \ - Region.c \ - RepWindow.c \ - RestackWs.c \ - RotProp.c \ - ScrResStr.c \ - SelInput.c \ - SendEvent.c \ - SetBack.c \ - SetCRects.c \ - SetClMask.c \ - SetClOrig.c \ - SetDashes.c \ - SetFPath.c \ - SetFont.c \ - SetFore.c \ - SetFunc.c \ - SetHints.c \ - SetIFocus.c \ - SetLStyle.c \ - SetPMask.c \ - SetPntMap.c \ - SetSOwner.c \ - SetSSaver.c \ - SetState.c \ - SetStip.c \ - SetStCmap.c \ - SetTile.c \ - SetTSOrig.c \ - StBytes.c \ - StColor.c \ - StColors.c \ - StNColor.c \ - StName.c \ - StrKeysym.c \ - Sync.c \ - Synchro.c \ - Text.c \ - Text16.c \ - TextExt.c \ - TextExt16.c \ - TrCoords.c \ - UndefCurs.c \ - UngrabBut.c \ - UngrabKbd.c \ - UngrabKey.c \ - UngrabPtr.c \ - UngrabSvr.c \ - UninsCmap.c \ - UnldFont.c \ - UnmapSubs.c \ - UnmapWin.c \ - VisUtil.c \ - WarpPtr.c \ - WinEvent.c \ - Window.c \ - WrBitF.c \ - XlibAsync.c \ - XlibInt.c \ - Xrm.c \ - evtomask.c \ - globals.c \ - GetGCVals.c \ - GetNrmHint.c \ - GetRGBCMap.c \ - GetTxtProp.c \ - GetWMCMapW.c \ - GetWMProto.c \ - Iconify.c \ - PixFormats.c \ - PropAlloc.c \ - ReconfWM.c \ - SetNrmHint.c \ - SetRGBCMap.c \ - SetTxtProp.c \ - SetWMCMapW.c \ - SetWMProto.c \ - StrToText.c \ - TextToStr.c \ - Withdraw.c \ - WMGeom.c \ - WMProps.c \ - $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS) - -OBJS2 = \ - Macros.o \ - MapRaised.o \ - MapSubs.o \ - MapWindow.o \ - MaskEvent.o \ - Misc.o \ - ModMap.o \ - MoveWin.o \ - NextEvent.o \ - OpenDis.o \ - ParseCol.o \ - ParseGeom.o \ - PeekEvent.o \ - PeekIfEv.o \ - Pending.o \ - PmapBgnd.o \ - PmapBord.o \ - PolyReg.o \ - PolyTxt.o \ - PolyTxt16.o \ - PutBEvent.o \ - PutImage.o \ - QuBest.o \ - QuColor.o \ - QuColors.o \ - QuCurShp.o \ - QuExt.o \ - QuKeybd.o \ - QuPntr.o \ - QuStipShp.o \ - QuTextE16.o \ - QuTextExt.o \ - QuTileShp.o \ - QuTree.o \ - RaiseWin.o \ - RdBitF.o \ - RecolorC.o \ - ReconfWin.o \ - Region.o \ - RepWindow.o \ - RestackWs.o \ - RotProp.o \ - ScrResStr.o \ - SelInput.o \ - SendEvent.o \ - SetBack.o \ - SetCRects.o \ - SetClMask.o \ - SetClOrig.o \ - SetDashes.o \ - SetFPath.o \ - SetFont.o \ - SetFore.o \ - SetFunc.o \ - SetHints.o \ - SetIFocus.o \ - SetLStyle.o \ - SetPMask.o \ - SetPntMap.o \ - SetSOwner.o \ - SetSSaver.o \ - SetState.o \ - SetStip.o \ - SetStCmap.o \ - SetTile.o \ - SetTSOrig.o \ - StBytes.o \ - StColor.o \ - StColors.o \ - StNColor.o \ - StName.o \ - StrKeysym.o \ - Sync.o \ - Synchro.o \ - Text.o \ - Text16.o \ - TextExt.o \ - TextExt16.o \ - TrCoords.o \ - UndefCurs.o \ - UngrabBut.o \ - UngrabKbd.o \ - UngrabKey.o \ - UngrabPtr.o \ - UngrabSvr.o \ - UninsCmap.o \ - UnldFont.o \ - UnmapSubs.o \ - UnmapWin.o \ - VisUtil.o \ - WarpPtr.o \ - WinEvent.o \ - Window.o \ - WrBitF.o \ - XlibAsync.o \ - XlibInt.o \ - Xrm.o \ - evtomask.o \ - globals.o \ - GetGCVals.o \ - GetNrmHint.o \ - GetRGBCMap.o \ - GetTxtProp.o \ - GetWMCMapW.o \ - GetWMProto.o \ - Iconify.o \ - PixFormats.o \ - PropAlloc.o \ - ReconfWM.o \ - SetNrmHint.o \ - SetRGBCMap.o \ - SetTxtProp.o \ - SetWMCMapW.o \ - SetWMProto.o \ - StrToText.o \ - TextToStr.o \ - Withdraw.o \ - WMGeom.o \ - WMProps.o \ - $(AUTHOBJS) \ - $(XDMAUTHOBJS) \ - $(K5OBJS) \ - $(THRSTUBOBJS) - -SRCS3 = \ - Lab.c \ - LabGcC.c \ - LabGcL.c \ - LabGcLC.c \ - LabMnL.c \ - LabMxC.c \ - LabMxL.c \ - LabMxLC.c \ - LabWpAj.c \ - Luv.c \ - LuvGcC.c \ - LuvGcL.c \ - LuvGcLC.c \ - LuvMnL.c \ - LuvMxC.c \ - LuvMxL.c \ - LuvMxLC.c \ - LuvWpAj.c \ - XYZ.c \ - uvY.c \ - xyY.c \ - HVC.c \ - HVCGcC.c \ - HVCGcV.c \ - HVCGcVC.c \ - HVCMnV.c \ - HVCMxC.c \ - HVCMxV.c \ - HVCMxVC.c \ - HVCMxVs.c \ - HVCWpAj.c \ - UNDEFINED.c \ - AddDIC.c \ - AddSF.c \ - cmsAllNCol.c \ - cmsAllCol.c \ - CCC.c \ - cmsCmap.c \ - cmsColNm.c \ - CvColW.c \ - CvCols.c \ - cmsGlobls.c \ - IdOfPr.c \ - cmsInt.c \ - LRGB.c \ - cmsLkCol.c \ - cmsMath.c \ - OfCCC.c \ - PrOfId.c \ - cmsProp.c \ - QBlack.c \ - QBlue.c \ - QGreen.c \ - QRed.c \ - QWhite.c \ - QuCol.c \ - QuCols.c \ - SetCCC.c \ - SetGetCols.c \ - StCol.c \ - StCols.c \ - cmsTrig.c \ - XRGB.c \ - FSWrap.c \ - ICWrap.c \ - IMWrap.c \ - OCWrap.c \ - OMWrap.c \ - lcWrap.c \ - mbWMProps.c \ - utf8WMProps.c \ - mbWrap.c \ - wcWrap.c \ - utf8Wrap.c \ - FilterEv.c \ - RegstFlt.c \ - locking.c \ - LockDis.c \ - x11trans.c \ - ximtrans.c \ - $(XKBSRCS) $(LCSRCS) $(MISCSRCS) - -OBJS3 = \ - Lab.o \ - LabGcC.o \ - LabGcL.o \ - LabGcLC.o \ - LabMnL.o \ - LabMxC.o \ - LabMxL.o \ - LabMxLC.o \ - LabWpAj.o \ - Luv.o \ - LuvGcC.o \ - LuvGcL.o \ - LuvGcLC.o \ - LuvMnL.o \ - LuvMxC.o \ - LuvMxL.o \ - LuvMxLC.o \ - LuvWpAj.o \ - XYZ.o \ - uvY.o \ - xyY.o \ - HVC.o \ - HVCGcC.o \ - HVCGcV.o \ - HVCGcVC.o \ - HVCMnV.o \ - HVCMxC.o \ - HVCMxV.o \ - HVCMxVC.o \ - HVCMxVs.o \ - HVCWpAj.o \ - UNDEFINED.o \ - AddDIC.o \ - AddSF.o \ - cmsAllNCol.o \ - cmsAllCol.o \ - CCC.o \ - cmsCmap.o \ - cmsColNm.o \ - CvColW.o \ - CvCols.o \ - cmsGlobls.o \ - IdOfPr.o \ - cmsInt.o \ - LRGB.o \ - cmsLkCol.o \ - cmsMath.o \ - OfCCC.o \ - PrOfId.o \ - cmsProp.o \ - QBlack.o \ - QBlue.o \ - QGreen.o \ - QRed.o \ - QWhite.o \ - QuCol.o \ - QuCols.o \ - SetCCC.o \ - SetGetCols.o \ - StCol.o \ - StCols.o \ - cmsTrig.o \ - XRGB.o \ - FSWrap.o \ - ICWrap.o \ - IMWrap.o \ - OCWrap.o \ - OMWrap.o \ - lcWrap.o \ - mbWMProps.o \ - utf8WMProps.o \ - mbWrap.o \ - wcWrap.o \ - utf8Wrap.o \ - FilterEv.o \ - RegstFlt.o \ - locking.o \ - LockDis.o \ - x11trans.o \ - ximtrans.o \ - $(XKBOBJS) $(LCOBJS) $(MISCOBJS) - -#if BuildLoadableXlibI18n -LC_DYNDEFINES = -DUSE_DYNAMIC_LC -#endif - -SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c - -SHAREDI18NSTATICSRCS = \ - XDefaultIMIF.c XDefaultOMIF.c - -STATICLCDEPSYMSRCS = - -STATICI18NSTATICSRCS = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRm.c \ - imRmAttr.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrX.c \ - imTransR.c \ - imTrans.c \ - lcEuc.c \ - lcGenConv.c \ - lcJis.c \ - lcSjis.c \ - lcUTF8Load.c \ - omDefault.c \ - omGeneric.c \ - omImText.c \ - omText.c \ - omTextEsc.c \ - omTextExt.c \ - omTextPer.c \ - omXChar.c - -LCSRCS = \ - SetLocale.c \ - imConv.c \ - imKStoUCS.c \ - lcCT.c \ - lcCharSet.c \ - lcConv.c \ - lcDB.c \ - lcDefConv.c \ - lcFile.c \ - lcGeneric.c \ - lcInit.c \ - lcPrTxt.c \ - lcPubWrap.c \ - lcPublic.c \ - lcRM.c \ - lcStd.c \ - lcTxtPr.c \ - lcUtil.c \ - lcUTF8.c - -STATICLCSRCS = \ - $(STATICLCDEPSYMSRCS) \ - $(STATICI18NSTATICSRCS) - -SHAREDLCSRCS = \ - $(SHAREDLCDEPSYMSRCS) \ - $(SHAREDI18NSTATICSRCS) - -SHAREDLCDEPOBJS = XlcDL.o XlcSL.o -SHAREDI18NSTATICOBJS = \ - XDefaultIMIF.o XDefaultOMIF.o -STATICLCDEPOBJS = -STATICI18NSTATICOBJS = \ - imCallbk.o \ - imDefFlt.o \ - imDefIc.o \ - imDefIm.o \ - imDefLkup.o \ - imDispch.o \ - imEvToWire.o \ - imExten.o \ - imImSw.o \ - imInsClbk.o \ - imInt.o \ - imLcFlt.o \ - imLcGIc.o \ - imLcIc.o \ - imLcIm.o \ - imLcLkup.o \ - imLcPrs.o \ - imLcSIc.o \ - imRm.o \ - imRmAttr.o \ - imThaiFlt.o \ - imThaiIc.o \ - imThaiIm.o \ - imTrX.o \ - imTransR.o \ - imTrans.o \ - lcEuc.o \ - lcGenConv.o \ - lcJis.o \ - lcSjis.o \ - lcUTF8Load.o \ - omDefault.o \ - omGeneric.o \ - omImText.o \ - omText.o \ - omTextEsc.o \ - omTextExt.o \ - omTextPer.o \ - omXChar.o - -LCOBJS = \ - SetLocale.o \ - imConv.o \ - imKStoUCS.o \ - lcCT.o \ - lcCharSet.o \ - lcConv.o \ - lcDB.o \ - lcDefConv.o \ - lcFile.o \ - lcGeneric.o \ - lcInit.o \ - lcPrTxt.o \ - lcPubWrap.o \ - lcPublic.o \ - lcRM.o \ - lcStd.o \ - lcTxtPr.o \ - lcUtil.o \ - lcUTF8.o - -STATICLCOBJS = \ - $(STATICLCDEPOBJS) \ - $(STATICI18NSTATICOBJS) - -SHAREDLCOBJS = \ - $(SHAREDLCDEPOBJS) \ - $(SHAREDI18NSTATICOBJS) - -#ifdef OS2Architecture -MISCSRCS = os2Stubs.c -#endif - -#ifdef OS2Architecture -MISCOBJS = os2Stubs.o -#endif - -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -EXTRAUNSHAREDOBJS = $(STATICLCOBJS) - -#if BuildLoadableXlibI18n -EXTRASHAREDOBJS = $(SHAREDLCOBJS) -# else -EXTRASHAREDOBJS = $(STATICLCOBJS) -#endif - -#include <Library.tmpl> - -SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES)) -SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES)) -SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS)) -SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES)) -LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES)) -LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES)) -SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS)) -SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES)) -SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES)) -SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES)) -SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES)) -SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES)) -#if BuildXKBlib -SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES)) -#endif -#if HasKrb5 -SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL)) -#endif -#if BuildLoadableXlibI18n -SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -#endif -#if BuildLoadableXlibXcursor -SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -#endif - -#if InstallXcmsTxt -InstallNonExecFile(Xcms.txt,$(LIBDIR)) -#endif -InstallNonExecFile(XErrorDB,$(LIBDIR)) -InstallNonExecFile(XKeysymDB,$(LIBDIR)) -InstallLintLibrary(X11,$(LINTLIBDIR)) - - -LinkSourceFile(AuDispose.c,$(XAUTHSRC)) -LinkSourceFile(AuGetBest.c,$(XAUTHSRC)) -LinkSourceFile(AuFileName.c,$(XAUTHSRC)) -LinkSourceFile(AuRead.c,$(XAUTHSRC)) -#if HasKrb5 -LinkSourceFile(k5encode.c,$(XAUTHSRC)) -#endif -#if HasXdmAuth -LinkSourceFile(Wrap.h,$(XDMCPLIBSRC)) -LinkSourceFile(Wrap.c,$(XDMCPLIBSRC)) -LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC)) -#endif - -#ifdef QNX4Architecture -LOCAL_LDFLAGS=-F -#endif - -MAKEKEYS = ./makekeys - -#if CrossCompiling -HOST_LDLIBS= -HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \ - $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES) -#else -HOST_LDLIBS=$(LDLIBS) -HOST_CFLAGS=$(CFLAGS) -#endif - -ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c - RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf) - -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS)) - RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h) - $(MV) ks_tables_h $@ - RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h) - -includes:: ks_tables.h - -#if NXLibraries - -$(NX_XCOMPCONFIGTARGET): - cd ../../../nxcomp && \ - ./configure - -$(NX_XCOMPEXTCONFIGTARGET): - cd ../../../nxcompext && \ - ./configure - -#ifdef SunArchitecture -$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET) - cd $(NX_XCOMPLIBDIR) && \ - gmake - -$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET) - cd ../../../nxcompext && \ - gmake - -#else -$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET) - cd $(NX_XCOMPLIBDIR) && \ - make - -$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET) - cd ../../../nxcompext && \ - make - -#endif - -depend:: $(NX_XCOMPLIBTARGET) - -all:: $(NX_XCOMPLIBTARGET) - -$(NX_XCOMPDEPTARGET): - ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) - ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME).1 $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1 - -depend:: $(NX_XCOMPLIBTARGET) - -all:: $(NX_XCOMPDEPTARGET) $(NX_XCOMPEXTLIBTARGET) - -clean:: - rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) - rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1 - -#endif - -depend:: ks_tables.h - -clean:: - RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys)) - - -DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS)) - -#if BuildLoadableXlibI18n -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) -MakeLintLibSubdirs($(LINTSUBDIRS)) -MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln) -#endif -#endif - -includes:: XlibConf.h - -#include <Threads.tmpl> - -#if ThreadedProject -#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\ - echo '#define XTHREADS' >> $@ @@\ - echo '#endif' >> $@ -#else -#define XThreadsDefine echo '#undef XTHREADS' >> $@ -#endif - -#if HasThreadSafeAPI -#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\ - echo '#define XUSE_MTSAFE_API' >> $@ @@\ - echo '#endif' >> $@ -#else -#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@ -#endif - -XlibConf.h: - echo '/* Defines needed to use Xlib from non-imake projects */' > $@ - XThreadsDefine - MTSafeAPIDefine diff --git a/nx-X11/lib/X11/Imakefile.X.original b/nx-X11/lib/X11/Imakefile.X.original deleted file mode 100644 index 1f2c9b2bc..000000000 --- a/nx-X11/lib/X11/Imakefile.X.original +++ /dev/null @@ -1,1134 +0,0 @@ -XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $ - - - - HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \ - Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h - -#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer -all:: - -BuildIncludes($(HEADERS),IncSubdir,..) - -#else - -#if BuildLoadableXlibI18n -#define IHaveSubdirs -#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" -#define NoLibSubdirs -#endif - -#define DoNormalLib NormalLibX11 -#define DoSharedLib SharedLibX11 -#define DoExtraLib SharedLibX11 -#define DoDebugLib DebugLibX11 -#define DoProfileLib ProfileLibX11 -#define LibName X11 -#define SoRev SOXLIBREV -#define HugeLibrary YES -#define IncSubdir X11 - -#if BuildLoadableXlibI18n -SUBDIRS = xlibi18n -#endif - -#include <Threads.tmpl> - -#ifndef MotifBC -#define MotifBC NO -#endif - -#ifdef SharedX11Reqs -REQUIREDX11LIBS = SharedX11Reqs -#endif -#if BuildLoadableXlibI18n -REQUIREDI18NLIBS = DlLibrary -#endif -#ifdef cygwinArchitecture -EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity -#endif - -REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) - -#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture) -XBSDLIB = /**/ -#endif -#if defined(LunaArchitecture) && defined(Mc88000Architecture) -EXTRA_LIBRARIES = /**/ -#endif -#if Malloc0ReturnsNull - MALLOC_DEFINES = XMalloc0ReturnsNullDefines -#endif -#if HasXdmAuth - XDMAUTHDEFS = -DHASXDMAUTH - XDMAUTHOBJS = Wrap.o Wraphelp.o - XDMAUTHSRCS = Wrap.c Wraphelp.c -#endif -#if BuildXKBlib - XKB_DEFINES = -DXKB - XKBSRCS = XKB.c XKBBind.c XKBCompat.c XKBCtrls.c XKBCvt.c XKBGetMap.c \ - XKBGetByName.c XKBNames.c XKBRdBuf.c XKBSetMap.c XKBUse.c \ - XKBleds.c XKBBell.c XKBGeom.c XKBSetGeom.c XKBExtDev.c \ - XKBList.c XKBMisc.c \ - XKBMAlloc.c XKBGAlloc.c XKBAlloc.c - XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \ - XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \ - XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \ - XKBList.o XKBMisc.o \ - XKBMAlloc.o XKBGAlloc.o XKBAlloc.o -#endif -#if HasSecureRPC - RPCDEFS = -DSECURE_RPC -#endif -#if HasPoll - POLL_DEFINES = -DUSE_POLL -#endif - CONN_DEFINES = $(CONNECTION_FLAGS) - XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) - XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) -#if HasBSD44Sockets - SOCK_DEFINES = -DBSD44SOCKETS -#endif -#if HasShm - SHM_DEFINES = -DHAS_SHM -#endif - - XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines - - EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\" - KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\" - CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\" -#if HasSnprintf - MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11 -#endif -#if MotifBC - BC_DEFINES = -DMOTIFBC -#endif -#if NoRConst - RCONST_DEFINES = -DNORCONST -#endif -#if DisableXLocaleDirEnv - SETID_DEFINES = -DNO_XLOCALEDIR -#elif HasIssetugid - SETID_DEFINES = -DHASSETUGID -#elif HasGetresuid - SETID_DEFINES = -DHASGETRESUID -#endif - XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\" -#if HasKrb5 - K5OBJS = k5encode.o - K5SRCS = k5encode.c - K5INCL = Krb5Includes - K5DEFS = Krb5Defines -#endif -#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \ - defined(OpenBSDArchitecture) -THRSTUBSRCS = UIThrStubs.c -THRSTUBOBJS = UIThrStubs.o -#endif -#if BuildLoadableXlibXcursor -XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\" -#endif -#if NeedLibInsideFlag - LIB_DEFINES = -D_XLIBINT_ -#endif -#if defined(LibDirName) - POSTLOCALELIBDIR = LibDirName - POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\" -#endif - DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\ - $(POSTLOCALELIBDEFINES) - OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS) - DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines - AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o - AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c - SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */ - LINTLIBS = - -#if BuildLoadableXlibI18n && DoSharedLib -EXTRASHAREDSRC = $(SHAREDLCSRCS) -#endif -#if !BuildLoadableXlibI18n || DoNormalLib -EXTRASTATICSRC = $(STATICLCSRCS) -#endif - -EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC) - -SRCS1 = \ - Context.c \ - Depths.c \ - ParseCmd.c \ - Quarks.c \ - AllCells.c \ - AllPlanes.c \ - AllowEv.c \ - AutoRep.c \ - Backgnd.c \ - BdrWidth.c \ - Bell.c \ - Border.c \ - ChAccCon.c \ - ChClMode.c \ - ChActPGb.c \ - ChCmap.c \ - ChGC.c \ - ChKeyCon.c \ - ChPntCon.c \ - ChProp.c \ - ChSaveSet.c \ - ChWAttrs.c \ - ChWindow.c \ - ChkIfEv.c \ - ChkMaskEv.c \ - ChkWinEv.c \ - ChkTypEv.c \ - ChkTypWEv.c \ - CirWin.c \ - CirWinDn.c \ - CirWinUp.c \ - ClDisplay.c \ - Clear.c \ - ClearArea.c \ - ConfWind.c \ - ConnDis.c \ - ConvSel.c \ - CopyArea.c \ - CopyCmap.c \ - CopyGC.c \ - CopyPlane.c \ - CrBFData.c \ - CrCmap.c \ - CrCursor.c \ - CrGC.c \ - CrGlCur.c \ - CrPFBData.c \ - CrPixmap.c \ - CrWindow.c \ - Cursor.c \ - DefCursor.c \ - DelProp.c \ - DestSubs.c \ - DestWind.c \ - DisName.c \ - DrArc.c \ - DrArcs.c \ - DrLine.c \ - DrLines.c \ - DrPoint.c \ - DrPoints.c \ - DrRect.c \ - DrRects.c \ - DrSegs.c \ - ErrDes.c \ - ErrHndlr.c \ - EvToWire.c \ - FetchName.c \ - FillArc.c \ - FillArcs.c \ - FillPoly.c \ - FillRct.c \ - FillRcts.c \ - Flush.c \ - Font.c \ - FontNames.c \ - FontInfo.c \ - FreeCmap.c \ - FreeCols.c \ - FreeCurs.c \ - FreeEData.c \ - FreeGC.c \ - FreePix.c \ - FSSaver.c \ - GCMisc.c \ - Geom.c \ - GetAtomNm.c \ - GetColor.c \ - GetDflt.c \ - GetFPath.c \ - GetFProp.c \ - GetGeom.c \ - GetHColor.c \ - GetHints.c \ - GetIFocus.c \ - GetImage.c \ - GetKCnt.c \ - GetMoEv.c \ - GetPCnt.c \ - GetPntMap.c \ - GetProp.c \ - GetSOwner.c \ - GetSSaver.c \ - GetStCmap.c \ - GetWAttrs.c \ - GrButton.c \ - GrKey.c \ - GrKeybd.c \ - GrPointer.c \ - GrServer.c \ - Host.c \ - IfEvent.c \ - ImUtil.c \ - ImText.c \ - ImText16.c \ - InitExt.c \ - InsCmap.c \ - IntAtom.c \ - KeyBind.c \ - KeysymStr.c \ - KillCl.c \ - LiHosts.c \ - LiICmaps.c \ - LiProps.c \ - ListExt.c \ - LoadFont.c \ - LookupCol.c \ - LowerWin.c - -OBJS1 = \ - Context.o \ - Depths.o \ - ParseCmd.o \ - Quarks.o \ - AllCells.o \ - AllPlanes.o \ - AllowEv.o \ - AutoRep.o \ - Backgnd.o \ - BdrWidth.o \ - Bell.o \ - Border.o \ - ChAccCon.o \ - ChClMode.o \ - ChActPGb.o \ - ChCmap.o \ - ChGC.o \ - ChKeyCon.o \ - ChPntCon.o \ - ChProp.o \ - ChSaveSet.o \ - ChWAttrs.o \ - ChWindow.o \ - ChkIfEv.o \ - ChkMaskEv.o \ - ChkWinEv.o \ - ChkTypEv.o \ - ChkTypWEv.o \ - CirWin.o \ - CirWinDn.o \ - CirWinUp.o \ - ClDisplay.o \ - Clear.o \ - ClearArea.o \ - ConfWind.o \ - ConnDis.o \ - ConvSel.o \ - CopyArea.o \ - CopyCmap.o \ - CopyGC.o \ - CopyPlane.o \ - CrBFData.o \ - CrCmap.o \ - CrCursor.o \ - CrGC.o \ - CrGlCur.o \ - CrPFBData.o \ - CrPixmap.o \ - CrWindow.o \ - Cursor.o \ - DefCursor.o \ - DelProp.o \ - DestSubs.o \ - DestWind.o \ - DisName.o \ - DrArc.o \ - DrArcs.o \ - DrLine.o \ - DrLines.o \ - DrPoint.o \ - DrPoints.o \ - DrRect.o \ - DrRects.o \ - DrSegs.o \ - ErrDes.o \ - ErrHndlr.o \ - EvToWire.o \ - FetchName.o \ - FillArc.o \ - FillArcs.o \ - FillPoly.o \ - FillRct.o \ - FillRcts.o \ - Flush.o \ - Font.o \ - FontNames.o \ - FontInfo.o \ - FreeCmap.o \ - FreeCols.o \ - FreeCurs.o \ - FreeEData.o \ - FreeGC.o \ - FreePix.o \ - FSSaver.o \ - GCMisc.o \ - Geom.o \ - GetAtomNm.o \ - GetColor.o \ - GetDflt.o \ - GetFPath.o \ - GetFProp.o \ - GetGeom.o \ - GetHColor.o \ - GetHints.o \ - GetIFocus.o \ - GetImage.o \ - GetKCnt.o \ - GetMoEv.o \ - GetPCnt.o \ - GetPntMap.o \ - GetProp.o \ - GetSOwner.o \ - GetSSaver.o \ - GetStCmap.o \ - GetWAttrs.o \ - GrButton.o \ - GrKey.o \ - GrKeybd.o \ - GrPointer.o \ - GrServer.o \ - Host.o \ - IfEvent.o \ - ImUtil.o \ - ImText.o \ - ImText16.o \ - InitExt.o \ - InsCmap.o \ - IntAtom.o \ - KeyBind.o \ - KeysymStr.o \ - KillCl.o \ - LiHosts.o \ - LiICmaps.o \ - LiProps.o \ - ListExt.o \ - LoadFont.o \ - LookupCol.o \ - LowerWin.o - -SRCS2 = \ - Macros.c \ - MapRaised.c \ - MapSubs.c \ - MapWindow.c \ - MaskEvent.c \ - Misc.c \ - ModMap.c \ - MoveWin.c \ - NextEvent.c \ - OpenDis.c \ - ParseCol.c \ - ParseGeom.c \ - PeekEvent.c \ - PeekIfEv.c \ - Pending.c \ - PmapBgnd.c \ - PmapBord.c \ - PolyReg.c \ - PolyTxt.c \ - PolyTxt16.c \ - PutBEvent.c \ - PutImage.c \ - QuBest.c \ - QuColor.c \ - QuColors.c \ - QuCurShp.c \ - QuExt.c \ - QuKeybd.c \ - QuPntr.c \ - QuStipShp.c \ - QuTextE16.c \ - QuTextExt.c \ - QuTileShp.c \ - QuTree.c \ - RaiseWin.c \ - RdBitF.c \ - RecolorC.c \ - ReconfWin.c \ - Region.c \ - RepWindow.c \ - RestackWs.c \ - RotProp.c \ - ScrResStr.c \ - SelInput.c \ - SendEvent.c \ - SetBack.c \ - SetCRects.c \ - SetClMask.c \ - SetClOrig.c \ - SetDashes.c \ - SetFPath.c \ - SetFont.c \ - SetFore.c \ - SetFunc.c \ - SetHints.c \ - SetIFocus.c \ - SetLStyle.c \ - SetPMask.c \ - SetPntMap.c \ - SetSOwner.c \ - SetSSaver.c \ - SetState.c \ - SetStip.c \ - SetStCmap.c \ - SetTile.c \ - SetTSOrig.c \ - StBytes.c \ - StColor.c \ - StColors.c \ - StNColor.c \ - StName.c \ - StrKeysym.c \ - Sync.c \ - Synchro.c \ - Text.c \ - Text16.c \ - TextExt.c \ - TextExt16.c \ - TrCoords.c \ - UndefCurs.c \ - UngrabBut.c \ - UngrabKbd.c \ - UngrabKey.c \ - UngrabPtr.c \ - UngrabSvr.c \ - UninsCmap.c \ - UnldFont.c \ - UnmapSubs.c \ - UnmapWin.c \ - VisUtil.c \ - WarpPtr.c \ - WinEvent.c \ - Window.c \ - WrBitF.c \ - XlibAsync.c \ - XlibInt.c \ - Xrm.c \ - evtomask.c \ - globals.c \ - GetGCVals.c \ - GetNrmHint.c \ - GetRGBCMap.c \ - GetTxtProp.c \ - GetWMCMapW.c \ - GetWMProto.c \ - Iconify.c \ - PixFormats.c \ - PropAlloc.c \ - ReconfWM.c \ - SetNrmHint.c \ - SetRGBCMap.c \ - SetTxtProp.c \ - SetWMCMapW.c \ - SetWMProto.c \ - StrToText.c \ - TextToStr.c \ - Withdraw.c \ - WMGeom.c \ - WMProps.c \ - $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS) - -OBJS2 = \ - Macros.o \ - MapRaised.o \ - MapSubs.o \ - MapWindow.o \ - MaskEvent.o \ - Misc.o \ - ModMap.o \ - MoveWin.o \ - NextEvent.o \ - OpenDis.o \ - ParseCol.o \ - ParseGeom.o \ - PeekEvent.o \ - PeekIfEv.o \ - Pending.o \ - PmapBgnd.o \ - PmapBord.o \ - PolyReg.o \ - PolyTxt.o \ - PolyTxt16.o \ - PutBEvent.o \ - PutImage.o \ - QuBest.o \ - QuColor.o \ - QuColors.o \ - QuCurShp.o \ - QuExt.o \ - QuKeybd.o \ - QuPntr.o \ - QuStipShp.o \ - QuTextE16.o \ - QuTextExt.o \ - QuTileShp.o \ - QuTree.o \ - RaiseWin.o \ - RdBitF.o \ - RecolorC.o \ - ReconfWin.o \ - Region.o \ - RepWindow.o \ - RestackWs.o \ - RotProp.o \ - ScrResStr.o \ - SelInput.o \ - SendEvent.o \ - SetBack.o \ - SetCRects.o \ - SetClMask.o \ - SetClOrig.o \ - SetDashes.o \ - SetFPath.o \ - SetFont.o \ - SetFore.o \ - SetFunc.o \ - SetHints.o \ - SetIFocus.o \ - SetLStyle.o \ - SetPMask.o \ - SetPntMap.o \ - SetSOwner.o \ - SetSSaver.o \ - SetState.o \ - SetStip.o \ - SetStCmap.o \ - SetTile.o \ - SetTSOrig.o \ - StBytes.o \ - StColor.o \ - StColors.o \ - StNColor.o \ - StName.o \ - StrKeysym.o \ - Sync.o \ - Synchro.o \ - Text.o \ - Text16.o \ - TextExt.o \ - TextExt16.o \ - TrCoords.o \ - UndefCurs.o \ - UngrabBut.o \ - UngrabKbd.o \ - UngrabKey.o \ - UngrabPtr.o \ - UngrabSvr.o \ - UninsCmap.o \ - UnldFont.o \ - UnmapSubs.o \ - UnmapWin.o \ - VisUtil.o \ - WarpPtr.o \ - WinEvent.o \ - Window.o \ - WrBitF.o \ - XlibAsync.o \ - XlibInt.o \ - Xrm.o \ - evtomask.o \ - globals.o \ - GetGCVals.o \ - GetNrmHint.o \ - GetRGBCMap.o \ - GetTxtProp.o \ - GetWMCMapW.o \ - GetWMProto.o \ - Iconify.o \ - PixFormats.o \ - PropAlloc.o \ - ReconfWM.o \ - SetNrmHint.o \ - SetRGBCMap.o \ - SetTxtProp.o \ - SetWMCMapW.o \ - SetWMProto.o \ - StrToText.o \ - TextToStr.o \ - Withdraw.o \ - WMGeom.o \ - WMProps.o \ - $(AUTHOBJS) \ - $(XDMAUTHOBJS) \ - $(K5OBJS) \ - $(THRSTUBOBJS) - -SRCS3 = \ - Lab.c \ - LabGcC.c \ - LabGcL.c \ - LabGcLC.c \ - LabMnL.c \ - LabMxC.c \ - LabMxL.c \ - LabMxLC.c \ - LabWpAj.c \ - Luv.c \ - LuvGcC.c \ - LuvGcL.c \ - LuvGcLC.c \ - LuvMnL.c \ - LuvMxC.c \ - LuvMxL.c \ - LuvMxLC.c \ - LuvWpAj.c \ - XYZ.c \ - uvY.c \ - xyY.c \ - HVC.c \ - HVCGcC.c \ - HVCGcV.c \ - HVCGcVC.c \ - HVCMnV.c \ - HVCMxC.c \ - HVCMxV.c \ - HVCMxVC.c \ - HVCMxVs.c \ - HVCWpAj.c \ - UNDEFINED.c \ - AddDIC.c \ - AddSF.c \ - cmsAllNCol.c \ - cmsAllCol.c \ - CCC.c \ - cmsCmap.c \ - cmsColNm.c \ - CvColW.c \ - CvCols.c \ - cmsGlobls.c \ - IdOfPr.c \ - cmsInt.c \ - LRGB.c \ - cmsLkCol.c \ - cmsMath.c \ - OfCCC.c \ - PrOfId.c \ - cmsProp.c \ - QBlack.c \ - QBlue.c \ - QGreen.c \ - QRed.c \ - QWhite.c \ - QuCol.c \ - QuCols.c \ - SetCCC.c \ - SetGetCols.c \ - StCol.c \ - StCols.c \ - cmsTrig.c \ - XRGB.c \ - FSWrap.c \ - ICWrap.c \ - IMWrap.c \ - OCWrap.c \ - OMWrap.c \ - lcWrap.c \ - mbWMProps.c \ - utf8WMProps.c \ - mbWrap.c \ - wcWrap.c \ - utf8Wrap.c \ - FilterEv.c \ - RegstFlt.c \ - locking.c \ - LockDis.c \ - x11trans.c \ - ximtrans.c \ - $(XKBSRCS) $(LCSRCS) $(MISCSRCS) - -OBJS3 = \ - Lab.o \ - LabGcC.o \ - LabGcL.o \ - LabGcLC.o \ - LabMnL.o \ - LabMxC.o \ - LabMxL.o \ - LabMxLC.o \ - LabWpAj.o \ - Luv.o \ - LuvGcC.o \ - LuvGcL.o \ - LuvGcLC.o \ - LuvMnL.o \ - LuvMxC.o \ - LuvMxL.o \ - LuvMxLC.o \ - LuvWpAj.o \ - XYZ.o \ - uvY.o \ - xyY.o \ - HVC.o \ - HVCGcC.o \ - HVCGcV.o \ - HVCGcVC.o \ - HVCMnV.o \ - HVCMxC.o \ - HVCMxV.o \ - HVCMxVC.o \ - HVCMxVs.o \ - HVCWpAj.o \ - UNDEFINED.o \ - AddDIC.o \ - AddSF.o \ - cmsAllNCol.o \ - cmsAllCol.o \ - CCC.o \ - cmsCmap.o \ - cmsColNm.o \ - CvColW.o \ - CvCols.o \ - cmsGlobls.o \ - IdOfPr.o \ - cmsInt.o \ - LRGB.o \ - cmsLkCol.o \ - cmsMath.o \ - OfCCC.o \ - PrOfId.o \ - cmsProp.o \ - QBlack.o \ - QBlue.o \ - QGreen.o \ - QRed.o \ - QWhite.o \ - QuCol.o \ - QuCols.o \ - SetCCC.o \ - SetGetCols.o \ - StCol.o \ - StCols.o \ - cmsTrig.o \ - XRGB.o \ - FSWrap.o \ - ICWrap.o \ - IMWrap.o \ - OCWrap.o \ - OMWrap.o \ - lcWrap.o \ - mbWMProps.o \ - utf8WMProps.o \ - mbWrap.o \ - wcWrap.o \ - utf8Wrap.o \ - FilterEv.o \ - RegstFlt.o \ - locking.o \ - LockDis.o \ - x11trans.o \ - ximtrans.o \ - $(XKBOBJS) $(LCOBJS) $(MISCOBJS) - -#if BuildLoadableXlibI18n -LC_DYNDEFINES = -DUSE_DYNAMIC_LC -#endif - -SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c - -SHAREDI18NSTATICSRCS = \ - XDefaultIMIF.c XDefaultOMIF.c - -STATICLCDEPSYMSRCS = - -STATICI18NSTATICSRCS = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRm.c \ - imRmAttr.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrX.c \ - imTransR.c \ - imTrans.c \ - lcEuc.c \ - lcGenConv.c \ - lcJis.c \ - lcSjis.c \ - lcUTF8Load.c \ - omDefault.c \ - omGeneric.c \ - omImText.c \ - omText.c \ - omTextEsc.c \ - omTextExt.c \ - omTextPer.c \ - omXChar.c - -LCSRCS = \ - SetLocale.c \ - imConv.c \ - imKStoUCS.c \ - lcCT.c \ - lcCharSet.c \ - lcConv.c \ - lcDB.c \ - lcDefConv.c \ - lcFile.c \ - lcGeneric.c \ - lcInit.c \ - lcPrTxt.c \ - lcPubWrap.c \ - lcPublic.c \ - lcRM.c \ - lcStd.c \ - lcTxtPr.c \ - lcUtil.c \ - lcUTF8.c - -STATICLCSRCS = \ - $(STATICLCDEPSYMSRCS) \ - $(STATICI18NSTATICSRCS) - -SHAREDLCSRCS = \ - $(SHAREDLCDEPSYMSRCS) \ - $(SHAREDI18NSTATICSRCS) - -SHAREDLCDEPOBJS = XlcDL.o XlcSL.o -SHAREDI18NSTATICOBJS = \ - XDefaultIMIF.o XDefaultOMIF.o -STATICLCDEPOBJS = -STATICI18NSTATICOBJS = \ - imCallbk.o \ - imDefFlt.o \ - imDefIc.o \ - imDefIm.o \ - imDefLkup.o \ - imDispch.o \ - imEvToWire.o \ - imExten.o \ - imImSw.o \ - imInsClbk.o \ - imInt.o \ - imLcFlt.o \ - imLcGIc.o \ - imLcIc.o \ - imLcIm.o \ - imLcLkup.o \ - imLcPrs.o \ - imLcSIc.o \ - imRm.o \ - imRmAttr.o \ - imThaiFlt.o \ - imThaiIc.o \ - imThaiIm.o \ - imTrX.o \ - imTransR.o \ - imTrans.o \ - lcEuc.o \ - lcGenConv.o \ - lcJis.o \ - lcSjis.o \ - lcUTF8Load.o \ - omDefault.o \ - omGeneric.o \ - omImText.o \ - omText.o \ - omTextEsc.o \ - omTextExt.o \ - omTextPer.o \ - omXChar.o - -LCOBJS = \ - SetLocale.o \ - imConv.o \ - imKStoUCS.o \ - lcCT.o \ - lcCharSet.o \ - lcConv.o \ - lcDB.o \ - lcDefConv.o \ - lcFile.o \ - lcGeneric.o \ - lcInit.o \ - lcPrTxt.o \ - lcPubWrap.o \ - lcPublic.o \ - lcRM.o \ - lcStd.o \ - lcTxtPr.o \ - lcUtil.o \ - lcUTF8.o - -STATICLCOBJS = \ - $(STATICLCDEPOBJS) \ - $(STATICI18NSTATICOBJS) - -SHAREDLCOBJS = \ - $(SHAREDLCDEPOBJS) \ - $(SHAREDI18NSTATICOBJS) - -#ifdef OS2Architecture -MISCSRCS = os2Stubs.c -#endif - -#ifdef OS2Architecture -MISCOBJS = os2Stubs.o -#endif - -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -EXTRAUNSHAREDOBJS = $(STATICLCOBJS) - -#if BuildLoadableXlibI18n -EXTRASHAREDOBJS = $(SHAREDLCOBJS) -# else -EXTRASHAREDOBJS = $(STATICLCOBJS) -#endif - -#include <Library.tmpl> - -SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES)) -SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES)) -SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS)) -SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES)) -LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES)) -LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES)) -SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS)) -SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES)) -SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES)) -SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES)) -SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES)) -SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES)) -#if BuildXKBlib -SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES)) -#endif -#if HasKrb5 -SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL)) -#endif -#if BuildLoadableXlibI18n -SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -#endif -#if BuildLoadableXlibXcursor -SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -#endif - -#if InstallXcmsTxt -InstallNonExecFile(Xcms.txt,$(LIBDIR)) -#endif -InstallNonExecFile(XErrorDB,$(LIBDIR)) -InstallNonExecFile(XKeysymDB,$(LIBDIR)) -InstallLintLibrary(X11,$(LINTLIBDIR)) - - -LinkSourceFile(AuDispose.c,$(XAUTHSRC)) -LinkSourceFile(AuGetBest.c,$(XAUTHSRC)) -LinkSourceFile(AuFileName.c,$(XAUTHSRC)) -LinkSourceFile(AuRead.c,$(XAUTHSRC)) -#if HasKrb5 -LinkSourceFile(k5encode.c,$(XAUTHSRC)) -#endif -#if HasXdmAuth -LinkSourceFile(Wrap.h,$(XDMCPLIBSRC)) -LinkSourceFile(Wrap.c,$(XDMCPLIBSRC)) -LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC)) -#endif - -#ifdef QNX4Architecture -LOCAL_LDFLAGS=-F -#endif - -MAKEKEYS = ./makekeys - -#if CrossCompiling -HOST_LDLIBS= -HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \ - $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES) -#else -HOST_LDLIBS=$(LDLIBS) -HOST_CFLAGS=$(CFLAGS) -#endif - -ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c - RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf) - -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS)) - RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h) - $(MV) ks_tables_h $@ - RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h) - -includes:: ks_tables.h - -depend:: ks_tables.h - -clean:: - RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys)) - - -DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS)) - -#if BuildLoadableXlibI18n -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) -MakeLintLibSubdirs($(LINTSUBDIRS)) -MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln) -#endif -#endif - -includes:: XlibConf.h - -#include <Threads.tmpl> - -#if ThreadedProject -#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\ - echo '#define XTHREADS' >> $@ @@\ - echo '#endif' >> $@ -#else -#define XThreadsDefine echo '#undef XTHREADS' >> $@ -#endif - -#if HasThreadSafeAPI -#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\ - echo '#define XUSE_MTSAFE_API' >> $@ @@\ - echo '#endif' >> $@ -#else -#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@ -#endif - -XlibConf.h: - echo '/* Defines needed to use Xlib from non-imake projects */' > $@ - XThreadsDefine - MTSafeAPIDefine diff --git a/nx-X11/lib/X11/MaskEvent.c.NX.original b/nx-X11/lib/X11/MaskEvent.c.NX.original deleted file mode 100644 index c48a960d2..000000000 --- a/nx-X11/lib/X11/MaskEvent.c.NX.original +++ /dev/null @@ -1,84 +0,0 @@ -/* $Xorg: MaskEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -extern long const _Xevent_to_mask[]; -#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask) -#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\ - Button4MotionMask|Button5MotionMask) - -/* - * return the next event in the queue matching one of the events in the mask. - * If no event, flush output, and wait until match succeeds. - * Events earlier in the queue are not discarded. - */ - -int -XMaskEvent (dpy, mask, event) - register Display *dpy; - long mask; /* Selected event mask. */ - register XEvent *event; /* XEvent to be filled in. */ -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if ((qelt->event.type < LASTEvent) && - (_Xevent_to_mask[qelt->event.type] & mask) && - ((qelt->event.type != MotionNotify) || - (mask & AllPointers) || - (mask & AllButtons & qelt->event.xmotion.state))) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} diff --git a/nx-X11/lib/X11/MaskEvent.c.X.original b/nx-X11/lib/X11/MaskEvent.c.X.original deleted file mode 100644 index c5f41b54d..000000000 --- a/nx-X11/lib/X11/MaskEvent.c.X.original +++ /dev/null @@ -1,79 +0,0 @@ -/* $Xorg: MaskEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -extern long const _Xevent_to_mask[]; -#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask) -#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\ - Button4MotionMask|Button5MotionMask) - -/* - * return the next event in the queue matching one of the events in the mask. - * If no event, flush output, and wait until match succeeds. - * Events earlier in the queue are not discarded. - */ - -int -XMaskEvent (dpy, mask, event) - register Display *dpy; - long mask; /* Selected event mask. */ - register XEvent *event; /* XEvent to be filled in. */ -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if ((qelt->event.type < LASTEvent) && - (_Xevent_to_mask[qelt->event.type] & mask) && - ((qelt->event.type != MotionNotify) || - (mask & AllPointers) || - (mask & AllButtons & qelt->event.xmotion.state))) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} diff --git a/nx-X11/lib/X11/OpenDis.c.NX.original b/nx-X11/lib/X11/OpenDis.c.NX.original deleted file mode 100644 index e9d019723..000000000 --- a/nx-X11/lib/X11/OpenDis.c.NX.original +++ /dev/null @@ -1,911 +0,0 @@ -/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/extensions/bigreqstr.h> -#include <stdio.h> -#include "Xintconn.h" - -#ifdef XKB -#include "XKBlib.h" -#endif /* XKB */ - -#ifdef NX_TRANS_SOCKET -extern void *_X11TransSocketProxyConnInfo(XtransConnInfo); -#endif - -#ifdef X_NOT_POSIX -#define Size_t unsigned int -#else -#define Size_t size_t -#endif - -#define bignamelen (sizeof(XBigReqExtensionName) - 1) - -typedef struct { - unsigned long seq; - int opcode; -} _XBigReqState; - -#ifdef XTHREADS -#include "locking.h" -int (*_XInitDisplayLock_fn)(Display *dpy) = NULL; -void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL; - -#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success) -#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d) -#else -#define InitDisplayLock(dis) Success -#define FreeDisplayLock(dis) -#endif /* XTHREADS */ - -static xReq _dummy_request = { - 0, 0, 0 -}; - -static void OutOfMemory(Display *dpy, char *setup); -static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len, - XPointer data); - -/* - * Connects to a server, creates a Display object and returns a pointer to - * the newly created Display back to the caller. - */ -Display * -XOpenDisplay ( - register _Xconst char *display) -{ - register Display *dpy; /* New Display object being created. */ - register int i; - int j, k; /* random iterator indexes */ - char *display_name; /* pointer to display name */ - int endian; /* to determine which endian. */ - xConnClientPrefix client; /* client information */ - xConnSetupPrefix prefix; /* prefix information */ - int vendorlen; /* length of vendor string */ - char *setup = NULL; /* memory allocated at startup */ - char *fullname = NULL; /* expanded name of display */ - int idisplay; /* display number */ - int iscreen; /* screen number */ - int prefixread = 0; /* setup prefix already read? */ - union { - xConnSetup *setup; - char *failure; - char *vendor; - xPixmapFormat *sf; - xWindowRoot *rp; - xDepth *dp; - xVisualType *vp; - } u; /* proto data returned from server */ - long setuplength; /* number of bytes in setup message */ - long usedbytes = 0; /* number of bytes we have processed */ - char *conn_auth_name, *conn_auth_data; - int conn_auth_namelen, conn_auth_datalen; - unsigned long mask; - long int conn_buf_size; - char *xlib_buffer_size; - - bzero((char *) &client, sizeof(client)); - bzero((char *) &prefix, sizeof(prefix)); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXOpenDisplay: Called with display [%s].\n", display); -#endif - /* - * If the display specifier string supplied as an argument to this - * routine is NULL or a pointer to NULL, read the DISPLAY variable. - */ - if (display == NULL || *display == '\0') { - if ((display_name = getenv("DISPLAY")) == NULL) { - /* Oops! No DISPLAY environment variable - error. */ - return(NULL); - } - } - else { - /* Display is non-NULL, copy the pointer */ - display_name = (char *)display; - } -/* - * Set the default error handlers. This allows the global variables to - * default to NULL for use with shared libraries. - */ - if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL); - if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL); - -/* - * Attempt to allocate a display structure. Return NULL if allocation fails. - */ - if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) { - return(NULL); - } - -/* - * Call the Connect routine to get the transport connection object. - * If NULL is returned, the connection failed. The connect routine - * will set fullname to point to the expanded name. - */ - - if ((dpy->trans_conn = _X11TransConnectDisplay ( - display_name, &fullname, &idisplay, - &iscreen, &conn_auth_name, - &conn_auth_namelen, &conn_auth_data, - &conn_auth_datalen)) == NULL) { - Xfree ((char *) dpy); - return(NULL); - } - - dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXOpenDisplay: Connected display with dpy->fd = [%d].\n", dpy->fd); -#endif - /* Initialize as much of the display structure as we can. - * Initialize pointers to NULL so that XFreeDisplayStructure will - * work if we run out of memory before we finish initializing. - */ - dpy->display_name = fullname; - dpy->keysyms = (KeySym *) NULL; - dpy->modifiermap = NULL; - dpy->lock_meaning = NoSymbol; - dpy->keysyms_per_keycode = 0; - dpy->xdefaults = (char *)NULL; - dpy->scratch_length = 0L; - dpy->scratch_buffer = NULL; - dpy->key_bindings = NULL; - dpy->ext_procs = (_XExtension *)NULL; - dpy->ext_data = (XExtData *)NULL; - dpy->ext_number = 0; - dpy->event_vec[X_Error] = _XUnknownWireEvent; - dpy->event_vec[X_Reply] = _XUnknownWireEvent; - dpy->wire_vec[X_Error] = _XUnknownNativeEvent; - dpy->wire_vec[X_Reply] = _XUnknownNativeEvent; - for (i = KeyPress; i < LASTEvent; i++) { - dpy->event_vec[i] = _XWireToEvent; - dpy->wire_vec[i] = NULL; - } - for (i = LASTEvent; i < 128; i++) { - dpy->event_vec[i] = _XUnknownWireEvent; - dpy->wire_vec[i] = _XUnknownNativeEvent; - } - dpy->resource_id = 0; - dpy->db = (struct _XrmHashBucketRec *)NULL; - dpy->cursor_font = None; - dpy->flags = 0; - dpy->async_handlers = NULL; - dpy->screens = NULL; - dpy->vendor = NULL; - dpy->buffer = NULL; - dpy->atoms = NULL; - dpy->error_vec = NULL; - dpy->context_db = NULL; - dpy->free_funcs = NULL; - dpy->pixmap_format = NULL; - dpy->cms.clientCmaps = NULL; - dpy->cms.defaultCCCs = NULL; - dpy->cms.perVisualIntensityMaps = NULL; - dpy->im_filters = NULL; - dpy->bigreq_size = 0; - dpy->lock = NULL; - dpy->lock_fns = NULL; - dpy->qfree = NULL; - dpy->next_event_serial_num = 1; - dpy->im_fd_info = NULL; - dpy->im_fd_length = 0; - dpy->conn_watchers = NULL; - dpy->watcher_count = 0; - dpy->filedes = NULL; - dpy->flushes = NULL; - dpy->xcmisc_opcode = 0; - dpy->xkb_info = NULL; - -/* - * Setup other information in this display structure. - */ - dpy->vnumber = X_PROTOCOL; - dpy->resource_alloc = _XAllocID; - dpy->idlist_alloc = _XAllocIDs; - dpy->synchandler = NULL; - dpy->savedsynchandler = NULL; - dpy->request = 0; - dpy->last_request_read = 0; - dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */ - dpy->last_req = (char *)&_dummy_request; - - /* Initialize the display lock */ - if (InitDisplayLock(dpy) != 0) { - OutOfMemory (dpy, setup); - return(NULL); - } - - if (!_XPollfdCacheInit(dpy)) { - OutOfMemory (dpy, setup); - return(NULL); - } - - /* Set up the output buffers. */ -#ifndef XLIBDEFAULTBUFSIZE -#define XLIBDEFAULTBUFSIZE 16384 /* 16k */ -#endif -#ifndef XLIBMINBUFSIZE -#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */ -#endif - if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == NULL) - conn_buf_size = XLIBDEFAULTBUFSIZE; - else - conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10); - if (conn_buf_size < XLIBMINBUFSIZE) - conn_buf_size = XLIBMINBUFSIZE; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf (stderr, "Xlib: Running with XLIBBUFFERSIZE [%d] XLIBMINBUFSIZE [%d] " - "buffer size [%ld].\n", XLIBDEFAULTBUFSIZE, XLIBMINBUFSIZE, conn_buf_size); -#endif - - if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - dpy->bufmax = dpy->buffer + conn_buf_size; - - /* Set up the input event queue and input event queue parameters. */ - dpy->head = dpy->tail = NULL; - dpy->qlen = 0; - - /* Set up free-function record */ - if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, - sizeof(_XFreeFuncRec))) - == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - -/* - * The xConnClientPrefix describes the initial connection setup information - * and is followed by the authorization information. Sites that are interested - * in security are strongly encouraged to use an authentication and - * authorization system such as Kerberos. - */ - endian = 1; - if (*(char *) &endian) - client.byteOrder = '\154'; /* 'l' */ - else - client.byteOrder = '\102'; /* 'B' */ - client.majorVersion = X_PROTOCOL; - client.minorVersion = X_PROTOCOL_REVISION; - client.nbytesAuthProto = conn_auth_namelen; - client.nbytesAuthString = conn_auth_datalen; - prefixread = _XSendClientPrefix(dpy, &client, - conn_auth_name, conn_auth_data, - &prefix); - if (prefixread < 0) - { - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - if (conn_auth_name) Xfree(conn_auth_name); - if (conn_auth_data) Xfree(conn_auth_data); -/* - * Now see if connection was accepted... - */ - /* these internal functions expect the display to be locked */ - LockDisplay(dpy); - - if (prefixread == 0) - _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix)); - - /* an Authenticate reply we weren't expecting? */ - if (prefix.success != xTrue && prefix.success != xFalse) { - fprintf (stderr, - "Xlib: unexpected connection setup reply from server, type %d.\r\n", - prefix.success); - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - - if (prefix.majorVersion != X_PROTOCOL) { - /* XXX - printing messages marks a bad programming interface */ -#ifdef NX_TRANS_SOCKET - if (_X11TransSocketProxyConnInfo(dpy->trans_conn) == NULL) { - fprintf (stderr, "Xlib: client uses different protocol version (%d) " - "than server (%d)!\r\n", X_PROTOCOL, prefix.majorVersion); - } -#else - fprintf (stderr, - "Xlib: client uses different protocol version (%d) than server (%d)!\r\n", - X_PROTOCOL, prefix.majorVersion); -#endif - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - - setuplength = prefix.length << 2; - if ( (u.setup = (xConnSetup *) - (setup = Xmalloc ((unsigned) setuplength))) == NULL) { - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - _XRead (dpy, (char *)u.setup, setuplength); - -/* - * If the connection was not accepted by the server due to problems, - * give error message to the user.... - */ - if (prefix.success != xTrue) { - /* XXX - printing messages marks a bad programming interface */ - fprintf (stderr, - "Xlib: connection to \"%s\" refused by server\r\nXlib: ", - fullname); - - if (prefix.lengthReason > setuplength) { - fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n"); - }else{ - (void) fwrite (u.failure, (Size_t)sizeof(char), - (Size_t)prefix.lengthReason, stderr); - (void) fwrite ("\r\n", sizeof(char), 2, stderr); - } - - OutOfMemory(dpy, setup); - return (NULL); - } - -/* - * Check if the reply was long enough to get any information out of it. - */ - usedbytes = sz_xConnSetup; - if (setuplength < usedbytes ) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory(dpy, setup); - return (NULL); - } - -/* - * We succeeded at authorization, so let us move the data into - * the display structure. - */ - dpy->proto_major_version= prefix.majorVersion; - dpy->proto_minor_version= prefix.minorVersion; - dpy->release = u.setup->release; - dpy->resource_base = u.setup->ridBase; - dpy->resource_mask = u.setup->ridMask; - dpy->min_keycode = u.setup->minKeyCode; - dpy->max_keycode = u.setup->maxKeyCode; - dpy->motion_buffer = u.setup->motionBufferSize; - dpy->nformats = u.setup->numFormats; - dpy->nscreens = u.setup->numRoots; - dpy->byte_order = u.setup->imageByteOrder; - dpy->bitmap_unit = u.setup->bitmapScanlineUnit; - dpy->bitmap_pad = u.setup->bitmapScanlinePad; - dpy->bitmap_bit_order = u.setup->bitmapBitOrder; - dpy->max_request_size = u.setup->maxRequestSize; - mask = dpy->resource_mask; - dpy->resource_shift = 0; - if (!mask) - { - fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n", - fullname); - OutOfMemory(dpy, setup); - return (NULL); - } - - while (!(mask & 1)) { - dpy->resource_shift++; - mask = mask >> 1; - } - dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5; -/* - * now extract the vendor string... String must be null terminated, - * padded to multiple of 4 bytes. - */ - /* Check for a sane vendor string length */ - if (u.setup->nbytesVendor > 256) { - OutOfMemory(dpy, setup); - return (NULL); - } - - dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1)); - if (dpy->vendor == NULL) { - OutOfMemory(dpy, setup); - return (NULL); - } - vendorlen = u.setup->nbytesVendor; - -/* - * validate setup length - */ - usedbytes += (vendorlen + 3) & ~3; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory(dpy, setup); - return (NULL); - } - - u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup); - (void) strncpy(dpy->vendor, u.vendor, vendorlen); - dpy->vendor[vendorlen] = '\0'; - vendorlen = (vendorlen + 3) & ~3; /* round up */ - - - memmove (setup, u.vendor + vendorlen, - (int) setuplength - sz_xConnSetup - vendorlen); - u.vendor = setup; -/* - * Now iterate down setup information..... - */ - dpy->pixmap_format = - (ScreenFormat *)Xmalloc( - (unsigned) (dpy->nformats *sizeof(ScreenFormat))); - if (dpy->pixmap_format == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } -/* - * First decode the Z axis Screen format information. - */ - usedbytes += dpy->nformats * sz_xPixmapFormat; - - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - for (i = 0; i < dpy->nformats; i++) { - register ScreenFormat *fmt = &dpy->pixmap_format[i]; - fmt->depth = u.sf->depth; - fmt->bits_per_pixel = u.sf->bitsPerPixel; - fmt->scanline_pad = u.sf->scanLinePad; - fmt->ext_data = NULL; - u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat); - } - -/* - * next the Screen structures. - */ - dpy->screens = - (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen)); - if (dpy->screens == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - -/* - * Now go deal with each screen structure. - */ - for (i = 0; i < dpy->nscreens; i++) { - register Screen *sp = &dpy->screens[i]; - VisualID root_visualID; - - usedbytes += sz_xWindowRoot; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - root_visualID = u.rp->rootVisualID; - sp->display = dpy; - sp->root = u.rp->windowId; - sp->cmap = u.rp->defaultColormap; - sp->white_pixel = u.rp->whitePixel; - sp->black_pixel = u.rp->blackPixel; - sp->root_input_mask = u.rp->currentInputMask; - sp->width = u.rp->pixWidth; - sp->height = u.rp->pixHeight; - sp->mwidth = u.rp->mmWidth; - sp->mheight = u.rp->mmHeight; - sp->min_maps = u.rp->minInstalledMaps; - sp->max_maps = u.rp->maxInstalledMaps; - sp->backing_store= u.rp->backingStore; - sp->save_unders = u.rp->saveUnders; - sp->root_depth = u.rp->rootDepth; - sp->ndepths = u.rp->nDepths; - sp->ext_data = NULL; - u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot); -/* - * lets set up the depth structures. - */ - sp->depths = (Depth *)Xmalloc( - (unsigned)sp->ndepths*sizeof(Depth)); - if (sp->depths == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - /* - * for all depths on this screen. - */ - for (j = 0; j < sp->ndepths; j++) { - Depth *dp = &sp->depths[j]; - - usedbytes += sz_xDepth; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - dp->depth = u.dp->depth; - dp->nvisuals = u.dp->nVisuals; - u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); - if (dp->nvisuals > 0) { - dp->visuals = - (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual)); - if (dp->visuals == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - for (k = 0; k < dp->nvisuals; k++) { - register Visual *vp = &dp->visuals[k]; - - usedbytes += sz_xVisualType; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - vp->visualid = u.vp->visualID; - vp->class = u.vp->class; - vp->bits_per_rgb= u.vp->bitsPerRGB; - vp->map_entries = u.vp->colormapEntries; - vp->red_mask = u.vp->redMask; - vp->green_mask = u.vp->greenMask; - vp->blue_mask = u.vp->blueMask; - vp->ext_data = NULL; - u.vp = (xVisualType *) (((char *) u.vp) + - sz_xVisualType); - } - if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS")) - { - Xfree (dp->visuals); - dp->visuals = NULL; - dp->nvisuals = 0; - } - } else { - dp->visuals = (Visual *) NULL; - } - } - sp->root_visual = _XVIDtoVisual(dpy, root_visualID); - } - - if(usedbytes != setuplength){ - /* Sanity check, shouldn't happen. */ - fprintf(stderr, "Xlib: Did not parse entire setup message: " - "parsed: %ld, message: %ld\n", - usedbytes, setuplength); - OutOfMemory(dpy, setup); - return(NULL); - } - -/* - * Now start talking to the server to setup all other information... - */ - - Xfree (setup); /* all finished with setup information */ - -/* - * Make sure default screen is legal. - */ - if (iscreen >= dpy->nscreens) { - OutOfMemory(dpy, (char *) NULL); - return(NULL); - } - -/* - * finished calling internal routines, now unlock for external routines - */ - UnlockDisplay(dpy); - -/* - * Set up other stuff clients are always going to use. - */ - for (i = 0; i < dpy->nscreens; i++) { - register Screen *sp = &dpy->screens[i]; - XGCValues values; - values.foreground = sp->black_pixel; - values.background = sp->white_pixel; - if ((sp->default_gc = XCreateGC (dpy, sp->root, - GCForeground|GCBackground, - &values)) == NULL) { - OutOfMemory(dpy, (char *) NULL); - return (NULL); - } - } -/* - * call into synchronization routine so that all programs can be - * forced synchronous - */ - (void) XSynchronize(dpy, _Xdebug); - -/* - * get availability of large requests, and - * get the resource manager database off the root window. - */ - LockDisplay(dpy); - { - _XAsyncHandler async; - _XBigReqState async_state; - xQueryExtensionReq *qreq; - xGetPropertyReply reply; - xGetPropertyReq *req; - xBigReqEnableReq *breq; - xBigReqEnableReply brep; - - GetReq(QueryExtension, qreq); - async_state.seq = dpy->request; - async_state.opcode = 0; - async.next = dpy->async_handlers; - async.handler = _XBigReqHandler; - async.data = (XPointer)&async_state; - dpy->async_handlers = &async; - qreq->nbytes = bignamelen; - qreq->length += (bignamelen+3)>>2; - Data(dpy, XBigReqExtensionName, bignamelen); - - GetReq (GetProperty, req); - req->window = RootWindow(dpy, 0); - req->property = XA_RESOURCE_MANAGER; - req->type = XA_STRING; - req->delete = False; - req->longOffset = 0; - req->longLength = 100000000L; - - if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) { - if (reply.format == 8 && reply.propertyType == XA_STRING && - (reply.nItems + 1 > 0) && - (reply.nItems <= req->longLength * 4) && - (dpy->xdefaults = Xmalloc (reply.nItems + 1))) { - _XReadPad (dpy, dpy->xdefaults, reply.nItems); - dpy->xdefaults[reply.nItems] = '\0'; - } - else if (reply.propertyType != None) - _XEatData(dpy, reply.nItems * (reply.format >> 3)); - } - DeqAsyncHandler(dpy, &async); - if (async_state.opcode) { - GetReq(BigReqEnable, breq); - breq->reqType = async_state.opcode; - breq->brReqType = X_BigReqEnable; - if (_XReply(dpy, (xReply *)&brep, 0, xFalse)) - dpy->bigreq_size = brep.max_request_size; - } - } - UnlockDisplay(dpy); - -#ifdef MOTIFBC - { - extern Display *_XHeadOfDisplayList; - _XHeadOfDisplayList = dpy; - } -#endif -#ifdef XKB - XkbUseExtension(dpy,NULL,NULL); -#endif -/* - * and return successfully - */ -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "XOpenDisplay: Returning display at [%p].\n", dpy); -#endif - return(dpy); -} - -static Bool -_XBigReqHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - _XBigReqState *state; - xQueryExtensionReply replbuf; - xQueryExtensionReply *repl; - - state = (_XBigReqState *)data; - if (dpy->last_request_read != state->seq) - return False; - if (rep->generic.type == X_Error) - return True; - repl = (xQueryExtensionReply *) - _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, - (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2, - True); - if (repl->present) - state->opcode = repl->major_opcode; - return True; -} - - -/* XFreeDisplayStructure frees all the storage associated with a - * Display. It is used by XOpenDisplay if it runs out of memory, - * and also by XCloseDisplay. It needs to check whether all pointers - * are non-NULL before dereferencing them, since it may be called - * by XOpenDisplay before the Display structure is fully formed. - * XOpenDisplay must be sure to initialize all the pointers to NULL - * before the first possible call on this. - */ - -void _XFreeDisplayStructure(dpy) - register Display *dpy; -{ - while (dpy->ext_procs) { - _XExtension *ext = dpy->ext_procs; - dpy->ext_procs = ext->next; - if (ext->name) - Xfree (ext->name); - Xfree ((char *)ext); - } - if (dpy->im_filters) - (*dpy->free_funcs->im_filters)(dpy); - if (dpy->cms.clientCmaps) - (*dpy->free_funcs->clientCmaps)(dpy); - if (dpy->cms.defaultCCCs) - (*dpy->free_funcs->defaultCCCs)(dpy); - if (dpy->cms.perVisualIntensityMaps) - (*dpy->free_funcs->intensityMaps)(dpy); - if (dpy->atoms) - (*dpy->free_funcs->atoms)(dpy); - if (dpy->modifiermap) - (*dpy->free_funcs->modifiermap)(dpy->modifiermap); - if (dpy->key_bindings) - (*dpy->free_funcs->key_bindings)(dpy); - if (dpy->context_db) - (*dpy->free_funcs->context_db)(dpy); - if (dpy->xkb_info) - (*dpy->free_funcs->xkb)(dpy); - - /* if RM database was allocated by XGetDefault() free it */ - if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB)) - XrmDestroyDatabase(dpy->db); - - if (dpy->screens) { - register int i; - - for (i = 0; i < dpy->nscreens; i++) { - Screen *sp = &dpy->screens[i]; - - if (sp->depths) { - register int j; - - for (j = 0; j < sp->ndepths; j++) { - Depth *dp = &sp->depths[j]; - - if (dp->visuals) { - register int k; - - for (k = 0; k < dp->nvisuals; k++) - _XFreeExtData (dp->visuals[k].ext_data); - Xfree ((char *) dp->visuals); - } - } - - Xfree ((char *) sp->depths); - } - - _XFreeExtData (sp->ext_data); - } - - Xfree ((char *)dpy->screens); - } - - if (dpy->pixmap_format) { - register int i; - - for (i = 0; i < dpy->nformats; i++) - _XFreeExtData (dpy->pixmap_format[i].ext_data); - Xfree ((char *)dpy->pixmap_format); - } - - if (dpy->display_name) - Xfree (dpy->display_name); - if (dpy->vendor) - Xfree (dpy->vendor); - - if (dpy->buffer) - Xfree (dpy->buffer); - if (dpy->keysyms) - Xfree ((char *) dpy->keysyms); - if (dpy->xdefaults) - Xfree (dpy->xdefaults); - if (dpy->error_vec) - Xfree ((char *)dpy->error_vec); - - _XFreeExtData (dpy->ext_data); - if (dpy->free_funcs) - Xfree ((char *)dpy->free_funcs); - if (dpy->scratch_buffer) - Xfree (dpy->scratch_buffer); - FreeDisplayLock(dpy); - - if (dpy->qfree) { - register _XQEvent *qelt = dpy->qfree; - - while (qelt) { - register _XQEvent *qnxt = qelt->next; - Xfree ((char *) qelt); - qelt = qnxt; - } - } - while (dpy->im_fd_info) { - struct _XConnectionInfo *conni = dpy->im_fd_info; - dpy->im_fd_info = conni->next; - if (conni->watch_data) - Xfree (conni->watch_data); - Xfree (conni); - } - if (dpy->conn_watchers) { - struct _XConnWatchInfo *watcher = dpy->conn_watchers; - dpy->conn_watchers = watcher->next; - Xfree (watcher); - } - if (dpy->filedes) - Xfree (dpy->filedes); - - Xfree ((char *)dpy); -} - -/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL - after this returns. */ - -static void OutOfMemory (dpy, setup) - Display *dpy; - char *setup; -{ - _XDisconnectDisplay (dpy->trans_conn); - _XFreeDisplayStructure (dpy); - if (setup) Xfree (setup); -} diff --git a/nx-X11/lib/X11/OpenDis.c.X.original b/nx-X11/lib/X11/OpenDis.c.X.original deleted file mode 100644 index 121291b5f..000000000 --- a/nx-X11/lib/X11/OpenDis.c.X.original +++ /dev/null @@ -1,869 +0,0 @@ -/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/extensions/bigreqstr.h> -#include <stdio.h> -#include "Xintconn.h" - -#ifdef XKB -#include "XKBlib.h" -#endif /* XKB */ - -#ifdef X_NOT_POSIX -#define Size_t unsigned int -#else -#define Size_t size_t -#endif - -#define bignamelen (sizeof(XBigReqExtensionName) - 1) - -typedef struct { - unsigned long seq; - int opcode; -} _XBigReqState; - -#ifdef XTHREADS -#include "locking.h" -int (*_XInitDisplayLock_fn)(Display *dpy) = NULL; -void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL; - -#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success) -#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d) -#else -#define InitDisplayLock(dis) Success -#define FreeDisplayLock(dis) -#endif /* XTHREADS */ - -static xReq _dummy_request = { - 0, 0, 0 -}; - -static void OutOfMemory(Display *dpy, char *setup); -static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len, - XPointer data); - -/* - * Connects to a server, creates a Display object and returns a pointer to - * the newly created Display back to the caller. - */ -Display * -XOpenDisplay ( - register _Xconst char *display) -{ - register Display *dpy; /* New Display object being created. */ - register int i; - int j, k; /* random iterator indexes */ - char *display_name; /* pointer to display name */ - int endian; /* to determine which endian. */ - xConnClientPrefix client; /* client information */ - xConnSetupPrefix prefix; /* prefix information */ - int vendorlen; /* length of vendor string */ - char *setup = NULL; /* memory allocated at startup */ - char *fullname = NULL; /* expanded name of display */ - int idisplay; /* display number */ - int iscreen; /* screen number */ - int prefixread = 0; /* setup prefix already read? */ - union { - xConnSetup *setup; - char *failure; - char *vendor; - xPixmapFormat *sf; - xWindowRoot *rp; - xDepth *dp; - xVisualType *vp; - } u; /* proto data returned from server */ - long setuplength; /* number of bytes in setup message */ - long usedbytes = 0; /* number of bytes we have processed */ - char *conn_auth_name, *conn_auth_data; - int conn_auth_namelen, conn_auth_datalen; - unsigned long mask; - long int conn_buf_size; - char *xlib_buffer_size; - - bzero((char *) &client, sizeof(client)); - bzero((char *) &prefix, sizeof(prefix)); - - /* - * If the display specifier string supplied as an argument to this - * routine is NULL or a pointer to NULL, read the DISPLAY variable. - */ - if (display == NULL || *display == '\0') { - if ((display_name = getenv("DISPLAY")) == NULL) { - /* Oops! No DISPLAY environment variable - error. */ - return(NULL); - } - } - else { - /* Display is non-NULL, copy the pointer */ - display_name = (char *)display; - } -/* - * Set the default error handlers. This allows the global variables to - * default to NULL for use with shared libraries. - */ - if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL); - if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL); - -/* - * Attempt to allocate a display structure. Return NULL if allocation fails. - */ - if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) { - return(NULL); - } - -/* - * Call the Connect routine to get the transport connection object. - * If NULL is returned, the connection failed. The connect routine - * will set fullname to point to the expanded name. - */ - - if ((dpy->trans_conn = _X11TransConnectDisplay ( - display_name, &fullname, &idisplay, - &iscreen, &conn_auth_name, - &conn_auth_namelen, &conn_auth_data, - &conn_auth_datalen)) == NULL) { - Xfree ((char *) dpy); - return(NULL); - } - - dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn); - - /* Initialize as much of the display structure as we can. - * Initialize pointers to NULL so that XFreeDisplayStructure will - * work if we run out of memory before we finish initializing. - */ - dpy->display_name = fullname; - dpy->keysyms = (KeySym *) NULL; - dpy->modifiermap = NULL; - dpy->lock_meaning = NoSymbol; - dpy->keysyms_per_keycode = 0; - dpy->xdefaults = (char *)NULL; - dpy->scratch_length = 0L; - dpy->scratch_buffer = NULL; - dpy->key_bindings = NULL; - dpy->ext_procs = (_XExtension *)NULL; - dpy->ext_data = (XExtData *)NULL; - dpy->ext_number = 0; - dpy->event_vec[X_Error] = _XUnknownWireEvent; - dpy->event_vec[X_Reply] = _XUnknownWireEvent; - dpy->wire_vec[X_Error] = _XUnknownNativeEvent; - dpy->wire_vec[X_Reply] = _XUnknownNativeEvent; - for (i = KeyPress; i < LASTEvent; i++) { - dpy->event_vec[i] = _XWireToEvent; - dpy->wire_vec[i] = NULL; - } - for (i = LASTEvent; i < 128; i++) { - dpy->event_vec[i] = _XUnknownWireEvent; - dpy->wire_vec[i] = _XUnknownNativeEvent; - } - dpy->resource_id = 0; - dpy->db = (struct _XrmHashBucketRec *)NULL; - dpy->cursor_font = None; - dpy->flags = 0; - dpy->async_handlers = NULL; - dpy->screens = NULL; - dpy->vendor = NULL; - dpy->buffer = NULL; - dpy->atoms = NULL; - dpy->error_vec = NULL; - dpy->context_db = NULL; - dpy->free_funcs = NULL; - dpy->pixmap_format = NULL; - dpy->cms.clientCmaps = NULL; - dpy->cms.defaultCCCs = NULL; - dpy->cms.perVisualIntensityMaps = NULL; - dpy->im_filters = NULL; - dpy->bigreq_size = 0; - dpy->lock = NULL; - dpy->lock_fns = NULL; - dpy->qfree = NULL; - dpy->next_event_serial_num = 1; - dpy->im_fd_info = NULL; - dpy->im_fd_length = 0; - dpy->conn_watchers = NULL; - dpy->watcher_count = 0; - dpy->filedes = NULL; - dpy->flushes = NULL; - dpy->xcmisc_opcode = 0; - dpy->xkb_info = NULL; - -/* - * Setup other information in this display structure. - */ - dpy->vnumber = X_PROTOCOL; - dpy->resource_alloc = _XAllocID; - dpy->idlist_alloc = _XAllocIDs; - dpy->synchandler = NULL; - dpy->savedsynchandler = NULL; - dpy->request = 0; - dpy->last_request_read = 0; - dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */ - dpy->last_req = (char *)&_dummy_request; - - /* Initialize the display lock */ - if (InitDisplayLock(dpy) != 0) { - OutOfMemory (dpy, setup); - return(NULL); - } - - if (!_XPollfdCacheInit(dpy)) { - OutOfMemory (dpy, setup); - return(NULL); - } - - /* Set up the output buffers. */ -#ifndef XLIBDEFAULTBUFSIZE -#define XLIBDEFAULTBUFSIZE 16384 /* 16k */ -#endif -#ifndef XLIBMINBUFSIZE -#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */ -#endif - if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == NULL) - conn_buf_size = XLIBDEFAULTBUFSIZE; - else - conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10); - if (conn_buf_size < XLIBMINBUFSIZE) - conn_buf_size = XLIBMINBUFSIZE; - - if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - dpy->bufmax = dpy->buffer + conn_buf_size; - - /* Set up the input event queue and input event queue parameters. */ - dpy->head = dpy->tail = NULL; - dpy->qlen = 0; - - /* Set up free-function record */ - if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1, - sizeof(_XFreeFuncRec))) - == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - -/* - * The xConnClientPrefix describes the initial connection setup information - * and is followed by the authorization information. Sites that are interested - * in security are strongly encouraged to use an authentication and - * authorization system such as Kerberos. - */ - endian = 1; - if (*(char *) &endian) - client.byteOrder = '\154'; /* 'l' */ - else - client.byteOrder = '\102'; /* 'B' */ - client.majorVersion = X_PROTOCOL; - client.minorVersion = X_PROTOCOL_REVISION; - client.nbytesAuthProto = conn_auth_namelen; - client.nbytesAuthString = conn_auth_datalen; - prefixread = _XSendClientPrefix(dpy, &client, - conn_auth_name, conn_auth_data, - &prefix); - if (prefixread < 0) - { - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - if (conn_auth_name) Xfree(conn_auth_name); - if (conn_auth_data) Xfree(conn_auth_data); -/* - * Now see if connection was accepted... - */ - /* these internal functions expect the display to be locked */ - LockDisplay(dpy); - - if (prefixread == 0) - _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix)); - - /* an Authenticate reply we weren't expecting? */ - if (prefix.success != xTrue && prefix.success != xFalse) { - fprintf (stderr, - "Xlib: unexpected connection setup reply from server, type %d.\r\n", - prefix.success); - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - - if (prefix.majorVersion != X_PROTOCOL) { - /* XXX - printing messages marks a bad programming interface */ - fprintf (stderr, - "Xlib: client uses different protocol version (%d) than server (%d)!\r\n", - X_PROTOCOL, prefix.majorVersion); - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - - setuplength = prefix.length << 2; - if ( (u.setup = (xConnSetup *) - (setup = Xmalloc ((unsigned) setuplength))) == NULL) { - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - _XRead (dpy, (char *)u.setup, setuplength); - -/* - * If the connection was not accepted by the server due to problems, - * give error message to the user.... - */ - if (prefix.success != xTrue) { - /* XXX - printing messages marks a bad programming interface */ - fprintf (stderr, - "Xlib: connection to \"%s\" refused by server\r\nXlib: ", - fullname); - - if (prefix.lengthReason > setuplength) { - fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n"); - }else{ - (void) fwrite (u.failure, (Size_t)sizeof(char), - (Size_t)prefix.lengthReason, stderr); - (void) fwrite ("\r\n", sizeof(char), 2, stderr); - } - - OutOfMemory(dpy, setup); - return (NULL); - } - -/* - * Check if the reply was long enough to get any information out of it. - */ - usedbytes = sz_xConnSetup; - if (setuplength < usedbytes ) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory(dpy, setup); - return (NULL); - } - -/* - * We succeeded at authorization, so let us move the data into - * the display structure. - */ - dpy->proto_major_version= prefix.majorVersion; - dpy->proto_minor_version= prefix.minorVersion; - dpy->release = u.setup->release; - dpy->resource_base = u.setup->ridBase; - dpy->resource_mask = u.setup->ridMask; - dpy->min_keycode = u.setup->minKeyCode; - dpy->max_keycode = u.setup->maxKeyCode; - dpy->motion_buffer = u.setup->motionBufferSize; - dpy->nformats = u.setup->numFormats; - dpy->nscreens = u.setup->numRoots; - dpy->byte_order = u.setup->imageByteOrder; - dpy->bitmap_unit = u.setup->bitmapScanlineUnit; - dpy->bitmap_pad = u.setup->bitmapScanlinePad; - dpy->bitmap_bit_order = u.setup->bitmapBitOrder; - dpy->max_request_size = u.setup->maxRequestSize; - mask = dpy->resource_mask; - dpy->resource_shift = 0; - if (!mask) - { - fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n", - fullname); - OutOfMemory(dpy, setup); - return (NULL); - } - - while (!(mask & 1)) { - dpy->resource_shift++; - mask = mask >> 1; - } - dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5; -/* - * now extract the vendor string... String must be null terminated, - * padded to multiple of 4 bytes. - */ - /* Check for a sane vendor string length */ - if (u.setup->nbytesVendor > 256) { - OutOfMemory(dpy, setup); - return (NULL); - } - - dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1)); - if (dpy->vendor == NULL) { - OutOfMemory(dpy, setup); - return (NULL); - } - vendorlen = u.setup->nbytesVendor; - -/* - * validate setup length - */ - usedbytes += (vendorlen + 3) & ~3; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory(dpy, setup); - return (NULL); - } - - u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup); - (void) strncpy(dpy->vendor, u.vendor, vendorlen); - dpy->vendor[vendorlen] = '\0'; - vendorlen = (vendorlen + 3) & ~3; /* round up */ - - - memmove (setup, u.vendor + vendorlen, - (int) setuplength - sz_xConnSetup - vendorlen); - u.vendor = setup; -/* - * Now iterate down setup information..... - */ - dpy->pixmap_format = - (ScreenFormat *)Xmalloc( - (unsigned) (dpy->nformats *sizeof(ScreenFormat))); - if (dpy->pixmap_format == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } -/* - * First decode the Z axis Screen format information. - */ - usedbytes += dpy->nformats * sz_xPixmapFormat; - - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - for (i = 0; i < dpy->nformats; i++) { - register ScreenFormat *fmt = &dpy->pixmap_format[i]; - fmt->depth = u.sf->depth; - fmt->bits_per_pixel = u.sf->bitsPerPixel; - fmt->scanline_pad = u.sf->scanLinePad; - fmt->ext_data = NULL; - u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat); - } - -/* - * next the Screen structures. - */ - dpy->screens = - (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen)); - if (dpy->screens == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - -/* - * Now go deal with each screen structure. - */ - for (i = 0; i < dpy->nscreens; i++) { - register Screen *sp = &dpy->screens[i]; - VisualID root_visualID; - - usedbytes += sz_xWindowRoot; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - root_visualID = u.rp->rootVisualID; - sp->display = dpy; - sp->root = u.rp->windowId; - sp->cmap = u.rp->defaultColormap; - sp->white_pixel = u.rp->whitePixel; - sp->black_pixel = u.rp->blackPixel; - sp->root_input_mask = u.rp->currentInputMask; - sp->width = u.rp->pixWidth; - sp->height = u.rp->pixHeight; - sp->mwidth = u.rp->mmWidth; - sp->mheight = u.rp->mmHeight; - sp->min_maps = u.rp->minInstalledMaps; - sp->max_maps = u.rp->maxInstalledMaps; - sp->backing_store= u.rp->backingStore; - sp->save_unders = u.rp->saveUnders; - sp->root_depth = u.rp->rootDepth; - sp->ndepths = u.rp->nDepths; - sp->ext_data = NULL; - u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot); -/* - * lets set up the depth structures. - */ - sp->depths = (Depth *)Xmalloc( - (unsigned)sp->ndepths*sizeof(Depth)); - if (sp->depths == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - /* - * for all depths on this screen. - */ - for (j = 0; j < sp->ndepths; j++) { - Depth *dp = &sp->depths[j]; - - usedbytes += sz_xDepth; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - dp->depth = u.dp->depth; - dp->nvisuals = u.dp->nVisuals; - u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth); - if (dp->nvisuals > 0) { - dp->visuals = - (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual)); - if (dp->visuals == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - for (k = 0; k < dp->nvisuals; k++) { - register Visual *vp = &dp->visuals[k]; - - usedbytes += sz_xVisualType; - if (setuplength < usedbytes) { - fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength); - OutOfMemory (dpy, setup); - return(NULL); - } - - vp->visualid = u.vp->visualID; - vp->class = u.vp->class; - vp->bits_per_rgb= u.vp->bitsPerRGB; - vp->map_entries = u.vp->colormapEntries; - vp->red_mask = u.vp->redMask; - vp->green_mask = u.vp->greenMask; - vp->blue_mask = u.vp->blueMask; - vp->ext_data = NULL; - u.vp = (xVisualType *) (((char *) u.vp) + - sz_xVisualType); - } - if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS")) - { - Xfree (dp->visuals); - dp->visuals = NULL; - dp->nvisuals = 0; - } - } else { - dp->visuals = (Visual *) NULL; - } - } - sp->root_visual = _XVIDtoVisual(dpy, root_visualID); - } - - if(usedbytes != setuplength){ - /* Sanity check, shouldn't happen. */ - fprintf(stderr, "Xlib: Did not parse entire setup message: " - "parsed: %ld, message: %ld\n", - usedbytes, setuplength); - OutOfMemory(dpy, setup); - return(NULL); - } - -/* - * Now start talking to the server to setup all other information... - */ - - Xfree (setup); /* all finished with setup information */ - -/* - * Make sure default screen is legal. - */ - if (iscreen >= dpy->nscreens) { - OutOfMemory(dpy, (char *) NULL); - return(NULL); - } - -/* - * finished calling internal routines, now unlock for external routines - */ - UnlockDisplay(dpy); - -/* - * Set up other stuff clients are always going to use. - */ - for (i = 0; i < dpy->nscreens; i++) { - register Screen *sp = &dpy->screens[i]; - XGCValues values; - values.foreground = sp->black_pixel; - values.background = sp->white_pixel; - if ((sp->default_gc = XCreateGC (dpy, sp->root, - GCForeground|GCBackground, - &values)) == NULL) { - OutOfMemory(dpy, (char *) NULL); - return (NULL); - } - } -/* - * call into synchronization routine so that all programs can be - * forced synchronous - */ - (void) XSynchronize(dpy, _Xdebug); - -/* - * get availability of large requests, and - * get the resource manager database off the root window. - */ - LockDisplay(dpy); - { - _XAsyncHandler async; - _XBigReqState async_state; - xQueryExtensionReq *qreq; - xGetPropertyReply reply; - xGetPropertyReq *req; - xBigReqEnableReq *breq; - xBigReqEnableReply brep; - - GetReq(QueryExtension, qreq); - async_state.seq = dpy->request; - async_state.opcode = 0; - async.next = dpy->async_handlers; - async.handler = _XBigReqHandler; - async.data = (XPointer)&async_state; - dpy->async_handlers = &async; - qreq->nbytes = bignamelen; - qreq->length += (bignamelen+3)>>2; - Data(dpy, XBigReqExtensionName, bignamelen); - - GetReq (GetProperty, req); - req->window = RootWindow(dpy, 0); - req->property = XA_RESOURCE_MANAGER; - req->type = XA_STRING; - req->delete = False; - req->longOffset = 0; - req->longLength = 100000000L; - - if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) { - if (reply.format == 8 && reply.propertyType == XA_STRING && - (reply.nItems + 1 > 0) && - (reply.nItems <= req->longLength * 4) && - (dpy->xdefaults = Xmalloc (reply.nItems + 1))) { - _XReadPad (dpy, dpy->xdefaults, reply.nItems); - dpy->xdefaults[reply.nItems] = '\0'; - } - else if (reply.propertyType != None) - _XEatData(dpy, reply.nItems * (reply.format >> 3)); - } - DeqAsyncHandler(dpy, &async); - if (async_state.opcode) { - GetReq(BigReqEnable, breq); - breq->reqType = async_state.opcode; - breq->brReqType = X_BigReqEnable; - if (_XReply(dpy, (xReply *)&brep, 0, xFalse)) - dpy->bigreq_size = brep.max_request_size; - } - } - UnlockDisplay(dpy); - -#ifdef MOTIFBC - { - extern Display *_XHeadOfDisplayList; - _XHeadOfDisplayList = dpy; - } -#endif -#ifdef XKB - XkbUseExtension(dpy,NULL,NULL); -#endif -/* - * and return successfully - */ - return(dpy); -} - -static Bool -_XBigReqHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - _XBigReqState *state; - xQueryExtensionReply replbuf; - xQueryExtensionReply *repl; - - state = (_XBigReqState *)data; - if (dpy->last_request_read != state->seq) - return False; - if (rep->generic.type == X_Error) - return True; - repl = (xQueryExtensionReply *) - _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, - (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2, - True); - if (repl->present) - state->opcode = repl->major_opcode; - return True; -} - - -/* XFreeDisplayStructure frees all the storage associated with a - * Display. It is used by XOpenDisplay if it runs out of memory, - * and also by XCloseDisplay. It needs to check whether all pointers - * are non-NULL before dereferencing them, since it may be called - * by XOpenDisplay before the Display structure is fully formed. - * XOpenDisplay must be sure to initialize all the pointers to NULL - * before the first possible call on this. - */ - -void _XFreeDisplayStructure(dpy) - register Display *dpy; -{ - while (dpy->ext_procs) { - _XExtension *ext = dpy->ext_procs; - dpy->ext_procs = ext->next; - if (ext->name) - Xfree (ext->name); - Xfree ((char *)ext); - } - if (dpy->im_filters) - (*dpy->free_funcs->im_filters)(dpy); - if (dpy->cms.clientCmaps) - (*dpy->free_funcs->clientCmaps)(dpy); - if (dpy->cms.defaultCCCs) - (*dpy->free_funcs->defaultCCCs)(dpy); - if (dpy->cms.perVisualIntensityMaps) - (*dpy->free_funcs->intensityMaps)(dpy); - if (dpy->atoms) - (*dpy->free_funcs->atoms)(dpy); - if (dpy->modifiermap) - (*dpy->free_funcs->modifiermap)(dpy->modifiermap); - if (dpy->key_bindings) - (*dpy->free_funcs->key_bindings)(dpy); - if (dpy->context_db) - (*dpy->free_funcs->context_db)(dpy); - if (dpy->xkb_info) - (*dpy->free_funcs->xkb)(dpy); - - /* if RM database was allocated by XGetDefault() free it */ - if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB)) - XrmDestroyDatabase(dpy->db); - - if (dpy->screens) { - register int i; - - for (i = 0; i < dpy->nscreens; i++) { - Screen *sp = &dpy->screens[i]; - - if (sp->depths) { - register int j; - - for (j = 0; j < sp->ndepths; j++) { - Depth *dp = &sp->depths[j]; - - if (dp->visuals) { - register int k; - - for (k = 0; k < dp->nvisuals; k++) - _XFreeExtData (dp->visuals[k].ext_data); - Xfree ((char *) dp->visuals); - } - } - - Xfree ((char *) sp->depths); - } - - _XFreeExtData (sp->ext_data); - } - - Xfree ((char *)dpy->screens); - } - - if (dpy->pixmap_format) { - register int i; - - for (i = 0; i < dpy->nformats; i++) - _XFreeExtData (dpy->pixmap_format[i].ext_data); - Xfree ((char *)dpy->pixmap_format); - } - - if (dpy->display_name) - Xfree (dpy->display_name); - if (dpy->vendor) - Xfree (dpy->vendor); - - if (dpy->buffer) - Xfree (dpy->buffer); - if (dpy->keysyms) - Xfree ((char *) dpy->keysyms); - if (dpy->xdefaults) - Xfree (dpy->xdefaults); - if (dpy->error_vec) - Xfree ((char *)dpy->error_vec); - - _XFreeExtData (dpy->ext_data); - if (dpy->free_funcs) - Xfree ((char *)dpy->free_funcs); - if (dpy->scratch_buffer) - Xfree (dpy->scratch_buffer); - FreeDisplayLock(dpy); - - if (dpy->qfree) { - register _XQEvent *qelt = dpy->qfree; - - while (qelt) { - register _XQEvent *qnxt = qelt->next; - Xfree ((char *) qelt); - qelt = qnxt; - } - } - while (dpy->im_fd_info) { - struct _XConnectionInfo *conni = dpy->im_fd_info; - dpy->im_fd_info = conni->next; - if (conni->watch_data) - Xfree (conni->watch_data); - Xfree (conni); - } - if (dpy->conn_watchers) { - struct _XConnWatchInfo *watcher = dpy->conn_watchers; - dpy->conn_watchers = watcher->next; - Xfree (watcher); - } - if (dpy->filedes) - Xfree (dpy->filedes); - - Xfree ((char *)dpy); -} - -/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL - after this returns. */ - -static void OutOfMemory (dpy, setup) - Display *dpy; - char *setup; -{ - _XDisconnectDisplay (dpy->trans_conn); - _XFreeDisplayStructure (dpy); - if (setup) Xfree (setup); -} diff --git a/nx-X11/lib/X11/PeekIfEv.c.NX.original b/nx-X11/lib/X11/PeekIfEv.c.NX.original deleted file mode 100644 index a8da27932..000000000 --- a/nx-X11/lib/X11/PeekIfEv.c.NX.original +++ /dev/null @@ -1,81 +0,0 @@ -/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * return the next event in the queue that satisfies the predicate. - * BUT do not remove it from the queue. - * If none found, flush, and then wait until one satisfies the predicate. - */ - -int -XPeekIfEvent (dpy, event, predicate, arg) - register Display *dpy; - register XEvent *event; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} - diff --git a/nx-X11/lib/X11/PeekIfEv.c.X.original b/nx-X11/lib/X11/PeekIfEv.c.X.original deleted file mode 100644 index beb991a07..000000000 --- a/nx-X11/lib/X11/PeekIfEv.c.X.original +++ /dev/null @@ -1,76 +0,0 @@ -/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * return the next event in the queue that satisfies the predicate. - * BUT do not remove it from the queue. - * If none found, flush, and then wait until one satisfies the predicate. - */ - -int -XPeekIfEvent (dpy, event, predicate, arg) - register Display *dpy; - register XEvent *event; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} - diff --git a/nx-X11/lib/X11/Pending.c.NX.original b/nx-X11/lib/X11/Pending.c.NX.original deleted file mode 100644 index 34e7cf6ca..000000000 --- a/nx-X11/lib/X11/Pending.c.NX.original +++ /dev/null @@ -1,69 +0,0 @@ -/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#include <stdio.h> - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* Read in pending events if needed and return the number of queued events. */ - -int XEventsQueued (dpy, mode) - register Display *dpy; - int mode; -{ - int ret_val; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXEventsQueued: Called with a display at [%p].\n", dpy); -#endif - - LockDisplay(dpy); - if (dpy->qlen || (mode == QueuedAlready)) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, mode); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXEventsQueued: Going to unlock the display at [%p].\n", dpy); -#endif - UnlockDisplay(dpy); - return ret_val; -} - -int XPending (dpy) - register Display *dpy; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, QueuedAfterFlush); - UnlockDisplay(dpy); - return ret_val; -} diff --git a/nx-X11/lib/X11/Pending.c.X.original b/nx-X11/lib/X11/Pending.c.X.original deleted file mode 100644 index 480ec6cf0..000000000 --- a/nx-X11/lib/X11/Pending.c.X.original +++ /dev/null @@ -1,60 +0,0 @@ -/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -Copyright 1986, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* Read in pending events if needed and return the number of queued events. */ - -int XEventsQueued (dpy, mode) - register Display *dpy; - int mode; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen || (mode == QueuedAlready)) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, mode); - UnlockDisplay(dpy); - return ret_val; -} - -int XPending (dpy) - register Display *dpy; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, QueuedAfterFlush); - UnlockDisplay(dpy); - return ret_val; -} diff --git a/nx-X11/lib/X11/XKBMAlloc.c.NX.original b/nx-X11/lib/X11/XKBMAlloc.c.NX.original deleted file mode 100644 index d57d9a58d..000000000 --- a/nx-X11/lib/X11/XKBMAlloc.c.NX.original +++ /dev/null @@ -1,1023 +0,0 @@ -/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ -/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#elif defined(HAVE_CONFIG_H) -#include <config.h> -#endif - -#ifndef XKB_IN_SERVER - -#include <stdio.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include "Xlibint.h" -#include <X11/extensions/XKBproto.h> -#include <X11/keysym.h> -#include "XKBlibint.h" - -#else - -#include <stdio.h> -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#include "misc.h" -#include "inputstr.h" -#include <X11/keysym.h> -#define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> - -#endif /* XKB_IN_SERVER */ - -/***====================================================================***/ - -Status -XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes) -{ -register int i; -XkbClientMapPtr map; - - if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes))) - return BadValue; - if ((which&XkbKeySymsMask)&& - ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code))) { -#ifdef DEBUG -fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n", - xkb->min_key_code,xkb->max_key_code); -#endif - return BadValue; - } - - if (xkb->map==NULL) { - map= _XkbTypedCalloc(1,XkbClientMapRec); - if (map==NULL) - return BadAlloc; - xkb->map= map; - } - else map= xkb->map; - - if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) { - if (map->types==NULL) { - map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) - return BadAlloc; - map->num_types= 0; - map->size_types= nTotalTypes; - } - else if (map->size_types<nTotalTypes) { - XkbKeyTypeRec *prev_types = map->types; - - map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) { - _XkbFree(prev_types); - map->num_types= map->size_types= 0; - return BadAlloc; - } - map->size_types= nTotalTypes; - bzero(&map->types[map->num_types], - ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec))); - } - } - if (which&XkbKeySymsMask) { - int nKeys= XkbNumKeys(xkb); - if (map->syms==NULL) { - map->size_syms= (nKeys*15)/10; - map->syms= _XkbTypedCalloc(map->size_syms,KeySym); - if (!map->syms) { - map->size_syms= 0; - return BadAlloc; - } - map->num_syms= 1; - map->syms[0]= NoSymbol; - } - if (map->key_sym_map==NULL) { - i= xkb->max_key_code+1; - map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec); - if (map->key_sym_map==NULL) - return BadAlloc; - } - } - if (which&XkbModifierMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->modmap==NULL) { - i= xkb->max_key_code+1; - map->modmap= _XkbTypedCalloc(i,unsigned char); - if (map->modmap==NULL) - return BadAlloc; - } - } - return Success; -} - -Status -XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions) -{ -register int i; -XkbServerMapPtr map; - - if (xkb==NULL) - return BadMatch; - if (xkb->server==NULL) { - map= _XkbTypedCalloc(1,XkbServerMapRec); - if (map==NULL) - return BadAlloc; - for (i=0;i<XkbNumVirtualMods;i++) { - map->vmods[i]= XkbNoModifierMask; - } - xkb->server= map; - } - else map= xkb->server; - if (which&XkbExplicitComponentsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->explicit==NULL) { - i= xkb->max_key_code+1; - map->explicit= _XkbTypedCalloc(i,unsigned char); - if (map->explicit==NULL) - return BadAlloc; - } - } - if (which&XkbKeyActionsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (nNewActions<1) - nNewActions= 1; - if (map->acts==NULL) { - map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction); - if (map->acts==NULL) - return BadAlloc; - map->num_acts= 1; - map->size_acts= nNewActions+1; - } - else if ((map->size_acts-map->num_acts)<nNewActions) { - unsigned need; - XkbAction *prev_acts = map->acts; - need= map->num_acts+nNewActions; - map->acts= _XkbTypedRealloc(map->acts,need,XkbAction); - if (map->acts==NULL) { - _XkbFree(prev_acts); - map->num_acts= map->size_acts= 0; - return BadAlloc; - } - map->size_acts= need; - bzero(&map->acts[map->num_acts], - ((map->size_acts-map->num_acts)*sizeof(XkbAction))); - } - if (map->key_acts==NULL) { - i= xkb->max_key_code+1; - map->key_acts= _XkbTypedCalloc(i,unsigned short); - if (map->key_acts==NULL) - return BadAlloc; - } - } - if (which&XkbKeyBehaviorsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->behaviors==NULL) { - i= xkb->max_key_code+1; - map->behaviors= _XkbTypedCalloc(i,XkbBehavior); - if (map->behaviors==NULL) - return BadAlloc; - } - } - if (which&XkbVirtualModMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->vmodmap==NULL) { - i= xkb->max_key_code+1; - map->vmodmap= _XkbTypedCalloc(i,unsigned short); - if (map->vmodmap==NULL) - return BadAlloc; - } - } - return Success; -} - -/***====================================================================***/ - -Status -XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) -{ - if ((!from)||(!into)) - return BadMatch; - if (into->map) { - _XkbFree(into->map); - into->map= NULL; - } - if (into->preserve) { - _XkbFree(into->preserve); - into->preserve= NULL; - } - if (into->level_names) { - _XkbFree(into->level_names); - into->level_names= NULL; - } - *into= *from; - if ((from->map)&&(into->map_count>0)) { - into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec); - if (!into->map) - return BadAlloc; - memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec)); - } - if ((from->preserve)&&(into->map_count>0)) { - into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec); - if (!into->preserve) - return BadAlloc; - memcpy(into->preserve,from->preserve, - into->map_count*sizeof(XkbModsRec)); - } - if ((from->level_names)&&(into->num_levels>0)) { - into->level_names= _XkbTypedCalloc(into->num_levels,Atom); - if (!into->level_names) - return BadAlloc; - memcpy(into->level_names,from->level_names, - into->num_levels*sizeof(Atom)); - } - return Success; -} - -Status -XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types) -{ -register int i,rtrn; - - if ((!from)||(!into)||(num_types<0)) - return BadMatch; - for (i=0;i<num_types;i++) { - if ((rtrn= XkbCopyKeyType(from++,into++))!=Success) - return rtrn; - } - return Success; -} - -XkbKeyTypePtr -XkbAddKeyType( XkbDescPtr xkb, - Atom name, - int map_count, - Bool want_preserve, - int num_lvls) -{ -register int i; -unsigned tmp; -XkbKeyTypePtr type; -XkbClientMapPtr map; - - if ((!xkb)||(num_lvls<1)) - return NULL; - map= xkb->map; - if ((map)&&(map->types)) { - for (i=0;i<map->num_types;i++) { - if (map->types[i].name==name) { - Status status; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) { - tmp= XkbNumRequiredTypes+1; - if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success) - return NULL; - tmp= 0; - if (map->num_types<=XkbKeypadIndex) - tmp|= XkbKeypadMask; - if (map->num_types<=XkbAlphabeticIndex) - tmp|= XkbAlphabeticMask; - if (map->num_types<=XkbTwoLevelIndex) - tmp|= XkbTwoLevelMask; - if (map->num_types<=XkbOneLevelIndex) - tmp|= XkbOneLevelMask; - if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) { - for (i=0;i<map->num_types;i++) { - Status status; - if (map->types[i].name!=name) - continue; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((map->num_types<=map->size_types)&& - (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) { - return NULL; - } - type= &map->types[map->num_types]; - map->num_types++; - bzero((char *)type,sizeof(XkbKeyTypeRec)); - type->num_levels= num_lvls; - type->map_count= map_count; - type->name= name; - if (map_count>0) { - type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec); - if (!type->map) { - map->num_types--; - return NULL; - } - if (want_preserve) { - type->preserve= _XkbTypedCalloc(map_count,XkbModsRec); - if (!type->preserve) { - _XkbFree(type->map); - map->num_types--; - return NULL; - } - } - } - return type; -} - -Status -XkbResizeKeyType( XkbDescPtr xkb, - int type_ndx, - int map_count, - Bool want_preserve, - int new_num_lvls) -{ -XkbKeyTypePtr type; -KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; - - if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)|| - (new_num_lvls<1)) - return BadValue; - switch (type_ndx) { - case XkbOneLevelIndex: - if (new_num_lvls!=1) - return BadMatch; - break; - case XkbTwoLevelIndex: - case XkbAlphabeticIndex: - case XkbKeypadIndex: - if (new_num_lvls!=2) - return BadMatch; - break; - } - type= &xkb->map->types[type_ndx]; - if (map_count==0) { - if (type->map!=NULL) - _XkbFree(type->map); - type->map= NULL; - if (type->preserve!=NULL) - _XkbFree(type->preserve); - type->preserve= NULL; - type->map_count= 0; - } - else { - XkbKTMapEntryRec *prev_map = type->map; - - if ((map_count>type->map_count)||(type->map==NULL)) - type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec); - if (!type->map) { - if (prev_map) - _XkbFree(prev_map); - return BadAlloc; - } - if (want_preserve) { - XkbModsRec *prev_preserve = type->preserve; - - if ((map_count>type->map_count)||(type->preserve==NULL)) { - type->preserve= _XkbTypedRealloc(type->preserve,map_count, - XkbModsRec); - } - if (!type->preserve) { - if (prev_preserve) - _XkbFree(prev_preserve); - return BadAlloc; - } - } - else if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= map_count; - } - - if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) { - Atom * prev_level_names = type->level_names; - - type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom); - if (!type->level_names) { - if (prev_level_names) - _XkbFree(prev_level_names); - return BadAlloc; - } - } - /* - * Here's the theory: - * If the width of the type changed, we might have to resize the symbol - * maps for any keys that use the type for one or more groups. This is - * expensive, so we'll try to cull out any keys that are obviously okay: - * In any case: - * - keys that have a group width <= the old width are okay (because - * they could not possibly have been associated with the old type) - * If the key type increased in size: - * - keys that already have a group width >= to the new width are okay - * + keys that have a group width >= the old width but < the new width - * might have to be enlarged. - * If the key type decreased in size: - * - keys that have a group width > the old width don't have to be - * resized (because they must have some other wider type associated - * with some group). - * + keys that have a group width == the old width might have to be - * shrunk. - * The possibilities marked with '+' require us to examine the key types - * associated with each group for the key. - */ - bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode)); - nMatchingKeys= 0; - if (new_num_lvls>type->num_levels) { - int nTotal; - KeySym * newSyms; - int width,match,nResize; - register int i,g,nSyms; - - nResize= 0; - for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - if ((!match)||(width>=new_num_lvls)) - nTotal+= XkbKeyNumSyms(xkb,i); - else { - nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - nResize++; - } - } - if (nResize>0) { - int nextMatch; - xkb->map->size_syms= (nTotal*12)/10; - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return BadAlloc; - nextMatch= 0; - nSyms= 1; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - if (matchingKeys[nextMatch]==i) { - KeySym *pOld; - nextMatch++; - width= XkbKeyGroupsWidth(xkb,i); - pOld= XkbKeySymsPtr(xkb,i); - for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) { - memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g], - width*sizeof(KeySym)); - } - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - } - else { - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i), - XkbKeyNumSyms(xkb,i)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumSyms(xkb,i); - } - } - type->num_levels= new_num_lvls; - _XkbFree(xkb->map->syms); - xkb->map->syms= newSyms; - xkb->map->num_syms= nSyms; - return Success; - } - } - else if (new_num_lvls<type->num_levels) { - int width,match; - register int g,i; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - } - } - if (nMatchingKeys>0) { - int key,firstClear; - register int i,g; - if (new_num_lvls>type->num_levels) - firstClear= type->num_levels; - else firstClear= new_num_lvls; - for (i=0;i<nMatchingKeys;i++) { - KeySym * pSyms; - int width,nClear; - - key= matchingKeys[i]; - width= XkbKeyGroupsWidth(xkb,key); - nClear= width-firstClear; - pSyms= XkbKeySymsPtr(xkb,key); - for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) { - if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) { - if (nClear>0) - bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym)); - } - } - } - } - type->num_levels= new_num_lvls; - return Success; -} - -KeySym * -XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed) -{ -register int i,nSyms,nKeySyms; -unsigned nOldSyms; -KeySym *newSyms; - - if (needed==0) { - xkb->map->key_sym_map[key].offset= 0; - return xkb->map->syms; - } - nOldSyms= XkbKeyNumSyms(xkb,key); - if (nOldSyms>=(unsigned)needed) { - return XkbKeySymsPtr(xkb,key); - } - if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) { - if (nOldSyms>0) { - memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key), - nOldSyms*sizeof(KeySym)); - } - if ((needed-nOldSyms)>0) { - bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)], - (needed-nOldSyms)*sizeof(KeySym)); - } - xkb->map->key_sym_map[key].offset = xkb->map->num_syms; - xkb->map->num_syms+= needed; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; - } - xkb->map->size_syms+= (needed>32?needed:32); - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return NULL; - newSyms[0]= NoSymbol; - nSyms = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nCopy; - - nCopy= nKeySyms= XkbKeyNumSyms(xkb,i); - if ((nKeySyms==0)&&(i!=key)) - continue; - if (i==key) - nKeySyms= needed; - if (nCopy!=0) - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym)); - if (nKeySyms>nCopy) - bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset = nSyms; - nSyms+= nKeySyms; - } - _XkbFree(xkb->map->syms); - xkb->map->syms = newSyms; - xkb->map->num_syms = nSyms; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; -} - -static unsigned -_ExtendRange( unsigned int old_flags, - unsigned int flag, - KeyCode newKC, - KeyCode * old_min, - unsigned char * old_num) -{ - if ((old_flags&flag)==0) { - old_flags|= flag; - *old_min= newKC; - *old_num= 1; - } - else { - int last= (*old_min)+(*old_num)-1; - if (newKC<*old_min) { - *old_min= newKC; - *old_num= (last-newKC)+1; - } - else if (newKC>last) { - *old_num= (newKC-(*old_min))+1; - } - } - return old_flags; -} - -Status -XkbChangeKeycodeRange( XkbDescPtr xkb, - int minKC, - int maxKC, - XkbChangesPtr changes) -{ -int tmp; - - if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode)) - return BadValue; - if (minKC>maxKC) - return BadMatch; - if (minKC<xkb->min_key_code) { - if (changes) - changes->map.min_key_code= minKC; - tmp= xkb->min_key_code-minKC; - if (xkb->map) { - if (xkb->map->key_sym_map) { - bzero((char *)&xkb->map->key_sym_map[minKC], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,minKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - bzero((char *)&xkb->map->modmap[minKC],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - bzero((char *)&xkb->server->behaviors[minKC], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,minKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - bzero((char *)&xkb->server->key_acts[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,minKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - bzero((char *)&xkb->server->vmodmap[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,minKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->min_key_code= minKC; - } - if (maxKC>xkb->max_key_code) { - if (changes) - changes->map.max_key_code= maxKC; - tmp= maxKC-xkb->max_key_code; - if (xkb->map) { - if (xkb->map->key_sym_map) { - XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map; - - xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map, - (maxKC+1),XkbSymMapRec); - if (!xkb->map->key_sym_map) { - _XkbFree(prev_key_sym_map); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1], - tmp*sizeof(XkbSymMapRec)); -#else - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code], - tmp*sizeof(XkbSymMapRec)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,maxKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - unsigned char *prev_modmap = xkb->map->modmap; - - xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap, - (maxKC+1),unsigned char); - if (!xkb->map->modmap) { - _XkbFree(prev_modmap); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp); -#else - bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - XkbBehavior *prev_behaviors = xkb->server->behaviors; - - xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors, - (maxKC+1),XkbBehavior); - if (!xkb->server->behaviors) { - _XkbFree(prev_behaviors); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1], - tmp*sizeof(XkbBehavior)); -#else - bzero((char *)&xkb->server->behaviors[xkb->max_key_code], - tmp*sizeof(XkbBehavior)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,maxKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - unsigned short *prev_key_acts = xkb->server->key_acts; - - xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts, - (maxKC+1),unsigned short); - if (!xkb->server->key_acts) { - _XkbFree(prev_key_acts); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1], - tmp*sizeof(unsigned short)); -#else - bzero((char *)&xkb->server->key_acts[xkb->max_key_code], - tmp*sizeof(unsigned short)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,maxKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - unsigned short *prev_vmodmap = xkb->server->vmodmap; - - xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap, - (maxKC+1),unsigned short); - if (!xkb->server->vmodmap) { - _XkbFree(prev_vmodmap); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1], - tmp*sizeof(unsigned short)); -#else - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code], - tmp*sizeof(unsigned short)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - XkbKeyNameRec *prev_keys = xkb->names->keys; - - xkb->names->keys= _XkbTypedRealloc(xkb->names->keys, - (maxKC+1),XkbKeyNameRec); - if (!xkb->names->keys) { - _XkbFree(prev_keys); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->names->keys[xkb->max_key_code+1], - tmp*sizeof(XkbKeyNameRec)); -#else - bzero((char *)&xkb->names->keys[xkb->max_key_code], - tmp*sizeof(XkbKeyNameRec)); -#endif - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,maxKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->max_key_code= maxKC; - } - return Success; -} - -XkbAction * -XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed) -{ -register int i,nActs; -XkbAction *newActs; - - if (needed==0) { - xkb->server->key_acts[key]= 0; - return NULL; - } - if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed)) - return XkbKeyActionsPtr(xkb,key); - if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) { - xkb->server->key_acts[key]= xkb->server->num_acts; - xkb->server->num_acts+= needed; - return &xkb->server->acts[xkb->server->key_acts[key]]; - } - xkb->server->size_acts= xkb->server->num_acts+needed+8; - newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction); - if (newActs==NULL) - return NULL; - newActs[0].type = XkbSA_NoAction; - nActs = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nKeyActs,nCopy; - - if ((xkb->server->key_acts[i]==0)&&(i!=key)) - continue; - - nCopy= nKeyActs= XkbKeyNumActions(xkb,i); - if (i==key) { - nKeyActs= needed; - if (needed<nCopy) - nCopy= needed; - } - - if (nCopy>0) - memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i), - nCopy*sizeof(XkbAction)); - if (nCopy<nKeyActs) - bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction)); - xkb->server->key_acts[i]= nActs; - nActs+= nKeyActs; - } - _XkbFree(xkb->server->acts); - xkb->server->acts = newActs; - xkb->server->num_acts= nActs; - return &xkb->server->acts[xkb->server->key_acts[key]]; -} - -void -XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbClientMapPtr map; - - if ((xkb==NULL)||(xkb->map==NULL)) - return; - if (freeMap) - what= XkbAllClientInfoMask; - map= xkb->map; - if (what&XkbKeyTypesMask) { - if (map->types!=NULL) { - if (map->num_types>0) { - register int i; - XkbKeyTypePtr type; - for (i=0,type=map->types;i<map->num_types;i++,type++) { - if (type->map!=NULL) { - _XkbFree(type->map); - type->map= NULL; - } - if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= 0; - if (type->level_names!=NULL) { - _XkbFree(type->level_names); - type->level_names= NULL; - } - } - } - _XkbFree(map->types); - map->num_types= map->size_types= 0; - map->types= NULL; - } - } - if (what&XkbKeySymsMask) { - if (map->key_sym_map!=NULL) { - _XkbFree(map->key_sym_map); - map->key_sym_map= NULL; - } - if (map->syms!=NULL) { - _XkbFree(map->syms); - map->size_syms= map->num_syms= 0; - map->syms= NULL; - } - } - if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) { - _XkbFree(map->modmap); - map->modmap= NULL; - } - if (freeMap) { - _XkbFree(xkb->map); - xkb->map= NULL; - } - return; -} - -void -XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbServerMapPtr map; - - if ((xkb==NULL)||(xkb->server==NULL)) - return; - if (freeMap) - what= XkbAllServerInfoMask; - map= xkb->server; - if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) { - _XkbFree(map->explicit); - map->explicit= NULL; - } - if (what&XkbKeyActionsMask) { - if (map->key_acts!=NULL) { - _XkbFree(map->key_acts); - map->key_acts= NULL; - } - if (map->acts!=NULL) { - _XkbFree(map->acts); - map->num_acts= map->size_acts= 0; - map->acts= NULL; - } - } - if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) { - _XkbFree(map->behaviors); - map->behaviors= NULL; - } - if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) { - _XkbFree(map->vmodmap); - map->vmodmap= NULL; - } - - if (freeMap) { - _XkbFree(xkb->server); - xkb->server= NULL; - } - return; -} diff --git a/nx-X11/lib/X11/XKBMAlloc.c.X.original b/nx-X11/lib/X11/XKBMAlloc.c.X.original deleted file mode 100644 index 91d87d57c..000000000 --- a/nx-X11/lib/X11/XKBMAlloc.c.X.original +++ /dev/null @@ -1,994 +0,0 @@ -/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ -/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#elif defined(HAVE_CONFIG_H) -#include <config.h> -#endif - -#ifndef XKB_IN_SERVER - -#include <stdio.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include "Xlibint.h" -#include <X11/extensions/XKBproto.h> -#include <X11/keysym.h> -#include "XKBlibint.h" - -#else - -#include <stdio.h> -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#include "misc.h" -#include "inputstr.h" -#include <X11/keysym.h> -#define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> - -#endif /* XKB_IN_SERVER */ - -/***====================================================================***/ - -Status -XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes) -{ -register int i; -XkbClientMapPtr map; - - if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes))) - return BadValue; - if ((which&XkbKeySymsMask)&& - ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code))) { -#ifdef DEBUG -fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n", - xkb->min_key_code,xkb->max_key_code); -#endif - return BadValue; - } - - if (xkb->map==NULL) { - map= _XkbTypedCalloc(1,XkbClientMapRec); - if (map==NULL) - return BadAlloc; - xkb->map= map; - } - else map= xkb->map; - - if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) { - if (map->types==NULL) { - map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) - return BadAlloc; - map->num_types= 0; - map->size_types= nTotalTypes; - } - else if (map->size_types<nTotalTypes) { - XkbKeyTypeRec *prev_types = map->types; - - map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) { - _XkbFree(prev_types); - map->num_types= map->size_types= 0; - return BadAlloc; - } - map->size_types= nTotalTypes; - bzero(&map->types[map->num_types], - ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec))); - } - } - if (which&XkbKeySymsMask) { - int nKeys= XkbNumKeys(xkb); - if (map->syms==NULL) { - map->size_syms= (nKeys*15)/10; - map->syms= _XkbTypedCalloc(map->size_syms,KeySym); - if (!map->syms) { - map->size_syms= 0; - return BadAlloc; - } - map->num_syms= 1; - map->syms[0]= NoSymbol; - } - if (map->key_sym_map==NULL) { - i= xkb->max_key_code+1; - map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec); - if (map->key_sym_map==NULL) - return BadAlloc; - } - } - if (which&XkbModifierMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->modmap==NULL) { - i= xkb->max_key_code+1; - map->modmap= _XkbTypedCalloc(i,unsigned char); - if (map->modmap==NULL) - return BadAlloc; - } - } - return Success; -} - -Status -XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions) -{ -register int i; -XkbServerMapPtr map; - - if (xkb==NULL) - return BadMatch; - if (xkb->server==NULL) { - map= _XkbTypedCalloc(1,XkbServerMapRec); - if (map==NULL) - return BadAlloc; - for (i=0;i<XkbNumVirtualMods;i++) { - map->vmods[i]= XkbNoModifierMask; - } - xkb->server= map; - } - else map= xkb->server; - if (which&XkbExplicitComponentsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->explicit==NULL) { - i= xkb->max_key_code+1; - map->explicit= _XkbTypedCalloc(i,unsigned char); - if (map->explicit==NULL) - return BadAlloc; - } - } - if (which&XkbKeyActionsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (nNewActions<1) - nNewActions= 1; - if (map->acts==NULL) { - map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction); - if (map->acts==NULL) - return BadAlloc; - map->num_acts= 1; - map->size_acts= nNewActions+1; - } - else if ((map->size_acts-map->num_acts)<nNewActions) { - unsigned need; - XkbAction *prev_acts = map->acts; - need= map->num_acts+nNewActions; - map->acts= _XkbTypedRealloc(map->acts,need,XkbAction); - if (map->acts==NULL) { - _XkbFree(prev_acts); - map->num_acts= map->size_acts= 0; - return BadAlloc; - } - map->size_acts= need; - bzero(&map->acts[map->num_acts], - ((map->size_acts-map->num_acts)*sizeof(XkbAction))); - } - if (map->key_acts==NULL) { - i= xkb->max_key_code+1; - map->key_acts= _XkbTypedCalloc(i,unsigned short); - if (map->key_acts==NULL) - return BadAlloc; - } - } - if (which&XkbKeyBehaviorsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->behaviors==NULL) { - i= xkb->max_key_code+1; - map->behaviors= _XkbTypedCalloc(i,XkbBehavior); - if (map->behaviors==NULL) - return BadAlloc; - } - } - if (which&XkbVirtualModMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->vmodmap==NULL) { - i= xkb->max_key_code+1; - map->vmodmap= _XkbTypedCalloc(i,unsigned short); - if (map->vmodmap==NULL) - return BadAlloc; - } - } - return Success; -} - -/***====================================================================***/ - -Status -XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) -{ - if ((!from)||(!into)) - return BadMatch; - if (into->map) { - _XkbFree(into->map); - into->map= NULL; - } - if (into->preserve) { - _XkbFree(into->preserve); - into->preserve= NULL; - } - if (into->level_names) { - _XkbFree(into->level_names); - into->level_names= NULL; - } - *into= *from; - if ((from->map)&&(into->map_count>0)) { - into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec); - if (!into->map) - return BadAlloc; - memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec)); - } - if ((from->preserve)&&(into->map_count>0)) { - into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec); - if (!into->preserve) - return BadAlloc; - memcpy(into->preserve,from->preserve, - into->map_count*sizeof(XkbModsRec)); - } - if ((from->level_names)&&(into->num_levels>0)) { - into->level_names= _XkbTypedCalloc(into->num_levels,Atom); - if (!into->level_names) - return BadAlloc; - memcpy(into->level_names,from->level_names, - into->num_levels*sizeof(Atom)); - } - return Success; -} - -Status -XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types) -{ -register int i,rtrn; - - if ((!from)||(!into)||(num_types<0)) - return BadMatch; - for (i=0;i<num_types;i++) { - if ((rtrn= XkbCopyKeyType(from++,into++))!=Success) - return rtrn; - } - return Success; -} - -XkbKeyTypePtr -XkbAddKeyType( XkbDescPtr xkb, - Atom name, - int map_count, - Bool want_preserve, - int num_lvls) -{ -register int i; -unsigned tmp; -XkbKeyTypePtr type; -XkbClientMapPtr map; - - if ((!xkb)||(num_lvls<1)) - return NULL; - map= xkb->map; - if ((map)&&(map->types)) { - for (i=0;i<map->num_types;i++) { - if (map->types[i].name==name) { - Status status; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) { - tmp= XkbNumRequiredTypes+1; - if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success) - return NULL; - tmp= 0; - if (map->num_types<=XkbKeypadIndex) - tmp|= XkbKeypadMask; - if (map->num_types<=XkbAlphabeticIndex) - tmp|= XkbAlphabeticMask; - if (map->num_types<=XkbTwoLevelIndex) - tmp|= XkbTwoLevelMask; - if (map->num_types<=XkbOneLevelIndex) - tmp|= XkbOneLevelMask; - if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) { - for (i=0;i<map->num_types;i++) { - Status status; - if (map->types[i].name!=name) - continue; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((map->num_types<=map->size_types)&& - (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) { - return NULL; - } - type= &map->types[map->num_types]; - map->num_types++; - bzero((char *)type,sizeof(XkbKeyTypeRec)); - type->num_levels= num_lvls; - type->map_count= map_count; - type->name= name; - if (map_count>0) { - type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec); - if (!type->map) { - map->num_types--; - return NULL; - } - if (want_preserve) { - type->preserve= _XkbTypedCalloc(map_count,XkbModsRec); - if (!type->preserve) { - _XkbFree(type->map); - map->num_types--; - return NULL; - } - } - } - return type; -} - -Status -XkbResizeKeyType( XkbDescPtr xkb, - int type_ndx, - int map_count, - Bool want_preserve, - int new_num_lvls) -{ -XkbKeyTypePtr type; -KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; - - if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)|| - (new_num_lvls<1)) - return BadValue; - switch (type_ndx) { - case XkbOneLevelIndex: - if (new_num_lvls!=1) - return BadMatch; - break; - case XkbTwoLevelIndex: - case XkbAlphabeticIndex: - case XkbKeypadIndex: - if (new_num_lvls!=2) - return BadMatch; - break; - } - type= &xkb->map->types[type_ndx]; - if (map_count==0) { - if (type->map!=NULL) - _XkbFree(type->map); - type->map= NULL; - if (type->preserve!=NULL) - _XkbFree(type->preserve); - type->preserve= NULL; - type->map_count= 0; - } - else { - XkbKTMapEntryRec *prev_map = type->map; - - if ((map_count>type->map_count)||(type->map==NULL)) - type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec); - if (!type->map) { - if (prev_map) - _XkbFree(prev_map); - return BadAlloc; - } - if (want_preserve) { - XkbModsRec *prev_preserve = type->preserve; - - if ((map_count>type->map_count)||(type->preserve==NULL)) { - type->preserve= _XkbTypedRealloc(type->preserve,map_count, - XkbModsRec); - } - if (!type->preserve) { - if (prev_preserve) - _XkbFree(prev_preserve); - return BadAlloc; - } - } - else if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= map_count; - } - - if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) { - Atom * prev_level_names = type->level_names; - - type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom); - if (!type->level_names) { - if (prev_level_names) - _XkbFree(prev_level_names); - return BadAlloc; - } - } - /* - * Here's the theory: - * If the width of the type changed, we might have to resize the symbol - * maps for any keys that use the type for one or more groups. This is - * expensive, so we'll try to cull out any keys that are obviously okay: - * In any case: - * - keys that have a group width <= the old width are okay (because - * they could not possibly have been associated with the old type) - * If the key type increased in size: - * - keys that already have a group width >= to the new width are okay - * + keys that have a group width >= the old width but < the new width - * might have to be enlarged. - * If the key type decreased in size: - * - keys that have a group width > the old width don't have to be - * resized (because they must have some other wider type associated - * with some group). - * + keys that have a group width == the old width might have to be - * shrunk. - * The possibilities marked with '+' require us to examine the key types - * associated with each group for the key. - */ - bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode)); - nMatchingKeys= 0; - if (new_num_lvls>type->num_levels) { - int nTotal; - KeySym * newSyms; - int width,match,nResize; - register int i,g,nSyms; - - nResize= 0; - for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - if ((!match)||(width>=new_num_lvls)) - nTotal+= XkbKeyNumSyms(xkb,i); - else { - nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - nResize++; - } - } - if (nResize>0) { - int nextMatch; - xkb->map->size_syms= (nTotal*12)/10; - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return BadAlloc; - nextMatch= 0; - nSyms= 1; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - if (matchingKeys[nextMatch]==i) { - KeySym *pOld; - nextMatch++; - width= XkbKeyGroupsWidth(xkb,i); - pOld= XkbKeySymsPtr(xkb,i); - for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) { - memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g], - width*sizeof(KeySym)); - } - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - } - else { - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i), - XkbKeyNumSyms(xkb,i)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumSyms(xkb,i); - } - } - type->num_levels= new_num_lvls; - _XkbFree(xkb->map->syms); - xkb->map->syms= newSyms; - xkb->map->num_syms= nSyms; - return Success; - } - } - else if (new_num_lvls<type->num_levels) { - int width,match; - register int g,i; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - } - } - if (nMatchingKeys>0) { - int key,firstClear; - register int i,g; - if (new_num_lvls>type->num_levels) - firstClear= type->num_levels; - else firstClear= new_num_lvls; - for (i=0;i<nMatchingKeys;i++) { - KeySym * pSyms; - int width,nClear; - - key= matchingKeys[i]; - width= XkbKeyGroupsWidth(xkb,key); - nClear= width-firstClear; - pSyms= XkbKeySymsPtr(xkb,key); - for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) { - if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) { - if (nClear>0) - bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym)); - } - } - } - } - type->num_levels= new_num_lvls; - return Success; -} - -KeySym * -XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed) -{ -register int i,nSyms,nKeySyms; -unsigned nOldSyms; -KeySym *newSyms; - - if (needed==0) { - xkb->map->key_sym_map[key].offset= 0; - return xkb->map->syms; - } - nOldSyms= XkbKeyNumSyms(xkb,key); - if (nOldSyms>=(unsigned)needed) { - return XkbKeySymsPtr(xkb,key); - } - if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) { - if (nOldSyms>0) { - memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key), - nOldSyms*sizeof(KeySym)); - } - if ((needed-nOldSyms)>0) { - bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)], - (needed-nOldSyms)*sizeof(KeySym)); - } - xkb->map->key_sym_map[key].offset = xkb->map->num_syms; - xkb->map->num_syms+= needed; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; - } - xkb->map->size_syms+= (needed>32?needed:32); - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return NULL; - newSyms[0]= NoSymbol; - nSyms = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nCopy; - - nCopy= nKeySyms= XkbKeyNumSyms(xkb,i); - if ((nKeySyms==0)&&(i!=key)) - continue; - if (i==key) - nKeySyms= needed; - if (nCopy!=0) - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym)); - if (nKeySyms>nCopy) - bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset = nSyms; - nSyms+= nKeySyms; - } - _XkbFree(xkb->map->syms); - xkb->map->syms = newSyms; - xkb->map->num_syms = nSyms; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; -} - -static unsigned -_ExtendRange( unsigned int old_flags, - unsigned int flag, - KeyCode newKC, - KeyCode * old_min, - unsigned char * old_num) -{ - if ((old_flags&flag)==0) { - old_flags|= flag; - *old_min= newKC; - *old_num= 1; - } - else { - int last= (*old_min)+(*old_num)-1; - if (newKC<*old_min) { - *old_min= newKC; - *old_num= (last-newKC)+1; - } - else if (newKC>last) { - *old_num= (newKC-(*old_min))+1; - } - } - return old_flags; -} - -Status -XkbChangeKeycodeRange( XkbDescPtr xkb, - int minKC, - int maxKC, - XkbChangesPtr changes) -{ -int tmp; - - if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode)) - return BadValue; - if (minKC>maxKC) - return BadMatch; - if (minKC<xkb->min_key_code) { - if (changes) - changes->map.min_key_code= minKC; - tmp= xkb->min_key_code-minKC; - if (xkb->map) { - if (xkb->map->key_sym_map) { - bzero((char *)&xkb->map->key_sym_map[minKC], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,minKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - bzero((char *)&xkb->map->modmap[minKC],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - bzero((char *)&xkb->server->behaviors[minKC], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,minKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - bzero((char *)&xkb->server->key_acts[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,minKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - bzero((char *)&xkb->server->vmodmap[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,minKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->min_key_code= minKC; - } - if (maxKC>xkb->max_key_code) { - if (changes) - changes->map.max_key_code= maxKC; - tmp= maxKC-xkb->max_key_code; - if (xkb->map) { - if (xkb->map->key_sym_map) { - XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map; - - xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map, - (maxKC+1),XkbSymMapRec); - if (!xkb->map->key_sym_map) { - _XkbFree(prev_key_sym_map); - return BadAlloc; - } - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,maxKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - unsigned char *prev_modmap = xkb->map->modmap; - - xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap, - (maxKC+1),unsigned char); - if (!xkb->map->modmap) { - _XkbFree(prev_modmap); - return BadAlloc; - } - bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - XkbBehavior *prev_behaviors = xkb->server->behaviors; - - xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors, - (maxKC+1),XkbBehavior); - if (!xkb->server->behaviors) { - _XkbFree(prev_behaviors); - return BadAlloc; - } - bzero((char *)&xkb->server->behaviors[xkb->max_key_code], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,maxKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - unsigned short *prev_key_acts = xkb->server->key_acts; - - xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts, - (maxKC+1),unsigned short); - if (!xkb->server->key_acts) { - _XkbFree(prev_key_acts); - return BadAlloc; - } - bzero((char *)&xkb->server->key_acts[xkb->max_key_code], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,maxKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - unsigned short *prev_vmodmap = xkb->server->vmodmap; - - xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap, - (maxKC+1),unsigned short); - if (!xkb->server->vmodmap) { - _XkbFree(prev_vmodmap); - return BadAlloc; - } - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - XkbKeyNameRec *prev_keys = xkb->names->keys; - - xkb->names->keys= _XkbTypedRealloc(xkb->names->keys, - (maxKC+1),XkbKeyNameRec); - if (!xkb->names->keys) { - _XkbFree(prev_keys); - return BadAlloc; - } - bzero((char *)&xkb->names->keys[xkb->max_key_code], - tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,maxKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->max_key_code= maxKC; - } - return Success; -} - -XkbAction * -XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed) -{ -register int i,nActs; -XkbAction *newActs; - - if (needed==0) { - xkb->server->key_acts[key]= 0; - return NULL; - } - if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed)) - return XkbKeyActionsPtr(xkb,key); - if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) { - xkb->server->key_acts[key]= xkb->server->num_acts; - xkb->server->num_acts+= needed; - return &xkb->server->acts[xkb->server->key_acts[key]]; - } - xkb->server->size_acts= xkb->server->num_acts+needed+8; - newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction); - if (newActs==NULL) - return NULL; - newActs[0].type = XkbSA_NoAction; - nActs = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nKeyActs,nCopy; - - if ((xkb->server->key_acts[i]==0)&&(i!=key)) - continue; - - nCopy= nKeyActs= XkbKeyNumActions(xkb,i); - if (i==key) { - nKeyActs= needed; - if (needed<nCopy) - nCopy= needed; - } - - if (nCopy>0) - memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i), - nCopy*sizeof(XkbAction)); - if (nCopy<nKeyActs) - bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction)); - xkb->server->key_acts[i]= nActs; - nActs+= nKeyActs; - } - _XkbFree(xkb->server->acts); - xkb->server->acts = newActs; - xkb->server->num_acts= nActs; - return &xkb->server->acts[xkb->server->key_acts[key]]; -} - -void -XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbClientMapPtr map; - - if ((xkb==NULL)||(xkb->map==NULL)) - return; - if (freeMap) - what= XkbAllClientInfoMask; - map= xkb->map; - if (what&XkbKeyTypesMask) { - if (map->types!=NULL) { - if (map->num_types>0) { - register int i; - XkbKeyTypePtr type; - for (i=0,type=map->types;i<map->num_types;i++,type++) { - if (type->map!=NULL) { - _XkbFree(type->map); - type->map= NULL; - } - if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= 0; - if (type->level_names!=NULL) { - _XkbFree(type->level_names); - type->level_names= NULL; - } - } - } - _XkbFree(map->types); - map->num_types= map->size_types= 0; - map->types= NULL; - } - } - if (what&XkbKeySymsMask) { - if (map->key_sym_map!=NULL) { - _XkbFree(map->key_sym_map); - map->key_sym_map= NULL; - } - if (map->syms!=NULL) { - _XkbFree(map->syms); - map->size_syms= map->num_syms= 0; - map->syms= NULL; - } - } - if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) { - _XkbFree(map->modmap); - map->modmap= NULL; - } - if (freeMap) { - _XkbFree(xkb->map); - xkb->map= NULL; - } - return; -} - -void -XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbServerMapPtr map; - - if ((xkb==NULL)||(xkb->server==NULL)) - return; - if (freeMap) - what= XkbAllServerInfoMask; - map= xkb->server; - if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) { - _XkbFree(map->explicit); - map->explicit= NULL; - } - if (what&XkbKeyActionsMask) { - if (map->key_acts!=NULL) { - _XkbFree(map->key_acts); - map->key_acts= NULL; - } - if (map->acts!=NULL) { - _XkbFree(map->acts); - map->num_acts= map->size_acts= 0; - map->acts= NULL; - } - } - if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) { - _XkbFree(map->behaviors); - map->behaviors= NULL; - } - if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) { - _XkbFree(map->vmodmap); - map->vmodmap= NULL; - } - - if (freeMap) { - _XkbFree(xkb->server); - xkb->server= NULL; - } - return; -} diff --git a/nx-X11/lib/X11/Xlib.h.NX.original b/nx-X11/lib/X11/Xlib.h.NX.original deleted file mode 100644 index e21d9ffac..000000000 --- a/nx-X11/lib/X11/Xlib.h.NX.original +++ /dev/null @@ -1,4029 +0,0 @@ -/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */ -/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */ - - -/* - * Xlib.h - Header definition and support file for the C subroutine - * interface library (Xlib) to the X Window System Protocol (V11). - * Structures and symbols starting with "_" are private to the library. - */ -#ifndef _XLIB_H_ -#define _XLIB_H_ - -#define XlibSpecificationRelease 6 - -#ifdef USG -#ifndef __TYPES__ -#include <sys/types.h> /* forgot to protect it... */ -#define __TYPES__ -#endif /* __TYPES__ */ -#else -#if defined(_POSIX_SOURCE) && defined(MOTOROLA) -#undef _POSIX_SOURCE -#include <sys/types.h> -#define _POSIX_SOURCE -#else -#include <sys/types.h> -#endif -#endif /* USG */ - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <stdint.h> -#endif - -#include <X11/X.h> - -/* applications should not depend on these two headers being included! */ -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> - -#ifndef X_WCHAR -#ifdef X_NOT_STDC_ENV -#ifndef ISC -#define X_WCHAR -#endif -#endif -#endif - -#ifndef X_WCHAR -#include <stddef.h> -#else -#ifdef __UNIXOS2__ -#include <stdlib.h> -#else -/* replace this with #include or typedef appropriate for your system */ -typedef unsigned long wchar_t; -#endif -#endif - -#if defined(ISC) && defined(USE_XMBTOWC) -#define wctomb(a,b) _Xwctomb(a,b) -#define mblen(a,b) _Xmblen(a,b) -#ifndef USE_XWCHAR_STRING -#define mbtowc(a,b,c) _Xmbtowc(a,b,c) -#endif -#endif - -extern int -_Xmblen( -#ifdef ISC - char const *str, - size_t len -#else - char *str, - int len -#endif - ); - -/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in - November 2000. Its presence is indicated through the following macro. */ -#define X_HAVE_UTF8_STRING 1 - -typedef char *XPointer; - -#define Bool int -#define Status int -#define True 1 -#define False 0 - -#define QueuedAlready 0 -#define QueuedAfterReading 1 -#define QueuedAfterFlush 2 - -#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) -#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) -#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) -#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) -#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) -#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) -#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) -#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) -#define AllPlanes ((unsigned long)~0L) -#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) -#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) -#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) -#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) -#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) -#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) -#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) -#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) -#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) -#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) -#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) -#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) -#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) -#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) -#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) -#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) -#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) -#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ -#define NextRequest(dpy) XNextRequest(dpy) -#else -#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) -#endif -#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) - -/* macros for screen oriented applications (toolkit) */ -#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) -#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) -#define DisplayOfScreen(s) ((s)->display) -#define RootWindowOfScreen(s) ((s)->root) -#define BlackPixelOfScreen(s) ((s)->black_pixel) -#define WhitePixelOfScreen(s) ((s)->white_pixel) -#define DefaultColormapOfScreen(s)((s)->cmap) -#define DefaultDepthOfScreen(s) ((s)->root_depth) -#define DefaultGCOfScreen(s) ((s)->default_gc) -#define DefaultVisualOfScreen(s)((s)->root_visual) -#define WidthOfScreen(s) ((s)->width) -#define HeightOfScreen(s) ((s)->height) -#define WidthMMOfScreen(s) ((s)->mwidth) -#define HeightMMOfScreen(s) ((s)->mheight) -#define PlanesOfScreen(s) ((s)->root_depth) -#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) -#define MinCmapsOfScreen(s) ((s)->min_maps) -#define MaxCmapsOfScreen(s) ((s)->max_maps) -#define DoesSaveUnders(s) ((s)->save_unders) -#define DoesBackingStore(s) ((s)->backing_store) -#define EventMaskOfScreen(s) ((s)->root_input_mask) - -/* - * Extensions need a way to hang private data on some structures. - */ -typedef struct _XExtData { - int number; /* number returned by XRegisterExtension */ - struct _XExtData *next; /* next item on list of data for structure */ - int (*free_private)( /* called to free private storage */ - struct _XExtData *extension - ); - XPointer private_data; /* data private to this extension. */ -} XExtData; - -/* - * This file contains structures used by the extension mechanism. - */ -typedef struct { /* public to extension, cannot be changed */ - int extension; /* extension number */ - int major_opcode; /* major op-code assigned by server */ - int first_event; /* first event number for the extension */ - int first_error; /* first error number for the extension */ -} XExtCodes; - -/* - * Data structure for retrieving info about pixmap formats. - */ - -typedef struct { - int depth; - int bits_per_pixel; - int scanline_pad; -} XPixmapFormatValues; - - -/* - * Data structure for setting graphics context. - */ -typedef struct { - int function; /* logical operation */ - unsigned long plane_mask;/* plane mask */ - unsigned long foreground;/* foreground pixel */ - unsigned long background;/* background pixel */ - int line_width; /* line width */ - int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ - int cap_style; /* CapNotLast, CapButt, - CapRound, CapProjecting */ - int join_style; /* JoinMiter, JoinRound, JoinBevel */ - int fill_style; /* FillSolid, FillTiled, - FillStippled, FillOpaeueStippled */ - int fill_rule; /* EvenOddRule, WindingRule */ - int arc_mode; /* ArcChord, ArcPieSlice */ - Pixmap tile; /* tile pixmap for tiling operations */ - Pixmap stipple; /* stipple 1 plane pixmap for stipping */ - int ts_x_origin; /* offset for tile or stipple operations */ - int ts_y_origin; - Font font; /* default text font for text operations */ - int subwindow_mode; /* ClipByChildren, IncludeInferiors */ - Bool graphics_exposures;/* boolean, should exposures be generated */ - int clip_x_origin; /* origin for clipping */ - int clip_y_origin; - Pixmap clip_mask; /* bitmap clipping; other calls for rects */ - int dash_offset; /* patterned/dashed line information */ - char dashes; -} XGCValues; - -/* - * Graphics context. The contents of this structure are implementation - * dependent. A GC should be treated as opaque by application code. - */ - -typedef struct _XGC -#ifdef XLIB_ILLEGAL_ACCESS -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - /* there is more to this structure, but it is private to Xlib */ -} -#endif -*GC; - -/* - * Visual structure; contains information about colormapping possible. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - VisualID visualid; /* visual id of this visual */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ class of screen (monochrome, etc.) */ -#else - int class; /* class of screen (monochrome, etc.) */ -#endif - unsigned long red_mask, green_mask, blue_mask; /* mask values */ - int bits_per_rgb; /* log base 2 of distinct color values */ - int map_entries; /* color map entries */ -} Visual; - -/* - * Depth structure; contains information for each possible depth. - */ -typedef struct { - int depth; /* this depth (Z) of the depth */ - int nvisuals; /* number of Visual types at this depth */ - Visual *visuals; /* list of visuals possible at this depth */ -} Depth; - -/* - * Information about the screen. The contents of this structure are - * implementation dependent. A Screen should be treated as opaque - * by application code. - */ - -struct _XDisplay; /* Forward declare before use for C++ */ - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - struct _XDisplay *display;/* back pointer to display structure */ - Window root; /* Root window id. */ - int width, height; /* width and height of screen */ - int mwidth, mheight; /* width and height of in millimeters */ - int ndepths; /* number of depths possible */ - Depth *depths; /* list of allowable depths on the screen */ - int root_depth; /* bits per pixel */ - Visual *root_visual; /* root visual */ - GC default_gc; /* GC for the root root visual */ - Colormap cmap; /* default color map */ - unsigned long white_pixel; - unsigned long black_pixel; /* White and Black pixel values */ - int max_maps, min_maps; /* max and min color maps */ - int backing_store; /* Never, WhenMapped, Always */ - Bool save_unders; - long root_input_mask; /* initial root input mask */ -} Screen; - -/* - * Format structure; describes ZFormat data the screen will understand. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - int depth; /* depth of this image format */ - int bits_per_pixel; /* bits/pixel at this depth */ - int scanline_pad; /* scanline must padded to this multiple */ -} ScreenFormat; - -/* - * Data structure for setting window attributes. - */ -typedef struct { - Pixmap background_pixmap; /* background or None or ParentRelative */ - unsigned long background_pixel; /* background pixel */ - Pixmap border_pixmap; /* border of the window */ - unsigned long border_pixel; /* border pixel value */ - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preseved if possible */ - unsigned long backing_pixel;/* value to use in restoring planes */ - Bool save_under; /* should bits under be saved? (popups) */ - long event_mask; /* set of events that should be saved */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Colormap colormap; /* color map to be associated with window */ - Cursor cursor; /* cursor to be displayed (or None) */ -} XSetWindowAttributes; - -typedef struct { - int x, y; /* location of window */ - int width, height; /* width and height of window */ - int border_width; /* border width of window */ - int depth; /* depth of window */ - Visual *visual; /* the associated visual structure */ - Window root; /* root of screen containing window */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ InputOutput, InputOnly*/ -#else - int class; /* InputOutput, InputOnly*/ -#endif - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preserved if possible */ - unsigned long backing_pixel;/* value to be used when restoring planes */ - Bool save_under; /* boolean, should bits under be saved? */ - Colormap colormap; /* color map to be associated with window */ - Bool map_installed; /* boolean, is color map currently installed*/ - int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ - long all_event_masks; /* set of events all people have interest in*/ - long your_event_mask; /* my event mask */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Screen *screen; /* back pointer to correct screen */ -} XWindowAttributes; - -/* - * Data structure for host setting; getting routines. - * - */ - -typedef struct { - int family; /* for example FamilyInternet */ - int length; /* length of address, in bytes */ - char *address; /* pointer to where to find the bytes */ -} XHostAddress; - -/* - * Data structure for ServerFamilyInterpreted addresses in host routines - */ -typedef struct { - int typelength; /* length of type string, in bytes */ - int valuelength; /* length of value string, in bytes */ - char *type; /* pointer to where to find the type string */ - char *value; /* pointer to where to find the address */ -} XServerInterpretedAddress; - -/* - * Data structure for "image" data, used by image manipulation routines. - */ -typedef struct _XImage { - int width, height; /* size of image */ - int xoffset; /* number of pixels offset in X direction */ - int format; /* XYBitmap, XYPixmap, ZPixmap */ - char *data; /* pointer to image data */ - int byte_order; /* data byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* quant. of scanline 8, 16, 32 */ - int bitmap_bit_order; /* LSBFirst, MSBFirst */ - int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ - int depth; /* depth of image */ - int bytes_per_line; /* accelarator to next line */ - int bits_per_pixel; /* bits per pixel (ZPixmap) */ - unsigned long red_mask; /* bits in z arrangment */ - unsigned long green_mask; - unsigned long blue_mask; - XPointer obdata; /* hook for the object routines to hang on */ - struct funcs { /* image manipulation routines */ - struct _XImage *(*create_image)( - struct _XDisplay* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */); - int (*destroy_image) (struct _XImage *); - unsigned long (*get_pixel) (struct _XImage *, int, int); - int (*put_pixel) (struct _XImage *, int, int, unsigned long); - struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); - int (*add_pixel) (struct _XImage *, long); - } f; -} XImage; - -/* - * Data structure for XReconfigureWindow - */ -typedef struct { - int x, y; - int width, height; - int border_width; - Window sibling; - int stack_mode; -} XWindowChanges; - -/* - * Data structure used by color operations - */ -typedef struct { - unsigned long pixel; - unsigned short red, green, blue; - char flags; /* do_red, do_green, do_blue */ - char pad; -} XColor; - -/* - * Data structures for graphics operations. On most machines, these are - * congruent with the wire protocol structures, so reformatting the data - * can be avoided on these architectures. - */ -typedef struct { - short x1, y1, x2, y2; -} XSegment; - -typedef struct { - short x, y; -} XPoint; - -typedef struct { - short x, y; - unsigned short width, height; -} XRectangle; - -typedef struct { - short x, y; - unsigned short width, height; - short angle1, angle2; -} XArc; - - -/* Data structure for XChangeKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - int bell_pitch; - int bell_duration; - int led; - int led_mode; - int key; - int auto_repeat_mode; /* On, Off, Default */ -} XKeyboardControl; - -/* Data structure for XGetKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - unsigned int bell_pitch, bell_duration; - unsigned long led_mask; - int global_auto_repeat; - char auto_repeats[32]; -} XKeyboardState; - -/* Data structure for XGetMotionEvents. */ - -typedef struct { - Time time; - short x, y; -} XTimeCoord; - -/* Data structure for X{Set,Get}ModifierMapping */ - -typedef struct { - int max_keypermod; /* The server's max # of keys per modifier */ - KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ -} XModifierKeymap; - - -/* - * Display datatype maintaining display specific data. - * The contents of this structure are implementation dependent. - * A Display should be treated as opaque by application code. - */ -#ifndef XLIB_ILLEGAL_ACCESS -typedef struct _XDisplay Display; -#endif - -struct _XPrivate; /* Forward declare before use for C++ */ -struct _XrmHashBucketRec; - -typedef struct -#ifdef XLIB_ILLEGAL_ACCESS -_XDisplay -#endif -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XPrivate *private1; - int fd; /* Network socket. */ - int private2; - int proto_major_version;/* major version of server's X protocol */ - int proto_minor_version;/* minor version of servers X protocol */ - char *vendor; /* vendor of the server hardware */ - XID private3; - XID private4; - XID private5; - int private6; - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int private8; - int release; /* release of the server */ - struct _XPrivate *private9, *private10; - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - XPointer private11; - XPointer private12; - XPointer private13; - XPointer private14; - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*private15)( - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long private16; - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - XPointer private17; - XPointer private18; - int private19; - char *xdefaults; /* contents of defaults from server */ - /* there is more to this structure, but it is private to Xlib */ -} -#ifdef XLIB_ILLEGAL_ACCESS -Display, -#endif -*_XPrivDisplay; - -#undef _XEVENT_ -#ifndef _XEVENT_ -/* - * Definitions of specific events. - */ -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int keycode; /* detail */ - Bool same_screen; /* same screen flag */ -} XKeyEvent; -typedef XKeyEvent XKeyPressedEvent; -typedef XKeyEvent XKeyReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int button; /* detail */ - Bool same_screen; /* same screen flag */ -} XButtonEvent; -typedef XButtonEvent XButtonPressedEvent; -typedef XButtonEvent XButtonReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - char is_hint; /* detail */ - Bool same_screen; /* same screen flag */ -} XMotionEvent; -typedef XMotionEvent XPointerMovedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual - */ - Bool same_screen; /* same screen flag */ - Bool focus; /* boolean focus */ - unsigned int state; /* key or button mask */ -} XCrossingEvent; -typedef XCrossingEvent XEnterWindowEvent; -typedef XCrossingEvent XLeaveWindowEvent; - -typedef struct { - int type; /* FocusIn or FocusOut */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* window of event */ - int mode; /* NotifyNormal, NotifyWhileGrabbed, - NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, - * NotifyPointerRoot, NotifyDetailNone - */ -} XFocusChangeEvent; -typedef XFocusChangeEvent XFocusInEvent; -typedef XFocusChangeEvent XFocusOutEvent; - -/* generated on EnterWindow and FocusIn when KeyMapState selected */ -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - char key_vector[32]; -} XKeymapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ -} XExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XGraphicsExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XNoExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int state; /* Visibility state */ -} XVisibilityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; /* parent of the window */ - Window window; /* window id of window created */ - int x, y; /* window location */ - int width, height; /* size of window */ - int border_width; /* border width */ - Bool override_redirect; /* creation should be overridden */ -} XCreateWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; -} XDestroyWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool from_configure; -} XUnmapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool override_redirect; /* boolean, is override set... */ -} XMapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; -} XMapRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Window parent; - int x, y; - Bool override_redirect; -} XReparentEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - Bool override_redirect; -} XConfigureEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; -} XGravityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int width, height; -} XResizeRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - int detail; /* Above, Below, TopIf, BottomIf, Opposite */ - unsigned long value_mask; -} XConfigureRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom atom; - Time time; - int state; /* NewValue, Deleted */ -} XPropertyEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom selection; - Time time; -} XSelectionClearEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window owner; - Window requestor; - Atom selection; - Atom target; - Atom property; - Time time; -} XSelectionRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window requestor; - Atom selection; - Atom target; - Atom property; /* ATOM or None */ - Time time; -} XSelectionEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Colormap colormap; /* COLORMAP or None */ -#if defined(__cplusplus) || defined(c_plusplus) - Bool c_new; /* C++ */ -#else - Bool new; -#endif - int state; /* ColormapInstalled, ColormapUninstalled */ -} XColormapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom message_type; - int format; - union { - char b[20]; - short s[10]; - long l[5]; - } data; -} XClientMessageEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* unused */ - int request; /* one of MappingModifier, MappingKeyboard, - MappingPointer */ - int first_keycode; /* first keycode */ - int count; /* defines range of change w. first_keycode*/ -} XMappingEvent; - -typedef struct { - int type; - Display *display; /* Display the event was read from */ - XID resourceid; /* resource id */ - unsigned long serial; /* serial number of failed request */ - unsigned char error_code; /* error code of failed request */ - unsigned char request_code; /* Major op-code of failed request */ - unsigned char minor_code; /* Minor op-code of failed request */ -} XErrorEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display;/* Display the event was read from */ - Window window; /* window on which event was requested in event mask */ -} XAnyEvent; - -/* - * this union is defined so Xlib can always use the same sized - * event structure internally, to avoid memory fragmentation. - */ -typedef union _XEvent { - int type; /* must not be changed; first element */ - XAnyEvent xany; - XKeyEvent xkey; - XButtonEvent xbutton; - XMotionEvent xmotion; - XCrossingEvent xcrossing; - XFocusChangeEvent xfocus; - XExposeEvent xexpose; - XGraphicsExposeEvent xgraphicsexpose; - XNoExposeEvent xnoexpose; - XVisibilityEvent xvisibility; - XCreateWindowEvent xcreatewindow; - XDestroyWindowEvent xdestroywindow; - XUnmapEvent xunmap; - XMapEvent xmap; - XMapRequestEvent xmaprequest; - XReparentEvent xreparent; - XConfigureEvent xconfigure; - XGravityEvent xgravity; - XResizeRequestEvent xresizerequest; - XConfigureRequestEvent xconfigurerequest; - XCirculateEvent xcirculate; - XCirculateRequestEvent xcirculaterequest; - XPropertyEvent xproperty; - XSelectionClearEvent xselectionclear; - XSelectionRequestEvent xselectionrequest; - XSelectionEvent xselection; - XColormapEvent xcolormap; - XClientMessageEvent xclient; - XMappingEvent xmapping; - XErrorEvent xerror; - XKeymapEvent xkeymap; - long pad[24]; -} XEvent; -#endif - -#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) - -/* - * per character font metric information. - */ -typedef struct { - short lbearing; /* origin to left edge of raster */ - short rbearing; /* origin to right edge of raster */ - short width; /* advance to next char's origin */ - short ascent; /* baseline to top edge of raster */ - short descent; /* baseline to bottom edge of raster */ - unsigned short attributes; /* per char flags (not predefined) */ -} XCharStruct; - -/* - * To allow arbitrary information with fonts, there are additional properties - * returned. - */ -typedef struct { - Atom name; - unsigned long card32; -} XFontProp; - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - Font fid; /* Font id for this font */ - unsigned direction; /* hint about direction the font is painted */ - unsigned min_char_or_byte2;/* first character */ - unsigned max_char_or_byte2;/* last character */ - unsigned min_byte1; /* first row that exists */ - unsigned max_byte1; /* last row that exists */ - Bool all_chars_exist;/* flag if all characters have non-zero size*/ - unsigned default_char; /* char to print for undefined character */ - int n_properties; /* how many properties there are */ - XFontProp *properties; /* pointer to array of additional properties*/ - XCharStruct min_bounds; /* minimum bounds over all existing char*/ - XCharStruct max_bounds; /* maximum bounds over all existing char*/ - XCharStruct *per_char; /* first_char to last_char information */ - int ascent; /* log. extent above baseline for spacing */ - int descent; /* log. descent below baseline for spacing */ -} XFontStruct; - -/* - * PolyText routines take these as arguments. - */ -typedef struct { - char *chars; /* pointer to string */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem; - -typedef struct { /* normal 16 bit characters are two bytes */ - unsigned char byte1; - unsigned char byte2; -} XChar2b; - -typedef struct { - XChar2b *chars; /* two byte characters */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem16; - - -typedef union { Display *display; - GC gc; - Visual *visual; - Screen *screen; - ScreenFormat *pixmap_format; - XFontStruct *font; } XEDataObject; - -typedef struct { - XRectangle max_ink_extent; - XRectangle max_logical_extent; -} XFontSetExtents; - -/* unused: -typedef void (*XOMProc)(); - */ - -typedef struct _XOM *XOM; -typedef struct _XOC *XOC, *XFontSet; - -typedef struct { - char *chars; - int nchars; - int delta; - XFontSet font_set; -} XmbTextItem; - -typedef struct { - wchar_t *chars; - int nchars; - int delta; - XFontSet font_set; -} XwcTextItem; - -#define XNRequiredCharSet "requiredCharSet" -#define XNQueryOrientation "queryOrientation" -#define XNBaseFontName "baseFontName" -#define XNOMAutomatic "omAutomatic" -#define XNMissingCharSet "missingCharSet" -#define XNDefaultString "defaultString" -#define XNOrientation "orientation" -#define XNDirectionalDependentDrawing "directionalDependentDrawing" -#define XNContextualDrawing "contextualDrawing" -#define XNFontInfo "fontInfo" - -typedef struct { - int charset_count; - char **charset_list; -} XOMCharSetList; - -typedef enum { - XOMOrientation_LTR_TTB, - XOMOrientation_RTL_TTB, - XOMOrientation_TTB_LTR, - XOMOrientation_TTB_RTL, - XOMOrientation_Context -} XOrientation; - -typedef struct { - int num_orientation; - XOrientation *orientation; /* Input Text description */ -} XOMOrientation; - -typedef struct { - int num_font; - XFontStruct **font_struct_list; - char **font_name_list; -} XOMFontInfo; - -typedef struct _XIM *XIM; -typedef struct _XIC *XIC; - -typedef void (*XIMProc)( - XIM, - XPointer, - XPointer -); - -typedef Bool (*XICProc)( - XIC, - XPointer, - XPointer -); - -typedef void (*XIDProc)( - Display*, - XPointer, - XPointer -); - -typedef unsigned long XIMStyle; - -typedef struct { - unsigned short count_styles; - XIMStyle *supported_styles; -} XIMStyles; - -#define XIMPreeditArea 0x0001L -#define XIMPreeditCallbacks 0x0002L -#define XIMPreeditPosition 0x0004L -#define XIMPreeditNothing 0x0008L -#define XIMPreeditNone 0x0010L -#define XIMStatusArea 0x0100L -#define XIMStatusCallbacks 0x0200L -#define XIMStatusNothing 0x0400L -#define XIMStatusNone 0x0800L - -#define XNVaNestedList "XNVaNestedList" -#define XNQueryInputStyle "queryInputStyle" -#define XNClientWindow "clientWindow" -#define XNInputStyle "inputStyle" -#define XNFocusWindow "focusWindow" -#define XNResourceName "resourceName" -#define XNResourceClass "resourceClass" -#define XNGeometryCallback "geometryCallback" -#define XNDestroyCallback "destroyCallback" -#define XNFilterEvents "filterEvents" -#define XNPreeditStartCallback "preeditStartCallback" -#define XNPreeditDoneCallback "preeditDoneCallback" -#define XNPreeditDrawCallback "preeditDrawCallback" -#define XNPreeditCaretCallback "preeditCaretCallback" -#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" -#define XNPreeditAttributes "preeditAttributes" -#define XNStatusStartCallback "statusStartCallback" -#define XNStatusDoneCallback "statusDoneCallback" -#define XNStatusDrawCallback "statusDrawCallback" -#define XNStatusAttributes "statusAttributes" -#define XNArea "area" -#define XNAreaNeeded "areaNeeded" -#define XNSpotLocation "spotLocation" -#define XNColormap "colorMap" -#define XNStdColormap "stdColorMap" -#define XNForeground "foreground" -#define XNBackground "background" -#define XNBackgroundPixmap "backgroundPixmap" -#define XNFontSet "fontSet" -#define XNLineSpace "lineSpace" -#define XNCursor "cursor" - -#define XNQueryIMValuesList "queryIMValuesList" -#define XNQueryICValuesList "queryICValuesList" -#define XNVisiblePosition "visiblePosition" -#define XNR6PreeditCallback "r6PreeditCallback" -#define XNStringConversionCallback "stringConversionCallback" -#define XNStringConversion "stringConversion" -#define XNResetState "resetState" -#define XNHotKey "hotKey" -#define XNHotKeyState "hotKeyState" -#define XNPreeditState "preeditState" -#define XNSeparatorofNestedList "separatorofNestedList" - -#define XBufferOverflow -1 -#define XLookupNone 1 -#define XLookupChars 2 -#define XLookupKeySym 3 -#define XLookupBoth 4 - -typedef void *XVaNestedList; - -typedef struct { - XPointer client_data; - XIMProc callback; -} XIMCallback; - -typedef struct { - XPointer client_data; - XICProc callback; -} XICCallback; - -typedef unsigned long XIMFeedback; - -#define XIMReverse 1L -#define XIMUnderline (1L<<1) -#define XIMHighlight (1L<<2) -#define XIMPrimary (1L<<5) -#define XIMSecondary (1L<<6) -#define XIMTertiary (1L<<7) -#define XIMVisibleToForward (1L<<8) -#define XIMVisibleToBackword (1L<<9) -#define XIMVisibleToCenter (1L<<10) - -typedef struct _XIMText { - unsigned short length; - XIMFeedback *feedback; - Bool encoding_is_wchar; - union { - char *multi_byte; - wchar_t *wide_char; - } string; -} XIMText; - -typedef unsigned long XIMPreeditState; - -#define XIMPreeditUnKnown 0L -#define XIMPreeditEnable 1L -#define XIMPreeditDisable (1L<<1) - -typedef struct _XIMPreeditStateNotifyCallbackStruct { - XIMPreeditState state; -} XIMPreeditStateNotifyCallbackStruct; - -typedef unsigned long XIMResetState; - -#define XIMInitialState 1L -#define XIMPreserveState (1L<<1) - -typedef unsigned long XIMStringConversionFeedback; - -#define XIMStringConversionLeftEdge (0x00000001) -#define XIMStringConversionRightEdge (0x00000002) -#define XIMStringConversionTopEdge (0x00000004) -#define XIMStringConversionBottomEdge (0x00000008) -#define XIMStringConversionConcealed (0x00000010) -#define XIMStringConversionWrapped (0x00000020) - -typedef struct _XIMStringConversionText { - unsigned short length; - XIMStringConversionFeedback *feedback; - Bool encoding_is_wchar; - union { - char *mbs; - wchar_t *wcs; - } string; -} XIMStringConversionText; - -typedef unsigned short XIMStringConversionPosition; - -typedef unsigned short XIMStringConversionType; - -#define XIMStringConversionBuffer (0x0001) -#define XIMStringConversionLine (0x0002) -#define XIMStringConversionWord (0x0003) -#define XIMStringConversionChar (0x0004) - -typedef unsigned short XIMStringConversionOperation; - -#define XIMStringConversionSubstitution (0x0001) -#define XIMStringConversionRetrieval (0x0002) - -typedef enum { - XIMForwardChar, XIMBackwardChar, - XIMForwardWord, XIMBackwardWord, - XIMCaretUp, XIMCaretDown, - XIMNextLine, XIMPreviousLine, - XIMLineStart, XIMLineEnd, - XIMAbsolutePosition, - XIMDontChange -} XIMCaretDirection; - -typedef struct _XIMStringConversionCallbackStruct { - XIMStringConversionPosition position; - XIMCaretDirection direction; - XIMStringConversionOperation operation; - unsigned short factor; - XIMStringConversionText *text; -} XIMStringConversionCallbackStruct; - -typedef struct _XIMPreeditDrawCallbackStruct { - int caret; /* Cursor offset within pre-edit string */ - int chg_first; /* Starting change position */ - int chg_length; /* Length of the change in character count */ - XIMText *text; -} XIMPreeditDrawCallbackStruct; - -typedef enum { - XIMIsInvisible, /* Disable caret feedback */ - XIMIsPrimary, /* UI defined caret feedback */ - XIMIsSecondary /* UI defined caret feedback */ -} XIMCaretStyle; - -typedef struct _XIMPreeditCaretCallbackStruct { - int position; /* Caret offset within pre-edit string */ - XIMCaretDirection direction; /* Caret moves direction */ - XIMCaretStyle style; /* Feedback of the caret */ -} XIMPreeditCaretCallbackStruct; - -typedef enum { - XIMTextType, - XIMBitmapType -} XIMStatusDataType; - -typedef struct _XIMStatusDrawCallbackStruct { - XIMStatusDataType type; - union { - XIMText *text; - Pixmap bitmap; - } data; -} XIMStatusDrawCallbackStruct; - -typedef struct _XIMHotKeyTrigger { - KeySym keysym; - int modifier; - int modifier_mask; -} XIMHotKeyTrigger; - -typedef struct _XIMHotKeyTriggers { - int num_hot_key; - XIMHotKeyTrigger *key; -} XIMHotKeyTriggers; - -typedef unsigned long XIMHotKeyState; - -#define XIMHotKeyStateON (0x0001L) -#define XIMHotKeyStateOFF (0x0002L) - -typedef struct { - unsigned short count_values; - char **supported_values; -} XIMValuesList; - -_XFUNCPROTOBEGIN - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _Xdebug (*_Xdebug_p) -#endif - -extern int _Xdebug; - -extern XFontStruct *XLoadQueryFont( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XFontStruct *XQueryFont( - Display* /* display */, - XID /* font_ID */ -); - - -extern XTimeCoord *XGetMotionEvents( - Display* /* display */, - Window /* w */, - Time /* start */, - Time /* stop */, - int* /* nevents_return */ -); - -extern XModifierKeymap *XDeleteModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XGetModifierMapping( - Display* /* display */ -); - -extern XModifierKeymap *XInsertModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XNewModifiermap( - int /* max_keys_per_mod */ -); - -extern XImage *XCreateImage( - Display* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */ -); -extern Status XInitImage( - XImage* /* image */ -); -extern XImage *XGetImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */ -); -extern XImage *XGetSubImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */, - XImage* /* dest_image */, - int /* dest_x */, - int /* dest_y */ -); - -/* - * X function declarations. - */ -extern Display *XOpenDisplay( - _Xconst char* /* display_name */ -); - -extern void XrmInitialize( - void -); - -extern char *XFetchBytes( - Display* /* display */, - int* /* nbytes_return */ -); -extern char *XFetchBuffer( - Display* /* display */, - int* /* nbytes_return */, - int /* buffer */ -); -extern char *XGetAtomName( - Display* /* display */, - Atom /* atom */ -); -extern Status XGetAtomNames( - Display* /* dpy */, - Atom* /* atoms */, - int /* count */, - char** /* names_return */ -); -extern char *XGetDefault( - Display* /* display */, - _Xconst char* /* program */, - _Xconst char* /* option */ -); -extern char *XDisplayName( - _Xconst char* /* string */ -); -extern char *XKeysymToString( - KeySym /* keysym */ -); - -extern int (*XSynchronize( - Display* /* display */, - Bool /* onoff */ -))( - Display* /* display */ -); -extern int (*XSetAfterFunction( - Display* /* display */, - int (*) ( - Display* /* display */ - ) /* procedure */ -))( - Display* /* display */ -); -extern Atom XInternAtom( - Display* /* display */, - _Xconst char* /* atom_name */, - Bool /* only_if_exists */ -); -extern Status XInternAtoms( - Display* /* dpy */, - char** /* names */, - int /* count */, - Bool /* onlyIfExists */, - Atom* /* atoms_return */ -); -extern Colormap XCopyColormapAndFree( - Display* /* display */, - Colormap /* colormap */ -); -extern Colormap XCreateColormap( - Display* /* display */, - Window /* w */, - Visual* /* visual */, - int /* alloc */ -); -extern Cursor XCreatePixmapCursor( - Display* /* display */, - Pixmap /* source */, - Pixmap /* mask */, - XColor* /* foreground_color */, - XColor* /* background_color */, - unsigned int /* x */, - unsigned int /* y */ -); -extern Cursor XCreateGlyphCursor( - Display* /* display */, - Font /* source_font */, - Font /* mask_font */, - unsigned int /* source_char */, - unsigned int /* mask_char */, - XColor _Xconst * /* foreground_color */, - XColor _Xconst * /* background_color */ -); -extern Cursor XCreateFontCursor( - Display* /* display */, - unsigned int /* shape */ -); -extern Font XLoadFont( - Display* /* display */, - _Xconst char* /* name */ -); -extern GC XCreateGC( - Display* /* display */, - Drawable /* d */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); -extern GContext XGContextFromGC( - GC /* gc */ -); -extern void XFlushGC( - Display* /* display */, - GC /* gc */ -); -extern Pixmap XCreatePixmap( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* depth */ -); -extern Pixmap XCreateBitmapFromData( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* data */, - unsigned int /* width */, - unsigned int /* height */ -); -extern Pixmap XCreatePixmapFromBitmapData( - Display* /* display */, - Drawable /* d */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* fg */, - unsigned long /* bg */, - unsigned int /* depth */ -); -extern Window XCreateSimpleWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - unsigned long /* border */, - unsigned long /* background */ -); -extern Window XGetSelectionOwner( - Display* /* display */, - Atom /* selection */ -); -extern Window XCreateWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - int /* depth */, - unsigned int /* class */, - Visual* /* visual */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); -extern Colormap *XListInstalledColormaps( - Display* /* display */, - Window /* w */, - int* /* num_return */ -); -extern char **XListFonts( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* actual_count_return */ -); -extern char **XListFontsWithInfo( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* count_return */, - XFontStruct** /* info_return */ -); -extern char **XGetFontPath( - Display* /* display */, - int* /* npaths_return */ -); -extern char **XListExtensions( - Display* /* display */, - int* /* nextensions_return */ -); -extern Atom *XListProperties( - Display* /* display */, - Window /* w */, - int* /* num_prop_return */ -); -extern XHostAddress *XListHosts( - Display* /* display */, - int* /* nhosts_return */, - Bool* /* state_return */ -); -extern KeySym XKeycodeToKeysym( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* keycode */, -#else - KeyCode /* keycode */, -#endif - int /* index */ -); -extern KeySym XLookupKeysym( - XKeyEvent* /* key_event */, - int /* index */ -); -extern KeySym *XGetKeyboardMapping( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* first_keycode */, -#else - KeyCode /* first_keycode */, -#endif - int /* keycode_count */, - int* /* keysyms_per_keycode_return */ -); -extern KeySym XStringToKeysym( - _Xconst char* /* string */ -); -extern long XMaxRequestSize( - Display* /* display */ -); -extern long XExtendedMaxRequestSize( - Display* /* display */ -); -extern char *XResourceManagerString( - Display* /* display */ -); -extern char *XScreenResourceString( - Screen* /* screen */ -); -extern unsigned long XDisplayMotionBufferSize( - Display* /* display */ -); -extern VisualID XVisualIDFromVisual( - Visual* /* visual */ -); - -/* multithread routines */ - -extern Status XInitThreads( - void -); - -extern void XLockDisplay( - Display* /* display */ -); - -extern void XUnlockDisplay( - Display* /* display */ -); - -/* routines for dealing with extensions */ - -extern XExtCodes *XInitExtension( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XExtCodes *XAddExtension( - Display* /* display */ -); -extern XExtData *XFindOnExtensionList( - XExtData** /* structure */, - int /* number */ -); -extern XExtData **XEHeadOfExtensionList( - XEDataObject /* object */ -); - -/* these are routines for which there are also macros */ -extern Window XRootWindow( - Display* /* display */, - int /* screen_number */ -); -extern Window XDefaultRootWindow( - Display* /* display */ -); -extern Window XRootWindowOfScreen( - Screen* /* screen */ -); -extern Visual *XDefaultVisual( - Display* /* display */, - int /* screen_number */ -); -extern Visual *XDefaultVisualOfScreen( - Screen* /* screen */ -); -extern GC XDefaultGC( - Display* /* display */, - int /* screen_number */ -); -extern GC XDefaultGCOfScreen( - Screen* /* screen */ -); -extern unsigned long XBlackPixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XWhitePixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XAllPlanes( - void -); -extern unsigned long XBlackPixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XWhitePixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XNextRequest( - Display* /* display */ -); -extern unsigned long XLastKnownRequestProcessed( - Display* /* display */ -); -extern char *XServerVendor( - Display* /* display */ -); -extern char *XDisplayString( - Display* /* display */ -); -extern Colormap XDefaultColormap( - Display* /* display */, - int /* screen_number */ -); -extern Colormap XDefaultColormapOfScreen( - Screen* /* screen */ -); -extern Display *XDisplayOfScreen( - Screen* /* screen */ -); -extern Screen *XScreenOfDisplay( - Display* /* display */, - int /* screen_number */ -); -extern Screen *XDefaultScreenOfDisplay( - Display* /* display */ -); -extern long XEventMaskOfScreen( - Screen* /* screen */ -); - -extern int XScreenNumberOfScreen( - Screen* /* screen */ -); - -typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */, - XErrorEvent* /* error_event */ -); - -extern XErrorHandler XSetErrorHandler ( - XErrorHandler /* handler */ -); - - -typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */ -); - -extern XIOErrorHandler XSetIOErrorHandler ( - XIOErrorHandler /* handler */ -); - - -extern XPixmapFormatValues *XListPixmapFormats( - Display* /* display */, - int* /* count_return */ -); -extern int *XListDepths( - Display* /* display */, - int /* screen_number */, - int* /* count_return */ -); - -/* ICCCM routines for things that don't require special include files; */ -/* other declarations are given in Xutil.h */ -extern Status XReconfigureWMWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */, - unsigned int /* mask */, - XWindowChanges* /* changes */ -); - -extern Status XGetWMProtocols( - Display* /* display */, - Window /* w */, - Atom** /* protocols_return */, - int* /* count_return */ -); -extern Status XSetWMProtocols( - Display* /* display */, - Window /* w */, - Atom* /* protocols */, - int /* count */ -); -extern Status XIconifyWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XWithdrawWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XGetCommand( - Display* /* display */, - Window /* w */, - char*** /* argv_return */, - int* /* argc_return */ -); -extern Status XGetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window** /* windows_return */, - int* /* count_return */ -); -extern Status XSetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window* /* colormap_windows */, - int /* count */ -); -extern void XFreeStringList( - char** /* list */ -); -extern int XSetTransientForHint( - Display* /* display */, - Window /* w */, - Window /* prop_window */ -); - -/* The following are given in alphabetical order */ - -extern int XActivateScreenSaver( - Display* /* display */ -); - -extern int XAddHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XAddHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XAddToExtensionList( - struct _XExtData** /* structure */, - XExtData* /* ext_data */ -); - -extern int XAddToSaveSet( - Display* /* display */, - Window /* w */ -); - -extern Status XAllocColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* screen_in_out */ -); - -extern Status XAllocColorCells( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* plane_masks_return */, - unsigned int /* nplanes */, - unsigned long* /* pixels_return */, - unsigned int /* npixels */ -); - -extern Status XAllocColorPlanes( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* pixels_return */, - int /* ncolors */, - int /* nreds */, - int /* ngreens */, - int /* nblues */, - unsigned long* /* rmask_return */, - unsigned long* /* gmask_return */, - unsigned long* /* bmask_return */ -); - -extern Status XAllocNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* screen_def_return */, - XColor* /* exact_def_return */ -); - -extern int XAllowEvents( - Display* /* display */, - int /* event_mode */, - Time /* time */ -); - -extern int XAutoRepeatOff( - Display* /* display */ -); - -extern int XAutoRepeatOn( - Display* /* display */ -); - -extern int XBell( - Display* /* display */, - int /* percent */ -); - -extern int XBitmapBitOrder( - Display* /* display */ -); - -extern int XBitmapPad( - Display* /* display */ -); - -extern int XBitmapUnit( - Display* /* display */ -); - -extern int XCellsOfScreen( - Screen* /* screen */ -); - -extern int XChangeActivePointerGrab( - Display* /* display */, - unsigned int /* event_mask */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XChangeGC( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); - -extern int XChangeKeyboardControl( - Display* /* display */, - unsigned long /* value_mask */, - XKeyboardControl* /* values */ -); - -extern int XChangeKeyboardMapping( - Display* /* display */, - int /* first_keycode */, - int /* keysyms_per_keycode */, - KeySym* /* keysyms */, - int /* num_codes */ -); - -extern int XChangePointerControl( - Display* /* display */, - Bool /* do_accel */, - Bool /* do_threshold */, - int /* accel_numerator */, - int /* accel_denominator */, - int /* threshold */ -); - -extern int XChangeProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - Atom /* type */, - int /* format */, - int /* mode */, - _Xconst unsigned char* /* data */, - int /* nelements */ -); - -extern int XChangeSaveSet( - Display* /* display */, - Window /* w */, - int /* change_mode */ -); - -extern int XChangeWindowAttributes( - Display* /* display */, - Window /* w */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); - -extern Bool XCheckIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -#ifdef NX_TRANS_SOCKET - -/* - * This is just like XCheckIfEvent() but doesn't - * flush the output buffer if it can't read new - * events. - */ - -extern Bool XCheckIfEventNoFlush( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -#endif - -extern Bool XCheckMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedEvent( - Display* /* display */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedWindowEvent( - Display* /* display */, - Window /* w */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XCirculateSubwindows( - Display* /* display */, - Window /* w */, - int /* direction */ -); - -extern int XCirculateSubwindowsDown( - Display* /* display */, - Window /* w */ -); - -extern int XCirculateSubwindowsUp( - Display* /* display */, - Window /* w */ -); - -extern int XClearArea( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - Bool /* exposures */ -); - -extern int XClearWindow( - Display* /* display */, - Window /* w */ -); - -extern int XCloseDisplay( - Display* /* display */ -); - -extern int XConfigureWindow( - Display* /* display */, - Window /* w */, - unsigned int /* value_mask */, - XWindowChanges* /* values */ -); - -extern int XConnectionNumber( - Display* /* display */ -); - -extern int XConvertSelection( - Display* /* display */, - Atom /* selection */, - Atom /* target */, - Atom /* property */, - Window /* requestor */, - Time /* time */ -); - -extern int XCopyArea( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XCopyGC( - Display* /* display */, - GC /* src */, - unsigned long /* valuemask */, - GC /* dest */ -); - -extern int XCopyPlane( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */, - unsigned long /* plane */ -); - -extern int XDefaultDepth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDefaultDepthOfScreen( - Screen* /* screen */ -); - -extern int XDefaultScreen( - Display* /* display */ -); - -extern int XDefineCursor( - Display* /* display */, - Window /* w */, - Cursor /* cursor */ -); - -extern int XDeleteProperty( - Display* /* display */, - Window /* w */, - Atom /* property */ -); - -extern int XDestroyWindow( - Display* /* display */, - Window /* w */ -); - -extern int XDestroySubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XDoesBackingStore( - Screen* /* screen */ -); - -extern Bool XDoesSaveUnders( - Screen* /* screen */ -); - -extern int XDisableAccessControl( - Display* /* display */ -); - - -extern int XDisplayCells( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeight( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeightMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayKeycodes( - Display* /* display */, - int* /* min_keycodes_return */, - int* /* max_keycodes_return */ -); - -extern int XDisplayPlanes( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidthMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDrawArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XDrawArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XDrawImageString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawImageString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawLine( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x1 */, - int /* y1 */, - int /* x2 */, - int /* y2 */ -); - -extern int XDrawLines( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawPoint( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */ -); - -extern int XDrawPoints( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XDrawRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XDrawSegments( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XSegment* /* segments */, - int /* nsegments */ -); - -extern int XDrawString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem* /* items */, - int /* nitems */ -); - -extern int XDrawText16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem16* /* items */, - int /* nitems */ -); - -extern int XEnableAccessControl( - Display* /* display */ -); - -extern int XEventsQueued( - Display* /* display */, - int /* mode */ -); - -extern Status XFetchName( - Display* /* display */, - Window /* w */, - char** /* window_name_return */ -); - -extern int XFillArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XFillArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XFillPolygon( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* shape */, - int /* mode */ -); - -extern int XFillRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XFillRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XFlush( - Display* /* display */ -); - -extern int XForceScreenSaver( - Display* /* display */, - int /* mode */ -); - -extern int XFree( - void* /* data */ -); - -extern int XFreeColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XFreeColors( - Display* /* display */, - Colormap /* colormap */, - unsigned long* /* pixels */, - int /* npixels */, - unsigned long /* planes */ -); - -extern int XFreeCursor( - Display* /* display */, - Cursor /* cursor */ -); - -extern int XFreeExtensionList( - char** /* list */ -); - -extern int XFreeFont( - Display* /* display */, - XFontStruct* /* font_struct */ -); - -extern int XFreeFontInfo( - char** /* names */, - XFontStruct* /* free_info */, - int /* actual_count */ -); - -extern int XFreeFontNames( - char** /* list */ -); - -extern int XFreeFontPath( - char** /* list */ -); - -extern int XFreeGC( - Display* /* display */, - GC /* gc */ -); - -extern int XFreeModifiermap( - XModifierKeymap* /* modmap */ -); - -extern int XFreePixmap( - Display* /* display */, - Pixmap /* pixmap */ -); - -extern int XGeometry( - Display* /* display */, - int /* screen */, - _Xconst char* /* position */, - _Xconst char* /* default_position */, - unsigned int /* bwidth */, - unsigned int /* fwidth */, - unsigned int /* fheight */, - int /* xadder */, - int /* yadder */, - int* /* x_return */, - int* /* y_return */, - int* /* width_return */, - int* /* height_return */ -); - -extern int XGetErrorDatabaseText( - Display* /* display */, - _Xconst char* /* name */, - _Xconst char* /* message */, - _Xconst char* /* default_string */, - char* /* buffer_return */, - int /* length */ -); - -extern int XGetErrorText( - Display* /* display */, - int /* code */, - char* /* buffer_return */, - int /* length */ -); - -extern Bool XGetFontProperty( - XFontStruct* /* font_struct */, - Atom /* atom */, - unsigned long* /* value_return */ -); - -extern Status XGetGCValues( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values_return */ -); - -extern Status XGetGeometry( - Display* /* display */, - Drawable /* d */, - Window* /* root_return */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned int* /* border_width_return */, - unsigned int* /* depth_return */ -); - -extern Status XGetIconName( - Display* /* display */, - Window /* w */, - char** /* icon_name_return */ -); - -extern int XGetInputFocus( - Display* /* display */, - Window* /* focus_return */, - int* /* revert_to_return */ -); - -extern int XGetKeyboardControl( - Display* /* display */, - XKeyboardState* /* values_return */ -); - -extern int XGetPointerControl( - Display* /* display */, - int* /* accel_numerator_return */, - int* /* accel_denominator_return */, - int* /* threshold_return */ -); - -extern int XGetPointerMapping( - Display* /* display */, - unsigned char* /* map_return */, - int /* nmap */ -); - -extern int XGetScreenSaver( - Display* /* display */, - int* /* timeout_return */, - int* /* interval_return */, - int* /* prefer_blanking_return */, - int* /* allow_exposures_return */ -); - -extern Status XGetTransientForHint( - Display* /* display */, - Window /* w */, - Window* /* prop_window_return */ -); - -extern int XGetWindowProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - long /* long_offset */, - long /* long_length */, - Bool /* delete */, - Atom /* req_type */, - Atom* /* actual_type_return */, - int* /* actual_format_return */, - unsigned long* /* nitems_return */, - unsigned long* /* bytes_after_return */, - unsigned char** /* prop_return */ -); - -extern Status XGetWindowAttributes( - Display* /* display */, - Window /* w */, - XWindowAttributes* /* window_attributes_return */ -); - -extern int XGrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */ -); - -extern int XGrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */ -); - -extern int XGrabKeyboard( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */, - Time /* time */ -); - -extern int XGrabPointer( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XGrabServer( - Display* /* display */ -); - -extern int XHeightMMOfScreen( - Screen* /* screen */ -); - -extern int XHeightOfScreen( - Screen* /* screen */ -); - -extern int XIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XImageByteOrder( - Display* /* display */ -); - -extern int XInstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern KeyCode XKeysymToKeycode( - Display* /* display */, - KeySym /* keysym */ -); - -extern int XKillClient( - Display* /* display */, - XID /* resource */ -); - -extern Status XLookupColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* exact_def_return */, - XColor* /* screen_def_return */ -); - -extern int XLowerWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMapRaised( - Display* /* display */, - Window /* w */ -); - -extern int XMapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XMapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XMaxCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMinCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMoveResizeWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XMoveWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */ -); - -extern int XNextEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XNoOp( - Display* /* display */ -); - -extern Status XParseColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* spec */, - XColor* /* exact_def_return */ -); - -extern int XParseGeometry( - _Xconst char* /* parsestring */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XPeekEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XPeekIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XPending( - Display* /* display */ -); - -extern int XPlanesOfScreen( - Screen* /* screen */ -); - -extern int XProtocolRevision( - Display* /* display */ -); - -extern int XProtocolVersion( - Display* /* display */ -); - - -extern int XPutBackEvent( - Display* /* display */, - XEvent* /* event */ -); - -extern int XPutImage( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XImage* /* image */, - int /* src_x */, - int /* src_y */, - int /* dest_x */, - int /* dest_y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XQLength( - Display* /* display */ -); - -extern Status XQueryBestCursor( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestSize( - Display* /* display */, - int /* class */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestStipple( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestTile( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XQueryColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* def_in_out */ -); - -extern int XQueryColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* defs_in_out */, - int /* ncolors */ -); - -extern Bool XQueryExtension( - Display* /* display */, - _Xconst char* /* name */, - int* /* major_opcode_return */, - int* /* first_event_return */, - int* /* first_error_return */ -); - -extern int XQueryKeymap( - Display* /* display */, - char [32] /* keys_return */ -); - -extern Bool XQueryPointer( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* child_return */, - int* /* root_x_return */, - int* /* root_y_return */, - int* /* win_x_return */, - int* /* win_y_return */, - unsigned int* /* mask_return */ -); - -extern int XQueryTextExtents( - Display* /* display */, - XID /* font_ID */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XQueryTextExtents16( - Display* /* display */, - XID /* font_ID */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern Status XQueryTree( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* parent_return */, - Window** /* children_return */, - unsigned int* /* nchildren_return */ -); - -extern int XRaiseWindow( - Display* /* display */, - Window /* w */ -); - -extern int XReadBitmapFile( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - Pixmap* /* bitmap_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XReadBitmapFileData( - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned char** /* data_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XRebindKeysym( - Display* /* display */, - KeySym /* keysym */, - KeySym* /* list */, - int /* mod_count */, - _Xconst unsigned char* /* string */, - int /* bytes_string */ -); - -extern int XRecolorCursor( - Display* /* display */, - Cursor /* cursor */, - XColor* /* foreground_color */, - XColor* /* background_color */ -); - -extern int XRefreshKeyboardMapping( - XMappingEvent* /* event_map */ -); - -extern int XRemoveFromSaveSet( - Display* /* display */, - Window /* w */ -); - -extern int XRemoveHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XRemoveHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XReparentWindow( - Display* /* display */, - Window /* w */, - Window /* parent */, - int /* x */, - int /* y */ -); - -extern int XResetScreenSaver( - Display* /* display */ -); - -extern int XResizeWindow( - Display* /* display */, - Window /* w */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XRestackWindows( - Display* /* display */, - Window* /* windows */, - int /* nwindows */ -); - -extern int XRotateBuffers( - Display* /* display */, - int /* rotate */ -); - -extern int XRotateWindowProperties( - Display* /* display */, - Window /* w */, - Atom* /* properties */, - int /* num_prop */, - int /* npositions */ -); - -extern int XScreenCount( - Display* /* display */ -); - -extern int XSelectInput( - Display* /* display */, - Window /* w */, - long /* event_mask */ -); - -extern Status XSendEvent( - Display* /* display */, - Window /* w */, - Bool /* propagate */, - long /* event_mask */, - XEvent* /* event_send */ -); - -extern int XSetAccessControl( - Display* /* display */, - int /* mode */ -); - -extern int XSetArcMode( - Display* /* display */, - GC /* gc */, - int /* arc_mode */ -); - -extern int XSetBackground( - Display* /* display */, - GC /* gc */, - unsigned long /* background */ -); - -extern int XSetClipMask( - Display* /* display */, - GC /* gc */, - Pixmap /* pixmap */ -); - -extern int XSetClipOrigin( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */ -); - -extern int XSetClipRectangles( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */, - XRectangle* /* rectangles */, - int /* n */, - int /* ordering */ -); - -extern int XSetCloseDownMode( - Display* /* display */, - int /* close_mode */ -); - -extern int XSetCommand( - Display* /* display */, - Window /* w */, - char** /* argv */, - int /* argc */ -); - -extern int XSetDashes( - Display* /* display */, - GC /* gc */, - int /* dash_offset */, - _Xconst char* /* dash_list */, - int /* n */ -); - -extern int XSetFillRule( - Display* /* display */, - GC /* gc */, - int /* fill_rule */ -); - -extern int XSetFillStyle( - Display* /* display */, - GC /* gc */, - int /* fill_style */ -); - -extern int XSetFont( - Display* /* display */, - GC /* gc */, - Font /* font */ -); - -extern int XSetFontPath( - Display* /* display */, - char** /* directories */, - int /* ndirs */ -); - -extern int XSetForeground( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */ -); - -extern int XSetFunction( - Display* /* display */, - GC /* gc */, - int /* function */ -); - -extern int XSetGraphicsExposures( - Display* /* display */, - GC /* gc */, - Bool /* graphics_exposures */ -); - -extern int XSetIconName( - Display* /* display */, - Window /* w */, - _Xconst char* /* icon_name */ -); - -extern int XSetInputFocus( - Display* /* display */, - Window /* focus */, - int /* revert_to */, - Time /* time */ -); - -extern int XSetLineAttributes( - Display* /* display */, - GC /* gc */, - unsigned int /* line_width */, - int /* line_style */, - int /* cap_style */, - int /* join_style */ -); - -extern int XSetModifierMapping( - Display* /* display */, - XModifierKeymap* /* modmap */ -); - -extern int XSetPlaneMask( - Display* /* display */, - GC /* gc */, - unsigned long /* plane_mask */ -); - -extern int XSetPointerMapping( - Display* /* display */, - _Xconst unsigned char* /* map */, - int /* nmap */ -); - -extern int XSetScreenSaver( - Display* /* display */, - int /* timeout */, - int /* interval */, - int /* prefer_blanking */, - int /* allow_exposures */ -); - -extern int XSetSelectionOwner( - Display* /* display */, - Atom /* selection */, - Window /* owner */, - Time /* time */ -); - -extern int XSetState( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */, - unsigned long /* background */, - int /* function */, - unsigned long /* plane_mask */ -); - -extern int XSetStipple( - Display* /* display */, - GC /* gc */, - Pixmap /* stipple */ -); - -extern int XSetSubwindowMode( - Display* /* display */, - GC /* gc */, - int /* subwindow_mode */ -); - -extern int XSetTSOrigin( - Display* /* display */, - GC /* gc */, - int /* ts_x_origin */, - int /* ts_y_origin */ -); - -extern int XSetTile( - Display* /* display */, - GC /* gc */, - Pixmap /* tile */ -); - -extern int XSetWindowBackground( - Display* /* display */, - Window /* w */, - unsigned long /* background_pixel */ -); - -extern int XSetWindowBackgroundPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* background_pixmap */ -); - -extern int XSetWindowBorder( - Display* /* display */, - Window /* w */, - unsigned long /* border_pixel */ -); - -extern int XSetWindowBorderPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* border_pixmap */ -); - -extern int XSetWindowBorderWidth( - Display* /* display */, - Window /* w */, - unsigned int /* width */ -); - -extern int XSetWindowColormap( - Display* /* display */, - Window /* w */, - Colormap /* colormap */ -); - -extern int XStoreBuffer( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */, - int /* buffer */ -); - -extern int XStoreBytes( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */ -); - -extern int XStoreColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */ -); - -extern int XStoreColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */, - int /* ncolors */ -); - -extern int XStoreName( - Display* /* display */, - Window /* w */, - _Xconst char* /* window_name */ -); - -extern int XStoreNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color */, - unsigned long /* pixel */, - int /* flags */ -); - -extern int XSync( - Display* /* display */, - Bool /* discard */ -); - -extern int XTextExtents( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextExtents16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextWidth( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int XTextWidth16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -extern Bool XTranslateCoordinates( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - int* /* dest_x_return */, - int* /* dest_y_return */, - Window* /* child_return */ -); - -extern int XUndefineCursor( - Display* /* display */, - Window /* w */ -); - -extern int XUngrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKeyboard( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabPointer( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabServer( - Display* /* display */ -); - -extern int XUninstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XUnloadFont( - Display* /* display */, - Font /* font */ -); - -extern int XUnmapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XUnmapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XVendorRelease( - Display* /* display */ -); - -extern int XWarpPointer( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - unsigned int /* src_width */, - unsigned int /* src_height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XWidthMMOfScreen( - Screen* /* screen */ -); - -extern int XWidthOfScreen( - Screen* /* screen */ -); - -extern int XWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XWriteBitmapFile( - Display* /* display */, - _Xconst char* /* filename */, - Pixmap /* bitmap */, - unsigned int /* width */, - unsigned int /* height */, - int /* x_hot */, - int /* y_hot */ -); - -extern Bool XSupportsLocale (void); - -extern char *XSetLocaleModifiers( - const char* /* modifier_list */ -); - -extern XOM XOpenOM( - Display* /* display */, - struct _XrmHashBucketRec* /* rdb */, - _Xconst char* /* res_name */, - _Xconst char* /* res_class */ -); - -extern Status XCloseOM( - XOM /* om */ -); - -extern char *XSetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern char *XGetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfOM( - XOM /* om */ -); - -extern char *XLocaleOfOM( - XOM /* om */ -); - -extern XOC XCreateOC( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern void XDestroyOC( - XOC /* oc */ -); - -extern XOM XOMOfOC( - XOC /* oc */ -); - -extern char *XSetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern char *XGetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern XFontSet XCreateFontSet( - Display* /* display */, - _Xconst char* /* base_font_name_list */, - char*** /* missing_charset_list */, - int* /* missing_charset_count */, - char** /* def_string */ -); - -extern void XFreeFontSet( - Display* /* display */, - XFontSet /* font_set */ -); - -extern int XFontsOfFontSet( - XFontSet /* font_set */, - XFontStruct*** /* font_struct_list */, - char*** /* font_name_list */ -); - -extern char *XBaseFontNameListOfFontSet( - XFontSet /* font_set */ -); - -extern char *XLocaleOfFontSet( - XFontSet /* font_set */ -); - -extern Bool XContextDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XDirectionalDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XContextualDrawing( - XFontSet /* font_set */ -); - -extern XFontSetExtents *XExtentsOfFontSet( - XFontSet /* font_set */ -); - -extern int XmbTextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XwcTextEscapement( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern int Xutf8TextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XmbTextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int XwcTextExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int Xutf8TextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XmbTextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XwcTextPerCharExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status Xutf8TextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern void XmbDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XwcDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XwcTextItem* /* text_items */, - int /* nitems */ -); - -extern void Xutf8DrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XmbDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XmbDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern XIM XOpenIM( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */ -); - -extern Status XCloseIM( - XIM /* im */ -); - -extern char *XGetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern char *XSetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfIM( - XIM /* im */ -); - -extern char *XLocaleOfIM( - XIM /* im*/ -); - -extern XIC XCreateIC( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern void XDestroyIC( - XIC /* ic */ -); - -extern void XSetICFocus( - XIC /* ic */ -); - -extern void XUnsetICFocus( - XIC /* ic */ -); - -extern wchar_t *XwcResetIC( - XIC /* ic */ -); - -extern char *XmbResetIC( - XIC /* ic */ -); - -extern char *Xutf8ResetIC( - XIC /* ic */ -); - -extern char *XSetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern char *XGetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern XIM XIMOfIC( - XIC /* ic */ -); - -extern Bool XFilterEvent( - XEvent* /* event */, - Window /* window */ -); - -extern int XmbLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int XwcLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - wchar_t* /* buffer_return */, - int /* wchars_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int Xutf8LookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern XVaNestedList XVaCreateNestedList( - int /*unused*/, ... -) _X_SENTINEL(0); - -/* internal connections for IMs */ - -extern Bool XRegisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -extern Bool XUnregisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -typedef void (*XConnectionWatchProc)( - Display* /* dpy */, - XPointer /* client_data */, - int /* fd */, - Bool /* opening */, /* open or close flag */ - XPointer* /* watch_data */ /* open sets, close uses */ -); - - -extern Status XInternalConnectionNumbers( - Display* /* dpy */, - int** /* fd_return */, - int* /* count_return */ -); - -extern void XProcessInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -extern Status XAddConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XRemoveConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XSetAuthorization( - char * /* name */, - int /* namelen */, - char * /* data */, - int /* datalen */ -); - -extern int _Xmbtowc( - wchar_t * /* wstr */, -#ifdef ISC - char const * /* str */, - size_t /* len */ -#else - char * /* str */, - int /* len */ -#endif -); - -extern int _Xwctomb( - char * /* str */, - wchar_t /* wc */ -); - -_XFUNCPROTOEND - -#endif /* _XLIB_H_ */ diff --git a/nx-X11/lib/X11/Xlib.h.X.original b/nx-X11/lib/X11/Xlib.h.X.original deleted file mode 100644 index b1535f9b1..000000000 --- a/nx-X11/lib/X11/Xlib.h.X.original +++ /dev/null @@ -1,4008 +0,0 @@ -/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */ -/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1991, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */ - - -/* - * Xlib.h - Header definition and support file for the C subroutine - * interface library (Xlib) to the X Window System Protocol (V11). - * Structures and symbols starting with "_" are private to the library. - */ -#ifndef _XLIB_H_ -#define _XLIB_H_ - -#define XlibSpecificationRelease 6 - -#ifdef USG -#ifndef __TYPES__ -#include <sys/types.h> /* forgot to protect it... */ -#define __TYPES__ -#endif /* __TYPES__ */ -#else -#if defined(_POSIX_SOURCE) && defined(MOTOROLA) -#undef _POSIX_SOURCE -#include <sys/types.h> -#define _POSIX_SOURCE -#else -#include <sys/types.h> -#endif -#endif /* USG */ - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <stdint.h> -#endif - -#include <X11/X.h> - -/* applications should not depend on these two headers being included! */ -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> - -#ifndef X_WCHAR -#ifdef X_NOT_STDC_ENV -#ifndef ISC -#define X_WCHAR -#endif -#endif -#endif - -#ifndef X_WCHAR -#include <stddef.h> -#else -#ifdef __UNIXOS2__ -#include <stdlib.h> -#else -/* replace this with #include or typedef appropriate for your system */ -typedef unsigned long wchar_t; -#endif -#endif - -#if defined(ISC) && defined(USE_XMBTOWC) -#define wctomb(a,b) _Xwctomb(a,b) -#define mblen(a,b) _Xmblen(a,b) -#ifndef USE_XWCHAR_STRING -#define mbtowc(a,b,c) _Xmbtowc(a,b,c) -#endif -#endif - -extern int -_Xmblen( -#ifdef ISC - char const *str, - size_t len -#else - char *str, - int len -#endif - ); - -/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in - November 2000. Its presence is indicated through the following macro. */ -#define X_HAVE_UTF8_STRING 1 - -typedef char *XPointer; - -#define Bool int -#define Status int -#define True 1 -#define False 0 - -#define QueuedAlready 0 -#define QueuedAfterReading 1 -#define QueuedAfterFlush 2 - -#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) -#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) -#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) -#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) -#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) -#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) -#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) -#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) -#define AllPlanes ((unsigned long)~0L) -#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) -#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) -#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) -#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) -#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) -#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) -#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) -#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) -#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) -#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) -#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) -#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) -#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) -#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) -#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) -#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) -#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) -#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ -#define NextRequest(dpy) XNextRequest(dpy) -#else -#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) -#endif -#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) - -/* macros for screen oriented applications (toolkit) */ -#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) -#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) -#define DisplayOfScreen(s) ((s)->display) -#define RootWindowOfScreen(s) ((s)->root) -#define BlackPixelOfScreen(s) ((s)->black_pixel) -#define WhitePixelOfScreen(s) ((s)->white_pixel) -#define DefaultColormapOfScreen(s)((s)->cmap) -#define DefaultDepthOfScreen(s) ((s)->root_depth) -#define DefaultGCOfScreen(s) ((s)->default_gc) -#define DefaultVisualOfScreen(s)((s)->root_visual) -#define WidthOfScreen(s) ((s)->width) -#define HeightOfScreen(s) ((s)->height) -#define WidthMMOfScreen(s) ((s)->mwidth) -#define HeightMMOfScreen(s) ((s)->mheight) -#define PlanesOfScreen(s) ((s)->root_depth) -#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) -#define MinCmapsOfScreen(s) ((s)->min_maps) -#define MaxCmapsOfScreen(s) ((s)->max_maps) -#define DoesSaveUnders(s) ((s)->save_unders) -#define DoesBackingStore(s) ((s)->backing_store) -#define EventMaskOfScreen(s) ((s)->root_input_mask) - -/* - * Extensions need a way to hang private data on some structures. - */ -typedef struct _XExtData { - int number; /* number returned by XRegisterExtension */ - struct _XExtData *next; /* next item on list of data for structure */ - int (*free_private)( /* called to free private storage */ - struct _XExtData *extension - ); - XPointer private_data; /* data private to this extension. */ -} XExtData; - -/* - * This file contains structures used by the extension mechanism. - */ -typedef struct { /* public to extension, cannot be changed */ - int extension; /* extension number */ - int major_opcode; /* major op-code assigned by server */ - int first_event; /* first event number for the extension */ - int first_error; /* first error number for the extension */ -} XExtCodes; - -/* - * Data structure for retrieving info about pixmap formats. - */ - -typedef struct { - int depth; - int bits_per_pixel; - int scanline_pad; -} XPixmapFormatValues; - - -/* - * Data structure for setting graphics context. - */ -typedef struct { - int function; /* logical operation */ - unsigned long plane_mask;/* plane mask */ - unsigned long foreground;/* foreground pixel */ - unsigned long background;/* background pixel */ - int line_width; /* line width */ - int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ - int cap_style; /* CapNotLast, CapButt, - CapRound, CapProjecting */ - int join_style; /* JoinMiter, JoinRound, JoinBevel */ - int fill_style; /* FillSolid, FillTiled, - FillStippled, FillOpaeueStippled */ - int fill_rule; /* EvenOddRule, WindingRule */ - int arc_mode; /* ArcChord, ArcPieSlice */ - Pixmap tile; /* tile pixmap for tiling operations */ - Pixmap stipple; /* stipple 1 plane pixmap for stipping */ - int ts_x_origin; /* offset for tile or stipple operations */ - int ts_y_origin; - Font font; /* default text font for text operations */ - int subwindow_mode; /* ClipByChildren, IncludeInferiors */ - Bool graphics_exposures;/* boolean, should exposures be generated */ - int clip_x_origin; /* origin for clipping */ - int clip_y_origin; - Pixmap clip_mask; /* bitmap clipping; other calls for rects */ - int dash_offset; /* patterned/dashed line information */ - char dashes; -} XGCValues; - -/* - * Graphics context. The contents of this structure are implementation - * dependent. A GC should be treated as opaque by application code. - */ - -typedef struct _XGC -#ifdef XLIB_ILLEGAL_ACCESS -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - /* there is more to this structure, but it is private to Xlib */ -} -#endif -*GC; - -/* - * Visual structure; contains information about colormapping possible. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - VisualID visualid; /* visual id of this visual */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ class of screen (monochrome, etc.) */ -#else - int class; /* class of screen (monochrome, etc.) */ -#endif - unsigned long red_mask, green_mask, blue_mask; /* mask values */ - int bits_per_rgb; /* log base 2 of distinct color values */ - int map_entries; /* color map entries */ -} Visual; - -/* - * Depth structure; contains information for each possible depth. - */ -typedef struct { - int depth; /* this depth (Z) of the depth */ - int nvisuals; /* number of Visual types at this depth */ - Visual *visuals; /* list of visuals possible at this depth */ -} Depth; - -/* - * Information about the screen. The contents of this structure are - * implementation dependent. A Screen should be treated as opaque - * by application code. - */ - -struct _XDisplay; /* Forward declare before use for C++ */ - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - struct _XDisplay *display;/* back pointer to display structure */ - Window root; /* Root window id. */ - int width, height; /* width and height of screen */ - int mwidth, mheight; /* width and height of in millimeters */ - int ndepths; /* number of depths possible */ - Depth *depths; /* list of allowable depths on the screen */ - int root_depth; /* bits per pixel */ - Visual *root_visual; /* root visual */ - GC default_gc; /* GC for the root root visual */ - Colormap cmap; /* default color map */ - unsigned long white_pixel; - unsigned long black_pixel; /* White and Black pixel values */ - int max_maps, min_maps; /* max and min color maps */ - int backing_store; /* Never, WhenMapped, Always */ - Bool save_unders; - long root_input_mask; /* initial root input mask */ -} Screen; - -/* - * Format structure; describes ZFormat data the screen will understand. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - int depth; /* depth of this image format */ - int bits_per_pixel; /* bits/pixel at this depth */ - int scanline_pad; /* scanline must padded to this multiple */ -} ScreenFormat; - -/* - * Data structure for setting window attributes. - */ -typedef struct { - Pixmap background_pixmap; /* background or None or ParentRelative */ - unsigned long background_pixel; /* background pixel */ - Pixmap border_pixmap; /* border of the window */ - unsigned long border_pixel; /* border pixel value */ - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preseved if possible */ - unsigned long backing_pixel;/* value to use in restoring planes */ - Bool save_under; /* should bits under be saved? (popups) */ - long event_mask; /* set of events that should be saved */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Colormap colormap; /* color map to be associated with window */ - Cursor cursor; /* cursor to be displayed (or None) */ -} XSetWindowAttributes; - -typedef struct { - int x, y; /* location of window */ - int width, height; /* width and height of window */ - int border_width; /* border width of window */ - int depth; /* depth of window */ - Visual *visual; /* the associated visual structure */ - Window root; /* root of screen containing window */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ InputOutput, InputOnly*/ -#else - int class; /* InputOutput, InputOnly*/ -#endif - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preserved if possible */ - unsigned long backing_pixel;/* value to be used when restoring planes */ - Bool save_under; /* boolean, should bits under be saved? */ - Colormap colormap; /* color map to be associated with window */ - Bool map_installed; /* boolean, is color map currently installed*/ - int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ - long all_event_masks; /* set of events all people have interest in*/ - long your_event_mask; /* my event mask */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Screen *screen; /* back pointer to correct screen */ -} XWindowAttributes; - -/* - * Data structure for host setting; getting routines. - * - */ - -typedef struct { - int family; /* for example FamilyInternet */ - int length; /* length of address, in bytes */ - char *address; /* pointer to where to find the bytes */ -} XHostAddress; - -/* - * Data structure for ServerFamilyInterpreted addresses in host routines - */ -typedef struct { - int typelength; /* length of type string, in bytes */ - int valuelength; /* length of value string, in bytes */ - char *type; /* pointer to where to find the type string */ - char *value; /* pointer to where to find the address */ -} XServerInterpretedAddress; - -/* - * Data structure for "image" data, used by image manipulation routines. - */ -typedef struct _XImage { - int width, height; /* size of image */ - int xoffset; /* number of pixels offset in X direction */ - int format; /* XYBitmap, XYPixmap, ZPixmap */ - char *data; /* pointer to image data */ - int byte_order; /* data byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* quant. of scanline 8, 16, 32 */ - int bitmap_bit_order; /* LSBFirst, MSBFirst */ - int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ - int depth; /* depth of image */ - int bytes_per_line; /* accelarator to next line */ - int bits_per_pixel; /* bits per pixel (ZPixmap) */ - unsigned long red_mask; /* bits in z arrangment */ - unsigned long green_mask; - unsigned long blue_mask; - XPointer obdata; /* hook for the object routines to hang on */ - struct funcs { /* image manipulation routines */ - struct _XImage *(*create_image)( - struct _XDisplay* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */); - int (*destroy_image) (struct _XImage *); - unsigned long (*get_pixel) (struct _XImage *, int, int); - int (*put_pixel) (struct _XImage *, int, int, unsigned long); - struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); - int (*add_pixel) (struct _XImage *, long); - } f; -} XImage; - -/* - * Data structure for XReconfigureWindow - */ -typedef struct { - int x, y; - int width, height; - int border_width; - Window sibling; - int stack_mode; -} XWindowChanges; - -/* - * Data structure used by color operations - */ -typedef struct { - unsigned long pixel; - unsigned short red, green, blue; - char flags; /* do_red, do_green, do_blue */ - char pad; -} XColor; - -/* - * Data structures for graphics operations. On most machines, these are - * congruent with the wire protocol structures, so reformatting the data - * can be avoided on these architectures. - */ -typedef struct { - short x1, y1, x2, y2; -} XSegment; - -typedef struct { - short x, y; -} XPoint; - -typedef struct { - short x, y; - unsigned short width, height; -} XRectangle; - -typedef struct { - short x, y; - unsigned short width, height; - short angle1, angle2; -} XArc; - - -/* Data structure for XChangeKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - int bell_pitch; - int bell_duration; - int led; - int led_mode; - int key; - int auto_repeat_mode; /* On, Off, Default */ -} XKeyboardControl; - -/* Data structure for XGetKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - unsigned int bell_pitch, bell_duration; - unsigned long led_mask; - int global_auto_repeat; - char auto_repeats[32]; -} XKeyboardState; - -/* Data structure for XGetMotionEvents. */ - -typedef struct { - Time time; - short x, y; -} XTimeCoord; - -/* Data structure for X{Set,Get}ModifierMapping */ - -typedef struct { - int max_keypermod; /* The server's max # of keys per modifier */ - KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ -} XModifierKeymap; - - -/* - * Display datatype maintaining display specific data. - * The contents of this structure are implementation dependent. - * A Display should be treated as opaque by application code. - */ -#ifndef XLIB_ILLEGAL_ACCESS -typedef struct _XDisplay Display; -#endif - -struct _XPrivate; /* Forward declare before use for C++ */ -struct _XrmHashBucketRec; - -typedef struct -#ifdef XLIB_ILLEGAL_ACCESS -_XDisplay -#endif -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XPrivate *private1; - int fd; /* Network socket. */ - int private2; - int proto_major_version;/* major version of server's X protocol */ - int proto_minor_version;/* minor version of servers X protocol */ - char *vendor; /* vendor of the server hardware */ - XID private3; - XID private4; - XID private5; - int private6; - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int private8; - int release; /* release of the server */ - struct _XPrivate *private9, *private10; - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - XPointer private11; - XPointer private12; - XPointer private13; - XPointer private14; - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*private15)( - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long private16; - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - XPointer private17; - XPointer private18; - int private19; - char *xdefaults; /* contents of defaults from server */ - /* there is more to this structure, but it is private to Xlib */ -} -#ifdef XLIB_ILLEGAL_ACCESS -Display, -#endif -*_XPrivDisplay; - -#undef _XEVENT_ -#ifndef _XEVENT_ -/* - * Definitions of specific events. - */ -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int keycode; /* detail */ - Bool same_screen; /* same screen flag */ -} XKeyEvent; -typedef XKeyEvent XKeyPressedEvent; -typedef XKeyEvent XKeyReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int button; /* detail */ - Bool same_screen; /* same screen flag */ -} XButtonEvent; -typedef XButtonEvent XButtonPressedEvent; -typedef XButtonEvent XButtonReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - char is_hint; /* detail */ - Bool same_screen; /* same screen flag */ -} XMotionEvent; -typedef XMotionEvent XPointerMovedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual - */ - Bool same_screen; /* same screen flag */ - Bool focus; /* boolean focus */ - unsigned int state; /* key or button mask */ -} XCrossingEvent; -typedef XCrossingEvent XEnterWindowEvent; -typedef XCrossingEvent XLeaveWindowEvent; - -typedef struct { - int type; /* FocusIn or FocusOut */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* window of event */ - int mode; /* NotifyNormal, NotifyWhileGrabbed, - NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, - * NotifyPointerRoot, NotifyDetailNone - */ -} XFocusChangeEvent; -typedef XFocusChangeEvent XFocusInEvent; -typedef XFocusChangeEvent XFocusOutEvent; - -/* generated on EnterWindow and FocusIn when KeyMapState selected */ -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - char key_vector[32]; -} XKeymapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ -} XExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XGraphicsExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XNoExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int state; /* Visibility state */ -} XVisibilityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; /* parent of the window */ - Window window; /* window id of window created */ - int x, y; /* window location */ - int width, height; /* size of window */ - int border_width; /* border width */ - Bool override_redirect; /* creation should be overridden */ -} XCreateWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; -} XDestroyWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool from_configure; -} XUnmapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool override_redirect; /* boolean, is override set... */ -} XMapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; -} XMapRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Window parent; - int x, y; - Bool override_redirect; -} XReparentEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - Bool override_redirect; -} XConfigureEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; -} XGravityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int width, height; -} XResizeRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - int detail; /* Above, Below, TopIf, BottomIf, Opposite */ - unsigned long value_mask; -} XConfigureRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom atom; - Time time; - int state; /* NewValue, Deleted */ -} XPropertyEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom selection; - Time time; -} XSelectionClearEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window owner; - Window requestor; - Atom selection; - Atom target; - Atom property; - Time time; -} XSelectionRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window requestor; - Atom selection; - Atom target; - Atom property; /* ATOM or None */ - Time time; -} XSelectionEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Colormap colormap; /* COLORMAP or None */ -#if defined(__cplusplus) || defined(c_plusplus) - Bool c_new; /* C++ */ -#else - Bool new; -#endif - int state; /* ColormapInstalled, ColormapUninstalled */ -} XColormapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom message_type; - int format; - union { - char b[20]; - short s[10]; - long l[5]; - } data; -} XClientMessageEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* unused */ - int request; /* one of MappingModifier, MappingKeyboard, - MappingPointer */ - int first_keycode; /* first keycode */ - int count; /* defines range of change w. first_keycode*/ -} XMappingEvent; - -typedef struct { - int type; - Display *display; /* Display the event was read from */ - XID resourceid; /* resource id */ - unsigned long serial; /* serial number of failed request */ - unsigned char error_code; /* error code of failed request */ - unsigned char request_code; /* Major op-code of failed request */ - unsigned char minor_code; /* Minor op-code of failed request */ -} XErrorEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display;/* Display the event was read from */ - Window window; /* window on which event was requested in event mask */ -} XAnyEvent; - -/* - * this union is defined so Xlib can always use the same sized - * event structure internally, to avoid memory fragmentation. - */ -typedef union _XEvent { - int type; /* must not be changed; first element */ - XAnyEvent xany; - XKeyEvent xkey; - XButtonEvent xbutton; - XMotionEvent xmotion; - XCrossingEvent xcrossing; - XFocusChangeEvent xfocus; - XExposeEvent xexpose; - XGraphicsExposeEvent xgraphicsexpose; - XNoExposeEvent xnoexpose; - XVisibilityEvent xvisibility; - XCreateWindowEvent xcreatewindow; - XDestroyWindowEvent xdestroywindow; - XUnmapEvent xunmap; - XMapEvent xmap; - XMapRequestEvent xmaprequest; - XReparentEvent xreparent; - XConfigureEvent xconfigure; - XGravityEvent xgravity; - XResizeRequestEvent xresizerequest; - XConfigureRequestEvent xconfigurerequest; - XCirculateEvent xcirculate; - XCirculateRequestEvent xcirculaterequest; - XPropertyEvent xproperty; - XSelectionClearEvent xselectionclear; - XSelectionRequestEvent xselectionrequest; - XSelectionEvent xselection; - XColormapEvent xcolormap; - XClientMessageEvent xclient; - XMappingEvent xmapping; - XErrorEvent xerror; - XKeymapEvent xkeymap; - long pad[24]; -} XEvent; -#endif - -#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) - -/* - * per character font metric information. - */ -typedef struct { - short lbearing; /* origin to left edge of raster */ - short rbearing; /* origin to right edge of raster */ - short width; /* advance to next char's origin */ - short ascent; /* baseline to top edge of raster */ - short descent; /* baseline to bottom edge of raster */ - unsigned short attributes; /* per char flags (not predefined) */ -} XCharStruct; - -/* - * To allow arbitrary information with fonts, there are additional properties - * returned. - */ -typedef struct { - Atom name; - unsigned long card32; -} XFontProp; - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - Font fid; /* Font id for this font */ - unsigned direction; /* hint about direction the font is painted */ - unsigned min_char_or_byte2;/* first character */ - unsigned max_char_or_byte2;/* last character */ - unsigned min_byte1; /* first row that exists */ - unsigned max_byte1; /* last row that exists */ - Bool all_chars_exist;/* flag if all characters have non-zero size*/ - unsigned default_char; /* char to print for undefined character */ - int n_properties; /* how many properties there are */ - XFontProp *properties; /* pointer to array of additional properties*/ - XCharStruct min_bounds; /* minimum bounds over all existing char*/ - XCharStruct max_bounds; /* maximum bounds over all existing char*/ - XCharStruct *per_char; /* first_char to last_char information */ - int ascent; /* log. extent above baseline for spacing */ - int descent; /* log. descent below baseline for spacing */ -} XFontStruct; - -/* - * PolyText routines take these as arguments. - */ -typedef struct { - char *chars; /* pointer to string */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem; - -typedef struct { /* normal 16 bit characters are two bytes */ - unsigned char byte1; - unsigned char byte2; -} XChar2b; - -typedef struct { - XChar2b *chars; /* two byte characters */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem16; - - -typedef union { Display *display; - GC gc; - Visual *visual; - Screen *screen; - ScreenFormat *pixmap_format; - XFontStruct *font; } XEDataObject; - -typedef struct { - XRectangle max_ink_extent; - XRectangle max_logical_extent; -} XFontSetExtents; - -/* unused: -typedef void (*XOMProc)(); - */ - -typedef struct _XOM *XOM; -typedef struct _XOC *XOC, *XFontSet; - -typedef struct { - char *chars; - int nchars; - int delta; - XFontSet font_set; -} XmbTextItem; - -typedef struct { - wchar_t *chars; - int nchars; - int delta; - XFontSet font_set; -} XwcTextItem; - -#define XNRequiredCharSet "requiredCharSet" -#define XNQueryOrientation "queryOrientation" -#define XNBaseFontName "baseFontName" -#define XNOMAutomatic "omAutomatic" -#define XNMissingCharSet "missingCharSet" -#define XNDefaultString "defaultString" -#define XNOrientation "orientation" -#define XNDirectionalDependentDrawing "directionalDependentDrawing" -#define XNContextualDrawing "contextualDrawing" -#define XNFontInfo "fontInfo" - -typedef struct { - int charset_count; - char **charset_list; -} XOMCharSetList; - -typedef enum { - XOMOrientation_LTR_TTB, - XOMOrientation_RTL_TTB, - XOMOrientation_TTB_LTR, - XOMOrientation_TTB_RTL, - XOMOrientation_Context -} XOrientation; - -typedef struct { - int num_orientation; - XOrientation *orientation; /* Input Text description */ -} XOMOrientation; - -typedef struct { - int num_font; - XFontStruct **font_struct_list; - char **font_name_list; -} XOMFontInfo; - -typedef struct _XIM *XIM; -typedef struct _XIC *XIC; - -typedef void (*XIMProc)( - XIM, - XPointer, - XPointer -); - -typedef Bool (*XICProc)( - XIC, - XPointer, - XPointer -); - -typedef void (*XIDProc)( - Display*, - XPointer, - XPointer -); - -typedef unsigned long XIMStyle; - -typedef struct { - unsigned short count_styles; - XIMStyle *supported_styles; -} XIMStyles; - -#define XIMPreeditArea 0x0001L -#define XIMPreeditCallbacks 0x0002L -#define XIMPreeditPosition 0x0004L -#define XIMPreeditNothing 0x0008L -#define XIMPreeditNone 0x0010L -#define XIMStatusArea 0x0100L -#define XIMStatusCallbacks 0x0200L -#define XIMStatusNothing 0x0400L -#define XIMStatusNone 0x0800L - -#define XNVaNestedList "XNVaNestedList" -#define XNQueryInputStyle "queryInputStyle" -#define XNClientWindow "clientWindow" -#define XNInputStyle "inputStyle" -#define XNFocusWindow "focusWindow" -#define XNResourceName "resourceName" -#define XNResourceClass "resourceClass" -#define XNGeometryCallback "geometryCallback" -#define XNDestroyCallback "destroyCallback" -#define XNFilterEvents "filterEvents" -#define XNPreeditStartCallback "preeditStartCallback" -#define XNPreeditDoneCallback "preeditDoneCallback" -#define XNPreeditDrawCallback "preeditDrawCallback" -#define XNPreeditCaretCallback "preeditCaretCallback" -#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" -#define XNPreeditAttributes "preeditAttributes" -#define XNStatusStartCallback "statusStartCallback" -#define XNStatusDoneCallback "statusDoneCallback" -#define XNStatusDrawCallback "statusDrawCallback" -#define XNStatusAttributes "statusAttributes" -#define XNArea "area" -#define XNAreaNeeded "areaNeeded" -#define XNSpotLocation "spotLocation" -#define XNColormap "colorMap" -#define XNStdColormap "stdColorMap" -#define XNForeground "foreground" -#define XNBackground "background" -#define XNBackgroundPixmap "backgroundPixmap" -#define XNFontSet "fontSet" -#define XNLineSpace "lineSpace" -#define XNCursor "cursor" - -#define XNQueryIMValuesList "queryIMValuesList" -#define XNQueryICValuesList "queryICValuesList" -#define XNVisiblePosition "visiblePosition" -#define XNR6PreeditCallback "r6PreeditCallback" -#define XNStringConversionCallback "stringConversionCallback" -#define XNStringConversion "stringConversion" -#define XNResetState "resetState" -#define XNHotKey "hotKey" -#define XNHotKeyState "hotKeyState" -#define XNPreeditState "preeditState" -#define XNSeparatorofNestedList "separatorofNestedList" - -#define XBufferOverflow -1 -#define XLookupNone 1 -#define XLookupChars 2 -#define XLookupKeySym 3 -#define XLookupBoth 4 - -typedef void *XVaNestedList; - -typedef struct { - XPointer client_data; - XIMProc callback; -} XIMCallback; - -typedef struct { - XPointer client_data; - XICProc callback; -} XICCallback; - -typedef unsigned long XIMFeedback; - -#define XIMReverse 1L -#define XIMUnderline (1L<<1) -#define XIMHighlight (1L<<2) -#define XIMPrimary (1L<<5) -#define XIMSecondary (1L<<6) -#define XIMTertiary (1L<<7) -#define XIMVisibleToForward (1L<<8) -#define XIMVisibleToBackword (1L<<9) -#define XIMVisibleToCenter (1L<<10) - -typedef struct _XIMText { - unsigned short length; - XIMFeedback *feedback; - Bool encoding_is_wchar; - union { - char *multi_byte; - wchar_t *wide_char; - } string; -} XIMText; - -typedef unsigned long XIMPreeditState; - -#define XIMPreeditUnKnown 0L -#define XIMPreeditEnable 1L -#define XIMPreeditDisable (1L<<1) - -typedef struct _XIMPreeditStateNotifyCallbackStruct { - XIMPreeditState state; -} XIMPreeditStateNotifyCallbackStruct; - -typedef unsigned long XIMResetState; - -#define XIMInitialState 1L -#define XIMPreserveState (1L<<1) - -typedef unsigned long XIMStringConversionFeedback; - -#define XIMStringConversionLeftEdge (0x00000001) -#define XIMStringConversionRightEdge (0x00000002) -#define XIMStringConversionTopEdge (0x00000004) -#define XIMStringConversionBottomEdge (0x00000008) -#define XIMStringConversionConcealed (0x00000010) -#define XIMStringConversionWrapped (0x00000020) - -typedef struct _XIMStringConversionText { - unsigned short length; - XIMStringConversionFeedback *feedback; - Bool encoding_is_wchar; - union { - char *mbs; - wchar_t *wcs; - } string; -} XIMStringConversionText; - -typedef unsigned short XIMStringConversionPosition; - -typedef unsigned short XIMStringConversionType; - -#define XIMStringConversionBuffer (0x0001) -#define XIMStringConversionLine (0x0002) -#define XIMStringConversionWord (0x0003) -#define XIMStringConversionChar (0x0004) - -typedef unsigned short XIMStringConversionOperation; - -#define XIMStringConversionSubstitution (0x0001) -#define XIMStringConversionRetrieval (0x0002) - -typedef enum { - XIMForwardChar, XIMBackwardChar, - XIMForwardWord, XIMBackwardWord, - XIMCaretUp, XIMCaretDown, - XIMNextLine, XIMPreviousLine, - XIMLineStart, XIMLineEnd, - XIMAbsolutePosition, - XIMDontChange -} XIMCaretDirection; - -typedef struct _XIMStringConversionCallbackStruct { - XIMStringConversionPosition position; - XIMCaretDirection direction; - XIMStringConversionOperation operation; - unsigned short factor; - XIMStringConversionText *text; -} XIMStringConversionCallbackStruct; - -typedef struct _XIMPreeditDrawCallbackStruct { - int caret; /* Cursor offset within pre-edit string */ - int chg_first; /* Starting change position */ - int chg_length; /* Length of the change in character count */ - XIMText *text; -} XIMPreeditDrawCallbackStruct; - -typedef enum { - XIMIsInvisible, /* Disable caret feedback */ - XIMIsPrimary, /* UI defined caret feedback */ - XIMIsSecondary /* UI defined caret feedback */ -} XIMCaretStyle; - -typedef struct _XIMPreeditCaretCallbackStruct { - int position; /* Caret offset within pre-edit string */ - XIMCaretDirection direction; /* Caret moves direction */ - XIMCaretStyle style; /* Feedback of the caret */ -} XIMPreeditCaretCallbackStruct; - -typedef enum { - XIMTextType, - XIMBitmapType -} XIMStatusDataType; - -typedef struct _XIMStatusDrawCallbackStruct { - XIMStatusDataType type; - union { - XIMText *text; - Pixmap bitmap; - } data; -} XIMStatusDrawCallbackStruct; - -typedef struct _XIMHotKeyTrigger { - KeySym keysym; - int modifier; - int modifier_mask; -} XIMHotKeyTrigger; - -typedef struct _XIMHotKeyTriggers { - int num_hot_key; - XIMHotKeyTrigger *key; -} XIMHotKeyTriggers; - -typedef unsigned long XIMHotKeyState; - -#define XIMHotKeyStateON (0x0001L) -#define XIMHotKeyStateOFF (0x0002L) - -typedef struct { - unsigned short count_values; - char **supported_values; -} XIMValuesList; - -_XFUNCPROTOBEGIN - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _Xdebug (*_Xdebug_p) -#endif - -extern int _Xdebug; - -extern XFontStruct *XLoadQueryFont( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XFontStruct *XQueryFont( - Display* /* display */, - XID /* font_ID */ -); - - -extern XTimeCoord *XGetMotionEvents( - Display* /* display */, - Window /* w */, - Time /* start */, - Time /* stop */, - int* /* nevents_return */ -); - -extern XModifierKeymap *XDeleteModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XGetModifierMapping( - Display* /* display */ -); - -extern XModifierKeymap *XInsertModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XNewModifiermap( - int /* max_keys_per_mod */ -); - -extern XImage *XCreateImage( - Display* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */ -); -extern Status XInitImage( - XImage* /* image */ -); -extern XImage *XGetImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */ -); -extern XImage *XGetSubImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */, - XImage* /* dest_image */, - int /* dest_x */, - int /* dest_y */ -); - -/* - * X function declarations. - */ -extern Display *XOpenDisplay( - _Xconst char* /* display_name */ -); - -extern void XrmInitialize( - void -); - -extern char *XFetchBytes( - Display* /* display */, - int* /* nbytes_return */ -); -extern char *XFetchBuffer( - Display* /* display */, - int* /* nbytes_return */, - int /* buffer */ -); -extern char *XGetAtomName( - Display* /* display */, - Atom /* atom */ -); -extern Status XGetAtomNames( - Display* /* dpy */, - Atom* /* atoms */, - int /* count */, - char** /* names_return */ -); -extern char *XGetDefault( - Display* /* display */, - _Xconst char* /* program */, - _Xconst char* /* option */ -); -extern char *XDisplayName( - _Xconst char* /* string */ -); -extern char *XKeysymToString( - KeySym /* keysym */ -); - -extern int (*XSynchronize( - Display* /* display */, - Bool /* onoff */ -))( - Display* /* display */ -); -extern int (*XSetAfterFunction( - Display* /* display */, - int (*) ( - Display* /* display */ - ) /* procedure */ -))( - Display* /* display */ -); -extern Atom XInternAtom( - Display* /* display */, - _Xconst char* /* atom_name */, - Bool /* only_if_exists */ -); -extern Status XInternAtoms( - Display* /* dpy */, - char** /* names */, - int /* count */, - Bool /* onlyIfExists */, - Atom* /* atoms_return */ -); -extern Colormap XCopyColormapAndFree( - Display* /* display */, - Colormap /* colormap */ -); -extern Colormap XCreateColormap( - Display* /* display */, - Window /* w */, - Visual* /* visual */, - int /* alloc */ -); -extern Cursor XCreatePixmapCursor( - Display* /* display */, - Pixmap /* source */, - Pixmap /* mask */, - XColor* /* foreground_color */, - XColor* /* background_color */, - unsigned int /* x */, - unsigned int /* y */ -); -extern Cursor XCreateGlyphCursor( - Display* /* display */, - Font /* source_font */, - Font /* mask_font */, - unsigned int /* source_char */, - unsigned int /* mask_char */, - XColor _Xconst * /* foreground_color */, - XColor _Xconst * /* background_color */ -); -extern Cursor XCreateFontCursor( - Display* /* display */, - unsigned int /* shape */ -); -extern Font XLoadFont( - Display* /* display */, - _Xconst char* /* name */ -); -extern GC XCreateGC( - Display* /* display */, - Drawable /* d */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); -extern GContext XGContextFromGC( - GC /* gc */ -); -extern void XFlushGC( - Display* /* display */, - GC /* gc */ -); -extern Pixmap XCreatePixmap( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* depth */ -); -extern Pixmap XCreateBitmapFromData( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* data */, - unsigned int /* width */, - unsigned int /* height */ -); -extern Pixmap XCreatePixmapFromBitmapData( - Display* /* display */, - Drawable /* d */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* fg */, - unsigned long /* bg */, - unsigned int /* depth */ -); -extern Window XCreateSimpleWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - unsigned long /* border */, - unsigned long /* background */ -); -extern Window XGetSelectionOwner( - Display* /* display */, - Atom /* selection */ -); -extern Window XCreateWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - int /* depth */, - unsigned int /* class */, - Visual* /* visual */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); -extern Colormap *XListInstalledColormaps( - Display* /* display */, - Window /* w */, - int* /* num_return */ -); -extern char **XListFonts( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* actual_count_return */ -); -extern char **XListFontsWithInfo( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* count_return */, - XFontStruct** /* info_return */ -); -extern char **XGetFontPath( - Display* /* display */, - int* /* npaths_return */ -); -extern char **XListExtensions( - Display* /* display */, - int* /* nextensions_return */ -); -extern Atom *XListProperties( - Display* /* display */, - Window /* w */, - int* /* num_prop_return */ -); -extern XHostAddress *XListHosts( - Display* /* display */, - int* /* nhosts_return */, - Bool* /* state_return */ -); -extern KeySym XKeycodeToKeysym( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* keycode */, -#else - KeyCode /* keycode */, -#endif - int /* index */ -); -extern KeySym XLookupKeysym( - XKeyEvent* /* key_event */, - int /* index */ -); -extern KeySym *XGetKeyboardMapping( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* first_keycode */, -#else - KeyCode /* first_keycode */, -#endif - int /* keycode_count */, - int* /* keysyms_per_keycode_return */ -); -extern KeySym XStringToKeysym( - _Xconst char* /* string */ -); -extern long XMaxRequestSize( - Display* /* display */ -); -extern long XExtendedMaxRequestSize( - Display* /* display */ -); -extern char *XResourceManagerString( - Display* /* display */ -); -extern char *XScreenResourceString( - Screen* /* screen */ -); -extern unsigned long XDisplayMotionBufferSize( - Display* /* display */ -); -extern VisualID XVisualIDFromVisual( - Visual* /* visual */ -); - -/* multithread routines */ - -extern Status XInitThreads( - void -); - -extern void XLockDisplay( - Display* /* display */ -); - -extern void XUnlockDisplay( - Display* /* display */ -); - -/* routines for dealing with extensions */ - -extern XExtCodes *XInitExtension( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XExtCodes *XAddExtension( - Display* /* display */ -); -extern XExtData *XFindOnExtensionList( - XExtData** /* structure */, - int /* number */ -); -extern XExtData **XEHeadOfExtensionList( - XEDataObject /* object */ -); - -/* these are routines for which there are also macros */ -extern Window XRootWindow( - Display* /* display */, - int /* screen_number */ -); -extern Window XDefaultRootWindow( - Display* /* display */ -); -extern Window XRootWindowOfScreen( - Screen* /* screen */ -); -extern Visual *XDefaultVisual( - Display* /* display */, - int /* screen_number */ -); -extern Visual *XDefaultVisualOfScreen( - Screen* /* screen */ -); -extern GC XDefaultGC( - Display* /* display */, - int /* screen_number */ -); -extern GC XDefaultGCOfScreen( - Screen* /* screen */ -); -extern unsigned long XBlackPixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XWhitePixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XAllPlanes( - void -); -extern unsigned long XBlackPixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XWhitePixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XNextRequest( - Display* /* display */ -); -extern unsigned long XLastKnownRequestProcessed( - Display* /* display */ -); -extern char *XServerVendor( - Display* /* display */ -); -extern char *XDisplayString( - Display* /* display */ -); -extern Colormap XDefaultColormap( - Display* /* display */, - int /* screen_number */ -); -extern Colormap XDefaultColormapOfScreen( - Screen* /* screen */ -); -extern Display *XDisplayOfScreen( - Screen* /* screen */ -); -extern Screen *XScreenOfDisplay( - Display* /* display */, - int /* screen_number */ -); -extern Screen *XDefaultScreenOfDisplay( - Display* /* display */ -); -extern long XEventMaskOfScreen( - Screen* /* screen */ -); - -extern int XScreenNumberOfScreen( - Screen* /* screen */ -); - -typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */, - XErrorEvent* /* error_event */ -); - -extern XErrorHandler XSetErrorHandler ( - XErrorHandler /* handler */ -); - - -typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */ -); - -extern XIOErrorHandler XSetIOErrorHandler ( - XIOErrorHandler /* handler */ -); - - -extern XPixmapFormatValues *XListPixmapFormats( - Display* /* display */, - int* /* count_return */ -); -extern int *XListDepths( - Display* /* display */, - int /* screen_number */, - int* /* count_return */ -); - -/* ICCCM routines for things that don't require special include files; */ -/* other declarations are given in Xutil.h */ -extern Status XReconfigureWMWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */, - unsigned int /* mask */, - XWindowChanges* /* changes */ -); - -extern Status XGetWMProtocols( - Display* /* display */, - Window /* w */, - Atom** /* protocols_return */, - int* /* count_return */ -); -extern Status XSetWMProtocols( - Display* /* display */, - Window /* w */, - Atom* /* protocols */, - int /* count */ -); -extern Status XIconifyWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XWithdrawWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XGetCommand( - Display* /* display */, - Window /* w */, - char*** /* argv_return */, - int* /* argc_return */ -); -extern Status XGetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window** /* windows_return */, - int* /* count_return */ -); -extern Status XSetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window* /* colormap_windows */, - int /* count */ -); -extern void XFreeStringList( - char** /* list */ -); -extern int XSetTransientForHint( - Display* /* display */, - Window /* w */, - Window /* prop_window */ -); - -/* The following are given in alphabetical order */ - -extern int XActivateScreenSaver( - Display* /* display */ -); - -extern int XAddHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XAddHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XAddToExtensionList( - struct _XExtData** /* structure */, - XExtData* /* ext_data */ -); - -extern int XAddToSaveSet( - Display* /* display */, - Window /* w */ -); - -extern Status XAllocColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* screen_in_out */ -); - -extern Status XAllocColorCells( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* plane_masks_return */, - unsigned int /* nplanes */, - unsigned long* /* pixels_return */, - unsigned int /* npixels */ -); - -extern Status XAllocColorPlanes( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* pixels_return */, - int /* ncolors */, - int /* nreds */, - int /* ngreens */, - int /* nblues */, - unsigned long* /* rmask_return */, - unsigned long* /* gmask_return */, - unsigned long* /* bmask_return */ -); - -extern Status XAllocNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* screen_def_return */, - XColor* /* exact_def_return */ -); - -extern int XAllowEvents( - Display* /* display */, - int /* event_mode */, - Time /* time */ -); - -extern int XAutoRepeatOff( - Display* /* display */ -); - -extern int XAutoRepeatOn( - Display* /* display */ -); - -extern int XBell( - Display* /* display */, - int /* percent */ -); - -extern int XBitmapBitOrder( - Display* /* display */ -); - -extern int XBitmapPad( - Display* /* display */ -); - -extern int XBitmapUnit( - Display* /* display */ -); - -extern int XCellsOfScreen( - Screen* /* screen */ -); - -extern int XChangeActivePointerGrab( - Display* /* display */, - unsigned int /* event_mask */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XChangeGC( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); - -extern int XChangeKeyboardControl( - Display* /* display */, - unsigned long /* value_mask */, - XKeyboardControl* /* values */ -); - -extern int XChangeKeyboardMapping( - Display* /* display */, - int /* first_keycode */, - int /* keysyms_per_keycode */, - KeySym* /* keysyms */, - int /* num_codes */ -); - -extern int XChangePointerControl( - Display* /* display */, - Bool /* do_accel */, - Bool /* do_threshold */, - int /* accel_numerator */, - int /* accel_denominator */, - int /* threshold */ -); - -extern int XChangeProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - Atom /* type */, - int /* format */, - int /* mode */, - _Xconst unsigned char* /* data */, - int /* nelements */ -); - -extern int XChangeSaveSet( - Display* /* display */, - Window /* w */, - int /* change_mode */ -); - -extern int XChangeWindowAttributes( - Display* /* display */, - Window /* w */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); - -extern Bool XCheckIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern Bool XCheckMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedEvent( - Display* /* display */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedWindowEvent( - Display* /* display */, - Window /* w */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XCirculateSubwindows( - Display* /* display */, - Window /* w */, - int /* direction */ -); - -extern int XCirculateSubwindowsDown( - Display* /* display */, - Window /* w */ -); - -extern int XCirculateSubwindowsUp( - Display* /* display */, - Window /* w */ -); - -extern int XClearArea( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - Bool /* exposures */ -); - -extern int XClearWindow( - Display* /* display */, - Window /* w */ -); - -extern int XCloseDisplay( - Display* /* display */ -); - -extern int XConfigureWindow( - Display* /* display */, - Window /* w */, - unsigned int /* value_mask */, - XWindowChanges* /* values */ -); - -extern int XConnectionNumber( - Display* /* display */ -); - -extern int XConvertSelection( - Display* /* display */, - Atom /* selection */, - Atom /* target */, - Atom /* property */, - Window /* requestor */, - Time /* time */ -); - -extern int XCopyArea( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XCopyGC( - Display* /* display */, - GC /* src */, - unsigned long /* valuemask */, - GC /* dest */ -); - -extern int XCopyPlane( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */, - unsigned long /* plane */ -); - -extern int XDefaultDepth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDefaultDepthOfScreen( - Screen* /* screen */ -); - -extern int XDefaultScreen( - Display* /* display */ -); - -extern int XDefineCursor( - Display* /* display */, - Window /* w */, - Cursor /* cursor */ -); - -extern int XDeleteProperty( - Display* /* display */, - Window /* w */, - Atom /* property */ -); - -extern int XDestroyWindow( - Display* /* display */, - Window /* w */ -); - -extern int XDestroySubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XDoesBackingStore( - Screen* /* screen */ -); - -extern Bool XDoesSaveUnders( - Screen* /* screen */ -); - -extern int XDisableAccessControl( - Display* /* display */ -); - - -extern int XDisplayCells( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeight( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeightMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayKeycodes( - Display* /* display */, - int* /* min_keycodes_return */, - int* /* max_keycodes_return */ -); - -extern int XDisplayPlanes( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidthMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDrawArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XDrawArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XDrawImageString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawImageString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawLine( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x1 */, - int /* y1 */, - int /* x2 */, - int /* y2 */ -); - -extern int XDrawLines( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawPoint( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */ -); - -extern int XDrawPoints( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XDrawRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XDrawSegments( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XSegment* /* segments */, - int /* nsegments */ -); - -extern int XDrawString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem* /* items */, - int /* nitems */ -); - -extern int XDrawText16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem16* /* items */, - int /* nitems */ -); - -extern int XEnableAccessControl( - Display* /* display */ -); - -extern int XEventsQueued( - Display* /* display */, - int /* mode */ -); - -extern Status XFetchName( - Display* /* display */, - Window /* w */, - char** /* window_name_return */ -); - -extern int XFillArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XFillArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XFillPolygon( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* shape */, - int /* mode */ -); - -extern int XFillRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XFillRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XFlush( - Display* /* display */ -); - -extern int XForceScreenSaver( - Display* /* display */, - int /* mode */ -); - -extern int XFree( - void* /* data */ -); - -extern int XFreeColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XFreeColors( - Display* /* display */, - Colormap /* colormap */, - unsigned long* /* pixels */, - int /* npixels */, - unsigned long /* planes */ -); - -extern int XFreeCursor( - Display* /* display */, - Cursor /* cursor */ -); - -extern int XFreeExtensionList( - char** /* list */ -); - -extern int XFreeFont( - Display* /* display */, - XFontStruct* /* font_struct */ -); - -extern int XFreeFontInfo( - char** /* names */, - XFontStruct* /* free_info */, - int /* actual_count */ -); - -extern int XFreeFontNames( - char** /* list */ -); - -extern int XFreeFontPath( - char** /* list */ -); - -extern int XFreeGC( - Display* /* display */, - GC /* gc */ -); - -extern int XFreeModifiermap( - XModifierKeymap* /* modmap */ -); - -extern int XFreePixmap( - Display* /* display */, - Pixmap /* pixmap */ -); - -extern int XGeometry( - Display* /* display */, - int /* screen */, - _Xconst char* /* position */, - _Xconst char* /* default_position */, - unsigned int /* bwidth */, - unsigned int /* fwidth */, - unsigned int /* fheight */, - int /* xadder */, - int /* yadder */, - int* /* x_return */, - int* /* y_return */, - int* /* width_return */, - int* /* height_return */ -); - -extern int XGetErrorDatabaseText( - Display* /* display */, - _Xconst char* /* name */, - _Xconst char* /* message */, - _Xconst char* /* default_string */, - char* /* buffer_return */, - int /* length */ -); - -extern int XGetErrorText( - Display* /* display */, - int /* code */, - char* /* buffer_return */, - int /* length */ -); - -extern Bool XGetFontProperty( - XFontStruct* /* font_struct */, - Atom /* atom */, - unsigned long* /* value_return */ -); - -extern Status XGetGCValues( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values_return */ -); - -extern Status XGetGeometry( - Display* /* display */, - Drawable /* d */, - Window* /* root_return */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned int* /* border_width_return */, - unsigned int* /* depth_return */ -); - -extern Status XGetIconName( - Display* /* display */, - Window /* w */, - char** /* icon_name_return */ -); - -extern int XGetInputFocus( - Display* /* display */, - Window* /* focus_return */, - int* /* revert_to_return */ -); - -extern int XGetKeyboardControl( - Display* /* display */, - XKeyboardState* /* values_return */ -); - -extern int XGetPointerControl( - Display* /* display */, - int* /* accel_numerator_return */, - int* /* accel_denominator_return */, - int* /* threshold_return */ -); - -extern int XGetPointerMapping( - Display* /* display */, - unsigned char* /* map_return */, - int /* nmap */ -); - -extern int XGetScreenSaver( - Display* /* display */, - int* /* timeout_return */, - int* /* interval_return */, - int* /* prefer_blanking_return */, - int* /* allow_exposures_return */ -); - -extern Status XGetTransientForHint( - Display* /* display */, - Window /* w */, - Window* /* prop_window_return */ -); - -extern int XGetWindowProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - long /* long_offset */, - long /* long_length */, - Bool /* delete */, - Atom /* req_type */, - Atom* /* actual_type_return */, - int* /* actual_format_return */, - unsigned long* /* nitems_return */, - unsigned long* /* bytes_after_return */, - unsigned char** /* prop_return */ -); - -extern Status XGetWindowAttributes( - Display* /* display */, - Window /* w */, - XWindowAttributes* /* window_attributes_return */ -); - -extern int XGrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */ -); - -extern int XGrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */ -); - -extern int XGrabKeyboard( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */, - Time /* time */ -); - -extern int XGrabPointer( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XGrabServer( - Display* /* display */ -); - -extern int XHeightMMOfScreen( - Screen* /* screen */ -); - -extern int XHeightOfScreen( - Screen* /* screen */ -); - -extern int XIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XImageByteOrder( - Display* /* display */ -); - -extern int XInstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern KeyCode XKeysymToKeycode( - Display* /* display */, - KeySym /* keysym */ -); - -extern int XKillClient( - Display* /* display */, - XID /* resource */ -); - -extern Status XLookupColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* exact_def_return */, - XColor* /* screen_def_return */ -); - -extern int XLowerWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMapRaised( - Display* /* display */, - Window /* w */ -); - -extern int XMapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XMapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XMaxCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMinCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMoveResizeWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XMoveWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */ -); - -extern int XNextEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XNoOp( - Display* /* display */ -); - -extern Status XParseColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* spec */, - XColor* /* exact_def_return */ -); - -extern int XParseGeometry( - _Xconst char* /* parsestring */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XPeekEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XPeekIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XPending( - Display* /* display */ -); - -extern int XPlanesOfScreen( - Screen* /* screen */ -); - -extern int XProtocolRevision( - Display* /* display */ -); - -extern int XProtocolVersion( - Display* /* display */ -); - - -extern int XPutBackEvent( - Display* /* display */, - XEvent* /* event */ -); - -extern int XPutImage( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XImage* /* image */, - int /* src_x */, - int /* src_y */, - int /* dest_x */, - int /* dest_y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XQLength( - Display* /* display */ -); - -extern Status XQueryBestCursor( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestSize( - Display* /* display */, - int /* class */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestStipple( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestTile( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XQueryColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* def_in_out */ -); - -extern int XQueryColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* defs_in_out */, - int /* ncolors */ -); - -extern Bool XQueryExtension( - Display* /* display */, - _Xconst char* /* name */, - int* /* major_opcode_return */, - int* /* first_event_return */, - int* /* first_error_return */ -); - -extern int XQueryKeymap( - Display* /* display */, - char [32] /* keys_return */ -); - -extern Bool XQueryPointer( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* child_return */, - int* /* root_x_return */, - int* /* root_y_return */, - int* /* win_x_return */, - int* /* win_y_return */, - unsigned int* /* mask_return */ -); - -extern int XQueryTextExtents( - Display* /* display */, - XID /* font_ID */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XQueryTextExtents16( - Display* /* display */, - XID /* font_ID */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern Status XQueryTree( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* parent_return */, - Window** /* children_return */, - unsigned int* /* nchildren_return */ -); - -extern int XRaiseWindow( - Display* /* display */, - Window /* w */ -); - -extern int XReadBitmapFile( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - Pixmap* /* bitmap_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XReadBitmapFileData( - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned char** /* data_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XRebindKeysym( - Display* /* display */, - KeySym /* keysym */, - KeySym* /* list */, - int /* mod_count */, - _Xconst unsigned char* /* string */, - int /* bytes_string */ -); - -extern int XRecolorCursor( - Display* /* display */, - Cursor /* cursor */, - XColor* /* foreground_color */, - XColor* /* background_color */ -); - -extern int XRefreshKeyboardMapping( - XMappingEvent* /* event_map */ -); - -extern int XRemoveFromSaveSet( - Display* /* display */, - Window /* w */ -); - -extern int XRemoveHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XRemoveHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XReparentWindow( - Display* /* display */, - Window /* w */, - Window /* parent */, - int /* x */, - int /* y */ -); - -extern int XResetScreenSaver( - Display* /* display */ -); - -extern int XResizeWindow( - Display* /* display */, - Window /* w */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XRestackWindows( - Display* /* display */, - Window* /* windows */, - int /* nwindows */ -); - -extern int XRotateBuffers( - Display* /* display */, - int /* rotate */ -); - -extern int XRotateWindowProperties( - Display* /* display */, - Window /* w */, - Atom* /* properties */, - int /* num_prop */, - int /* npositions */ -); - -extern int XScreenCount( - Display* /* display */ -); - -extern int XSelectInput( - Display* /* display */, - Window /* w */, - long /* event_mask */ -); - -extern Status XSendEvent( - Display* /* display */, - Window /* w */, - Bool /* propagate */, - long /* event_mask */, - XEvent* /* event_send */ -); - -extern int XSetAccessControl( - Display* /* display */, - int /* mode */ -); - -extern int XSetArcMode( - Display* /* display */, - GC /* gc */, - int /* arc_mode */ -); - -extern int XSetBackground( - Display* /* display */, - GC /* gc */, - unsigned long /* background */ -); - -extern int XSetClipMask( - Display* /* display */, - GC /* gc */, - Pixmap /* pixmap */ -); - -extern int XSetClipOrigin( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */ -); - -extern int XSetClipRectangles( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */, - XRectangle* /* rectangles */, - int /* n */, - int /* ordering */ -); - -extern int XSetCloseDownMode( - Display* /* display */, - int /* close_mode */ -); - -extern int XSetCommand( - Display* /* display */, - Window /* w */, - char** /* argv */, - int /* argc */ -); - -extern int XSetDashes( - Display* /* display */, - GC /* gc */, - int /* dash_offset */, - _Xconst char* /* dash_list */, - int /* n */ -); - -extern int XSetFillRule( - Display* /* display */, - GC /* gc */, - int /* fill_rule */ -); - -extern int XSetFillStyle( - Display* /* display */, - GC /* gc */, - int /* fill_style */ -); - -extern int XSetFont( - Display* /* display */, - GC /* gc */, - Font /* font */ -); - -extern int XSetFontPath( - Display* /* display */, - char** /* directories */, - int /* ndirs */ -); - -extern int XSetForeground( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */ -); - -extern int XSetFunction( - Display* /* display */, - GC /* gc */, - int /* function */ -); - -extern int XSetGraphicsExposures( - Display* /* display */, - GC /* gc */, - Bool /* graphics_exposures */ -); - -extern int XSetIconName( - Display* /* display */, - Window /* w */, - _Xconst char* /* icon_name */ -); - -extern int XSetInputFocus( - Display* /* display */, - Window /* focus */, - int /* revert_to */, - Time /* time */ -); - -extern int XSetLineAttributes( - Display* /* display */, - GC /* gc */, - unsigned int /* line_width */, - int /* line_style */, - int /* cap_style */, - int /* join_style */ -); - -extern int XSetModifierMapping( - Display* /* display */, - XModifierKeymap* /* modmap */ -); - -extern int XSetPlaneMask( - Display* /* display */, - GC /* gc */, - unsigned long /* plane_mask */ -); - -extern int XSetPointerMapping( - Display* /* display */, - _Xconst unsigned char* /* map */, - int /* nmap */ -); - -extern int XSetScreenSaver( - Display* /* display */, - int /* timeout */, - int /* interval */, - int /* prefer_blanking */, - int /* allow_exposures */ -); - -extern int XSetSelectionOwner( - Display* /* display */, - Atom /* selection */, - Window /* owner */, - Time /* time */ -); - -extern int XSetState( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */, - unsigned long /* background */, - int /* function */, - unsigned long /* plane_mask */ -); - -extern int XSetStipple( - Display* /* display */, - GC /* gc */, - Pixmap /* stipple */ -); - -extern int XSetSubwindowMode( - Display* /* display */, - GC /* gc */, - int /* subwindow_mode */ -); - -extern int XSetTSOrigin( - Display* /* display */, - GC /* gc */, - int /* ts_x_origin */, - int /* ts_y_origin */ -); - -extern int XSetTile( - Display* /* display */, - GC /* gc */, - Pixmap /* tile */ -); - -extern int XSetWindowBackground( - Display* /* display */, - Window /* w */, - unsigned long /* background_pixel */ -); - -extern int XSetWindowBackgroundPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* background_pixmap */ -); - -extern int XSetWindowBorder( - Display* /* display */, - Window /* w */, - unsigned long /* border_pixel */ -); - -extern int XSetWindowBorderPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* border_pixmap */ -); - -extern int XSetWindowBorderWidth( - Display* /* display */, - Window /* w */, - unsigned int /* width */ -); - -extern int XSetWindowColormap( - Display* /* display */, - Window /* w */, - Colormap /* colormap */ -); - -extern int XStoreBuffer( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */, - int /* buffer */ -); - -extern int XStoreBytes( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */ -); - -extern int XStoreColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */ -); - -extern int XStoreColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */, - int /* ncolors */ -); - -extern int XStoreName( - Display* /* display */, - Window /* w */, - _Xconst char* /* window_name */ -); - -extern int XStoreNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color */, - unsigned long /* pixel */, - int /* flags */ -); - -extern int XSync( - Display* /* display */, - Bool /* discard */ -); - -extern int XTextExtents( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextExtents16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextWidth( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int XTextWidth16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -extern Bool XTranslateCoordinates( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - int* /* dest_x_return */, - int* /* dest_y_return */, - Window* /* child_return */ -); - -extern int XUndefineCursor( - Display* /* display */, - Window /* w */ -); - -extern int XUngrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKeyboard( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabPointer( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabServer( - Display* /* display */ -); - -extern int XUninstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XUnloadFont( - Display* /* display */, - Font /* font */ -); - -extern int XUnmapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XUnmapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XVendorRelease( - Display* /* display */ -); - -extern int XWarpPointer( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - unsigned int /* src_width */, - unsigned int /* src_height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XWidthMMOfScreen( - Screen* /* screen */ -); - -extern int XWidthOfScreen( - Screen* /* screen */ -); - -extern int XWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XWriteBitmapFile( - Display* /* display */, - _Xconst char* /* filename */, - Pixmap /* bitmap */, - unsigned int /* width */, - unsigned int /* height */, - int /* x_hot */, - int /* y_hot */ -); - -extern Bool XSupportsLocale (void); - -extern char *XSetLocaleModifiers( - const char* /* modifier_list */ -); - -extern XOM XOpenOM( - Display* /* display */, - struct _XrmHashBucketRec* /* rdb */, - _Xconst char* /* res_name */, - _Xconst char* /* res_class */ -); - -extern Status XCloseOM( - XOM /* om */ -); - -extern char *XSetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern char *XGetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfOM( - XOM /* om */ -); - -extern char *XLocaleOfOM( - XOM /* om */ -); - -extern XOC XCreateOC( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern void XDestroyOC( - XOC /* oc */ -); - -extern XOM XOMOfOC( - XOC /* oc */ -); - -extern char *XSetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern char *XGetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern XFontSet XCreateFontSet( - Display* /* display */, - _Xconst char* /* base_font_name_list */, - char*** /* missing_charset_list */, - int* /* missing_charset_count */, - char** /* def_string */ -); - -extern void XFreeFontSet( - Display* /* display */, - XFontSet /* font_set */ -); - -extern int XFontsOfFontSet( - XFontSet /* font_set */, - XFontStruct*** /* font_struct_list */, - char*** /* font_name_list */ -); - -extern char *XBaseFontNameListOfFontSet( - XFontSet /* font_set */ -); - -extern char *XLocaleOfFontSet( - XFontSet /* font_set */ -); - -extern Bool XContextDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XDirectionalDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XContextualDrawing( - XFontSet /* font_set */ -); - -extern XFontSetExtents *XExtentsOfFontSet( - XFontSet /* font_set */ -); - -extern int XmbTextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XwcTextEscapement( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern int Xutf8TextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XmbTextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int XwcTextExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int Xutf8TextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XmbTextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XwcTextPerCharExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status Xutf8TextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern void XmbDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XwcDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XwcTextItem* /* text_items */, - int /* nitems */ -); - -extern void Xutf8DrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XmbDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XmbDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern XIM XOpenIM( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */ -); - -extern Status XCloseIM( - XIM /* im */ -); - -extern char *XGetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern char *XSetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfIM( - XIM /* im */ -); - -extern char *XLocaleOfIM( - XIM /* im*/ -); - -extern XIC XCreateIC( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern void XDestroyIC( - XIC /* ic */ -); - -extern void XSetICFocus( - XIC /* ic */ -); - -extern void XUnsetICFocus( - XIC /* ic */ -); - -extern wchar_t *XwcResetIC( - XIC /* ic */ -); - -extern char *XmbResetIC( - XIC /* ic */ -); - -extern char *Xutf8ResetIC( - XIC /* ic */ -); - -extern char *XSetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern char *XGetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern XIM XIMOfIC( - XIC /* ic */ -); - -extern Bool XFilterEvent( - XEvent* /* event */, - Window /* window */ -); - -extern int XmbLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int XwcLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - wchar_t* /* buffer_return */, - int /* wchars_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int Xutf8LookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern XVaNestedList XVaCreateNestedList( - int /*unused*/, ... -) _X_SENTINEL(0); - -/* internal connections for IMs */ - -extern Bool XRegisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -extern Bool XUnregisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -typedef void (*XConnectionWatchProc)( - Display* /* dpy */, - XPointer /* client_data */, - int /* fd */, - Bool /* opening */, /* open or close flag */ - XPointer* /* watch_data */ /* open sets, close uses */ -); - - -extern Status XInternalConnectionNumbers( - Display* /* dpy */, - int** /* fd_return */, - int* /* count_return */ -); - -extern void XProcessInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -extern Status XAddConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XRemoveConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XSetAuthorization( - char * /* name */, - int /* namelen */, - char * /* data */, - int /* datalen */ -); - -extern int _Xmbtowc( - wchar_t * /* wstr */, -#ifdef ISC - char const * /* str */, - size_t /* len */ -#else - char * /* str */, - int /* len */ -#endif -); - -extern int _Xwctomb( - char * /* str */, - wchar_t /* wc */ -); - -_XFUNCPROTOEND - -#endif /* _XLIB_H_ */ diff --git a/nx-X11/lib/X11/XlibAsync.c.NX.original b/nx-X11/lib/X11/XlibAsync.c.NX.original deleted file mode 100644 index 70bd82bad..000000000 --- a/nx-X11/lib/X11/XlibAsync.c.NX.original +++ /dev/null @@ -1,181 +0,0 @@ -/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1992, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -#define NEED_REPLIES -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xos.h> - -/*ARGSUSED*/ -Bool -_XAsyncErrorHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - register _XAsyncErrorState *state; - - state = (_XAsyncErrorState *)data; - if (rep->generic.type == X_Error && - (!state->error_code || - rep->error.errorCode == state->error_code) && - (!state->major_opcode || - rep->error.majorCode == state->major_opcode) && - (!state->minor_opcode || - rep->error.minorCode == state->minor_opcode) && - (!state->min_sequence_number || - (state->min_sequence_number <= dpy->last_request_read)) && - (!state->max_sequence_number || - (state->max_sequence_number >= dpy->last_request_read))) { - state->last_error_received = rep->error.errorCode; - state->error_count++; - return True; - } - return False; -} - -void _XDeqAsyncHandler(dpy, handler) - Display *dpy; - register _XAsyncHandler *handler; -{ - register _XAsyncHandler **prev; - register _XAsyncHandler *async; - - for (prev = &dpy->async_handlers; - (async = *prev) && (async != handler); - prev = &async->next) - ; - if (async) - *prev = async->next; -} - -char * -_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard) - register Display *dpy; - register char *replbuf; /* data is read into this buffer */ - register xReply *rep; /* value passed to calling handler */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int extra; /* extra words to read, ala _XReply */ - Bool discard; /* discard after extra?, ala _XReply */ -{ - if (extra == 0) { - if (discard && (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - return (char *)rep; - } - - if (extra <= rep->generic.length) { - int size = SIZEOF(xReply) + (extra << 2); - if (size > len) { - memcpy(replbuf, buf, len); - _XRead(dpy, replbuf + len, size - len); - buf = replbuf; - len = size; -#ifdef MUSTCOPY - } else { - memcpy(replbuf, buf, size); - buf = replbuf; -#endif - } - - if (discard && rep->generic.length > extra && - (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - - return buf; - } - /* - *if we get here, then extra > rep->generic.length--meaning we - * read a reply that's shorter than we expected. This is an - * error, but we still need to figure out how to handle it... - */ - if ((rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _XIOError (dpy); - return (char *)rep; -} - -void -_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal) - Display *dpy; - char *data; /* data is read into this buffer */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int skip; /* number of bytes already read in previous - _XGetAsyncReply or _XGetAsyncData calls */ - int datalen; /* size of data buffer in bytes */ - int discardtotal; /* min. bytes to consume (after skip) */ -{ - buf += skip; - len -= skip; - if (!data) { - if (datalen > len) - _XEatData(dpy, datalen - len); - } else if (datalen <= len) { - memcpy(data, buf, datalen); - } else { - memcpy(data, buf, len); - _XRead(dpy, data + len, datalen - len); - } - if (discardtotal > len) { - if (datalen > len) - len = datalen; - _XEatData(dpy, discardtotal - len); - } -} diff --git a/nx-X11/lib/X11/XlibAsync.c.X.original b/nx-X11/lib/X11/XlibAsync.c.X.original deleted file mode 100644 index a0314ba81..000000000 --- a/nx-X11/lib/X11/XlibAsync.c.X.original +++ /dev/null @@ -1,156 +0,0 @@ -/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1992, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -#define NEED_REPLIES -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xos.h> - -/*ARGSUSED*/ -Bool -_XAsyncErrorHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - register _XAsyncErrorState *state; - - state = (_XAsyncErrorState *)data; - if (rep->generic.type == X_Error && - (!state->error_code || - rep->error.errorCode == state->error_code) && - (!state->major_opcode || - rep->error.majorCode == state->major_opcode) && - (!state->minor_opcode || - rep->error.minorCode == state->minor_opcode) && - (!state->min_sequence_number || - (state->min_sequence_number <= dpy->last_request_read)) && - (!state->max_sequence_number || - (state->max_sequence_number >= dpy->last_request_read))) { - state->last_error_received = rep->error.errorCode; - state->error_count++; - return True; - } - return False; -} - -void _XDeqAsyncHandler(dpy, handler) - Display *dpy; - register _XAsyncHandler *handler; -{ - register _XAsyncHandler **prev; - register _XAsyncHandler *async; - - for (prev = &dpy->async_handlers; - (async = *prev) && (async != handler); - prev = &async->next) - ; - if (async) - *prev = async->next; -} - -char * -_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard) - register Display *dpy; - register char *replbuf; /* data is read into this buffer */ - register xReply *rep; /* value passed to calling handler */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int extra; /* extra words to read, ala _XReply */ - Bool discard; /* discard after extra?, ala _XReply */ -{ - if (extra == 0) { - if (discard && (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - return (char *)rep; - } - - if (extra <= rep->generic.length) { - int size = SIZEOF(xReply) + (extra << 2); - if (size > len) { - memcpy(replbuf, buf, len); - _XRead(dpy, replbuf + len, size - len); - buf = replbuf; - len = size; -#ifdef MUSTCOPY - } else { - memcpy(replbuf, buf, size); - buf = replbuf; -#endif - } - - if (discard && rep->generic.length > extra && - (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - - return buf; - } - /* - *if we get here, then extra > rep->generic.length--meaning we - * read a reply that's shorter than we expected. This is an - * error, but we still need to figure out how to handle it... - */ - if ((rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - _XIOError (dpy); - return (char *)rep; -} - -void -_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal) - Display *dpy; - char *data; /* data is read into this buffer */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int skip; /* number of bytes already read in previous - _XGetAsyncReply or _XGetAsyncData calls */ - int datalen; /* size of data buffer in bytes */ - int discardtotal; /* min. bytes to consume (after skip) */ -{ - buf += skip; - len -= skip; - if (!data) { - if (datalen > len) - _XEatData(dpy, datalen - len); - } else if (datalen <= len) { - memcpy(data, buf, datalen); - } else { - memcpy(data, buf, len); - _XRead(dpy, data + len, datalen - len); - } - if (discardtotal > len) { - if (datalen > len) - len = datalen; - _XEatData(dpy, discardtotal - len); - } -} diff --git a/nx-X11/lib/X11/XlibInt.c.NX.original b/nx-X11/lib/X11/XlibInt.c.NX.original deleted file mode 100644 index 47e2ea139..000000000 --- a/nx-X11/lib/X11/XlibInt.c.NX.original +++ /dev/null @@ -1,4167 +0,0 @@ -/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */ - -/* - * XlibInt.c - Internal support routines for the C subroutine - * interface library (Xlib) to the X Window System Protocol V11.0. - */ -#define NEED_EVENTS -#define NEED_REPLIES - -#ifdef WIN32 -#define _XLIBINT_ -#endif -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xpoll.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/extensions/xcmiscstr.h> -#include <stdio.h> -#ifdef WIN32 -#include <direct.h> -#endif - -#ifdef XTHREADS -#include "locking.h" - -/* these pointers get initialized by XInitThreads */ -LockInfoPtr _Xglobal_lock = NULL; -void (*_XCreateMutex_fn)(LockInfoPtr) = NULL; -/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */ -void (*_XFreeMutex_fn)(LockInfoPtr) = NULL; -void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = NULL; -void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = NULL; -xthread_t (*_Xthread_self_fn)(void) = NULL; - -#define XThread_Self() ((*_Xthread_self_fn)()) - -#define UnlockNextReplyReader(d) if ((d)->lock) \ - (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail) - -#define QueueReplyReaderLock(d) ((d)->lock ? \ - (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL) -#define QueueEventReaderLock(d) ((d)->lock ? \ - (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL) - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define InternalLockDisplay(d,wskip) if ((d)->lock) \ - (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__) -#else -#define InternalLockDisplay(d,wskip) if ((d)->lock) \ - (*(d)->lock->internal_lock_display)(d,wskip) -#endif - -#else /* XTHREADS else */ - -#define UnlockNextReplyReader(d) -#define UnlockNextEventReader(d) -#define InternalLockDisplay(d,wskip) - -#endif /* XTHREADS else */ - -#include "NX.h" - -#ifdef NX_TRANS_SOCKET - -#include "NX.h" -#include "NXvars.h" - -static struct timeval retry; - -/* - * From Xtranssock.c. Presently the congestion state - * is reported by the proxy to the application, by - * invoking the callback directly. The function will - * be possibly used in the future, to be able to track - * the bandwidth usage even when the NX transport is - * not running. Note that in this sample implementation - * the congestion state is checked very often and can - * be surely optimized. - */ - -#ifdef NX_TRANS_CHANGE - -extern int _X11TransSocketCongestionChange(XtransConnInfo, int *); - -#endif - -#endif /* #ifdef NX_TRANS_SOCKET */ - -/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX - * systems are broken and return EWOULDBLOCK when they should return EAGAIN - */ -#ifdef WIN32 -#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK) -#else -#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */ -#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) -#else -#if defined(EAGAIN) && defined(EWOULDBLOCK) -#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK) -#else -#ifdef EAGAIN -#define ETEST() (errno == EAGAIN) -#else -#define ETEST() (errno == EWOULDBLOCK) -#endif /* EAGAIN */ -#endif /* EAGAIN && EWOULDBLOCK */ -#endif /* __CYGWIN__ */ -#endif /* WIN32 */ - -#ifdef WIN32 -#define ECHECK(err) (WSAGetLastError() == err) -#define ESET(val) WSASetLastError(val) -#else -#ifdef __UNIXOS2__ -#define ECHECK(err) (errno == err) -#define ESET(val) -#else -#ifdef ISC -#define ECHECK(err) ((errno == err) || ETEST()) -#else -#define ECHECK(err) (errno == err) -#endif -#define ESET(val) errno = val -#endif -#endif - -#if defined(LOCALCONN) || defined(LACHMAN) -#ifdef EMSGSIZE -#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE)) -#else -#define ESZTEST() ECHECK(ERANGE) -#endif -#else -#ifdef EMSGSIZE -#define ESZTEST() ECHECK(EMSGSIZE) -#endif -#endif - -#ifdef __UNIXOS2__ -#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t) -#include <limits.h> -#define MAX_PATH _POSIX_PATH_MAX -#endif - -#ifdef MUSTCOPY - -#define STARTITERATE(tpvar,type,start,endcond) \ - { register char *cpvar; \ - for (cpvar = (char *) (start); endcond; ) { \ - type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \ - tpvar = &dummy; -#define ITERPTR(tpvar) cpvar -#define RESETITERPTR(tpvar,type,start) cpvar = start -#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type) -#define ENDITERATE }} - -#else - -#define STARTITERATE(tpvar,type,start,endcond) \ - for (tpvar = (type *) (start); endcond; ) -#define ITERPTR(tpvar) (char *)tpvar -#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start) -#define INCITERPTR(tpvar,type) tpvar++ -#define ENDITERATE - -#endif /* MUSTCOPY */ - -typedef union { - xReply rep; - char buf[BUFSIZE]; -} _XAlignedBuffer; - -static char *_XAsyncReply( - Display *dpy, - register xReply *rep, - char *buf, - register int *lenp, - Bool discard); - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info); - -#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10) - -/* - * The following routines are internal routines used by Xlib for protocol - * packet transmission and reception. - * - * _XIOError(Display *) will be called if any sort of system call error occurs. - * This is assumed to be a fatal condition, i.e., XIOError should not return. - * - * _XError(Display *, xError *) will be called whenever an X_Error event is - * received. This is not assumed to be a fatal condition, i.e., it is - * acceptable for this procedure to return. However, XError should NOT - * perform any operations (directly or indirectly) on the DISPLAY. - * - * Routines declared with a return type of 'Status' return 0 on failure, - * and non 0 on success. Routines with no declared return type don't - * return anything. Whenever possible routines that create objects return - * the object they have created. - */ - -static xReq _dummy_request = { - 0, 0, 0 -}; - -#ifdef NX_TRANS_SOCKET - -/* - * Replace the standard Select with a version giving NX a - * chance to check its own descriptors. This doesn't cover - * the cases where the system is using poll or when system- - * specific defines override the Select definition (OS/2). - */ - -int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XSelect: Called with [%d][%p][%p][%p][%p].\n", - maxfds, (void *) readfds, (void *) writefds, (void *) exceptfds, - (void *) timeout); -#endif - - if (NXTransRunning(NX_FD_ANY)) - { - fd_set t_readfds, t_writefds; - struct timeval t_timeout; - - int n, r, e; - -#ifdef NX_TRANS_TEST - - if (exceptfds != NULL) - { - fprintf(stderr, "_XSelect: WARNING! Can't handle exception fds in select.\n"); - } - -#endif - - if (readfds == NULL) - { - FD_ZERO(&t_readfds); - - readfds = &t_readfds; - } - - if (writefds == NULL) - { - FD_ZERO(&t_writefds); - - writefds = &t_writefds; - } - - if (timeout == NULL) - { - t_timeout.tv_sec = 10; - t_timeout.tv_usec = 0; - - timeout = &t_timeout; - } - - n = maxfds; - - /* - * If the transport is gone avoid - * sleeping until the timeout. - */ - - if (NXTransPrepare(&n, readfds, writefds, timeout) != 0) - { - NXTransSelect(&r, &e, &n, readfds, writefds, timeout); - - NXTransExecute(&r, &e, &n, readfds, writefds, timeout); - - errno = e; - - return r; - } - else - { - return 0; - } - } - else - { - return select(maxfds, readfds, writefds, exceptfds, timeout); - } -} - -#else /* #ifdef NX_TRANS_SOCKET */ - -int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - return select(maxfds, readfds, writefds, exceptfds, timeout); -} - -#endif /* #ifdef NX_TRANS_SOCKET */ - -/* - * This is an OS dependent routine which: - * 1) returns as soon as the connection can be written on.... - * 2) if the connection can be read, must enqueue events and handle errors, - * until the connection is writable. - */ -static void -_XWaitForWritable( - Display *dpy -#ifdef XTHREADS - , - xcondition_t cv /* our reading condition variable */ -#endif - ) -{ -#ifdef USE_POLL - struct pollfd filedes; -#else - fd_set r_mask; - fd_set w_mask; -#endif - int nfound; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#ifdef NX_TRANS_SOCKET - - if (_XGetIOError(dpy)) { - return; - } - -#endif - -#ifdef USE_POLL - filedes.fd = dpy->fd; - filedes.events = 0; -#else - FD_ZERO(&r_mask); - FD_ZERO(&w_mask); -#endif - - for (;;) { -#ifdef XTHREADS - /* We allow only one thread at a time to read, to minimize - passing of read data between threads. - Now, who is it? If there is a non-NULL reply_awaiters and - we (i.e., our cv) are not at the head of it, then whoever - is at the head is the reader, and we don't read. - Otherwise there is no reply_awaiters or we are at the - head, having just appended ourselves. - In this case, if there is a event_awaiters, then whoever - is at the head of it got there before we did, and they are the - reader. - - Last cases: no event_awaiters and we are at the head of - reply_awaiters or reply_awaiters is NULL: we are the reader, - since there is obviously no one else involved. - - XXX - what if cv is NULL and someone else comes along after - us while we are waiting? - */ - - if (!dpy->lock || - (!dpy->lock->event_awaiters && - (!dpy->lock->reply_awaiters || - dpy->lock->reply_awaiters->cv == cv))) -#endif - -#ifndef NX_TRANS_SOCKET -#ifdef USE_POLL - filedes.events = POLLIN; - filedes.events |= POLLOUT; -#else - FD_SET(dpy->fd, &r_mask); - FD_SET(dpy->fd, &w_mask); -#endif -#endif /* #ifndef NX_TRANS_SOCKET */ - - do { -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the registered client to perform - * any needed operation before entering the select. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XWaitForWritable: WAIT! Waiting for the display to become writable.\n"); -#endif - NXTransFlush(dpy->fd); - - if (_NXDisplayBlockFunction != NULL) { - (*_NXDisplayBlockFunction)(dpy, NXBlockWrite); - } - - /* - * Need to set again the descriptors as we could have - * run multiple selects before having the possibility - * to read or write to the X connection. - */ - -#ifdef USE_POLL - filedes.events = POLLIN; - filedes.events |= POLLOUT; -#else - FD_SET(dpy->fd, &r_mask); - FD_SET(dpy->fd, &w_mask); -#endif -#endif /* #ifdef NX_TRANS_SOCKET */ - - UnlockDisplay(dpy); -#ifdef USE_POLL -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Calling poll().\n"); -#endif - nfound = poll (&filedes, 1, -1); -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Calling select() after [%ld] ms.\n", - NXTransTime()); -#endif -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the callback to detect - * the failure of the display even if we - * miss the interrupt inside the select. - */ - - if (_NXDisplayErrorFunction != NULL) { - retry.tv_sec = 5; - retry.tv_usec = 0; - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, &retry); - } else { - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL); - } -#else - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL); -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Out of select() with [%d] after [%ld] ms.\n", - nfound, NXTransTime()); - - if (FD_ISSET(dpy->fd, &r_mask)) - { - BytesReadable_t pend; - - _X11TransBytesReadable(dpy->trans_conn, &pend); - - fprintf(stderr, "_XWaitForWritable: Descriptor [%d] is ready with [%ld] bytes to read.\n", - dpy->fd, pend); - } - - if (FD_ISSET(dpy->fd, &w_mask)) - { - fprintf(stderr, "_XWaitForWritable: Descriptor [%d] has become writable.\n\n", - dpy->fd); - } -#endif -#endif - InternalLockDisplay(dpy, cv != NULL); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif - -#ifdef NX_TRANS_SOCKET - if (nfound <= 0) { - if ((nfound == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } - } -#else - if (nfound < 0 && !ECHECK(EINTR)) - _XIOError(dpy); -#endif - } while (nfound <= 0); - - if ( -#ifdef USE_POLL - filedes.revents & POLLIN -#else - FD_ISSET(dpy->fd, &r_mask) -#endif - ) - { - _XAlignedBuffer buf; - BytesReadable_t pend; - register int len; - register xReply *rep; - - /* find out how much data can be read */ - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return; - } -#else - _XIOError(dpy); -#endif - len = pend; - - /* must read at least one xEvent; if none is pending, then - we'll just block waiting for it */ - if (len < SIZEOF(xReply) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) - len = SIZEOF(xReply); - - /* but we won't read more than the max buffer size */ - if (len > BUFSIZE) len = BUFSIZE; - - /* round down to an integral number of XReps */ - len = (len / SIZEOF(xReply)) * SIZEOF(xReply); - - (void) _XRead (dpy, buf.buf, (long) len); - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - int tmp = len; - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &tmp, True)); - len = tmp; - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *)rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE -#ifdef XTHREADS - if (dpy->lock && dpy->lock->event_awaiters) - ConditionSignal(dpy, dpy->lock->event_awaiters->cv); -#endif - } -#ifdef USE_POLL - if (filedes.revents & (POLLOUT|POLLHUP|POLLERR)) -#else - if (FD_ISSET(dpy->fd, &w_mask)) -#endif - { -#ifdef XTHREADS - if (dpy->lock) { - ConditionBroadcast(dpy, dpy->lock->writers); - } -#endif - return; - } - } -} - - -#define POLLFD_CACHE_SIZE 5 - -/* initialize the struct array passed to poll() below */ -Bool _XPollfdCacheInit( - Display *dpy) -{ -#ifdef USE_POLL - struct pollfd *pfp; - - pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd)); - if (!pfp) - return False; - pfp[0].fd = dpy->fd; - pfp[0].events = POLLIN; - - dpy->filedes = (XPointer)pfp; -#endif - return True; -} - -void _XPollfdCacheAdd( - Display *dpy, - int fd) -{ -#ifdef USE_POLL - struct pollfd *pfp = (struct pollfd *)dpy->filedes; - - if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) { - pfp[dpy->im_fd_length].fd = fd; - pfp[dpy->im_fd_length].events = POLLIN; - } -#endif -} - -/* ARGSUSED */ -void _XPollfdCacheDel( - Display *dpy, - int fd) /* not used */ -{ -#ifdef USE_POLL - struct pollfd *pfp = (struct pollfd *)dpy->filedes; - struct _XConnectionInfo *conni; - - /* just recalculate whole list */ - if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) { - int loc = 1; - for (conni = dpy->im_fd_info; conni; conni=conni->next) { - pfp[loc].fd = conni->fd; - pfp[loc].events = POLLIN; - loc++; - } - } -#endif -} - -/* returns True iff there is an event in the queue newer than serial_num */ - -static Bool -_XNewerQueuedEvent( - Display *dpy, - int serial_num) -{ - _XQEvent *qev; - - if (dpy->next_event_serial_num == serial_num) - return False; - - qev = dpy->head; - while (qev) { - if (qev->qserial_num >= serial_num) { - return True; - } - qev = qev->next; - } - return False; -} - -static int -_XWaitForReadable( - Display *dpy) -{ - int result; - int fd = dpy->fd; - struct _XConnectionInfo *ilist; - register int saved_event_serial = 0; - int in_read_events = 0; - register Bool did_proc_conni = False; -#ifdef USE_POLL - struct pollfd *filedes; -#else - fd_set r_mask; - int highest_fd = fd; -#endif - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return -1; - } -#endif - -#ifdef USE_POLL - if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE - && !(dpy->flags & XlibDisplayProcConni)) { - /* XXX - this fallback is gross */ - int i; - - filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd)); - filedes[0].fd = fd; - filedes[0].events = POLLIN; - for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) { - filedes[i].fd = ilist->fd; - filedes[i].events = POLLIN; - } - } else { - filedes = (struct pollfd *)dpy->filedes; - } -#else - FD_ZERO(&r_mask); -#endif - for (;;) { -#ifndef USE_POLL - FD_SET(fd, &r_mask); - if (!(dpy->flags & XlibDisplayProcConni)) - for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) { - FD_SET(ilist->fd, &r_mask); - if (ilist->fd > highest_fd) - highest_fd = ilist->fd; - } -#endif - UnlockDisplay(dpy); -#ifdef USE_POLL -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Calling poll().\n"); -#endif - result = poll(filedes, - (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length, - -1); -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Calling select().\n"); -#endif -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the registered application - * to perform any needed operation. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XWaitForReadable: WAIT! Waiting for the display to become readable.\n"); -#endif - NXTransFlush(dpy->fd); - - if (_NXDisplayBlockFunction != NULL) { - (*_NXDisplayBlockFunction)(dpy, NXBlockRead); - } - - if (_NXDisplayErrorFunction != NULL) { - retry.tv_sec = 5; - retry.tv_usec = 0; - result = Select(highest_fd + 1, &r_mask, NULL, NULL, &retry); - } else { - result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL); - } -#else - result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL); -#endif -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Out of select with result [%d] and errno [%d].\n", - result, (result < 0 ? errno : 0)); -#endif - InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#ifdef NX_TRANS_SOCKET - if (result <= 0) { - if ((result == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return -1; - } - continue; - } -#else - if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy); - if (result <= 0) - continue; -#endif -#ifdef USE_POLL - if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR)) -#else - if (FD_ISSET(fd, &r_mask)) -#endif - break; - if (!(dpy->flags & XlibDisplayProcConni)) { - int i; - - saved_event_serial = dpy->next_event_serial_num; - /* dpy flags can be clobbered by internal connection callback */ - in_read_events = dpy->flags & XlibDisplayReadEvents; - for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) { -#ifdef USE_POLL - if (filedes[i].revents & POLLIN) -#else - if (FD_ISSET(ilist->fd, &r_mask)) -#endif - { - _XProcessInternalConnection(dpy, ilist); - did_proc_conni = True; - } - } -#ifdef USE_POLL - if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE) - Xfree(filedes); -#endif - } - if (did_proc_conni) { - /* some internal connection callback might have done an - XPutBackEvent. We notice it here and if we needed an event, - we can return all the way. */ - if (_XNewerQueuedEvent(dpy, saved_event_serial) - && (in_read_events -#ifdef XTHREADS - || (dpy->lock && dpy->lock->event_awaiters) -#endif - )) - return -2; - did_proc_conni = False; - } - } -#ifdef XTHREADS -#ifdef XTHREADS_DEBUG - printf("thread %x _XWaitForReadable returning\n", XThread_Self()); -#endif -#endif - return 0; -} - -static -int _XSeqSyncFunction( - register Display *dpy) -{ - xGetInputFocusReply rep; - register xReq *req; - -#ifdef NX_TRANS_SOCKET -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n"); -#endif - if (dpy->flags & XlibDisplayIOError) - { -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n"); -#endif - return 0; - } -#endif - - LockDisplay(dpy); - if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { - GetEmptyReq(GetInputFocus, req); - (void) _XReply (dpy, (xReply *)&rep, 0, xTrue); - } - /* could get XID handler while waiting for reply in MT env */ - if (dpy->synchandler == _XSeqSyncFunction) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -#ifdef XTHREADS -static void _XFlushInt( - register Display *dpy, - register xcondition_t cv); -#endif - -/* - * _XFlush - Flush the X request buffer. If the buffer is empty, no - * action is taken. This routine correctly handles incremental writes. - * This routine may have to be reworked if int < long. - */ -void _XFlush( - register Display *dpy) -{ -#ifdef XTHREADS - /* With multi-threading we introduce an internal routine to which - we can pass a condition variable to do locking correctly. */ - - _XFlushInt(dpy, NULL); -} - -/* _XFlushInt - Internal version of _XFlush used to do multi-threaded - * locking correctly. - */ - -static void _XFlushInt( - register Display *dpy, - register xcondition_t cv) -{ -#endif /* XTHREADS*/ - register long size, todo; - register int write_stat; - register char *bufindex; - _XExtension *ext; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n", - (dpy->bufptr - dpy->buffer)); -#endif - /* This fix resets the bufptr to the front of the buffer so - * additional appends to the bufptr will not corrupt memory. Since - * the server is down, these appends are no-op's anyway but - * callers of _XFlush() are not verifying this before they call it. - */ - if (dpy->flags & XlibDisplayIOError) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n"); -#endif - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *)&_dummy_request; - return; - } - -#ifdef XTHREADS -#ifdef NX_TRANS_SOCKET - while (dpy->flags & XlibDisplayWriting) { - if (_XGetIOError(dpy)) { - return; - } -#else - while (dpy->flags & XlibDisplayWriting) { -#endif - if (dpy->lock) { - ConditionWait(dpy, dpy->lock->writers); - } else { - _XWaitForWritable (dpy, cv); - } - } -#endif - size = todo = dpy->bufptr - dpy->buffer; - if (!size) return; -#ifdef XTHREADS - dpy->flags |= XlibDisplayWriting; - /* make sure no one else can put in data */ - dpy->bufptr = dpy->bufmax; -#endif - for (ext = dpy->flushes; ext; ext = ext->next_flush) - (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size); - bufindex = dpy->buffer; - /* - * While write has not written the entire buffer, keep looping - * until the entire buffer is written. bufindex will be - * incremented and size decremented as buffer is written out. - */ - while (size) { - ESET(0); - write_stat = _X11TransWrite(dpy->trans_conn, - bufindex, (int) todo); - if (write_stat >= 0) { -#ifdef NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, write_stat); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - size -= write_stat; - todo = size; - bufindex += write_stat; - } else if (ETEST()) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); -#ifdef SUNSYSV - } else if (ECHECK(0)) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); -#endif -#ifdef ESZTEST - } else if (ESZTEST()) { - if (todo > 1) - todo >>= 1; - else { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); - } -#endif -#ifdef NX_TRANS_SOCKET - } else if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - } else if (!ECHECK(EINTR)) { - /* Write failed! */ - /* errno set by write system call. */ - _XIOError(dpy); - } -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } - dpy->last_req = (char *)&_dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->bufptr = dpy->buffer; -#ifdef XTHREADS - dpy->flags &= ~XlibDisplayWriting; -#endif -} - -int -_XEventsQueued( - register Display *dpy, - int mode) -{ - register int len; - BytesReadable_t pend; - _XAlignedBuffer buf; - register xReply *rep; - char *read_buf; -#ifdef XTHREADS - int entry_event_serial_num; - struct _XCVList *cvl = NULL; - xthread_t self; - -#ifdef XTHREADS_DEBUG - printf("_XEventsQueued called in thread %x\n", XThread_Self()); -#endif -#endif /* XTHREADS*/ - - if (mode == QueuedAfterFlush) - { - _XFlush(dpy); - if (dpy->qlen) - return(dpy->qlen); - } -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - if (dpy->flags & XlibDisplayIOError) { - fprintf(stderr, "_XEventsQueued: Returning [%d] after display failure.\n", - dpy->qlen); - } -#endif - if (dpy->flags & XlibDisplayIOError) return(dpy->qlen); - -#ifdef XTHREADS - /* create our condition variable and append to list, - * unless we were called from within XProcessInternalConnection - * or XLockDisplay - */ - xthread_clear_id(self); - if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread) - || xthread_have_id (dpy->lock->locking_thread))) - /* some thread is in XProcessInternalConnection or XLockDisplay - so we have to see if we are it */ - self = XThread_Self(); - if (!xthread_have_id(self) - || (!xthread_equal(self, dpy->lock->conni_thread) - && !xthread_equal(self, dpy->lock->locking_thread))) { - /* In the multi-threaded case, if there is someone else - reading events, then there aren't any available, so - we just return. If we waited we would block. - */ - if (dpy->lock && dpy->lock->event_awaiters) - return dpy->qlen; - /* nobody here but us, so lock out any newcomers */ - cvl = QueueEventReaderLock(dpy); - } - - while (dpy->lock && cvl && dpy->lock->reply_first) { - /* note which events we have already seen so we'll know - if _XReply (in another thread) reads one */ - entry_event_serial_num = dpy->next_event_serial_num; - ConditionWait(dpy, cvl->cv); - /* did _XReply read an event we can return? */ - if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) - { - UnlockNextEventReader(dpy); - return 0; - } - } -#endif /* XTHREADS*/ - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Checking bytes readable.\n"); -#endif - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return (dpy->qlen); - } -#else - _XIOError(dpy); -#endif -#ifdef XCONN_CHECK_FREQ - /* This is a crock, required because FIONREAD or equivalent is - * not guaranteed to detect a broken connection. - */ - if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ) - { - int result; -#ifdef USE_POLL - struct pollfd filedes; -#else - fd_set r_mask; - static struct timeval zero_time; -#endif - - dpy->conn_checker = 0; -#ifdef USE_POLL -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Calling poll().\n"); -#endif - filedes.fd = dpy->fd; - filedes.events = POLLIN; - if ((result = poll(&filedes, 1, 0))) -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Calling select().\n"); -#endif - FD_ZERO(&r_mask); - FD_SET(dpy->fd, &r_mask); - if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time))) -#endif - { - if (result > 0) - { - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return (dpy->qlen); - } -#else - _XIOError(dpy); -#endif - /* we should not get zero, if we do, force a read */ - if (!pend) - pend = SIZEOF(xReply); - } -#ifdef NX_TRANS_SOCKET - if (result <= 0) { - if ((result == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return (dpy->qlen); - } - } -#else - else if (result < 0 && !ECHECK(EINTR)) - _XIOError(dpy); -#endif - } - } -#endif /* XCONN_CHECK_FREQ */ - if (!(len = pend)) { - /* _XFlush can enqueue events */ -#ifdef XTHREADS - if (cvl) -#endif - { - UnlockNextEventReader(dpy); - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Returning [%d].\n", dpy->qlen); -#endif - return(dpy->qlen); - } - /* Force a read if there is not enough data. Otherwise, - * a select() loop at a higher-level will spin undesirably, - * and we've seen at least one OS that appears to not update - * the result from FIONREAD once it has returned nonzero. - */ -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_awaiters) { - read_buf = (char *)dpy->lock->reply_awaiters->buf; - len = SIZEOF(xReply); - } else -#endif /* XTHREADS*/ - { - read_buf = buf.buf; - - if (len < SIZEOF(xReply) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) - len = SIZEOF(xReply); - else if (len > BUFSIZE) - len = BUFSIZE; - len = (len / SIZEOF(xReply)) * SIZEOF(xReply); - } -#ifdef XCONN_CHECK_FREQ - dpy->conn_checker = 0; -#endif - - (void) _XRead (dpy, read_buf, (long) len); - -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return(dpy->qlen); - } -#endif -#ifdef XTHREADS - /* what did we actually read: reply or event? */ - if (dpy->lock && dpy->lock->reply_awaiters) { - if (((xReply *)read_buf)->generic.type == X_Reply || - ((xReply *)read_buf)->generic.type == X_Error) - { - dpy->lock->reply_was_read = True; - dpy->lock->reply_first = True; - if (read_buf != (char *)dpy->lock->reply_awaiters->buf) - memcpy(dpy->lock->reply_awaiters->buf, read_buf, - len); - if (cvl) { - UnlockNextEventReader(dpy); - } - return(dpy->qlen); /* we read, so we can return */ - } else if (read_buf != buf.buf) - memcpy(buf.buf, read_buf, len); - } -#endif /* XTHREADS*/ - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - int tmp = len; - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &tmp, True)); - len = tmp; - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *)rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE - -#ifdef XTHREADS - if (cvl) -#endif - { - UnlockNextEventReader(dpy); - } - return(dpy->qlen); -} - -/* _XReadEvents - Flush the output queue, - * then read as many events as possible (but at least 1) and enqueue them - */ -void _XReadEvents( - register Display *dpy) -{ - _XAlignedBuffer buf; - BytesReadable_t pend; - int len; - register xReply *rep; - Bool not_yet_flushed = True; - char *read_buf; - int i; - int entry_event_serial_num = dpy->next_event_serial_num; -#ifdef XTHREADS - struct _XCVList *cvl = NULL; - xthread_t self; - -#ifdef XTHREADS_DEBUG - printf("_XReadEvents called in thread %x\n", - XThread_Self()); -#endif - /* create our condition variable and append to list, - * unless we were called from within XProcessInternalConnection - * or XLockDisplay - */ - xthread_clear_id(self); - if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread) - || xthread_have_id (dpy->lock->locking_thread))) - /* some thread is in XProcessInternalConnection or XLockDisplay - so we have to see if we are it */ - self = XThread_Self(); - if (!xthread_have_id(self) - || (!xthread_equal(self, dpy->lock->conni_thread) - && !xthread_equal(self, dpy->lock->locking_thread))) - cvl = QueueEventReaderLock(dpy); -#endif /* XTHREADS */ - - do { -#ifdef XTHREADS - /* if it is not our turn to read an event off the wire, - wait til we're at head of list */ - if (dpy->lock && cvl && - (dpy->lock->event_awaiters != cvl || - dpy->lock->reply_first)) { - ConditionWait(dpy, cvl->cv); - continue; - } -#endif /* XTHREADS */ - /* find out how much data can be read */ - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return; - } -#else - _XIOError(dpy); -#endif - len = pend; - - /* must read at least one xEvent; if none is pending, then - we'll just flush and block waiting for it */ - if (len < SIZEOF(xEvent) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) { - len = SIZEOF(xEvent); - /* don't flush until the first time we would block */ - if (not_yet_flushed) { - _XFlush (dpy); - if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) { - /* _XReply has read an event for us */ - goto got_event; - } - not_yet_flushed = False; - } - } - -#ifdef XTHREADS - /* If someone is waiting for a reply, gamble that - the reply will be the next thing on the wire - and read it into their buffer. */ - if (dpy->lock && dpy->lock->reply_awaiters) { - read_buf = (char *)dpy->lock->reply_awaiters->buf; - len = SIZEOF(xReply); - } else -#endif /* XTHREADS*/ - { - read_buf = buf.buf; - - /* but we won't read more than the max buffer size */ - if (len > BUFSIZE) - len = BUFSIZE; - - /* round down to an integral number of XReps */ - len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent); - } - -#ifdef XTHREADS - if (xthread_have_id(self)) - /* save value we may have to stick in conni_thread */ - dpy->lock->reading_thread = self; -#endif /* XTHREADS */ - dpy->flags |= XlibDisplayReadEvents; - i = _XRead (dpy, read_buf, (long) len); - dpy->flags &= ~XlibDisplayReadEvents; -#ifdef NX_TRANS_SOCKET - if (dpy->flags & XlibDisplayIOError) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n"); -#endif - return; - } -#endif - if (i == -2) { - /* special flag from _XRead to say that internal connection has - done XPutBackEvent. Which we can use so we're done. */ - got_event: -#ifdef XTHREADS - if (dpy->lock && dpy->lock->lock_wait) { - if (dpy->lock->event_awaiters != cvl) - /* since it is not us, must be user lock thread */ - ConditionSignal(dpy, - dpy->lock->event_awaiters->cv); - (*dpy->lock->lock_wait)(dpy); - continue; - } -#endif - break; - } -#ifdef XTHREADS - if (xthread_have_id(self)) - xthread_clear_id(dpy->lock->reading_thread); - - /* what did we actually read: reply or event? */ - if (dpy->lock && dpy->lock->reply_awaiters) { - if (((xReply *)read_buf)->generic.type == X_Reply || - ((xReply *)read_buf)->generic.type == X_Error) - { - dpy->lock->reply_was_read = True; - dpy->lock->reply_first = True; - if (read_buf != (char *)dpy->lock->reply_awaiters->buf) - memcpy(dpy->lock->reply_awaiters->buf, - read_buf, len); - ConditionSignal(dpy, dpy->lock->reply_awaiters->cv); - continue; - } else if (read_buf != buf.buf) - memcpy(buf.buf, read_buf, len); - } -#endif /* XTHREADS */ - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &len, True)); - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *) rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE; - } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num)); - - UnlockNextEventReader(dpy); -} - -/* - * _XRead - Read bytes from the socket taking into account incomplete - * reads. This routine may have to be reworked if int < long. - */ -int _XRead( - register Display *dpy, - register char *data, - register long size) -{ - register long bytes_read; -#ifdef XTHREADS - int original_size = size; -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - - if ((dpy->flags & XlibDisplayIOError) || size == 0) - return 0; - ESET(0); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - while (1) { - /* - * Need to check the congestion state - * after the read so split the statement - * in multiple blocks. - */ - - bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size); - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } - if (bytes_read == size) { - break; - } -#else - while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size)) - != size) { -#endif - - if (bytes_read > 0) { - size -= bytes_read; - data += bytes_read; - } - else if (ETEST()) { - if (_XWaitForReadable(dpy) == -2) - return -2; /* internal connection did XPutBackEvent */ - ESET(0); - } -#ifdef SUNSYSV - else if (ECHECK(0)) { - if (_XWaitForReadable(dpy) == -2) - return -2; /* internal connection did XPutBackEvent */ - } -#endif - else if (bytes_read == 0) { - /* Read failed because of end of file! */ - ESET(EPIPE); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return -1; -#else - _XIOError(dpy); -#endif - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ -#ifdef NX_TRANS_SOCKET - if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return -1; - } -#else - if (!ECHECK(EINTR)) - _XIOError(dpy); -#endif - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return -1; - } -#endif - } -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_bytes_left > 0) - { - dpy->lock->reply_bytes_left -= original_size; - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } -#endif /* XTHREADS*/ - return 0; -} - -#ifdef LONG64 -void _XRead32( - Display *dpy, - register long *data, - long len) -{ - register int *buf; - register long i; - - if (len) { - (void) _XRead(dpy, (char *)data, len); - i = len >> 2; - buf = (int *)data + i; - data += i; - while (--i >= 0) - *--data = *--buf; - } -} -#endif /* LONG64 */ - -#ifdef WORD64 - -/* - * XXX This is a *really* stupid way of doing this.... - * PACKBUFFERSIZE must be a multiple of 4. - */ - -#define PACKBUFFERSIZE 4096 - - -/* - * _XRead32 - Read bytes from the socket unpacking each 32 bits - * into a long (64 bits on a CRAY computer). - * - */ -static void _doXRead32( - register Display *dpy, - register long *data - register long size, - register char *packbuffer) -{ - long *lpack,*lp; - long mask32 = 0x00000000ffffffff; - long maskw, nwords, i, bits; - - _XReadPad (dpy, packbuffer, size); - - lp = data; - lpack = (long *) packbuffer; - nwords = size >> 2; - bits = 32; - - for(i=0;i<nwords;i++){ - maskw = mask32 << bits; - *lp++ = ( *lpack & maskw ) >> bits; - bits = bits ^32; - if(bits){ - lpack++; - } - } -} - -void _XRead32( - Display *dpy, - long *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 2; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) _doXRead32 (dpy, data, len, packbuffer); -} - - - -/* - * _XRead16 - Read bytes from the socket unpacking each 16 bits - * into a long (64 bits on a CRAY computer). - * - */ -static _doXRead16( - register Display *dpy, - register short *data, - register long size, - char *packbuffer) -{ - long *lpack,*lp; - long mask16 = 0x000000000000ffff; - long maskw, nwords, i, bits; - - (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */ - - lp = (long *) data; - lpack = (long *) packbuffer; - nwords = size >> 1; /* number of 16 bit words to be unpacked */ - bits = 48; - for(i=0;i<nwords;i++){ - maskw = mask16 << bits; - *lp++ = ( *lpack & maskw ) >> bits; - bits -= 16; - if(bits < 0){ - lpack++; - bits = 48; - } - } -} - -void _XRead16( - Display *dpy, - short *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 1; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) _doXRead16 (dpy, data, len, packbuffer); -} - -void _XRead16Pad( - Display *dpy, - short *data, - long size) -{ - int slop = (size & 3); - short slopbuf[3]; - - _XRead16 (dpy, data, size); - if (slop > 0) { - _XRead16 (dpy, slopbuf, 4 - slop); - } -} -#endif /* WORD64 */ - - -/* - * _XReadPad - Read bytes from the socket taking into account incomplete - * reads. If the number of bytes is not 0 mod 4, read additional pad - * bytes. This routine may have to be reworked if int < long. - */ -void _XReadPad( - register Display *dpy, - register char *data, - register long size) -{ - register long bytes_read; - struct iovec iov[2]; - char pad[3]; -#ifdef XTHREADS - int original_size; -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - - if ((dpy->flags & XlibDisplayIOError) || size == 0) return; - iov[0].iov_len = (int)size; - iov[0].iov_base = data; - /* - * The following hack is used to provide 32 bit long-word - * aligned padding. The [1] vector is of length 0, 1, 2, or 3, - * whatever is needed. - */ - - iov[1].iov_len = -size & 3; - iov[1].iov_base = pad; - size += iov[1].iov_len; -#ifdef XTHREADS - original_size = size; -#endif - ESET(0); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - while (1) { - bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2); - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } - if (bytes_read == size) { - break; - } -#else - while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) { -#endif - - if (bytes_read > 0) { - size -= bytes_read; - if (iov[0].iov_len < bytes_read) { - int pad_bytes_read = bytes_read - iov[0].iov_len; - iov[1].iov_len -= pad_bytes_read; - iov[1].iov_base = - (char *)iov[1].iov_base + pad_bytes_read; - iov[0].iov_len = 0; - } - else { - iov[0].iov_len -= bytes_read; - iov[0].iov_base = (char *)iov[0].iov_base + bytes_read; - } - } - else if (ETEST()) { - _XWaitForReadable(dpy); - ESET(0); - } -#ifdef SUNSYSV - else if (ECHECK(0)) { - _XWaitForReadable(dpy); - } -#endif - else if (bytes_read == 0) { - /* Read failed because of end of file! */ - ESET(EPIPE); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return; -#else - _XIOError(dpy); -#endif - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ -#ifdef NX_TRANS_SOCKET - if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - if (!ECHECK(EINTR)) - _XIOError(dpy); -#endif - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_bytes_left > 0) - { - dpy->lock->reply_bytes_left -= original_size; - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } -#endif /* XTHREADS*/ -} - -/* - * _XSend - Flush the buffer and send the client data. 32 bit word aligned - * transmission is used, if size is not 0 mod 4, extra bytes are transmitted. - * This routine may have to be reworked if int < long; - */ -void -_XSend ( - register Display *dpy, - _Xconst char *data, - register long size) -{ - struct iovec iov[3]; - static char const pad[3] = {0, 0, 0}; - /* XText8 and XText16 require that the padding bytes be zero! */ - - long skip, dbufsize, padsize, total, todo; - _XExtension *ext; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#ifdef NX_TRANS_SOCKET -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n", - (dpy->bufptr - dpy->buffer)); -#endif - if (!size || (dpy->flags & XlibDisplayIOError)) - { - if (dpy->flags & XlibDisplayIOError) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XSend: Returning with I/O error detected.\n"); -#endif - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *)&_dummy_request; - } - - return; - } -#else - if (!size || (dpy->flags & XlibDisplayIOError)) return; -#endif - dbufsize = dpy->bufptr - dpy->buffer; -#ifdef XTHREADS - dpy->flags |= XlibDisplayWriting; - /* make sure no one else can put in data */ - dpy->bufptr = dpy->bufmax; -#endif - padsize = -size & 3; - for (ext = dpy->flushes; ext; ext = ext->next_flush) { - (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize); - (*ext->before_flush)(dpy, &ext->codes, (char *)data, size); - if (padsize) - (*ext->before_flush)(dpy, &ext->codes, pad, padsize); - } - skip = 0; - todo = total = dbufsize + size + padsize; - - /* - * There are 3 pieces that may need to be written out: - * - * o whatever is in the display buffer - * o the data passed in by the user - * o any padding needed to 32bit align the whole mess - * - * This loop looks at all 3 pieces each time through. It uses skip - * to figure out whether or not a given piece is needed. - */ - while (total) { - long before = skip; /* amount of whole thing written */ - long remain = todo; /* amount to try this time, <= total */ - int i = 0; - long len; - - /* You could be very general here and have "in" and "out" iovecs - * and write a loop without using a macro, but what the heck. This - * translates to: - * - * how much of this piece is new? - * if more new then we are trying this time, clamp - * if nothing new - * then bump down amount already written, for next piece - * else put new stuff in iovec, will need all of next piece - * - * Note that todo had better be at least 1 or else we'll end up - * writing 0 iovecs. - */ -#define InsertIOV(pointer, length) \ - len = (length) - before; \ - if (len > remain) \ - len = remain; \ - if (len <= 0) { \ - before = (-len); \ - } else { \ - iov[i].iov_len = len; \ - iov[i].iov_base = (pointer) + before; \ - i++; \ - remain -= len; \ - before = 0; \ - } - - InsertIOV (dpy->buffer, dbufsize) - InsertIOV ((char *)data, size) - InsertIOV ((char *)pad, padsize) - - ESET(0); - if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) { -#ifdef NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, len); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - skip += len; - total -= len; - todo = total; - } else if (ETEST()) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); -#ifdef SUNSYSV - } else if (ECHECK(0)) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); -#endif -#ifdef ESZTEST - } else if (ESZTEST()) { - if (todo > 1) - todo >>= 1; - else { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); - } -#endif -#ifdef NX_TRANS_SOCKET - } else if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - } else if (!ECHECK(EINTR)) { - _XIOError(dpy); - } -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } - dpy->last_req = (char *) & _dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->bufptr = dpy->buffer; -#ifdef XTHREADS - dpy->flags &= ~XlibDisplayWriting; -#endif - return; -} - -static void -_XGetMiscCode( - register Display *dpy) -{ - xQueryExtensionReply qrep; - register xQueryExtensionReq *qreq; - xXCMiscGetVersionReply vrep; - register xXCMiscGetVersionReq *vreq; - - if (dpy->xcmisc_opcode) - return; - GetReq(QueryExtension, qreq); - qreq->nbytes = sizeof(XCMiscExtensionName) - 1; - qreq->length += (qreq->nbytes+(unsigned)3)>>2; - _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes); - if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue)) - dpy->xcmisc_opcode = -1; - else { - GetReq(XCMiscGetVersion, vreq); - vreq->reqType = qrep.major_opcode; - vreq->miscReqType = X_XCMiscGetVersion; - vreq->majorVersion = XCMiscMajorVersion; - vreq->minorVersion = XCMiscMinorVersion; - if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue)) - dpy->xcmisc_opcode = -1; - else - dpy->xcmisc_opcode = qrep.major_opcode; - } -} - -static int -_XIDHandler( - register Display *dpy) -{ - xXCMiscGetXIDRangeReply grep; - register xXCMiscGetXIDRangeReq *greq; - - LockDisplay(dpy); - _XGetMiscCode(dpy); - if (dpy->xcmisc_opcode > 0) { - GetReq(XCMiscGetXIDRange, greq); - greq->reqType = dpy->xcmisc_opcode; - greq->miscReqType = X_XCMiscGetXIDRange; - if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) { - dpy->resource_id = ((grep.start_id - dpy->resource_base) >> - dpy->resource_shift); - dpy->resource_max = dpy->resource_id; - if (grep.count > 5) - dpy->resource_max += grep.count - 6; - dpy->resource_max <<= dpy->resource_shift; - } - } - if (dpy->flags & XlibDisplayPrivSync) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -/* - * _XAllocID - resource ID allocation routine. - */ -XID _XAllocID( - register Display *dpy) -{ - XID id; - - id = dpy->resource_id << dpy->resource_shift; - if (id >= dpy->resource_max) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - if (id <= dpy->resource_mask) { - dpy->resource_id++; - return (dpy->resource_base + id); - } - if (id != 0x10000000) { - (void) fprintf(stderr, - "Xlib: resource ID allocation space exhausted!\n"); - id = 0x10000000; - dpy->resource_id = id >> dpy->resource_shift; - } - return id; -} - -/* - * _XAllocIDs - multiple resource ID allocation routine. - */ -void _XAllocIDs( - register Display *dpy, - XID *ids, - int count) -{ - XID id; - int i; - xXCMiscGetXIDListReply grep; - register xXCMiscGetXIDListReq *greq; - - id = dpy->resource_id << dpy->resource_shift; - if (dpy->resource_max <= dpy->resource_mask && - id <= dpy->resource_mask && - (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) { - id += dpy->resource_base; - for (i = 0; i < count; i++) { - ids[i] = id; - id += (1 << dpy->resource_shift); - dpy->resource_id++; - } - return; - } - grep.count = 0; - _XGetMiscCode(dpy); - if (dpy->xcmisc_opcode > 0) { - GetReq(XCMiscGetXIDList, greq); - greq->reqType = dpy->xcmisc_opcode; - greq->miscReqType = X_XCMiscGetXIDList; - greq->count = count; - if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) { - _XRead32(dpy, (long *) ids, 4L * (long) (grep.count)); - for (i = 0; i < grep.count; i++) { - id = (ids[i] - dpy->resource_base) >> dpy->resource_shift; - if (id >= dpy->resource_id) - dpy->resource_id = id; - } - if (id >= dpy->resource_max) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - } - } - for (i = grep.count; i < count; i++) - ids[i] = XAllocID(dpy); -} - -/* - * The hard part about this is that we only get 16 bits from a reply. - * We have three values that will march along, with the following invariant: - * dpy->last_request_read <= rep->sequenceNumber <= dpy->request - * We have to keep - * dpy->request - dpy->last_request_read < 2^16 - * or else we won't know for sure what value to use in events. We do this - * by forcing syncs when we get close. - */ - -unsigned long -_XSetLastRequestRead( - register Display *dpy, - register xGenericReply *rep) -{ - register unsigned long newseq, lastseq; - - lastseq = dpy->last_request_read; - /* - * KeymapNotify has no sequence number, but is always guaranteed - * to immediately follow another event, except when generated via - * SendEvent (hmmm). - */ - if ((rep->type & 0x7f) == KeymapNotify) - return(lastseq); - - newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber; - - if (newseq < lastseq) { - newseq += 0x10000; - if (newseq > dpy->request) { - -#ifdef NX_TRANS_SOCKET - - if (_NXLostSequenceFunction != NULL) - { - (*_NXLostSequenceFunction)(dpy, newseq, dpy->request, - (unsigned int) rep->type); - } - else - { - (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, - (unsigned int) rep->type); - } - -#else /* #ifdef NX_TRANS_SOCKET */ - - (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, - (unsigned int) rep->type); - -#endif /* #ifdef NX_TRANS_SOCKET */ - - newseq -= 0x10000; - } - } - - dpy->last_request_read = newseq; - return(newseq); -} - -/* - * _XReply - Wait for a reply packet and copy its contents into the - * specified rep. Meanwhile we must handle error and event packets that - * we may encounter. - */ -Status -_XReply ( - register Display *dpy, - register xReply *rep, - int extra, /* number of 32-bit words expected after the reply */ - Bool discard) /* should I discard data following "extra" words? */ -{ - /* Pull out the serial number now, so that (currently illegal) requests - * generated by an error handler don't confuse us. - */ - unsigned long cur_request = dpy->request; -#ifdef XTHREADS - struct _XCVList *cvl; -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReply: Going to wait for an X reply.\n"); -#endif - -#ifdef NX_TRANS_SOCKET - if (dpy->flags & XlibDisplayIOError) - { -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n"); -#endif - return 0; - } -#else - if (dpy->flags & XlibDisplayIOError) - return 0; -#endif - -#ifdef XTHREADS - /* create our condition variable and append to list */ - cvl = QueueReplyReaderLock(dpy); - if (cvl) { - cvl->buf = rep; - if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters) - dpy->lock->reply_first = True; - } - -#ifdef XTHREADS_DEBUG - printf("_XReply called in thread %x, adding %x to cvl\n", - XThread_Self(), cvl); -#endif - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReply: Going to flush the display buffer.\n"); -#endif - _XFlushInt(dpy, cvl ? cvl->cv : NULL); - /* if it is not our turn to read a reply off the wire, - * wait til we're at head of list. if there is an event waiter, - * and our reply hasn't been read, they'll be in select and will - * hand control back to us next. - */ - if(dpy->lock && - (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) { - ConditionWait(dpy, cvl->cv); - } - dpy->flags |= XlibDisplayReply; -#else /* XTHREADS else */ - _XFlush(dpy); -#endif - -#ifdef NX_TRANS_SOCKET - /* - * We are going to block waiting for the remote - * X server. Be sure that the proxy has flushed - * all the data. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XReply: Requesting a flush of the NX transport.\n"); -#endif - - NXTransFlush(dpy->fd); -#endif - - for (;;) { -#ifdef XTHREADS - /* Did another thread's _XReadEvents get our reply by accident? */ - if (!dpy->lock || !dpy->lock->reply_was_read) -#endif - (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply)); -#ifdef XTHREADS - if (dpy->lock) - dpy->lock->reply_was_read = False; -#endif - - switch ((int)rep->generic.type) { - - case X_Reply: - /* Reply received. Fast update for synchronous replies, - * but deal with multiple outstanding replies. - */ - if (rep->generic.sequenceNumber == (cur_request & 0xffff)) - dpy->last_request_read = cur_request; - else { - int pend = SIZEOF(xReply); - if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False) - != (char *)rep) - continue; - } - if (extra <= rep->generic.length) { - if (extra > 0) - /* - * Read the extra data into storage immediately - * following the GenericReply structure. - */ - (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)), - ((long)extra) << 2); - if (discard) { - if (extra < rep->generic.length) - _XEatData(dpy, (rep->generic.length - extra) << 2); - } -#ifdef XTHREADS - if (dpy->lock) { - if (discard) { - dpy->lock->reply_bytes_left = 0; - } else { - dpy->lock->reply_bytes_left = - (rep->generic.length - extra) << 2; - } - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } else - dpy->flags &= ~XlibDisplayReply; -#endif - return 1; - } - /* - *if we get here, then extra > rep->generic.length--meaning we - * read a reply that's shorter than we expected. This is an - * error, but we still need to figure out how to handle it... - */ - (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)), - ((long) rep->generic.length) << 2); - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); -#ifdef NX_TRANS_SOCKET - /* - * The original code has provision - * for returning already. - */ -#endif - _XIOError (dpy); - return (0); - - case X_Error: - { - register _XExtension *ext; - register Bool ret = False; - int ret_code; - xError *err = (xError *) rep; - unsigned long serial; - - dpy->flags &= ~XlibDisplayReply; - serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep); - if (serial == cur_request) - /* do not die on "no such font", "can't allocate", - "can't grab" failures */ - switch ((int)err->errorCode) { - case BadName: - switch (err->majorCode) { - case X_LookupColor: - case X_AllocNamedColor: - UnlockNextReplyReader(dpy); - return(0); - } - break; - case BadFont: - if (err->majorCode == X_QueryFont) { - UnlockNextReplyReader(dpy); - return (0); - } - break; - case BadAlloc: - case BadAccess: - UnlockNextReplyReader(dpy); - return (0); - } - /* - * we better see if there is an extension who may - * want to suppress the error. - */ - for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) { - if (ext->error) - ret = (*ext->error)(dpy, err, &ext->codes, &ret_code); - } - if (!ret) { - _XError(dpy, err); - ret_code = 0; - } - if (serial == cur_request) { - UnlockNextReplyReader(dpy); - return(ret_code); - } - - } /* case X_Error */ - break; - default: - _XEnq(dpy, (xEvent *) rep); -#ifdef XTHREADS - if (dpy->lock && dpy->lock->event_awaiters) - ConditionSignal(dpy, dpy->lock->event_awaiters->cv); -#endif - break; - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - UnlockNextReplyReader(dpy); - return 0; - } -#endif - } -} - -static char * -_XAsyncReply( - Display *dpy, - register xReply *rep, - char *buf, - register int *lenp, - Bool discard) -{ - register _XAsyncHandler *async, *next; - register int len; - register Bool consumed = False; - char *nbuf; - - (void) _XSetLastRequestRead(dpy, &rep->generic); - len = SIZEOF(xReply) + (rep->generic.length << 2); - if (len < SIZEOF(xReply)) { -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _XIOError (dpy); - buf += *lenp; - *lenp = 0; - return buf; - } - - for (async = dpy->async_handlers; async; async = next) { - next = async->next; - if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data))) - break; - } - if (!consumed) { - if (!discard) - return buf; - (void) fprintf(stderr, - "Xlib: unexpected async reply (sequence 0x%lx)!\n", - dpy->last_request_read); -#ifdef XTHREADS -#ifdef XTHREADS_DEBUG - printf("thread %x, unexpected async reply\n", XThread_Self()); -#endif -#endif - if (len > *lenp) - _XEatData(dpy, len - *lenp); - } - if (len < SIZEOF(xReply)) - { -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _XIOError (dpy); - buf += *lenp; - *lenp = 0; - return buf; - } - if (len >= *lenp) { - buf += *lenp; - *lenp = 0; - return buf; - } - *lenp -= len; - buf += len; - len = *lenp; - nbuf = buf; - while (len > SIZEOF(xReply)) { - if (*buf == X_Reply) - return nbuf; - buf += SIZEOF(xReply); - len -= SIZEOF(xReply); - } - if (len > 0 && len < SIZEOF(xReply)) { - buf = nbuf; - len = SIZEOF(xReply) - len; - nbuf -= len; - memmove(nbuf, buf, *lenp); - (void) _XRead(dpy, nbuf + *lenp, (long)len); - *lenp += len; - } - return nbuf; -} - -/* - * Support for internal connections, such as an IM might use. - * By Stephen Gildea, X Consortium, September 1993 - */ - -/* _XRegisterInternalConnection - * Each IM (or Xlib extension) that opens a file descriptor that Xlib should - * include in its select/poll mask must call this function to register the - * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch - * will also be called. - * - * Whenever Xlib detects input available on fd, it will call callback - * with call_data to process it. If non-Xlib code calls select/poll - * and detects input available, it must call XProcessInternalConnection, - * which will call the associated callback. - * - * Non-Xlib code can learn about these additional fds by calling - * XInternalConnectionNumbers or, more typically, by registering - * a XConnectionWatchProc with XAddConnectionWatch - * to be called when fds are registered or unregistered. - * - * Returns True if registration succeeded, False if not, typically - * because could not allocate memory. - * Assumes Display locked when called. - */ -Status -_XRegisterInternalConnection( - Display* dpy, - int fd, - _XInternalConnectionProc callback, - XPointer call_data -) -{ - struct _XConnectionInfo *new_conni, **iptr; - struct _XConnWatchInfo *watchers; - XPointer *wd; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XRegisterInternalConnection: Got called.\n"); -#endif - - new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo)); - if (!new_conni) - return 0; - new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer)); - if (!new_conni->watch_data) { - Xfree(new_conni); - return 0; - } - new_conni->fd = fd; - new_conni->read_callback = callback; - new_conni->call_data = call_data; - new_conni->next = NULL; - /* link new structure onto end of list */ - for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next) - ; - *iptr = new_conni; - dpy->im_fd_length++; - _XPollfdCacheAdd(dpy, fd); - - for (watchers=dpy->conn_watchers, wd=new_conni->watch_data; - watchers; - watchers=watchers->next, wd++) { - *wd = NULL; /* for cleanliness */ - (*watchers->fn) (dpy, watchers->client_data, fd, True, wd); - } - - return 1; -} - -/* _XUnregisterInternalConnection - * Each IM (or Xlib extension) that closes a file descriptor previously - * registered with _XRegisterInternalConnection must call this function. - * Any XConnectionWatchProc registered by XAddConnectionWatch - * will also be called. - * - * Assumes Display locked when called. - */ -void -_XUnregisterInternalConnection( - Display* dpy, - int fd -) -{ - struct _XConnectionInfo *info_list, **prev; - struct _XConnWatchInfo *watch; - XPointer *wd; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XUnregisterInternalConnection: Got called.\n"); -#endif - - for (prev = &dpy->im_fd_info; (info_list = *prev); - prev = &info_list->next) { - if (info_list->fd == fd) { - *prev = info_list->next; - dpy->im_fd_length--; - for (watch=dpy->conn_watchers, wd=info_list->watch_data; - watch; - watch=watch->next, wd++) { - (*watch->fn) (dpy, watch->client_data, fd, False, wd); - } - if (info_list->watch_data) - Xfree (info_list->watch_data); - Xfree (info_list); - break; - } - } - _XPollfdCacheDel(dpy, fd); -} - -/* XInternalConnectionNumbers - * Returns an array of fds and an array of corresponding call data. - * Typically a XConnectionWatchProc registered with XAddConnectionWatch - * will be used instead of this function to discover - * additional fds to include in the select/poll mask. - * - * The list is allocated with Xmalloc and should be freed by the caller - * with Xfree; - */ -Status -XInternalConnectionNumbers( - Display *dpy, - int **fd_return, - int *count_return -) -{ - int count; - struct _XConnectionInfo *info_list; - int *fd_list; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XInternalConnectionNumbers: Got called.\n"); -#endif - - LockDisplay(dpy); - count = 0; - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) - count++; - fd_list = (int*) Xmalloc (count * sizeof(int)); - if (!fd_list) { - UnlockDisplay(dpy); - return 0; - } - count = 0; - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - fd_list[count] = info_list->fd; - count++; - } - UnlockDisplay(dpy); - - *fd_return = fd_list; - *count_return = count; - return 1; -} - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info) -{ - dpy->flags |= XlibDisplayProcConni; -#ifdef XTHREADS - if (dpy->lock) { - /* check cache to avoid call to thread_self */ - if (xthread_have_id(dpy->lock->reading_thread)) - dpy->lock->conni_thread = dpy->lock->reading_thread; - else - dpy->lock->conni_thread = XThread_Self(); - } -#endif /* XTHREADS */ - UnlockDisplay(dpy); - (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data); - LockDisplay(dpy); -#ifdef XTHREADS - if (dpy->lock) - xthread_clear_id(dpy->lock->conni_thread); -#endif /* XTHREADS */ - dpy->flags &= ~XlibDisplayProcConni; -} - -/* XProcessInternalConnection - * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection - * for this fd. - * The Display is NOT locked during the call. - */ -void -XProcessInternalConnection( - Display* dpy, - int fd -) -{ - struct _XConnectionInfo *info_list; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XProcessInternalConnection: Got called.\n"); -#endif - - LockDisplay(dpy); - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - if (info_list->fd == fd) { - _XProcessInternalConnection(dpy, info_list); - break; - } - } - UnlockDisplay(dpy); -} - -/* XAddConnectionWatch - * Register a callback to be called whenever _XRegisterInternalConnection - * or _XUnregisterInternalConnection is called. - * Callbacks are called with the Display locked. - * If any connections are already registered, the callback is immediately - * called for each of them. - */ -Status -XAddConnectionWatch( - Display* dpy, - XConnectionWatchProc callback, - XPointer client_data -) -{ - struct _XConnWatchInfo *new_watcher, **wptr; - struct _XConnectionInfo *info_list; - XPointer *wd_array; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XAddConnectionWatch: Got called.\n"); -#endif - - LockDisplay(dpy); - - /* allocate new watch data */ - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data, - (dpy->watcher_count + 1) * - sizeof(XPointer)); - if (!wd_array) { - UnlockDisplay(dpy); - return 0; - } - wd_array[dpy->watcher_count] = NULL; /* for cleanliness */ - } - - new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo)); - if (!new_watcher) { - UnlockDisplay(dpy); - return 0; - } - new_watcher->fn = callback; - new_watcher->client_data = client_data; - new_watcher->next = NULL; - - /* link new structure onto end of list */ - for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next) - ; - *wptr = new_watcher; - dpy->watcher_count++; - - /* call new watcher on all currently registered fds */ - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - (*callback) (dpy, client_data, info_list->fd, True, - info_list->watch_data + dpy->watcher_count - 1); - } - - UnlockDisplay(dpy); - return 1; -} - -/* XRemoveConnectionWatch - * Unregister a callback registered by XAddConnectionWatch. - * Both callback and client_data must match what was passed to - * XAddConnectionWatch. - */ -void -XRemoveConnectionWatch( - Display* dpy, - XConnectionWatchProc callback, - XPointer client_data -) -{ - struct _XConnWatchInfo *watch; - struct _XConnWatchInfo *previous = NULL; - struct _XConnectionInfo *conni; - int counter = 0; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XRemoveConnectionWatch: Got called.\n"); -#endif - - LockDisplay(dpy); - for (watch=dpy->conn_watchers; watch; watch=watch->next) { - if (watch->fn == callback && watch->client_data == client_data) { - if (previous) - previous->next = watch->next; - else - dpy->conn_watchers = watch->next; - Xfree (watch); - dpy->watcher_count--; - /* remove our watch_data for each connection */ - for (conni=dpy->im_fd_info; conni; conni=conni->next) { - /* don't bother realloc'ing; these arrays are small anyway */ - /* overlapping */ - memmove(conni->watch_data+counter, - conni->watch_data+counter+1, - dpy->watcher_count - counter); - } - break; - } - previous = watch; - counter++; - } - UnlockDisplay(dpy); -} - -/* end of internal connections support */ - - -/* Read and discard "n" 8-bit bytes of data */ - -void _XEatData( - Display *dpy, - register unsigned long n) -{ -#define SCRATCHSIZE 2048 - char buf[SCRATCHSIZE]; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEatData: Going to eat [%ld] bytes of data from descriptor [%d].\n", - n, dpy->fd); -#endif - while (n > 0) { - register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n; - (void) _XRead (dpy, buf, bytes_read); - n -= bytes_read; - } -#undef SCRATCHSIZE -} - - -/* - * _XEnq - Place event packets on the display's queue. - * note that no squishing of move events in V11, since there - * is pointer motion hints.... - */ -void _XEnq( - register Display *dpy, - register xEvent *event) -{ - register _XQEvent *qelt; - - if ((qelt = dpy->qfree)) { - /* If dpy->qfree is non-NULL do this, else malloc a new one. */ - dpy->qfree = qelt->next; - } - else if ((qelt = - (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) { - /* Malloc call failed! */ - ESET(ENOMEM); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return; -#else - _XIOError(dpy); -#endif - } - qelt->next = NULL; - /* go call through display to find proper event reformatter */ - if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) { - qelt->qserial_num = dpy->next_event_serial_num++; - if (dpy->tail) dpy->tail->next = qelt; - else dpy->head = qelt; - - dpy->tail = qelt; - dpy->qlen++; - } else { - /* ignored, or stashed away for many-to-one compression */ - qelt->next = dpy->qfree; - dpy->qfree = qelt; - } -} - -/* - * _XDeq - Remove event packet from the display's queue. - */ -void _XDeq( - register Display *dpy, - register _XQEvent *prev, /* element before qelt */ - register _XQEvent *qelt) /* element to be unlinked */ -{ - if (prev) { - if ((prev->next = qelt->next) == NULL) - dpy->tail = prev; - } else { - /* no prev, so removing first elt */ - if ((dpy->head = qelt->next) == NULL) - dpy->tail = NULL; - } - qelt->qserial_num = 0; - qelt->next = dpy->qfree; - dpy->qfree = qelt; - dpy->qlen--; -} - -/* - * EventToWire in separate file in that often not needed. - */ - -/*ARGSUSED*/ -Bool -_XUnknownWireEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ -#ifdef notdef - (void) fprintf(stderr, - "Xlib: unhandled wire event! event number = %d, display = %x\n.", - event->u.u.type, dpy); -#endif - return(False); -} - -/*ARGSUSED*/ -Status -_XUnknownNativeEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ -#ifdef notdef - (void) fprintf(stderr, - "Xlib: unhandled native event! event number = %d, display = %x\n.", - re->type, dpy); -#endif - return(0); -} -/* - * reformat a wire event into an XEvent structure of the right type. - */ -Bool -_XWireToEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ - - re->type = event->u.u.type & 0x7f; - ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy, - (xGenericReply *)event); - ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0); - ((XAnyEvent *)re)->display = dpy; - - /* Ignore the leading bit of the event type since it is set when a - client sends an event rather than the server. */ - - switch (event-> u.u.type & 0177) { - case KeyPress: - case KeyRelease: - { - register XKeyEvent *ev = (XKeyEvent*) re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->keycode = event->u.u.detail; - } - break; - case ButtonPress: - case ButtonRelease: - { - register XButtonEvent *ev = (XButtonEvent *) re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->button = event->u.u.detail; - } - break; - case MotionNotify: - { - register XMotionEvent *ev = (XMotionEvent *)re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->is_hint = event->u.u.detail; - } - break; - case EnterNotify: - case LeaveNotify: - { - register XCrossingEvent *ev = (XCrossingEvent *) re; - ev->root = event->u.enterLeave.root; - ev->window = event->u.enterLeave.event; - ev->subwindow = event->u.enterLeave.child; - ev->time = event->u.enterLeave.time; - ev->x = cvtINT16toInt(event->u.enterLeave.eventX); - ev->y = cvtINT16toInt(event->u.enterLeave.eventY); - ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX); - ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY); - ev->state = event->u.enterLeave.state; - ev->mode = event->u.enterLeave.mode; - ev->same_screen = (event->u.enterLeave.flags & - ELFlagSameScreen) && True; - ev->focus = (event->u.enterLeave.flags & - ELFlagFocus) && True; - ev->detail = event->u.u.detail; - } - break; - case FocusIn: - case FocusOut: - { - register XFocusChangeEvent *ev = (XFocusChangeEvent *) re; - ev->window = event->u.focus.window; - ev->mode = event->u.focus.mode; - ev->detail = event->u.u.detail; - } - break; - case KeymapNotify: - { - register XKeymapEvent *ev = (XKeymapEvent *) re; - ev->window = None; - memcpy(&ev->key_vector[1], - (char *)((xKeymapEvent *) event)->map, - sizeof (((xKeymapEvent *) event)->map)); - } - break; - case Expose: - { - register XExposeEvent *ev = (XExposeEvent *) re; - ev->window = event->u.expose.window; - ev->x = event->u.expose.x; - ev->y = event->u.expose.y; - ev->width = event->u.expose.width; - ev->height = event->u.expose.height; - ev->count = event->u.expose.count; - } - break; - case GraphicsExpose: - { - register XGraphicsExposeEvent *ev = - (XGraphicsExposeEvent *) re; - ev->drawable = event->u.graphicsExposure.drawable; - ev->x = event->u.graphicsExposure.x; - ev->y = event->u.graphicsExposure.y; - ev->width = event->u.graphicsExposure.width; - ev->height = event->u.graphicsExposure.height; - ev->count = event->u.graphicsExposure.count; - ev->major_code = event->u.graphicsExposure.majorEvent; - ev->minor_code = event->u.graphicsExposure.minorEvent; - } - break; - case NoExpose: - { - register XNoExposeEvent *ev = (XNoExposeEvent *) re; - ev->drawable = event->u.noExposure.drawable; - ev->major_code = event->u.noExposure.majorEvent; - ev->minor_code = event->u.noExposure.minorEvent; - } - break; - case VisibilityNotify: - { - register XVisibilityEvent *ev = (XVisibilityEvent *) re; - ev->window = event->u.visibility.window; - ev->state = event->u.visibility.state; - } - break; - case CreateNotify: - { - register XCreateWindowEvent *ev = - (XCreateWindowEvent *) re; - ev->window = event->u.createNotify.window; - ev->parent = event->u.createNotify.parent; - ev->x = cvtINT16toInt(event->u.createNotify.x); - ev->y = cvtINT16toInt(event->u.createNotify.y); - ev->width = event->u.createNotify.width; - ev->height = event->u.createNotify.height; - ev->border_width = event->u.createNotify.borderWidth; - ev->override_redirect = event->u.createNotify.override; - } - break; - case DestroyNotify: - { - register XDestroyWindowEvent *ev = - (XDestroyWindowEvent *) re; - ev->window = event->u.destroyNotify.window; - ev->event = event->u.destroyNotify.event; - } - break; - case UnmapNotify: - { - register XUnmapEvent *ev = (XUnmapEvent *) re; - ev->window = event->u.unmapNotify.window; - ev->event = event->u.unmapNotify.event; - ev->from_configure = event->u.unmapNotify.fromConfigure; - } - break; - case MapNotify: - { - register XMapEvent *ev = (XMapEvent *) re; - ev->window = event->u.mapNotify.window; - ev->event = event->u.mapNotify.event; - ev->override_redirect = event->u.mapNotify.override; - } - break; - case MapRequest: - { - register XMapRequestEvent *ev = (XMapRequestEvent *) re; - ev->window = event->u.mapRequest.window; - ev->parent = event->u.mapRequest.parent; - } - break; - case ReparentNotify: - { - register XReparentEvent *ev = (XReparentEvent *) re; - ev->event = event->u.reparent.event; - ev->window = event->u.reparent.window; - ev->parent = event->u.reparent.parent; - ev->x = cvtINT16toInt(event->u.reparent.x); - ev->y = cvtINT16toInt(event->u.reparent.y); - ev->override_redirect = event->u.reparent.override; - } - break; - case ConfigureNotify: - { - register XConfigureEvent *ev = (XConfigureEvent *) re; - ev->event = event->u.configureNotify.event; - ev->window = event->u.configureNotify.window; - ev->above = event->u.configureNotify.aboveSibling; - ev->x = cvtINT16toInt(event->u.configureNotify.x); - ev->y = cvtINT16toInt(event->u.configureNotify.y); - ev->width = event->u.configureNotify.width; - ev->height = event->u.configureNotify.height; - ev->border_width = event->u.configureNotify.borderWidth; - ev->override_redirect = event->u.configureNotify.override; - } - break; - case ConfigureRequest: - { - register XConfigureRequestEvent *ev = - (XConfigureRequestEvent *) re; - ev->window = event->u.configureRequest.window; - ev->parent = event->u.configureRequest.parent; - ev->above = event->u.configureRequest.sibling; - ev->x = cvtINT16toInt(event->u.configureRequest.x); - ev->y = cvtINT16toInt(event->u.configureRequest.y); - ev->width = event->u.configureRequest.width; - ev->height = event->u.configureRequest.height; - ev->border_width = event->u.configureRequest.borderWidth; - ev->value_mask = event->u.configureRequest.valueMask; - ev->detail = event->u.u.detail; - } - break; - case GravityNotify: - { - register XGravityEvent *ev = (XGravityEvent *) re; - ev->window = event->u.gravity.window; - ev->event = event->u.gravity.event; - ev->x = cvtINT16toInt(event->u.gravity.x); - ev->y = cvtINT16toInt(event->u.gravity.y); - } - break; - case ResizeRequest: - { - register XResizeRequestEvent *ev = - (XResizeRequestEvent *) re; - ev->window = event->u.resizeRequest.window; - ev->width = event->u.resizeRequest.width; - ev->height = event->u.resizeRequest.height; - } - break; - case CirculateNotify: - { - register XCirculateEvent *ev = (XCirculateEvent *) re; - ev->window = event->u.circulate.window; - ev->event = event->u.circulate.event; - ev->place = event->u.circulate.place; - } - break; - case CirculateRequest: - { - register XCirculateRequestEvent *ev = - (XCirculateRequestEvent *) re; - ev->window = event->u.circulate.window; - ev->parent = event->u.circulate.event; - ev->place = event->u.circulate.place; - } - break; - case PropertyNotify: - { - register XPropertyEvent *ev = (XPropertyEvent *) re; - ev->window = event->u.property.window; - ev->atom = event->u.property.atom; - ev->time = event->u.property.time; - ev->state = event->u.property.state; - } - break; - case SelectionClear: - { - register XSelectionClearEvent *ev = - (XSelectionClearEvent *) re; - ev->window = event->u.selectionClear.window; - ev->selection = event->u.selectionClear.atom; - ev->time = event->u.selectionClear.time; - } - break; - case SelectionRequest: - { - register XSelectionRequestEvent *ev = - (XSelectionRequestEvent *) re; - ev->owner = event->u.selectionRequest.owner; - ev->requestor = event->u.selectionRequest.requestor; - ev->selection = event->u.selectionRequest.selection; - ev->target = event->u.selectionRequest.target; - ev->property = event->u.selectionRequest.property; - ev->time = event->u.selectionRequest.time; - } - break; - case SelectionNotify: - { - register XSelectionEvent *ev = (XSelectionEvent *) re; - ev->requestor = event->u.selectionNotify.requestor; - ev->selection = event->u.selectionNotify.selection; - ev->target = event->u.selectionNotify.target; - ev->property = event->u.selectionNotify.property; - ev->time = event->u.selectionNotify.time; - } - break; - case ColormapNotify: - { - register XColormapEvent *ev = (XColormapEvent *) re; - ev->window = event->u.colormap.window; - ev->colormap = event->u.colormap.colormap; - ev->new = event->u.colormap.new; - ev->state = event->u.colormap.state; - } - break; - case ClientMessage: - { - register int i; - register XClientMessageEvent *ev - = (XClientMessageEvent *) re; - ev->window = event->u.clientMessage.window; - ev->format = event->u.u.detail; - switch (ev->format) { - case 8: - ev->message_type = event->u.clientMessage.u.b.type; - for (i = 0; i < 20; i++) - ev->data.b[i] = event->u.clientMessage.u.b.bytes[i]; - break; - case 16: - ev->message_type = event->u.clientMessage.u.s.type; - ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0); - ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1); - ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2); - ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3); - ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4); - ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5); - ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6); - ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7); - ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8); - ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9); - break; - case 32: - ev->message_type = event->u.clientMessage.u.l.type; - ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0); - ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1); - ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2); - ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3); - ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4); - break; - default: /* XXX should never occur */ - break; - } - } - break; - case MappingNotify: - { - register XMappingEvent *ev = (XMappingEvent *)re; - ev->window = 0; - ev->first_keycode = event->u.mappingNotify.firstKeyCode; - ev->request = event->u.mappingNotify.request; - ev->count = event->u.mappingNotify.count; - } - break; - default: - return(_XUnknownWireEvent(dpy, re, event)); - } - return(True); -} - - -/* - * _XDefaultIOError - Default fatal system error reporting routine. Called - * when an X internal system error is encountered. - */ -int _XDefaultIOError( - Display *dpy) -{ - if (ECHECK(EPIPE)) { - (void) fprintf (stderr, - "X connection to %s broken (explicit kill or server shutdown).\r\n", - DisplayString (dpy)); - } else { - (void) fprintf (stderr, - "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n", -#ifdef WIN32 - WSAGetLastError(), strerror(WSAGetLastError()), -#else - errno, strerror (errno), -#endif - DisplayString (dpy)); - (void) fprintf (stderr, - " after %lu requests (%lu known processed) with %d events remaining.\r\n", - NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy), - QLength(dpy)); - - } -#ifdef NX_TRANS_SOCKET - if (_NXHandleDisplayError == 1) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XDefaultIOError: Going to return from the error handler.\n"); -#endif - return 0; - } - else - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XDefaultIOError: Going to exit from the program.\n"); -#endif -#ifdef NX_TRANS_EXIT - NXTransExit(1); -#else - exit(1); -#endif - } -#else - exit(1); -#endif /* #ifdef NX_TRANS_SOCKET */ - - return(0); /* dummy - function should never return */ -} - - -static int _XPrintDefaultError( - Display *dpy, - XErrorEvent *event, - FILE *fp) -{ - char buffer[BUFSIZ]; - char mesg[BUFSIZ]; - char number[32]; - char *mtype = "XlibMessage"; - register _XExtension *ext = (_XExtension *)NULL; - _XExtension *bext = (_XExtension *)NULL; - XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); - XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); - (void) fprintf(fp, "%s: %s\n ", mesg, buffer); - XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->request_code); - if (event->request_code < 128) { - sprintf(number, "%d", event->request_code); - XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); - } else { - for (ext = dpy->ext_procs; - ext && (ext->codes.major_opcode != event->request_code); - ext = ext->next) - ; - if (ext) - strcpy(buffer, ext->name); - else - buffer[0] = '\0'; - } - (void) fprintf(fp, " (%s)\n", buffer); - if (event->request_code >= 128) { - XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->minor_code); - if (ext) { - sprintf(mesg, "%s.%d", ext->name, event->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); - (void) fprintf(fp, " (%s)", buffer); - } - fputs("\n", fp); - } - if (event->error_code >= 128) { - /* kludge, try to find the extension that caused it */ - buffer[0] = '\0'; - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_string) - (*ext->error_string)(dpy, event->error_code, &ext->codes, - buffer, BUFSIZ); - if (buffer[0]) { - bext = ext; - break; - } - if (ext->codes.first_error && - ext->codes.first_error < (int)event->error_code && - (!bext || ext->codes.first_error > bext->codes.first_error)) - bext = ext; - } - if (bext) - sprintf(buffer, "%s.%d", bext->name, - event->error_code - bext->codes.first_error); - else - strcpy(buffer, "Value"); - XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ); - if (mesg[0]) { - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - /* let extensions try to print the values */ - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_values) - (*ext->error_values)(dpy, event, fp); - } - } else if ((event->error_code == BadWindow) || - (event->error_code == BadPixmap) || - (event->error_code == BadCursor) || - (event->error_code == BadFont) || - (event->error_code == BadDrawable) || - (event->error_code == BadColor) || - (event->error_code == BadGC) || - (event->error_code == BadIDChoice) || - (event->error_code == BadValue) || - (event->error_code == BadAtom)) { - if (event->error_code == BadValue) - XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", - mesg, BUFSIZ); - else if (event->error_code == BadAtom) - XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", - mesg, BUFSIZ); - else - XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->serial); - XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", - mesg, BUFSIZ); - fputs("\n ", fp); - (void) fprintf(fp, mesg, dpy->request); - fputs("\n", fp); - if (event->error_code == BadImplementation) return 0; - return 1; -} - -int _XDefaultError( - Display *dpy, - XErrorEvent *event) -{ - if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0; - exit(1); - /*NOTREACHED*/ -} - -/*ARGSUSED*/ -Bool _XDefaultWireError(display, he, we) - Display *display; - XErrorEvent *he; - xError *we; -{ - return True; -} - -/* - * _XError - upcall internal or user protocol error handler - */ -int _XError ( - Display *dpy, - register xError *rep) -{ - /* - * X_Error packet encountered! We need to unpack the error before - * giving it to the user. - */ - XEvent event; /* make it a large event */ - register _XAsyncHandler *async, *next; - - event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep); - - for (async = dpy->async_handlers; async; async = next) { - next = async->next; - if ((*async->handler)(dpy, (xReply *)rep, - (char *)rep, SIZEOF(xError), async->data)) - return 0; - } - - event.xerror.display = dpy; - event.xerror.type = X_Error; - event.xerror.resourceid = rep->resourceID; - event.xerror.error_code = rep->errorCode; - event.xerror.request_code = rep->majorCode; - event.xerror.minor_code = rep->minorCode; - if (dpy->error_vec && - !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep)) - return 0; - if (_XErrorFunction != NULL) { - int rtn_val; -#ifdef XTHREADS - if (dpy->lock) - (*dpy->lock->user_lock_display)(dpy); - UnlockDisplay(dpy); -#endif /* XTHREADS */ - rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */ -#ifdef XTHREADS - LockDisplay(dpy); - if (dpy->lock) - (*dpy->lock->user_unlock_display)(dpy); -#endif /* XTHREADS */ - return rtn_val; - } else { - return _XDefaultError(dpy, (XErrorEvent *)&event); - } -} - -/* - * _XIOError - call user connection error handler and exit - */ -int -_XIOError ( - Display *dpy) -{ - dpy->flags |= XlibDisplayIOError; -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - - if (_XIOErrorFunction != NULL) - (*_XIOErrorFunction)(dpy); - else - _XDefaultIOError(dpy); -#ifdef NX_TRANS_SOCKET - /* - * Check if we are supposed to return in the case - * of a display failure. The client which originated - * the X operation will have to check the value of - * the XlibDisplayIOError flag and handle appropria- - * tely the display disconnection. - */ - - if (_NXHandleDisplayError == 0) - { -#ifdef NX_TRANS_EXIT - NXTransExit(1); -#else - exit(1); -#endif - } - - /* - * We are going to return. Reset the display - * buffers. Further writes will be discarded. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display buffer.\n"); -#endif - - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *) &_dummy_request; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display flags.\n"); -#endif - - dpy->flags &= ~XlibDisplayProcConni; - dpy->flags &= ~XlibDisplayPrivSync; - dpy->flags &= ~XlibDisplayReadEvents; - dpy->flags &= ~XlibDisplayWriting; - dpy->flags &= ~XlibDisplayReply; -#else - exit (1); -#endif - return 0; -} - - -/* - * This routine can be used to (cheaply) get some memory within a single - * Xlib routine for scratch space. A single buffer is reused each time - * if possible. To be MT safe, you can only call this between a call to - * GetReq* and a call to Data* or _XSend*, or in a context when the thread - * is guaranteed to not unlock the display. - */ -char *_XAllocScratch( - register Display *dpy, - unsigned long nbytes) -{ - if (nbytes > dpy->scratch_length) { - if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer); - if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes))) - dpy->scratch_length = nbytes; - else dpy->scratch_length = 0; - } - return (dpy->scratch_buffer); -} - -/* - * Scratch space allocator you can call any time, multiple times, and be - * MT safe, but you must hand the buffer back with _XFreeTemp. - */ -char *_XAllocTemp( - register Display *dpy, - unsigned long nbytes) -{ - char *buf; - - buf = _XAllocScratch(dpy, nbytes); - dpy->scratch_buffer = NULL; - dpy->scratch_length = 0; - return buf; -} - -void _XFreeTemp( - register Display *dpy, - char *buf, - unsigned long nbytes) -{ - if (dpy->scratch_buffer) - Xfree(dpy->scratch_buffer); - dpy->scratch_buffer = buf; - dpy->scratch_length = nbytes; -} - -/* - * Given a visual id, find the visual structure for this id on this display. - */ -Visual *_XVIDtoVisual( - Display *dpy, - VisualID id) -{ - register int i, j, k; - register Screen *sp; - register Depth *dp; - register Visual *vp; - for (i = 0; i < dpy->nscreens; i++) { - sp = &dpy->screens[i]; - for (j = 0; j < sp->ndepths; j++) { - dp = &sp->depths[j]; - /* if nvisuals == 0 then visuals will be NULL */ - for (k = 0; k < dp->nvisuals; k++) { - vp = &dp->visuals[k]; - if (vp->visualid == id) return (vp); - } - } - } - return (NULL); -} - -int -XFree (void *data) -{ - Xfree (data); - return 1; -} - -#ifdef _XNEEDBCOPYFUNC -void _Xbcopy(b1, b2, length) - register char *b1, *b2; - register length; -{ - if (b1 < b2) { - b2 += length; - b1 += length; - while (length--) - *--b2 = *--b1; - } else { - while (length--) - *b2++ = *b1++; - } -} -#endif - -#ifdef DataRoutineIsProcedure -void Data( - Display *dpy, - char *data, - long len) -{ - if (dpy->bufptr + (len) <= dpy->bufmax) { - memcpy(dpy->bufptr, data, (int)len); - dpy->bufptr += ((len) + 3) & ~3; - } else { - _XSend(dpy, data, len); - } -} -#endif /* DataRoutineIsProcedure */ - - -#ifdef LONG64 -int -_XData32( - Display *dpy, - register long *data, - unsigned len) -{ - register int *buf; - register long i; - - while (len) { - buf = (int *)dpy->bufptr; - i = dpy->bufmax - (char *)buf; - if (!i) { - _XFlush(dpy); - continue; - } - if (len < i) - i = len; - dpy->bufptr = (char *)buf + i; - len -= i; - i >>= 2; - while (--i >= 0) - *buf++ = *data++; - } - return 0; -} -#endif /* LONG64 */ - -#ifdef WORD64 - -/* - * XXX This is a *really* stupid way of doing this. It should just use - * dpy->bufptr directly, taking into account where in the word it is. - */ - -/* - * Data16 - Place 16 bit data in the buffer. - * - * "dpy" is a pointer to a Display. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static doData16( - register Display *dpy, - short *data, - unsigned len, - char *packbuffer) -{ - long *lp,*lpack; - long i, nwords,bits; - long mask16 = 0x000000000000ffff; - - lp = (long *)data; - lpack = (long *)packbuffer; - -/* nwords is the number of 16 bit values to be packed, - * the low order 16 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 1; - bits = 48; - - for(i=0;i<nwords;i++){ - if (bits == 48) *lpack = 0; - *lpack ^= (*lp & mask16) << bits; - bits -= 16 ; - lp++; - if(bits < 0){ - lpack++; - bits = 48; - } - } - Data(dpy, packbuffer, len); -} - -_XData16 ( - Display *dpy, - short *data, - unsigned len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 1; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - doData16 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) doData16 (dpy, data, len, packbuffer); -} - -/* - * Data32 - Place 32 bit data in the buffer. - * - * "dpy" is a pointer to a Display. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static doData32( - register Display *dpy - long *data, - unsigned len, - char *packbuffer) -{ - long *lp,*lpack; - long i,bits,nwords; - long mask32 = 0x00000000ffffffff; - - lpack = (long *) packbuffer; - lp = data; - -/* nwords is the number of 32 bit values to be packed - * the low order 32 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 2; - bits = 32; - - for(i=0;i<nwords;i++){ - if (bits == 32) *lpack = 0; - *lpack ^= (*lp & mask32) << bits; - bits = bits ^32; - lp++; - if(bits) - lpack++; - } - Data(dpy, packbuffer, len); -} - -void _XData32( - Display *dpy, - long *data, - unsigned len, -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 2; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - doData32 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) doData32 (dpy, data, len, packbuffer); -} - -#endif /* WORD64 */ - - -/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm. - * Otherwise, Xau will not be able to find your cookies in the Xauthority file. - * - * Note: POSIX says that the ``nodename'' member of utsname does _not_ have - * to have sufficient information for interfacing to the network, - * and so, you may be better off using gethostname (if it exists). - */ - -#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) -#define NEED_UTSNAME -#include <sys/utsname.h> -#endif - -/* - * _XGetHostname - similar to gethostname but allows special processing. - */ -int _XGetHostname ( - char *buf, - int maxlen) -{ - int len; - -#ifdef NEED_UTSNAME - struct utsname name; - - if (maxlen <= 0 || buf == NULL) - return 0; - - uname (&name); - len = strlen (name.nodename); - if (len >= maxlen) len = maxlen - 1; - strncpy (buf, name.nodename, len); - buf[len] = '\0'; -#else - if (maxlen <= 0 || buf == NULL) - return 0; - - buf[0] = '\0'; - (void) gethostname (buf, maxlen); - buf [maxlen - 1] = '\0'; - len = strlen(buf); -#endif /* NEED_UTSNAME */ - return len; -} - - -/* - * _XScreenOfWindow - get the Screen of a given window - */ - -Screen *_XScreenOfWindow (dpy, w) - Display *dpy; - Window w; -{ - register int i; - Window root; - int x, y; /* dummy variables */ - unsigned int width, height, bw, depth; /* dummy variables */ - - if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height, - &bw, &depth) == False) { - return None; - } - for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */ - if (root == RootWindow (dpy, i)) { - return ScreenOfDisplay (dpy, i); - } - } - return NULL; -} - - -#if defined(WIN32) - -/* - * These functions are intended to be used internally to Xlib only. - * These functions will always prefix the path with a DOS drive in the - * form "<drive-letter>:". As such, these functions are only suitable - * for use by Xlib function that supply a root-based path to some - * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will - * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir". - */ - -static int access_file (path, pathbuf, len_pathbuf, pathret) - char* path; - char* pathbuf; - int len_pathbuf; - char** pathret; -{ - if (access (path, F_OK) == 0) { - if (strlen (path) < len_pathbuf) - *pathret = pathbuf; - else - *pathret = Xmalloc (strlen (path) + 1); - if (*pathret) { - strcpy (*pathret, path); - return 1; - } - } - return 0; -} - -static int AccessFile (path, pathbuf, len_pathbuf, pathret) - char* path; - char* pathbuf; - int len_pathbuf; - char** pathret; -{ - unsigned long drives; - int i, len; - char* drive; - char buf[MAX_PATH]; - char* bufp; - - /* just try the "raw" name first and see if it works */ - if (access_file (path, pathbuf, len_pathbuf, pathret)) - return 1; - - /* try the places set in the environment */ - drive = getenv ("_XBASEDRIVE"); -#ifdef __UNIXOS2__ - if (!drive) - drive = getenv ("X11ROOT"); -#endif - if (!drive) - drive = "C:"; - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - -#ifndef __UNIXOS2__ - /* one last place to look */ - drive = getenv ("HOMEDRIVE"); - if (drive) { - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - } - - /* tried everywhere else, go fishing */ -#define C_DRIVE ('C' - 'A') -#define Z_DRIVE ('Z' - 'A') - /* does OS/2 (with or with gcc-emx) have getdrives? */ - drives = _getdrives (); - for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */ - if ((1 << i) & drives) { - len = 2 + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - *bufp = 'A' + i; - *(bufp + 1) = ':'; - *(bufp + 2) = '\0'; - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - } - } -#endif - return 0; -} - -int _XOpenFile(path, flags) - _Xconst char* path; - int flags; -{ - char buf[MAX_PATH]; - char* bufp = NULL; - int ret = -1; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - if (AccessFile (path, buf, MAX_PATH, &bufp)) - ret = open (bufp, flags); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -void* _XFopenFile(path, mode) - _Xconst char* path; - _Xconst char* mode; -{ - char buf[MAX_PATH]; - char* bufp = NULL; - void* ret = NULL; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - if (AccessFile (path, buf, MAX_PATH, &bufp)) - ret = fopen (bufp, mode); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -int _XAccessFile(path) - _Xconst char* path; -{ - char buf[MAX_PATH]; - char* bufp; - int ret = -1; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - ret = AccessFile (path, buf, MAX_PATH, &bufp); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -#endif - -#ifdef WIN32 -#undef _Xdebug -int _Xdebug = 0; -int *_Xdebug_p = &_Xdebug; -void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn; -void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn; -void (**_XLockMutex_fn_p)(LockInfoPtr -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = &_XLockMutex_fn; -void (**_XUnlockMutex_fn_p)(LockInfoPtr -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = &_XUnlockMutex_fn; -LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock; -#endif diff --git a/nx-X11/lib/X11/XlibInt.c.X.original b/nx-X11/lib/X11/XlibInt.c.X.original deleted file mode 100644 index c042eb2e4..000000000 --- a/nx-X11/lib/X11/XlibInt.c.X.original +++ /dev/null @@ -1,3429 +0,0 @@ -/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */ - -/* - * XlibInt.c - Internal support routines for the C subroutine - * interface library (Xlib) to the X Window System Protocol V11.0. - */ -#define NEED_EVENTS -#define NEED_REPLIES - -#ifdef WIN32 -#define _XLIBINT_ -#endif -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xpoll.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/extensions/xcmiscstr.h> -#include <stdio.h> -#ifdef WIN32 -#include <direct.h> -#endif - -#ifdef XTHREADS -#include "locking.h" - -/* these pointers get initialized by XInitThreads */ -LockInfoPtr _Xglobal_lock = NULL; -void (*_XCreateMutex_fn)(LockInfoPtr) = NULL; -/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */ -void (*_XFreeMutex_fn)(LockInfoPtr) = NULL; -void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = NULL; -void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = NULL; -xthread_t (*_Xthread_self_fn)(void) = NULL; - -#define XThread_Self() ((*_Xthread_self_fn)()) - -#define UnlockNextReplyReader(d) if ((d)->lock) \ - (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail) - -#define QueueReplyReaderLock(d) ((d)->lock ? \ - (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL) -#define QueueEventReaderLock(d) ((d)->lock ? \ - (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL) - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define InternalLockDisplay(d,wskip) if ((d)->lock) \ - (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__) -#else -#define InternalLockDisplay(d,wskip) if ((d)->lock) \ - (*(d)->lock->internal_lock_display)(d,wskip) -#endif - -#else /* XTHREADS else */ - -#define UnlockNextReplyReader(d) -#define UnlockNextEventReader(d) -#define InternalLockDisplay(d,wskip) - -#endif /* XTHREADS else */ - -/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX - * systems are broken and return EWOULDBLOCK when they should return EAGAIN - */ -#ifdef WIN32 -#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK) -#else -#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */ -#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS) -#else -#if defined(EAGAIN) && defined(EWOULDBLOCK) -#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK) -#else -#ifdef EAGAIN -#define ETEST() (errno == EAGAIN) -#else -#define ETEST() (errno == EWOULDBLOCK) -#endif /* EAGAIN */ -#endif /* EAGAIN && EWOULDBLOCK */ -#endif /* __CYGWIN__ */ -#endif /* WIN32 */ - -#ifdef WIN32 -#define ECHECK(err) (WSAGetLastError() == err) -#define ESET(val) WSASetLastError(val) -#else -#ifdef __UNIXOS2__ -#define ECHECK(err) (errno == err) -#define ESET(val) -#else -#ifdef ISC -#define ECHECK(err) ((errno == err) || ETEST()) -#else -#define ECHECK(err) (errno == err) -#endif -#define ESET(val) errno = val -#endif -#endif - -#if defined(LOCALCONN) || defined(LACHMAN) -#ifdef EMSGSIZE -#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE)) -#else -#define ESZTEST() ECHECK(ERANGE) -#endif -#else -#ifdef EMSGSIZE -#define ESZTEST() ECHECK(EMSGSIZE) -#endif -#endif - -#ifdef __UNIXOS2__ -#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t) -#include <limits.h> -#define MAX_PATH _POSIX_PATH_MAX -#endif - -#ifdef MUSTCOPY - -#define STARTITERATE(tpvar,type,start,endcond) \ - { register char *cpvar; \ - for (cpvar = (char *) (start); endcond; ) { \ - type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \ - tpvar = &dummy; -#define ITERPTR(tpvar) cpvar -#define RESETITERPTR(tpvar,type,start) cpvar = start -#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type) -#define ENDITERATE }} - -#else - -#define STARTITERATE(tpvar,type,start,endcond) \ - for (tpvar = (type *) (start); endcond; ) -#define ITERPTR(tpvar) (char *)tpvar -#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start) -#define INCITERPTR(tpvar,type) tpvar++ -#define ENDITERATE - -#endif /* MUSTCOPY */ - -typedef union { - xReply rep; - char buf[BUFSIZE]; -} _XAlignedBuffer; - -static char *_XAsyncReply( - Display *dpy, - register xReply *rep, - char *buf, - register int *lenp, - Bool discard); - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info); - -#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10) - -/* - * The following routines are internal routines used by Xlib for protocol - * packet transmission and reception. - * - * _XIOError(Display *) will be called if any sort of system call error occurs. - * This is assumed to be a fatal condition, i.e., XIOError should not return. - * - * _XError(Display *, xError *) will be called whenever an X_Error event is - * received. This is not assumed to be a fatal condition, i.e., it is - * acceptable for this procedure to return. However, XError should NOT - * perform any operations (directly or indirectly) on the DISPLAY. - * - * Routines declared with a return type of 'Status' return 0 on failure, - * and non 0 on success. Routines with no declared return type don't - * return anything. Whenever possible routines that create objects return - * the object they have created. - */ - -static xReq _dummy_request = { - 0, 0, 0 -}; - -/* - * This is an OS dependent routine which: - * 1) returns as soon as the connection can be written on.... - * 2) if the connection can be read, must enqueue events and handle errors, - * until the connection is writable. - */ -static void -_XWaitForWritable( - Display *dpy -#ifdef XTHREADS - , - xcondition_t cv /* our reading condition variable */ -#endif - ) -{ -#ifdef USE_POLL - struct pollfd filedes; -#else - fd_set r_mask; - fd_set w_mask; -#endif - int nfound; - -#ifdef USE_POLL - filedes.fd = dpy->fd; - filedes.events = 0; -#else - FD_ZERO(&r_mask); - FD_ZERO(&w_mask); -#endif - - for (;;) { -#ifdef XTHREADS - /* We allow only one thread at a time to read, to minimize - passing of read data between threads. - Now, who is it? If there is a non-NULL reply_awaiters and - we (i.e., our cv) are not at the head of it, then whoever - is at the head is the reader, and we don't read. - Otherwise there is no reply_awaiters or we are at the - head, having just appended ourselves. - In this case, if there is a event_awaiters, then whoever - is at the head of it got there before we did, and they are the - reader. - - Last cases: no event_awaiters and we are at the head of - reply_awaiters or reply_awaiters is NULL: we are the reader, - since there is obviously no one else involved. - - XXX - what if cv is NULL and someone else comes along after - us while we are waiting? - */ - - if (!dpy->lock || - (!dpy->lock->event_awaiters && - (!dpy->lock->reply_awaiters || - dpy->lock->reply_awaiters->cv == cv))) -#endif -#ifdef USE_POLL - filedes.events = POLLIN; - filedes.events |= POLLOUT; -#else - FD_SET(dpy->fd, &r_mask); - FD_SET(dpy->fd, &w_mask); -#endif - - do { - UnlockDisplay(dpy); -#ifdef USE_POLL - nfound = poll (&filedes, 1, -1); -#else - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL); -#endif - InternalLockDisplay(dpy, cv != NULL); - if (nfound < 0 && !ECHECK(EINTR)) - _XIOError(dpy); - } while (nfound <= 0); - - if ( -#ifdef USE_POLL - filedes.revents & POLLIN -#else - FD_ISSET(dpy->fd, &r_mask) -#endif - ) - { - _XAlignedBuffer buf; - BytesReadable_t pend; - register int len; - register xReply *rep; - - /* find out how much data can be read */ - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) - _XIOError(dpy); - len = pend; - - /* must read at least one xEvent; if none is pending, then - we'll just block waiting for it */ - if (len < SIZEOF(xReply) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) - len = SIZEOF(xReply); - - /* but we won't read more than the max buffer size */ - if (len > BUFSIZE) len = BUFSIZE; - - /* round down to an integral number of XReps */ - len = (len / SIZEOF(xReply)) * SIZEOF(xReply); - - (void) _XRead (dpy, buf.buf, (long) len); - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - int tmp = len; - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &tmp, True)); - len = tmp; - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *)rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE -#ifdef XTHREADS - if (dpy->lock && dpy->lock->event_awaiters) - ConditionSignal(dpy, dpy->lock->event_awaiters->cv); -#endif - } -#ifdef USE_POLL - if (filedes.revents & (POLLOUT|POLLHUP|POLLERR)) -#else - if (FD_ISSET(dpy->fd, &w_mask)) -#endif - { -#ifdef XTHREADS - if (dpy->lock) { - ConditionBroadcast(dpy, dpy->lock->writers); - } -#endif - return; - } - } -} - - -#define POLLFD_CACHE_SIZE 5 - -/* initialize the struct array passed to poll() below */ -Bool _XPollfdCacheInit( - Display *dpy) -{ -#ifdef USE_POLL - struct pollfd *pfp; - - pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd)); - if (!pfp) - return False; - pfp[0].fd = dpy->fd; - pfp[0].events = POLLIN; - - dpy->filedes = (XPointer)pfp; -#endif - return True; -} - -void _XPollfdCacheAdd( - Display *dpy, - int fd) -{ -#ifdef USE_POLL - struct pollfd *pfp = (struct pollfd *)dpy->filedes; - - if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) { - pfp[dpy->im_fd_length].fd = fd; - pfp[dpy->im_fd_length].events = POLLIN; - } -#endif -} - -/* ARGSUSED */ -void _XPollfdCacheDel( - Display *dpy, - int fd) /* not used */ -{ -#ifdef USE_POLL - struct pollfd *pfp = (struct pollfd *)dpy->filedes; - struct _XConnectionInfo *conni; - - /* just recalculate whole list */ - if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) { - int loc = 1; - for (conni = dpy->im_fd_info; conni; conni=conni->next) { - pfp[loc].fd = conni->fd; - pfp[loc].events = POLLIN; - loc++; - } - } -#endif -} - -/* returns True iff there is an event in the queue newer than serial_num */ - -static Bool -_XNewerQueuedEvent( - Display *dpy, - int serial_num) -{ - _XQEvent *qev; - - if (dpy->next_event_serial_num == serial_num) - return False; - - qev = dpy->head; - while (qev) { - if (qev->qserial_num >= serial_num) { - return True; - } - qev = qev->next; - } - return False; -} - -static int -_XWaitForReadable( - Display *dpy) -{ - int result; - int fd = dpy->fd; - struct _XConnectionInfo *ilist; - register int saved_event_serial = 0; - int in_read_events = 0; - register Bool did_proc_conni = False; -#ifdef USE_POLL - struct pollfd *filedes; -#else - fd_set r_mask; - int highest_fd = fd; -#endif - -#ifdef USE_POLL - if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE - && !(dpy->flags & XlibDisplayProcConni)) { - /* XXX - this fallback is gross */ - int i; - - filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd)); - filedes[0].fd = fd; - filedes[0].events = POLLIN; - for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) { - filedes[i].fd = ilist->fd; - filedes[i].events = POLLIN; - } - } else { - filedes = (struct pollfd *)dpy->filedes; - } -#else - FD_ZERO(&r_mask); -#endif - for (;;) { -#ifndef USE_POLL - FD_SET(fd, &r_mask); - if (!(dpy->flags & XlibDisplayProcConni)) - for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) { - FD_SET(ilist->fd, &r_mask); - if (ilist->fd > highest_fd) - highest_fd = ilist->fd; - } -#endif - UnlockDisplay(dpy); -#ifdef USE_POLL - result = poll(filedes, - (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length, - -1); -#else - result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL); -#endif - InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply); - if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy); - if (result <= 0) - continue; -#ifdef USE_POLL - if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR)) -#else - if (FD_ISSET(fd, &r_mask)) -#endif - break; - if (!(dpy->flags & XlibDisplayProcConni)) { - int i; - - saved_event_serial = dpy->next_event_serial_num; - /* dpy flags can be clobbered by internal connection callback */ - in_read_events = dpy->flags & XlibDisplayReadEvents; - for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) { -#ifdef USE_POLL - if (filedes[i].revents & POLLIN) -#else - if (FD_ISSET(ilist->fd, &r_mask)) -#endif - { - _XProcessInternalConnection(dpy, ilist); - did_proc_conni = True; - } - } -#ifdef USE_POLL - if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE) - Xfree(filedes); -#endif - } - if (did_proc_conni) { - /* some internal connection callback might have done an - XPutBackEvent. We notice it here and if we needed an event, - we can return all the way. */ - if (_XNewerQueuedEvent(dpy, saved_event_serial) - && (in_read_events -#ifdef XTHREADS - || (dpy->lock && dpy->lock->event_awaiters) -#endif - )) - return -2; - did_proc_conni = False; - } - } -#ifdef XTHREADS -#ifdef XTHREADS_DEBUG - printf("thread %x _XWaitForReadable returning\n", XThread_Self()); -#endif -#endif - return 0; -} - -static -int _XSeqSyncFunction( - register Display *dpy) -{ - xGetInputFocusReply rep; - register xReq *req; - - LockDisplay(dpy); - if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { - GetEmptyReq(GetInputFocus, req); - (void) _XReply (dpy, (xReply *)&rep, 0, xTrue); - } - /* could get XID handler while waiting for reply in MT env */ - if (dpy->synchandler == _XSeqSyncFunction) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -#ifdef XTHREADS -static void _XFlushInt( - register Display *dpy, - register xcondition_t cv); -#endif - -/* - * _XFlush - Flush the X request buffer. If the buffer is empty, no - * action is taken. This routine correctly handles incremental writes. - * This routine may have to be reworked if int < long. - */ -void _XFlush( - register Display *dpy) -{ -#ifdef XTHREADS - /* With multi-threading we introduce an internal routine to which - we can pass a condition variable to do locking correctly. */ - - _XFlushInt(dpy, NULL); -} - -/* _XFlushInt - Internal version of _XFlush used to do multi-threaded - * locking correctly. - */ - -static void _XFlushInt( - register Display *dpy, - register xcondition_t cv) -{ -#endif /* XTHREADS*/ - register long size, todo; - register int write_stat; - register char *bufindex; - _XExtension *ext; - - /* This fix resets the bufptr to the front of the buffer so - * additional appends to the bufptr will not corrupt memory. Since - * the server is down, these appends are no-op's anyway but - * callers of _XFlush() are not verifying this before they call it. - */ - if (dpy->flags & XlibDisplayIOError) - { - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *)&_dummy_request; - return; - } - -#ifdef XTHREADS - while (dpy->flags & XlibDisplayWriting) { - if (dpy->lock) { - ConditionWait(dpy, dpy->lock->writers); - } else { - _XWaitForWritable (dpy, cv); - } - } -#endif - size = todo = dpy->bufptr - dpy->buffer; - if (!size) return; -#ifdef XTHREADS - dpy->flags |= XlibDisplayWriting; - /* make sure no one else can put in data */ - dpy->bufptr = dpy->bufmax; -#endif - for (ext = dpy->flushes; ext; ext = ext->next_flush) - (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size); - bufindex = dpy->buffer; - /* - * While write has not written the entire buffer, keep looping - * until the entire buffer is written. bufindex will be - * incremented and size decremented as buffer is written out. - */ - while (size) { - ESET(0); - write_stat = _X11TransWrite(dpy->trans_conn, - bufindex, (int) todo); - if (write_stat >= 0) { - size -= write_stat; - todo = size; - bufindex += write_stat; - } else if (ETEST()) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); -#ifdef SUNSYSV - } else if (ECHECK(0)) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); -#endif -#ifdef ESZTEST - } else if (ESZTEST()) { - if (todo > 1) - todo >>= 1; - else { - _XWaitForWritable(dpy -#ifdef XTHREADS - , cv -#endif - ); - } -#endif - } else if (!ECHECK(EINTR)) { - /* Write failed! */ - /* errno set by write system call. */ - _XIOError(dpy); - } - } - dpy->last_req = (char *)&_dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->bufptr = dpy->buffer; -#ifdef XTHREADS - dpy->flags &= ~XlibDisplayWriting; -#endif -} - -int -_XEventsQueued( - register Display *dpy, - int mode) -{ - register int len; - BytesReadable_t pend; - _XAlignedBuffer buf; - register xReply *rep; - char *read_buf; -#ifdef XTHREADS - int entry_event_serial_num; - struct _XCVList *cvl = NULL; - xthread_t self; - -#ifdef XTHREADS_DEBUG - printf("_XEventsQueued called in thread %x\n", XThread_Self()); -#endif -#endif /* XTHREADS*/ - - if (mode == QueuedAfterFlush) - { - _XFlush(dpy); - if (dpy->qlen) - return(dpy->qlen); - } - if (dpy->flags & XlibDisplayIOError) return(dpy->qlen); - -#ifdef XTHREADS - /* create our condition variable and append to list, - * unless we were called from within XProcessInternalConnection - * or XLockDisplay - */ - xthread_clear_id(self); - if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread) - || xthread_have_id (dpy->lock->locking_thread))) - /* some thread is in XProcessInternalConnection or XLockDisplay - so we have to see if we are it */ - self = XThread_Self(); - if (!xthread_have_id(self) - || (!xthread_equal(self, dpy->lock->conni_thread) - && !xthread_equal(self, dpy->lock->locking_thread))) { - /* In the multi-threaded case, if there is someone else - reading events, then there aren't any available, so - we just return. If we waited we would block. - */ - if (dpy->lock && dpy->lock->event_awaiters) - return dpy->qlen; - /* nobody here but us, so lock out any newcomers */ - cvl = QueueEventReaderLock(dpy); - } - - while (dpy->lock && cvl && dpy->lock->reply_first) { - /* note which events we have already seen so we'll know - if _XReply (in another thread) reads one */ - entry_event_serial_num = dpy->next_event_serial_num; - ConditionWait(dpy, cvl->cv); - /* did _XReply read an event we can return? */ - if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) - { - UnlockNextEventReader(dpy); - return 0; - } - } -#endif /* XTHREADS*/ - - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) - _XIOError(dpy); -#ifdef XCONN_CHECK_FREQ - /* This is a crock, required because FIONREAD or equivalent is - * not guaranteed to detect a broken connection. - */ - if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ) - { - int result; -#ifdef USE_POLL - struct pollfd filedes; -#else - fd_set r_mask; - static struct timeval zero_time; -#endif - - dpy->conn_checker = 0; -#ifdef USE_POLL - filedes.fd = dpy->fd; - filedes.events = POLLIN; - if ((result = poll(&filedes, 1, 0))) -#else - FD_ZERO(&r_mask); - FD_SET(dpy->fd, &r_mask); - if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time))) -#endif - { - if (result > 0) - { - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) - _XIOError(dpy); - /* we should not get zero, if we do, force a read */ - if (!pend) - pend = SIZEOF(xReply); - } - else if (result < 0 && !ECHECK(EINTR)) - _XIOError(dpy); - } - } -#endif /* XCONN_CHECK_FREQ */ - if (!(len = pend)) { - /* _XFlush can enqueue events */ -#ifdef XTHREADS - if (cvl) -#endif - { - UnlockNextEventReader(dpy); - } - return(dpy->qlen); - } - /* Force a read if there is not enough data. Otherwise, - * a select() loop at a higher-level will spin undesirably, - * and we've seen at least one OS that appears to not update - * the result from FIONREAD once it has returned nonzero. - */ -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_awaiters) { - read_buf = (char *)dpy->lock->reply_awaiters->buf; - len = SIZEOF(xReply); - } else -#endif /* XTHREADS*/ - { - read_buf = buf.buf; - - if (len < SIZEOF(xReply) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) - len = SIZEOF(xReply); - else if (len > BUFSIZE) - len = BUFSIZE; - len = (len / SIZEOF(xReply)) * SIZEOF(xReply); - } -#ifdef XCONN_CHECK_FREQ - dpy->conn_checker = 0; -#endif - - (void) _XRead (dpy, read_buf, (long) len); - -#ifdef XTHREADS - /* what did we actually read: reply or event? */ - if (dpy->lock && dpy->lock->reply_awaiters) { - if (((xReply *)read_buf)->generic.type == X_Reply || - ((xReply *)read_buf)->generic.type == X_Error) - { - dpy->lock->reply_was_read = True; - dpy->lock->reply_first = True; - if (read_buf != (char *)dpy->lock->reply_awaiters->buf) - memcpy(dpy->lock->reply_awaiters->buf, read_buf, - len); - if (cvl) { - UnlockNextEventReader(dpy); - } - return(dpy->qlen); /* we read, so we can return */ - } else if (read_buf != buf.buf) - memcpy(buf.buf, read_buf, len); - } -#endif /* XTHREADS*/ - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - int tmp = len; - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &tmp, True)); - len = tmp; - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *)rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE - -#ifdef XTHREADS - if (cvl) -#endif - { - UnlockNextEventReader(dpy); - } - return(dpy->qlen); -} - -/* _XReadEvents - Flush the output queue, - * then read as many events as possible (but at least 1) and enqueue them - */ -void _XReadEvents( - register Display *dpy) -{ - _XAlignedBuffer buf; - BytesReadable_t pend; - int len; - register xReply *rep; - Bool not_yet_flushed = True; - char *read_buf; - int i; - int entry_event_serial_num = dpy->next_event_serial_num; -#ifdef XTHREADS - struct _XCVList *cvl = NULL; - xthread_t self; - -#ifdef XTHREADS_DEBUG - printf("_XReadEvents called in thread %x\n", - XThread_Self()); -#endif - /* create our condition variable and append to list, - * unless we were called from within XProcessInternalConnection - * or XLockDisplay - */ - xthread_clear_id(self); - if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread) - || xthread_have_id (dpy->lock->locking_thread))) - /* some thread is in XProcessInternalConnection or XLockDisplay - so we have to see if we are it */ - self = XThread_Self(); - if (!xthread_have_id(self) - || (!xthread_equal(self, dpy->lock->conni_thread) - && !xthread_equal(self, dpy->lock->locking_thread))) - cvl = QueueEventReaderLock(dpy); -#endif /* XTHREADS */ - - do { -#ifdef XTHREADS - /* if it is not our turn to read an event off the wire, - wait til we're at head of list */ - if (dpy->lock && cvl && - (dpy->lock->event_awaiters != cvl || - dpy->lock->reply_first)) { - ConditionWait(dpy, cvl->cv); - continue; - } -#endif /* XTHREADS */ - /* find out how much data can be read */ - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) - _XIOError(dpy); - len = pend; - - /* must read at least one xEvent; if none is pending, then - we'll just flush and block waiting for it */ - if (len < SIZEOF(xEvent) -#ifdef XTHREADS - || dpy->async_handlers -#endif - ) { - len = SIZEOF(xEvent); - /* don't flush until the first time we would block */ - if (not_yet_flushed) { - _XFlush (dpy); - if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) { - /* _XReply has read an event for us */ - goto got_event; - } - not_yet_flushed = False; - } - } - -#ifdef XTHREADS - /* If someone is waiting for a reply, gamble that - the reply will be the next thing on the wire - and read it into their buffer. */ - if (dpy->lock && dpy->lock->reply_awaiters) { - read_buf = (char *)dpy->lock->reply_awaiters->buf; - len = SIZEOF(xReply); - } else -#endif /* XTHREADS*/ - { - read_buf = buf.buf; - - /* but we won't read more than the max buffer size */ - if (len > BUFSIZE) - len = BUFSIZE; - - /* round down to an integral number of XReps */ - len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent); - } - -#ifdef XTHREADS - if (xthread_have_id(self)) - /* save value we may have to stick in conni_thread */ - dpy->lock->reading_thread = self; -#endif /* XTHREADS */ - dpy->flags |= XlibDisplayReadEvents; - i = _XRead (dpy, read_buf, (long) len); - dpy->flags &= ~XlibDisplayReadEvents; - if (i == -2) { - /* special flag from _XRead to say that internal connection has - done XPutBackEvent. Which we can use so we're done. */ - got_event: -#ifdef XTHREADS - if (dpy->lock && dpy->lock->lock_wait) { - if (dpy->lock->event_awaiters != cvl) - /* since it is not us, must be user lock thread */ - ConditionSignal(dpy, - dpy->lock->event_awaiters->cv); - (*dpy->lock->lock_wait)(dpy); - continue; - } -#endif - break; - } -#ifdef XTHREADS - if (xthread_have_id(self)) - xthread_clear_id(dpy->lock->reading_thread); - - /* what did we actually read: reply or event? */ - if (dpy->lock && dpy->lock->reply_awaiters) { - if (((xReply *)read_buf)->generic.type == X_Reply || - ((xReply *)read_buf)->generic.type == X_Error) - { - dpy->lock->reply_was_read = True; - dpy->lock->reply_first = True; - if (read_buf != (char *)dpy->lock->reply_awaiters->buf) - memcpy(dpy->lock->reply_awaiters->buf, - read_buf, len); - ConditionSignal(dpy, dpy->lock->reply_awaiters->cv); - continue; - } else if (read_buf != buf.buf) - memcpy(buf.buf, read_buf, len); - } -#endif /* XTHREADS */ - - STARTITERATE(rep,xReply,buf.buf,len > 0) { - if (rep->generic.type == X_Reply) { - RESETITERPTR(rep,xReply, - _XAsyncReply (dpy, rep, - ITERPTR(rep), &len, True)); - pend = len; - } else { - if (rep->generic.type == X_Error) - _XError (dpy, (xError *) rep); - else /* must be an event packet */ - _XEnq (dpy, (xEvent *)rep); - INCITERPTR(rep,xReply); - len -= SIZEOF(xReply); - } - } ENDITERATE; - } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num)); - - UnlockNextEventReader(dpy); -} - -/* - * _XRead - Read bytes from the socket taking into account incomplete - * reads. This routine may have to be reworked if int < long. - */ -int _XRead( - register Display *dpy, - register char *data, - register long size) -{ - register long bytes_read; -#ifdef XTHREADS - int original_size = size; -#endif - - if ((dpy->flags & XlibDisplayIOError) || size == 0) - return 0; - ESET(0); - while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size)) - != size) { - - if (bytes_read > 0) { - size -= bytes_read; - data += bytes_read; - } - else if (ETEST()) { - if (_XWaitForReadable(dpy) == -2) - return -2; /* internal connection did XPutBackEvent */ - ESET(0); - } -#ifdef SUNSYSV - else if (ECHECK(0)) { - if (_XWaitForReadable(dpy) == -2) - return -2; /* internal connection did XPutBackEvent */ - } -#endif - else if (bytes_read == 0) { - /* Read failed because of end of file! */ - ESET(EPIPE); - _XIOError(dpy); - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ - if (!ECHECK(EINTR)) - _XIOError(dpy); - } - } -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_bytes_left > 0) - { - dpy->lock->reply_bytes_left -= original_size; - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } -#endif /* XTHREADS*/ - return 0; -} - -#ifdef LONG64 -void _XRead32( - Display *dpy, - register long *data, - long len) -{ - register int *buf; - register long i; - - if (len) { - (void) _XRead(dpy, (char *)data, len); - i = len >> 2; - buf = (int *)data + i; - data += i; - while (--i >= 0) - *--data = *--buf; - } -} -#endif /* LONG64 */ - -#ifdef WORD64 - -/* - * XXX This is a *really* stupid way of doing this.... - * PACKBUFFERSIZE must be a multiple of 4. - */ - -#define PACKBUFFERSIZE 4096 - - -/* - * _XRead32 - Read bytes from the socket unpacking each 32 bits - * into a long (64 bits on a CRAY computer). - * - */ -static void _doXRead32( - register Display *dpy, - register long *data - register long size, - register char *packbuffer) -{ - long *lpack,*lp; - long mask32 = 0x00000000ffffffff; - long maskw, nwords, i, bits; - - _XReadPad (dpy, packbuffer, size); - - lp = data; - lpack = (long *) packbuffer; - nwords = size >> 2; - bits = 32; - - for(i=0;i<nwords;i++){ - maskw = mask32 << bits; - *lp++ = ( *lpack & maskw ) >> bits; - bits = bits ^32; - if(bits){ - lpack++; - } - } -} - -void _XRead32( - Display *dpy, - long *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 2; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) _doXRead32 (dpy, data, len, packbuffer); -} - - - -/* - * _XRead16 - Read bytes from the socket unpacking each 16 bits - * into a long (64 bits on a CRAY computer). - * - */ -static _doXRead16( - register Display *dpy, - register short *data, - register long size, - char *packbuffer) -{ - long *lpack,*lp; - long mask16 = 0x000000000000ffff; - long maskw, nwords, i, bits; - - (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */ - - lp = (long *) data; - lpack = (long *) packbuffer; - nwords = size >> 1; /* number of 16 bit words to be unpacked */ - bits = 48; - for(i=0;i<nwords;i++){ - maskw = mask16 << bits; - *lp++ = ( *lpack & maskw ) >> bits; - bits -= 16; - if(bits < 0){ - lpack++; - bits = 48; - } - } -} - -void _XRead16( - Display *dpy, - short *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 1; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) _doXRead16 (dpy, data, len, packbuffer); -} - -void _XRead16Pad( - Display *dpy, - short *data, - long size) -{ - int slop = (size & 3); - short slopbuf[3]; - - _XRead16 (dpy, data, size); - if (slop > 0) { - _XRead16 (dpy, slopbuf, 4 - slop); - } -} -#endif /* WORD64 */ - - -/* - * _XReadPad - Read bytes from the socket taking into account incomplete - * reads. If the number of bytes is not 0 mod 4, read additional pad - * bytes. This routine may have to be reworked if int < long. - */ -void _XReadPad( - register Display *dpy, - register char *data, - register long size) -{ - register long bytes_read; - struct iovec iov[2]; - char pad[3]; -#ifdef XTHREADS - int original_size; -#endif - - if ((dpy->flags & XlibDisplayIOError) || size == 0) return; - iov[0].iov_len = (int)size; - iov[0].iov_base = data; - /* - * The following hack is used to provide 32 bit long-word - * aligned padding. The [1] vector is of length 0, 1, 2, or 3, - * whatever is needed. - */ - - iov[1].iov_len = -size & 3; - iov[1].iov_base = pad; - size += iov[1].iov_len; -#ifdef XTHREADS - original_size = size; -#endif - ESET(0); - while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) { - - if (bytes_read > 0) { - size -= bytes_read; - if (iov[0].iov_len < bytes_read) { - int pad_bytes_read = bytes_read - iov[0].iov_len; - iov[1].iov_len -= pad_bytes_read; - iov[1].iov_base = - (char *)iov[1].iov_base + pad_bytes_read; - iov[0].iov_len = 0; - } - else { - iov[0].iov_len -= bytes_read; - iov[0].iov_base = (char *)iov[0].iov_base + bytes_read; - } - } - else if (ETEST()) { - _XWaitForReadable(dpy); - ESET(0); - } -#ifdef SUNSYSV - else if (ECHECK(0)) { - _XWaitForReadable(dpy); - } -#endif - else if (bytes_read == 0) { - /* Read failed because of end of file! */ - ESET(EPIPE); - _XIOError(dpy); - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ - if (!ECHECK(EINTR)) - _XIOError(dpy); - } - } -#ifdef XTHREADS - if (dpy->lock && dpy->lock->reply_bytes_left > 0) - { - dpy->lock->reply_bytes_left -= original_size; - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } -#endif /* XTHREADS*/ -} - -/* - * _XSend - Flush the buffer and send the client data. 32 bit word aligned - * transmission is used, if size is not 0 mod 4, extra bytes are transmitted. - * This routine may have to be reworked if int < long; - */ -void -_XSend ( - register Display *dpy, - _Xconst char *data, - register long size) -{ - struct iovec iov[3]; - static char const pad[3] = {0, 0, 0}; - /* XText8 and XText16 require that the padding bytes be zero! */ - - long skip, dbufsize, padsize, total, todo; - _XExtension *ext; - - if (!size || (dpy->flags & XlibDisplayIOError)) return; - dbufsize = dpy->bufptr - dpy->buffer; -#ifdef XTHREADS - dpy->flags |= XlibDisplayWriting; - /* make sure no one else can put in data */ - dpy->bufptr = dpy->bufmax; -#endif - padsize = -size & 3; - for (ext = dpy->flushes; ext; ext = ext->next_flush) { - (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize); - (*ext->before_flush)(dpy, &ext->codes, (char *)data, size); - if (padsize) - (*ext->before_flush)(dpy, &ext->codes, pad, padsize); - } - skip = 0; - todo = total = dbufsize + size + padsize; - - /* - * There are 3 pieces that may need to be written out: - * - * o whatever is in the display buffer - * o the data passed in by the user - * o any padding needed to 32bit align the whole mess - * - * This loop looks at all 3 pieces each time through. It uses skip - * to figure out whether or not a given piece is needed. - */ - while (total) { - long before = skip; /* amount of whole thing written */ - long remain = todo; /* amount to try this time, <= total */ - int i = 0; - long len; - - /* You could be very general here and have "in" and "out" iovecs - * and write a loop without using a macro, but what the heck. This - * translates to: - * - * how much of this piece is new? - * if more new then we are trying this time, clamp - * if nothing new - * then bump down amount already written, for next piece - * else put new stuff in iovec, will need all of next piece - * - * Note that todo had better be at least 1 or else we'll end up - * writing 0 iovecs. - */ -#define InsertIOV(pointer, length) \ - len = (length) - before; \ - if (len > remain) \ - len = remain; \ - if (len <= 0) { \ - before = (-len); \ - } else { \ - iov[i].iov_len = len; \ - iov[i].iov_base = (pointer) + before; \ - i++; \ - remain -= len; \ - before = 0; \ - } - - InsertIOV (dpy->buffer, dbufsize) - InsertIOV ((char *)data, size) - InsertIOV ((char *)pad, padsize) - - ESET(0); - if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) { - skip += len; - total -= len; - todo = total; - } else if (ETEST()) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); -#ifdef SUNSYSV - } else if (ECHECK(0)) { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); -#endif -#ifdef ESZTEST - } else if (ESZTEST()) { - if (todo > 1) - todo >>= 1; - else { - _XWaitForWritable(dpy -#ifdef XTHREADS - , NULL -#endif - ); - } -#endif - } else if (!ECHECK(EINTR)) { - _XIOError(dpy); - } - } - dpy->last_req = (char *) & _dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->bufptr = dpy->buffer; -#ifdef XTHREADS - dpy->flags &= ~XlibDisplayWriting; -#endif - return; -} - -static void -_XGetMiscCode( - register Display *dpy) -{ - xQueryExtensionReply qrep; - register xQueryExtensionReq *qreq; - xXCMiscGetVersionReply vrep; - register xXCMiscGetVersionReq *vreq; - - if (dpy->xcmisc_opcode) - return; - GetReq(QueryExtension, qreq); - qreq->nbytes = sizeof(XCMiscExtensionName) - 1; - qreq->length += (qreq->nbytes+(unsigned)3)>>2; - _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes); - if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue)) - dpy->xcmisc_opcode = -1; - else { - GetReq(XCMiscGetVersion, vreq); - vreq->reqType = qrep.major_opcode; - vreq->miscReqType = X_XCMiscGetVersion; - vreq->majorVersion = XCMiscMajorVersion; - vreq->minorVersion = XCMiscMinorVersion; - if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue)) - dpy->xcmisc_opcode = -1; - else - dpy->xcmisc_opcode = qrep.major_opcode; - } -} - -static int -_XIDHandler( - register Display *dpy) -{ - xXCMiscGetXIDRangeReply grep; - register xXCMiscGetXIDRangeReq *greq; - - LockDisplay(dpy); - _XGetMiscCode(dpy); - if (dpy->xcmisc_opcode > 0) { - GetReq(XCMiscGetXIDRange, greq); - greq->reqType = dpy->xcmisc_opcode; - greq->miscReqType = X_XCMiscGetXIDRange; - if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) { - dpy->resource_id = ((grep.start_id - dpy->resource_base) >> - dpy->resource_shift); - dpy->resource_max = dpy->resource_id; - if (grep.count > 5) - dpy->resource_max += grep.count - 6; - dpy->resource_max <<= dpy->resource_shift; - } - } - if (dpy->flags & XlibDisplayPrivSync) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -/* - * _XAllocID - resource ID allocation routine. - */ -XID _XAllocID( - register Display *dpy) -{ - XID id; - - id = dpy->resource_id << dpy->resource_shift; - if (id >= dpy->resource_max) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - if (id <= dpy->resource_mask) { - dpy->resource_id++; - return (dpy->resource_base + id); - } - if (id != 0x10000000) { - (void) fprintf(stderr, - "Xlib: resource ID allocation space exhausted!\n"); - id = 0x10000000; - dpy->resource_id = id >> dpy->resource_shift; - } - return id; -} - -/* - * _XAllocIDs - multiple resource ID allocation routine. - */ -void _XAllocIDs( - register Display *dpy, - XID *ids, - int count) -{ - XID id; - int i; - xXCMiscGetXIDListReply grep; - register xXCMiscGetXIDListReq *greq; - - id = dpy->resource_id << dpy->resource_shift; - if (dpy->resource_max <= dpy->resource_mask && - id <= dpy->resource_mask && - (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) { - id += dpy->resource_base; - for (i = 0; i < count; i++) { - ids[i] = id; - id += (1 << dpy->resource_shift); - dpy->resource_id++; - } - return; - } - grep.count = 0; - _XGetMiscCode(dpy); - if (dpy->xcmisc_opcode > 0) { - GetReq(XCMiscGetXIDList, greq); - greq->reqType = dpy->xcmisc_opcode; - greq->miscReqType = X_XCMiscGetXIDList; - greq->count = count; - if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) { - _XRead32(dpy, (long *) ids, 4L * (long) (grep.count)); - for (i = 0; i < grep.count; i++) { - id = (ids[i] - dpy->resource_base) >> dpy->resource_shift; - if (id >= dpy->resource_id) - dpy->resource_id = id; - } - if (id >= dpy->resource_max) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - } - } - for (i = grep.count; i < count; i++) - ids[i] = XAllocID(dpy); -} - -/* - * The hard part about this is that we only get 16 bits from a reply. - * We have three values that will march along, with the following invariant: - * dpy->last_request_read <= rep->sequenceNumber <= dpy->request - * We have to keep - * dpy->request - dpy->last_request_read < 2^16 - * or else we won't know for sure what value to use in events. We do this - * by forcing syncs when we get close. - */ - -unsigned long -_XSetLastRequestRead( - register Display *dpy, - register xGenericReply *rep) -{ - register unsigned long newseq, lastseq; - - lastseq = dpy->last_request_read; - /* - * KeymapNotify has no sequence number, but is always guaranteed - * to immediately follow another event, except when generated via - * SendEvent (hmmm). - */ - if ((rep->type & 0x7f) == KeymapNotify) - return(lastseq); - - newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber; - - if (newseq < lastseq) { - newseq += 0x10000; - if (newseq > dpy->request) { - (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, - (unsigned int) rep->type); - newseq -= 0x10000; - } - } - - dpy->last_request_read = newseq; - return(newseq); -} - -/* - * _XReply - Wait for a reply packet and copy its contents into the - * specified rep. Meanwhile we must handle error and event packets that - * we may encounter. - */ -Status -_XReply ( - register Display *dpy, - register xReply *rep, - int extra, /* number of 32-bit words expected after the reply */ - Bool discard) /* should I discard data following "extra" words? */ -{ - /* Pull out the serial number now, so that (currently illegal) requests - * generated by an error handler don't confuse us. - */ - unsigned long cur_request = dpy->request; -#ifdef XTHREADS - struct _XCVList *cvl; -#endif - - if (dpy->flags & XlibDisplayIOError) - return 0; - -#ifdef XTHREADS - /* create our condition variable and append to list */ - cvl = QueueReplyReaderLock(dpy); - if (cvl) { - cvl->buf = rep; - if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters) - dpy->lock->reply_first = True; - } - -#ifdef XTHREADS_DEBUG - printf("_XReply called in thread %x, adding %x to cvl\n", - XThread_Self(), cvl); -#endif - - _XFlushInt(dpy, cvl ? cvl->cv : NULL); - /* if it is not our turn to read a reply off the wire, - * wait til we're at head of list. if there is an event waiter, - * and our reply hasn't been read, they'll be in select and will - * hand control back to us next. - */ - if(dpy->lock && - (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) { - ConditionWait(dpy, cvl->cv); - } - dpy->flags |= XlibDisplayReply; -#else /* XTHREADS else */ - _XFlush(dpy); -#endif - - for (;;) { -#ifdef XTHREADS - /* Did another thread's _XReadEvents get our reply by accident? */ - if (!dpy->lock || !dpy->lock->reply_was_read) -#endif - (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply)); -#ifdef XTHREADS - if (dpy->lock) - dpy->lock->reply_was_read = False; -#endif - - switch ((int)rep->generic.type) { - - case X_Reply: - /* Reply received. Fast update for synchronous replies, - * but deal with multiple outstanding replies. - */ - if (rep->generic.sequenceNumber == (cur_request & 0xffff)) - dpy->last_request_read = cur_request; - else { - int pend = SIZEOF(xReply); - if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False) - != (char *)rep) - continue; - } - if (extra <= rep->generic.length) { - if (extra > 0) - /* - * Read the extra data into storage immediately - * following the GenericReply structure. - */ - (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)), - ((long)extra) << 2); - if (discard) { - if (extra < rep->generic.length) - _XEatData(dpy, (rep->generic.length - extra) << 2); - } -#ifdef XTHREADS - if (dpy->lock) { - if (discard) { - dpy->lock->reply_bytes_left = 0; - } else { - dpy->lock->reply_bytes_left = - (rep->generic.length - extra) << 2; - } - if (dpy->lock->reply_bytes_left == 0) { - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - } - } else - dpy->flags &= ~XlibDisplayReply; -#endif - return 1; - } - /* - *if we get here, then extra > rep->generic.length--meaning we - * read a reply that's shorter than we expected. This is an - * error, but we still need to figure out how to handle it... - */ - (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)), - ((long) rep->generic.length) << 2); - dpy->flags &= ~XlibDisplayReply; - UnlockNextReplyReader(dpy); - _XIOError (dpy); - return (0); - - case X_Error: - { - register _XExtension *ext; - register Bool ret = False; - int ret_code; - xError *err = (xError *) rep; - unsigned long serial; - - dpy->flags &= ~XlibDisplayReply; - serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep); - if (serial == cur_request) - /* do not die on "no such font", "can't allocate", - "can't grab" failures */ - switch ((int)err->errorCode) { - case BadName: - switch (err->majorCode) { - case X_LookupColor: - case X_AllocNamedColor: - UnlockNextReplyReader(dpy); - return(0); - } - break; - case BadFont: - if (err->majorCode == X_QueryFont) { - UnlockNextReplyReader(dpy); - return (0); - } - break; - case BadAlloc: - case BadAccess: - UnlockNextReplyReader(dpy); - return (0); - } - /* - * we better see if there is an extension who may - * want to suppress the error. - */ - for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) { - if (ext->error) - ret = (*ext->error)(dpy, err, &ext->codes, &ret_code); - } - if (!ret) { - _XError(dpy, err); - ret_code = 0; - } - if (serial == cur_request) { - UnlockNextReplyReader(dpy); - return(ret_code); - } - - } /* case X_Error */ - break; - default: - _XEnq(dpy, (xEvent *) rep); -#ifdef XTHREADS - if (dpy->lock && dpy->lock->event_awaiters) - ConditionSignal(dpy, dpy->lock->event_awaiters->cv); -#endif - break; - } - } -} - -static char * -_XAsyncReply( - Display *dpy, - register xReply *rep, - char *buf, - register int *lenp, - Bool discard) -{ - register _XAsyncHandler *async, *next; - register int len; - register Bool consumed = False; - char *nbuf; - - (void) _XSetLastRequestRead(dpy, &rep->generic); - len = SIZEOF(xReply) + (rep->generic.length << 2); - if (len < SIZEOF(xReply)) { - _XIOError (dpy); - buf += *lenp; - *lenp = 0; - return buf; - } - - for (async = dpy->async_handlers; async; async = next) { - next = async->next; - if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data))) - break; - } - if (!consumed) { - if (!discard) - return buf; - (void) fprintf(stderr, - "Xlib: unexpected async reply (sequence 0x%lx)!\n", - dpy->last_request_read); -#ifdef XTHREADS -#ifdef XTHREADS_DEBUG - printf("thread %x, unexpected async reply\n", XThread_Self()); -#endif -#endif - if (len > *lenp) - _XEatData(dpy, len - *lenp); - } - if (len < SIZEOF(xReply)) - { - _XIOError (dpy); - buf += *lenp; - *lenp = 0; - return buf; - } - if (len >= *lenp) { - buf += *lenp; - *lenp = 0; - return buf; - } - *lenp -= len; - buf += len; - len = *lenp; - nbuf = buf; - while (len > SIZEOF(xReply)) { - if (*buf == X_Reply) - return nbuf; - buf += SIZEOF(xReply); - len -= SIZEOF(xReply); - } - if (len > 0 && len < SIZEOF(xReply)) { - buf = nbuf; - len = SIZEOF(xReply) - len; - nbuf -= len; - memmove(nbuf, buf, *lenp); - (void) _XRead(dpy, nbuf + *lenp, (long)len); - *lenp += len; - } - return nbuf; -} - -/* - * Support for internal connections, such as an IM might use. - * By Stephen Gildea, X Consortium, September 1993 - */ - -/* _XRegisterInternalConnection - * Each IM (or Xlib extension) that opens a file descriptor that Xlib should - * include in its select/poll mask must call this function to register the - * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch - * will also be called. - * - * Whenever Xlib detects input available on fd, it will call callback - * with call_data to process it. If non-Xlib code calls select/poll - * and detects input available, it must call XProcessInternalConnection, - * which will call the associated callback. - * - * Non-Xlib code can learn about these additional fds by calling - * XInternalConnectionNumbers or, more typically, by registering - * a XConnectionWatchProc with XAddConnectionWatch - * to be called when fds are registered or unregistered. - * - * Returns True if registration succeeded, False if not, typically - * because could not allocate memory. - * Assumes Display locked when called. - */ -Status -_XRegisterInternalConnection( - Display* dpy, - int fd, - _XInternalConnectionProc callback, - XPointer call_data -) -{ - struct _XConnectionInfo *new_conni, **iptr; - struct _XConnWatchInfo *watchers; - XPointer *wd; - - new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo)); - if (!new_conni) - return 0; - new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer)); - if (!new_conni->watch_data) { - Xfree(new_conni); - return 0; - } - new_conni->fd = fd; - new_conni->read_callback = callback; - new_conni->call_data = call_data; - new_conni->next = NULL; - /* link new structure onto end of list */ - for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next) - ; - *iptr = new_conni; - dpy->im_fd_length++; - _XPollfdCacheAdd(dpy, fd); - - for (watchers=dpy->conn_watchers, wd=new_conni->watch_data; - watchers; - watchers=watchers->next, wd++) { - *wd = NULL; /* for cleanliness */ - (*watchers->fn) (dpy, watchers->client_data, fd, True, wd); - } - - return 1; -} - -/* _XUnregisterInternalConnection - * Each IM (or Xlib extension) that closes a file descriptor previously - * registered with _XRegisterInternalConnection must call this function. - * Any XConnectionWatchProc registered by XAddConnectionWatch - * will also be called. - * - * Assumes Display locked when called. - */ -void -_XUnregisterInternalConnection( - Display* dpy, - int fd -) -{ - struct _XConnectionInfo *info_list, **prev; - struct _XConnWatchInfo *watch; - XPointer *wd; - - for (prev = &dpy->im_fd_info; (info_list = *prev); - prev = &info_list->next) { - if (info_list->fd == fd) { - *prev = info_list->next; - dpy->im_fd_length--; - for (watch=dpy->conn_watchers, wd=info_list->watch_data; - watch; - watch=watch->next, wd++) { - (*watch->fn) (dpy, watch->client_data, fd, False, wd); - } - if (info_list->watch_data) - Xfree (info_list->watch_data); - Xfree (info_list); - break; - } - } - _XPollfdCacheDel(dpy, fd); -} - -/* XInternalConnectionNumbers - * Returns an array of fds and an array of corresponding call data. - * Typically a XConnectionWatchProc registered with XAddConnectionWatch - * will be used instead of this function to discover - * additional fds to include in the select/poll mask. - * - * The list is allocated with Xmalloc and should be freed by the caller - * with Xfree; - */ -Status -XInternalConnectionNumbers( - Display *dpy, - int **fd_return, - int *count_return -) -{ - int count; - struct _XConnectionInfo *info_list; - int *fd_list; - - LockDisplay(dpy); - count = 0; - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) - count++; - fd_list = (int*) Xmalloc (count * sizeof(int)); - if (!fd_list) { - UnlockDisplay(dpy); - return 0; - } - count = 0; - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - fd_list[count] = info_list->fd; - count++; - } - UnlockDisplay(dpy); - - *fd_return = fd_list; - *count_return = count; - return 1; -} - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info) -{ - dpy->flags |= XlibDisplayProcConni; -#ifdef XTHREADS - if (dpy->lock) { - /* check cache to avoid call to thread_self */ - if (xthread_have_id(dpy->lock->reading_thread)) - dpy->lock->conni_thread = dpy->lock->reading_thread; - else - dpy->lock->conni_thread = XThread_Self(); - } -#endif /* XTHREADS */ - UnlockDisplay(dpy); - (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data); - LockDisplay(dpy); -#ifdef XTHREADS - if (dpy->lock) - xthread_clear_id(dpy->lock->conni_thread); -#endif /* XTHREADS */ - dpy->flags &= ~XlibDisplayProcConni; -} - -/* XProcessInternalConnection - * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection - * for this fd. - * The Display is NOT locked during the call. - */ -void -XProcessInternalConnection( - Display* dpy, - int fd -) -{ - struct _XConnectionInfo *info_list; - - LockDisplay(dpy); - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - if (info_list->fd == fd) { - _XProcessInternalConnection(dpy, info_list); - break; - } - } - UnlockDisplay(dpy); -} - -/* XAddConnectionWatch - * Register a callback to be called whenever _XRegisterInternalConnection - * or _XUnregisterInternalConnection is called. - * Callbacks are called with the Display locked. - * If any connections are already registered, the callback is immediately - * called for each of them. - */ -Status -XAddConnectionWatch( - Display* dpy, - XConnectionWatchProc callback, - XPointer client_data -) -{ - struct _XConnWatchInfo *new_watcher, **wptr; - struct _XConnectionInfo *info_list; - XPointer *wd_array; - - LockDisplay(dpy); - - /* allocate new watch data */ - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data, - (dpy->watcher_count + 1) * - sizeof(XPointer)); - if (!wd_array) { - UnlockDisplay(dpy); - return 0; - } - wd_array[dpy->watcher_count] = NULL; /* for cleanliness */ - } - - new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo)); - if (!new_watcher) { - UnlockDisplay(dpy); - return 0; - } - new_watcher->fn = callback; - new_watcher->client_data = client_data; - new_watcher->next = NULL; - - /* link new structure onto end of list */ - for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next) - ; - *wptr = new_watcher; - dpy->watcher_count++; - - /* call new watcher on all currently registered fds */ - for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) { - (*callback) (dpy, client_data, info_list->fd, True, - info_list->watch_data + dpy->watcher_count - 1); - } - - UnlockDisplay(dpy); - return 1; -} - -/* XRemoveConnectionWatch - * Unregister a callback registered by XAddConnectionWatch. - * Both callback and client_data must match what was passed to - * XAddConnectionWatch. - */ -void -XRemoveConnectionWatch( - Display* dpy, - XConnectionWatchProc callback, - XPointer client_data -) -{ - struct _XConnWatchInfo *watch; - struct _XConnWatchInfo *previous = NULL; - struct _XConnectionInfo *conni; - int counter = 0; - - LockDisplay(dpy); - for (watch=dpy->conn_watchers; watch; watch=watch->next) { - if (watch->fn == callback && watch->client_data == client_data) { - if (previous) - previous->next = watch->next; - else - dpy->conn_watchers = watch->next; - Xfree (watch); - dpy->watcher_count--; - /* remove our watch_data for each connection */ - for (conni=dpy->im_fd_info; conni; conni=conni->next) { - /* don't bother realloc'ing; these arrays are small anyway */ - /* overlapping */ - memmove(conni->watch_data+counter, - conni->watch_data+counter+1, - dpy->watcher_count - counter); - } - break; - } - previous = watch; - counter++; - } - UnlockDisplay(dpy); -} - -/* end of internal connections support */ - - -/* Read and discard "n" 8-bit bytes of data */ - -void _XEatData( - Display *dpy, - register unsigned long n) -{ -#define SCRATCHSIZE 2048 - char buf[SCRATCHSIZE]; - - while (n > 0) { - register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n; - (void) _XRead (dpy, buf, bytes_read); - n -= bytes_read; - } -#undef SCRATCHSIZE -} - - -/* - * _XEnq - Place event packets on the display's queue. - * note that no squishing of move events in V11, since there - * is pointer motion hints.... - */ -void _XEnq( - register Display *dpy, - register xEvent *event) -{ - register _XQEvent *qelt; - - if ((qelt = dpy->qfree)) { - /* If dpy->qfree is non-NULL do this, else malloc a new one. */ - dpy->qfree = qelt->next; - } - else if ((qelt = - (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) { - /* Malloc call failed! */ - ESET(ENOMEM); - _XIOError(dpy); - } - qelt->next = NULL; - /* go call through display to find proper event reformatter */ - if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) { - qelt->qserial_num = dpy->next_event_serial_num++; - if (dpy->tail) dpy->tail->next = qelt; - else dpy->head = qelt; - - dpy->tail = qelt; - dpy->qlen++; - } else { - /* ignored, or stashed away for many-to-one compression */ - qelt->next = dpy->qfree; - dpy->qfree = qelt; - } -} - -/* - * _XDeq - Remove event packet from the display's queue. - */ -void _XDeq( - register Display *dpy, - register _XQEvent *prev, /* element before qelt */ - register _XQEvent *qelt) /* element to be unlinked */ -{ - if (prev) { - if ((prev->next = qelt->next) == NULL) - dpy->tail = prev; - } else { - /* no prev, so removing first elt */ - if ((dpy->head = qelt->next) == NULL) - dpy->tail = NULL; - } - qelt->qserial_num = 0; - qelt->next = dpy->qfree; - dpy->qfree = qelt; - dpy->qlen--; -} - -/* - * EventToWire in separate file in that often not needed. - */ - -/*ARGSUSED*/ -Bool -_XUnknownWireEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ -#ifdef notdef - (void) fprintf(stderr, - "Xlib: unhandled wire event! event number = %d, display = %x\n.", - event->u.u.type, dpy); -#endif - return(False); -} - -/*ARGSUSED*/ -Status -_XUnknownNativeEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ -#ifdef notdef - (void) fprintf(stderr, - "Xlib: unhandled native event! event number = %d, display = %x\n.", - re->type, dpy); -#endif - return(0); -} -/* - * reformat a wire event into an XEvent structure of the right type. - */ -Bool -_XWireToEvent( - register Display *dpy, /* pointer to display structure */ - register XEvent *re, /* pointer to where event should be reformatted */ - register xEvent *event) /* wire protocol event */ -{ - - re->type = event->u.u.type & 0x7f; - ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy, - (xGenericReply *)event); - ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0); - ((XAnyEvent *)re)->display = dpy; - - /* Ignore the leading bit of the event type since it is set when a - client sends an event rather than the server. */ - - switch (event-> u.u.type & 0177) { - case KeyPress: - case KeyRelease: - { - register XKeyEvent *ev = (XKeyEvent*) re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->keycode = event->u.u.detail; - } - break; - case ButtonPress: - case ButtonRelease: - { - register XButtonEvent *ev = (XButtonEvent *) re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->button = event->u.u.detail; - } - break; - case MotionNotify: - { - register XMotionEvent *ev = (XMotionEvent *)re; - ev->root = event->u.keyButtonPointer.root; - ev->window = event->u.keyButtonPointer.event; - ev->subwindow = event->u.keyButtonPointer.child; - ev->time = event->u.keyButtonPointer.time; - ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX); - ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY); - ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX); - ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY); - ev->state = event->u.keyButtonPointer.state; - ev->same_screen = event->u.keyButtonPointer.sameScreen; - ev->is_hint = event->u.u.detail; - } - break; - case EnterNotify: - case LeaveNotify: - { - register XCrossingEvent *ev = (XCrossingEvent *) re; - ev->root = event->u.enterLeave.root; - ev->window = event->u.enterLeave.event; - ev->subwindow = event->u.enterLeave.child; - ev->time = event->u.enterLeave.time; - ev->x = cvtINT16toInt(event->u.enterLeave.eventX); - ev->y = cvtINT16toInt(event->u.enterLeave.eventY); - ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX); - ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY); - ev->state = event->u.enterLeave.state; - ev->mode = event->u.enterLeave.mode; - ev->same_screen = (event->u.enterLeave.flags & - ELFlagSameScreen) && True; - ev->focus = (event->u.enterLeave.flags & - ELFlagFocus) && True; - ev->detail = event->u.u.detail; - } - break; - case FocusIn: - case FocusOut: - { - register XFocusChangeEvent *ev = (XFocusChangeEvent *) re; - ev->window = event->u.focus.window; - ev->mode = event->u.focus.mode; - ev->detail = event->u.u.detail; - } - break; - case KeymapNotify: - { - register XKeymapEvent *ev = (XKeymapEvent *) re; - ev->window = None; - memcpy(&ev->key_vector[1], - (char *)((xKeymapEvent *) event)->map, - sizeof (((xKeymapEvent *) event)->map)); - } - break; - case Expose: - { - register XExposeEvent *ev = (XExposeEvent *) re; - ev->window = event->u.expose.window; - ev->x = event->u.expose.x; - ev->y = event->u.expose.y; - ev->width = event->u.expose.width; - ev->height = event->u.expose.height; - ev->count = event->u.expose.count; - } - break; - case GraphicsExpose: - { - register XGraphicsExposeEvent *ev = - (XGraphicsExposeEvent *) re; - ev->drawable = event->u.graphicsExposure.drawable; - ev->x = event->u.graphicsExposure.x; - ev->y = event->u.graphicsExposure.y; - ev->width = event->u.graphicsExposure.width; - ev->height = event->u.graphicsExposure.height; - ev->count = event->u.graphicsExposure.count; - ev->major_code = event->u.graphicsExposure.majorEvent; - ev->minor_code = event->u.graphicsExposure.minorEvent; - } - break; - case NoExpose: - { - register XNoExposeEvent *ev = (XNoExposeEvent *) re; - ev->drawable = event->u.noExposure.drawable; - ev->major_code = event->u.noExposure.majorEvent; - ev->minor_code = event->u.noExposure.minorEvent; - } - break; - case VisibilityNotify: - { - register XVisibilityEvent *ev = (XVisibilityEvent *) re; - ev->window = event->u.visibility.window; - ev->state = event->u.visibility.state; - } - break; - case CreateNotify: - { - register XCreateWindowEvent *ev = - (XCreateWindowEvent *) re; - ev->window = event->u.createNotify.window; - ev->parent = event->u.createNotify.parent; - ev->x = cvtINT16toInt(event->u.createNotify.x); - ev->y = cvtINT16toInt(event->u.createNotify.y); - ev->width = event->u.createNotify.width; - ev->height = event->u.createNotify.height; - ev->border_width = event->u.createNotify.borderWidth; - ev->override_redirect = event->u.createNotify.override; - } - break; - case DestroyNotify: - { - register XDestroyWindowEvent *ev = - (XDestroyWindowEvent *) re; - ev->window = event->u.destroyNotify.window; - ev->event = event->u.destroyNotify.event; - } - break; - case UnmapNotify: - { - register XUnmapEvent *ev = (XUnmapEvent *) re; - ev->window = event->u.unmapNotify.window; - ev->event = event->u.unmapNotify.event; - ev->from_configure = event->u.unmapNotify.fromConfigure; - } - break; - case MapNotify: - { - register XMapEvent *ev = (XMapEvent *) re; - ev->window = event->u.mapNotify.window; - ev->event = event->u.mapNotify.event; - ev->override_redirect = event->u.mapNotify.override; - } - break; - case MapRequest: - { - register XMapRequestEvent *ev = (XMapRequestEvent *) re; - ev->window = event->u.mapRequest.window; - ev->parent = event->u.mapRequest.parent; - } - break; - case ReparentNotify: - { - register XReparentEvent *ev = (XReparentEvent *) re; - ev->event = event->u.reparent.event; - ev->window = event->u.reparent.window; - ev->parent = event->u.reparent.parent; - ev->x = cvtINT16toInt(event->u.reparent.x); - ev->y = cvtINT16toInt(event->u.reparent.y); - ev->override_redirect = event->u.reparent.override; - } - break; - case ConfigureNotify: - { - register XConfigureEvent *ev = (XConfigureEvent *) re; - ev->event = event->u.configureNotify.event; - ev->window = event->u.configureNotify.window; - ev->above = event->u.configureNotify.aboveSibling; - ev->x = cvtINT16toInt(event->u.configureNotify.x); - ev->y = cvtINT16toInt(event->u.configureNotify.y); - ev->width = event->u.configureNotify.width; - ev->height = event->u.configureNotify.height; - ev->border_width = event->u.configureNotify.borderWidth; - ev->override_redirect = event->u.configureNotify.override; - } - break; - case ConfigureRequest: - { - register XConfigureRequestEvent *ev = - (XConfigureRequestEvent *) re; - ev->window = event->u.configureRequest.window; - ev->parent = event->u.configureRequest.parent; - ev->above = event->u.configureRequest.sibling; - ev->x = cvtINT16toInt(event->u.configureRequest.x); - ev->y = cvtINT16toInt(event->u.configureRequest.y); - ev->width = event->u.configureRequest.width; - ev->height = event->u.configureRequest.height; - ev->border_width = event->u.configureRequest.borderWidth; - ev->value_mask = event->u.configureRequest.valueMask; - ev->detail = event->u.u.detail; - } - break; - case GravityNotify: - { - register XGravityEvent *ev = (XGravityEvent *) re; - ev->window = event->u.gravity.window; - ev->event = event->u.gravity.event; - ev->x = cvtINT16toInt(event->u.gravity.x); - ev->y = cvtINT16toInt(event->u.gravity.y); - } - break; - case ResizeRequest: - { - register XResizeRequestEvent *ev = - (XResizeRequestEvent *) re; - ev->window = event->u.resizeRequest.window; - ev->width = event->u.resizeRequest.width; - ev->height = event->u.resizeRequest.height; - } - break; - case CirculateNotify: - { - register XCirculateEvent *ev = (XCirculateEvent *) re; - ev->window = event->u.circulate.window; - ev->event = event->u.circulate.event; - ev->place = event->u.circulate.place; - } - break; - case CirculateRequest: - { - register XCirculateRequestEvent *ev = - (XCirculateRequestEvent *) re; - ev->window = event->u.circulate.window; - ev->parent = event->u.circulate.event; - ev->place = event->u.circulate.place; - } - break; - case PropertyNotify: - { - register XPropertyEvent *ev = (XPropertyEvent *) re; - ev->window = event->u.property.window; - ev->atom = event->u.property.atom; - ev->time = event->u.property.time; - ev->state = event->u.property.state; - } - break; - case SelectionClear: - { - register XSelectionClearEvent *ev = - (XSelectionClearEvent *) re; - ev->window = event->u.selectionClear.window; - ev->selection = event->u.selectionClear.atom; - ev->time = event->u.selectionClear.time; - } - break; - case SelectionRequest: - { - register XSelectionRequestEvent *ev = - (XSelectionRequestEvent *) re; - ev->owner = event->u.selectionRequest.owner; - ev->requestor = event->u.selectionRequest.requestor; - ev->selection = event->u.selectionRequest.selection; - ev->target = event->u.selectionRequest.target; - ev->property = event->u.selectionRequest.property; - ev->time = event->u.selectionRequest.time; - } - break; - case SelectionNotify: - { - register XSelectionEvent *ev = (XSelectionEvent *) re; - ev->requestor = event->u.selectionNotify.requestor; - ev->selection = event->u.selectionNotify.selection; - ev->target = event->u.selectionNotify.target; - ev->property = event->u.selectionNotify.property; - ev->time = event->u.selectionNotify.time; - } - break; - case ColormapNotify: - { - register XColormapEvent *ev = (XColormapEvent *) re; - ev->window = event->u.colormap.window; - ev->colormap = event->u.colormap.colormap; - ev->new = event->u.colormap.new; - ev->state = event->u.colormap.state; - } - break; - case ClientMessage: - { - register int i; - register XClientMessageEvent *ev - = (XClientMessageEvent *) re; - ev->window = event->u.clientMessage.window; - ev->format = event->u.u.detail; - switch (ev->format) { - case 8: - ev->message_type = event->u.clientMessage.u.b.type; - for (i = 0; i < 20; i++) - ev->data.b[i] = event->u.clientMessage.u.b.bytes[i]; - break; - case 16: - ev->message_type = event->u.clientMessage.u.s.type; - ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0); - ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1); - ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2); - ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3); - ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4); - ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5); - ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6); - ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7); - ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8); - ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9); - break; - case 32: - ev->message_type = event->u.clientMessage.u.l.type; - ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0); - ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1); - ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2); - ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3); - ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4); - break; - default: /* XXX should never occur */ - break; - } - } - break; - case MappingNotify: - { - register XMappingEvent *ev = (XMappingEvent *)re; - ev->window = 0; - ev->first_keycode = event->u.mappingNotify.firstKeyCode; - ev->request = event->u.mappingNotify.request; - ev->count = event->u.mappingNotify.count; - } - break; - default: - return(_XUnknownWireEvent(dpy, re, event)); - } - return(True); -} - - -/* - * _XDefaultIOError - Default fatal system error reporting routine. Called - * when an X internal system error is encountered. - */ -int _XDefaultIOError( - Display *dpy) -{ - if (ECHECK(EPIPE)) { - (void) fprintf (stderr, - "X connection to %s broken (explicit kill or server shutdown).\r\n", - DisplayString (dpy)); - } else { - (void) fprintf (stderr, - "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n", -#ifdef WIN32 - WSAGetLastError(), strerror(WSAGetLastError()), -#else - errno, strerror (errno), -#endif - DisplayString (dpy)); - (void) fprintf (stderr, - " after %lu requests (%lu known processed) with %d events remaining.\r\n", - NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy), - QLength(dpy)); - - } - exit(1); - return(0); /* dummy - function should never return */ -} - - -static int _XPrintDefaultError( - Display *dpy, - XErrorEvent *event, - FILE *fp) -{ - char buffer[BUFSIZ]; - char mesg[BUFSIZ]; - char number[32]; - char *mtype = "XlibMessage"; - register _XExtension *ext = (_XExtension *)NULL; - _XExtension *bext = (_XExtension *)NULL; - XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); - XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); - (void) fprintf(fp, "%s: %s\n ", mesg, buffer); - XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", - mesg, BUFSIZ); - (void) fprintf(fp, mesg, event->request_code); - if (event->request_code < 128) { - sprintf(number, "%d", event->request_code); - XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); - } else { - for (ext = dpy->ext_procs; - ext && (ext->codes.major_opcode != event->request_code); - ext = ext->next) - ; - if (ext) - strcpy(buffer, ext->name); - else - buffer[0] = '\0'; - } - (void) fprintf(fp, " (%s)\n", buffer); - if (event->request_code >= 128) { - XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->minor_code); - if (ext) { - sprintf(mesg, "%s.%d", ext->name, event->minor_code); - XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); - (void) fprintf(fp, " (%s)", buffer); - } - fputs("\n", fp); - } - if (event->error_code >= 128) { - /* kludge, try to find the extension that caused it */ - buffer[0] = '\0'; - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_string) - (*ext->error_string)(dpy, event->error_code, &ext->codes, - buffer, BUFSIZ); - if (buffer[0]) { - bext = ext; - break; - } - if (ext->codes.first_error && - ext->codes.first_error < (int)event->error_code && - (!bext || ext->codes.first_error > bext->codes.first_error)) - bext = ext; - } - if (bext) - sprintf(buffer, "%s.%d", bext->name, - event->error_code - bext->codes.first_error); - else - strcpy(buffer, "Value"); - XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ); - if (mesg[0]) { - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - /* let extensions try to print the values */ - for (ext = dpy->ext_procs; ext; ext = ext->next) { - if (ext->error_values) - (*ext->error_values)(dpy, event, fp); - } - } else if ((event->error_code == BadWindow) || - (event->error_code == BadPixmap) || - (event->error_code == BadCursor) || - (event->error_code == BadFont) || - (event->error_code == BadDrawable) || - (event->error_code == BadColor) || - (event->error_code == BadGC) || - (event->error_code == BadIDChoice) || - (event->error_code == BadValue) || - (event->error_code == BadAtom)) { - if (event->error_code == BadValue) - XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", - mesg, BUFSIZ); - else if (event->error_code == BadAtom) - XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", - mesg, BUFSIZ); - else - XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->resourceid); - fputs("\n", fp); - } - XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", - mesg, BUFSIZ); - fputs(" ", fp); - (void) fprintf(fp, mesg, event->serial); - XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", - mesg, BUFSIZ); - fputs("\n ", fp); - (void) fprintf(fp, mesg, dpy->request); - fputs("\n", fp); - if (event->error_code == BadImplementation) return 0; - return 1; -} - -int _XDefaultError( - Display *dpy, - XErrorEvent *event) -{ - if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0; - exit(1); - /*NOTREACHED*/ -} - -/*ARGSUSED*/ -Bool _XDefaultWireError(display, he, we) - Display *display; - XErrorEvent *he; - xError *we; -{ - return True; -} - -/* - * _XError - upcall internal or user protocol error handler - */ -int _XError ( - Display *dpy, - register xError *rep) -{ - /* - * X_Error packet encountered! We need to unpack the error before - * giving it to the user. - */ - XEvent event; /* make it a large event */ - register _XAsyncHandler *async, *next; - - event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep); - - for (async = dpy->async_handlers; async; async = next) { - next = async->next; - if ((*async->handler)(dpy, (xReply *)rep, - (char *)rep, SIZEOF(xError), async->data)) - return 0; - } - - event.xerror.display = dpy; - event.xerror.type = X_Error; - event.xerror.resourceid = rep->resourceID; - event.xerror.error_code = rep->errorCode; - event.xerror.request_code = rep->majorCode; - event.xerror.minor_code = rep->minorCode; - if (dpy->error_vec && - !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep)) - return 0; - if (_XErrorFunction != NULL) { - int rtn_val; -#ifdef XTHREADS - if (dpy->lock) - (*dpy->lock->user_lock_display)(dpy); - UnlockDisplay(dpy); -#endif /* XTHREADS */ - rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */ -#ifdef XTHREADS - LockDisplay(dpy); - if (dpy->lock) - (*dpy->lock->user_unlock_display)(dpy); -#endif /* XTHREADS */ - return rtn_val; - } else { - return _XDefaultError(dpy, (XErrorEvent *)&event); - } -} - -/* - * _XIOError - call user connection error handler and exit - */ -int -_XIOError ( - Display *dpy) -{ - dpy->flags |= XlibDisplayIOError; -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - - if (_XIOErrorFunction != NULL) - (*_XIOErrorFunction)(dpy); - else - _XDefaultIOError(dpy); - exit (1); - return 0; -} - - -/* - * This routine can be used to (cheaply) get some memory within a single - * Xlib routine for scratch space. A single buffer is reused each time - * if possible. To be MT safe, you can only call this between a call to - * GetReq* and a call to Data* or _XSend*, or in a context when the thread - * is guaranteed to not unlock the display. - */ -char *_XAllocScratch( - register Display *dpy, - unsigned long nbytes) -{ - if (nbytes > dpy->scratch_length) { - if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer); - if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes))) - dpy->scratch_length = nbytes; - else dpy->scratch_length = 0; - } - return (dpy->scratch_buffer); -} - -/* - * Scratch space allocator you can call any time, multiple times, and be - * MT safe, but you must hand the buffer back with _XFreeTemp. - */ -char *_XAllocTemp( - register Display *dpy, - unsigned long nbytes) -{ - char *buf; - - buf = _XAllocScratch(dpy, nbytes); - dpy->scratch_buffer = NULL; - dpy->scratch_length = 0; - return buf; -} - -void _XFreeTemp( - register Display *dpy, - char *buf, - unsigned long nbytes) -{ - if (dpy->scratch_buffer) - Xfree(dpy->scratch_buffer); - dpy->scratch_buffer = buf; - dpy->scratch_length = nbytes; -} - -/* - * Given a visual id, find the visual structure for this id on this display. - */ -Visual *_XVIDtoVisual( - Display *dpy, - VisualID id) -{ - register int i, j, k; - register Screen *sp; - register Depth *dp; - register Visual *vp; - for (i = 0; i < dpy->nscreens; i++) { - sp = &dpy->screens[i]; - for (j = 0; j < sp->ndepths; j++) { - dp = &sp->depths[j]; - /* if nvisuals == 0 then visuals will be NULL */ - for (k = 0; k < dp->nvisuals; k++) { - vp = &dp->visuals[k]; - if (vp->visualid == id) return (vp); - } - } - } - return (NULL); -} - -int -XFree (void *data) -{ - Xfree (data); - return 1; -} - -#ifdef _XNEEDBCOPYFUNC -void _Xbcopy(b1, b2, length) - register char *b1, *b2; - register length; -{ - if (b1 < b2) { - b2 += length; - b1 += length; - while (length--) - *--b2 = *--b1; - } else { - while (length--) - *b2++ = *b1++; - } -} -#endif - -#ifdef DataRoutineIsProcedure -void Data( - Display *dpy, - char *data, - long len) -{ - if (dpy->bufptr + (len) <= dpy->bufmax) { - memcpy(dpy->bufptr, data, (int)len); - dpy->bufptr += ((len) + 3) & ~3; - } else { - _XSend(dpy, data, len); - } -} -#endif /* DataRoutineIsProcedure */ - - -#ifdef LONG64 -int -_XData32( - Display *dpy, - register long *data, - unsigned len) -{ - register int *buf; - register long i; - - while (len) { - buf = (int *)dpy->bufptr; - i = dpy->bufmax - (char *)buf; - if (!i) { - _XFlush(dpy); - continue; - } - if (len < i) - i = len; - dpy->bufptr = (char *)buf + i; - len -= i; - i >>= 2; - while (--i >= 0) - *buf++ = *data++; - } - return 0; -} -#endif /* LONG64 */ - -#ifdef WORD64 - -/* - * XXX This is a *really* stupid way of doing this. It should just use - * dpy->bufptr directly, taking into account where in the word it is. - */ - -/* - * Data16 - Place 16 bit data in the buffer. - * - * "dpy" is a pointer to a Display. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static doData16( - register Display *dpy, - short *data, - unsigned len, - char *packbuffer) -{ - long *lp,*lpack; - long i, nwords,bits; - long mask16 = 0x000000000000ffff; - - lp = (long *)data; - lpack = (long *)packbuffer; - -/* nwords is the number of 16 bit values to be packed, - * the low order 16 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 1; - bits = 48; - - for(i=0;i<nwords;i++){ - if (bits == 48) *lpack = 0; - *lpack ^= (*lp & mask16) << bits; - bits -= 16 ; - lp++; - if(bits < 0){ - lpack++; - bits = 48; - } - } - Data(dpy, packbuffer, len); -} - -_XData16 ( - Display *dpy, - short *data, - unsigned len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 1; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - doData16 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) doData16 (dpy, data, len, packbuffer); -} - -/* - * Data32 - Place 32 bit data in the buffer. - * - * "dpy" is a pointer to a Display. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static doData32( - register Display *dpy - long *data, - unsigned len, - char *packbuffer) -{ - long *lp,*lpack; - long i,bits,nwords; - long mask32 = 0x00000000ffffffff; - - lpack = (long *) packbuffer; - lp = data; - -/* nwords is the number of 32 bit values to be packed - * the low order 32 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 2; - bits = 32; - - for(i=0;i<nwords;i++){ - if (bits == 32) *lpack = 0; - *lpack ^= (*lp & mask32) << bits; - bits = bits ^32; - lp++; - if(bits) - lpack++; - } - Data(dpy, packbuffer, len); -} - -void _XData32( - Display *dpy, - long *data, - unsigned len, -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nunits = PACKBUFFERSIZE >> 2; - - for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) { - doData32 (dpy, data, PACKBUFFERSIZE, packbuffer); - } - if (len) doData32 (dpy, data, len, packbuffer); -} - -#endif /* WORD64 */ - - -/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm. - * Otherwise, Xau will not be able to find your cookies in the Xauthority file. - * - * Note: POSIX says that the ``nodename'' member of utsname does _not_ have - * to have sufficient information for interfacing to the network, - * and so, you may be better off using gethostname (if it exists). - */ - -#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) -#define NEED_UTSNAME -#include <sys/utsname.h> -#endif - -/* - * _XGetHostname - similar to gethostname but allows special processing. - */ -int _XGetHostname ( - char *buf, - int maxlen) -{ - int len; - -#ifdef NEED_UTSNAME - struct utsname name; - - if (maxlen <= 0 || buf == NULL) - return 0; - - uname (&name); - len = strlen (name.nodename); - if (len >= maxlen) len = maxlen - 1; - strncpy (buf, name.nodename, len); - buf[len] = '\0'; -#else - if (maxlen <= 0 || buf == NULL) - return 0; - - buf[0] = '\0'; - (void) gethostname (buf, maxlen); - buf [maxlen - 1] = '\0'; - len = strlen(buf); -#endif /* NEED_UTSNAME */ - return len; -} - - -/* - * _XScreenOfWindow - get the Screen of a given window - */ - -Screen *_XScreenOfWindow (dpy, w) - Display *dpy; - Window w; -{ - register int i; - Window root; - int x, y; /* dummy variables */ - unsigned int width, height, bw, depth; /* dummy variables */ - - if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height, - &bw, &depth) == False) { - return None; - } - for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */ - if (root == RootWindow (dpy, i)) { - return ScreenOfDisplay (dpy, i); - } - } - return NULL; -} - - -#if defined(WIN32) - -/* - * These functions are intended to be used internally to Xlib only. - * These functions will always prefix the path with a DOS drive in the - * form "<drive-letter>:". As such, these functions are only suitable - * for use by Xlib function that supply a root-based path to some - * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will - * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir". - */ - -static int access_file (path, pathbuf, len_pathbuf, pathret) - char* path; - char* pathbuf; - int len_pathbuf; - char** pathret; -{ - if (access (path, F_OK) == 0) { - if (strlen (path) < len_pathbuf) - *pathret = pathbuf; - else - *pathret = Xmalloc (strlen (path) + 1); - if (*pathret) { - strcpy (*pathret, path); - return 1; - } - } - return 0; -} - -static int AccessFile (path, pathbuf, len_pathbuf, pathret) - char* path; - char* pathbuf; - int len_pathbuf; - char** pathret; -{ - unsigned long drives; - int i, len; - char* drive; - char buf[MAX_PATH]; - char* bufp; - - /* just try the "raw" name first and see if it works */ - if (access_file (path, pathbuf, len_pathbuf, pathret)) - return 1; - - /* try the places set in the environment */ - drive = getenv ("_XBASEDRIVE"); -#ifdef __UNIXOS2__ - if (!drive) - drive = getenv ("X11ROOT"); -#endif - if (!drive) - drive = "C:"; - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - -#ifndef __UNIXOS2__ - /* one last place to look */ - drive = getenv ("HOMEDRIVE"); - if (drive) { - len = strlen (drive) + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - strcpy (bufp, drive); - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - } - - /* tried everywhere else, go fishing */ -#define C_DRIVE ('C' - 'A') -#define Z_DRIVE ('Z' - 'A') - /* does OS/2 (with or with gcc-emx) have getdrives? */ - drives = _getdrives (); - for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */ - if ((1 << i) & drives) { - len = 2 + strlen (path); - if (len < MAX_PATH) bufp = buf; - else bufp = Xmalloc (len + 1); - *bufp = 'A' + i; - *(bufp + 1) = ':'; - *(bufp + 2) = '\0'; - strcat (bufp, path); - if (access_file (bufp, pathbuf, len_pathbuf, pathret)) { - if (bufp != buf) Xfree (bufp); - return 1; - } - } - } -#endif - return 0; -} - -int _XOpenFile(path, flags) - _Xconst char* path; - int flags; -{ - char buf[MAX_PATH]; - char* bufp = NULL; - int ret = -1; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - if (AccessFile (path, buf, MAX_PATH, &bufp)) - ret = open (bufp, flags); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -void* _XFopenFile(path, mode) - _Xconst char* path; - _Xconst char* mode; -{ - char buf[MAX_PATH]; - char* bufp = NULL; - void* ret = NULL; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - if (AccessFile (path, buf, MAX_PATH, &bufp)) - ret = fopen (bufp, mode); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -int _XAccessFile(path) - _Xconst char* path; -{ - char buf[MAX_PATH]; - char* bufp; - int ret = -1; - UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS); - - ret = AccessFile (path, buf, MAX_PATH, &bufp); - - (void) SetErrorMode (olderror); - - if (bufp != buf) Xfree (bufp); - - return ret; -} - -#endif - -#ifdef WIN32 -#undef _Xdebug -int _Xdebug = 0; -int *_Xdebug_p = &_Xdebug; -void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn; -void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn; -void (**_XLockMutex_fn_p)(LockInfoPtr -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = &_XLockMutex_fn; -void (**_XUnlockMutex_fn_p)(LockInfoPtr -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif - ) = &_XUnlockMutex_fn; -LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock; -#endif diff --git a/nx-X11/lib/X11/Xlibint.h.NX.original b/nx-X11/lib/X11/Xlibint.h.NX.original deleted file mode 100644 index 56da2349b..000000000 --- a/nx-X11/lib/X11/Xlibint.h.NX.original +++ /dev/null @@ -1,1346 +0,0 @@ -/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */ - -/* - -Copyright 1984, 1985, 1987, 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */ - -#ifndef _XLIBINT_H_ -#define _XLIBINT_H_ 1 - -/* - * Xlibint.h - Header definition and support file for the internal - * support routines used by the C subroutine interface - * library (Xlib) to the X Window System. - * - * Warning, there be dragons here.... - */ - -#include <X11/Xlib.h> -#include <X11/Xproto.h> /* to declare xEvent */ -#include <X11/XlibConf.h> /* for configured options like XTHREADS */ - -#ifdef NX_TRANS_SOCKET - -#include "NXvars.h" - -#define _XGetIOError(dpy) \ - (dpy -> flags & XlibDisplayIOError) - -#endif - -#ifdef WIN32 -#define _XFlush _XFlushIt -#endif - -/* - * If your BytesReadable correctly detects broken connections, then - * you should NOT define XCONN_CHECK_FREQ. - */ -#ifndef XCONN_CHECK_FREQ -#define XCONN_CHECK_FREQ 256 -#endif - -struct _XGC -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - Bool rects; /* boolean: TRUE if clipmask is list of rectangles */ - Bool dashes; /* boolean: TRUE if dash-list is really a list */ - unsigned long dirty;/* cache dirty bits */ - XGCValues values; /* shadow structure of values */ -}; - -struct _XDisplay -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XFreeFuncs *free_funcs; /* internal free functions */ - int fd; /* Network socket. */ - int conn_checker; /* ugly thing used by _XEventsQueued */ - int proto_major_version;/* maj. version of server's X protocol */ - int proto_minor_version;/* minor version of server's X protocol */ - char *vendor; /* vendor of the server hardware */ - XID resource_base; /* resource ID base */ - XID resource_mask; /* resource ID mask bits */ - XID resource_id; /* allocator current ID */ - int resource_shift; /* allocator shift to correct bits */ - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int vnumber; /* Xlib's X protocol version number. */ - int release; /* release of the server */ - struct _XSQEvent *head, *tail; /* Input event queue. */ - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - char *last_req; /* beginning of last request, or dummy */ - char *buffer; /* Output buffer starting address. */ - char *bufptr; /* Output buffer index pointer. */ - char *bufmax; /* Output buffer maximum+1 address. */ - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*synchandler)( /* Synchronization handler */ - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long flags; /* internal connection flags */ - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - KeySym *keysyms; /* This server's keysyms */ - XModifierKeymap *modifiermap; /* This server's modifier keymap */ - int keysyms_per_keycode;/* number of rows */ - char *xdefaults; /* contents of defaults from server */ - char *scratch_buffer; /* place to hang scratch buffer */ - unsigned long scratch_length; /* length of scratch buffer */ - int ext_number; /* extension number on this display */ - struct _XExten *ext_procs; /* extensions initialized on this display */ - /* - * the following can be fixed size, as the protocol defines how - * much address space is available. - * While this could be done using the extension vector, there - * may be MANY events processed, so a search through the extension - * list to find the right procedure for each event might be - * expensive if many extensions are being used. - */ - Bool (*event_vec[128])( /* vector for wire to event */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - Status (*wire_vec[128])( /* vector for event to wire */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - KeySym lock_meaning; /* for XLookupString */ - struct _XLockInfo *lock; /* multi-thread state, display lock */ - struct _XInternalAsync *async_handlers; /* for internal async */ - unsigned long bigreq_size; /* max size of big requests */ - struct _XLockPtrs *lock_fns; /* pointers to threads functions */ - void (*idlist_alloc)( /* XID list allocator function */ - Display * /* dpy */, - XID * /* ids */, - int /* count */ - ); - /* things above this line should not move, for binary compatibility */ - struct _XKeytrans *key_bindings; /* for XLookupString */ - Font cursor_font; /* for XCreateFontCursor */ - struct _XDisplayAtoms *atoms; /* for XInternAtom */ - unsigned int mode_switch; /* keyboard group modifiers */ - unsigned int num_lock; /* keyboard numlock modifiers */ - struct _XContextDB *context_db; /* context database */ - Bool (**error_vec)( /* vector for wire to error */ - Display * /* display */, - XErrorEvent * /* he */, - xError * /* we */ - ); - /* - * Xcms information - */ - struct { - XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */ - XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */ - XPointer perVisualIntensityMaps; - /* linked list of XcmsIntensityMap */ - } cms; - struct _XIMFilter *im_filters; - struct _XSQEvent *qfree; /* unallocated event queue elements */ - unsigned long next_event_serial_num; /* inserted into next queue elt */ - struct _XExten *flushes; /* Flush hooks */ - struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */ - int im_fd_length; /* number of im_fd_info */ - struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */ - int watcher_count; /* number of conn_watchers */ - XPointer filedes; /* struct pollfd cache for _XWaitForReadable */ - int (*savedsynchandler)( /* user synchandler when Xlib usurps */ - Display * /* dpy */ - ); - XID resource_max; /* allocator max ID */ - int xcmisc_opcode; /* major opcode for XC-MISC */ - struct _XkbInfoRec *xkb_info; /* XKB info */ - struct _XtransConnInfo *trans_conn; /* transport connection object */ -}; - -#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n) - -/* - * define the following if you want the Data macro to be a procedure instead - */ -#ifdef CRAY -#define DataRoutineIsProcedure -#endif /* CRAY */ - -#ifndef _XEVENT_ -/* - * _QEvent datatype for use in input queueing. - */ -typedef struct _XSQEvent -{ - struct _XSQEvent *next; - XEvent event; - unsigned long qserial_num; /* so multi-threaded code can find new ones */ -} _XQEvent; -#endif - -#ifdef XTHREADS /* for xReply */ -#define NEED_REPLIES -#endif - -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#ifdef __sgi -#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */ -#endif -#include <errno.h> -#define _XBCOPYFUNC _Xbcopy -#include <X11/Xfuncs.h> -#include <X11/Xosdefs.h> - -/* Utek leaves kernel macros around in include files (bleah) */ -#ifdef dirty -#undef dirty -#endif - -#include <stdlib.h> -#include <string.h> - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -/* - * The following definitions can be used for locking requests in multi-threaded - * address spaces. - */ -#ifdef XTHREADS -/* Author: Stephen Gildea, MIT X Consortium - * - * declarations for C Threads locking - */ - -typedef struct _LockInfoRec *LockInfoPtr; - -/* interfaces for locking.c */ -struct _XLockPtrs { - /* used by all, including extensions; do not move */ - void (*lock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); - void (*unlock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); -}; - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _XCreateMutex_fn (*_XCreateMutex_fn_p) -#define _XFreeMutex_fn (*_XFreeMutex_fn_p) -#define _XLockMutex_fn (*_XLockMutex_fn_p) -#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p) -#define _Xglobal_lock (*_Xglobal_lock_p) -#endif - -/* in XlibInt.c */ -extern void (*_XCreateMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XFreeMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); -extern void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); - -extern LockInfoPtr _Xglobal_lock; - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__) -#else -/* used everywhere, so must be fast if not using threads */ -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock) -#endif -#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock); -#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock); - -#else /* XTHREADS */ -#define LockDisplay(dis) -#define _XLockMutex(lock) -#define _XUnlockMutex(lock) -#define UnlockDisplay(dis) -#define _XCreateMutex(lock) -#define _XFreeMutex(lock) -#endif - -#define Xfree(ptr) free((ptr)) - -/* - * Note that some machines do not return a valid pointer for malloc(0), in - * which case we provide an alternate under the control of the - * define MALLOC_0_RETURNS_NULL. This is necessary because some - * Xlib code expects malloc(0) to return a valid pointer to storage. - */ -#ifdef MALLOC_0_RETURNS_NULL - -# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size))) -# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size))) -# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize)) - -#else - -# define Xmalloc(size) malloc((size)) -# define Xrealloc(ptr, size) realloc((ptr), (size)) -# define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) - -#endif - -#include <stddef.h> - -#define LOCKED 1 -#define UNLOCKED 0 - -#ifdef NX_TRANS_SOCKET -#ifndef BUFSIZE /* Output buffer size is configurable */ -#define BUFSIZE 8192 /* but this is still used for reading. */ -#endif -#else -#ifndef BUFSIZE -#define BUFSIZE 2048 /* X output buffer size. */ -#endif -#endif -#ifndef PTSPERBATCH -#define PTSPERBATCH 1024 /* point batching */ -#endif -#ifndef WLNSPERBATCH -#define WLNSPERBATCH 50 /* wide line batching */ -#endif -#ifndef ZLNSPERBATCH -#define ZLNSPERBATCH 1024 /* thin line batching */ -#endif -#ifndef WRCTSPERBATCH -#define WRCTSPERBATCH 10 /* wide line rectangle batching */ -#endif -#ifndef ZRCTSPERBATCH -#define ZRCTSPERBATCH 256 /* thin line rectangle batching */ -#endif -#ifndef FRCTSPERBATCH -#define FRCTSPERBATCH 256 /* filled rectangle batching */ -#endif -#ifndef FARCSPERBATCH -#define FARCSPERBATCH 256 /* filled arc batching */ -#endif -#ifndef CURSORFONT -#define CURSORFONT "cursor" /* standard cursor fonts */ -#endif - -/* - * Display flags - */ -#define XlibDisplayIOError (1L << 0) -#define XlibDisplayClosing (1L << 1) -#define XlibDisplayNoXkb (1L << 2) -#define XlibDisplayPrivSync (1L << 3) -#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */ -#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */ -#define XlibDisplayReply (1L << 5) /* in _XReply */ -#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */ -#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */ - -/* - * X Protocol packetizing macros. - */ - -/* Need to start requests on 64 bit word boundaries - * on a CRAY computer so add a NoOp (127) if needed. - * A character pointer on a CRAY computer will be non-zero - * after shifting right 61 bits of it is not pointing to - * a word boundary. - */ -#ifdef WORD64 -#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\ - dpy->last_req = dpy->bufptr;\ - *(dpy->bufptr) = X_NoOperation;\ - *(dpy->bufptr+1) = 0;\ - *(dpy->bufptr+2) = 0;\ - *(dpy->bufptr+3) = 1;\ - dpy->request++;\ - dpy->bufptr += 4;\ - } -#else /* else does not require alignment on 64-bit boundaries */ -#define WORD64ALIGN -#endif /* WORD64 */ - - -/* - * GetReq - Get the next available X request packet in the buffer and - * return it. - * - * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc. - * "req" is the name of the request pointer. - * - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req))>>2;\ - dpy->bufptr += SIZEOF(x##name##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req))>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req);\ - dpy->request++ -#endif - -/* GetReqExtra is the same as GetReq, but allocates "n" additional - bytes after the request. "n" must be a multiple of 4! */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x##name##Req) + n;\ - dpy->request++ -#else -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\ - dpy->request++ -#endif - - -/* - * GetResReq is for those requests that have a resource ID - * (Window, Pixmap, GContext, etc.) as their single argument. - * "rid" is the name of the resource. - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#else -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#endif - -/* - * GetEmptyReq is for those requests that have no arguments - * at all. - */ -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#else -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#endif - -#ifdef WORD64 -#define MakeBigReq(req,n) \ - { \ - char _BRdat[4]; \ - unsigned long _BRlen = req->length - 1; \ - req->length = 0; \ - memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - memcpy(((char *)req) + 4, _BRdat, 4); \ - Data32(dpy, (long *)&_BRdat, 4); \ - } -#else -#ifdef LONG64 -#define MakeBigReq(req,n) \ - { \ - CARD64 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#else -#define MakeBigReq(req,n) \ - { \ - CARD32 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#endif -#endif - -#define SetReqLen(req,n,badlen) \ - if ((req->length + n) > (unsigned)65535) { \ - if (dpy->bigreq_size) { \ - MakeBigReq(req,n) \ - } else { \ - n = badlen; \ - req->length += n; \ - } \ - } else \ - req->length += n - -#define SyncHandle() \ - if (dpy->synchandler) (*dpy->synchandler)(dpy) - -extern void _XFlushGCCache(Display *dpy, GC gc); -#define FlushGC(dpy, gc) \ - if ((gc)->dirty) _XFlushGCCache((dpy), (gc)) -/* - * Data - Place data in the buffer and pad the end to provide - * 32 bit word alignment. Transmit if the buffer fills. - * - * "dpy" is a pointer to a Display. - * "data" is a pinter to a data buffer. - * "len" is the length of the data buffer. - */ -#ifndef DataRoutineIsProcedure -#define Data(dpy, data, len) {\ - if (dpy->bufptr + (len) <= dpy->bufmax) {\ - memcpy(dpy->bufptr, data, (int)len);\ - dpy->bufptr += ((len) + 3) & ~3;\ - } else\ - _XSend(dpy, data, len);\ - } -#endif /* DataRoutineIsProcedure */ - - -/* Allocate bytes from the buffer. No padding is done, so if - * the length is not a multiple of 4, the caller must be - * careful to leave the buffer aligned after sending the - * current request. - * - * "type" is the type of the pointer being assigned to. - * "ptr" is the pointer being assigned to. - * "n" is the number of bytes to allocate. - * - * Example: - * xTextElt *elt; - * BufAlloc (xTextElt *, elt, nbytes) - */ - -#define BufAlloc(type, ptr, n) \ - if (dpy->bufptr + (n) > dpy->bufmax) \ - _XFlush (dpy); \ - ptr = (type) dpy->bufptr; \ - (void)ptr; \ - dpy->bufptr += (n); - -#ifdef WORD64 -#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len) -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -#else -#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len)) -#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#ifdef LONG64 -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -extern int _XData32( - Display *dpy, - register long *data, - unsigned len -); -extern void _XRead32( - Display *dpy, - register long *data, - long len -); -#else -#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#endif -#endif /* not WORD64 */ - -#define PackData16(dpy,data,len) Data16 (dpy, data, len) -#define PackData32(dpy,data,len) Data32 (dpy, data, len) - -/* Xlib manual is bogus */ -#define PackData(dpy,data,len) PackData16 (dpy, data, len) - -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) - -#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ - (((cs)->rbearing|(cs)->lbearing| \ - (cs)->ascent|(cs)->descent) == 0)) - -/* - * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit - * character. If the character is in the column and exists, then return the - * appropriate metrics (note that fonts with common per-character metrics will - * return min_bounds). If none of these hold true, try again with the default - * char. - */ -#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ -{ \ - cs = def; \ - if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ - CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) - - - -/* - * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and - * column. This is used for fonts that have more than row zero. - */ -#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ -{ \ - cs = def; \ - if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ - col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[((row - fs->min_byte1) * \ - (fs->max_char_or_byte2 - \ - fs->min_char_or_byte2 + 1)) + \ - (col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ -{ \ - unsigned int r = (fs->default_char >> 8); \ - unsigned int c = (fs->default_char & 0xff); \ - CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ -} - - -#ifdef MUSTCOPY - -/* for when 32-bit alignment is not good enough */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); } - -#else - -/* srcvar must be a variable for large architecture version */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { *(CARD32 *)(dstaddr) = (srcvar); } - -#endif /* MUSTCOPY */ - -typedef struct _XInternalAsync { - struct _XInternalAsync *next; - /* - * handler arguments: - * rep is the generic reply that caused this handler - * to be invoked. It must also be passed to _XGetAsyncReply. - * buf and len are opaque values that must be passed to - * _XGetAsyncReply or _XGetAsyncData. - * data is the closure stored in this struct. - * The handler returns True iff it handled this reply. - */ - Bool (*handler)( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ - ); - XPointer data; -} _XAsyncHandler; - -typedef struct _XAsyncEState { - unsigned long min_sequence_number; - unsigned long max_sequence_number; - unsigned char error_code; - unsigned char major_opcode; - unsigned short minor_opcode; - unsigned char last_error_received; - int error_count; -} _XAsyncErrorState; - -extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler); -#define DeqAsyncHandler(dpy,handler) { \ - if (dpy->async_handlers == (handler)) \ - dpy->async_handlers = (handler)->next; \ - else \ - _XDeqAsyncHandler(dpy, handler); \ - } - -typedef void (*FreeFuncType) ( - Display* /* display */ -); - -typedef int (*FreeModmapType) ( - XModifierKeymap* /* modmap */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XFreeFuncs { - FreeFuncType atoms; /* _XFreeAtomTable */ - FreeModmapType modifiermap; /* XFreeModifierMap */ - FreeFuncType key_bindings; /* _XFreeKeyBindings */ - FreeFuncType context_db; /* _XFreeContextDB */ - FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */ - FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */ - FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */ - FreeFuncType im_filters; /* _XFreeIMFilters */ - FreeFuncType xkb; /* _XkbFreeInfo */ -} _XFreeFuncRec; - -/* types for InitExt.c */ -typedef int (*CreateGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CopyGCType)( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FlushGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FreeGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CreateFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*FreeFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*CloseDisplayType) ( - Display* /* display */, - XExtCodes* /* codes */ -); - -typedef int (*ErrorType) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ -); - -typedef char* (*ErrorStringType) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ -); - -typedef void (*PrintErrorType)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ -); - -typedef void (*BeforeFlushType)( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XExten { /* private to extension mechanism */ - struct _XExten *next; /* next in list */ - XExtCodes codes; /* public information, all extension told */ - CreateGCType create_GC; /* routine to call when GC created */ - CopyGCType copy_GC; /* routine to call when GC copied */ - FlushGCType flush_GC; /* routine to call when GC flushed */ - FreeGCType free_GC; /* routine to call when GC freed */ - CreateFontType create_Font; /* routine to call when Font created */ - FreeFontType free_Font; /* routine to call when Font freed */ - CloseDisplayType close_display; /* routine to call when connection closed */ - ErrorType error; /* who to call when an error occurs */ - ErrorStringType error_string; /* routine to supply error string */ - char *name; /* name of this extension */ - PrintErrorType error_values; /* routine to supply error values */ - BeforeFlushType before_flush; /* routine to call when sending data */ - struct _XExten *next_flush; /* next in list of those with flushes */ -} _XExtension; - -/* extension hooks */ - -#ifdef DataRoutineIsProcedure -extern void Data(Display *dpy, char *data, long len); -#endif -extern int _XError( - Display* /* dpy */, - xError* /* rep */ -); -extern int _XIOError( - Display* /* dpy */ -); -extern int (*_XIOErrorFunction)( - Display* /* dpy */ -); -extern int (*_XErrorFunction)( - Display* /* dpy */, - XErrorEvent* /* error_event */ -); -extern void _XEatData( - Display* /* dpy */, - unsigned long /* n */ -); -extern char *_XAllocScratch( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern char *_XAllocTemp( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern void _XFreeTemp( - Display* /* dpy */, - char* /* buf */, - unsigned long /* nbytes */ -); -extern Visual *_XVIDtoVisual( - Display* /* dpy */, - VisualID /* id */ -); -extern unsigned long _XSetLastRequestRead( - Display* /* dpy */, - xGenericReply* /* rep */ -); -extern int _XGetHostname( - char* /* buf */, - int /* maxlen */ -); -extern Screen *_XScreenOfWindow( - Display* /* dpy */, - Window /* w */ -); -extern Bool _XAsyncErrorHandler( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ -); -extern char *_XGetAsyncReply( - Display* /* dpy */, - char* /* replbuf */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - int /* extra */, - Bool /* discard */ -); -extern void _XGetAsyncData( - Display* /* dpy */, - char * /* data */, - char * /* buf */, - int /* len */, - int /* skip */, - int /* datalen */, - int /* discardtotal */ -); -extern void _XFlush( - Display* /* dpy */ -); -extern int _XEventsQueued( - Display* /* dpy */, - int /* mode */ -); -extern void _XReadEvents( - Display* /* dpy */ -); -extern int _XRead( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XReadPad( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XSend( - Display* /* dpy */, - _Xconst char* /* data */, - long /* size */ -); -extern Status _XReply( - Display* /* dpy */, - xReply* /* rep */, - int /* extra */, - Bool /* discard */ -); -extern void _XEnq( - Display* /* dpy */, - xEvent* /* event */ -); -extern void _XDeq( - Display* /* dpy */, - _XQEvent* /* prev */, - _XQEvent* /* qelt */ -); - -extern Bool _XUnknownWireEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); -extern Status _XUnknownNativeEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); - -extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event); -extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we); -extern Bool _XPollfdCacheInit(Display *dpy); -extern void _XPollfdCacheAdd(Display *dpy, int fd); -extern void _XPollfdCacheDel(Display *dpy, int fd); -extern XID _XAllocID(Display *dpy); -extern void _XAllocIDs(Display *dpy, XID *ids, int count); - -extern int _XFreeExtData( - XExtData* /* extension */ -); - -extern int (*XESetCreateGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCopyGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFlushGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFreeGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCreateFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetFreeFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetCloseDisplay( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XExtCodes* -); - -extern int (*XESetError( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ - ) /* proc */ -))( - Display*, xError*, XExtCodes*, int* -); - -extern char* (*XESetErrorString( - Display* /* display */, - int /* extension */, - char* (*) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ - ) /* proc */ -))( - Display*, int, XExtCodes*, char*, int -); - -extern void (*XESetPrintErrorValues ( - Display* /* display */, - int /* extension */, - void (*)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ - ) /* proc */ -))( - Display*, XErrorEvent*, void* -); - -extern Bool (*XESetWireToEvent( - Display* /* display */, - int /* event_number */, - Bool (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Status (*XESetEventToWire( - Display* /* display */, - int /* event_number */, - Status (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Bool (*XESetWireToError( - Display* /* display */, - int /* error_number */, - Bool (*) ( - Display* /* display */, - XErrorEvent* /* he */, - xError* /* we */ - ) /* proc */ -))( - Display*, XErrorEvent*, xError* -); - -extern void (*XESetBeforeFlush( - Display* /* display */, - int /* error_number */, - void (*) ( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ - ) /* proc */ -))( - Display*, XExtCodes*, _Xconst char*, long -); - -/* internal connections for IMs */ - -typedef void (*_XInternalConnectionProc)( - Display* /* dpy */, - int /* fd */, - XPointer /* call_data */ -); - - -extern Status _XRegisterInternalConnection( - Display* /* dpy */, - int /* fd */, - _XInternalConnectionProc /* callback */, - XPointer /* call_data */ -); - -extern void _XUnregisterInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -/* Display structure has pointers to these */ - -struct _XConnectionInfo { /* info from _XRegisterInternalConnection */ - int fd; - _XInternalConnectionProc read_callback; - XPointer call_data; - XPointer *watch_data; /* set/used by XConnectionWatchProc */ - struct _XConnectionInfo *next; -}; - -struct _XConnWatchInfo { /* info from XAddConnectionWatch */ - XConnectionWatchProc fn; - XPointer client_data; - struct _XConnWatchInfo *next; -}; - -#ifdef __UNIXOS2__ -extern char* __XOS2RedirRoot( - char* -); -#endif - -extern int _XTextHeight( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int _XTextHeight16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -#if defined(WIN32) - -extern int _XOpenFile( - _Xconst char* /* path */, - int /* flags */ -); - -extern void* _XFopenFile( - _Xconst char* /* path */, - _Xconst char* /* mode */ -); - -extern int _XAccessFile( - _Xconst char* /* path */ -); -#else -#define _XOpenFile(path,flags) open(path,flags) -#define _XFopenFile(path,mode) fopen(path,mode) -#endif - -/* EvToWire.c */ -extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event); - -extern int _XF86LoadQueryLocaleFont( - Display* /* dpy */, - _Xconst char* /* name*/, - XFontStruct** /* xfp*/, - Font* /* fidp */ -); - -extern void _XProcessWindowAttributes ( - register Display *dpy, - xChangeWindowAttributesReq *req, - register unsigned long valuemask, - register XSetWindowAttributes *attributes); - -extern int _XDefaultError( - Display *dpy, - XErrorEvent *event); - -extern int _XDefaultIOError( - Display *dpy); - -extern void _XSetClipRectangles ( - register Display *dpy, - GC gc, - int clip_x_origin, int clip_y_origin, - XRectangle *rectangles, - int n, - int ordering); - -Status _XGetWindowAttributes( - register Display *dpy, - Window w, - XWindowAttributes *attr); - -int _XPutBackEvent ( - register Display *dpy, - register XEvent *event); - -_XFUNCPROTOEND - -#endif /* _XLIBINT_H_ */ diff --git a/nx-X11/lib/X11/Xlibint.h.X.original b/nx-X11/lib/X11/Xlibint.h.X.original deleted file mode 100644 index 8517f6539..000000000 --- a/nx-X11/lib/X11/Xlibint.h.X.original +++ /dev/null @@ -1,1313 +0,0 @@ -/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */ - -/* - -Copyright 1984, 1985, 1987, 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ -/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */ - -#ifndef _XLIBINT_H_ -#define _XLIBINT_H_ 1 - -/* - * Xlibint.h - Header definition and support file for the internal - * support routines used by the C subroutine interface - * library (Xlib) to the X Window System. - * - * Warning, there be dragons here.... - */ - -#include <X11/Xlib.h> -#include <X11/Xproto.h> /* to declare xEvent */ -#include <X11/XlibConf.h> /* for configured options like XTHREADS */ - -#ifdef WIN32 -#define _XFlush _XFlushIt -#endif - -/* - * If your BytesReadable correctly detects broken connections, then - * you should NOT define XCONN_CHECK_FREQ. - */ -#ifndef XCONN_CHECK_FREQ -#define XCONN_CHECK_FREQ 256 -#endif - -struct _XGC -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - Bool rects; /* boolean: TRUE if clipmask is list of rectangles */ - Bool dashes; /* boolean: TRUE if dash-list is really a list */ - unsigned long dirty;/* cache dirty bits */ - XGCValues values; /* shadow structure of values */ -}; - -struct _XDisplay -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XFreeFuncs *free_funcs; /* internal free functions */ - int fd; /* Network socket. */ - int conn_checker; /* ugly thing used by _XEventsQueued */ - int proto_major_version;/* maj. version of server's X protocol */ - int proto_minor_version;/* minor version of server's X protocol */ - char *vendor; /* vendor of the server hardware */ - XID resource_base; /* resource ID base */ - XID resource_mask; /* resource ID mask bits */ - XID resource_id; /* allocator current ID */ - int resource_shift; /* allocator shift to correct bits */ - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int vnumber; /* Xlib's X protocol version number. */ - int release; /* release of the server */ - struct _XSQEvent *head, *tail; /* Input event queue. */ - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - char *last_req; /* beginning of last request, or dummy */ - char *buffer; /* Output buffer starting address. */ - char *bufptr; /* Output buffer index pointer. */ - char *bufmax; /* Output buffer maximum+1 address. */ - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*synchandler)( /* Synchronization handler */ - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long flags; /* internal connection flags */ - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - KeySym *keysyms; /* This server's keysyms */ - XModifierKeymap *modifiermap; /* This server's modifier keymap */ - int keysyms_per_keycode;/* number of rows */ - char *xdefaults; /* contents of defaults from server */ - char *scratch_buffer; /* place to hang scratch buffer */ - unsigned long scratch_length; /* length of scratch buffer */ - int ext_number; /* extension number on this display */ - struct _XExten *ext_procs; /* extensions initialized on this display */ - /* - * the following can be fixed size, as the protocol defines how - * much address space is available. - * While this could be done using the extension vector, there - * may be MANY events processed, so a search through the extension - * list to find the right procedure for each event might be - * expensive if many extensions are being used. - */ - Bool (*event_vec[128])( /* vector for wire to event */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - Status (*wire_vec[128])( /* vector for event to wire */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - KeySym lock_meaning; /* for XLookupString */ - struct _XLockInfo *lock; /* multi-thread state, display lock */ - struct _XInternalAsync *async_handlers; /* for internal async */ - unsigned long bigreq_size; /* max size of big requests */ - struct _XLockPtrs *lock_fns; /* pointers to threads functions */ - void (*idlist_alloc)( /* XID list allocator function */ - Display * /* dpy */, - XID * /* ids */, - int /* count */ - ); - /* things above this line should not move, for binary compatibility */ - struct _XKeytrans *key_bindings; /* for XLookupString */ - Font cursor_font; /* for XCreateFontCursor */ - struct _XDisplayAtoms *atoms; /* for XInternAtom */ - unsigned int mode_switch; /* keyboard group modifiers */ - unsigned int num_lock; /* keyboard numlock modifiers */ - struct _XContextDB *context_db; /* context database */ - Bool (**error_vec)( /* vector for wire to error */ - Display * /* display */, - XErrorEvent * /* he */, - xError * /* we */ - ); - /* - * Xcms information - */ - struct { - XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */ - XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */ - XPointer perVisualIntensityMaps; - /* linked list of XcmsIntensityMap */ - } cms; - struct _XIMFilter *im_filters; - struct _XSQEvent *qfree; /* unallocated event queue elements */ - unsigned long next_event_serial_num; /* inserted into next queue elt */ - struct _XExten *flushes; /* Flush hooks */ - struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */ - int im_fd_length; /* number of im_fd_info */ - struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */ - int watcher_count; /* number of conn_watchers */ - XPointer filedes; /* struct pollfd cache for _XWaitForReadable */ - int (*savedsynchandler)( /* user synchandler when Xlib usurps */ - Display * /* dpy */ - ); - XID resource_max; /* allocator max ID */ - int xcmisc_opcode; /* major opcode for XC-MISC */ - struct _XkbInfoRec *xkb_info; /* XKB info */ - struct _XtransConnInfo *trans_conn; /* transport connection object */ -}; - -#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n) - -/* - * define the following if you want the Data macro to be a procedure instead - */ -#ifdef CRAY -#define DataRoutineIsProcedure -#endif /* CRAY */ - -#ifndef _XEVENT_ -/* - * _QEvent datatype for use in input queueing. - */ -typedef struct _XSQEvent -{ - struct _XSQEvent *next; - XEvent event; - unsigned long qserial_num; /* so multi-threaded code can find new ones */ -} _XQEvent; -#endif - -#ifdef XTHREADS /* for xReply */ -#define NEED_REPLIES -#endif - -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#ifdef __sgi -#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */ -#endif -#include <errno.h> -#define _XBCOPYFUNC _Xbcopy -#include <X11/Xfuncs.h> -#include <X11/Xosdefs.h> - -/* Utek leaves kernel macros around in include files (bleah) */ -#ifdef dirty -#undef dirty -#endif - -#include <stdlib.h> -#include <string.h> - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -/* - * The following definitions can be used for locking requests in multi-threaded - * address spaces. - */ -#ifdef XTHREADS -/* Author: Stephen Gildea, MIT X Consortium - * - * declarations for C Threads locking - */ - -typedef struct _LockInfoRec *LockInfoPtr; - -/* interfaces for locking.c */ -struct _XLockPtrs { - /* used by all, including extensions; do not move */ - void (*lock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); - void (*unlock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); -}; - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _XCreateMutex_fn (*_XCreateMutex_fn_p) -#define _XFreeMutex_fn (*_XFreeMutex_fn_p) -#define _XLockMutex_fn (*_XLockMutex_fn_p) -#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p) -#define _Xglobal_lock (*_Xglobal_lock_p) -#endif - -/* in XlibInt.c */ -extern void (*_XCreateMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XFreeMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); -extern void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); - -extern LockInfoPtr _Xglobal_lock; - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__) -#else -/* used everywhere, so must be fast if not using threads */ -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock) -#endif -#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock); -#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock); - -#else /* XTHREADS */ -#define LockDisplay(dis) -#define _XLockMutex(lock) -#define _XUnlockMutex(lock) -#define UnlockDisplay(dis) -#define _XCreateMutex(lock) -#define _XFreeMutex(lock) -#endif - -#define Xfree(ptr) free((ptr)) - -/* - * Note that some machines do not return a valid pointer for malloc(0), in - * which case we provide an alternate under the control of the - * define MALLOC_0_RETURNS_NULL. This is necessary because some - * Xlib code expects malloc(0) to return a valid pointer to storage. - */ -#ifdef MALLOC_0_RETURNS_NULL - -# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size))) -# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size))) -# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize)) - -#else - -# define Xmalloc(size) malloc((size)) -# define Xrealloc(ptr, size) realloc((ptr), (size)) -# define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) - -#endif - -#include <stddef.h> - -#define LOCKED 1 -#define UNLOCKED 0 - -#ifndef BUFSIZE -#define BUFSIZE 2048 /* X output buffer size. */ -#endif -#ifndef PTSPERBATCH -#define PTSPERBATCH 1024 /* point batching */ -#endif -#ifndef WLNSPERBATCH -#define WLNSPERBATCH 50 /* wide line batching */ -#endif -#ifndef ZLNSPERBATCH -#define ZLNSPERBATCH 1024 /* thin line batching */ -#endif -#ifndef WRCTSPERBATCH -#define WRCTSPERBATCH 10 /* wide line rectangle batching */ -#endif -#ifndef ZRCTSPERBATCH -#define ZRCTSPERBATCH 256 /* thin line rectangle batching */ -#endif -#ifndef FRCTSPERBATCH -#define FRCTSPERBATCH 256 /* filled rectangle batching */ -#endif -#ifndef FARCSPERBATCH -#define FARCSPERBATCH 256 /* filled arc batching */ -#endif -#ifndef CURSORFONT -#define CURSORFONT "cursor" /* standard cursor fonts */ -#endif - -/* - * Display flags - */ -#define XlibDisplayIOError (1L << 0) -#define XlibDisplayClosing (1L << 1) -#define XlibDisplayNoXkb (1L << 2) -#define XlibDisplayPrivSync (1L << 3) -#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */ -#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */ -#define XlibDisplayReply (1L << 5) /* in _XReply */ -#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */ -#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */ - -/* - * X Protocol packetizing macros. - */ - -/* Need to start requests on 64 bit word boundaries - * on a CRAY computer so add a NoOp (127) if needed. - * A character pointer on a CRAY computer will be non-zero - * after shifting right 61 bits of it is not pointing to - * a word boundary. - */ -#ifdef WORD64 -#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\ - dpy->last_req = dpy->bufptr;\ - *(dpy->bufptr) = X_NoOperation;\ - *(dpy->bufptr+1) = 0;\ - *(dpy->bufptr+2) = 0;\ - *(dpy->bufptr+3) = 1;\ - dpy->request++;\ - dpy->bufptr += 4;\ - } -#else /* else does not require alignment on 64-bit boundaries */ -#define WORD64ALIGN -#endif /* WORD64 */ - - -/* - * GetReq - Get the next available X request packet in the buffer and - * return it. - * - * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc. - * "req" is the name of the request pointer. - * - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req))>>2;\ - dpy->bufptr += SIZEOF(x##name##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req))>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req);\ - dpy->request++ -#endif - -/* GetReqExtra is the same as GetReq, but allocates "n" additional - bytes after the request. "n" must be a multiple of 4! */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x##name##Req) + n;\ - dpy->request++ -#else -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\ - dpy->request++ -#endif - - -/* - * GetResReq is for those requests that have a resource ID - * (Window, Pixmap, GContext, etc.) as their single argument. - * "rid" is the name of the resource. - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#else -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#endif - -/* - * GetEmptyReq is for those requests that have no arguments - * at all. - */ -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#else -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#endif - -#ifdef WORD64 -#define MakeBigReq(req,n) \ - { \ - char _BRdat[4]; \ - unsigned long _BRlen = req->length - 1; \ - req->length = 0; \ - memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - memcpy(((char *)req) + 4, _BRdat, 4); \ - Data32(dpy, (long *)&_BRdat, 4); \ - } -#else -#ifdef LONG64 -#define MakeBigReq(req,n) \ - { \ - CARD64 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#else -#define MakeBigReq(req,n) \ - { \ - CARD32 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#endif -#endif - -#define SetReqLen(req,n,badlen) \ - if ((req->length + n) > (unsigned)65535) { \ - if (dpy->bigreq_size) { \ - MakeBigReq(req,n) \ - } else { \ - n = badlen; \ - req->length += n; \ - } \ - } else \ - req->length += n - -#define SyncHandle() \ - if (dpy->synchandler) (*dpy->synchandler)(dpy) - -extern void _XFlushGCCache(Display *dpy, GC gc); -#define FlushGC(dpy, gc) \ - if ((gc)->dirty) _XFlushGCCache((dpy), (gc)) -/* - * Data - Place data in the buffer and pad the end to provide - * 32 bit word alignment. Transmit if the buffer fills. - * - * "dpy" is a pointer to a Display. - * "data" is a pinter to a data buffer. - * "len" is the length of the data buffer. - */ -#ifndef DataRoutineIsProcedure -#define Data(dpy, data, len) {\ - if (dpy->bufptr + (len) <= dpy->bufmax) {\ - memcpy(dpy->bufptr, data, (int)len);\ - dpy->bufptr += ((len) + 3) & ~3;\ - } else\ - _XSend(dpy, data, len);\ - } -#endif /* DataRoutineIsProcedure */ - - -/* Allocate bytes from the buffer. No padding is done, so if - * the length is not a multiple of 4, the caller must be - * careful to leave the buffer aligned after sending the - * current request. - * - * "type" is the type of the pointer being assigned to. - * "ptr" is the pointer being assigned to. - * "n" is the number of bytes to allocate. - * - * Example: - * xTextElt *elt; - * BufAlloc (xTextElt *, elt, nbytes) - */ - -#define BufAlloc(type, ptr, n) \ - if (dpy->bufptr + (n) > dpy->bufmax) \ - _XFlush (dpy); \ - ptr = (type) dpy->bufptr; \ - (void)ptr; \ - dpy->bufptr += (n); - -#ifdef WORD64 -#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len) -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -#else -#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len)) -#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#ifdef LONG64 -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -extern int _XData32( - Display *dpy, - register long *data, - unsigned len -); -extern void _XRead32( - Display *dpy, - register long *data, - long len -); -#else -#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#endif -#endif /* not WORD64 */ - -#define PackData16(dpy,data,len) Data16 (dpy, data, len) -#define PackData32(dpy,data,len) Data32 (dpy, data, len) - -/* Xlib manual is bogus */ -#define PackData(dpy,data,len) PackData16 (dpy, data, len) - -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) - -#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ - (((cs)->rbearing|(cs)->lbearing| \ - (cs)->ascent|(cs)->descent) == 0)) - -/* - * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit - * character. If the character is in the column and exists, then return the - * appropriate metrics (note that fonts with common per-character metrics will - * return min_bounds). If none of these hold true, try again with the default - * char. - */ -#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ -{ \ - cs = def; \ - if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ - CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) - - - -/* - * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and - * column. This is used for fonts that have more than row zero. - */ -#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ -{ \ - cs = def; \ - if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ - col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[((row - fs->min_byte1) * \ - (fs->max_char_or_byte2 - \ - fs->min_char_or_byte2 + 1)) + \ - (col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ -{ \ - unsigned int r = (fs->default_char >> 8); \ - unsigned int c = (fs->default_char & 0xff); \ - CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ -} - - -#ifdef MUSTCOPY - -/* for when 32-bit alignment is not good enough */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); } - -#else - -/* srcvar must be a variable for large architecture version */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { *(CARD32 *)(dstaddr) = (srcvar); } - -#endif /* MUSTCOPY */ - -typedef struct _XInternalAsync { - struct _XInternalAsync *next; - /* - * handler arguments: - * rep is the generic reply that caused this handler - * to be invoked. It must also be passed to _XGetAsyncReply. - * buf and len are opaque values that must be passed to - * _XGetAsyncReply or _XGetAsyncData. - * data is the closure stored in this struct. - * The handler returns True iff it handled this reply. - */ - Bool (*handler)( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ - ); - XPointer data; -} _XAsyncHandler; - -typedef struct _XAsyncEState { - unsigned long min_sequence_number; - unsigned long max_sequence_number; - unsigned char error_code; - unsigned char major_opcode; - unsigned short minor_opcode; - unsigned char last_error_received; - int error_count; -} _XAsyncErrorState; - -extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler); -#define DeqAsyncHandler(dpy,handler) { \ - if (dpy->async_handlers == (handler)) \ - dpy->async_handlers = (handler)->next; \ - else \ - _XDeqAsyncHandler(dpy, handler); \ - } - -typedef void (*FreeFuncType) ( - Display* /* display */ -); - -typedef int (*FreeModmapType) ( - XModifierKeymap* /* modmap */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XFreeFuncs { - FreeFuncType atoms; /* _XFreeAtomTable */ - FreeModmapType modifiermap; /* XFreeModifierMap */ - FreeFuncType key_bindings; /* _XFreeKeyBindings */ - FreeFuncType context_db; /* _XFreeContextDB */ - FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */ - FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */ - FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */ - FreeFuncType im_filters; /* _XFreeIMFilters */ - FreeFuncType xkb; /* _XkbFreeInfo */ -} _XFreeFuncRec; - -/* types for InitExt.c */ -typedef int (*CreateGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CopyGCType)( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FlushGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FreeGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CreateFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*FreeFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*CloseDisplayType) ( - Display* /* display */, - XExtCodes* /* codes */ -); - -typedef int (*ErrorType) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ -); - -typedef char* (*ErrorStringType) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ -); - -typedef void (*PrintErrorType)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ -); - -typedef void (*BeforeFlushType)( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XExten { /* private to extension mechanism */ - struct _XExten *next; /* next in list */ - XExtCodes codes; /* public information, all extension told */ - CreateGCType create_GC; /* routine to call when GC created */ - CopyGCType copy_GC; /* routine to call when GC copied */ - FlushGCType flush_GC; /* routine to call when GC flushed */ - FreeGCType free_GC; /* routine to call when GC freed */ - CreateFontType create_Font; /* routine to call when Font created */ - FreeFontType free_Font; /* routine to call when Font freed */ - CloseDisplayType close_display; /* routine to call when connection closed */ - ErrorType error; /* who to call when an error occurs */ - ErrorStringType error_string; /* routine to supply error string */ - char *name; /* name of this extension */ - PrintErrorType error_values; /* routine to supply error values */ - BeforeFlushType before_flush; /* routine to call when sending data */ - struct _XExten *next_flush; /* next in list of those with flushes */ -} _XExtension; - -/* extension hooks */ - -#ifdef DataRoutineIsProcedure -extern void Data(Display *dpy, char *data, long len); -#endif -extern int _XError( - Display* /* dpy */, - xError* /* rep */ -); -extern int _XIOError( - Display* /* dpy */ -); -extern int (*_XIOErrorFunction)( - Display* /* dpy */ -); -extern int (*_XErrorFunction)( - Display* /* dpy */, - XErrorEvent* /* error_event */ -); -extern void _XEatData( - Display* /* dpy */, - unsigned long /* n */ -); -extern char *_XAllocScratch( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern char *_XAllocTemp( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern void _XFreeTemp( - Display* /* dpy */, - char* /* buf */, - unsigned long /* nbytes */ -); -extern Visual *_XVIDtoVisual( - Display* /* dpy */, - VisualID /* id */ -); -extern unsigned long _XSetLastRequestRead( - Display* /* dpy */, - xGenericReply* /* rep */ -); -extern int _XGetHostname( - char* /* buf */, - int /* maxlen */ -); -extern Screen *_XScreenOfWindow( - Display* /* dpy */, - Window /* w */ -); -extern Bool _XAsyncErrorHandler( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ -); -extern char *_XGetAsyncReply( - Display* /* dpy */, - char* /* replbuf */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - int /* extra */, - Bool /* discard */ -); -extern void _XGetAsyncData( - Display* /* dpy */, - char * /* data */, - char * /* buf */, - int /* len */, - int /* skip */, - int /* datalen */, - int /* discardtotal */ -); -extern void _XFlush( - Display* /* dpy */ -); -extern int _XEventsQueued( - Display* /* dpy */, - int /* mode */ -); -extern void _XReadEvents( - Display* /* dpy */ -); -extern int _XRead( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XReadPad( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XSend( - Display* /* dpy */, - _Xconst char* /* data */, - long /* size */ -); -extern Status _XReply( - Display* /* dpy */, - xReply* /* rep */, - int /* extra */, - Bool /* discard */ -); -extern void _XEnq( - Display* /* dpy */, - xEvent* /* event */ -); -extern void _XDeq( - Display* /* dpy */, - _XQEvent* /* prev */, - _XQEvent* /* qelt */ -); - -extern Bool _XUnknownWireEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); -extern Status _XUnknownNativeEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); - -extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event); -extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we); -extern Bool _XPollfdCacheInit(Display *dpy); -extern void _XPollfdCacheAdd(Display *dpy, int fd); -extern void _XPollfdCacheDel(Display *dpy, int fd); -extern XID _XAllocID(Display *dpy); -extern void _XAllocIDs(Display *dpy, XID *ids, int count); - -extern int _XFreeExtData( - XExtData* /* extension */ -); - -extern int (*XESetCreateGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCopyGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFlushGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFreeGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCreateFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetFreeFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetCloseDisplay( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XExtCodes* -); - -extern int (*XESetError( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ - ) /* proc */ -))( - Display*, xError*, XExtCodes*, int* -); - -extern char* (*XESetErrorString( - Display* /* display */, - int /* extension */, - char* (*) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ - ) /* proc */ -))( - Display*, int, XExtCodes*, char*, int -); - -extern void (*XESetPrintErrorValues ( - Display* /* display */, - int /* extension */, - void (*)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ - ) /* proc */ -))( - Display*, XErrorEvent*, void* -); - -extern Bool (*XESetWireToEvent( - Display* /* display */, - int /* event_number */, - Bool (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Status (*XESetEventToWire( - Display* /* display */, - int /* event_number */, - Status (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Bool (*XESetWireToError( - Display* /* display */, - int /* error_number */, - Bool (*) ( - Display* /* display */, - XErrorEvent* /* he */, - xError* /* we */ - ) /* proc */ -))( - Display*, XErrorEvent*, xError* -); - -extern void (*XESetBeforeFlush( - Display* /* display */, - int /* error_number */, - void (*) ( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ - ) /* proc */ -))( - Display*, XExtCodes*, _Xconst char*, long -); - -/* internal connections for IMs */ - -typedef void (*_XInternalConnectionProc)( - Display* /* dpy */, - int /* fd */, - XPointer /* call_data */ -); - - -extern Status _XRegisterInternalConnection( - Display* /* dpy */, - int /* fd */, - _XInternalConnectionProc /* callback */, - XPointer /* call_data */ -); - -extern void _XUnregisterInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -/* Display structure has pointers to these */ - -struct _XConnectionInfo { /* info from _XRegisterInternalConnection */ - int fd; - _XInternalConnectionProc read_callback; - XPointer call_data; - XPointer *watch_data; /* set/used by XConnectionWatchProc */ - struct _XConnectionInfo *next; -}; - -struct _XConnWatchInfo { /* info from XAddConnectionWatch */ - XConnectionWatchProc fn; - XPointer client_data; - struct _XConnWatchInfo *next; -}; - -#ifdef __UNIXOS2__ -extern char* __XOS2RedirRoot( - char* -); -#endif - -extern int _XTextHeight( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int _XTextHeight16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -#if defined(WIN32) - -extern int _XOpenFile( - _Xconst char* /* path */, - int /* flags */ -); - -extern void* _XFopenFile( - _Xconst char* /* path */, - _Xconst char* /* mode */ -); - -extern int _XAccessFile( - _Xconst char* /* path */ -); -#else -#define _XOpenFile(path,flags) open(path,flags) -#define _XFopenFile(path,mode) fopen(path,mode) -#endif - -/* EvToWire.c */ -extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event); - -extern int _XF86LoadQueryLocaleFont( - Display* /* dpy */, - _Xconst char* /* name*/, - XFontStruct** /* xfp*/, - Font* /* fidp */ -); - -extern void _XProcessWindowAttributes ( - register Display *dpy, - xChangeWindowAttributesReq *req, - register unsigned long valuemask, - register XSetWindowAttributes *attributes); - -extern int _XDefaultError( - Display *dpy, - XErrorEvent *event); - -extern int _XDefaultIOError( - Display *dpy); - -extern void _XSetClipRectangles ( - register Display *dpy, - GC gc, - int clip_x_origin, int clip_y_origin, - XRectangle *rectangles, - int n, - int ordering); - -Status _XGetWindowAttributes( - register Display *dpy, - Window w, - XWindowAttributes *attr); - -int _XPutBackEvent ( - register Display *dpy, - register XEvent *event); - -_XFUNCPROTOEND - -#endif /* _XLIBINT_H_ */ diff --git a/nx-X11/lib/X11/cmsProp.c.X.original b/nx-X11/lib/X11/cmsProp.c.X.original deleted file mode 100644 index 4040a05ce..000000000 --- a/nx-X11/lib/X11/cmsProp.c.X.original +++ /dev/null @@ -1,148 +0,0 @@ -/* $Xorg: cmsProp.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */ - -/* - * - * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. - * All Rights Reserved - * - * This file is a component of an X Window System-specific implementation - * of Xcms based on the TekColor Color Management System. Permission is - * hereby granted to use, copy, modify, sell, and otherwise distribute this - * software and its documentation for any purpose and without fee, provided - * that this copyright, permission, and disclaimer notice is reproduced in - * all copies of this software and in supporting documentation. TekColor - * is a trademark of Tektronix, Inc. - * - * Tektronix makes no representation about the suitability of this software - * for any purpose. It is provided "as is" and with all faults. - * - * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, - * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE. - * - * NAME - * XcmsProp.c - * - * DESCRIPTION - * This utility routines for manipulating properties. - * - */ -/* $XFree86$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xatom.h> -#include "Xlibint.h" -#include "Xcmsint.h" -#include "Cv.h" - - -/************************************************************************ - * * - * API PRIVATE ROUTINES * - * * - ************************************************************************/ - - -/* - * NAME - * _XcmsGetElement -- get an element value from the property passed - * - * SYNOPSIS - */ -unsigned long -_XcmsGetElement( - int format, - char **pValue, - unsigned long *pCount) -/* - * DESCRIPTION - * Get the next element from the property and return it. - * Also increment the pointer the amount needed. - * - * Returns - * unsigned long - */ -{ - unsigned long value; - - switch (format) { - case 32: - value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF; - *pValue += sizeof(unsigned long); - *pCount -= 1; - break; - case 16: - value = *((unsigned short *)(*pValue)); - *pValue += sizeof(unsigned short); - *pCount -= 1; - break; - case 8: - value = *((unsigned char *) (*pValue)); - *pValue += 1; - *pCount -= 1; - break; - default: - value = 0; - break; - } - return(value); -} - - -/* - * NAME - * _XcmsGetProperty -- Determine the existance of a property - * - * SYNOPSIS - */ -int -_XcmsGetProperty( - Display *pDpy, - Window w, - Atom property, - int *pFormat, - unsigned long *pNItems, - unsigned long *pNBytes, - char **pValue) -/* - * DESCRIPTION - * - * Returns - * 0 if property does not exist. - * 1 if property exists. - */ -{ - char *prop_ret; - int format_ret; - long len = 6516; - unsigned long nitems_ret, after_ret; - Atom atom_ret; - - while (XGetWindowProperty (pDpy, w, property, 0, len, False, - XA_INTEGER, &atom_ret, &format_ret, - &nitems_ret, &after_ret, - (unsigned char **)&prop_ret)) { - if (after_ret > 0) { - len += nitems_ret * (format_ret >> 3); - XFree (prop_ret); - } else { - break; - } - } - if (format_ret == 0 || nitems_ret == 0) { - /* the property does not exist or is of an unexpected type */ - return(XcmsFailure); - } - - *pFormat = format_ret; - *pNItems = nitems_ret; - *pNBytes = nitems_ret * (format_ret >> 3); - *pValue = prop_ret; - return(XcmsSuccess); -} |