aboutsummaryrefslogtreecommitdiff
path: root/libXext/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-07-08 06:58:33 +0000
committermarha <marha@users.sourceforge.net>2010-07-08 06:58:33 +0000
commitd1e8cd61e0fa02a5b415a5c161b355c95f45ae14 (patch)
tree6ef2e067b387b0e145e65be0f05fb071b8e60364 /libXext/src
parent5da15e274b35656568f59602f2e3fd00d5718879 (diff)
downloadvcxsrv-d1e8cd61e0fa02a5b415a5c161b355c95f45ae14.tar.gz
vcxsrv-d1e8cd61e0fa02a5b415a5c161b355c95f45ae14.tar.bz2
vcxsrv-d1e8cd61e0fa02a5b415a5c161b355c95f45ae14.zip
git update 8/7/2010
Diffstat (limited to 'libXext/src')
-rw-r--r--libXext/src/DPMS.c585
-rw-r--r--libXext/src/MITMisc.c265
-rw-r--r--libXext/src/XAppgroup.c782
-rw-r--r--libXext/src/XEVI.c431
-rw-r--r--libXext/src/XLbx.c256
-rw-r--r--libXext/src/XMultibuf.c1428
-rw-r--r--libXext/src/XShape.c981
-rw-r--r--libXext/src/XShm.c870
-rw-r--r--libXext/src/XSync.c1594
-rw-r--r--libXext/src/XTestExt1.c2641
-rw-r--r--libXext/src/Xcup.c530
-rw-r--r--libXext/src/Xdbe.c2
-rw-r--r--libXext/src/Xge.c733
13 files changed, 5537 insertions, 5561 deletions
diff --git a/libXext/src/DPMS.c b/libXext/src/DPMS.c
index 92a7f616a..02698aad7 100644
--- a/libXext/src/DPMS.c
+++ b/libXext/src/DPMS.c
@@ -1,293 +1,292 @@
-/* $Xorg: DPMS.c,v 1.3 2000/08/17 19:45:50 cpqbld Exp $ */
-/*****************************************************************
-
-Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software.
-
-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
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-
-******************************************************************/
-/* $XFree86: xc/lib/Xext/DPMS.c,v 3.5 2002/10/16 00:37:27 dawes Exp $ */
-
-/*
- * HISTORY
- */
-
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <X11/extensions/dpms.h>
-#include <X11/extensions/dpmsproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <stdio.h>
-
-static XExtensionInfo _dpms_info_data;
-static XExtensionInfo *dpms_info = &_dpms_info_data;
-static char *dpms_extension_name = DPMSExtensionName;
-
-#define DPMSCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, dpms_extension_name, val)
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static /* const */ XExtensionHooks dpms_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, dpms_info,
- dpms_extension_name,
- &dpms_extension_hooks, DPMSNumberEvents,
- NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, dpms_info)
-
-/*****************************************************************************
- * *
- * public routines *
- * *
- *****************************************************************************/
-
-Bool
-DPMSQueryExtension (Display *dpy, int *event_basep, int *error_basep)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- return True;
- } else {
- return False;
- }
-}
-
-Status
-DPMSGetVersion(Display *dpy, int *major_versionp, int *minor_versionp)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xDPMSGetVersionReply rep;
- register xDPMSGetVersionReq *req;
-
- DPMSCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- GetReq (DPMSGetVersion, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSGetVersion;
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- *major_versionp = rep.majorVersion;
- *minor_versionp = rep.minorVersion;
- UnlockDisplay (dpy);
- SyncHandle ();
- return 1;
-}
-
-Bool
-DPMSCapable(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSCapableReq *req;
- xDPMSCapableReply rep;
-
- DPMSCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(DPMSCapable, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSCapable;
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return rep.capable;
-}
-
-Status
-DPMSSetTimeouts(Display *dpy, CARD16 standby, CARD16 suspend, CARD16 off)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSSetTimeoutsReq *req;
-
- if ((off != 0)&&(off < suspend))
- {
- return BadValue;
- }
- if ((suspend != 0)&&(suspend < standby))
- {
- return BadValue;
- }
-
- DPMSCheckExtension (dpy, info, 0);
- LockDisplay(dpy);
- GetReq(DPMSSetTimeouts, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSSetTimeouts;
- req->standby = standby;
- req->suspend = suspend;
- req->off = off;
-
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-Bool
-DPMSGetTimeouts(Display *dpy, CARD16 *standby, CARD16 *suspend, CARD16 *off)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSGetTimeoutsReq *req;
- xDPMSGetTimeoutsReply rep;
-
- DPMSCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(DPMSGetTimeouts, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSGetTimeouts;
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- *standby = rep.standby;
- *suspend = rep.suspend;
- *off = rep.off;
- return 1;
-}
-
-Status
-DPMSEnable(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSEnableReq *req;
-
- DPMSCheckExtension (dpy, info, 0);
- LockDisplay(dpy);
- GetReq(DPMSEnable, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSEnable;
-
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-Status
-DPMSDisable(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSDisableReq *req;
-
- DPMSCheckExtension (dpy, info, 0);
- LockDisplay(dpy);
- GetReq(DPMSDisable, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSDisable;
-
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-
-Status
-DPMSForceLevel(Display *dpy, CARD16 level)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSForceLevelReq *req;
-
- DPMSCheckExtension (dpy, info, 0);
-
- if ((level != DPMSModeOn) &&
- (level != DPMSModeStandby) &&
- (level != DPMSModeSuspend) &&
- (level != DPMSModeOff))
- return BadValue;
-
- LockDisplay(dpy);
- GetReq(DPMSForceLevel, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSForceLevel;
- req->level = level;
-
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-Status
-DPMSInfo(Display *dpy, CARD16 *power_level, BOOL *state)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xDPMSInfoReq *req;
- xDPMSInfoReply rep;
-
- DPMSCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(DPMSInfo, req);
- req->reqType = info->codes->major_opcode;
- req->dpmsReqType = X_DPMSInfo;
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- *power_level = rep.power_level;
- *state = rep.state;
- return 1;
-}
-
-
-
+/* $Xorg: DPMS.c,v 1.3 2000/08/17 19:45:50 cpqbld Exp $ */
+/*****************************************************************
+
+Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+/* $XFree86: xc/lib/Xext/DPMS.c,v 3.5 2002/10/16 00:37:27 dawes Exp $ */
+
+/*
+ * HISTORY
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/dpms.h>
+#include <X11/extensions/dpmsproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <stdio.h>
+
+static XExtensionInfo _dpms_info_data;
+static XExtensionInfo *dpms_info = &_dpms_info_data;
+static char *dpms_extension_name = DPMSExtensionName;
+
+#define DPMSCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, dpms_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks dpms_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, dpms_info,
+ dpms_extension_name,
+ &dpms_extension_hooks, DPMSNumberEvents,
+ NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, dpms_info)
+
+/*****************************************************************************
+ * *
+ * public routines *
+ * *
+ *****************************************************************************/
+
+Bool
+DPMSQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+Status
+DPMSGetVersion(Display *dpy, int *major_versionp, int *minor_versionp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xDPMSGetVersionReply rep;
+ register xDPMSGetVersionReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (DPMSGetVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSGetVersion;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+Bool
+DPMSCapable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSCapableReq *req;
+ xDPMSCapableReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSCapable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.capable;
+}
+
+Status
+DPMSSetTimeouts(Display *dpy, CARD16 standby, CARD16 suspend, CARD16 off)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSSetTimeoutsReq *req;
+
+ if ((off != 0)&&(off < suspend))
+ {
+ return BadValue;
+ }
+ if ((suspend != 0)&&(suspend < standby))
+ {
+ return BadValue;
+ }
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSSetTimeouts, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSSetTimeouts;
+ req->standby = standby;
+ req->suspend = suspend;
+ req->off = off;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Bool
+DPMSGetTimeouts(Display *dpy, CARD16 *standby, CARD16 *suspend, CARD16 *off)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSGetTimeoutsReq *req;
+ xDPMSGetTimeoutsReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSGetTimeouts, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSGetTimeouts;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *standby = rep.standby;
+ *suspend = rep.suspend;
+ *off = rep.off;
+ return 1;
+}
+
+Status
+DPMSEnable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSEnableReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSEnable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSEnable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+DPMSDisable(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSDisableReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(DPMSDisable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSDisable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status
+DPMSForceLevel(Display *dpy, CARD16 level)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSForceLevelReq *req;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ if ((level != DPMSModeOn) &&
+ (level != DPMSModeStandby) &&
+ (level != DPMSModeSuspend) &&
+ (level != DPMSModeOff))
+ return BadValue;
+
+ LockDisplay(dpy);
+ GetReq(DPMSForceLevel, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSForceLevel;
+ req->level = level;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Status
+DPMSInfo(Display *dpy, CARD16 *power_level, BOOL *state)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xDPMSInfoReq *req;
+ xDPMSInfoReply rep;
+
+ DPMSCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(DPMSInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->dpmsReqType = X_DPMSInfo;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *power_level = rep.power_level;
+ *state = rep.state;
+ return 1;
+}
+
+
+
diff --git a/libXext/src/MITMisc.c b/libXext/src/MITMisc.c
index 606ca6ece..0304bf320 100644
--- a/libXext/src/MITMisc.c
+++ b/libXext/src/MITMisc.c
@@ -1,133 +1,132 @@
-/*
- * $Xorg: MITMisc.c,v 1.4 2001/02/09 02:03:49 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/Xext/MITMisc.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
-
-/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
-
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <X11/extensions/MITMisc.h>
-#include <X11/extensions/mitmiscproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-static XExtensionInfo _mit_info_data;
-static XExtensionInfo *mit_info = &_mit_info_data;
-static /* const */ char *mit_extension_name = MITMISCNAME;
-
-#define MITCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, mit_extension_name, val)
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static /* const */ XExtensionHooks mit_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, mit_info, mit_extension_name,
- &mit_extension_hooks, MITMiscNumberEvents,
- NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, mit_info)
-
-
-/*****************************************************************************
- * *
- * public routines *
- * *
- *****************************************************************************/
-
-Bool XMITMiscQueryExtension (Display *dpy, int *event_basep, int *error_basep)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- return True;
- } else {
- return False;
- }
-}
-
-
-Status XMITMiscSetBugMode(Display *dpy, Bool onOff)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMITSetBugModeReq *req;
-
- MITCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(MITSetBugMode, req);
- req->reqType = info->codes->major_opcode;
- req->mitReqType = X_MITSetBugMode;
- req->onOff = onOff;
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-Bool XMITMiscGetBugMode(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMITGetBugModeReq *req;
- xMITGetBugModeReply rep;
-
- MITCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(MITGetBugMode, req);
- req->reqType = info->codes->major_opcode;
- req->mitReqType = X_MITGetBugMode;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return rep.onOff;
-}
+/*
+ * $Xorg: MITMisc.c,v 1.4 2001/02/09 02:03:49 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/Xext/MITMisc.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
+
+/* RANDOM CRUFT! THIS HAS NO OFFICIAL X CONSORTIUM BLESSING */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/MITMisc.h>
+#include <X11/extensions/mitmiscproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _mit_info_data;
+static XExtensionInfo *mit_info = &_mit_info_data;
+static /* const */ char *mit_extension_name = MITMISCNAME;
+
+#define MITCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, mit_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks mit_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, mit_info, mit_extension_name,
+ &mit_extension_hooks, MITMiscNumberEvents,
+ NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, mit_info)
+
+
+/*****************************************************************************
+ * *
+ * public routines *
+ * *
+ *****************************************************************************/
+
+Bool XMITMiscQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XMITMiscSetBugMode(Display *dpy, Bool onOff)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMITSetBugModeReq *req;
+
+ MITCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(MITSetBugMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->mitReqType = X_MITSetBugMode;
+ req->onOff = onOff;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Bool XMITMiscGetBugMode(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMITGetBugModeReq *req;
+ xMITGetBugModeReply rep;
+
+ MITCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(MITGetBugMode, req);
+ req->reqType = info->codes->major_opcode;
+ req->mitReqType = X_MITGetBugMode;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return rep.onOff;
+}
diff --git a/libXext/src/XAppgroup.c b/libXext/src/XAppgroup.c
index 212e9642c..c533fd25f 100644
--- a/libXext/src/XAppgroup.c
+++ b/libXext/src/XAppgroup.c
@@ -1,392 +1,390 @@
-/* $XFree86: xc/lib/Xext/XAppgroup.c,v 1.11 2002/10/16 02:19:22 dawes Exp $ */
-/*
-
-Copyright 1996, 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.
-
-*/
-/* $Xorg: XAppgroup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#ifdef WIN32
-#include <X11/Xwindows.h>
-#endif
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xag.h>
-#include <X11/extensions/agproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-#include <stdarg.h>
-
-struct xagstuff {
- int attrib_mask;
- Bool app_group_leader;
- Bool single_screen;
- Window default_root;
- VisualID root_visual;
- Colormap default_colormap;
- unsigned long black_pixel;
- unsigned long white_pixel;
-};
-
-static XExtensionInfo _xag_info_data;
-static XExtensionInfo *xag_info = &_xag_info_data;
-static char *xag_extension_name = XAGNAME;
-
-#define XagCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, xag_extension_name, val)
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static /* const */ XExtensionHooks xag_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xag_info,
- xag_extension_name,
- &xag_extension_hooks,
- 0, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xag_info)
-
-
-/*****************************************************************************
- * *
- * public Xag Extension routines *
- * *
- *****************************************************************************/
-
-Bool
-XagQueryVersion(
- Display *dpy,
- int *major_version_return,
- int *minor_version_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXagQueryVersionReply rep;
- xXagQueryVersionReq *req;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagQueryVersion;
- req->client_major_version = XAG_MAJOR_VERSION;
- req->client_minor_version = XAG_MINOR_VERSION;
- if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *major_version_return = rep.server_major_version;
- *minor_version_return = rep.server_minor_version;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-static void
-StuffToWire (Display *dpy, struct xagstuff *stuff, xXagCreateReq *req)
-{
- unsigned long values[8];
- unsigned long* value = values;
- unsigned int nvalues;
-
- /* the order these are in is important */
- if (stuff->attrib_mask & XagSingleScreenMask)
- *value++ = stuff->single_screen;
-
- if (stuff->attrib_mask & XagDefaultRootMask)
- *value++ = stuff->default_root;
-
- if (stuff->attrib_mask & XagRootVisualMask)
- *value++ = stuff->root_visual;
-
- if (stuff->attrib_mask & XagDefaultColormapMask)
- *value++ = stuff->default_colormap;
-
- if (stuff->attrib_mask & XagBlackPixelMask)
- *value++ = stuff->black_pixel;
-
- if (stuff->attrib_mask & XagWhitePixelMask)
- *value++ = stuff->white_pixel;
-
- if (stuff->attrib_mask & XagAppGroupLeaderMask)
- *value++ = stuff->app_group_leader;
-
- req->length += (nvalues = value - values);
-
- nvalues <<= 2;
- Data32 (dpy, (long*) values, (long) nvalues);
-}
-
-Bool
-XagCreateEmbeddedApplicationGroup(
- Display* dpy,
- VisualID root_visual,
- Colormap default_colormap,
- unsigned long black_pixel,
- unsigned long white_pixel,
- XAppGroup* app_group_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXagCreateReq *req;
- struct xagstuff stuff;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- stuff.app_group_leader = True;
- stuff.single_screen = True;
- stuff.default_root = RootWindow (dpy, DefaultScreen(dpy));
- stuff.root_visual = root_visual;
- stuff.default_colormap = default_colormap;
- stuff.attrib_mask =
- XagAppGroupLeaderMask | XagSingleScreenMask | XagDefaultRootMask |
- XagRootVisualMask | XagDefaultColormapMask;
- if (default_colormap != None) {
- stuff.black_pixel = black_pixel;
- stuff.white_pixel = white_pixel;
- stuff.attrib_mask |= XagBlackPixelMask | XagWhitePixelMask;
- }
- /* might do some validation here */
- GetReq(XagCreate, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagCreate;
- *app_group_return = req->app_group = XAllocID(dpy);
- req->attrib_mask = stuff.attrib_mask;
- StuffToWire (dpy, &stuff, req);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Bool
-XagCreateNonembeddedApplicationGroup(
- Display* dpy,
- XAppGroup* app_group_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXagCreateReq *req;
- struct xagstuff stuff;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- stuff.app_group_leader = False;
- stuff.single_screen = False;
- stuff.attrib_mask = XagAppGroupLeaderMask | XagSingleScreenMask;
- /* might do some validation here */
- GetReq(XagCreate, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagCreate;
- *app_group_return = req->app_group = XAllocID(dpy);
- req->attrib_mask = stuff.attrib_mask;
- StuffToWire (dpy, &stuff, req);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Bool XagDestroyApplicationGroup(Display* dpy, XAppGroup app_group)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXagDestroyReq *req;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagDestroy, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagDestroy;
- req->app_group = app_group;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Bool
-XagGetApplicationGroupAttributes(Display* dpy, XAppGroup app_group, ...)
-{
- va_list var;
- XExtDisplayInfo *info = find_display (dpy);
- xXagGetAttrReq *req;
- xXagGetAttrReply rep;
- int attr;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagGetAttr, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagGetAttr;
- req->app_group = app_group;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- va_start (var, app_group);
- for (attr = va_arg(var, int); attr != 0; attr = va_arg(var, int)) {
- void* ptr;
-
- switch (attr) {
- case XagNappGroupLeader:
- ptr = va_arg(var, void*);
- *(Bool*)ptr = rep.app_group_leader;
- break;
- case XagNsingleScreen:
- ptr = va_arg(var, void*);
- *(Bool*)ptr = rep.single_screen;
- break;
- case XagNdefaultRoot:
- ptr = va_arg(var, void*);
- *(Window*)ptr = rep.default_root;
- break;
- case XagNrootVisual:
- ptr = va_arg(var, void*);
- *(VisualID*)ptr = rep.root_visual;
- break;
- case XagNdefaultColormap:
- ptr = va_arg(var, void*);
- *(Colormap*)ptr = rep.default_colormap;
- break;
- case XagNblackPixel:
- ptr = va_arg(var, void*);
- *(unsigned long*)ptr = rep.black_pixel;
- break;
- case XagNwhitePixel:
- ptr = va_arg(var, void*);
- *(unsigned long*)ptr = rep.white_pixel;
- break;
- }
- }
- va_end (var);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Bool
-XagQueryApplicationGroup(
- Display* dpy,
- XID resource,
- XAppGroup* app_group_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXagQueryReq *req;
- xXagQueryReply rep;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagQuery, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagQuery;
- req->resource = resource;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *app_group_return = rep.app_group;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-
-}
-
-Bool
-XagCreateAssociation(Display* dpy, Window* window_return, void* system_window)
-{
-#ifdef WIN32
- long tmp = *(HWND*) system_window;
- XExtDisplayInfo *info = find_display (dpy);
- xXagCreateAssocReq *req;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagCreateAssoc, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagCreateAssoc;
- *window_return = req->window = XAllocID(dpy);
- req->window_type = XagWindowTypeWin32;
- req->system_window_len = sizeof(HWND);
- Data32 (dpy, (long*) tmp, 1L);
- req->length++;
- UnlockDisplay(dpy);
- SyncHandle();
-#else
- /* other platforms go here */
-
- /* this whole thing could be arranged better, but since X need
- * only short-circuit the protocol and WIN32 is the only other
- * platform the XC supports, it will suffice for now.
- */
- *window_return = *(Window*)system_window;
-#endif
- return True;
-}
-
-Bool
-XagDestroyAssociation(Display* dpy, Window window)
-{
-#ifdef WIN32
- XExtDisplayInfo *info = find_display (dpy);
- xXagDestroyAssocReq *req;
-
- XagCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XagDestroyAssoc, req);
- req->reqType = info->codes->major_opcode;
- req->xagReqType = X_XagDestroyAssoc;
- req->window = window;
- UnlockDisplay(dpy);
- SyncHandle();
-#endif
- return True;
-}
-
+/* $XFree86: xc/lib/Xext/XAppgroup.c,v 1.11 2002/10/16 02:19:22 dawes Exp $ */
+/*
+
+Copyright 1996, 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.
+
+*/
+/* $Xorg: XAppgroup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#endif
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xag.h>
+#include <X11/extensions/agproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+#include <stdarg.h>
+
+struct xagstuff {
+ int attrib_mask;
+ Bool app_group_leader;
+ Bool single_screen;
+ Window default_root;
+ VisualID root_visual;
+ Colormap default_colormap;
+ unsigned long black_pixel;
+ unsigned long white_pixel;
+};
+
+static XExtensionInfo _xag_info_data;
+static XExtensionInfo *xag_info = &_xag_info_data;
+static char *xag_extension_name = XAGNAME;
+
+#define XagCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xag_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks xag_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xag_info,
+ xag_extension_name,
+ &xag_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xag_info)
+
+
+/*****************************************************************************
+ * *
+ * public Xag Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool
+XagQueryVersion(
+ Display *dpy,
+ int *major_version_return,
+ int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagQueryVersionReply rep;
+ xXagQueryVersionReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagQueryVersion;
+ req->client_major_version = XAG_MAJOR_VERSION;
+ req->client_minor_version = XAG_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major_version_return = rep.server_major_version;
+ *minor_version_return = rep.server_minor_version;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static void
+StuffToWire (Display *dpy, struct xagstuff *stuff, xXagCreateReq *req)
+{
+ unsigned long values[8];
+ unsigned long* value = values;
+ unsigned int nvalues;
+
+ /* the order these are in is important */
+ if (stuff->attrib_mask & XagSingleScreenMask)
+ *value++ = stuff->single_screen;
+
+ if (stuff->attrib_mask & XagDefaultRootMask)
+ *value++ = stuff->default_root;
+
+ if (stuff->attrib_mask & XagRootVisualMask)
+ *value++ = stuff->root_visual;
+
+ if (stuff->attrib_mask & XagDefaultColormapMask)
+ *value++ = stuff->default_colormap;
+
+ if (stuff->attrib_mask & XagBlackPixelMask)
+ *value++ = stuff->black_pixel;
+
+ if (stuff->attrib_mask & XagWhitePixelMask)
+ *value++ = stuff->white_pixel;
+
+ if (stuff->attrib_mask & XagAppGroupLeaderMask)
+ *value++ = stuff->app_group_leader;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2;
+ Data32 (dpy, (long*) values, (long) nvalues);
+}
+
+Bool
+XagCreateEmbeddedApplicationGroup(
+ Display* dpy,
+ VisualID root_visual,
+ Colormap default_colormap,
+ unsigned long black_pixel,
+ unsigned long white_pixel,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateReq *req;
+ struct xagstuff stuff;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ stuff.app_group_leader = True;
+ stuff.single_screen = True;
+ stuff.default_root = RootWindow (dpy, DefaultScreen(dpy));
+ stuff.root_visual = root_visual;
+ stuff.default_colormap = default_colormap;
+ stuff.attrib_mask =
+ XagAppGroupLeaderMask | XagSingleScreenMask | XagDefaultRootMask |
+ XagRootVisualMask | XagDefaultColormapMask;
+ if (default_colormap != None) {
+ stuff.black_pixel = black_pixel;
+ stuff.white_pixel = white_pixel;
+ stuff.attrib_mask |= XagBlackPixelMask | XagWhitePixelMask;
+ }
+ /* might do some validation here */
+ GetReq(XagCreate, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreate;
+ *app_group_return = req->app_group = XAllocID(dpy);
+ req->attrib_mask = stuff.attrib_mask;
+ StuffToWire (dpy, &stuff, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagCreateNonembeddedApplicationGroup(
+ Display* dpy,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateReq *req;
+ struct xagstuff stuff;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ stuff.app_group_leader = False;
+ stuff.single_screen = False;
+ stuff.attrib_mask = XagAppGroupLeaderMask | XagSingleScreenMask;
+ /* might do some validation here */
+ GetReq(XagCreate, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreate;
+ *app_group_return = req->app_group = XAllocID(dpy);
+ req->attrib_mask = stuff.attrib_mask;
+ StuffToWire (dpy, &stuff, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool XagDestroyApplicationGroup(Display* dpy, XAppGroup app_group)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagDestroyReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagDestroy, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagDestroy;
+ req->app_group = app_group;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagGetApplicationGroupAttributes(Display* dpy, XAppGroup app_group, ...)
+{
+ va_list var;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagGetAttrReq *req;
+ xXagGetAttrReply rep;
+ int attr;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagGetAttr, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagGetAttr;
+ req->app_group = app_group;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ va_start (var, app_group);
+ for (attr = va_arg(var, int); attr != 0; attr = va_arg(var, int)) {
+ void* ptr;
+
+ switch (attr) {
+ case XagNappGroupLeader:
+ ptr = va_arg(var, void*);
+ *(Bool*)ptr = rep.app_group_leader;
+ break;
+ case XagNsingleScreen:
+ ptr = va_arg(var, void*);
+ *(Bool*)ptr = rep.single_screen;
+ break;
+ case XagNdefaultRoot:
+ ptr = va_arg(var, void*);
+ *(Window*)ptr = rep.default_root;
+ break;
+ case XagNrootVisual:
+ ptr = va_arg(var, void*);
+ *(VisualID*)ptr = rep.root_visual;
+ break;
+ case XagNdefaultColormap:
+ ptr = va_arg(var, void*);
+ *(Colormap*)ptr = rep.default_colormap;
+ break;
+ case XagNblackPixel:
+ ptr = va_arg(var, void*);
+ *(unsigned long*)ptr = rep.black_pixel;
+ break;
+ case XagNwhitePixel:
+ ptr = va_arg(var, void*);
+ *(unsigned long*)ptr = rep.white_pixel;
+ break;
+ }
+ }
+ va_end (var);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+XagQueryApplicationGroup(
+ Display* dpy,
+ XID resource,
+ XAppGroup* app_group_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagQueryReq *req;
+ xXagQueryReply rep;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagQuery, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagQuery;
+ req->resource = resource;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *app_group_return = rep.app_group;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+
+}
+
+Bool
+XagCreateAssociation(Display* dpy, Window* window_return, void* system_window)
+{
+#ifdef WIN32
+ long tmp = *(HWND*) system_window;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagCreateAssocReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagCreateAssoc, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagCreateAssoc;
+ *window_return = req->window = XAllocID(dpy);
+ req->window_type = XagWindowTypeWin32;
+ req->system_window_len = sizeof(HWND);
+ Data32 (dpy, (long*) tmp, 1L);
+ req->length++;
+ UnlockDisplay(dpy);
+ SyncHandle();
+#else
+ /* other platforms go here */
+
+ /* this whole thing could be arranged better, but since X need
+ * only short-circuit the protocol and WIN32 is the only other
+ * platform the XC supports, it will suffice for now.
+ */
+ *window_return = *(Window*)system_window;
+#endif
+ return True;
+}
+
+Bool
+XagDestroyAssociation(Display* dpy, Window window)
+{
+#ifdef WIN32
+ XExtDisplayInfo *info = find_display (dpy);
+ xXagDestroyAssocReq *req;
+
+ XagCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XagDestroyAssoc, req);
+ req->reqType = info->codes->major_opcode;
+ req->xagReqType = X_XagDestroyAssoc;
+ req->window = window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+#endif
+ return True;
+}
+
diff --git a/libXext/src/XEVI.c b/libXext/src/XEVI.c
index b357c4fe9..b4e5b77f4 100644
--- a/libXext/src/XEVI.c
+++ b/libXext/src/XEVI.c
@@ -1,216 +1,215 @@
-/* $Xorg: XEVI.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $ */
-/************************************************************
-Copyright (c) 1997 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$ */
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <X11/extensions/XEVI.h>
-#include <X11/extensions/EVIproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <X11/Xutil.h>
-static XExtensionInfo *xevi_info;/* needs to move to globals.c */
-static /* const */ char *xevi_extension_name = EVINAME;
-#define XeviCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, xevi_extension_name, val)
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-static /* const */ XExtensionHooks xevi_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- NULL, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xevi_info,
- xevi_extension_name,
- &xevi_extension_hooks, 0, NULL)
-Bool XeviQueryExtension (Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- if (XextHasExtension(info)) {
- return True;
- } else {
- return False;
- }
-}
-Bool XeviQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xEVIQueryVersionReply rep;
- register xEVIQueryVersionReq *req;
- XeviCheckExtension (dpy, info, False);
- LockDisplay(dpy);
- GetReq(EVIQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->xeviReqType = X_EVIQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *majorVersion = rep.majorVersion;
- *minorVersion = rep.minorVersion;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-static Bool notInList(VisualID32 *visual, int sz_visual, VisualID newVisualid)
-{
- while (sz_visual-- > 0) {
- if (*visual == newVisualid)
- return False;
- visual++;
- }
- return True;
-}
-Status XeviGetVisualInfo(
- register Display *dpy,
- VisualID *visual,
- int n_visual,
- ExtendedVisualInfo **evi_return,
- int *n_info_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xEVIGetVisualInfoReq *req;
- xEVIGetVisualInfoReply rep;
- int sz_info, sz_xInfo, sz_conflict, sz_xConflict;
- VisualID32 *temp_conflict, *temp_visual, *xConflictPtr;
- VisualID *conflict;
- xExtendedVisualInfo *temp_xInfo;
- XVisualInfo *vinfo;
- register ExtendedVisualInfo *infoPtr;
- register xExtendedVisualInfo *xInfoPtr;
- register int n_data, visualIndex, vinfoIndex;
- Bool isValid;
- XeviCheckExtension (dpy, info, 0);
- if (!n_info_return || !evi_return) {
- return BadValue;
- }
- *n_info_return = 0;
- *evi_return = NULL;
- vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info);
- if (!vinfo) {
- return BadValue;
- }
- if (!n_visual || !visual) { /* copy the all visual */
- temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
- n_visual = 0;
- for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
- if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
- temp_visual[n_visual++] = vinfo[vinfoIndex].visualid;
- }
- else { /* check if the visual is valid */
- for (visualIndex = 0; visualIndex < n_visual; visualIndex++) {
- isValid = False;
- for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) {
- if (visual[visualIndex] == vinfo[vinfoIndex].visualid) {
- isValid = True;
- break;
- }
- }
- if (!isValid) {
- XFree(vinfo);
- return BadValue;
- }
- }
- temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
- for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
- temp_visual[visualIndex] = visual[visualIndex];
- }
- XFree(vinfo);
- LockDisplay(dpy);
- GetReq(EVIGetVisualInfo, req);
- req->reqType = info->codes->major_opcode;
- req->xeviReqType = X_EVIGetVisualInfo;
- req->n_visual = n_visual;
- SetReqLen(req, n_visual, 1);
- Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32);
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- Xfree(temp_visual);
- return BadAccess;
- }
- Xfree(temp_visual);
- sz_info = rep.n_info * sizeof(ExtendedVisualInfo);
- sz_xInfo = rep.n_info * sz_xExtendedVisualInfo;
- sz_conflict = rep.n_conflicts * sizeof(VisualID);
- sz_xConflict = rep.n_conflicts * sz_VisualID32;
- infoPtr = *evi_return = (ExtendedVisualInfo *)Xmalloc(sz_info + sz_conflict);
- xInfoPtr = temp_xInfo = (xExtendedVisualInfo *)Xmalloc(sz_xInfo);
- xConflictPtr = temp_conflict = (VisualID32 *)Xmalloc(sz_xConflict);
- if (!*evi_return || !temp_xInfo || !temp_conflict) {
- _XEatData(dpy, (sz_xInfo + sz_xConflict + 3) & ~3);
- UnlockDisplay(dpy);
- SyncHandle();
- if (evi_return)
- Xfree(evi_return);
- if (temp_xInfo)
- Xfree(temp_xInfo);
- if (temp_conflict)
- Xfree(temp_conflict);
- return BadAlloc;
- }
- _XRead(dpy, (char *)temp_xInfo, sz_xInfo);
- _XRead(dpy, (char *)temp_conflict, sz_xConflict);
- UnlockDisplay(dpy);
- SyncHandle();
- n_data = rep.n_info;
- conflict = (VisualID *)(infoPtr + n_data);
- while (n_data-- > 0) {
- infoPtr->core_visual_id = xInfoPtr->core_visual_id;
- infoPtr->screen = xInfoPtr->screen;
- infoPtr->level = xInfoPtr->level;
- infoPtr->transparency_type = xInfoPtr->transparency_type;
- infoPtr->transparency_value = xInfoPtr->transparency_value;
- infoPtr->min_hw_colormaps = xInfoPtr->min_hw_colormaps;
- infoPtr->max_hw_colormaps = xInfoPtr->max_hw_colormaps;
- infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts;
- infoPtr->colormap_conflicts = conflict;
- conflict += infoPtr->num_colormap_conflicts;
- infoPtr++;
- xInfoPtr++;
- }
- n_data = rep.n_conflicts;
- conflict = (VisualID *)(infoPtr);
- while (n_data-- > 0)
- *conflict++ = *xConflictPtr++;
- Xfree(temp_xInfo);
- Xfree(temp_conflict);
- *n_info_return = rep.n_info;
- return Success;
-}
+/* $Xorg: XEVI.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1997 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$ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/extensions/XEVI.h>
+#include <X11/extensions/EVIproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/Xutil.h>
+static XExtensionInfo *xevi_info;/* needs to move to globals.c */
+static /* const */ char *xevi_extension_name = EVINAME;
+#define XeviCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xevi_extension_name, val)
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+static /* const */ XExtensionHooks xevi_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ NULL, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xevi_info,
+ xevi_extension_name,
+ &xevi_extension_hooks, 0, NULL)
+Bool XeviQueryExtension (Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ if (XextHasExtension(info)) {
+ return True;
+ } else {
+ return False;
+ }
+}
+Bool XeviQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xEVIQueryVersionReply rep;
+ register xEVIQueryVersionReq *req;
+ XeviCheckExtension (dpy, info, False);
+ LockDisplay(dpy);
+ GetReq(EVIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xeviReqType = X_EVIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+static Bool notInList(VisualID32 *visual, int sz_visual, VisualID newVisualid)
+{
+ while (sz_visual-- > 0) {
+ if (*visual == newVisualid)
+ return False;
+ visual++;
+ }
+ return True;
+}
+Status XeviGetVisualInfo(
+ register Display *dpy,
+ VisualID *visual,
+ int n_visual,
+ ExtendedVisualInfo **evi_return,
+ int *n_info_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xEVIGetVisualInfoReq *req;
+ xEVIGetVisualInfoReply rep;
+ int sz_info, sz_xInfo, sz_conflict, sz_xConflict;
+ VisualID32 *temp_conflict, *temp_visual, *xConflictPtr;
+ VisualID *conflict;
+ xExtendedVisualInfo *temp_xInfo;
+ XVisualInfo *vinfo;
+ register ExtendedVisualInfo *infoPtr;
+ register xExtendedVisualInfo *xInfoPtr;
+ register int n_data, visualIndex, vinfoIndex;
+ Bool isValid;
+ XeviCheckExtension (dpy, info, 0);
+ if (!n_info_return || !evi_return) {
+ return BadValue;
+ }
+ *n_info_return = 0;
+ *evi_return = NULL;
+ vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info);
+ if (!vinfo) {
+ return BadValue;
+ }
+ if (!n_visual || !visual) { /* copy the all visual */
+ temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
+ n_visual = 0;
+ for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
+ if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
+ temp_visual[n_visual++] = vinfo[vinfoIndex].visualid;
+ }
+ else { /* check if the visual is valid */
+ for (visualIndex = 0; visualIndex < n_visual; visualIndex++) {
+ isValid = False;
+ for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) {
+ if (visual[visualIndex] == vinfo[vinfoIndex].visualid) {
+ isValid = True;
+ break;
+ }
+ }
+ if (!isValid) {
+ XFree(vinfo);
+ return BadValue;
+ }
+ }
+ temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
+ for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
+ temp_visual[visualIndex] = visual[visualIndex];
+ }
+ XFree(vinfo);
+ LockDisplay(dpy);
+ GetReq(EVIGetVisualInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->xeviReqType = X_EVIGetVisualInfo;
+ req->n_visual = n_visual;
+ SetReqLen(req, n_visual, 1);
+ Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(temp_visual);
+ return BadAccess;
+ }
+ Xfree(temp_visual);
+ sz_info = rep.n_info * sizeof(ExtendedVisualInfo);
+ sz_xInfo = rep.n_info * sz_xExtendedVisualInfo;
+ sz_conflict = rep.n_conflicts * sizeof(VisualID);
+ sz_xConflict = rep.n_conflicts * sz_VisualID32;
+ infoPtr = *evi_return = (ExtendedVisualInfo *)Xmalloc(sz_info + sz_conflict);
+ xInfoPtr = temp_xInfo = (xExtendedVisualInfo *)Xmalloc(sz_xInfo);
+ xConflictPtr = temp_conflict = (VisualID32 *)Xmalloc(sz_xConflict);
+ if (!*evi_return || !temp_xInfo || !temp_conflict) {
+ _XEatData(dpy, (sz_xInfo + sz_xConflict + 3) & ~3);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (evi_return)
+ Xfree(evi_return);
+ if (temp_xInfo)
+ Xfree(temp_xInfo);
+ if (temp_conflict)
+ Xfree(temp_conflict);
+ return BadAlloc;
+ }
+ _XRead(dpy, (char *)temp_xInfo, sz_xInfo);
+ _XRead(dpy, (char *)temp_conflict, sz_xConflict);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ n_data = rep.n_info;
+ conflict = (VisualID *)(infoPtr + n_data);
+ while (n_data-- > 0) {
+ infoPtr->core_visual_id = xInfoPtr->core_visual_id;
+ infoPtr->screen = xInfoPtr->screen;
+ infoPtr->level = xInfoPtr->level;
+ infoPtr->transparency_type = xInfoPtr->transparency_type;
+ infoPtr->transparency_value = xInfoPtr->transparency_value;
+ infoPtr->min_hw_colormaps = xInfoPtr->min_hw_colormaps;
+ infoPtr->max_hw_colormaps = xInfoPtr->max_hw_colormaps;
+ infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts;
+ infoPtr->colormap_conflicts = conflict;
+ conflict += infoPtr->num_colormap_conflicts;
+ infoPtr++;
+ xInfoPtr++;
+ }
+ n_data = rep.n_conflicts;
+ conflict = (VisualID *)(infoPtr);
+ while (n_data-- > 0)
+ *conflict++ = *xConflictPtr++;
+ Xfree(temp_xInfo);
+ Xfree(temp_conflict);
+ *n_info_return = rep.n_info;
+ return Success;
+}
diff --git a/libXext/src/XLbx.c b/libXext/src/XLbx.c
index 2cae41614..fc2873be9 100644
--- a/libXext/src/XLbx.c
+++ b/libXext/src/XLbx.c
@@ -1,129 +1,127 @@
-/*
- * $Xorg: XLbx.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $
- *
- * Copyright 1992 Network Computing Devices
- *
- * 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, and that the name of NCD. not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. NCD. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
- * 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.
- *
- * Author: Keith Packard, Network Computing Devices
- */
-/* $XFree86: xc/lib/Xext/XLbx.c,v 1.4 2002/10/16 00:37:27 dawes Exp $ */
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/XLbx.h>
-#include <X11/extensions/lbxproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-static XExtensionInfo _lbx_info_data;
-static XExtensionInfo *lbx_info = &_lbx_info_data;
-static /* const */ char *lbx_extension_name = LBXNAME;
-
-#define LbxCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, lbx_extension_name, val)
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static char *error_string(Display *dpy, int code, XExtCodes *codes,
- char *buf, int n);
-static /* const */ XExtensionHooks lbx_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- error_string, /* error_string */
-};
-
-static /* const */ char *lbx_error_list[] = {
- "BadLbxClient", /* BadLbxClient */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, lbx_info, lbx_extension_name,
- &lbx_extension_hooks, LbxNumberEvents, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, lbx_info)
-
-static XEXT_GENERATE_ERROR_STRING (error_string, lbx_extension_name,
- LbxNumberErrors, lbx_error_list)
-
-
-Bool XLbxQueryExtension (
- Display *dpy,
- int *requestp, int *event_basep, int *error_basep)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- *requestp = info->codes->major_opcode;
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- return True;
- } else {
- return False;
- }
-}
-
-
-int XLbxGetEventBase(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- return info->codes->first_event;
- } else {
- return -1;
- }
-}
-
-
-Bool XLbxQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xLbxQueryVersionReply rep;
- register xLbxQueryVersionReq *req;
-
- LbxCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(LbxQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->lbxReqType = X_LbxQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *majorVersion = rep.majorVersion;
- *minorVersion = rep.minorVersion;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-/* all other requests will run after Xlib has lost the wire ... */
+/*
+ * $Xorg: XLbx.c,v 1.3 2000/08/17 19:45:51 cpqbld Exp $
+ *
+ * Copyright 1992 Network Computing Devices
+ *
+ * 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, and that the name of NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * 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.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+/* $XFree86: xc/lib/Xext/XLbx.c,v 1.4 2002/10/16 00:37:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XLbx.h>
+#include <X11/extensions/lbxproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _lbx_info_data;
+static XExtensionInfo *lbx_info = &_lbx_info_data;
+static /* const */ char *lbx_extension_name = LBXNAME;
+
+#define LbxCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, lbx_extension_name, val)
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+static /* const */ XExtensionHooks lbx_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *lbx_error_list[] = {
+ "BadLbxClient", /* BadLbxClient */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, lbx_info, lbx_extension_name,
+ &lbx_extension_hooks, LbxNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, lbx_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, lbx_extension_name,
+ LbxNumberErrors, lbx_error_list)
+
+
+Bool XLbxQueryExtension (
+ Display *dpy,
+ int *requestp, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *requestp = info->codes->major_opcode;
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+int XLbxGetEventBase(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ return info->codes->first_event;
+ } else {
+ return -1;
+ }
+}
+
+
+Bool XLbxQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xLbxQueryVersionReply rep;
+ register xLbxQueryVersionReq *req;
+
+ LbxCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(LbxQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->lbxReqType = X_LbxQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/* all other requests will run after Xlib has lost the wire ... */
diff --git a/libXext/src/XMultibuf.c b/libXext/src/XMultibuf.c
index edb5fa718..5c9cfc78c 100644
--- a/libXext/src/XMultibuf.c
+++ b/libXext/src/XMultibuf.c
@@ -1,715 +1,713 @@
-/*
- * $Xorg: XMultibuf.c,v 1.6 2001/02/09 02:03:49 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.
- *
- * Authors: Jim Fulton, MIT X Consortium
- */
-/* $XFree86: xc/lib/Xext/XMultibuf.c,v 1.5 2001/12/14 19:55:00 dawes Exp $ */
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <stdio.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <X11/extensions/multibufproto.h>
-#include <X11/extensions/multibuf.h>
-
-static XExtensionInfo _multibuf_info_data;
-static XExtensionInfo *multibuf_info = &_multibuf_info_data;
-static /* const */ char *multibuf_extension_name = MULTIBUFFER_PROTOCOL_NAME;
-
-#define MbufCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, multibuf_extension_name, val)
-#define MbufSimpleCheckExtension(dpy,i) \
- XextSimpleCheckExtension (dpy, i, multibuf_extension_name)
-
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-/*
- * find_display - locate the display info block
- */
-static int close_display(Display *dpy, XExtCodes *codes);
-static char *error_string(Display *dpy, int code, XExtCodes *codes, char *buf, int n);
-static Bool wire_to_event(Display *dpy, XEvent *libevent, xEvent *netevent);
-static Status event_to_wire(Display *dpy, XEvent *libevent, xEvent *netevent);
-static /* const */ XExtensionHooks multibuf_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- wire_to_event, /* wire_to_event */
- event_to_wire, /* event_to_wire */
- NULL, /* error */
- error_string, /* error_string */
-};
-
-static /* const */ char *multibuf_error_list[] = {
- "BadBuffer", /* MultibufferBadBuffer */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, multibuf_info,
- multibuf_extension_name,
- &multibuf_extension_hooks,
- MultibufferNumberEvents, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, multibuf_info)
-
-static XEXT_GENERATE_ERROR_STRING (error_string, multibuf_extension_name,
- MultibufferNumberErrors,
- multibuf_error_list)
-
-/*
- * wire_to_event - convert a wire event in network format to a C
- * event structure
- */
-static Bool wire_to_event (Display *dpy, XEvent *libevent, xEvent *netevent)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- MbufCheckExtension (dpy, info, False);
-
- switch ((netevent->u.u.type & 0x7f) - info->codes->first_event) {
- case MultibufferClobberNotify:
- {
- XmbufClobberNotifyEvent *ev;
- xMbufClobberNotifyEvent *event;
-
- ev = (XmbufClobberNotifyEvent *) libevent;
- event = (xMbufClobberNotifyEvent *) netevent;
- ev->type = event->type & 0x7f;
- ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
- ev->send_event = ((event->type & 0x80) != 0);
- ev->display = dpy;
- ev->buffer = event->buffer;
- ev->state = event->state;
- return True;
- }
- case MultibufferUpdateNotify:
- {
- XmbufUpdateNotifyEvent *ev;
- xMbufUpdateNotifyEvent *event;
-
- ev = (XmbufUpdateNotifyEvent *) libevent;
- event = (xMbufUpdateNotifyEvent *) netevent;
- ev->type = event->type & 0x7f;
- ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
- ev->send_event = ((event->type & 0x80) != 0);
- ev->display = dpy;
- ev->buffer = event->buffer;
- return True;
- }
- }
- return False;
-}
-
-
-/*
- * event_to_wire - convert a C event structure to a wire event in
- * network format
- */
-static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- MbufCheckExtension (dpy, info, 0);
-
- switch ((libevent->type & 0x7f) - info->codes->first_event) {
- case MultibufferClobberNotify:
- {
- XmbufClobberNotifyEvent *ev;
- xMbufClobberNotifyEvent *event;
-
- ev = (XmbufClobberNotifyEvent *) libevent;
- event = (xMbufClobberNotifyEvent *) netevent;
- event->type = ev->type;
- event->sequenceNumber = (ev->serial & 0xffff);
- event->buffer = ev->buffer;
- event->state = ev->state;
- return 1;
- }
- case MultibufferUpdateNotify:
- {
- XmbufUpdateNotifyEvent *ev;
- xMbufUpdateNotifyEvent *event;
-
- ev = (XmbufUpdateNotifyEvent *) libevent;
- event = (xMbufUpdateNotifyEvent *) netevent;
- event->type = ev->type;
- event->sequenceNumber = (ev->serial & 0xffff);
- event->buffer = ev->buffer;
- return 1;
- }
- }
- return 0;
-}
-
-
-/*
- * read_buffer_info - read Buffer Info descriptors from the net; if unable
- * to allocate memory, read junk to make sure that stream is clear.
- */
-#define TALLOC(type,count) ((type *) Xmalloc ((unsigned) count * sizeof(type)))
-
-static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
-{
- xMbufBufferInfo *netbuf = TALLOC (xMbufBufferInfo, nbufs);
- XmbufBufferInfo *bufinfo = NULL;
- long netbytes = nbufs * SIZEOF(xMbufBufferInfo);
-
- if (netbuf) {
- _XRead (dpy, (char *) netbuf, netbytes);
-
- bufinfo = TALLOC (XmbufBufferInfo, nbufs);
- if (bufinfo) {
- register XmbufBufferInfo *c;
- register xMbufBufferInfo *net;
- register int i;
-
- for (i = 0, c = bufinfo, net = netbuf; i < nbufs;
- i++, c++, net++) {
- c->visualid = net->visualID;
- c->max_buffers = net->maxBuffers;
- c->depth = net->depth;
- }
- }
- Xfree ((char *) netbuf);
- } else { /* eat the data */
- while (netbytes > 0) {
- char dummy[256]; /* stack size vs loops tradeoff */
- long nbytes = sizeof dummy;
-
- if (nbytes > netbytes) nbytes = netbytes;
- _XRead (dpy, dummy, nbytes);
- netbytes -= nbytes;
- }
- }
-
- return bufinfo;
-}
-
-#undef TALLOC
-
-
-/*****************************************************************************
- * *
- * Multibuffering/stereo public interfaces *
- * *
- *****************************************************************************/
-
-
-/*
- * XmbufQueryExtension -
- * Returns True if the multibuffering/stereo extension is available
- * on the given display. If the extension exists, the value of the
- * first event code (which should be added to the event type constants
- * MultibufferClobberNotify and MultibufferUpdateNotify to get the
- * actual values) is stored into event_base and the value of the first
- * error code (which should be added to the error type constant
- * MultibufferBadBuffer to get the actual value) is stored into
- * error_base.
- */
-Bool XmbufQueryExtension (
- Display *dpy,
- int *event_base_return, int *error_base_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension (info)) {
- *event_base_return = info->codes->first_event;
- *error_base_return = info->codes->first_error;
- return True;
- } else {
- return False;
- }
-}
-
-
-/*
- * XmbufGetVersion -
- * Gets the major and minor version numbers of the extension. The return
- * value is zero if an error occurs or non-zero if no error happens.
- */
-Status XmbufGetVersion (
- Display *dpy,
- int *major_version_return, int *minor_version_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xMbufGetBufferVersionReply rep;
- register xMbufGetBufferVersionReq *req;
-
- MbufCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- MbufGetReq (MbufGetBufferVersion, req, info);
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- *major_version_return = rep.majorVersion;
- *minor_version_return = rep.minorVersion;
- UnlockDisplay (dpy);
-
- SyncHandle ();
- return 1;
-}
-
-
-/*
- * XmbufCreateBuffers -
- * Requests that "count" buffers be created with the given update_action
- * and update_hint and be associated with the indicated window. The
- * number of buffers created is returned (zero if an error occurred)
- * and buffers_return is filled in with that many Multibuffer identifiers.
- */
-int XmbufCreateBuffers (
- Display *dpy,
- Window w,
- int count,
- int update_action, int update_hint,
- Multibuffer *buffers)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xMbufCreateImageBuffersReply rep;
- register xMbufCreateImageBuffersReq *req;
- int result;
-
- MbufCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
-
- XAllocIDs(dpy, buffers, count);
- MbufGetReq (MbufCreateImageBuffers, req, info);
- req->window = w;
- req->updateAction = update_action;
- req->updateHint = update_hint;
- req->length += count;
- count <<= 2;
- PackData32 (dpy, buffers, count);
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- result = rep.numberBuffer;
- UnlockDisplay (dpy);
-
- SyncHandle ();
- return result;
-}
-
-
-/*
- * XmbufDestroyBuffers -
- * Destroys the buffers associated with the given window.
- */
-void XmbufDestroyBuffers (Display *dpy, Window window)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufDestroyImageBuffersReq *req;
-
- MbufSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- MbufGetReq (MbufDestroyImageBuffers, req, info);
- req->window = window;
- UnlockDisplay (dpy);
- SyncHandle ();
-}
-
-
-/*
- * XmbufDisplayBuffers -
- * Displays the indicated buffers their appropriate windows within
- * max_delay milliseconds after min_delay milliseconds have passed.
- * No two buffers may be associated with the same window or else a Match
- * error is generated.
- */
-void XmbufDisplayBuffers (
- Display *dpy,
- int count,
- Multibuffer *buffers,
- int min_delay, int max_delay)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufDisplayImageBuffersReq *req;
-
- MbufSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- MbufGetReq (MbufDisplayImageBuffers, req, info);
- req->minDelay = min_delay;
- req->maxDelay = max_delay;
- req->length += count;
- count <<= 2;
- PackData32 (dpy, buffers, count);
- UnlockDisplay (dpy);
- SyncHandle();
-}
-
-
-/*
- * XmbufGetWindowAttributes -
- * Gets the multibuffering attributes that apply to all buffers associated
- * with the given window. Returns non-zero on success and zero if an
- * error occurs.
- */
-Status XmbufGetWindowAttributes (
- Display *dpy,
- Window w,
- XmbufWindowAttributes *attr)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufGetMBufferAttributesReq *req;
- xMbufGetMBufferAttributesReply rep;
-
- MbufCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- MbufGetReq (MbufGetMBufferAttributes, req, info);
- req->window = w;
- if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- attr->buffers = (Multibuffer *) NULL;
- if ((attr->nbuffers = rep.length)) {
- int nbytes = rep.length * sizeof(Multibuffer);
- attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes);
- nbytes = rep.length << 2;
- if (! attr->buffers) {
- _XEatData(dpy, (unsigned long) nbytes);
- UnlockDisplay(dpy);
- SyncHandle();
- return (0);
- }
- _XRead32 (dpy, (long *) attr->buffers, nbytes);
- }
- attr->displayed_index = rep.displayedBuffer;
- attr->update_action = rep.updateAction;
- attr->update_hint = rep.updateHint;
- attr->window_mode = rep.windowMode;
-
- UnlockDisplay (dpy);
- SyncHandle();
- return 1;
-}
-
-
-/*
- * XmbufChangeWindowAttributes -
- * Sets the multibuffering attributes that apply to all buffers associated
- * with the given window. This is currently limited to the update_hint.
- */
-void XmbufChangeWindowAttributes (
- Display *dpy,
- Window w,
- unsigned long valuemask,
- XmbufSetWindowAttributes *attr)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufSetMBufferAttributesReq *req;
-
- MbufSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- MbufGetReq (MbufSetMBufferAttributes, req, info);
- req->window = w;
- if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
- unsigned long values[1]; /* one per element in if stmts below */
- unsigned long *v = values;
- unsigned int nvalues;
-
- if (valuemask & MultibufferWindowUpdateHint)
- *v++ = attr->update_hint;
- req->length += (nvalues = v - values);
- nvalues <<= 2; /* watch out for macros... */
- Data32 (dpy, (long *) values, (long)nvalues);
- }
- UnlockDisplay (dpy);
- SyncHandle();
-}
-
-
-/*
- * XmbufGetBufferAttributes -
- * Gets the attributes for the indicated buffer. Returns non-zero on
- * success and zero if an error occurs.
- */
-Status XmbufGetBufferAttributes (
- Display *dpy,
- Multibuffer b,
- XmbufBufferAttributes *attr)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufGetBufferAttributesReq *req;
- xMbufGetBufferAttributesReply rep;
-
- MbufCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- MbufGetReq (MbufGetBufferAttributes, req, info);
- req->buffer = b;
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- attr->window = rep.window;
- attr->event_mask = rep.eventMask;
- attr->buffer_index = rep.bufferIndex;
- attr->side = rep.side;
-
- UnlockDisplay (dpy);
- SyncHandle();
- return 1;
-}
-
-
-/*
- * XmbufChangeBufferAttributes -
- * Sets the attributes for the indicated buffer. This is currently
- * limited to the event_mask.
- */
-void XmbufChangeBufferAttributes (
- Display *dpy,
- Multibuffer b,
- unsigned long valuemask,
- XmbufSetBufferAttributes *attr)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufSetBufferAttributesReq *req;
-
- MbufSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- MbufGetReq (MbufSetBufferAttributes, req, info);
- req->buffer = b;
- if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
- unsigned long values[1]; /* one per element in if stmts below */
- unsigned long *v = values;
- unsigned int nvalues;
-
- if (valuemask & MultibufferBufferEventMask)
- *v++ = attr->event_mask;
- req->length += (nvalues = v - values);
- nvalues <<= 2; /* watch out for macros... */
- Data32 (dpy, (long *) values, (long)nvalues);
- }
- UnlockDisplay (dpy);
- SyncHandle();
-}
-
-
-
-/*
- * XmbufGetScreenInfo -
- * Gets the parameters controlling how mono and stereo windows may be
- * created on the indicated screen. The numbers of sets of visual and
- * depths are returned in nmono_return and nstereo_return. If
- * nmono_return is greater than zero, then mono_info_return is set to
- * the address of an array of XmbufBufferInfo structures describing the
- * various visuals and depths that may be used. Otherwise,
- * mono_info_return is set to NULL. Similarly, stereo_info_return is
- * set according to nstereo_return. The storage returned in
- * mono_info_return and stereo_info_return may be released by XFree.
- * If no errors are encounted, non-zero will be returned.
- */
-Status XmbufGetScreenInfo (
- Display *dpy,
- Drawable d,
- int *nmono_return,
- XmbufBufferInfo **mono_info_return,
- int *nstereo_return,
- XmbufBufferInfo **stereo_info_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufGetBufferInfoReq *req;
- xMbufGetBufferInfoReply rep;
- int nmono, nstereo;
- XmbufBufferInfo *minfo, *sinfo;
-
- MbufCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- MbufGetReq (MbufGetBufferInfo, req, info);
- req->drawable = d;
- if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- nmono = rep.normalInfo;
- nstereo = rep.stereoInfo;
- minfo = ((nmono > 0) ? read_buffer_info (dpy, nmono) : NULL);
- sinfo = ((nstereo > 0) ? read_buffer_info (dpy, nstereo) : NULL);
-
- /* check for bad reads indicating we need to return an error */
- if ((nmono > 0 && !minfo) || (nstereo > 0 && !sinfo)) {
- if (minfo) Xfree ((char *) minfo);
- if (sinfo) Xfree ((char *) sinfo);
- UnlockDisplay (dpy);
- SyncHandle();
- return 0;
- }
-
- *nmono_return = nmono;
- *mono_info_return = minfo;
- *nstereo_return = nstereo;
- *stereo_info_return = sinfo;
-
- UnlockDisplay (dpy);
- SyncHandle();
- return 1;
-}
-
-
-/*
- * XmbufCreateStereoWindow -
- * Creates a stereo window in the same way that XCreateWindow creates
- * a mono window (in fact, use the same code, except for the request)
- * and returns the left and right buffers that may be
- */
-Window XmbufCreateStereoWindow (
- Display *dpy,
- 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 *attr,
- Multibuffer *leftp, Multibuffer *rightp)
-{
- XExtDisplayInfo *info = find_display (dpy);
- Window wid;
- register xMbufCreateStereoWindowReq *req;
-
- MbufCheckExtension (dpy, info, None);
-
- LockDisplay(dpy);
- MbufGetReq(MbufCreateStereoWindow, req, info);
- wid = req->wid = XAllocID(dpy);
- req->parent = parent;
- req->left = *leftp = XAllocID (dpy);
- req->right = *rightp = XAllocID (dpy);
- req->x = x;
- req->y = y;
- req->width = width;
- req->height = height;
- req->borderWidth = border_width;
- req->depth = depth;
- req->class = class;
- if (visual == (Visual *)CopyFromParent)
- req->visual = CopyFromParent;
- else
- req->visual = visual->visualid;
- valuemask &= (CWBackPixmap|CWBackPixel|CWBorderPixmap|
- CWBorderPixel|CWBitGravity|CWWinGravity|
- CWBackingStore|CWBackingPlanes|CWBackingPixel|
- CWOverrideRedirect|CWSaveUnder|CWEventMask|
- CWDontPropagate|CWColormap|CWCursor);
- if ((req->mask = valuemask)) {
- unsigned long values[32];
- register unsigned long *value = values;
- unsigned int nvalues;
-
- if (valuemask & CWBackPixmap)
- *value++ = attr->background_pixmap;
- if (valuemask & CWBackPixel)
- *value++ = attr->background_pixel;
- if (valuemask & CWBorderPixmap)
- *value++ = attr->border_pixmap;
- if (valuemask & CWBorderPixel)
- *value++ = attr->border_pixel;
- if (valuemask & CWBitGravity)
- *value++ = attr->bit_gravity;
- if (valuemask & CWWinGravity)
- *value++ = attr->win_gravity;
- if (valuemask & CWBackingStore)
- *value++ = attr->backing_store;
- if (valuemask & CWBackingPlanes)
- *value++ = attr->backing_planes;
- if (valuemask & CWBackingPixel)
- *value++ = attr->backing_pixel;
- if (valuemask & CWOverrideRedirect)
- *value++ = attr->override_redirect;
- if (valuemask & CWSaveUnder)
- *value++ = attr->save_under;
- if (valuemask & CWEventMask)
- *value++ = attr->event_mask;
- if (valuemask & CWDontPropagate)
- *value++ = attr->do_not_propagate_mask;
- if (valuemask & CWColormap)
- *value++ = attr->colormap;
- if (valuemask & CWCursor)
- *value++ = attr->cursor;
- req->length += (nvalues = value - values);
-
- nvalues <<= 2; /* watch out for macros... */
- Data32 (dpy, (long *) values, (long)nvalues);
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return wid;
-}
-
-void XmbufClearBufferArea (
- Display *dpy,
- Multibuffer buffer,
- int x, int y,
- unsigned int width, unsigned int height,
- Bool exposures)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xMbufClearImageBufferAreaReq *req;
-
- MbufSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- MbufGetReq (MbufClearImageBufferArea, req, info);
- req->buffer = buffer;
- req->x = x;
- req->y = y;
- req->width = width;
- req->height = height;
- req->exposures = exposures;
- UnlockDisplay (dpy);
- SyncHandle();
-}
-
+/*
+ * $Xorg: XMultibuf.c,v 1.6 2001/02/09 02:03:49 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.
+ *
+ * Authors: Jim Fulton, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XMultibuf.c,v 1.5 2001/12/14 19:55:00 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <stdio.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/multibufproto.h>
+#include <X11/extensions/multibuf.h>
+
+static XExtensionInfo _multibuf_info_data;
+static XExtensionInfo *multibuf_info = &_multibuf_info_data;
+static /* const */ char *multibuf_extension_name = MULTIBUFFER_PROTOCOL_NAME;
+
+#define MbufCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, multibuf_extension_name, val)
+#define MbufSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, multibuf_extension_name)
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * find_display - locate the display info block
+ */
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes, char *buf, int n);
+static Bool wire_to_event(Display *dpy, XEvent *libevent, xEvent *netevent);
+static Status event_to_wire(Display *dpy, XEvent *libevent, xEvent *netevent);
+static /* const */ XExtensionHooks multibuf_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *multibuf_error_list[] = {
+ "BadBuffer", /* MultibufferBadBuffer */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, multibuf_info,
+ multibuf_extension_name,
+ &multibuf_extension_hooks,
+ MultibufferNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, multibuf_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, multibuf_extension_name,
+ MultibufferNumberErrors,
+ multibuf_error_list)
+
+/*
+ * wire_to_event - convert a wire event in network format to a C
+ * event structure
+ */
+static Bool wire_to_event (Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ MbufCheckExtension (dpy, info, False);
+
+ switch ((netevent->u.u.type & 0x7f) - info->codes->first_event) {
+ case MultibufferClobberNotify:
+ {
+ XmbufClobberNotifyEvent *ev;
+ xMbufClobberNotifyEvent *event;
+
+ ev = (XmbufClobberNotifyEvent *) libevent;
+ event = (xMbufClobberNotifyEvent *) netevent;
+ ev->type = event->type & 0x7f;
+ ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
+ ev->send_event = ((event->type & 0x80) != 0);
+ ev->display = dpy;
+ ev->buffer = event->buffer;
+ ev->state = event->state;
+ return True;
+ }
+ case MultibufferUpdateNotify:
+ {
+ XmbufUpdateNotifyEvent *ev;
+ xMbufUpdateNotifyEvent *event;
+
+ ev = (XmbufUpdateNotifyEvent *) libevent;
+ event = (xMbufUpdateNotifyEvent *) netevent;
+ ev->type = event->type & 0x7f;
+ ev->serial = _XSetLastRequestRead(dpy,(xGenericReply *) netevent);
+ ev->send_event = ((event->type & 0x80) != 0);
+ ev->display = dpy;
+ ev->buffer = event->buffer;
+ return True;
+ }
+ }
+ return False;
+}
+
+
+/*
+ * event_to_wire - convert a C event structure to a wire event in
+ * network format
+ */
+static Status event_to_wire (Display *dpy, XEvent *libevent, xEvent *netevent)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ MbufCheckExtension (dpy, info, 0);
+
+ switch ((libevent->type & 0x7f) - info->codes->first_event) {
+ case MultibufferClobberNotify:
+ {
+ XmbufClobberNotifyEvent *ev;
+ xMbufClobberNotifyEvent *event;
+
+ ev = (XmbufClobberNotifyEvent *) libevent;
+ event = (xMbufClobberNotifyEvent *) netevent;
+ event->type = ev->type;
+ event->sequenceNumber = (ev->serial & 0xffff);
+ event->buffer = ev->buffer;
+ event->state = ev->state;
+ return 1;
+ }
+ case MultibufferUpdateNotify:
+ {
+ XmbufUpdateNotifyEvent *ev;
+ xMbufUpdateNotifyEvent *event;
+
+ ev = (XmbufUpdateNotifyEvent *) libevent;
+ event = (xMbufUpdateNotifyEvent *) netevent;
+ event->type = ev->type;
+ event->sequenceNumber = (ev->serial & 0xffff);
+ event->buffer = ev->buffer;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * read_buffer_info - read Buffer Info descriptors from the net; if unable
+ * to allocate memory, read junk to make sure that stream is clear.
+ */
+#define TALLOC(type,count) ((type *) Xmalloc ((unsigned) count * sizeof(type)))
+
+static XmbufBufferInfo *read_buffer_info (Display *dpy, int nbufs)
+{
+ xMbufBufferInfo *netbuf = TALLOC (xMbufBufferInfo, nbufs);
+ XmbufBufferInfo *bufinfo = NULL;
+ long netbytes = nbufs * SIZEOF(xMbufBufferInfo);
+
+ if (netbuf) {
+ _XRead (dpy, (char *) netbuf, netbytes);
+
+ bufinfo = TALLOC (XmbufBufferInfo, nbufs);
+ if (bufinfo) {
+ register XmbufBufferInfo *c;
+ register xMbufBufferInfo *net;
+ register int i;
+
+ for (i = 0, c = bufinfo, net = netbuf; i < nbufs;
+ i++, c++, net++) {
+ c->visualid = net->visualID;
+ c->max_buffers = net->maxBuffers;
+ c->depth = net->depth;
+ }
+ }
+ Xfree ((char *) netbuf);
+ } else { /* eat the data */
+ while (netbytes > 0) {
+ char dummy[256]; /* stack size vs loops tradeoff */
+ long nbytes = sizeof dummy;
+
+ if (nbytes > netbytes) nbytes = netbytes;
+ _XRead (dpy, dummy, nbytes);
+ netbytes -= nbytes;
+ }
+ }
+
+ return bufinfo;
+}
+
+#undef TALLOC
+
+
+/*****************************************************************************
+ * *
+ * Multibuffering/stereo public interfaces *
+ * *
+ *****************************************************************************/
+
+
+/*
+ * XmbufQueryExtension -
+ * Returns True if the multibuffering/stereo extension is available
+ * on the given display. If the extension exists, the value of the
+ * first event code (which should be added to the event type constants
+ * MultibufferClobberNotify and MultibufferUpdateNotify to get the
+ * actual values) is stored into event_base and the value of the first
+ * error code (which should be added to the error type constant
+ * MultibufferBadBuffer to get the actual value) is stored into
+ * error_base.
+ */
+Bool XmbufQueryExtension (
+ Display *dpy,
+ int *event_base_return, int *error_base_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension (info)) {
+ *event_base_return = info->codes->first_event;
+ *error_base_return = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+/*
+ * XmbufGetVersion -
+ * Gets the major and minor version numbers of the extension. The return
+ * value is zero if an error occurs or non-zero if no error happens.
+ */
+Status XmbufGetVersion (
+ Display *dpy,
+ int *major_version_return, int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xMbufGetBufferVersionReply rep;
+ register xMbufGetBufferVersionReq *req;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferVersion, req, info);
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+ return 1;
+}
+
+
+/*
+ * XmbufCreateBuffers -
+ * Requests that "count" buffers be created with the given update_action
+ * and update_hint and be associated with the indicated window. The
+ * number of buffers created is returned (zero if an error occurred)
+ * and buffers_return is filled in with that many Multibuffer identifiers.
+ */
+int XmbufCreateBuffers (
+ Display *dpy,
+ Window w,
+ int count,
+ int update_action, int update_hint,
+ Multibuffer *buffers)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xMbufCreateImageBuffersReply rep;
+ register xMbufCreateImageBuffersReq *req;
+ int result;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+
+ XAllocIDs(dpy, buffers, count);
+ MbufGetReq (MbufCreateImageBuffers, req, info);
+ req->window = w;
+ req->updateAction = update_action;
+ req->updateHint = update_hint;
+ req->length += count;
+ count <<= 2;
+ PackData32 (dpy, buffers, count);
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ result = rep.numberBuffer;
+ UnlockDisplay (dpy);
+
+ SyncHandle ();
+ return result;
+}
+
+
+/*
+ * XmbufDestroyBuffers -
+ * Destroys the buffers associated with the given window.
+ */
+void XmbufDestroyBuffers (Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufDestroyImageBuffersReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufDestroyImageBuffers, req, info);
+ req->window = window;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+
+/*
+ * XmbufDisplayBuffers -
+ * Displays the indicated buffers their appropriate windows within
+ * max_delay milliseconds after min_delay milliseconds have passed.
+ * No two buffers may be associated with the same window or else a Match
+ * error is generated.
+ */
+void XmbufDisplayBuffers (
+ Display *dpy,
+ int count,
+ Multibuffer *buffers,
+ int min_delay, int max_delay)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufDisplayImageBuffersReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufDisplayImageBuffers, req, info);
+ req->minDelay = min_delay;
+ req->maxDelay = max_delay;
+ req->length += count;
+ count <<= 2;
+ PackData32 (dpy, buffers, count);
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+/*
+ * XmbufGetWindowAttributes -
+ * Gets the multibuffering attributes that apply to all buffers associated
+ * with the given window. Returns non-zero on success and zero if an
+ * error occurs.
+ */
+Status XmbufGetWindowAttributes (
+ Display *dpy,
+ Window w,
+ XmbufWindowAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetMBufferAttributesReq *req;
+ xMbufGetMBufferAttributesReply rep;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetMBufferAttributes, req, info);
+ req->window = w;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ attr->buffers = (Multibuffer *) NULL;
+ if ((attr->nbuffers = rep.length)) {
+ int nbytes = rep.length * sizeof(Multibuffer);
+ attr->buffers = (Multibuffer *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.length << 2;
+ if (! attr->buffers) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ _XRead32 (dpy, (long *) attr->buffers, nbytes);
+ }
+ attr->displayed_index = rep.displayedBuffer;
+ attr->update_action = rep.updateAction;
+ attr->update_hint = rep.updateHint;
+ attr->window_mode = rep.windowMode;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufChangeWindowAttributes -
+ * Sets the multibuffering attributes that apply to all buffers associated
+ * with the given window. This is currently limited to the update_hint.
+ */
+void XmbufChangeWindowAttributes (
+ Display *dpy,
+ Window w,
+ unsigned long valuemask,
+ XmbufSetWindowAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufSetMBufferAttributesReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufSetMBufferAttributes, req, info);
+ req->window = w;
+ if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
+ unsigned long values[1]; /* one per element in if stmts below */
+ unsigned long *v = values;
+ unsigned int nvalues;
+
+ if (valuemask & MultibufferWindowUpdateHint)
+ *v++ = attr->update_hint;
+ req->length += (nvalues = v - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+/*
+ * XmbufGetBufferAttributes -
+ * Gets the attributes for the indicated buffer. Returns non-zero on
+ * success and zero if an error occurs.
+ */
+Status XmbufGetBufferAttributes (
+ Display *dpy,
+ Multibuffer b,
+ XmbufBufferAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetBufferAttributesReq *req;
+ xMbufGetBufferAttributesReply rep;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferAttributes, req, info);
+ req->buffer = b;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ attr->window = rep.window;
+ attr->event_mask = rep.eventMask;
+ attr->buffer_index = rep.bufferIndex;
+ attr->side = rep.side;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufChangeBufferAttributes -
+ * Sets the attributes for the indicated buffer. This is currently
+ * limited to the event_mask.
+ */
+void XmbufChangeBufferAttributes (
+ Display *dpy,
+ Multibuffer b,
+ unsigned long valuemask,
+ XmbufSetBufferAttributes *attr)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufSetBufferAttributesReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufSetBufferAttributes, req, info);
+ req->buffer = b;
+ if ((req->valueMask = valuemask)) { /* stolen from lib/X/XWindow.c */
+ unsigned long values[1]; /* one per element in if stmts below */
+ unsigned long *v = values;
+ unsigned int nvalues;
+
+ if (valuemask & MultibufferBufferEventMask)
+ *v++ = attr->event_mask;
+ req->length += (nvalues = v - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
+
+
+/*
+ * XmbufGetScreenInfo -
+ * Gets the parameters controlling how mono and stereo windows may be
+ * created on the indicated screen. The numbers of sets of visual and
+ * depths are returned in nmono_return and nstereo_return. If
+ * nmono_return is greater than zero, then mono_info_return is set to
+ * the address of an array of XmbufBufferInfo structures describing the
+ * various visuals and depths that may be used. Otherwise,
+ * mono_info_return is set to NULL. Similarly, stereo_info_return is
+ * set according to nstereo_return. The storage returned in
+ * mono_info_return and stereo_info_return may be released by XFree.
+ * If no errors are encounted, non-zero will be returned.
+ */
+Status XmbufGetScreenInfo (
+ Display *dpy,
+ Drawable d,
+ int *nmono_return,
+ XmbufBufferInfo **mono_info_return,
+ int *nstereo_return,
+ XmbufBufferInfo **stereo_info_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufGetBufferInfoReq *req;
+ xMbufGetBufferInfoReply rep;
+ int nmono, nstereo;
+ XmbufBufferInfo *minfo, *sinfo;
+
+ MbufCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufGetBufferInfo, req, info);
+ req->drawable = d;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ nmono = rep.normalInfo;
+ nstereo = rep.stereoInfo;
+ minfo = ((nmono > 0) ? read_buffer_info (dpy, nmono) : NULL);
+ sinfo = ((nstereo > 0) ? read_buffer_info (dpy, nstereo) : NULL);
+
+ /* check for bad reads indicating we need to return an error */
+ if ((nmono > 0 && !minfo) || (nstereo > 0 && !sinfo)) {
+ if (minfo) Xfree ((char *) minfo);
+ if (sinfo) Xfree ((char *) sinfo);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ *nmono_return = nmono;
+ *mono_info_return = minfo;
+ *nstereo_return = nstereo;
+ *stereo_info_return = sinfo;
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+/*
+ * XmbufCreateStereoWindow -
+ * Creates a stereo window in the same way that XCreateWindow creates
+ * a mono window (in fact, use the same code, except for the request)
+ * and returns the left and right buffers that may be
+ */
+Window XmbufCreateStereoWindow (
+ Display *dpy,
+ 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 *attr,
+ Multibuffer *leftp, Multibuffer *rightp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ Window wid;
+ register xMbufCreateStereoWindowReq *req;
+
+ MbufCheckExtension (dpy, info, None);
+
+ LockDisplay(dpy);
+ MbufGetReq(MbufCreateStereoWindow, req, info);
+ wid = req->wid = XAllocID(dpy);
+ req->parent = parent;
+ req->left = *leftp = XAllocID (dpy);
+ req->right = *rightp = XAllocID (dpy);
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = border_width;
+ req->depth = depth;
+ req->class = class;
+ if (visual == (Visual *)CopyFromParent)
+ req->visual = CopyFromParent;
+ else
+ req->visual = visual->visualid;
+ valuemask &= (CWBackPixmap|CWBackPixel|CWBorderPixmap|
+ CWBorderPixel|CWBitGravity|CWWinGravity|
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|
+ CWDontPropagate|CWColormap|CWCursor);
+ if ((req->mask = valuemask)) {
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CWBackPixmap)
+ *value++ = attr->background_pixmap;
+ if (valuemask & CWBackPixel)
+ *value++ = attr->background_pixel;
+ if (valuemask & CWBorderPixmap)
+ *value++ = attr->border_pixmap;
+ if (valuemask & CWBorderPixel)
+ *value++ = attr->border_pixel;
+ if (valuemask & CWBitGravity)
+ *value++ = attr->bit_gravity;
+ if (valuemask & CWWinGravity)
+ *value++ = attr->win_gravity;
+ if (valuemask & CWBackingStore)
+ *value++ = attr->backing_store;
+ if (valuemask & CWBackingPlanes)
+ *value++ = attr->backing_planes;
+ if (valuemask & CWBackingPixel)
+ *value++ = attr->backing_pixel;
+ if (valuemask & CWOverrideRedirect)
+ *value++ = attr->override_redirect;
+ if (valuemask & CWSaveUnder)
+ *value++ = attr->save_under;
+ if (valuemask & CWEventMask)
+ *value++ = attr->event_mask;
+ if (valuemask & CWDontPropagate)
+ *value++ = attr->do_not_propagate_mask;
+ if (valuemask & CWColormap)
+ *value++ = attr->colormap;
+ if (valuemask & CWCursor)
+ *value++ = attr->cursor;
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return wid;
+}
+
+void XmbufClearBufferArea (
+ Display *dpy,
+ Multibuffer buffer,
+ int x, int y,
+ unsigned int width, unsigned int height,
+ Bool exposures)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xMbufClearImageBufferAreaReq *req;
+
+ MbufSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ MbufGetReq (MbufClearImageBufferArea, req, info);
+ req->buffer = buffer;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->exposures = exposures;
+ UnlockDisplay (dpy);
+ SyncHandle();
+}
+
diff --git a/libXext/src/XShape.c b/libXext/src/XShape.c
index 9437efa4a..2810a4dc1 100644
--- a/libXext/src/XShape.c
+++ b/libXext/src/XShape.c
@@ -1,491 +1,490 @@
-/*
- * $Xorg: XShape.c,v 1.4 2001/02/09 02:03:49 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.
- *
- * Author: Keith Packard, MIT X Consortium
- */
-/* $XFree86: xc/lib/Xext/XShape.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <X11/Xutil.h>
-#include <X11/Xregion.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <X11/extensions/shape.h>
-#include <X11/extensions/shapeproto.h>
-
-static XExtensionInfo _shape_info_data;
-static XExtensionInfo *shape_info = &_shape_info_data;
-static /* const */ char *shape_extension_name = SHAPENAME;
-
-#define ShapeCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, shape_extension_name, val)
-#define ShapeSimpleCheckExtension(dpy,i) \
- XextSimpleCheckExtension (dpy, i, shape_extension_name)
-
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
-static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
-static /* const */ XExtensionHooks shape_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- wire_to_event, /* wire_to_event */
- event_to_wire, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, shape_info,
- shape_extension_name,
- &shape_extension_hooks,
- ShapeNumberEvents, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shape_info)
-
-
-static Bool
-wire_to_event (Display *dpy, XEvent *re, xEvent *event)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShapeEvent *se;
- xShapeNotifyEvent *sevent;
-
- ShapeCheckExtension (dpy, info, False);
-
- switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
- case ShapeNotify:
- se = (XShapeEvent *) re;
- sevent = (xShapeNotifyEvent *) event;
- se->type = sevent->type & 0x7f;
- se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
- se->send_event = (sevent->type & 0x80) != 0;
- se->display = dpy;
- se->window = sevent->window;
- se->kind = sevent->kind;
- se->x = cvtINT16toInt (sevent->x);
- se->y = cvtINT16toInt (sevent->y);
- se->width = sevent->width;
- se->height = sevent->height;
- se->time = sevent->time;
- se->shaped = True;
- if (sevent->shaped == xFalse)
- se->shaped = False;
- return True;
- }
- return False;
-}
-
-static Status
-event_to_wire (Display *dpy, XEvent *re, xEvent *event)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShapeEvent *se;
- xShapeNotifyEvent *sevent;
-
- ShapeCheckExtension (dpy, info, 0);
-
- switch ((re->type & 0x7f) - info->codes->first_event) {
- case ShapeNotify:
- se = (XShapeEvent *) re;
- sevent = (xShapeNotifyEvent *) event;
- sevent->type = se->type | (se->send_event ? 0x80 : 0);
- sevent->sequenceNumber = se->serial & 0xffff;
- sevent->window = se->window;
- sevent->kind = se->kind;
- sevent->x = se->x;
- sevent->y = se->y;
- sevent->width = se->width;
- sevent->height = se->height;
- sevent->time = se->time;
- return 1;
- }
- return 0;
-}
-
-
-/****************************************************************************
- * *
- * Shape public interfaces *
- * *
- ****************************************************************************/
-
-Bool XShapeQueryExtension (Display *dpy, int *event_basep, int *error_basep)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- return True;
- } else {
- return False;
- }
-}
-
-
-Status XShapeQueryVersion(
- Display *dpy,
- int *major_versionp,
- int *minor_versionp)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xShapeQueryVersionReply rep;
- register xShapeQueryVersionReq *req;
-
- ShapeCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- GetReq (ShapeQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeQueryVersion;
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- *major_versionp = rep.majorVersion;
- *minor_versionp = rep.minorVersion;
- UnlockDisplay (dpy);
- SyncHandle ();
- return 1;
-}
-
-void XShapeCombineRegion(
- register Display *dpy,
- Window dest,
- int destKind, int xOff, int yOff,
- register REGION *r,
- int op)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeRectanglesReq *req;
- register long nbytes;
- register int i;
- register XRectangle *xr, *pr;
- register BOX *pb;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay(dpy);
- GetReq(ShapeRectangles, req);
- xr = (XRectangle *)
- _XAllocScratch(dpy, (unsigned long)(r->numRects * sizeof (XRectangle)));
- for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
- pr->x = pb->x1;
- pr->y = pb->y1;
- pr->width = pb->x2 - pb->x1;
- pr->height = pb->y2 - pb->y1;
- }
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeRectangles;
- req->op = op;
- req->ordering = YXBanded;
- req->destKind = destKind;
- req->dest = dest;
- req->xOff = xOff;
- req->yOff = yOff;
-
- /* SIZEOF(xRectangle) will be a multiple of 4 */
- req->length += r->numRects * (SIZEOF(xRectangle) / 4);
-
- nbytes = r->numRects * sizeof(xRectangle);
-
- Data16 (dpy, (short *) xr, nbytes);
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-
-void XShapeCombineRectangles (
- register Display *dpy,
- XID dest,
- int destKind, int xOff, int yOff,
- XRectangle *rects,
- int n_rects,
- int op, int ordering)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeRectanglesReq *req;
- register long nbytes;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay(dpy);
- GetReq(ShapeRectangles, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeRectangles;
- req->op = op;
- req->ordering = ordering;
- req->destKind = destKind;
- req->dest = dest;
- req->xOff = xOff;
- req->yOff = yOff;
-
- /* SIZEOF(xRectangle) will be a multiple of 4 */
- req->length += n_rects * (SIZEOF(xRectangle) / 4);
-
- nbytes = n_rects * sizeof(xRectangle);
-
- Data16 (dpy, (short *) rects, nbytes);
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-
-void XShapeCombineMask (
- register Display *dpy,
- XID dest,
- int destKind,
- int xOff, int yOff,
- Pixmap src,
- int op)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeMaskReq *req;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay(dpy);
- GetReq(ShapeMask, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeMask;
- req->op = op;
- req->destKind = destKind;
- req->dest = dest;
- req->xOff = xOff;
- req->yOff = yOff;
- req->src = src;
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-void XShapeCombineShape (
- register Display *dpy,
- XID dest,
- int destKind,
- int xOff, int yOff,
- XID src,
- int srcKind,
- int op)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeCombineReq *req;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay(dpy);
- GetReq(ShapeCombine, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeCombine;
- req->op = op;
- req->destKind = destKind;
- req->srcKind = srcKind;
- req->dest = dest;
- req->xOff = xOff;
- req->yOff = yOff;
- req->src = src;
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-void XShapeOffsetShape (
- register Display *dpy,
- XID dest,
- int destKind,
- int xOff, int yOff)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeOffsetReq *req;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay(dpy);
- GetReq(ShapeOffset, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeOffset;
- req->destKind = destKind;
- req->dest = dest;
- req->xOff = xOff;
- req->yOff = yOff;
- UnlockDisplay(dpy);
- SyncHandle();
-}
-
-Status XShapeQueryExtents (
- register Display *dpy,
- Window window,
- int *bShaped, int *xbs, int *ybs, unsigned int *wbs, unsigned int *hbs, /* RETURN */
- int *cShaped, int *xcs, int *ycs, unsigned int *wcs, unsigned int *hcs /* RETURN */)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xShapeQueryExtentsReply rep;
- register xShapeQueryExtentsReq *req;
-
- ShapeCheckExtension (dpy, info, 0);
-
- LockDisplay (dpy);
- GetReq (ShapeQueryExtents, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeQueryExtents;
- req->window = window;
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return 0;
- }
- *bShaped = rep.boundingShaped;
- *cShaped = rep.clipShaped;
- *xbs = cvtINT16toInt (rep.xBoundingShape);
- *ybs = cvtINT16toInt (rep.yBoundingShape);
- *wbs = rep.widthBoundingShape;
- *hbs = rep.heightBoundingShape;
- *xcs = cvtINT16toInt (rep.xClipShape);
- *ycs = cvtINT16toInt (rep.yClipShape);
- *wcs = rep.widthClipShape;
- *hcs = rep.heightClipShape;
- UnlockDisplay (dpy);
- SyncHandle ();
- return 1;
-}
-
-
-void XShapeSelectInput (
- register Display *dpy,
- Window window,
- unsigned long mask)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeSelectInputReq *req;
-
- ShapeSimpleCheckExtension (dpy, info);
-
- LockDisplay (dpy);
- GetReq (ShapeSelectInput, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeSelectInput;
- req->window = window;
- if (mask & ShapeNotifyMask)
- req->enable = xTrue;
- else
- req->enable = xFalse;
- UnlockDisplay (dpy);
- SyncHandle ();
-}
-
-unsigned long XShapeInputSelected (register Display *dpy, Window window)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeInputSelectedReq *req;
- xShapeInputSelectedReply rep;
-
- ShapeCheckExtension (dpy, info, False);
-
- LockDisplay (dpy);
- GetReq (ShapeInputSelected, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeInputSelected;
- req->window = window;
- if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return False;
- }
- UnlockDisplay (dpy);
- SyncHandle ();
- return rep.enabled ? ShapeNotifyMask : 0L;
-}
-
-
-XRectangle *XShapeGetRectangles (
- register Display *dpy,
- Window window,
- int kind,
- int *count, /* RETURN */
- int *ordering /* RETURN */)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShapeGetRectanglesReq *req;
- xShapeGetRectanglesReply rep;
- XRectangle *rects;
- xRectangle *xrects;
- int i;
-
- ShapeCheckExtension (dpy, info, (XRectangle *)NULL);
-
- LockDisplay (dpy);
- GetReq (ShapeGetRectangles, req);
- req->reqType = info->codes->major_opcode;
- req->shapeReqType = X_ShapeGetRectangles;
- req->window = window;
- req->kind = kind;
- if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
- UnlockDisplay (dpy);
- SyncHandle ();
- return (XRectangle *)NULL;
- }
- *count = rep.nrects;
- *ordering = rep.ordering;
- rects = NULL;
- if (*count) {
- xrects = (xRectangle *) Xmalloc (*count * sizeof (xRectangle));
- rects = (XRectangle *) Xmalloc (*count * sizeof (XRectangle));
- if (!xrects || !rects) {
- if (xrects)
- Xfree (xrects);
- if (rects)
- Xfree (rects);
- _XEatData (dpy, *count * sizeof (xRectangle));
- rects = NULL;
- *count = 0;
- } else {
- _XRead (dpy, (char *) xrects, *count * sizeof (xRectangle));
- for (i = 0; i < *count; i++) {
- rects[i].x = (short) cvtINT16toInt (xrects[i].x);
- rects[i].y = (short) cvtINT16toInt (xrects[i].y);
- rects[i].width = xrects[i].width;
- rects[i].height = xrects[i].height;
- }
- Xfree (xrects);
- }
- }
- UnlockDisplay (dpy);
- SyncHandle ();
- return rects;
-}
+/*
+ * $Xorg: XShape.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XShape.c,v 1.3 2002/10/16 00:37:27 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xregion.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/shape.h>
+#include <X11/extensions/shapeproto.h>
+
+static XExtensionInfo _shape_info_data;
+static XExtensionInfo *shape_info = &_shape_info_data;
+static /* const */ char *shape_extension_name = SHAPENAME;
+
+#define ShapeCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, shape_extension_name, val)
+#define ShapeSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension (dpy, i, shape_extension_name)
+
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
+static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
+static /* const */ XExtensionHooks shape_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, shape_info,
+ shape_extension_name,
+ &shape_extension_hooks,
+ ShapeNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shape_info)
+
+
+static Bool
+wire_to_event (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShapeEvent *se;
+ xShapeNotifyEvent *sevent;
+
+ ShapeCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case ShapeNotify:
+ se = (XShapeEvent *) re;
+ sevent = (xShapeNotifyEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->window = sevent->window;
+ se->kind = sevent->kind;
+ se->x = cvtINT16toInt (sevent->x);
+ se->y = cvtINT16toInt (sevent->y);
+ se->width = sevent->width;
+ se->height = sevent->height;
+ se->time = sevent->time;
+ se->shaped = True;
+ if (sevent->shaped == xFalse)
+ se->shaped = False;
+ return True;
+ }
+ return False;
+}
+
+static Status
+event_to_wire (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShapeEvent *se;
+ xShapeNotifyEvent *sevent;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case ShapeNotify:
+ se = (XShapeEvent *) re;
+ sevent = (xShapeNotifyEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->window = se->window;
+ sevent->kind = se->kind;
+ sevent->x = se->x;
+ sevent->y = se->y;
+ sevent->width = se->width;
+ sevent->height = se->height;
+ sevent->time = se->time;
+ return 1;
+ }
+ return 0;
+}
+
+
+/****************************************************************************
+ * *
+ * Shape public interfaces *
+ * *
+ ****************************************************************************/
+
+Bool XShapeQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+Status XShapeQueryVersion(
+ Display *dpy,
+ int *major_versionp,
+ int *minor_versionp)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShapeQueryVersionReply rep;
+ register xShapeQueryVersionReq *req;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ShapeQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeQueryVersion;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *major_versionp = rep.majorVersion;
+ *minor_versionp = rep.minorVersion;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+void XShapeCombineRegion(
+ register Display *dpy,
+ Window dest,
+ int destKind, int xOff, int yOff,
+ register REGION *r,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeRectanglesReq *req;
+ register long nbytes;
+ register int i;
+ register XRectangle *xr, *pr;
+ register BOX *pb;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeRectangles, req);
+ xr = (XRectangle *)
+ _XAllocScratch(dpy, (unsigned long)(r->numRects * sizeof (XRectangle)));
+ for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+ pr->x = pb->x1;
+ pr->y = pb->y1;
+ pr->width = pb->x2 - pb->x1;
+ pr->height = pb->y2 - pb->y1;
+ }
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeRectangles;
+ req->op = op;
+ req->ordering = YXBanded;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+
+ /* SIZEOF(xRectangle) will be a multiple of 4 */
+ req->length += r->numRects * (SIZEOF(xRectangle) / 4);
+
+ nbytes = r->numRects * sizeof(xRectangle);
+
+ Data16 (dpy, (short *) xr, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XShapeCombineRectangles (
+ register Display *dpy,
+ XID dest,
+ int destKind, int xOff, int yOff,
+ XRectangle *rects,
+ int n_rects,
+ int op, int ordering)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeRectanglesReq *req;
+ register long nbytes;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeRectangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeRectangles;
+ req->op = op;
+ req->ordering = ordering;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+
+ /* SIZEOF(xRectangle) will be a multiple of 4 */
+ req->length += n_rects * (SIZEOF(xRectangle) / 4);
+
+ nbytes = n_rects * sizeof(xRectangle);
+
+ Data16 (dpy, (short *) rects, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void XShapeCombineMask (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff,
+ Pixmap src,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeMaskReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeMask, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeMask;
+ req->op = op;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ req->src = src;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XShapeCombineShape (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff,
+ XID src,
+ int srcKind,
+ int op)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeCombineReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeCombine, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeCombine;
+ req->op = op;
+ req->destKind = destKind;
+ req->srcKind = srcKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ req->src = src;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+void XShapeOffsetShape (
+ register Display *dpy,
+ XID dest,
+ int destKind,
+ int xOff, int yOff)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeOffsetReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay(dpy);
+ GetReq(ShapeOffset, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeOffset;
+ req->destKind = destKind;
+ req->dest = dest;
+ req->xOff = xOff;
+ req->yOff = yOff;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+Status XShapeQueryExtents (
+ register Display *dpy,
+ Window window,
+ int *bShaped, int *xbs, int *ybs, unsigned int *wbs, unsigned int *hbs, /* RETURN */
+ int *cShaped, int *xcs, int *ycs, unsigned int *wcs, unsigned int *hcs /* RETURN */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShapeQueryExtentsReply rep;
+ register xShapeQueryExtentsReq *req;
+
+ ShapeCheckExtension (dpy, info, 0);
+
+ LockDisplay (dpy);
+ GetReq (ShapeQueryExtents, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeQueryExtents;
+ req->window = window;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+ *bShaped = rep.boundingShaped;
+ *cShaped = rep.clipShaped;
+ *xbs = cvtINT16toInt (rep.xBoundingShape);
+ *ybs = cvtINT16toInt (rep.yBoundingShape);
+ *wbs = rep.widthBoundingShape;
+ *hbs = rep.heightBoundingShape;
+ *xcs = cvtINT16toInt (rep.xClipShape);
+ *ycs = cvtINT16toInt (rep.yClipShape);
+ *wcs = rep.widthClipShape;
+ *hcs = rep.heightClipShape;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 1;
+}
+
+
+void XShapeSelectInput (
+ register Display *dpy,
+ Window window,
+ unsigned long mask)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeSelectInputReq *req;
+
+ ShapeSimpleCheckExtension (dpy, info);
+
+ LockDisplay (dpy);
+ GetReq (ShapeSelectInput, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeSelectInput;
+ req->window = window;
+ if (mask & ShapeNotifyMask)
+ req->enable = xTrue;
+ else
+ req->enable = xFalse;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+}
+
+unsigned long XShapeInputSelected (register Display *dpy, Window window)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeInputSelectedReq *req;
+ xShapeInputSelectedReply rep;
+
+ ShapeCheckExtension (dpy, info, False);
+
+ LockDisplay (dpy);
+ GetReq (ShapeInputSelected, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeInputSelected;
+ req->window = window;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return rep.enabled ? ShapeNotifyMask : 0L;
+}
+
+
+XRectangle *XShapeGetRectangles (
+ register Display *dpy,
+ Window window,
+ int kind,
+ int *count, /* RETURN */
+ int *ordering /* RETURN */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShapeGetRectanglesReq *req;
+ xShapeGetRectanglesReply rep;
+ XRectangle *rects;
+ xRectangle *xrects;
+ int i;
+
+ ShapeCheckExtension (dpy, info, (XRectangle *)NULL);
+
+ LockDisplay (dpy);
+ GetReq (ShapeGetRectangles, req);
+ req->reqType = info->codes->major_opcode;
+ req->shapeReqType = X_ShapeGetRectangles;
+ req->window = window;
+ req->kind = kind;
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return (XRectangle *)NULL;
+ }
+ *count = rep.nrects;
+ *ordering = rep.ordering;
+ rects = NULL;
+ if (*count) {
+ xrects = (xRectangle *) Xmalloc (*count * sizeof (xRectangle));
+ rects = (XRectangle *) Xmalloc (*count * sizeof (XRectangle));
+ if (!xrects || !rects) {
+ if (xrects)
+ Xfree (xrects);
+ if (rects)
+ Xfree (rects);
+ _XEatData (dpy, *count * sizeof (xRectangle));
+ rects = NULL;
+ *count = 0;
+ } else {
+ _XRead (dpy, (char *) xrects, *count * sizeof (xRectangle));
+ for (i = 0; i < *count; i++) {
+ rects[i].x = (short) cvtINT16toInt (xrects[i].x);
+ rects[i].y = (short) cvtINT16toInt (xrects[i].y);
+ rects[i].width = xrects[i].width;
+ rects[i].height = xrects[i].height;
+ }
+ Xfree (xrects);
+ }
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return rects;
+}
diff --git a/libXext/src/XShm.c b/libXext/src/XShm.c
index 38efa9fa4..81d2b9db6 100644
--- a/libXext/src/XShm.c
+++ b/libXext/src/XShm.c
@@ -1,436 +1,434 @@
-/* $XdotOrg: $ */
-/*
- * $Xorg: XShm.c,v 1.4 2001/02/09 02:03:49 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.
- *
- * Author: Bob Scheifler and Keith Packard, MIT X Consortium
- */
-/* $XFree86: xc/lib/Xext/XShm.c,v 1.6 2002/10/16 02:19:22 dawes Exp $ */
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xlibint.h>
-#include <X11/ImUtil.h>
-#include <X11/extensions/XShm.h>
-#include <X11/extensions/shmproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-static XExtensionInfo _shm_info_data;
-static XExtensionInfo *shm_info = &_shm_info_data;
-static /* const */ char *shm_extension_name = SHMNAME;
-
-#define ShmCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, shm_extension_name, val)
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static char *error_string(Display *dpy, int code, XExtCodes *codes,
- char *buf, int n);
-static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
-static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
-static /* const */ XExtensionHooks shm_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- wire_to_event, /* wire_to_event */
- event_to_wire, /* event_to_wire */
- NULL, /* error */
- error_string, /* error_string */
-};
-
-static /* const */ char *shm_error_list[] = {
- "BadShmSeg", /* BadShmSeg */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, shm_info, shm_extension_name,
- &shm_extension_hooks, ShmNumberEvents, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shm_info)
-
-static XEXT_GENERATE_ERROR_STRING (error_string, shm_extension_name,
- ShmNumberErrors, shm_error_list)
-
-
-static Bool
-wire_to_event (Display *dpy, XEvent *re, xEvent *event)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShmCompletionEvent *se;
- xShmCompletionEvent *sevent;
-
- ShmCheckExtension (dpy, info, False);
-
- switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
- case ShmCompletion:
- se = (XShmCompletionEvent *) re;
- sevent = (xShmCompletionEvent *) event;
- se->type = sevent->type & 0x7f;
- se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
- se->send_event = (sevent->type & 0x80) != 0;
- se->display = dpy;
- se->drawable = sevent->drawable;
- se->major_code = sevent->majorEvent;
- se->minor_code = sevent->minorEvent;
- se->shmseg = sevent->shmseg;
- se->offset = sevent->offset;
- return True;
- }
- return False;
-}
-
-static Status
-event_to_wire (Display *dpy, XEvent *re, xEvent *event)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShmCompletionEvent *se;
- xShmCompletionEvent *sevent;
-
- ShmCheckExtension (dpy, info, 0);
-
- switch ((re->type & 0x7f) - info->codes->first_event) {
- case ShmCompletion:
- se = (XShmCompletionEvent *) re;
- sevent = (xShmCompletionEvent *) event;
- sevent->type = se->type | (se->send_event ? 0x80 : 0);
- sevent->sequenceNumber = se->serial & 0xffff;
- sevent->drawable = se->drawable;
- sevent->majorEvent = se->major_code;
- sevent->minorEvent = se->minor_code;
- sevent->shmseg = se->shmseg;
- sevent->offset = se->offset;
- return True;
- }
- return False;
-}
-
-/*****************************************************************************
- * *
- * public Shared Memory Extension routines *
- * *
- *****************************************************************************/
-
-Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
-/* *event_basep = info->codes->first_event;
- *error_basep = info->codes->error_event; */
- return True;
- } else {
- return False;
- }
-}
-
-
-int XShmGetEventBase(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
-
- if (XextHasExtension(info)) {
- return info->codes->first_event;
- } else {
- return -1;
- }
-}
-
-
-Bool XShmQueryVersion(
- Display *dpy,
- int *majorVersion,
- int *minorVersion,
- Bool *sharedPixmaps)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xShmQueryVersionReply rep;
- register xShmQueryVersionReq *req;
-
- ShmCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(ShmQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *majorVersion = rep.majorVersion;
- *minorVersion = rep.minorVersion;
- *sharedPixmaps = rep.sharedPixmaps ? True : False;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-
-int XShmPixmapFormat(Display *dpy)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xShmQueryVersionReply rep;
- register xShmQueryVersionReq *req;
-
- ShmCheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(ShmQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return 0;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- if (rep.sharedPixmaps &&
- (rep.majorVersion > 1 || rep.minorVersion > 0))
- return rep.pixmapFormat;
- return 0;
-}
-
-
-Status XShmAttach(Display *dpy, XShmSegmentInfo *shminfo)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShmAttachReq *req;
-
- ShmCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(ShmAttach, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmAttach;
- req->shmseg = shminfo->shmseg = XAllocID(dpy);
- req->shmid = shminfo->shmid;
- req->readOnly = shminfo->readOnly ? xTrue : xFalse;
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-
-Status XShmDetach(Display *dpy, XShmSegmentInfo *shminfo)
-{
- XExtDisplayInfo *info = find_display (dpy);
- register xShmDetachReq *req;
-
- ShmCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(ShmDetach, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmDetach;
- req->shmseg = shminfo->shmseg;
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-static int _XShmDestroyImage (XImage *ximage)
-{
- Xfree((char *)ximage);
- return 1;
-}
-
-#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad) - 1)) / (pad)) * (pad))
-
-XImage *XShmCreateImage (
- register Display *dpy,
- register Visual *visual,
- unsigned int depth,
- int format,
- char *data,
- XShmSegmentInfo *shminfo,
- unsigned int width,
- unsigned int height)
-{
- register XImage *image;
-
- image = (XImage *)Xcalloc(1, (unsigned)sizeof(XImage));
- if (!image)
- return image;
- image->data = data;
- image->obdata = (char *)shminfo;
- image->width = width;
- image->height = height;
- image->depth = depth;
- image->format = format;
- image->byte_order = dpy->byte_order;
- image->bitmap_unit = dpy->bitmap_unit;
- image->bitmap_bit_order = dpy->bitmap_bit_order;
- image->bitmap_pad = _XGetScanlinePad(dpy, depth);
- image->xoffset = 0;
- if (visual) {
- image->red_mask = visual->red_mask;
- image->green_mask = visual->green_mask;
- image->blue_mask = visual->blue_mask;
- } else {
- image->red_mask = image->green_mask = image->blue_mask = 0;
- }
- if (format == ZPixmap)
- image->bits_per_pixel = _XGetBitsPerPixel(dpy, (int)depth);
- else
- image->bits_per_pixel = 1;
- image->bytes_per_line = ROUNDUP((image->bits_per_pixel * width),
- image->bitmap_pad) >> 3;
- _XInitImageFuncPtrs(image);
- image->f.destroy_image = _XShmDestroyImage;
- return image;
-}
-
-Status XShmPutImage (
- register Display *dpy,
- Drawable d,
- GC gc,
- register XImage *image,
- int src_x, int src_y, int dst_x, int dst_y,
- unsigned int src_width, unsigned int src_height,
- Bool send_event)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
- register xShmPutImageReq *req;
-
- ShmCheckExtension (dpy, info, 0);
- if (!shminfo) return 0;
-
- LockDisplay(dpy);
- FlushGC(dpy, gc);
- GetReq(ShmPutImage, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmPutImage;
- req->drawable = d;
- req->gc = gc->gid;
- req->srcX = src_x;
- req->srcY = src_y;
- req->srcWidth = src_width;
- req->srcHeight = src_height;
- req->dstX = dst_x;
- req->dstY = dst_y;
- req->totalWidth = image->width;
- req->totalHeight = image->height;
- req->depth = image->depth;
- req->format = image->format;
- req->sendEvent = send_event;
- req->shmseg = shminfo->shmseg;
- req->offset = image->data - shminfo->shmaddr;
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-
-Status XShmGetImage(
- register Display *dpy,
- Drawable d,
- XImage *image,
- int x, int y,
- unsigned long plane_mask)
-{
- XExtDisplayInfo *info = find_display (dpy);
- XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
- register xShmGetImageReq *req;
- xShmGetImageReply rep;
- register Visual *visual;
-
- ShmCheckExtension (dpy, info, 0);
- if (!shminfo) return 0;
-
- LockDisplay(dpy);
- GetReq(ShmGetImage, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmGetImage;
- req->drawable = d;
- req->x = x;
- req->y = y;
- req->width = image->width;
- req->height = image->height;
- req->planeMask = plane_mask;
- req->format = image->format;
- req->shmseg = shminfo->shmseg;
- req->offset = image->data - shminfo->shmaddr;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return 0;
- }
- visual = _XVIDtoVisual(dpy, rep.visual);
- if (visual) {
- image->red_mask = visual->red_mask;
- image->green_mask = visual->green_mask;
- image->blue_mask = visual->blue_mask;
- } else {
- image->red_mask = image->green_mask = image->blue_mask = 0;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return 1;
-}
-
-Pixmap XShmCreatePixmap (
- register Display *dpy,
- Drawable d,
- char *data,
- XShmSegmentInfo *shminfo,
- unsigned int width, unsigned int height, unsigned int depth)
-{
- XExtDisplayInfo *info = find_display (dpy);
- Pixmap pid;
- register xShmCreatePixmapReq *req;
-
- ShmCheckExtension (dpy, info, 0);
-
- LockDisplay(dpy);
- GetReq(ShmCreatePixmap, req);
- req->reqType = info->codes->major_opcode;
- req->shmReqType = X_ShmCreatePixmap;
- req->drawable = d;
- req->width = width;
- req->height = height;
- req->depth = depth;
- req->shmseg = shminfo->shmseg;
- req->offset = data - shminfo->shmaddr;
- pid = req->pid = XAllocID(dpy);
- UnlockDisplay(dpy);
- SyncHandle();
- return pid;
-}
+/* $XdotOrg: $ */
+/*
+ * $Xorg: XShm.c,v 1.4 2001/02/09 02:03:49 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.
+ *
+ * Author: Bob Scheifler and Keith Packard, MIT X Consortium
+ */
+/* $XFree86: xc/lib/Xext/XShm.c,v 1.6 2002/10/16 02:19:22 dawes Exp $ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/ImUtil.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/shmproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _shm_info_data;
+static XExtensionInfo *shm_info = &_shm_info_data;
+static /* const */ char *shm_extension_name = SHMNAME;
+
+#define ShmCheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, shm_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+static Bool wire_to_event (Display *dpy, XEvent *re, xEvent *event);
+static Status event_to_wire (Display *dpy, XEvent *re, xEvent *event);
+static /* const */ XExtensionHooks shm_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static /* const */ char *shm_error_list[] = {
+ "BadShmSeg", /* BadShmSeg */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, shm_info, shm_extension_name,
+ &shm_extension_hooks, ShmNumberEvents, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, shm_info)
+
+static XEXT_GENERATE_ERROR_STRING (error_string, shm_extension_name,
+ ShmNumberErrors, shm_error_list)
+
+
+static Bool
+wire_to_event (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmCompletionEvent *se;
+ xShmCompletionEvent *sevent;
+
+ ShmCheckExtension (dpy, info, False);
+
+ switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+ case ShmCompletion:
+ se = (XShmCompletionEvent *) re;
+ sevent = (xShmCompletionEvent *) event;
+ se->type = sevent->type & 0x7f;
+ se->serial = _XSetLastRequestRead(dpy,(xGenericReply *) event);
+ se->send_event = (sevent->type & 0x80) != 0;
+ se->display = dpy;
+ se->drawable = sevent->drawable;
+ se->major_code = sevent->majorEvent;
+ se->minor_code = sevent->minorEvent;
+ se->shmseg = sevent->shmseg;
+ se->offset = sevent->offset;
+ return True;
+ }
+ return False;
+}
+
+static Status
+event_to_wire (Display *dpy, XEvent *re, xEvent *event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmCompletionEvent *se;
+ xShmCompletionEvent *sevent;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case ShmCompletion:
+ se = (XShmCompletionEvent *) re;
+ sevent = (xShmCompletionEvent *) event;
+ sevent->type = se->type | (se->send_event ? 0x80 : 0);
+ sevent->sequenceNumber = se->serial & 0xffff;
+ sevent->drawable = se->drawable;
+ sevent->majorEvent = se->major_code;
+ sevent->minorEvent = se->minor_code;
+ sevent->shmseg = se->shmseg;
+ sevent->offset = se->offset;
+ return True;
+ }
+ return False;
+}
+
+/*****************************************************************************
+ * *
+ * public Shared Memory Extension routines *
+ * *
+ *****************************************************************************/
+
+Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+/* *event_basep = info->codes->first_event;
+ *error_basep = info->codes->error_event; */
+ return True;
+ } else {
+ return False;
+ }
+}
+
+
+int XShmGetEventBase(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ if (XextHasExtension(info)) {
+ return info->codes->first_event;
+ } else {
+ return -1;
+ }
+}
+
+
+Bool XShmQueryVersion(
+ Display *dpy,
+ int *majorVersion,
+ int *minorVersion,
+ Bool *sharedPixmaps)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShmQueryVersionReply rep;
+ register xShmQueryVersionReq *req;
+
+ ShmCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(ShmQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *sharedPixmaps = rep.sharedPixmaps ? True : False;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+
+int XShmPixmapFormat(Display *dpy)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xShmQueryVersionReply rep;
+ register xShmQueryVersionReq *req;
+
+ ShmCheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(ShmQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (rep.sharedPixmaps &&
+ (rep.majorVersion > 1 || rep.minorVersion > 0))
+ return rep.pixmapFormat;
+ return 0;
+}
+
+
+Status XShmAttach(Display *dpy, XShmSegmentInfo *shminfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShmAttachReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(ShmAttach, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmAttach;
+ req->shmseg = shminfo->shmseg = XAllocID(dpy);
+ req->shmid = shminfo->shmid;
+ req->readOnly = shminfo->readOnly ? xTrue : xFalse;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status XShmDetach(Display *dpy, XShmSegmentInfo *shminfo)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ register xShmDetachReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(ShmDetach, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmDetach;
+ req->shmseg = shminfo->shmseg;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+static int _XShmDestroyImage (XImage *ximage)
+{
+ Xfree((char *)ximage);
+ return 1;
+}
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad) - 1)) / (pad)) * (pad))
+
+XImage *XShmCreateImage (
+ register Display *dpy,
+ register Visual *visual,
+ unsigned int depth,
+ int format,
+ char *data,
+ XShmSegmentInfo *shminfo,
+ unsigned int width,
+ unsigned int height)
+{
+ register XImage *image;
+
+ image = (XImage *)Xcalloc(1, (unsigned)sizeof(XImage));
+ if (!image)
+ return image;
+ image->data = data;
+ image->obdata = (char *)shminfo;
+ image->width = width;
+ image->height = height;
+ image->depth = depth;
+ image->format = format;
+ image->byte_order = dpy->byte_order;
+ image->bitmap_unit = dpy->bitmap_unit;
+ image->bitmap_bit_order = dpy->bitmap_bit_order;
+ image->bitmap_pad = _XGetScanlinePad(dpy, depth);
+ image->xoffset = 0;
+ if (visual) {
+ image->red_mask = visual->red_mask;
+ image->green_mask = visual->green_mask;
+ image->blue_mask = visual->blue_mask;
+ } else {
+ image->red_mask = image->green_mask = image->blue_mask = 0;
+ }
+ if (format == ZPixmap)
+ image->bits_per_pixel = _XGetBitsPerPixel(dpy, (int)depth);
+ else
+ image->bits_per_pixel = 1;
+ image->bytes_per_line = ROUNDUP((image->bits_per_pixel * width),
+ image->bitmap_pad) >> 3;
+ _XInitImageFuncPtrs(image);
+ image->f.destroy_image = _XShmDestroyImage;
+ return image;
+}
+
+Status XShmPutImage (
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ register XImage *image,
+ int src_x, int src_y, int dst_x, int dst_y,
+ unsigned int src_width, unsigned int src_height,
+ Bool send_event)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
+ register xShmPutImageReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+ if (!shminfo) return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(ShmPutImage, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmPutImage;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->srcWidth = src_width;
+ req->srcHeight = src_height;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->totalWidth = image->width;
+ req->totalHeight = image->height;
+ req->depth = image->depth;
+ req->format = image->format;
+ req->sendEvent = send_event;
+ req->shmseg = shminfo->shmseg;
+ req->offset = image->data - shminfo->shmaddr;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+Status XShmGetImage(
+ register Display *dpy,
+ Drawable d,
+ XImage *image,
+ int x, int y,
+ unsigned long plane_mask)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata;
+ register xShmGetImageReq *req;
+ xShmGetImageReply rep;
+ register Visual *visual;
+
+ ShmCheckExtension (dpy, info, 0);
+ if (!shminfo) return 0;
+
+ LockDisplay(dpy);
+ GetReq(ShmGetImage, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmGetImage;
+ req->drawable = d;
+ req->x = x;
+ req->y = y;
+ req->width = image->width;
+ req->height = image->height;
+ req->planeMask = plane_mask;
+ req->format = image->format;
+ req->shmseg = shminfo->shmseg;
+ req->offset = image->data - shminfo->shmaddr;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ visual = _XVIDtoVisual(dpy, rep.visual);
+ if (visual) {
+ image->red_mask = visual->red_mask;
+ image->green_mask = visual->green_mask;
+ image->blue_mask = visual->blue_mask;
+ } else {
+ image->red_mask = image->green_mask = image->blue_mask = 0;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+Pixmap XShmCreatePixmap (
+ register Display *dpy,
+ Drawable d,
+ char *data,
+ XShmSegmentInfo *shminfo,
+ unsigned int width, unsigned int height, unsigned int depth)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ Pixmap pid;
+ register xShmCreatePixmapReq *req;
+
+ ShmCheckExtension (dpy, info, 0);
+
+ LockDisplay(dpy);
+ GetReq(ShmCreatePixmap, req);
+ req->reqType = info->codes->major_opcode;
+ req->shmReqType = X_ShmCreatePixmap;
+ req->drawable = d;
+ req->width = width;
+ req->height = height;
+ req->depth = depth;
+ req->shmseg = shminfo->shmseg;
+ req->offset = data - shminfo->shmaddr;
+ pid = req->pid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
diff --git a/libXext/src/XSync.c b/libXext/src/XSync.c
index ce76dd37a..e7c0c3f78 100644
--- a/libXext/src/XSync.c
+++ b/libXext/src/XSync.c
@@ -1,798 +1,796 @@
-/*
-
-Copyright 1991, 1993, 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 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
-and Olivetti Research Limited, Cambridge, England.
-
- All Rights Reserved
-
-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 names of Digital or Olivetti
-not be used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL THEY 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/Xext/XSync.c,v 1.7tsi Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#define NEED_EVENTS
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-#include <X11/extensions/sync.h>
-#include <X11/extensions/syncproto.h>
-
-static XExtensionInfo _sync_info_data;
-static XExtensionInfo *sync_info = &_sync_info_data;
-static char *sync_extension_name = SYNC_NAME;
-
-#define SyncCheckExtension(dpy,i,val) \
- XextCheckExtension(dpy, i, sync_extension_name, val)
-#define SyncSimpleCheckExtension(dpy,i) \
- XextSimpleCheckExtension(dpy, i, sync_extension_name)
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static Bool wire_to_event(Display *dpy, XEvent *event, xEvent *wire);
-static Status event_to_wire(Display *dpy, XEvent *event, xEvent *wire);
-static char *error_string(Display *dpy, int code, XExtCodes *codes,
- char *buf, int n);
-
-static XExtensionHooks sync_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- wire_to_event, /* wire_to_event */
- event_to_wire, /* event_to_wire */
- NULL, /* error */
- error_string, /* error_string */
-};
-
-static char *sync_error_list[] = {
- "BadCounter",
- "BadAlarm",
-};
-
-static
-XEXT_GENERATE_FIND_DISPLAY(find_display, sync_info,
- sync_extension_name,
- &sync_extension_hooks,
- XSyncNumberEvents, (XPointer) NULL)
-
-static
-XEXT_GENERATE_CLOSE_DISPLAY(close_display, sync_info)
-
-static
-XEXT_GENERATE_ERROR_STRING(error_string, sync_extension_name,
- XSyncNumberErrors, sync_error_list)
-
-
-static Bool
-wire_to_event(Display *dpy, XEvent *event, xEvent *wire)
-{
- XExtDisplayInfo *info = find_display(dpy);
- XSyncCounterNotifyEvent *aevent;
- xSyncCounterNotifyEvent *awire;
- XSyncAlarmNotifyEvent *anl;
- xSyncAlarmNotifyEvent *ane;
-
- SyncCheckExtension(dpy, info, False);
-
- switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
- {
- case XSyncCounterNotify:
- awire = (xSyncCounterNotifyEvent *) wire;
- aevent = (XSyncCounterNotifyEvent *) event;
- aevent->type = awire->type & 0x7F;
- aevent->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *) wire);
- aevent->send_event = (awire->type & 0x80) != 0;
- aevent->display = dpy;
- aevent->counter = awire->counter;
- XSyncIntsToValue(&aevent->wait_value, awire->wait_value_lo,
- awire->wait_value_hi);
- XSyncIntsToValue(&aevent->counter_value,
- awire->counter_value_lo,
- awire->counter_value_hi);
- aevent->time = awire->time;
- aevent->count = awire->count;
- aevent->destroyed = awire->destroyed;
- return True;
-
- case XSyncAlarmNotify:
- ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
- anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
- anl->type = ane->type & 0x7F;
- anl->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *) wire);
- anl->send_event = (ane->type & 0x80) != 0;
- anl->display = dpy;
- anl->alarm = ane->alarm;
- XSyncIntsToValue(&anl->counter_value,
- ane->counter_value_lo,
- ane->counter_value_hi);
- XSyncIntsToValue(&anl->alarm_value,
- ane->alarm_value_lo,
- ane->alarm_value_hi);
- anl->state = (XSyncAlarmState)ane->state;
- anl->time = ane->time;
- return True;
- }
-
- return False;
-}
-
-static Status
-event_to_wire(Display *dpy, XEvent *event, xEvent *wire)
-{
- XExtDisplayInfo *info = find_display(dpy);
- XSyncCounterNotifyEvent *aevent;
- xSyncCounterNotifyEvent *awire;
- XSyncAlarmNotifyEvent *anl;
- xSyncAlarmNotifyEvent *ane;
-
- SyncCheckExtension(dpy, info, False);
-
- switch ((event->type & 0x7F) - info->codes->first_event)
- {
- case XSyncCounterNotify:
- awire = (xSyncCounterNotifyEvent *) wire;
- aevent = (XSyncCounterNotifyEvent *) event;
- awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
- awire->sequenceNumber = aevent->serial & 0xFFFF;
- awire->counter = aevent->counter;
- awire->wait_value_lo = XSyncValueLow32(aevent->wait_value);
- awire->wait_value_hi = XSyncValueHigh32(aevent->wait_value);
- awire->counter_value_lo = XSyncValueLow32(aevent->counter_value);
- awire->counter_value_hi = XSyncValueHigh32(aevent->counter_value);
- awire->time = aevent->time;
- awire->count = aevent->count;
- awire->destroyed = aevent->destroyed;
- return True;
-
- case XSyncAlarmNotify:
- ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
- anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
- ane->type = anl->type | (anl->send_event ? 0x80 : 0);
- ane->sequenceNumber = anl->serial & 0xFFFF;
- ane->alarm = anl->alarm;
- ane->counter_value_lo = XSyncValueLow32(anl->counter_value);
- ane->counter_value_hi = XSyncValueHigh32(anl->counter_value);
- ane->alarm_value_lo = XSyncValueLow32(anl->alarm_value);
- ane->alarm_value_hi = XSyncValueHigh32(anl->alarm_value);
- ane->state = anl->state;
- ane->time = anl->time;
- return True;
- }
- return False;
-}
-
-Status
-XSyncQueryExtension(
- Display *dpy,
- int *event_base_return, int *error_base_return)
-{
- XExtDisplayInfo *info = find_display(dpy);
-
- if (XextHasExtension(info))
- {
- *event_base_return = info->codes->first_event;
- *error_base_return = info->codes->first_error;
- return True;
- }
- else
- return False;
-}
-
-Status
-XSyncInitialize(
- Display *dpy,
- int *major_version_return, int *minor_version_return)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncInitializeReply rep;
- xSyncInitializeReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncInitialize, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncInitialize;
- req->majorVersion = SYNC_MAJOR_VERSION;
- req->minorVersion = SYNC_MINOR_VERSION;
- if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- *major_version_return = rep.majorVersion;
- *minor_version_return = rep.minorVersion;
- return ((rep.majorVersion == SYNC_MAJOR_VERSION)
-#if SYNC_MINOR_VERSION > 0 /* avoid compiler warning */
- && (rep.minorVersion >= SYNC_MINOR_VERSION)
-#endif
- );
-}
-
-XSyncSystemCounter *
-XSyncListSystemCounters(Display *dpy, int *n_counters_return)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncListSystemCountersReply rep;
- xSyncListSystemCountersReq *req;
- XSyncSystemCounter *list = NULL;
-
- SyncCheckExtension(dpy, info, NULL);
-
- LockDisplay(dpy);
- GetReq(SyncListSystemCounters, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncListSystemCounters;
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
- goto bail;
-
- *n_counters_return = rep.nCounters;
- if (rep.nCounters > 0)
- {
- xSyncSystemCounter *pWireSysCounter, *pNextWireSysCounter;
- XSyncCounter counter;
- int replylen;
- int i;
-
- list = Xmalloc(rep.nCounters * sizeof(XSyncSystemCounter));
- replylen = rep.length << 2;
- pWireSysCounter = Xmalloc ((unsigned) replylen + sizeof(XSyncCounter));
- /* +1 to leave room for last counter read-ahead */
-
- if ((!list) || (!pWireSysCounter))
- {
- if (list) Xfree((char *) list);
- if (pWireSysCounter) Xfree((char *) pWireSysCounter);
- _XEatData(dpy, (unsigned long) replylen);
- list = NULL;
- goto bail;
- }
-
- _XReadPad(dpy, (char *)pWireSysCounter, replylen);
-
- counter = pWireSysCounter->counter;
- for (i = 0; i < rep.nCounters; i++)
- {
- list[i].counter = counter;
- XSyncIntsToValue(&list[i].resolution,
- pWireSysCounter->resolution_lo,
- pWireSysCounter->resolution_hi);
-
- /* we may be about to clobber the counter field of the
- * next syscounter because we have to add a null terminator
- * to the counter name string. So we save the next counter
- * here.
- */
- pNextWireSysCounter = (xSyncSystemCounter *)
- (((char *)pWireSysCounter) + ((SIZEOF(xSyncSystemCounter) +
- pWireSysCounter->name_length + 3) & ~3));
- counter = pNextWireSysCounter->counter;
-
- list[i].name = ((char *)pWireSysCounter) +
- SIZEOF(xSyncSystemCounter);
- /* null-terminate the string */
- *(list[i].name + pWireSysCounter->name_length) = '\0';
- pWireSysCounter = pNextWireSysCounter;
- }
- }
-
-bail:
- UnlockDisplay(dpy);
- SyncHandle();
- return list;
-}
-
-void
-XSyncFreeSystemCounterList(XSyncSystemCounter *list)
-{
- if (list)
- {
- Xfree( ((char *)list[0].name) - SIZEOF(xSyncSystemCounter));
- Xfree(list);
- }
-}
-
-
-XSyncCounter
-XSyncCreateCounter(Display *dpy, XSyncValue initial_value)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncCreateCounterReq *req;
-
- SyncCheckExtension(dpy, info, None);
-
- LockDisplay(dpy);
- GetReq(SyncCreateCounter, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncCreateCounter;
-
- req->cid = XAllocID(dpy);
- req->initial_value_lo = XSyncValueLow32(initial_value);
- req->initial_value_hi = XSyncValueHigh32(initial_value);
-
- UnlockDisplay(dpy);
- SyncHandle();
- return req->cid;
-}
-
-Status
-XSyncSetCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncSetCounterReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncSetCounter, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncSetCounter;
- req->cid = counter;
- req->value_lo = XSyncValueLow32(value);
- req->value_hi = XSyncValueHigh32(value);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncChangeCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncChangeCounterReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncChangeCounter, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncChangeCounter;
- req->cid = counter;
- req->value_lo = XSyncValueLow32(value);
- req->value_hi = XSyncValueHigh32(value);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncDestroyCounter(Display *dpy, XSyncCounter counter)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncDestroyCounterReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncDestroyCounter, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncDestroyCounter;
- req->counter = counter;
- UnlockDisplay(dpy);
- SyncHandle();
-
- return True;
-}
-
-Status
-XSyncQueryCounter(Display *dpy, XSyncCounter counter, XSyncValue *value_return)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncQueryCounterReply rep;
- xSyncQueryCounterReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncQueryCounter, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncQueryCounter;
- req->counter = counter;
- if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- XSyncIntsToValue(value_return, rep.value_lo, rep.value_hi);
- UnlockDisplay(dpy);
- SyncHandle();
-
- return True;
-}
-
-
-Status
-XSyncAwait(Display *dpy, XSyncWaitCondition *wait_list, int n_conditions)
-{
- XExtDisplayInfo *info = find_display(dpy);
- XSyncWaitCondition *wait_item = wait_list;
- xSyncAwaitReq *req;
- unsigned int len;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncAwait, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncAwait;
- len = (n_conditions * SIZEOF(xSyncWaitCondition)) >> 2;
- SetReqLen(req, len, len /* XXX */ );
-
- while (n_conditions--)
- {
- xSyncWaitCondition wc;
- wc.counter = wait_item->trigger.counter;
- wc.value_type = wait_item->trigger.value_type;
- wc.wait_value_lo = XSyncValueLow32(wait_item->trigger.wait_value);
- wc.wait_value_hi = XSyncValueHigh32(wait_item->trigger.wait_value);
- wc.test_type = wait_item->trigger.test_type;
- wc.event_threshold_lo = XSyncValueLow32(wait_item->event_threshold);
- wc.event_threshold_hi = XSyncValueHigh32(wait_item->event_threshold);
- Data(dpy, (char *)&wc, SIZEOF(xSyncWaitCondition));
- wait_item++; /* get next trigger */
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-static void
-_XProcessAlarmAttributes(Display *dpy, xSyncChangeAlarmReq *req,
- unsigned long valuemask,
- XSyncAlarmAttributes *attributes)
-{
-
- unsigned long values[32];
- unsigned long *value = values;
- unsigned int nvalues;
-
- if (valuemask & XSyncCACounter)
- *value++ = attributes->trigger.counter;
-
- if (valuemask & XSyncCAValueType)
- *value++ = attributes->trigger.value_type;
-
- if (valuemask & XSyncCAValue)
- {
- *value++ = XSyncValueHigh32(attributes->trigger.wait_value);
- *value++ = XSyncValueLow32(attributes->trigger.wait_value);
- }
-
- if (valuemask & XSyncCATestType)
- *value++ = attributes->trigger.test_type;
-
- if (valuemask & XSyncCADelta)
- {
- *value++ = XSyncValueHigh32(attributes->delta);
- *value++ = XSyncValueLow32(attributes->delta);
- }
-
- if (valuemask & XSyncCAEvents)
- *value++ = attributes->events;
-
- /* N.B. the 'state' field cannot be set or changed */
- req->length += (nvalues = value - values);
- nvalues <<= 2; /* watch out for macros... */
-
- Data32(dpy, (long *) values, (long) nvalues);
-}
-
-XSyncAlarm
-XSyncCreateAlarm(
- Display *dpy,
- unsigned long values_mask,
- XSyncAlarmAttributes *values)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncCreateAlarmReq *req;
- XSyncAlarm aid;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncCreateAlarm, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncCreateAlarm;
- req->id = aid = XAllocID(dpy);
- values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
- | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
- if ((req->valueMask = values_mask))
- _XProcessAlarmAttributes(dpy, (xSyncChangeAlarmReq *) req,
- values_mask, values);
- UnlockDisplay(dpy);
- SyncHandle();
- return aid;
-}
-
-Status
-XSyncDestroyAlarm(Display *dpy, XSyncAlarm alarm)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncDestroyAlarmReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncDestroyAlarm, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncDestroyAlarm;
- req->alarm = alarm;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncQueryAlarm(
- Display *dpy,
- XSyncAlarm alarm,
- XSyncAlarmAttributes *values_return)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncQueryAlarmReq *req;
- xSyncQueryAlarmReply rep;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncQueryAlarm, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncQueryAlarm;
- req->alarm = alarm;
-
- if (!(_XReply(dpy, (xReply *) & rep,
- ((SIZEOF(xSyncQueryAlarmReply) - SIZEOF(xGenericReply)) >> 2), xFalse)))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
-
- values_return->trigger.counter = rep.counter;
- values_return->trigger.value_type = (XSyncValueType)rep.value_type;
- XSyncIntsToValue(&values_return->trigger.wait_value,
- rep.wait_value_lo, rep.wait_value_hi);
- values_return->trigger.test_type = (XSyncTestType)rep.test_type;
- XSyncIntsToValue(&values_return->delta, rep.delta_lo,
- rep.delta_hi);
- values_return->events = rep.events;
- values_return->state = (XSyncAlarmState)rep.state;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncChangeAlarm(
- Display *dpy,
- XSyncAlarm alarm,
- unsigned long values_mask,
- XSyncAlarmAttributes *values)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncChangeAlarmReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncChangeAlarm, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncChangeAlarm;
- req->alarm = alarm;
- values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
- | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
- if ((req->valueMask = values_mask))
- _XProcessAlarmAttributes(dpy, req, values_mask, values);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncSetPriority(
- Display *dpy,
- XID client_resource_id,
- int priority)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncSetPriorityReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncSetPriority, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncSetPriority;
- req->id = client_resource_id;
- req->priority = priority;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-Status
-XSyncGetPriority(Display *dpy, XID client_resource_id, int *return_priority)
-{
- XExtDisplayInfo *info = find_display(dpy);
- xSyncGetPriorityReply rep;
- xSyncGetPriorityReq *req;
-
- SyncCheckExtension(dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(SyncGetPriority, req);
- req->reqType = info->codes->major_opcode;
- req->syncReqType = X_SyncGetPriority;
- req->id = client_resource_id;
-
- if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- if (return_priority)
- *return_priority = rep.priority;
-
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-/*
- * Functions corresponding to the macros for manipulating 64-bit values
- */
-
-void
-XSyncIntToValue(XSyncValue *pv, int i)
-{
- _XSyncIntToValue(pv,i);
-}
-
-void
-XSyncIntsToValue(XSyncValue *pv, unsigned int l, int h)
-{
- _XSyncIntsToValue(pv, l, h);
-}
-
-Bool
-XSyncValueGreaterThan(XSyncValue a, XSyncValue b)
-{
- return _XSyncValueGreaterThan(a, b);
-}
-
-Bool
-XSyncValueLessThan(XSyncValue a, XSyncValue b)
-{
- return _XSyncValueLessThan(a, b);
-}
-
-Bool
-XSyncValueGreaterOrEqual(XSyncValue a, XSyncValue b)
-{
- return _XSyncValueGreaterOrEqual(a, b);
-}
-
-Bool
-XSyncValueLessOrEqual(XSyncValue a, XSyncValue b)
-{
- return _XSyncValueLessOrEqual(a, b);
-}
-
-Bool
-XSyncValueEqual(XSyncValue a, XSyncValue b)
-{
- return _XSyncValueEqual(a, b);
-}
-
-Bool
-XSyncValueIsNegative(XSyncValue v)
-{
- return _XSyncValueIsNegative(v);
-}
-
-Bool
-XSyncValueIsZero(XSyncValue a)
-{
- return _XSyncValueIsZero(a);
-}
-
-Bool
-XSyncValueIsPositive(XSyncValue v)
-{
- return _XSyncValueIsPositive(v);
-}
-
-unsigned int
-XSyncValueLow32(XSyncValue v)
-{
- return _XSyncValueLow32(v);
-}
-
-int
-XSyncValueHigh32(XSyncValue v)
-{
- return _XSyncValueHigh32(v);
-}
-
-void
-XSyncValueAdd(XSyncValue *presult, XSyncValue a, XSyncValue b, Bool *poverflow)
-{
- _XSyncValueAdd(presult, a, b, poverflow);
-}
-
-void
-XSyncValueSubtract(
- XSyncValue *presult,
- XSyncValue a, XSyncValue b,
- Bool *poverflow)
-{
- _XSyncValueSubtract(presult, a, b, poverflow);
-}
-
-void
-XSyncMaxValue(XSyncValue *pv)
-{
- _XSyncMaxValue(pv);
-}
-
-void
-XSyncMinValue(XSyncValue *pv)
-{
- _XSyncMinValue(pv);
-}
+/*
+
+Copyright 1991, 1993, 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 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+and Olivetti Research Limited, Cambridge, England.
+
+ All Rights Reserved
+
+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 names of Digital or Olivetti
+not be used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL THEY 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/Xext/XSync.c,v 1.7tsi Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/sync.h>
+#include <X11/extensions/syncproto.h>
+
+static XExtensionInfo _sync_info_data;
+static XExtensionInfo *sync_info = &_sync_info_data;
+static char *sync_extension_name = SYNC_NAME;
+
+#define SyncCheckExtension(dpy,i,val) \
+ XextCheckExtension(dpy, i, sync_extension_name, val)
+#define SyncSimpleCheckExtension(dpy,i) \
+ XextSimpleCheckExtension(dpy, i, sync_extension_name)
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static Bool wire_to_event(Display *dpy, XEvent *event, xEvent *wire);
+static Status event_to_wire(Display *dpy, XEvent *event, xEvent *wire);
+static char *error_string(Display *dpy, int code, XExtCodes *codes,
+ char *buf, int n);
+
+static XExtensionHooks sync_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ wire_to_event, /* wire_to_event */
+ event_to_wire, /* event_to_wire */
+ NULL, /* error */
+ error_string, /* error_string */
+};
+
+static char *sync_error_list[] = {
+ "BadCounter",
+ "BadAlarm",
+};
+
+static
+XEXT_GENERATE_FIND_DISPLAY(find_display, sync_info,
+ sync_extension_name,
+ &sync_extension_hooks,
+ XSyncNumberEvents, (XPointer) NULL)
+
+static
+XEXT_GENERATE_CLOSE_DISPLAY(close_display, sync_info)
+
+static
+XEXT_GENERATE_ERROR_STRING(error_string, sync_extension_name,
+ XSyncNumberErrors, sync_error_list)
+
+
+static Bool
+wire_to_event(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncCounterNotifyEvent *aevent;
+ xSyncCounterNotifyEvent *awire;
+ XSyncAlarmNotifyEvent *anl;
+ xSyncAlarmNotifyEvent *ane;
+
+ SyncCheckExtension(dpy, info, False);
+
+ switch ((wire->u.u.type & 0x7F) - info->codes->first_event)
+ {
+ case XSyncCounterNotify:
+ awire = (xSyncCounterNotifyEvent *) wire;
+ aevent = (XSyncCounterNotifyEvent *) event;
+ aevent->type = awire->type & 0x7F;
+ aevent->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ aevent->send_event = (awire->type & 0x80) != 0;
+ aevent->display = dpy;
+ aevent->counter = awire->counter;
+ XSyncIntsToValue(&aevent->wait_value, awire->wait_value_lo,
+ awire->wait_value_hi);
+ XSyncIntsToValue(&aevent->counter_value,
+ awire->counter_value_lo,
+ awire->counter_value_hi);
+ aevent->time = awire->time;
+ aevent->count = awire->count;
+ aevent->destroyed = awire->destroyed;
+ return True;
+
+ case XSyncAlarmNotify:
+ ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
+ anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
+ anl->type = ane->type & 0x7F;
+ anl->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *) wire);
+ anl->send_event = (ane->type & 0x80) != 0;
+ anl->display = dpy;
+ anl->alarm = ane->alarm;
+ XSyncIntsToValue(&anl->counter_value,
+ ane->counter_value_lo,
+ ane->counter_value_hi);
+ XSyncIntsToValue(&anl->alarm_value,
+ ane->alarm_value_lo,
+ ane->alarm_value_hi);
+ anl->state = (XSyncAlarmState)ane->state;
+ anl->time = ane->time;
+ return True;
+ }
+
+ return False;
+}
+
+static Status
+event_to_wire(Display *dpy, XEvent *event, xEvent *wire)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncCounterNotifyEvent *aevent;
+ xSyncCounterNotifyEvent *awire;
+ XSyncAlarmNotifyEvent *anl;
+ xSyncAlarmNotifyEvent *ane;
+
+ SyncCheckExtension(dpy, info, False);
+
+ switch ((event->type & 0x7F) - info->codes->first_event)
+ {
+ case XSyncCounterNotify:
+ awire = (xSyncCounterNotifyEvent *) wire;
+ aevent = (XSyncCounterNotifyEvent *) event;
+ awire->type = aevent->type | (aevent->send_event ? 0x80 : 0);
+ awire->sequenceNumber = aevent->serial & 0xFFFF;
+ awire->counter = aevent->counter;
+ awire->wait_value_lo = XSyncValueLow32(aevent->wait_value);
+ awire->wait_value_hi = XSyncValueHigh32(aevent->wait_value);
+ awire->counter_value_lo = XSyncValueLow32(aevent->counter_value);
+ awire->counter_value_hi = XSyncValueHigh32(aevent->counter_value);
+ awire->time = aevent->time;
+ awire->count = aevent->count;
+ awire->destroyed = aevent->destroyed;
+ return True;
+
+ case XSyncAlarmNotify:
+ ane = (xSyncAlarmNotifyEvent *) wire; /* ENCODING EVENT PTR */
+ anl = (XSyncAlarmNotifyEvent *) event; /* LIBRARY EVENT PTR */
+ ane->type = anl->type | (anl->send_event ? 0x80 : 0);
+ ane->sequenceNumber = anl->serial & 0xFFFF;
+ ane->alarm = anl->alarm;
+ ane->counter_value_lo = XSyncValueLow32(anl->counter_value);
+ ane->counter_value_hi = XSyncValueHigh32(anl->counter_value);
+ ane->alarm_value_lo = XSyncValueLow32(anl->alarm_value);
+ ane->alarm_value_hi = XSyncValueHigh32(anl->alarm_value);
+ ane->state = anl->state;
+ ane->time = anl->time;
+ return True;
+ }
+ return False;
+}
+
+Status
+XSyncQueryExtension(
+ Display *dpy,
+ int *event_base_return, int *error_base_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+
+ if (XextHasExtension(info))
+ {
+ *event_base_return = info->codes->first_event;
+ *error_base_return = info->codes->first_error;
+ return True;
+ }
+ else
+ return False;
+}
+
+Status
+XSyncInitialize(
+ Display *dpy,
+ int *major_version_return, int *minor_version_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncInitializeReply rep;
+ xSyncInitializeReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncInitialize, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncInitialize;
+ req->majorVersion = SYNC_MAJOR_VERSION;
+ req->minorVersion = SYNC_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *major_version_return = rep.majorVersion;
+ *minor_version_return = rep.minorVersion;
+ return ((rep.majorVersion == SYNC_MAJOR_VERSION)
+#if SYNC_MINOR_VERSION > 0 /* avoid compiler warning */
+ && (rep.minorVersion >= SYNC_MINOR_VERSION)
+#endif
+ );
+}
+
+XSyncSystemCounter *
+XSyncListSystemCounters(Display *dpy, int *n_counters_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncListSystemCountersReply rep;
+ xSyncListSystemCountersReq *req;
+ XSyncSystemCounter *list = NULL;
+
+ SyncCheckExtension(dpy, info, NULL);
+
+ LockDisplay(dpy);
+ GetReq(SyncListSystemCounters, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncListSystemCounters;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ goto bail;
+
+ *n_counters_return = rep.nCounters;
+ if (rep.nCounters > 0)
+ {
+ xSyncSystemCounter *pWireSysCounter, *pNextWireSysCounter;
+ XSyncCounter counter;
+ int replylen;
+ int i;
+
+ list = Xmalloc(rep.nCounters * sizeof(XSyncSystemCounter));
+ replylen = rep.length << 2;
+ pWireSysCounter = Xmalloc ((unsigned) replylen + sizeof(XSyncCounter));
+ /* +1 to leave room for last counter read-ahead */
+
+ if ((!list) || (!pWireSysCounter))
+ {
+ if (list) Xfree((char *) list);
+ if (pWireSysCounter) Xfree((char *) pWireSysCounter);
+ _XEatData(dpy, (unsigned long) replylen);
+ list = NULL;
+ goto bail;
+ }
+
+ _XReadPad(dpy, (char *)pWireSysCounter, replylen);
+
+ counter = pWireSysCounter->counter;
+ for (i = 0; i < rep.nCounters; i++)
+ {
+ list[i].counter = counter;
+ XSyncIntsToValue(&list[i].resolution,
+ pWireSysCounter->resolution_lo,
+ pWireSysCounter->resolution_hi);
+
+ /* we may be about to clobber the counter field of the
+ * next syscounter because we have to add a null terminator
+ * to the counter name string. So we save the next counter
+ * here.
+ */
+ pNextWireSysCounter = (xSyncSystemCounter *)
+ (((char *)pWireSysCounter) + ((SIZEOF(xSyncSystemCounter) +
+ pWireSysCounter->name_length + 3) & ~3));
+ counter = pNextWireSysCounter->counter;
+
+ list[i].name = ((char *)pWireSysCounter) +
+ SIZEOF(xSyncSystemCounter);
+ /* null-terminate the string */
+ *(list[i].name + pWireSysCounter->name_length) = '\0';
+ pWireSysCounter = pNextWireSysCounter;
+ }
+ }
+
+bail:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+}
+
+void
+XSyncFreeSystemCounterList(XSyncSystemCounter *list)
+{
+ if (list)
+ {
+ Xfree( ((char *)list[0].name) - SIZEOF(xSyncSystemCounter));
+ Xfree(list);
+ }
+}
+
+
+XSyncCounter
+XSyncCreateCounter(Display *dpy, XSyncValue initial_value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncCreateCounterReq *req;
+
+ SyncCheckExtension(dpy, info, None);
+
+ LockDisplay(dpy);
+ GetReq(SyncCreateCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncCreateCounter;
+
+ req->cid = XAllocID(dpy);
+ req->initial_value_lo = XSyncValueLow32(initial_value);
+ req->initial_value_hi = XSyncValueHigh32(initial_value);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return req->cid;
+}
+
+Status
+XSyncSetCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncSetCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncSetCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncSetCounter;
+ req->cid = counter;
+ req->value_lo = XSyncValueLow32(value);
+ req->value_hi = XSyncValueHigh32(value);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncChangeCounter(Display *dpy, XSyncCounter counter, XSyncValue value)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncChangeCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncChangeCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncChangeCounter;
+ req->cid = counter;
+ req->value_lo = XSyncValueLow32(value);
+ req->value_hi = XSyncValueHigh32(value);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncDestroyCounter(Display *dpy, XSyncCounter counter)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncDestroyCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncDestroyCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncDestroyCounter;
+ req->counter = counter;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+Status
+XSyncQueryCounter(Display *dpy, XSyncCounter counter, XSyncValue *value_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncQueryCounterReply rep;
+ xSyncQueryCounterReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncQueryCounter, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncQueryCounter;
+ req->counter = counter;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xTrue))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ XSyncIntsToValue(value_return, rep.value_lo, rep.value_hi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return True;
+}
+
+
+Status
+XSyncAwait(Display *dpy, XSyncWaitCondition *wait_list, int n_conditions)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ XSyncWaitCondition *wait_item = wait_list;
+ xSyncAwaitReq *req;
+ unsigned int len;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncAwait, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncAwait;
+ len = (n_conditions * SIZEOF(xSyncWaitCondition)) >> 2;
+ SetReqLen(req, len, len /* XXX */ );
+
+ while (n_conditions--)
+ {
+ xSyncWaitCondition wc;
+ wc.counter = wait_item->trigger.counter;
+ wc.value_type = wait_item->trigger.value_type;
+ wc.wait_value_lo = XSyncValueLow32(wait_item->trigger.wait_value);
+ wc.wait_value_hi = XSyncValueHigh32(wait_item->trigger.wait_value);
+ wc.test_type = wait_item->trigger.test_type;
+ wc.event_threshold_lo = XSyncValueLow32(wait_item->event_threshold);
+ wc.event_threshold_hi = XSyncValueHigh32(wait_item->event_threshold);
+ Data(dpy, (char *)&wc, SIZEOF(xSyncWaitCondition));
+ wait_item++; /* get next trigger */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+static void
+_XProcessAlarmAttributes(Display *dpy, xSyncChangeAlarmReq *req,
+ unsigned long valuemask,
+ XSyncAlarmAttributes *attributes)
+{
+
+ unsigned long values[32];
+ unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & XSyncCACounter)
+ *value++ = attributes->trigger.counter;
+
+ if (valuemask & XSyncCAValueType)
+ *value++ = attributes->trigger.value_type;
+
+ if (valuemask & XSyncCAValue)
+ {
+ *value++ = XSyncValueHigh32(attributes->trigger.wait_value);
+ *value++ = XSyncValueLow32(attributes->trigger.wait_value);
+ }
+
+ if (valuemask & XSyncCATestType)
+ *value++ = attributes->trigger.test_type;
+
+ if (valuemask & XSyncCADelta)
+ {
+ *value++ = XSyncValueHigh32(attributes->delta);
+ *value++ = XSyncValueLow32(attributes->delta);
+ }
+
+ if (valuemask & XSyncCAEvents)
+ *value++ = attributes->events;
+
+ /* N.B. the 'state' field cannot be set or changed */
+ req->length += (nvalues = value - values);
+ nvalues <<= 2; /* watch out for macros... */
+
+ Data32(dpy, (long *) values, (long) nvalues);
+}
+
+XSyncAlarm
+XSyncCreateAlarm(
+ Display *dpy,
+ unsigned long values_mask,
+ XSyncAlarmAttributes *values)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncCreateAlarmReq *req;
+ XSyncAlarm aid;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncCreateAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncCreateAlarm;
+ req->id = aid = XAllocID(dpy);
+ values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
+ | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
+ if ((req->valueMask = values_mask))
+ _XProcessAlarmAttributes(dpy, (xSyncChangeAlarmReq *) req,
+ values_mask, values);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return aid;
+}
+
+Status
+XSyncDestroyAlarm(Display *dpy, XSyncAlarm alarm)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncDestroyAlarmReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncDestroyAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncDestroyAlarm;
+ req->alarm = alarm;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncQueryAlarm(
+ Display *dpy,
+ XSyncAlarm alarm,
+ XSyncAlarmAttributes *values_return)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncQueryAlarmReq *req;
+ xSyncQueryAlarmReply rep;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncQueryAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncQueryAlarm;
+ req->alarm = alarm;
+
+ if (!(_XReply(dpy, (xReply *) & rep,
+ ((SIZEOF(xSyncQueryAlarmReply) - SIZEOF(xGenericReply)) >> 2), xFalse)))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+
+ values_return->trigger.counter = rep.counter;
+ values_return->trigger.value_type = (XSyncValueType)rep.value_type;
+ XSyncIntsToValue(&values_return->trigger.wait_value,
+ rep.wait_value_lo, rep.wait_value_hi);
+ values_return->trigger.test_type = (XSyncTestType)rep.test_type;
+ XSyncIntsToValue(&values_return->delta, rep.delta_lo,
+ rep.delta_hi);
+ values_return->events = rep.events;
+ values_return->state = (XSyncAlarmState)rep.state;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncChangeAlarm(
+ Display *dpy,
+ XSyncAlarm alarm,
+ unsigned long values_mask,
+ XSyncAlarmAttributes *values)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncChangeAlarmReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncChangeAlarm, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncChangeAlarm;
+ req->alarm = alarm;
+ values_mask &= XSyncCACounter | XSyncCAValueType | XSyncCAValue
+ | XSyncCATestType | XSyncCADelta | XSyncCAEvents;
+ if ((req->valueMask = values_mask))
+ _XProcessAlarmAttributes(dpy, req, values_mask, values);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncSetPriority(
+ Display *dpy,
+ XID client_resource_id,
+ int priority)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncSetPriorityReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncSetPriority, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncSetPriority;
+ req->id = client_resource_id;
+ req->priority = priority;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+XSyncGetPriority(Display *dpy, XID client_resource_id, int *return_priority)
+{
+ XExtDisplayInfo *info = find_display(dpy);
+ xSyncGetPriorityReply rep;
+ xSyncGetPriorityReq *req;
+
+ SyncCheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(SyncGetPriority, req);
+ req->reqType = info->codes->major_opcode;
+ req->syncReqType = X_SyncGetPriority;
+ req->id = client_resource_id;
+
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (return_priority)
+ *return_priority = rep.priority;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/*
+ * Functions corresponding to the macros for manipulating 64-bit values
+ */
+
+void
+XSyncIntToValue(XSyncValue *pv, int i)
+{
+ _XSyncIntToValue(pv,i);
+}
+
+void
+XSyncIntsToValue(XSyncValue *pv, unsigned int l, int h)
+{
+ _XSyncIntsToValue(pv, l, h);
+}
+
+Bool
+XSyncValueGreaterThan(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueGreaterThan(a, b);
+}
+
+Bool
+XSyncValueLessThan(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueLessThan(a, b);
+}
+
+Bool
+XSyncValueGreaterOrEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueGreaterOrEqual(a, b);
+}
+
+Bool
+XSyncValueLessOrEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueLessOrEqual(a, b);
+}
+
+Bool
+XSyncValueEqual(XSyncValue a, XSyncValue b)
+{
+ return _XSyncValueEqual(a, b);
+}
+
+Bool
+XSyncValueIsNegative(XSyncValue v)
+{
+ return _XSyncValueIsNegative(v);
+}
+
+Bool
+XSyncValueIsZero(XSyncValue a)
+{
+ return _XSyncValueIsZero(a);
+}
+
+Bool
+XSyncValueIsPositive(XSyncValue v)
+{
+ return _XSyncValueIsPositive(v);
+}
+
+unsigned int
+XSyncValueLow32(XSyncValue v)
+{
+ return _XSyncValueLow32(v);
+}
+
+int
+XSyncValueHigh32(XSyncValue v)
+{
+ return _XSyncValueHigh32(v);
+}
+
+void
+XSyncValueAdd(XSyncValue *presult, XSyncValue a, XSyncValue b, Bool *poverflow)
+{
+ _XSyncValueAdd(presult, a, b, poverflow);
+}
+
+void
+XSyncValueSubtract(
+ XSyncValue *presult,
+ XSyncValue a, XSyncValue b,
+ Bool *poverflow)
+{
+ _XSyncValueSubtract(presult, a, b, poverflow);
+}
+
+void
+XSyncMaxValue(XSyncValue *pv)
+{
+ _XSyncMaxValue(pv);
+}
+
+void
+XSyncMinValue(XSyncValue *pv)
+{
+ _XSyncMinValue(pv);
+}
diff --git a/libXext/src/XTestExt1.c b/libXext/src/XTestExt1.c
index c9d48d7da..7a73a8ae8 100644
--- a/libXext/src/XTestExt1.c
+++ b/libXext/src/XTestExt1.c
@@ -1,1322 +1,1319 @@
-/* $Xorg: XTestExt1.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $ */
-/*
- * File: xtestext1lib.c
- *
- * This file contains the Xlib parts of the input synthesis extension
- */
-
-/*
-
-
-Copyright 1986, 1987, 1988, 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 1986, 1987, 1988 by Hewlett-Packard Corporation
-
-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 Hewlett-Packard not be used in
-advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-Hewlett-Packard makes no representations about the
-suitability of this software for any purpose. It is provided
-"as is" without express or implied warranty.
-
-This software is not subject to any license of the American
-Telephone and Telegraph Company or of the Regents of the
-University of California.
-
-*/
-/* $XFree86: xc/lib/Xext/XTestExt1.c,v 1.3 2001/01/17 19:42:46 dawes Exp $ */
-
-/******************************************************************************
- * include files
- *****************************************************************************/
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <X11/Xproto.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/xtestext1.h>
-#include <X11/extensions/xtestext1proto.h>
-
-/******************************************************************************
- * variables
- *****************************************************************************/
-
-/*
- * Holds the request type code for this extension. The request type code
- * for this extension may vary depending on how many extensions are installed
- * already, so the initial value given below will be added to the base request
- * code that is acquired when this extension is installed.
- */
-static int XTestReqCode = 0;
-/*
- * Holds the two event type codes for this extension. The event type codes
- * for this extension may vary depending on how many extensions are installed
- * already, so the initial values given below will be added to the base event
- * code that is acquired when this extension is installed.
- *
- * These two variables must be available to programs that use this extension.
- */
-int XTestInputActionType = 0;
-int XTestFakeAckType = 1;
-/*
- * holds the current x and y coordinates for XTestMovePointer
- */
-static int current_x = 0;
-static int current_y = 0;
-/*
- * Holds input actions being accumulated until the input action buffer is
- * full or until XTestFlush is called.
- */
-static CARD8 action_buf[XTestMAX_ACTION_LIST_SIZE];
-/*
- * the index into the input action buffer
- */
-static int action_index = 0;
-/*
- * the number of input actions that the server can handle at one time
- */
-static unsigned long action_array_size = 0;
-/*
- * the current number of input actions
- */
-static unsigned long action_count = 0;
-
-/******************************************************************************
- * function declarations
- *****************************************************************************/
-
-static int XTestWireToEvent(Display *dpy, XEvent *reTemp, xEvent *eventTemp);
-static int XTestCheckExtInit(register Display *dpy);
-static Bool XTestIdentifyMyEvent(Display *display, XEvent *event_ptr, char *args);
-static int XTestInitExtension(register Display *dpy);
-static int XTestKeyOrButton(Display *display, int device_id, long unsigned int delay, unsigned int code, unsigned int action);
-static int XTestCheckDelay(Display *display, long unsigned int *delay_addr);
-static int XTestPackInputAction(Display *display, CARD8 *action_addr, int action_size);
-static int XTestWriteInputActions(Display *display, char *action_list_addr, int action_list_size, int ack_flag);
-
-/******************************************************************************
- *
- * XTestFakeInput
- *
- * Send a a request containing one or more input actions to be sent
- * to the server by this extension.
- */
-int
-XTestFakeInput(
-/*
- * the connection to the X server
- */
-register Display *dpy,
-/*
- * the address of a list of input actions to be sent to the server
- */
-char *action_list_addr,
-/*
- * the size (in bytes) of the list of input actions
- */
-int action_list_size,
-/*
- * specifies whether the server needs to send an event to indicate that its
- * input action buffer is empty
- */
-int ack_flag)
-{
- /*
- * pointer to xTestFakeInputReq structure
- */
- xTestFakeInputReq *req;
- /*
- * loop index
- */
- int i;
-
- LockDisplay(dpy);
- if ((XTestCheckExtInit(dpy) == -1) ||
- (action_list_size > XTestMAX_ACTION_LIST_SIZE))
- {
- /*
- * if the extension is not installed in the server or the
- * action list will not fit in the request, then unlock
- * the display and return -1.
- */
- UnlockDisplay(dpy);
- return(-1);
- }
- else
- {
- /*
- * Get the next available X request packet in the buffer.
- * It sets the `length' field to the size (in 32-bit words)
- * of the request. It also sets the `reqType' field in the
- * request to X_TestFakeInput, which is not what is needed.
- *
- * GetReq is a macro defined in Xlibint.h.
- */
- GetReq(TestFakeInput, req);
- /*
- * fix up the request type code to what is needed
- */
- req->reqType = XTestReqCode;
- /*
- * set the minor request type code to X_TestFakeInput
- */
- req->XTestReqType = X_TestFakeInput;
- /*
- * set the ack code
- */
- req->ack = ack_flag;
- /*
- * Set the action_list area to all 0's. An input action header
- * value of 0 is interpreted as a flag to the input action
- * list handling code in the server part of this extension
- * that there are no more input actions in this request.
- */
- for (i = 0; i < XTestMAX_ACTION_LIST_SIZE; i++)
- {
- req->action_list[i] = 0;
- }
- /*
- * copy the input actions into the request
- */
- for (i = 0; i < action_list_size; i++)
- {
- req->action_list[i] = *(action_list_addr++);
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return(0);
- }
-}
-
-/******************************************************************************
- *
- * XTestGetInput
- *
- * Request the server to begin putting user input actions into events
- * to be sent to the client that called this function.
- */
-int
-XTestGetInput(
-/*
- * the connection to the X server
- */
-register Display *dpy,
-/*
- * tells the server what to do with the user input actions
- */
-int action_handling)
-{
- /*
- * pointer to xTestGetInputReq structure
- */
- xTestGetInputReq *req;
-
- LockDisplay(dpy);
- if (XTestCheckExtInit(dpy) == -1)
- {
- /*
- * if the extension is not installed in the server
- * then unlock the display and return -1.
- */
- UnlockDisplay(dpy);
- return(-1);
- }
- else
- {
- /*
- * Get the next available X request packet in the buffer.
- * It sets the `length' field to the size (in 32-bit words)
- * of the request. It also sets the `reqType' field in the
- * request to X_TestGetInput, which is not what is needed.
- *
- * GetReq is a macro defined in Xlibint.h.
- */
- GetReq(TestGetInput, req);
- /*
- * fix up the request type code to what is needed
- */
- req->reqType = XTestReqCode;
- /*
- * set the minor request type code to X_TestGetInput
- */
- req->XTestReqType = X_TestGetInput;
- /*
- * set the action handling mode
- */
- req->mode = action_handling;
- UnlockDisplay(dpy);
- SyncHandle();
- return(0);
- }
-}
-
-/******************************************************************************
- *
- * XTestStopInput
- *
- * Tell the server to stop putting information about user input actions
- * into events.
- */
-int
-XTestStopInput(
-/*
- * the connection to the X server
- */
-register Display *dpy)
-{
- /*
- * pointer to xTestStopInputReq structure
- */
- xTestStopInputReq *req;
-
- LockDisplay(dpy);
- if (XTestCheckExtInit(dpy) == -1)
- {
- /*
- * if the extension is not installed in the server
- * then unlock the display and return -1.
- */
- UnlockDisplay(dpy);
- return(-1);
- }
- else
- {
- /*
- * Get the next available X request packet in the buffer.
- * It sets the `length' field to the size (in 32-bit words)
- * of the request. It also sets the `reqType' field in the
- * request to X_TestStopInput, which is not what is needed.
- *
- * GetReq is a macro defined in Xlibint.h.
- */
- GetReq(TestStopInput, req);
- /*
- * fix up the request type code to what is needed
- */
- req->reqType = XTestReqCode;
- /*
- * set the minor request type code to X_TestStopInput
- */
- req->XTestReqType = X_TestStopInput;
- UnlockDisplay(dpy);
- SyncHandle();
- return(0);
- }
-}
-
-/******************************************************************************
- *
- * XTestReset
- *
- * Tell the server to set everything having to do with this extension
- * back to its initial state.
- */
-int
-XTestReset(
-/*
- * the connection to the X server
- */
-register Display *dpy)
-{
- /*
- * pointer to xTestReset structure
- */
- xTestResetReq *req;
-
- LockDisplay(dpy);
- if (XTestCheckExtInit(dpy) == -1)
- {
- /*
- * if the extension is not installed in the server
- * then unlock the display and return -1.
- */
- UnlockDisplay(dpy);
- return(-1);
- }
- else
- {
- /*
- * Get the next available X request packet in the buffer.
- * It sets the `length' field to the size (in 32-bit words)
- * of the request. It also sets the `reqType' field in the
- * request to X_TestReset, which is not what is needed.
- *
- * GetReq is a macro defined in Xlibint.h.
- */
- GetReq(TestReset, req);
- /*
- * fix up the request type code to what is needed
- */
- req->reqType = XTestReqCode;
- /*
- * set the minor request type code to X_TestReset
- */
- req->XTestReqType = X_TestReset;
- UnlockDisplay(dpy);
- SyncHandle();
- return(0);
- }
-}
-
-/******************************************************************************
- *
- * XTestQueryInputSize
- *
- * Returns the number of input actions in the server's input action buffer.
- */
-int
-XTestQueryInputSize(
-/*
- * the connection to the X server
- */
-register Display *dpy,
-/*
- * the address of the place to put the number of input actions in the
- * server's input action buffer
- */
-unsigned long *size_return)
-{
- /*
- * pointer to xTestQueryInputSize structure
- */
- xTestQueryInputSizeReq *req;
- /*
- * pointer to xTestQueryInputSize structure
- */
- xTestQueryInputSizeReply rep;
-
- LockDisplay(dpy);
- if (XTestCheckExtInit(dpy) == -1)
- {
- /*
- * if the extension is not installed in the server
- * then unlock the display and return -1.
- */
- UnlockDisplay(dpy);
- return(-1);
- }
- else
- {
- /*
- * Get the next available X request packet in the buffer.
- * It sets the `length' field to the size (in 32-bit words)
- * of the request. It also sets the `reqType' field in the
- * request to X_TestQueryInputSize, which is not what is needed.
- *
- * GetReq is a macro defined in Xlibint.h.
- */
- GetReq(TestQueryInputSize, req);
- /*
- * fix up the request type code to what is needed
- */
- req->reqType = XTestReqCode;
- /*
- * set the minor request type code to X_TestQueryInputSize
- */
- req->XTestReqType = X_TestQueryInputSize;
- /*
- * get a reply from the server
- */
- (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
- /*
- * put the size in the caller's variable
- */
- *size_return = (unsigned long) rep.size_return;
- UnlockDisplay(dpy);
- SyncHandle();
- return(0);
- }
-}
-
-/******************************************************************************
- *
- * XTestCheckExtInit
- *
- * Check to see if the XTest extension is installed in the server.
- */
-static int
-XTestCheckExtInit(
-/*
- * the connection to the X server
- */
-register Display *dpy)
-{
- /*
- * if the extension has not been initialized, then do so
- */
- if (!XTestReqCode)
- {
- return(XTestInitExtension(dpy));
- }
- return(0);
-}
-
-/******************************************************************************
- *
- * XTestInitExtension
- *
- * Attempt to initialize this extension in the server. Return 0 if it
- * succeeds, -1 if it does not succeed.
- */
-static int
-XTestInitExtension(
-/*
- * the connection to the X server
- */
-register Display *dpy)
-{
- /*
- * loop index
- */
- int i;
- /*
- * return value from XInitExtension
- */
- XExtCodes *ret;
-
- /*
- * attempt to initialize the extension
- */
- ret = XInitExtension(dpy, XTestEXTENSION_NAME);
- /*
- * if the initialize failed, return -1
- */
- if (ret == NULL)
- {
- return (-1);
- }
- /*
- * the initialize succeeded, remember the major opcode
- * for this extension
- */
- XTestReqCode = ret->major_opcode;
- /*
- * set up the event handler for any events from
- * this extension
- */
- for (i = 0; i < XTestEVENT_COUNT; i++)
- {
- XESetWireToEvent(dpy,
- ret->first_event+i,
- XTestWireToEvent);
- }
- /*
- * compute the event type codes for the events
- * in this extension
- */
- XTestInputActionType += ret->first_event;
- XTestFakeAckType += ret->first_event;
- /*
- * everything worked ok
- */
- return(0);
-}
-
-/******************************************************************************
- *
- * XTestWireToEvent
- *
- * Handle XTest extension events.
- * Reformat a wire event into an XEvent structure of the right type.
- */
-static Bool
-XTestWireToEvent(
-/*
- * the connection to the X server
- */
-Display *dpy,
-/*
- * a pointer to where a host formatted event should be stored
- * with the information copied to it
- */
-XEvent *reTemp,
-/*
- * a pointer to the wire event
- */
-xEvent *eventTemp)
-{
- XTestInputActionEvent *re = (XTestInputActionEvent *) reTemp;
- xTestInputActionEvent *event = (xTestInputActionEvent *) eventTemp;
-
- /*
- * loop index
- */
- int i;
- /*
- * pointer to where the input actions go in the host format event
- */
- CARD8 *to;
- /*
- * pointer to the input actions in the wire event
- */
- CARD8 *from;
-
- /*
- * Copy the type of the wire event to the new event.
- * This will work for either event type because the type,
- * display, and window fields in the events have to be the same.
- */
- re->type = event->type;
- /*
- * set the display parameter in case it is needed (by who?)
- */
- re->display = dpy;
- if (re->type == XTestInputActionType)
- {
- /*
- * point at the first byte of input actions in the wire event
- */
- from = &(event->actions[0]);
- /*
- * point at where the input action bytes go in the new event
- */
- to = &(re->actions[0]);
- /*
- * copy the input action bytes from the wire event to
- * the new event
- */
- for (i = 0; i < XTestACTIONS_SIZE; i++)
- {
- *(to++) = *(from++);
- }
- }
- else if (re->type == XTestFakeAckType)
- {
- /*
- * nothing else needs to be done
- */
- }
- else
- {
- printf("XTestWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",
- (int) event->type);
- printf("%s is giving up.\n", XTestEXTENSION_NAME);
- exit (1);
- }
- return 1;
-}
-
-/******************************************************************************
- *
- * XTestPressKey
- *
- * Send input actions to the server to cause the server to think
- * that the specified key on the keyboard was moved as specified.
- */
-int
-XTestPressKey(
-Display *display,
-int device_id,
-unsigned long delay,
-unsigned int keycode,
-unsigned int key_action)
-{
- /*
- * bounds check the key code
- */
- if (keycode < 8 || keycode > 255)
- {
- return(-1);
- }
- /*
- * use the commmon key/button handling routine
- */
- return(XTestKeyOrButton(display,
- device_id,
- delay,
- keycode,
- key_action));
-}
-
-/******************************************************************************
- *
- * XTestPressButton
- *
- * Send input actions to the server to cause the server to think
- * that the specified button on the mouse was moved as specified.
- */
-int
-XTestPressButton(
-Display *display,
-int device_id,
-unsigned long delay,
-unsigned int button_number,
-unsigned int button_action)
-{
- /*
- * bounds check the button number
- */
- if (button_number > 7)
- {
- return(-1);
- }
- /*
- * use the commmon key/button handling routine
- */
- return(XTestKeyOrButton(display,
- device_id,
- delay,
- button_number,
- button_action));
-}
-
-/******************************************************************************
- *
- * XTestKeyOrButton
- *
- * Send input actions to the server to cause the server to think
- * that the specified key/button was moved as specified.
- */
-static int
-XTestKeyOrButton(
-Display *display,
-int device_id,
-unsigned long delay,
-unsigned int code,
-unsigned int action)
-{
- /*
- * holds a key input action to be filled out and sent to the server
- */
- XTestKeyInfo keyinfo;
-
- /*
- * bounds check the device id
- */
- if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
- {
- return(-1);
- }
- /*
- * fill out the key input action(s) as appropriate
- */
- switch(action)
- {
- case XTestPRESS:
- /*
- * Check the delay. If it is larger than will fit in the
- * key input action, send a delay input action.
- */
- if(XTestCheckDelay(display, &delay) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * create the header
- */
- keyinfo.header = XTestPackDeviceID(device_id) |
- XTestKEY_ACTION |
- XTestKEY_DOWN;
- /*
- * set the key/button code
- */
- keyinfo.keycode = code;
- /*
- * set the delay time
- */
- keyinfo.delay_time = delay;
- /*
- * pack the input action into a request to be sent to the
- * server when the request is full or XTestFlush is called
- */
- return(XTestPackInputAction(display,
- (CARD8 *) &keyinfo,
- sizeof(XTestKeyInfo)));
- case XTestRELEASE:
- /*
- * Check the delay. If it is larger than will fit in the
- * key input action, send a delay input action.
- */
- if(XTestCheckDelay(display, &delay) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * create the header
- */
- keyinfo.header = XTestPackDeviceID(device_id) |
- XTestKEY_ACTION |
- XTestKEY_UP;
- /*
- * set the key/button code
- */
- keyinfo.keycode = code;
- /*
- * set the delay time
- */
- keyinfo.delay_time = delay;
- /*
- * pack the input action into a request to be sent to the
- * server when the request is full or XTestFlush is called
- */
- return(XTestPackInputAction(display,
- (CARD8 *) &keyinfo,
- sizeof(XTestKeyInfo)));
- case XTestSTROKE:
- /*
- * Check the delay. If it is larger than will fit in the
- * key input action, send a delay input action.
- */
- if(XTestCheckDelay(display, &delay) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * create a key/button-down input action header
- */
- keyinfo.header = XTestPackDeviceID(device_id) |
- XTestKEY_ACTION |
- XTestKEY_DOWN;
- /*
- * set the key/button code
- */
- keyinfo.keycode = code;
- /*
- * set the delay time
- */
- keyinfo.delay_time = delay;
- /*
- * pack the input action into a request to be sent to the
- * server when the request is full or XTestFlush is called
- */
- if (XTestPackInputAction(display,
- (CARD8 *) &keyinfo,
- sizeof(XTestKeyInfo)) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * set the delay to XTestSTROKE_DELAY_TIME
- */
- delay = XTestSTROKE_DELAY_TIME;
- /*
- * Check the delay. If it is larger than will fit in the
- * key input action, send a delay input action.
- */
- if(XTestCheckDelay(display, &delay) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * create a key/button-up input action header
- */
- keyinfo.header = XTestPackDeviceID(device_id) |
- XTestKEY_ACTION |
- XTestKEY_UP;
- /*
- * set the key/button code
- */
- keyinfo.keycode = code;
- /*
- * set the delay time
- */
- keyinfo.delay_time = delay;
- /*
- * pack the input action into a request to be sent to the
- * server when the request is full or XTestFlush is called
- */
- return(XTestPackInputAction(display,
- (CARD8 *) &keyinfo,
- sizeof(XTestKeyInfo)));
- default:
- /*
- * invalid action value, return -1
- */
- return(-1);
- }
-}
-
-/******************************************************************************
- *
- * XTestMovePointer
- *
- * Send input actions to the server to cause the server to think
- * that the mouse was moved as specified.
- */
-int
-XTestMovePointer(
-Display *display,
-int device_id,
-unsigned long delay[],
-int x[],
-int y[],
-unsigned int count)
-{
- /*
- * holds a motion input action to be filled out and sent to the server
- */
- XTestMotionInfo motioninfo;
- /*
- * holds a jump input action to be filled out and sent to the server
- */
- XTestJumpInfo jumpinfo;
- /*
- * loop index
- */
- unsigned int i;
- /*
- * holds the change in x and y directions from the current x and y
- * coordinates
- */
- int dx;
- int dy;
-
- /*
- * bounds check the device id
- */
- if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
- {
- return(-1);
- }
- /*
- * if the count is 0, there is nothing to do. return 0
- */
- if (count == 0)
- {
- return(0);
- }
- /*
- * loop through the pointer motions, creating the appropriate
- * input actions for each motion
- */
- for (i = 0; i < count; i++)
- {
- /*
- * Check the delay. If it is larger than will fit in the
- * input action, send a delay input action.
- */
- if(XTestCheckDelay(display, &(delay[i])) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- /*
- * compute the change from the current x and y coordinates
- * to the new x and y coordinates
- */
- dx = x[i] - current_x;
- dy = y[i] - current_y;
- /*
- * update the current x and y coordinates
- */
- current_x = x[i];
- current_y = y[i];
- /*
- * If the pointer motion range is too large to fit into
- * a motion input action, then use a jump input action.
- * Otherwise, use a motion input action.
- */
- if ((dx > XTestMOTION_MAX) || (dx < XTestMOTION_MIN) ||
- (dy > XTestMOTION_MAX) || (dy < XTestMOTION_MIN))
- {
- /*
- * create a jump input action header
- */
- jumpinfo.header = XTestPackDeviceID(device_id) |
- XTestJUMP_ACTION;
- /*
- * set the x and y coordinates to jump to
- */
- jumpinfo.jumpx = x[i];
- jumpinfo.jumpy = y[i];
- /*
- * set the delay time
- */
- jumpinfo.delay_time = delay[i];
- /*
- * pack the jump input action into a request to be
- * sent to the server when the request is full
- * or XTestFlush is called
- */
- if (XTestPackInputAction(display,
- (CARD8 *) &jumpinfo,
- sizeof(XTestJumpInfo)) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- }
- else
- {
- /*
- * create a motion input action header
- */
- motioninfo.header = XTestPackDeviceID(device_id) |
- XTestMOTION_ACTION;
- /*
- * compute the motion data byte
- */
- if (dx < 0)
- {
- motioninfo.header |= XTestX_NEGATIVE;
- dx = abs(dx);
- }
- if (dy < 0)
- {
- motioninfo.header |= XTestY_NEGATIVE;
- dy = abs(dy);
- }
- motioninfo.motion_data = XTestPackXMotionValue(dx);
- motioninfo.motion_data |= XTestPackYMotionValue(dy);
- /*
- * set the delay time
- */
- motioninfo.delay_time = delay[i];
- /*
- * pack the motion input action into a request to be
- * sent to the server when the request is full
- * or XTestFlush is called
- */
- if (XTestPackInputAction(display,
- (CARD8 *) &motioninfo,
- sizeof(XTestMotionInfo)) == -1)
- {
- /*
- * an error occurred, return -1
- */
- return(-1);
- }
- }
- }
- /*
- * if you get here, everything went ok
- */
- return(0);
-}
-
-/******************************************************************************
- *
- * XTestCheckDelay
- *
- * Check the delay value at the passed-in address. If it is larger than
- * will fit in a normal input action, then send a delay input action.
- */
-static int
-XTestCheckDelay(
-Display *display,
-unsigned long *delay_addr)
-{
- /*
- * holds a delay input action to be filled out and sent to the server
- */
- XTestDelayInfo delayinfo;
-
- /*
- * if the delay value will fit in the input action,
- * then there is no need for a delay input action
- */
- if (*delay_addr <= XTestSHORT_DELAY_TIME)
- {
- return(0);
- }
- /*
- * fill out a delay input action
- */
- delayinfo.header = XTestPackDeviceID(XTestDELAY_DEVICE_ID);
- delayinfo.delay_time = *delay_addr;
- /*
- * all of the delay time will be accounted for in the
- * delay input action, so set the original delay value to 0
- */
- *delay_addr = 0;
- /*
- * pack the delay input action into a request to be sent to the
- * server when the request is full or XTestFlush is called
- */
- return(XTestPackInputAction(display,
- (CARD8 *) &delayinfo,
- sizeof(XTestDelayInfo)));
-}
-
-/******************************************************************************
- *
- * XTestPackInputAction
- *
- * If the input action buffer is full or the number of input actions
- * has reached the maximum that the server can handle at one time,
- * then send the input actions to the server using XTestFakeInput.
- */
-static int
-XTestPackInputAction(
-Display *display,
-CARD8 *action_addr,
-int action_size)
-{
- /*
- * loop index
- */
- int i;
- /*
- * acknowledge flag
- */
- int ack_flag;
-
- /*
- * if we don't already know it, find out how many input actions
- * the server can handle at one time
- */
- if (action_array_size == 0)
- {
- if(XTestQueryInputSize(display, &action_array_size) == -1)
- {
- /*
- * if an error, return -1
- */
- return(-1);
- }
- }
- /*
- * if the specified input action will fit in the the input
- * action buffer and won't exceed the server's capacity, then
- * put the input action into the input buffer
- */
- if(((action_index + action_size) <= XTestMAX_ACTION_LIST_SIZE) &&
- ((action_count + 1) < action_array_size))
- {
- /*
- * copy the input action into the buffer
- */
- for (i = 0; i < action_size; i++)
- {
- action_buf[action_index++] = *(action_addr++);
- }
- /*
- * increment the action count
- */
- action_count++;
- /*
- * everything went ok, return 0
- */
- return(0);
- }
- /*
- * We have to write input actions to the server. If the server's
- * input action capacity will be reached, then ask for an
- * acknowledge event when the server has processed all of the
- * input actions. Otherwise, an acknowledge event is not needed.
- */
- if (action_count >= action_array_size)
- {
- ack_flag = XTestFAKE_ACK_REQUEST;
- }
- else
- {
- ack_flag = XTestFAKE_ACK_NOT_NEEDED;
- }
- /*
- * write the input actions to the server
- */
- if (XTestWriteInputActions(display,
- (char *) &(action_buf[0]),
- action_index,
- ack_flag) == -1)
- {
- /*
- * error, return -1
- */
- return(-1);
- }
- /*
- * copy the input action into the buffer
- */
- for (i = 0; i < action_size; i++)
- {
- action_buf[action_index++] = *(action_addr++);
- }
- /*
- * increment the action count
- */
- action_count++;
- return(0);
-}
-
-/******************************************************************************
- *
- * XTestWriteInputActions
- *
- * Send input actions to the server.
- */
-static int
-XTestWriteInputActions(
-Display *display,
-char *action_list_addr,
-int action_list_size,
-int ack_flag)
-{
- /*
- * Holds an event. Used while waiting for an acknowledge event
- */
- XEvent event;
- /*
- * points to XTestIdentifyMyEvent
- */
- Bool (*func_ptr)(Display *, XEvent *, XPointer);
-
- /*
- * write the input actions to the server
- */
- if (XTestFakeInput(display,
- action_list_addr,
- action_list_size,
- ack_flag) == -1)
- {
- /*
- * if an error, return -1
- */
- return(-1);
- }
- /*
- * flush X's buffers to make sure that the server really gets
- * the input actions
- */
- XFlush(display);
- /*
- * mark the input action buffer as empty
- */
- action_index = 0;
- /*
- * if we asked for an acknowledge event, then wait for it
- */
- if (ack_flag == XTestFAKE_ACK_REQUEST)
- {
- /*
- * point func_ptr at XTestIdentifyMyEvent
- */
- func_ptr = XTestIdentifyMyEvent;
- /*
- * Wait until the acknowledge event comes. When the
- * acknowledge event comes, it is removed from the event
- * queue without disturbing any other events that might
- * be in the queue.
- */
- XIfEvent(display, &event, func_ptr, NULL);
- /*
- * set the input action count back to 0
- */
- action_count = 0;
- }
- /*
- * if we got here, then everything is ok, return 0
- */
- return(0);
-}
-
-/******************************************************************************
- *
- * XTestIdentifyMyEvent
- *
- * This function is called by XIfEvent to look at an event and see if
- * it is of XTestFakeAckType.
- */
-static Bool
-XTestIdentifyMyEvent(
-Display *display,
-/*
- * Holds the event that this routine is supposed to look at.
- */
-XEvent *event_ptr,
-/*
- * this points to any user-specified arguments (ignored)
- */
-char *args)
-{
- /*
- * if the event if of the correct type, return the Bool True,
- * otherwise return the Bool False.
- */
- if (event_ptr->type == XTestFakeAckType)
- {
- return(True);
- }
- else
- {
- return(False);
- }
-}
-
-/******************************************************************************
- *
- * XTestFlush
- *
- * Send any input actions in the input action buffer to the server.
- */
-int
-XTestFlush(Display *display)
-{
- /*
- * acknowledge flag
- */
- int ack_flag;
-
- /*
- * if there are no input actions in the input action buffer,
- * then return 0
- */
- if (action_index == 0)
- {
- return(0);
- }
- /*
- * We have input actions to write to the server. We will
- * wait until the server has finished processing the input actions.
- */
- ack_flag = XTestFAKE_ACK_REQUEST;
- /*
- * write the input actions to the server
- */
- return(XTestWriteInputActions(display,
- (char *) &(action_buf[0]),
- action_index,
- ack_flag));
-}
+/* $Xorg: XTestExt1.c,v 1.4 2001/02/09 02:03:49 xorgcvs Exp $ */
+/*
+ * File: xtestext1lib.c
+ *
+ * This file contains the Xlib parts of the input synthesis extension
+ */
+
+/*
+
+
+Copyright 1986, 1987, 1988, 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 1986, 1987, 1988 by Hewlett-Packard Corporation
+
+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 Hewlett-Packard not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+Hewlett-Packard makes no representations about the
+suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+This software is not subject to any license of the American
+Telephone and Telegraph Company or of the Regents of the
+University of California.
+
+*/
+/* $XFree86: xc/lib/Xext/XTestExt1.c,v 1.3 2001/01/17 19:42:46 dawes Exp $ */
+
+/******************************************************************************
+ * include files
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include <X11/Xproto.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/xtestext1.h>
+#include <X11/extensions/xtestext1proto.h>
+
+/******************************************************************************
+ * variables
+ *****************************************************************************/
+
+/*
+ * Holds the request type code for this extension. The request type code
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial value given below will be added to the base request
+ * code that is acquired when this extension is installed.
+ */
+static int XTestReqCode = 0;
+/*
+ * Holds the two event type codes for this extension. The event type codes
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial values given below will be added to the base event
+ * code that is acquired when this extension is installed.
+ *
+ * These two variables must be available to programs that use this extension.
+ */
+int XTestInputActionType = 0;
+int XTestFakeAckType = 1;
+/*
+ * holds the current x and y coordinates for XTestMovePointer
+ */
+static int current_x = 0;
+static int current_y = 0;
+/*
+ * Holds input actions being accumulated until the input action buffer is
+ * full or until XTestFlush is called.
+ */
+static CARD8 action_buf[XTestMAX_ACTION_LIST_SIZE];
+/*
+ * the index into the input action buffer
+ */
+static int action_index = 0;
+/*
+ * the number of input actions that the server can handle at one time
+ */
+static unsigned long action_array_size = 0;
+/*
+ * the current number of input actions
+ */
+static unsigned long action_count = 0;
+
+/******************************************************************************
+ * function declarations
+ *****************************************************************************/
+
+static int XTestWireToEvent(Display *dpy, XEvent *reTemp, xEvent *eventTemp);
+static int XTestCheckExtInit(register Display *dpy);
+static Bool XTestIdentifyMyEvent(Display *display, XEvent *event_ptr, char *args);
+static int XTestInitExtension(register Display *dpy);
+static int XTestKeyOrButton(Display *display, int device_id, long unsigned int delay, unsigned int code, unsigned int action);
+static int XTestCheckDelay(Display *display, long unsigned int *delay_addr);
+static int XTestPackInputAction(Display *display, CARD8 *action_addr, int action_size);
+static int XTestWriteInputActions(Display *display, char *action_list_addr, int action_list_size, int ack_flag);
+
+/******************************************************************************
+ *
+ * XTestFakeInput
+ *
+ * Send a a request containing one or more input actions to be sent
+ * to the server by this extension.
+ */
+int
+XTestFakeInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * the address of a list of input actions to be sent to the server
+ */
+char *action_list_addr,
+/*
+ * the size (in bytes) of the list of input actions
+ */
+int action_list_size,
+/*
+ * specifies whether the server needs to send an event to indicate that its
+ * input action buffer is empty
+ */
+int ack_flag)
+{
+ /*
+ * pointer to xTestFakeInputReq structure
+ */
+ xTestFakeInputReq *req;
+ /*
+ * loop index
+ */
+ int i;
+
+ LockDisplay(dpy);
+ if ((XTestCheckExtInit(dpy) == -1) ||
+ (action_list_size > XTestMAX_ACTION_LIST_SIZE))
+ {
+ /*
+ * if the extension is not installed in the server or the
+ * action list will not fit in the request, then unlock
+ * the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestFakeInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestFakeInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestFakeInput
+ */
+ req->XTestReqType = X_TestFakeInput;
+ /*
+ * set the ack code
+ */
+ req->ack = ack_flag;
+ /*
+ * Set the action_list area to all 0's. An input action header
+ * value of 0 is interpreted as a flag to the input action
+ * list handling code in the server part of this extension
+ * that there are no more input actions in this request.
+ */
+ for (i = 0; i < XTestMAX_ACTION_LIST_SIZE; i++)
+ {
+ req->action_list[i] = 0;
+ }
+ /*
+ * copy the input actions into the request
+ */
+ for (i = 0; i < action_list_size; i++)
+ {
+ req->action_list[i] = *(action_list_addr++);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestGetInput
+ *
+ * Request the server to begin putting user input actions into events
+ * to be sent to the client that called this function.
+ */
+int
+XTestGetInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * tells the server what to do with the user input actions
+ */
+int action_handling)
+{
+ /*
+ * pointer to xTestGetInputReq structure
+ */
+ xTestGetInputReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestGetInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestGetInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestGetInput
+ */
+ req->XTestReqType = X_TestGetInput;
+ /*
+ * set the action handling mode
+ */
+ req->mode = action_handling;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestStopInput
+ *
+ * Tell the server to stop putting information about user input actions
+ * into events.
+ */
+int
+XTestStopInput(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * pointer to xTestStopInputReq structure
+ */
+ xTestStopInputReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestStopInput, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestStopInput, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestStopInput
+ */
+ req->XTestReqType = X_TestStopInput;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestReset
+ *
+ * Tell the server to set everything having to do with this extension
+ * back to its initial state.
+ */
+int
+XTestReset(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * pointer to xTestReset structure
+ */
+ xTestResetReq *req;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestReset, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestReset, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestReset
+ */
+ req->XTestReqType = X_TestReset;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestQueryInputSize
+ *
+ * Returns the number of input actions in the server's input action buffer.
+ */
+int
+XTestQueryInputSize(
+/*
+ * the connection to the X server
+ */
+register Display *dpy,
+/*
+ * the address of the place to put the number of input actions in the
+ * server's input action buffer
+ */
+unsigned long *size_return)
+{
+ /*
+ * pointer to xTestQueryInputSize structure
+ */
+ xTestQueryInputSizeReq *req;
+ /*
+ * pointer to xTestQueryInputSize structure
+ */
+ xTestQueryInputSizeReply rep;
+
+ LockDisplay(dpy);
+ if (XTestCheckExtInit(dpy) == -1)
+ {
+ /*
+ * if the extension is not installed in the server
+ * then unlock the display and return -1.
+ */
+ UnlockDisplay(dpy);
+ return(-1);
+ }
+ else
+ {
+ /*
+ * Get the next available X request packet in the buffer.
+ * It sets the `length' field to the size (in 32-bit words)
+ * of the request. It also sets the `reqType' field in the
+ * request to X_TestQueryInputSize, which is not what is needed.
+ *
+ * GetReq is a macro defined in Xlibint.h.
+ */
+ GetReq(TestQueryInputSize, req);
+ /*
+ * fix up the request type code to what is needed
+ */
+ req->reqType = XTestReqCode;
+ /*
+ * set the minor request type code to X_TestQueryInputSize
+ */
+ req->XTestReqType = X_TestQueryInputSize;
+ /*
+ * get a reply from the server
+ */
+ (void) _XReply (dpy, (xReply *) &rep, 0, xTrue);
+ /*
+ * put the size in the caller's variable
+ */
+ *size_return = (unsigned long) rep.size_return;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestCheckExtInit
+ *
+ * Check to see if the XTest extension is installed in the server.
+ */
+static int
+XTestCheckExtInit(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * if the extension has not been initialized, then do so
+ */
+ if (!XTestReqCode)
+ {
+ return(XTestInitExtension(dpy));
+ }
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestInitExtension
+ *
+ * Attempt to initialize this extension in the server. Return 0 if it
+ * succeeds, -1 if it does not succeed.
+ */
+static int
+XTestInitExtension(
+/*
+ * the connection to the X server
+ */
+register Display *dpy)
+{
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * return value from XInitExtension
+ */
+ XExtCodes *ret;
+
+ /*
+ * attempt to initialize the extension
+ */
+ ret = XInitExtension(dpy, XTestEXTENSION_NAME);
+ /*
+ * if the initialize failed, return -1
+ */
+ if (ret == NULL)
+ {
+ return (-1);
+ }
+ /*
+ * the initialize succeeded, remember the major opcode
+ * for this extension
+ */
+ XTestReqCode = ret->major_opcode;
+ /*
+ * set up the event handler for any events from
+ * this extension
+ */
+ for (i = 0; i < XTestEVENT_COUNT; i++)
+ {
+ XESetWireToEvent(dpy,
+ ret->first_event+i,
+ XTestWireToEvent);
+ }
+ /*
+ * compute the event type codes for the events
+ * in this extension
+ */
+ XTestInputActionType += ret->first_event;
+ XTestFakeAckType += ret->first_event;
+ /*
+ * everything worked ok
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestWireToEvent
+ *
+ * Handle XTest extension events.
+ * Reformat a wire event into an XEvent structure of the right type.
+ */
+static Bool
+XTestWireToEvent(
+/*
+ * the connection to the X server
+ */
+Display *dpy,
+/*
+ * a pointer to where a host formatted event should be stored
+ * with the information copied to it
+ */
+XEvent *reTemp,
+/*
+ * a pointer to the wire event
+ */
+xEvent *eventTemp)
+{
+ XTestInputActionEvent *re = (XTestInputActionEvent *) reTemp;
+ xTestInputActionEvent *event = (xTestInputActionEvent *) eventTemp;
+
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * pointer to where the input actions go in the host format event
+ */
+ CARD8 *to;
+ /*
+ * pointer to the input actions in the wire event
+ */
+ CARD8 *from;
+
+ /*
+ * Copy the type of the wire event to the new event.
+ * This will work for either event type because the type,
+ * display, and window fields in the events have to be the same.
+ */
+ re->type = event->type;
+ /*
+ * set the display parameter in case it is needed (by who?)
+ */
+ re->display = dpy;
+ if (re->type == XTestInputActionType)
+ {
+ /*
+ * point at the first byte of input actions in the wire event
+ */
+ from = &(event->actions[0]);
+ /*
+ * point at where the input action bytes go in the new event
+ */
+ to = &(re->actions[0]);
+ /*
+ * copy the input action bytes from the wire event to
+ * the new event
+ */
+ for (i = 0; i < XTestACTIONS_SIZE; i++)
+ {
+ *(to++) = *(from++);
+ }
+ }
+ else if (re->type == XTestFakeAckType)
+ {
+ /*
+ * nothing else needs to be done
+ */
+ }
+ else
+ {
+ printf("XTestWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",
+ (int) event->type);
+ printf("%s is giving up.\n", XTestEXTENSION_NAME);
+ exit (1);
+ }
+ return 1;
+}
+
+/******************************************************************************
+ *
+ * XTestPressKey
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified key on the keyboard was moved as specified.
+ */
+int
+XTestPressKey(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int keycode,
+unsigned int key_action)
+{
+ /*
+ * bounds check the key code
+ */
+ if (keycode < 8 || keycode > 255)
+ {
+ return(-1);
+ }
+ /*
+ * use the commmon key/button handling routine
+ */
+ return(XTestKeyOrButton(display,
+ device_id,
+ delay,
+ keycode,
+ key_action));
+}
+
+/******************************************************************************
+ *
+ * XTestPressButton
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified button on the mouse was moved as specified.
+ */
+int
+XTestPressButton(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int button_number,
+unsigned int button_action)
+{
+ /*
+ * bounds check the button number
+ */
+ if (button_number > 7)
+ {
+ return(-1);
+ }
+ /*
+ * use the commmon key/button handling routine
+ */
+ return(XTestKeyOrButton(display,
+ device_id,
+ delay,
+ button_number,
+ button_action));
+}
+
+/******************************************************************************
+ *
+ * XTestKeyOrButton
+ *
+ * Send input actions to the server to cause the server to think
+ * that the specified key/button was moved as specified.
+ */
+static int
+XTestKeyOrButton(
+Display *display,
+int device_id,
+unsigned long delay,
+unsigned int code,
+unsigned int action)
+{
+ /*
+ * holds a key input action to be filled out and sent to the server
+ */
+ XTestKeyInfo keyinfo;
+
+ /*
+ * bounds check the device id
+ */
+ if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
+ {
+ return(-1);
+ }
+ /*
+ * fill out the key input action(s) as appropriate
+ */
+ switch(action)
+ {
+ case XTestPRESS:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create the header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_DOWN;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ case XTestRELEASE:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create the header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_UP;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ case XTestSTROKE:
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create a key/button-down input action header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_DOWN;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * set the delay to XTestSTROKE_DELAY_TIME
+ */
+ delay = XTestSTROKE_DELAY_TIME;
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * key input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &delay) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * create a key/button-up input action header
+ */
+ keyinfo.header = XTestPackDeviceID(device_id) |
+ XTestKEY_ACTION |
+ XTestKEY_UP;
+ /*
+ * set the key/button code
+ */
+ keyinfo.keycode = code;
+ /*
+ * set the delay time
+ */
+ keyinfo.delay_time = delay;
+ /*
+ * pack the input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &keyinfo,
+ sizeof(XTestKeyInfo)));
+ default:
+ /*
+ * invalid action value, return -1
+ */
+ return(-1);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestMovePointer
+ *
+ * Send input actions to the server to cause the server to think
+ * that the mouse was moved as specified.
+ */
+int
+XTestMovePointer(
+Display *display,
+int device_id,
+unsigned long delay[],
+int x[],
+int y[],
+unsigned int count)
+{
+ /*
+ * holds a motion input action to be filled out and sent to the server
+ */
+ XTestMotionInfo motioninfo;
+ /*
+ * holds a jump input action to be filled out and sent to the server
+ */
+ XTestJumpInfo jumpinfo;
+ /*
+ * loop index
+ */
+ unsigned int i;
+ /*
+ * holds the change in x and y directions from the current x and y
+ * coordinates
+ */
+ int dx;
+ int dy;
+
+ /*
+ * bounds check the device id
+ */
+ if (device_id < 0 || device_id > XTestMAX_DEVICE_ID)
+ {
+ return(-1);
+ }
+ /*
+ * if the count is 0, there is nothing to do. return 0
+ */
+ if (count == 0)
+ {
+ return(0);
+ }
+ /*
+ * loop through the pointer motions, creating the appropriate
+ * input actions for each motion
+ */
+ for (i = 0; i < count; i++)
+ {
+ /*
+ * Check the delay. If it is larger than will fit in the
+ * input action, send a delay input action.
+ */
+ if(XTestCheckDelay(display, &(delay[i])) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ /*
+ * compute the change from the current x and y coordinates
+ * to the new x and y coordinates
+ */
+ dx = x[i] - current_x;
+ dy = y[i] - current_y;
+ /*
+ * update the current x and y coordinates
+ */
+ current_x = x[i];
+ current_y = y[i];
+ /*
+ * If the pointer motion range is too large to fit into
+ * a motion input action, then use a jump input action.
+ * Otherwise, use a motion input action.
+ */
+ if ((dx > XTestMOTION_MAX) || (dx < XTestMOTION_MIN) ||
+ (dy > XTestMOTION_MAX) || (dy < XTestMOTION_MIN))
+ {
+ /*
+ * create a jump input action header
+ */
+ jumpinfo.header = XTestPackDeviceID(device_id) |
+ XTestJUMP_ACTION;
+ /*
+ * set the x and y coordinates to jump to
+ */
+ jumpinfo.jumpx = x[i];
+ jumpinfo.jumpy = y[i];
+ /*
+ * set the delay time
+ */
+ jumpinfo.delay_time = delay[i];
+ /*
+ * pack the jump input action into a request to be
+ * sent to the server when the request is full
+ * or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &jumpinfo,
+ sizeof(XTestJumpInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ }
+ else
+ {
+ /*
+ * create a motion input action header
+ */
+ motioninfo.header = XTestPackDeviceID(device_id) |
+ XTestMOTION_ACTION;
+ /*
+ * compute the motion data byte
+ */
+ if (dx < 0)
+ {
+ motioninfo.header |= XTestX_NEGATIVE;
+ dx = abs(dx);
+ }
+ if (dy < 0)
+ {
+ motioninfo.header |= XTestY_NEGATIVE;
+ dy = abs(dy);
+ }
+ motioninfo.motion_data = XTestPackXMotionValue(dx);
+ motioninfo.motion_data |= XTestPackYMotionValue(dy);
+ /*
+ * set the delay time
+ */
+ motioninfo.delay_time = delay[i];
+ /*
+ * pack the motion input action into a request to be
+ * sent to the server when the request is full
+ * or XTestFlush is called
+ */
+ if (XTestPackInputAction(display,
+ (CARD8 *) &motioninfo,
+ sizeof(XTestMotionInfo)) == -1)
+ {
+ /*
+ * an error occurred, return -1
+ */
+ return(-1);
+ }
+ }
+ }
+ /*
+ * if you get here, everything went ok
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestCheckDelay
+ *
+ * Check the delay value at the passed-in address. If it is larger than
+ * will fit in a normal input action, then send a delay input action.
+ */
+static int
+XTestCheckDelay(
+Display *display,
+unsigned long *delay_addr)
+{
+ /*
+ * holds a delay input action to be filled out and sent to the server
+ */
+ XTestDelayInfo delayinfo;
+
+ /*
+ * if the delay value will fit in the input action,
+ * then there is no need for a delay input action
+ */
+ if (*delay_addr <= XTestSHORT_DELAY_TIME)
+ {
+ return(0);
+ }
+ /*
+ * fill out a delay input action
+ */
+ delayinfo.header = XTestPackDeviceID(XTestDELAY_DEVICE_ID);
+ delayinfo.delay_time = *delay_addr;
+ /*
+ * all of the delay time will be accounted for in the
+ * delay input action, so set the original delay value to 0
+ */
+ *delay_addr = 0;
+ /*
+ * pack the delay input action into a request to be sent to the
+ * server when the request is full or XTestFlush is called
+ */
+ return(XTestPackInputAction(display,
+ (CARD8 *) &delayinfo,
+ sizeof(XTestDelayInfo)));
+}
+
+/******************************************************************************
+ *
+ * XTestPackInputAction
+ *
+ * If the input action buffer is full or the number of input actions
+ * has reached the maximum that the server can handle at one time,
+ * then send the input actions to the server using XTestFakeInput.
+ */
+static int
+XTestPackInputAction(
+Display *display,
+CARD8 *action_addr,
+int action_size)
+{
+ /*
+ * loop index
+ */
+ int i;
+ /*
+ * acknowledge flag
+ */
+ int ack_flag;
+
+ /*
+ * if we don't already know it, find out how many input actions
+ * the server can handle at one time
+ */
+ if (action_array_size == 0)
+ {
+ if(XTestQueryInputSize(display, &action_array_size) == -1)
+ {
+ /*
+ * if an error, return -1
+ */
+ return(-1);
+ }
+ }
+ /*
+ * if the specified input action will fit in the the input
+ * action buffer and won't exceed the server's capacity, then
+ * put the input action into the input buffer
+ */
+ if(((action_index + action_size) <= XTestMAX_ACTION_LIST_SIZE) &&
+ ((action_count + 1) < action_array_size))
+ {
+ /*
+ * copy the input action into the buffer
+ */
+ for (i = 0; i < action_size; i++)
+ {
+ action_buf[action_index++] = *(action_addr++);
+ }
+ /*
+ * increment the action count
+ */
+ action_count++;
+ /*
+ * everything went ok, return 0
+ */
+ return(0);
+ }
+ /*
+ * We have to write input actions to the server. If the server's
+ * input action capacity will be reached, then ask for an
+ * acknowledge event when the server has processed all of the
+ * input actions. Otherwise, an acknowledge event is not needed.
+ */
+ if (action_count >= action_array_size)
+ {
+ ack_flag = XTestFAKE_ACK_REQUEST;
+ }
+ else
+ {
+ ack_flag = XTestFAKE_ACK_NOT_NEEDED;
+ }
+ /*
+ * write the input actions to the server
+ */
+ if (XTestWriteInputActions(display,
+ (char *) &(action_buf[0]),
+ action_index,
+ ack_flag) == -1)
+ {
+ /*
+ * error, return -1
+ */
+ return(-1);
+ }
+ /*
+ * copy the input action into the buffer
+ */
+ for (i = 0; i < action_size; i++)
+ {
+ action_buf[action_index++] = *(action_addr++);
+ }
+ /*
+ * increment the action count
+ */
+ action_count++;
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestWriteInputActions
+ *
+ * Send input actions to the server.
+ */
+static int
+XTestWriteInputActions(
+Display *display,
+char *action_list_addr,
+int action_list_size,
+int ack_flag)
+{
+ /*
+ * Holds an event. Used while waiting for an acknowledge event
+ */
+ XEvent event;
+ /*
+ * points to XTestIdentifyMyEvent
+ */
+ Bool (*func_ptr)(Display *, XEvent *, XPointer);
+
+ /*
+ * write the input actions to the server
+ */
+ if (XTestFakeInput(display,
+ action_list_addr,
+ action_list_size,
+ ack_flag) == -1)
+ {
+ /*
+ * if an error, return -1
+ */
+ return(-1);
+ }
+ /*
+ * flush X's buffers to make sure that the server really gets
+ * the input actions
+ */
+ XFlush(display);
+ /*
+ * mark the input action buffer as empty
+ */
+ action_index = 0;
+ /*
+ * if we asked for an acknowledge event, then wait for it
+ */
+ if (ack_flag == XTestFAKE_ACK_REQUEST)
+ {
+ /*
+ * point func_ptr at XTestIdentifyMyEvent
+ */
+ func_ptr = XTestIdentifyMyEvent;
+ /*
+ * Wait until the acknowledge event comes. When the
+ * acknowledge event comes, it is removed from the event
+ * queue without disturbing any other events that might
+ * be in the queue.
+ */
+ XIfEvent(display, &event, func_ptr, NULL);
+ /*
+ * set the input action count back to 0
+ */
+ action_count = 0;
+ }
+ /*
+ * if we got here, then everything is ok, return 0
+ */
+ return(0);
+}
+
+/******************************************************************************
+ *
+ * XTestIdentifyMyEvent
+ *
+ * This function is called by XIfEvent to look at an event and see if
+ * it is of XTestFakeAckType.
+ */
+static Bool
+XTestIdentifyMyEvent(
+Display *display,
+/*
+ * Holds the event that this routine is supposed to look at.
+ */
+XEvent *event_ptr,
+/*
+ * this points to any user-specified arguments (ignored)
+ */
+char *args)
+{
+ /*
+ * if the event if of the correct type, return the Bool True,
+ * otherwise return the Bool False.
+ */
+ if (event_ptr->type == XTestFakeAckType)
+ {
+ return(True);
+ }
+ else
+ {
+ return(False);
+ }
+}
+
+/******************************************************************************
+ *
+ * XTestFlush
+ *
+ * Send any input actions in the input action buffer to the server.
+ */
+int
+XTestFlush(Display *display)
+{
+ /*
+ * acknowledge flag
+ */
+ int ack_flag;
+
+ /*
+ * if there are no input actions in the input action buffer,
+ * then return 0
+ */
+ if (action_index == 0)
+ {
+ return(0);
+ }
+ /*
+ * We have input actions to write to the server. We will
+ * wait until the server has finished processing the input actions.
+ */
+ ack_flag = XTestFAKE_ACK_REQUEST;
+ /*
+ * write the input actions to the server
+ */
+ return(XTestWriteInputActions(display,
+ (char *) &(action_buf[0]),
+ action_index,
+ ack_flag));
+}
diff --git a/libXext/src/Xcup.c b/libXext/src/Xcup.c
index 6013039ef..8d3cb70a2 100644
--- a/libXext/src/Xcup.c
+++ b/libXext/src/Xcup.c
@@ -1,266 +1,264 @@
-/* $XFree86: xc/lib/Xext/Xcup.c,v 1.8 2002/10/16 02:19:22 dawes Exp $ */
-/*
-
-Copyright 1987, 1988, 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.
-
-*/
-/* $Xorg: Xcup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#ifdef WIN32
-#include <X11/Xwindows.h>
-#endif
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xcup.h>
-#include <X11/extensions/cupproto.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
-
-static XExtensionInfo _xcup_info_data;
-static XExtensionInfo *xcup_info = &_xcup_info_data;
-static char *xcup_extension_name = XCUPNAME;
-
-/*****************************************************************************
- * *
- * private utility routines *
- * *
- *****************************************************************************/
-
-static int close_display(Display *dpy, XExtCodes *codes);
-static /* const */ XExtensionHooks xcup_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xcup_info,
- xcup_extension_name,
- &xcup_extension_hooks,
- 0, NULL)
-
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xcup_info)
-
-
-/*****************************************************************************
- * *
- * public Xcup Extension routines *
- * *
- *****************************************************************************/
-
-Status
-XcupQueryVersion(
- Display* dpy,
- int* major_version_return,
- int* minor_version_return)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXcupQueryVersionReply rep;
- xXcupQueryVersionReq *req;
-
- XextCheckExtension (dpy, info, xcup_extension_name, False);
-
- LockDisplay(dpy);
- GetReq(XcupQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->xcupReqType = X_XcupQueryVersion;
- req->client_major_version = XCUP_MAJOR_VERSION;
- req->client_minor_version = XCUP_MINOR_VERSION;
- if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
- *major_version_return = rep.server_major_version;
- *minor_version_return = rep.server_minor_version;
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
-}
-
-/* Win32 reserves 20 colormap entries for its desktop */
-#ifndef TYP_RESERVED_ENTRIES
-#define TYP_RESERVED_ENTRIES 20
-#endif
-
-Status
-XcupGetReservedColormapEntries(
- Display* dpy,
- int screen,
- XColor** colors_out,
- int* ncolors)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXcupGetReservedColormapEntriesReply rep;
- xXcupGetReservedColormapEntriesReq *req;
- xColorItem rbuf[TYP_RESERVED_ENTRIES];
-
- *ncolors = 0;
-
- XextCheckExtension (dpy, info, xcup_extension_name, False);
-
- LockDisplay(dpy);
- GetReq(XcupGetReservedColormapEntries, req);
- req->reqType = info->codes->major_opcode;
- req->xcupReqType = X_XcupGetReservedColormapEntries;
- req->screen = screen;
- if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- long nbytes;
- xColorItem* rbufp;
- int nentries = rep.length / 3;
-
- nbytes = nentries * SIZEOF (xColorItem);
- if (nentries > TYP_RESERVED_ENTRIES)
- rbufp = (xColorItem*) Xmalloc (nbytes);
- else
- rbufp = rbuf;
-
- if (rbufp == NULL) {
- _XEatData (dpy, (unsigned long) nbytes);
- UnlockDisplay (dpy);
- SyncHandle ();
- return False;
- }
- _XRead (dpy, (char*) rbufp, nbytes);
-
- *colors_out = (XColor*) Xmalloc (nentries * sizeof (XColor));
- if (*colors_out) {
- xColorItem* cs = (xColorItem *) rbufp;
- XColor* cd = *colors_out;
- int i;
-
- *ncolors = nentries;
- for (i = 0; i < *ncolors; i++, cd++) {
- cd->pixel = cs->pixel;
- cd->red = cs->red;
- cd->green = cs->green;
- cd->blue = cs->blue;
- cs = (xColorItem*) (((char*) cs) + SIZEOF(xColorItem));
- }
- if (rbufp != rbuf) XFree ((char*) rbufp);
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
- }
- if (rbufp != rbuf) XFree ((char*) rbufp);
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
-}
-
-Status
-XcupStoreColors(
- Display* dpy,
- Colormap colormap,
- XColor* colors_in_out,
- int ncolors)
-{
- XExtDisplayInfo *info = find_display (dpy);
- xXcupStoreColorsReply rep;
- xXcupStoreColorsReq *req;
- xColorItem rbuf[256];
- xColorItem citem;
- int i;
- XColor* xcp;
-
- XextCheckExtension (dpy, info, xcup_extension_name, False);
-
- LockDisplay(dpy);
- GetReq(XcupStoreColors, req);
- req->reqType = info->codes->major_opcode;
- req->xcupReqType = X_XcupStoreColors;
- req->cmap = colormap;
- req->length += (ncolors * SIZEOF(xColorItem)) >> 2;
-
- for (i = 0, xcp = colors_in_out; i < ncolors; i++, xcp++) {
- citem.pixel = xcp->pixel;
- citem.red = xcp->red;
- citem.green = xcp->green;
- citem.blue = xcp->blue;
-
- /* note that xColorItem doesn't contain all 16-bit quantities, so
- we can't use Data16 */
- Data(dpy, (char *)&citem, (long) SIZEOF(xColorItem));
- }
-
- if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- long nbytes;
- xColorItem* rbufp;
- xColorItem* cs;
- int nentries = rep.length / 3;
-
- nbytes = nentries * SIZEOF (xColorItem);
-
- if (nentries != ncolors) {
- _XEatData (dpy, (unsigned long) nbytes);
- UnlockDisplay (dpy);
- SyncHandle ();
- return False;
- }
-
- if (ncolors > 256)
- rbufp = (xColorItem*) Xmalloc (nbytes);
- else
- rbufp = rbuf;
-
- if (rbufp == NULL) {
- _XEatData (dpy, (unsigned long) nbytes);
- UnlockDisplay (dpy);
- SyncHandle ();
- return False;
-
- }
-
- _XRead (dpy, (char*) rbufp, nbytes);
-
- for (i = 0, xcp = colors_in_out, cs = rbufp; i < ncolors; i++, xcp++, cs++) {
- xcp->pixel = cs->pixel;
- xcp->red = cs->red;
- xcp->green = cs->green;
- xcp->blue = cs->blue;
- xcp->flags = cs->flags;
- }
- if (rbufp != rbuf) XFree ((char*)rbufp);
-
- UnlockDisplay(dpy);
- SyncHandle();
- return True;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
-}
-
+/* $XFree86: xc/lib/Xext/Xcup.c,v 1.8 2002/10/16 02:19:22 dawes Exp $ */
+/*
+
+Copyright 1987, 1988, 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.
+
+*/
+/* $Xorg: Xcup.c,v 1.5 2001/02/09 02:03:49 xorgcvs Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#endif
+
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xcup.h>
+#include <X11/extensions/cupproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+
+static XExtensionInfo _xcup_info_data;
+static XExtensionInfo *xcup_info = &_xcup_info_data;
+static char *xcup_extension_name = XCUPNAME;
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *codes);
+static /* const */ XExtensionHooks xcup_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xcup_info,
+ xcup_extension_name,
+ &xcup_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xcup_info)
+
+
+/*****************************************************************************
+ * *
+ * public Xcup Extension routines *
+ * *
+ *****************************************************************************/
+
+Status
+XcupQueryVersion(
+ Display* dpy,
+ int* major_version_return,
+ int* minor_version_return)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupQueryVersionReply rep;
+ xXcupQueryVersionReq *req;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupQueryVersion;
+ req->client_major_version = XCUP_MAJOR_VERSION;
+ req->client_minor_version = XCUP_MINOR_VERSION;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ *major_version_return = rep.server_major_version;
+ *minor_version_return = rep.server_minor_version;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+/* Win32 reserves 20 colormap entries for its desktop */
+#ifndef TYP_RESERVED_ENTRIES
+#define TYP_RESERVED_ENTRIES 20
+#endif
+
+Status
+XcupGetReservedColormapEntries(
+ Display* dpy,
+ int screen,
+ XColor** colors_out,
+ int* ncolors)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupGetReservedColormapEntriesReply rep;
+ xXcupGetReservedColormapEntriesReq *req;
+ xColorItem rbuf[TYP_RESERVED_ENTRIES];
+
+ *ncolors = 0;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupGetReservedColormapEntries, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupGetReservedColormapEntries;
+ req->screen = screen;
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ long nbytes;
+ xColorItem* rbufp;
+ int nentries = rep.length / 3;
+
+ nbytes = nentries * SIZEOF (xColorItem);
+ if (nentries > TYP_RESERVED_ENTRIES)
+ rbufp = (xColorItem*) Xmalloc (nbytes);
+ else
+ rbufp = rbuf;
+
+ if (rbufp == NULL) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+ _XRead (dpy, (char*) rbufp, nbytes);
+
+ *colors_out = (XColor*) Xmalloc (nentries * sizeof (XColor));
+ if (*colors_out) {
+ xColorItem* cs = (xColorItem *) rbufp;
+ XColor* cd = *colors_out;
+ int i;
+
+ *ncolors = nentries;
+ for (i = 0; i < *ncolors; i++, cd++) {
+ cd->pixel = cs->pixel;
+ cd->red = cs->red;
+ cd->green = cs->green;
+ cd->blue = cs->blue;
+ cs = (xColorItem*) (((char*) cs) + SIZEOF(xColorItem));
+ }
+ if (rbufp != rbuf) XFree ((char*) rbufp);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+ }
+ if (rbufp != rbuf) XFree ((char*) rbufp);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+}
+
+Status
+XcupStoreColors(
+ Display* dpy,
+ Colormap colormap,
+ XColor* colors_in_out,
+ int ncolors)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXcupStoreColorsReply rep;
+ xXcupStoreColorsReq *req;
+ xColorItem rbuf[256];
+ xColorItem citem;
+ int i;
+ XColor* xcp;
+
+ XextCheckExtension (dpy, info, xcup_extension_name, False);
+
+ LockDisplay(dpy);
+ GetReq(XcupStoreColors, req);
+ req->reqType = info->codes->major_opcode;
+ req->xcupReqType = X_XcupStoreColors;
+ req->cmap = colormap;
+ req->length += (ncolors * SIZEOF(xColorItem)) >> 2;
+
+ for (i = 0, xcp = colors_in_out; i < ncolors; i++, xcp++) {
+ citem.pixel = xcp->pixel;
+ citem.red = xcp->red;
+ citem.green = xcp->green;
+ citem.blue = xcp->blue;
+
+ /* note that xColorItem doesn't contain all 16-bit quantities, so
+ we can't use Data16 */
+ Data(dpy, (char *)&citem, (long) SIZEOF(xColorItem));
+ }
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ long nbytes;
+ xColorItem* rbufp;
+ xColorItem* cs;
+ int nentries = rep.length / 3;
+
+ nbytes = nentries * SIZEOF (xColorItem);
+
+ if (nentries != ncolors) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+ }
+
+ if (ncolors > 256)
+ rbufp = (xColorItem*) Xmalloc (nbytes);
+ else
+ rbufp = rbuf;
+
+ if (rbufp == NULL) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return False;
+
+ }
+
+ _XRead (dpy, (char*) rbufp, nbytes);
+
+ for (i = 0, xcp = colors_in_out, cs = rbufp; i < ncolors; i++, xcp++, cs++) {
+ xcp->pixel = cs->pixel;
+ xcp->red = cs->red;
+ xcp->green = cs->green;
+ xcp->blue = cs->blue;
+ xcp->flags = cs->flags;
+ }
+ if (rbufp != rbuf) XFree ((char*)rbufp);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+}
+
diff --git a/libXext/src/Xdbe.c b/libXext/src/Xdbe.c
index 2dd3509ca..5b8573e19 100644
--- a/libXext/src/Xdbe.c
+++ b/libXext/src/Xdbe.c
@@ -32,8 +32,6 @@
*****************************************************************************/
/* $XFree86: xc/lib/Xext/Xdbe.c,v 3.7 2002/10/16 02:19:22 dawes Exp $ */
-#define NEED_EVENTS
-#define NEED_REPLIES
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/libXext/src/Xge.c b/libXext/src/Xge.c
index 7a583e5aa..724011eab 100644
--- a/libXext/src/Xge.c
+++ b/libXext/src/Xge.c
@@ -1,368 +1,365 @@
-/*
- * Copyright © 2007-2008 Peter Hutterer
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors: Peter Hutterer, University of South Australia, NICTA
- */
-
-/*
- * XGE is an extension to re-use a single opcode for multiple events,
- * depending on the extension. XGE allows events >32 bytes.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define NEED_EVENTS
-#define NEED_REPLIES
-
-#include <stdio.h>
-#include <X11/extensions/geproto.h>
-#include <X11/extensions/ge.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/extutil.h>
-#include <X11/extensions/Xge.h>
-
-/***********************************************************************/
-/* internal data structures */
-/***********************************************************************/
-
-typedef struct {
- int present;
- short major_version;
- short minor_version;
-} XGEVersionRec;
-
-/* NULL terminated list of registered extensions. */
-typedef struct _XGEExtNode {
- int extension;
- XExtensionHooks* hooks;
- struct _XGEExtNode* next;
-} XGEExtNode, *XGEExtList;
-
-/* Internal data for GE extension */
-typedef struct _XGEData {
- XEvent data;
- XGEVersionRec *vers;
- XGEExtList extensions;
-} XGEData;
-
-
-/* forward declarations */
-static XExtDisplayInfo* _xgeFindDisplay(Display*);
-static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*);
-static Status _xgeEventToWire(Display*, XEvent*, xEvent*);
-static int _xgeDpyClose(Display*, XExtCodes*);
-static XGEVersionRec* _xgeGetExtensionVersion(Display*,
- _Xconst char*,
- XExtDisplayInfo*);
-static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info);
-
-/* main extension information data */
-static XExtensionInfo *xge_info;
-static char xge_extension_name[] = GE_NAME;
-static XExtensionHooks xge_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- _xgeDpyClose, /* close_display */
- _xgeWireToEvent, /* wire_to_event */
- _xgeEventToWire, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-
-static XExtDisplayInfo *_xgeFindDisplay(Display *dpy)
-{
- XExtDisplayInfo *dpyinfo;
- if (!xge_info)
- {
- if (!(xge_info = XextCreateExtension()))
- return NULL;
- }
- if (!(dpyinfo = XextFindDisplay (xge_info, dpy)))
- {
- dpyinfo = XextAddDisplay (xge_info,
- dpy,
- xge_extension_name,
- &xge_extension_hooks,
- 0 /* no events, see below */,
- NULL);
- /* We don't use an extension opcode, so we have to set the handlers
- * directly. If GenericEvent would be > 64, the job would be done by
- * XExtAddDisplay */
- XESetWireToEvent (dpy,
- GenericEvent,
- xge_extension_hooks.wire_to_event);
- XESetEventToWire (dpy,
- GenericEvent,
- xge_extension_hooks.event_to_wire);
- }
- return dpyinfo;
-}
-
-/*
- * Check extension is set up and internal data fields are filled.
- */
-static Bool
-_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info)
-{
- LockDisplay(dpy);
- if(!_xgeCheckExtension(dpy, info))
- {
- goto cleanup;
- }
-
- if (!info->data)
- {
- XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData));
- if (!data) {
- goto cleanup;
- }
- /* get version from server */
- data->vers =
- _xgeGetExtensionVersion(dpy, "Generic Event Extension", info);
- data->extensions = NULL;
- info->data = (XPointer)data;
- }
-
- UnlockDisplay(dpy);
- return True;
-
-cleanup:
- UnlockDisplay(dpy);
- return False;
-}
-
-/* Return 1 if XGE extension exists, 0 otherwise. */
-static Bool
-_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info)
-{
- return XextHasExtension(info);
-}
-
-
-/* Retrieve XGE version number from server. */
-static XGEVersionRec*
-_xgeGetExtensionVersion(Display* dpy,
- _Xconst char* name,
- XExtDisplayInfo*info)
-{
- xGEQueryVersionReply rep;
- xGEQueryVersionReq *req;
- XGEVersionRec *vers;
-
- GetReq(GEQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->ReqType = X_GEQueryVersion;
- req->majorVersion = GE_MAJOR;
- req->minorVersion = GE_MINOR;
-
- if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
- {
- Xfree(info);
- return NULL;
- }
-
- vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec));
- vers->major_version = rep.majorVersion;
- vers->minor_version = rep.minorVersion;
- return vers;
-}
-
-/*
- * Display closing routine.
- */
-
-static int
-_xgeDpyClose(Display* dpy, XExtCodes* codes)
-{
- XExtDisplayInfo *info = _xgeFindDisplay(dpy);
-
- if (info->data != NULL) {
- XGEData* xge_data = (XGEData*)info->data;
-
- if (xge_data->extensions)
- {
- XGEExtList current, next;
- current = xge_data->extensions;
- while(current)
- {
- next = current->next;
- Xfree(current);
- current = next;
- }
- }
-
- XFree(xge_data->vers);
- XFree(xge_data);
- }
-
- return XextRemoveDisplay(xge_info, dpy);
-}
-
-/*
- * protocol to Xlib event conversion routine.
- */
-static Bool
-_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event)
-{
- int extension;
- XGEExtList it;
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False;
- /*
- _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT.
- Well, I guess we don't need the data we get in CheckExtInit anyway
- if (!_xgeCheckExtInit(dpy, info))
- return False;
- */
-
- extension = ((xGenericEvent*)event)->extension;
-
- it = ((XGEData*)info->data)->extensions;
- while(it)
- {
- if (it->extension == extension)
- {
- return (it->hooks->wire_to_event(dpy, re, event));
- }
- it = it->next;
- }
-
- fprintf(stderr,
- "_xgeWireToEvent: Unknown extension %d, this should never happen.\n",
- extension);
- return False;
-}
-
-/*
- * xlib event to protocol conversion routine.
- */
-static Status
-_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
-{
- int extension;
- XGEExtList it;
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return 1; /* error! */
-
- extension = ((XGenericEvent*)re)->extension;
-
- it = ((XGEData*)info->data)->extensions;
- while(it)
- {
- if (it->extension == extension)
- {
- return (it->hooks->event_to_wire(dpy, re, event));
- }
- it = it->next;
- }
-
- fprintf(stderr,
- "_xgeEventToWire: Unknown extension %d, this should never happen.\n",
- extension);
-
- return Success;
-}
-
-/*
- * Extensions need to register callbacks for their events.
- */
-Bool
-xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
-{
- XGEExtNode* newExt;
- XGEData* xge_data;
-
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False; /* error! */
-
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- xge_data = (XGEData*)info->data;
-
- newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode));
- if (!newExt)
- {
- fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n");
- return False;
- }
-
- newExt->extension = offset;
- newExt->hooks = callbacks;
- newExt->next = xge_data->extensions;
- xge_data->extensions = newExt;
-
- return True;
-}
-
-/***********************************************************************/
-/* Client interfaces */
-/***********************************************************************/
-
-/* Set event_base and error_base to the matching values for XGE.
- * Note that since XGE doesn't use any errors and events, the actual return
- * value is of limited use.
- */
-Bool
-XGEQueryExtension(Display* dpy, int* event_base, int* error_base)
-{
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- *event_base = info->codes->first_event;
- *error_base = info->codes->first_error;
- return True;
-}
-
-/* Get XGE version number.
- * Doesn't actually get it from server, that should have been done beforehand
- * already
- */
-Bool
-XGEQueryVersion(Display* dpy,
- int *major_version,
- int *minor_version)
-{
- XExtDisplayInfo* info = _xgeFindDisplay(dpy);
- if (!info)
- return False;
-
- if (!_xgeCheckExtInit(dpy, info))
- return False;
-
- *major_version = ((XGEData*)info->data)->vers->major_version;
- *minor_version = ((XGEData*)info->data)->vers->minor_version;
-
- return True;
-}
-
+/*
+ * Copyright © 2007-2008 Peter Hutterer
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors: Peter Hutterer, University of South Australia, NICTA
+ */
+
+/*
+ * XGE is an extension to re-use a single opcode for multiple events,
+ * depending on the extension. XGE allows events >32 bytes.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/extensions/geproto.h>
+#include <X11/extensions/ge.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xge.h>
+
+/***********************************************************************/
+/* internal data structures */
+/***********************************************************************/
+
+typedef struct {
+ int present;
+ short major_version;
+ short minor_version;
+} XGEVersionRec;
+
+/* NULL terminated list of registered extensions. */
+typedef struct _XGEExtNode {
+ int extension;
+ XExtensionHooks* hooks;
+ struct _XGEExtNode* next;
+} XGEExtNode, *XGEExtList;
+
+/* Internal data for GE extension */
+typedef struct _XGEData {
+ XEvent data;
+ XGEVersionRec *vers;
+ XGEExtList extensions;
+} XGEData;
+
+
+/* forward declarations */
+static XExtDisplayInfo* _xgeFindDisplay(Display*);
+static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*);
+static Status _xgeEventToWire(Display*, XEvent*, xEvent*);
+static int _xgeDpyClose(Display*, XExtCodes*);
+static XGEVersionRec* _xgeGetExtensionVersion(Display*,
+ _Xconst char*,
+ XExtDisplayInfo*);
+static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info);
+
+/* main extension information data */
+static XExtensionInfo *xge_info;
+static char xge_extension_name[] = GE_NAME;
+static XExtensionHooks xge_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ _xgeDpyClose, /* close_display */
+ _xgeWireToEvent, /* wire_to_event */
+ _xgeEventToWire, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+
+static XExtDisplayInfo *_xgeFindDisplay(Display *dpy)
+{
+ XExtDisplayInfo *dpyinfo;
+ if (!xge_info)
+ {
+ if (!(xge_info = XextCreateExtension()))
+ return NULL;
+ }
+ if (!(dpyinfo = XextFindDisplay (xge_info, dpy)))
+ {
+ dpyinfo = XextAddDisplay (xge_info,
+ dpy,
+ xge_extension_name,
+ &xge_extension_hooks,
+ 0 /* no events, see below */,
+ NULL);
+ /* We don't use an extension opcode, so we have to set the handlers
+ * directly. If GenericEvent would be > 64, the job would be done by
+ * XExtAddDisplay */
+ XESetWireToEvent (dpy,
+ GenericEvent,
+ xge_extension_hooks.wire_to_event);
+ XESetEventToWire (dpy,
+ GenericEvent,
+ xge_extension_hooks.event_to_wire);
+ }
+ return dpyinfo;
+}
+
+/*
+ * Check extension is set up and internal data fields are filled.
+ */
+static Bool
+_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info)
+{
+ LockDisplay(dpy);
+ if(!_xgeCheckExtension(dpy, info))
+ {
+ goto cleanup;
+ }
+
+ if (!info->data)
+ {
+ XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData));
+ if (!data) {
+ goto cleanup;
+ }
+ /* get version from server */
+ data->vers =
+ _xgeGetExtensionVersion(dpy, "Generic Event Extension", info);
+ data->extensions = NULL;
+ info->data = (XPointer)data;
+ }
+
+ UnlockDisplay(dpy);
+ return True;
+
+cleanup:
+ UnlockDisplay(dpy);
+ return False;
+}
+
+/* Return 1 if XGE extension exists, 0 otherwise. */
+static Bool
+_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info)
+{
+ return XextHasExtension(info);
+}
+
+
+/* Retrieve XGE version number from server. */
+static XGEVersionRec*
+_xgeGetExtensionVersion(Display* dpy,
+ _Xconst char* name,
+ XExtDisplayInfo*info)
+{
+ xGEQueryVersionReply rep;
+ xGEQueryVersionReq *req;
+ XGEVersionRec *vers;
+
+ GetReq(GEQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->ReqType = X_GEQueryVersion;
+ req->majorVersion = GE_MAJOR;
+ req->minorVersion = GE_MINOR;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue))
+ {
+ Xfree(info);
+ return NULL;
+ }
+
+ vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec));
+ vers->major_version = rep.majorVersion;
+ vers->minor_version = rep.minorVersion;
+ return vers;
+}
+
+/*
+ * Display closing routine.
+ */
+
+static int
+_xgeDpyClose(Display* dpy, XExtCodes* codes)
+{
+ XExtDisplayInfo *info = _xgeFindDisplay(dpy);
+
+ if (info->data != NULL) {
+ XGEData* xge_data = (XGEData*)info->data;
+
+ if (xge_data->extensions)
+ {
+ XGEExtList current, next;
+ current = xge_data->extensions;
+ while(current)
+ {
+ next = current->next;
+ Xfree(current);
+ current = next;
+ }
+ }
+
+ XFree(xge_data->vers);
+ XFree(xge_data);
+ }
+
+ return XextRemoveDisplay(xge_info, dpy);
+}
+
+/*
+ * protocol to Xlib event conversion routine.
+ */
+static Bool
+_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event)
+{
+ int extension;
+ XGEExtList it;
+ XExtDisplayInfo* info = _xgeFindDisplay(dpy);
+ if (!info)
+ return False;
+ /*
+ _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT.
+ Well, I guess we don't need the data we get in CheckExtInit anyway
+ if (!_xgeCheckExtInit(dpy, info))
+ return False;
+ */
+
+ extension = ((xGenericEvent*)event)->extension;
+
+ it = ((XGEData*)info->data)->extensions;
+ while(it)
+ {
+ if (it->extension == extension)
+ {
+ return (it->hooks->wire_to_event(dpy, re, event));
+ }
+ it = it->next;
+ }
+
+ fprintf(stderr,
+ "_xgeWireToEvent: Unknown extension %d, this should never happen.\n",
+ extension);
+ return False;
+}
+
+/*
+ * xlib event to protocol conversion routine.
+ */
+static Status
+_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
+{
+ int extension;
+ XGEExtList it;
+ XExtDisplayInfo* info = _xgeFindDisplay(dpy);
+ if (!info)
+ return 1; /* error! */
+
+ extension = ((XGenericEvent*)re)->extension;
+
+ it = ((XGEData*)info->data)->extensions;
+ while(it)
+ {
+ if (it->extension == extension)
+ {
+ return (it->hooks->event_to_wire(dpy, re, event));
+ }
+ it = it->next;
+ }
+
+ fprintf(stderr,
+ "_xgeEventToWire: Unknown extension %d, this should never happen.\n",
+ extension);
+
+ return Success;
+}
+
+/*
+ * Extensions need to register callbacks for their events.
+ */
+Bool
+xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
+{
+ XGEExtNode* newExt;
+ XGEData* xge_data;
+
+ XExtDisplayInfo* info = _xgeFindDisplay(dpy);
+ if (!info)
+ return False; /* error! */
+
+ if (!_xgeCheckExtInit(dpy, info))
+ return False;
+
+ xge_data = (XGEData*)info->data;
+
+ newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode));
+ if (!newExt)
+ {
+ fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n");
+ return False;
+ }
+
+ newExt->extension = offset;
+ newExt->hooks = callbacks;
+ newExt->next = xge_data->extensions;
+ xge_data->extensions = newExt;
+
+ return True;
+}
+
+/***********************************************************************/
+/* Client interfaces */
+/***********************************************************************/
+
+/* Set event_base and error_base to the matching values for XGE.
+ * Note that since XGE doesn't use any errors and events, the actual return
+ * value is of limited use.
+ */
+Bool
+XGEQueryExtension(Display* dpy, int* event_base, int* error_base)
+{
+ XExtDisplayInfo* info = _xgeFindDisplay(dpy);
+ if (!_xgeCheckExtInit(dpy, info))
+ return False;
+
+ *event_base = info->codes->first_event;
+ *error_base = info->codes->first_error;
+ return True;
+}
+
+/* Get XGE version number.
+ * Doesn't actually get it from server, that should have been done beforehand
+ * already
+ */
+Bool
+XGEQueryVersion(Display* dpy,
+ int *major_version,
+ int *minor_version)
+{
+ XExtDisplayInfo* info = _xgeFindDisplay(dpy);
+ if (!info)
+ return False;
+
+ if (!_xgeCheckExtInit(dpy, info))
+ return False;
+
+ *major_version = ((XGEData*)info->data)->vers->major_version;
+ *minor_version = ((XGEData*)info->data)->vers->minor_version;
+
+ return True;
+}
+