1
0
Fork 0
forked from fte/fteqw

TimeServ wanted my X server.

Note that the copyright is not gplable due to the inclusion of X headers. These can be run from any linux, of course, where they would be part of the operating system and so freely redistributable.


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1683 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-12-06 21:16:16 +00:00
parent ff18dfb1dc
commit c41eb9937e
11 changed files with 11396 additions and 0 deletions

205
plugins/xsv/Xmd.h Normal file
View file

@ -0,0 +1,205 @@
/* $XFree86: xc/include/Xmd.h,v 3.16 2002/05/31 18:45:39 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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 name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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.
******************************************************************/
#ifndef XMD_H
#define XMD_H 1
/* $Xorg: Xmd.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ */
/*
* Xmd.h: MACHINE DEPENDENT DECLARATIONS.
*/
/*
* Special per-machine configuration flags.
*/
#ifdef CRAY
#define WORD64 /* 64-bit architecture */
#endif
#if defined(__alpha) || defined(__alpha__) || \
defined(__ia64__) || defined(ia64) || \
defined(__sparc64__) || \
defined(__s390x__) || \
(defined(__hppa__) && defined(__LP64__)) || \
defined(__x86_64__) || defined(x86_64)
#define LONG64 /* 32/64-bit architecture */
#endif
#ifdef __sgi
#if (_MIPS_SZLONG == 64)
#define LONG64
#endif
#endif
/*
* Stuff to handle large architecture machines; the constants were generated
* on a 32-bit machine and must coorespond to the protocol.
*/
#ifdef WORD64
#define MUSTCOPY
#endif /* WORD64 */
/*
* Definition of macro used to set constants for size of network structures;
* machines with preprocessors that can't handle all of the sz_ symbols
* can define this macro to be sizeof(x) if and only if their compiler doesn't
* pad out structures (esp. the xTextElt structure which contains only two
* one-byte fields). Network structures should always define sz_symbols.
*
* The sz_ prefix is used instead of something more descriptive so that the
* symbols are no more than 32 characters long (which causes problems for some
* compilers and preprocessors).
*
* The extra indirection in the __STDC__ case is to get macro arguments to
* expand correctly before the concatenation, rather than afterward.
*/
#if ((defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)) && !defined(UNIXCPP)) || defined(ANSICPP)
#define _SIZEOF(x) sz_##x
#define SIZEOF(x) _SIZEOF(x)
#else
#define SIZEOF(x) sz_/**/x
#endif /* if ANSI C compiler else not */
/*
* Bitfield suffixes for the protocol structure elements, if you
* need them. Note that bitfields are not guarranteed to be signed
* (or even unsigned) according to ANSI C.
*/
#ifdef WORD64
typedef long INT64;
typedef unsigned long CARD64;
#define B32 :32
#define B16 :16
#ifdef UNSIGNEDBITFIELDS
typedef unsigned int INT32;
typedef unsigned int INT16;
#else
#ifdef __STDC__
typedef signed int INT32;
typedef signed int INT16;
#else
typedef int INT32;
typedef int INT16;
#endif
#endif
#else
#define B32
#define B16
#ifdef LONG64
typedef long INT64;
typedef int INT32;
#else
typedef long INT32;
#endif
typedef short INT16;
#endif
#if defined(__STDC__) || defined(sgi) || defined(AIXV3)
typedef signed char INT8;
#else
typedef char INT8;
#endif
#ifdef LONG64
typedef unsigned long CARD64;
typedef unsigned int CARD32;
#else
typedef unsigned long CARD32;
#endif
typedef unsigned short CARD16;
typedef unsigned char CARD8;
typedef CARD32 BITS32;
typedef CARD16 BITS16;
#if !defined(I_NEED_OS2_H) && !defined(_WIN32)
typedef CARD8 BYTE;
typedef CARD8 BOOL;
#else
#define BYTE CARD8
#define BOOL CARD8
#endif
/*
* definitions for sign-extending bitfields on 64-bit architectures
*/
#if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
#define cvtINT8toInt(val) (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val))
#define cvtINT16toInt(val) (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val))
#define cvtINT32toInt(val) (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val))
#define cvtINT8toShort(val) cvtINT8toInt(val)
#define cvtINT16toShort(val) cvtINT16toInt(val)
#define cvtINT32toShort(val) cvtINT32toInt(val)
#define cvtINT8toLong(val) cvtINT8toInt(val)
#define cvtINT16toLong(val) cvtINT16toInt(val)
#define cvtINT32toLong(val) cvtINT32toInt(val)
#else
#define cvtINT8toInt(val) (val)
#define cvtINT16toInt(val) (val)
#define cvtINT32toInt(val) (val)
#define cvtINT8toShort(val) (val)
#define cvtINT16toShort(val) (val)
#define cvtINT32toShort(val) (val)
#define cvtINT8toLong(val) (val)
#define cvtINT16toLong(val) (val)
#define cvtINT32toLong(val) (val)
#endif /* WORD64 and UNSIGNEDBITFIELDS */
#ifdef MUSTCOPY
/*
* This macro must not cast or else pointers will get aligned and be wrong
*/
#define NEXTPTR(p,t) (((char *) p) + SIZEOF(t))
#else /* else not MUSTCOPY, this is used for 32-bit machines */
/*
* this version should leave result of type (t *), but that should only be
* used when not in MUSTCOPY
*/
#define NEXTPTR(p,t) (((t *)(p)) + 1)
#endif /* MUSTCOPY - used machines whose C structs don't line up with proto */
#endif /* XMD_H */

2132
plugins/xsv/Xproto.h Normal file

File diff suppressed because it is too large Load diff

80
plugins/xsv/Xprotostr.h Normal file
View file

@ -0,0 +1,80 @@
//the only changes in this file for qux support are with header file locations.
/* $Xorg: Xprotostr.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $ */
#ifndef XPROTOSTRUCTS_H
#define XPROTOSTRUCTS_H
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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 name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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.
******************************************************************/
#include "Xmd.h"
/* Used by PolySegment */
typedef struct _xSegment {
INT16 x1 B16, y1 B16, x2 B16, y2 B16;
} xSegment;
/* POINT */
typedef struct _xPoint {
INT16 x B16, y B16;
} xPoint;
typedef struct _xRectangle {
INT16 x B16, y B16;
CARD16 width B16, height B16;
} xRectangle;
/* ARC */
typedef struct _xArc {
INT16 x B16, y B16;
CARD16 width B16, height B16;
INT16 angle1 B16, angle2 B16;
} xArc;
#endif /* XPROTOSTRUCTS_H */

63
plugins/xsv/bigreqstr.h Normal file
View file

@ -0,0 +1,63 @@
/* $Xorg: bigreqstr.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
/*
Copyright 1992, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
#define X_BigReqEnable 0
#define XBigReqNumberEvents 0
#define XBigReqNumberErrors 0
#define XBigReqExtensionName "BIG-REQUESTS"
typedef struct {
CARD8 reqType; /* always XBigReqCode */
CARD8 brReqType; /* always X_BigReqEnable */
CARD16 length B16;
} xBigReqEnableReq;
#define sz_xBigReqEnableReq 4
typedef struct {
BYTE type; /* X_Reply */
CARD8 pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 max_request_size B32;
CARD32 pad1 B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
} xBigReqEnableReply;
#define sz_xBigReqEnableReply 32
typedef struct {
CARD8 reqType;
CARD8 data;
CARD16 zero B16;
CARD32 length B32;
} xBigReq;

2016
plugins/xsv/keysymdef.h Normal file

File diff suppressed because it is too large Load diff

1873
plugins/xsv/m_x.c Normal file

File diff suppressed because it is too large Load diff

200
plugins/xsv/qux.h Normal file
View file

@ -0,0 +1,200 @@
#include "../plugin.h"
/*
#ifdef _WIN32 //for multithreaded reading
#define BOOL WINDOWSSUCKS_BOOL
#define INT32 WINDOWSSUCKS_INT32
#include "winquake.h"
#undef BOOL
#undef INT32
#define MULTITHREADWIN32
#endif
#ifdef MULTITHREADWIN32
#define MULTITHREAD
#endif
*/
#include "Xproto.h"
#include "x.h"
#include "bigreqstr.h"
#define XK_MISCELLANY
#define XK_LATIN1
#include "keysymdef.h"
typedef struct xclient_s {
int socket;
int inbufferlen;
int outbufferlen;
int inbuffermaxlen;
int outbuffermaxlen;
char *outbuffer;
char *inbuffer;
qboolean tobedropped; //dropped when no more to send.
qboolean stillinitialising;
unsigned int requestnum;
unsigned int ridbase;
struct xclient_s *nextclient;
#ifdef MULTITHREADWIN32
HANDLE threadhandle;
CRITICAL_SECTION delecatesection;
#endif
} xclient_t;
extern xclient_t *xgrabbedclient; //stops reading other clients
extern xclient_t *xpointergrabclient;
typedef struct xproperty_s {
Atom atomid;
Atom type;
int datalen;
struct xproperty_s *next;
int format;
char data[1];
} xproperty_t;
typedef struct xnotificationmask_s {
xclient_t *client;
unsigned int mask;
struct xnotificationmask_s *next;
} xnotificationmask_t;
typedef struct xresource_s {
enum {x_none, x_window, x_gcontext, x_pixmap, x_font, x_atom} restype;
int id;
xclient_t *owner;
struct xresource_s *next, *prev;
} xresource_t;
typedef struct xpixmap_s {
xresource_t res;
int references;
qboolean linked;
int width;
int height;
int depth;
qbyte *data;
} xpixmap_t;
typedef struct xatom_s {
xresource_t res;
char atomname[1];
int selectionownerwindowid;
xclient_t *selectionownerclient;
} xatom_t;
typedef struct xwindow_s {
xresource_t res;
int xpos;
int ypos;
int width;
int height;
char *buffer;
int bg;
struct xwindow_s *parent;
struct xwindow_s *child;
struct xwindow_s *sibling;
xpixmap_t *backpixmap;
unsigned int backpixel;
unsigned int borderpixel;
int bitgravity, wingravity;
unsigned int donotpropagate;
int colormap;
qboolean mapped;
qboolean overrideredirect;
qboolean inputonly;
int depth;
xproperty_t *properties;
xnotificationmask_t *notificationmask;
} xwindow_t;
typedef struct xfont_s
{
xresource_t res;
int depth;
char name[256];
int rowwidth;
int rowheight;
int charwidth;
int charheight;
unsigned int data[4];
} xfont_t;
typedef struct xgcontext_s
{
xresource_t res;
int depth;
int function;
int fgcolour;
int bgcolour;
xfont_t *font;
} xgcontext_t;
extern xwindow_t *rootwindow;
extern qboolean xrefreshed; //something onscreen changed.
int XS_GetResource(int id, void **data);
void XS_SetProperty(xwindow_t *wnd, Atom atomid, Atom atomtype, char *data, int datalen, int format);
int XS_GetProperty(xwindow_t *wnd, Atom atomid, Atom *type, char *output, int maxlen, int offset, int *extrabytes, int *format);
void XS_DeleteProperty(xwindow_t *wnd, Atom atomid);
xatom_t *XS_CreateAtom(Atom atomid, char *name, xclient_t *owner);
Atom XS_FindAtom(char *name);
xgcontext_t *XS_CreateGContext(int id, xclient_t *owner, xresource_t *drawable);
int XS_NewResource(void);
xwindow_t *XS_CreateWindow(int wid, xclient_t *owner, xwindow_t *parent, short x, short y, short width, short height);
void XS_SetParent(xwindow_t *wnd, xwindow_t *parent);
xpixmap_t *XS_CreatePixmap(int id, xclient_t *owner, int width, int height, int depth);
void XS_CreateInitialResources(void);
void XS_DestroyResource(xresource_t *res);
void XS_DestroyResourcesOfClient(xclient_t *cl);
void XS_CheckResourceSentinals(void);
void XW_ExposeWindow(xwindow_t *root, int x, int y, int width, int height);
void XW_ClearArea(xwindow_t *wnd, int xp, int yp, int width, int height);
typedef void (*XRequest) (xclient_t *cl, xReq *request);
extern XRequest XRequests [256];
void X_SendData(xclient_t *cl, void *data, int datalen);
void X_SendNotification(xEvent *data);
int X_SendNotificationMasked(xEvent *data, xwindow_t *window, unsigned int mask);
qboolean X_NotifcationMaskPresent(xwindow_t *window, int mask, xclient_t *notfor);
void X_SendError(xclient_t *cl, int errorcode, int assocresource, int major, int minor);
void X_InitRequests(void);
void X_EvalutateCursorOwner(int movemode);
void X_EvalutateFocus(int movemode);
extern qbyte *xscreen;
extern short xscreenwidth;
extern short xscreenheight;
extern int K_BACKSPACE;
extern int K_CTRL;
extern int K_ALT;
extern int K_MOUSE1;
extern int K_MOUSE2;
extern int K_MOUSE3;
extern int K_MOUSE4;
extern int K_MOUSE5;

717
plugins/xsv/x.h Normal file
View file

@ -0,0 +1,717 @@
/*
* $Xorg: X.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $
*/
/* Definitions for the X window system likely to be used by applications */
#ifndef X_H
#define X_H
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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 name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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/include/X.h,v 1.5 2001/12/14 19:53:25 dawes Exp $ */
#define X_PROTOCOL 11 /* current protocol version */
#define X_PROTOCOL_REVISION 0 /* current minor version */
/* Resources */
/*
* _XSERVER64 must ONLY be defined when compiling X server sources on
* systems where unsigned long is not 32 bits, must NOT be used in
* client or library code.
*/
#ifndef _XSERVER64
# ifndef _XTYPEDEF_XID
# define _XTYPEDEF_XID
typedef unsigned long XID;
# endif
# ifndef _XTYPEDEF_MASK
# define _XTYPEDEF_MASK
typedef unsigned long Mask;
# endif
# ifndef _XTYPEDEF_ATOM
# define _XTYPEDEF_ATOM
typedef unsigned long Atom; /* Also in Xdefs.h */
# endif
typedef unsigned long VisualID;
typedef unsigned long Time;
#else
# include <X11/Xmd.h>
# ifndef _XTYPEDEF_XID
# define _XTYPEDEF_XID
typedef CARD32 XID;
# endif
# ifndef _XTYPEDEF_MASK
# define _XTYPEDEF_MASK
typedef CARD32 Mask;
# endif
# ifndef _XTYPEDEF_ATOM
# define _XTYPEDEF_ATOM
typedef CARD32 Atom;
# endif
typedef CARD32 VisualID;
typedef CARD32 Time;
#endif
typedef XID Window;
typedef XID Drawable;
#ifndef _XTYPEDEF_FONT
# define _XTYPEDEF_FONT
typedef XID Font;
#endif
typedef XID Pixmap;
typedef XID Cursor;
typedef XID Colormap;
typedef XID GContext;
typedef XID KeySym;
typedef unsigned char KeyCode;
/*****************************************************************
* RESERVED RESOURCE AND CONSTANT DEFINITIONS
*****************************************************************/
#ifndef None
#define None 0L /* universal null resource or null atom */
#endif
#define ParentRelative 1L /* background pixmap in CreateWindow
and ChangeWindowAttributes */
#define CopyFromParent 0L /* border pixmap in CreateWindow
and ChangeWindowAttributes
special VisualID and special window
class passed to CreateWindow */
#define PointerWindow 0L /* destination window in SendEvent */
#define InputFocus 1L /* destination window in SendEvent */
#define PointerRoot 1L /* focus window in SetInputFocus */
#define AnyPropertyType 0L /* special Atom, passed to GetProperty */
#define AnyKey 0L /* special Key Code, passed to GrabKey */
#define AnyButton 0L /* special Button Code, passed to GrabButton */
#define AllTemporary 0L /* special Resource ID passed to KillClient */
#define CurrentTime 0L /* special Time */
#define NoSymbol 0L /* special KeySym */
/*****************************************************************
* EVENT DEFINITIONS
*****************************************************************/
/* Input Event Masks. Used as event-mask window attribute and as arguments
to Grab requests. Not to be confused with event names. */
#define NoEventMask 0L
#define KeyPressMask (1L<<0)
#define KeyReleaseMask (1L<<1)
#define ButtonPressMask (1L<<2)
#define ButtonReleaseMask (1L<<3)
#define EnterWindowMask (1L<<4)
#define LeaveWindowMask (1L<<5)
#define PointerMotionMask (1L<<6)
#define PointerMotionHintMask (1L<<7)
#define Button1MotionMask (1L<<8)
#define Button2MotionMask (1L<<9)
#define Button3MotionMask (1L<<10)
#define Button4MotionMask (1L<<11)
#define Button5MotionMask (1L<<12)
#define ButtonMotionMask (1L<<13)
#define KeymapStateMask (1L<<14)
#define ExposureMask (1L<<15)
#define VisibilityChangeMask (1L<<16)
#define StructureNotifyMask (1L<<17)
#define ResizeRedirectMask (1L<<18)
#define SubstructureNotifyMask (1L<<19)
#define SubstructureRedirectMask (1L<<20)
#define FocusChangeMask (1L<<21)
#define PropertyChangeMask (1L<<22)
#define ColormapChangeMask (1L<<23)
#define OwnerGrabButtonMask (1L<<24)
/* Event names. Used in "type" field in XEvent structures. Not to be
confused with event masks above. They start from 2 because 0 and 1
are reserved in the protocol for errors and replies. */
#define KeyPress 2
#define KeyRelease 3
#define ButtonPress 4
#define ButtonRelease 5
#define MotionNotify 6
#define EnterNotify 7
#define LeaveNotify 8
#define FocusIn 9
#define FocusOut 10
#define KeymapNotify 11
#define Expose 12
#define GraphicsExpose 13
#define NoExpose 14
#define VisibilityNotify 15
#define CreateNotify 16
#define DestroyNotify 17
#define UnmapNotify 18
#define MapNotify 19
#define MapRequest 20
#define ReparentNotify 21
#define ConfigureNotify 22
#define ConfigureRequest 23
#define GravityNotify 24
#define ResizeRequest 25
#define CirculateNotify 26
#define CirculateRequest 27
#define PropertyNotify 28
#define SelectionClear 29
#define SelectionRequest 30
#define SelectionNotify 31
#define ColormapNotify 32
#define ClientMessage 33
#define MappingNotify 34
#define LASTEvent 35 /* must be bigger than any event # */
/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
state in various key-, mouse-, and button-related events. */
#define ShiftMask (1<<0)
#define LockMask (1<<1)
#define ControlMask (1<<2)
#define Mod1Mask (1<<3)
#define Mod2Mask (1<<4)
#define Mod3Mask (1<<5)
#define Mod4Mask (1<<6)
#define Mod5Mask (1<<7)
/* modifier names. Used to build a SetModifierMapping request or
to read a GetModifierMapping request. These correspond to the
masks defined above. */
#define ShiftMapIndex 0
#define LockMapIndex 1
#define ControlMapIndex 2
#define Mod1MapIndex 3
#define Mod2MapIndex 4
#define Mod3MapIndex 5
#define Mod4MapIndex 6
#define Mod5MapIndex 7
/* button masks. Used in same manner as Key masks above. Not to be confused
with button names below. */
#define Button1Mask (1<<8)
#define Button2Mask (1<<9)
#define Button3Mask (1<<10)
#define Button4Mask (1<<11)
#define Button5Mask (1<<12)
#define AnyModifier (1<<15) /* used in GrabButton, GrabKey */
/* button names. Used as arguments to GrabButton and as detail in ButtonPress
and ButtonRelease events. Not to be confused with button masks above.
Note that 0 is already defined above as "AnyButton". */
#define Button1 1
#define Button2 2
#define Button3 3
#define Button4 4
#define Button5 5
/* Notify modes */
#define NotifyNormal 0
#define NotifyGrab 1
#define NotifyUngrab 2
#define NotifyWhileGrabbed 3
#define NotifyHint 1 /* for MotionNotify events */
/* Notify detail */
#define NotifyAncestor 0
#define NotifyVirtual 1
#define NotifyInferior 2
#define NotifyNonlinear 3
#define NotifyNonlinearVirtual 4
#define NotifyPointer 5
#define NotifyPointerRoot 6
#define NotifyDetailNone 7
/* Visibility notify */
#define VisibilityUnobscured 0
#define VisibilityPartiallyObscured 1
#define VisibilityFullyObscured 2
/* Circulation request */
#define PlaceOnTop 0
#define PlaceOnBottom 1
/* protocol families */
#define FamilyInternet 0
#define FamilyDECnet 1
#define FamilyChaos 2
/* Property notification */
#define PropertyNewValue 0
#define PropertyDelete 1
/* Color Map notification */
#define ColormapUninstalled 0
#define ColormapInstalled 1
/* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */
#define GrabModeSync 0
#define GrabModeAsync 1
/* GrabPointer, GrabKeyboard reply status */
#define GrabSuccess 0
#define AlreadyGrabbed 1
#define GrabInvalidTime 2
#define GrabNotViewable 3
#define GrabFrozen 4
/* AllowEvents modes */
#define AsyncPointer 0
#define SyncPointer 1
#define ReplayPointer 2
#define AsyncKeyboard 3
#define SyncKeyboard 4
#define ReplayKeyboard 5
#define AsyncBoth 6
#define SyncBoth 7
/* Used in SetInputFocus, GetInputFocus */
#define RevertToNone (int)None
#define RevertToPointerRoot (int)PointerRoot
#define RevertToParent 2
/*****************************************************************
* ERROR CODES
*****************************************************************/
#define Success 0 /* everything's okay */
#define BadRequest 1 /* bad request code */
#define BadValue 2 /* int parameter out of range */
#define BadWindow 3 /* parameter not a Window */
#define BadPixmap 4 /* parameter not a Pixmap */
#define BadAtom 5 /* parameter not an Atom */
#define BadCursor 6 /* parameter not a Cursor */
#define BadFont 7 /* parameter not a Font */
#define BadMatch 8 /* parameter mismatch */
#define BadDrawable 9 /* parameter not a Pixmap or Window */
#define BadAccess 10 /* depending on context:
- key/button already grabbed
- attempt to free an illegal
cmap entry
- attempt to store into a read-only
color map entry.
- attempt to modify the access control
list from other than the local host.
*/
#define BadAlloc 11 /* insufficient resources */
#define BadColor 12 /* no such colormap */
#define BadGC 13 /* parameter not a GC */
#define BadIDChoice 14 /* choice not in range or already used */
#define BadName 15 /* font or color name doesn't exist */
#define BadLength 16 /* Request length incorrect */
#define BadImplementation 17 /* server is defective */
#define FirstExtensionError 128
#define LastExtensionError 255
/*****************************************************************
* WINDOW DEFINITIONS
*****************************************************************/
/* Window classes used by CreateWindow */
/* Note that CopyFromParent is already defined as 0 above */
#define InputOutput 1
#define InputOnly 2
/* Window attributes for CreateWindow and ChangeWindowAttributes */
#define CWBackPixmap (1L<<0)
#define CWBackPixel (1L<<1)
#define CWBorderPixmap (1L<<2)
#define CWBorderPixel (1L<<3)
#define CWBitGravity (1L<<4)
#define CWWinGravity (1L<<5)
#define CWBackingStore (1L<<6)
#define CWBackingPlanes (1L<<7)
#define CWBackingPixel (1L<<8)
#define CWOverrideRedirect (1L<<9)
#define CWSaveUnder (1L<<10)
#define CWEventMask (1L<<11)
#define CWDontPropagate (1L<<12)
#define CWColormap (1L<<13)
#define CWCursor (1L<<14)
/* ConfigureWindow structure */
#define CWX (1<<0)
#define CWY (1<<1)
#define CWWidth (1<<2)
#define CWHeight (1<<3)
#define CWBorderWidth (1<<4)
#define CWSibling (1<<5)
#define CWStackMode (1<<6)
/* Bit Gravity */
#define ForgetGravity 0
#define NorthWestGravity 1
#define NorthGravity 2
#define NorthEastGravity 3
#define WestGravity 4
#define CenterGravity 5
#define EastGravity 6
#define SouthWestGravity 7
#define SouthGravity 8
#define SouthEastGravity 9
#define StaticGravity 10
/* Window gravity + bit gravity above */
#define UnmapGravity 0
/* Used in CreateWindow for backing-store hint */
#define NotUseful 0
#define WhenMapped 1
#define Always 2
/* Used in GetWindowAttributes reply */
#define IsUnmapped 0
#define IsUnviewable 1
#define IsViewable 2
/* Used in ChangeSaveSet */
#define SetModeInsert 0
#define SetModeDelete 1
/* Used in ChangeCloseDownMode */
#define DestroyAll 0
#define RetainPermanent 1
#define RetainTemporary 2
/* Window stacking method (in configureWindow) */
#define Above 0
#define Below 1
#define TopIf 2
#define BottomIf 3
#define Opposite 4
/* Circulation direction */
#define RaiseLowest 0
#define LowerHighest 1
/* Property modes */
#define PropModeReplace 0
#define PropModePrepend 1
#define PropModeAppend 2
/*****************************************************************
* GRAPHICS DEFINITIONS
*****************************************************************/
/* graphics functions, as in GC.alu */
#define GXclear 0x0 /* 0 */
#define GXand 0x1 /* src AND dst */
#define GXandReverse 0x2 /* src AND NOT dst */
#define GXcopy 0x3 /* src */
#define GXandInverted 0x4 /* NOT src AND dst */
#define GXnoop 0x5 /* dst */
#define GXxor 0x6 /* src XOR dst */
#define GXor 0x7 /* src OR dst */
#define GXnor 0x8 /* NOT src AND NOT dst */
#define GXequiv 0x9 /* NOT src XOR dst */
#define GXinvert 0xa /* NOT dst */
#define GXorReverse 0xb /* src OR NOT dst */
#define GXcopyInverted 0xc /* NOT src */
#define GXorInverted 0xd /* NOT src OR dst */
#define GXnand 0xe /* NOT src OR NOT dst */
#define GXset 0xf /* 1 */
/* LineStyle */
#define LineSolid 0
#define LineOnOffDash 1
#define LineDoubleDash 2
/* capStyle */
#define CapNotLast 0
#define CapButt 1
#define CapRound 2
#define CapProjecting 3
/* joinStyle */
#define JoinMiter 0
#define JoinRound 1
#define JoinBevel 2
/* fillStyle */
#define FillSolid 0
#define FillTiled 1
#define FillStippled 2
#define FillOpaqueStippled 3
/* fillRule */
#define EvenOddRule 0
#define WindingRule 1
/* subwindow mode */
#define ClipByChildren 0
#define IncludeInferiors 1
/* SetClipRectangles ordering */
#define Unsorted 0
#define YSorted 1
#define YXSorted 2
#define YXBanded 3
/* CoordinateMode for drawing routines */
#define CoordModeOrigin 0 /* relative to the origin */
#define CoordModePrevious 1 /* relative to previous point */
/* Polygon shapes */
#define Complex 0 /* paths may intersect */
#define Nonconvex 1 /* no paths intersect, but not convex */
#define Convex 2 /* wholly convex */
/* Arc modes for PolyFillArc */
#define ArcChord 0 /* join endpoints of arc */
#define ArcPieSlice 1 /* join endpoints to center of arc */
/* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into
GC.stateChanges */
#define GCFunction (1L<<0)
#define GCPlaneMask (1L<<1)
#define GCForeground (1L<<2)
#define GCBackground (1L<<3)
#define GCLineWidth (1L<<4)
#define GCLineStyle (1L<<5)
#define GCCapStyle (1L<<6)
#define GCJoinStyle (1L<<7)
#define GCFillStyle (1L<<8)
#define GCFillRule (1L<<9)
#define GCTile (1L<<10)
#define GCStipple (1L<<11)
#define GCTileStipXOrigin (1L<<12)
#define GCTileStipYOrigin (1L<<13)
#define GCFont (1L<<14)
#define GCSubwindowMode (1L<<15)
#define GCGraphicsExposures (1L<<16)
#define GCClipXOrigin (1L<<17)
#define GCClipYOrigin (1L<<18)
#define GCClipMask (1L<<19)
#define GCDashOffset (1L<<20)
#define GCDashList (1L<<21)
#define GCArcMode (1L<<22)
#define GCLastBit 22
/*****************************************************************
* FONTS
*****************************************************************/
/* used in QueryFont -- draw direction */
#define FontLeftToRight 0
#define FontRightToLeft 1
#define FontChange 255
/*****************************************************************
* IMAGING
*****************************************************************/
/* ImageFormat -- PutImage, GetImage */
#define XYBitmap 0 /* depth 1, XYFormat */
#define XYPixmap 1 /* depth == drawable depth */
#define ZPixmap 2 /* depth == drawable depth */
/*****************************************************************
* COLOR MAP STUFF
*****************************************************************/
/* For CreateColormap */
#define AllocNone 0 /* create map with no entries */
#define AllocAll 1 /* allocate entire map writeable */
/* Flags used in StoreNamedColor, StoreColors */
#define DoRed (1<<0)
#define DoGreen (1<<1)
#define DoBlue (1<<2)
/*****************************************************************
* CURSOR STUFF
*****************************************************************/
/* QueryBestSize Class */
#define CursorShape 0 /* largest size that can be displayed */
#define TileShape 1 /* size tiled fastest */
#define StippleShape 2 /* size stippled fastest */
/*****************************************************************
* KEYBOARD/POINTER STUFF
*****************************************************************/
#define AutoRepeatModeOff 0
#define AutoRepeatModeOn 1
#define AutoRepeatModeDefault 2
#define LedModeOff 0
#define LedModeOn 1
/* masks for ChangeKeyboardControl */
#define KBKeyClickPercent (1L<<0)
#define KBBellPercent (1L<<1)
#define KBBellPitch (1L<<2)
#define KBBellDuration (1L<<3)
#define KBLed (1L<<4)
#define KBLedMode (1L<<5)
#define KBKey (1L<<6)
#define KBAutoRepeatMode (1L<<7)
#define MappingSuccess 0
#define MappingBusy 1
#define MappingFailed 2
#define MappingModifier 0
#define MappingKeyboard 1
#define MappingPointer 2
/*****************************************************************
* SCREEN SAVER STUFF
*****************************************************************/
#define DontPreferBlanking 0
#define PreferBlanking 1
#define DefaultBlanking 2
#define DisableScreenSaver 0
#define DisableScreenInterval 0
#define DontAllowExposures 0
#define AllowExposures 1
#define DefaultExposures 2
/* for ForceScreenSaver */
#define ScreenSaverReset 0
#define ScreenSaverActive 1
/*****************************************************************
* HOSTS AND CONNECTIONS
*****************************************************************/
/* for ChangeHosts */
#define HostInsert 0
#define HostDelete 1
/* for ChangeAccessControl */
#define EnableAccess 1
#define DisableAccess 0
/* Display classes used in opening the connection
* Note that the statically allocated ones are even numbered and the
* dynamically changeable ones are odd numbered */
#define StaticGray 0
#define GrayScale 1
#define StaticColor 2
#define PseudoColor 3
#define TrueColor 4
#define DirectColor 5
/* Byte order used in imageByteOrder and bitmapBitOrder */
#define LSBFirst 0
#define MSBFirst 1
#endif /* X_H */

3350
plugins/xsv/x_reqs.c Normal file

File diff suppressed because it is too large Load diff

625
plugins/xsv/x_res.c Normal file
View file

@ -0,0 +1,625 @@
#include "../plugin.h"
#include "qux.h"
#include "../../engine/qclib/hash.h"
hashtable_t restable;
bucket_t *resbuckets[1357]; //strange number to help the hashing.
xwindow_t *rootwindow;
xresource_t *resources;
qbyte *xscreen;
short xscreenwidth;
short xscreenheight;
int baseres;
void XS_ClearParent(xwindow_t *wnd);
int XS_GetResource(int id, void **data)
{
xresource_t *res;
if (id < 0)
return x_none;
res = Hash_GetKey(&restable, id);
if (res)
{
if (data)
*data = res;
return res->restype;
}
return x_none;
}
Atom XS_FindAtom(char *name)
{
xresource_t *res;
for (res = resources; res; res = res->next)
{
if (res->restype == x_atom)
{
if (!strcmp(((xatom_t*)res)->atomname, name))
return res->id;
}
}
return None;
}
void XS_CheckResourceSentinals(void)
{
/* xresource_t *res;
for (res = resources; res; res = res->next)
{
if (res->restype == x_window)
{
if (((xwindow_t*)res)->buffer)
BZ_CheckSentinals(((xwindow_t*)res)->buffer);
}
}
*/
}
void XS_DestroyResource(xresource_t *res)
{
qboolean nofree = false;
if (res->restype == x_pixmap)
{
xpixmap_t *pm = (xpixmap_t *)res;
if (pm->references)
nofree = true;
if (!pm->linked)
return;
pm->linked = false;
}
if (res->restype == x_gcontext)
{
xgcontext_t *gc = (xgcontext_t *)res;
/*
gc->references--;
if (gc->references > 0)
return;
*/
}
if (res->restype == x_window)
{
extern xwindow_t *xfocusedwindow, *xpgrabbedwindow;
xwindow_t *wnd = (xwindow_t *)res;
while(wnd->child)
XS_DestroyResource((xresource_t *)(wnd->child));
if (xfocusedwindow == wnd)
xfocusedwindow = wnd->parent;
if (xpgrabbedwindow == wnd)
xpgrabbedwindow = wnd->parent;
if (wnd->mapped)
{
XW_ExposeWindow(wnd, 0, 0, wnd->width, wnd->height);
}
{
xEvent ev;
xrefreshed = true;
ev.u.u.type = DestroyNotify;
ev.u.u.detail = 0;
ev.u.u.sequenceNumber = 0;
ev.u.destroyNotify.event = wnd->res.id; //should be the window that has the recieve attribute.
ev.u.destroyNotify.window = wnd->res.id;
X_SendNotificationMasked (&ev, wnd, StructureNotifyMask);
X_SendNotificationMasked (&ev, wnd, SubstructureNotifyMask);
}
XS_ClearParent(wnd);
}
if (!res->prev)
{
resources = res->next;
if (res->next)
res->next->prev = NULL;
}
else
{
res->prev->next = res->next;
res->next->prev = res->prev;
}
// XS_FindAtom("");
Hash_RemoveKey(&restable, res->id);
if (!nofree)
free(res);
// XS_FindAtom("");
}
void XS_DestroyResourcesOfClient(xclient_t *cl)
{
xresource_t *res;
xnotificationmask_t *nm, *nm2;
if (xgrabbedclient == cl)
xgrabbedclient = NULL;
if (xpointergrabclient == cl)
xpointergrabclient = NULL;
for (res = resources; res;)
{
if (res->restype == x_window)
{ //clear the event masks
nm = ((xwindow_t *)res)->notificationmask;
if (nm)
{
if (nm->client == cl)
{
((xwindow_t *)res)->notificationmask = nm->next;
free(nm);
}
else
{
for (; nm->next; nm = nm->next)
{
if (nm->next->client == cl || !cl)
{
nm2 = nm->next;
nm->next = nm->next->next;
free(nm2);
break;
}
}
}
}
}
if (res->owner == cl)
{
XS_DestroyResource(res);
res = resources; //evil!!!
continue;
}
res = res->next;
}
}
void XS_LinkResource(xresource_t *res)
{
res->next = resources;
resources = res;
res->prev = NULL;
if (res->next)
res->next->prev = res;
Hash_AddKey(&restable, res->id, res, malloc(sizeof(bucket_t)));
}
xatom_t *XS_CreateAtom(Atom atomid, char *name, xclient_t *owner)
{
xatom_t *at;
at = malloc(sizeof(xatom_t)+strlen(name));
at->res.owner = owner;
at->res.restype = x_atom;
at->res.id = atomid;
strcpy(at->atomname, name);
XS_LinkResource(&at->res);
return at;
}
void XS_ClearParent(xwindow_t *wnd)
{
xwindow_t *sib;
xwindow_t *parent = wnd->parent;
if (!parent)
return;
wnd->parent = NULL;
if (parent->child == wnd)
{
parent->child = wnd->sibling;
return;
}
for (sib = parent->child; sib; sib = sib->sibling)
{
if (sib->sibling == wnd)
{
sib->sibling = wnd->sibling;
return;
}
}
}
int XS_GetProperty(xwindow_t *wnd, Atom atomid, Atom *atomtype, char *output, int maxlen, int offset, int *extrabytes, int *format)
{
xproperty_t *xp;
for (xp = wnd->properties; xp; xp = xp->next)
{
if (xp->atomid == atomid)
{
if (maxlen > xp->datalen - offset)
maxlen = xp->datalen - offset;
memcpy(output, xp->data + offset, maxlen);
if (maxlen < 0)
maxlen = 0;
*extrabytes = xp->datalen - maxlen - offset;
*format = xp->format;
*atomtype = xp->type;
if (*extrabytes < 0)
*extrabytes = 0;
return maxlen;
}
}
*format = 0;
*extrabytes = 0;
*atomtype = None;
return 0;
}
void XS_DeleteProperty(xwindow_t *wnd, Atom atomid)
{
xproperty_t *xp, *prev = NULL;
for (xp = wnd->properties; xp; xp = xp->next)
{
if (xp->atomid == atomid)
{
if (prev)
prev->next = xp->next;
else
wnd->properties = xp->next;
free(xp);
return;
}
prev = xp;
}
}
void XS_SetProperty(xwindow_t *wnd, Atom atomid, Atom atomtype, char *data, int datalen, int format)
{
xproperty_t *prop;
XS_DeleteProperty(wnd, atomid);
prop = malloc(sizeof(xproperty_t) + datalen);
prop->atomid = atomid;
prop->format = format;
prop->type = atomtype;
memcpy(prop->data, data, datalen);
prop->data[datalen] = '\0';
prop->datalen = datalen;
prop->next = wnd->properties;
wnd->properties = prop;
}
void XS_RaiseWindow(xwindow_t *wnd)
{
xwindow_t *bigger;
if (!wnd->parent)
return;
bigger = wnd->parent->child;
if (bigger == wnd)
{
wnd->parent->child = wnd->sibling;
bigger = wnd->sibling;
if (!bigger)
{
wnd->parent->child = wnd;
//ah well, it was worth a try
return;
}
}
else
{
while(bigger->sibling != wnd)
bigger = bigger->sibling;
bigger->sibling = wnd->sibling; //unlink
}
while(bigger->sibling)
bigger = bigger->sibling;
bigger->sibling = wnd;
wnd->sibling = NULL;
}
void XS_SetParent(xwindow_t *wnd, xwindow_t *parent)
{
XS_ClearParent(wnd);
if (parent)
{
wnd->sibling = parent->child;
parent->child = wnd;
}
wnd->parent = parent;
XS_RaiseWindow(wnd);
}
xwindow_t *XS_CreateWindow(int wid, xclient_t *owner, xwindow_t *parent, short x, short y, short width, short height)
{
xwindow_t *neww;
neww = malloc(sizeof(xwindow_t));
memset(neww, 0, sizeof(xwindow_t));
neww->res.id = wid;
neww->res.owner = owner;
neww->res.restype = x_window;
if (width < 0)
{
width*=-1;
x-=width;
}
if (height < 0)
{
height*=-1;
x-=height;
}
neww->xpos = (CARD16)x;
neww->ypos = (CARD16)y;
neww->width = width;
neww->height = height;
neww->buffer = NULL;
XS_SetParent(neww, parent);
XS_LinkResource(&neww->res);
XS_CheckResourceSentinals();
return neww;
}
xgcontext_t *XS_CreateGContext(int id, xclient_t *owner, xresource_t *drawable)
{
xgcontext_t *newgc;
newgc = malloc(sizeof(xgcontext_t));
memset(newgc, 0, sizeof(xgcontext_t));
newgc->res.id = id;
newgc->res.owner = owner;
newgc->res.restype = x_gcontext;
newgc->function = GXcopy;
newgc->bgcolour = 0xffffff;
newgc->fgcolour = 0;
XS_LinkResource(&newgc->res);
return newgc;
}
xpixmap_t *XS_CreatePixmap(int id, xclient_t *owner, int width, int height, int depth)
{
xpixmap_t *newpm;
newpm = malloc(sizeof(xpixmap_t) + (width*height*4));
memset(newpm, 0, sizeof(xpixmap_t));
newpm->res.id = id;
newpm->res.owner = owner;
newpm->res.restype = x_pixmap;
if (id>0)
{
newpm->linked=true; //destroyed when last reference AND this are cleared
XS_LinkResource(&newpm->res);
}
newpm->data = (qbyte*)(newpm+1);
newpm->width = width;
newpm->height = height;
newpm->depth = depth;
return newpm;
}
#include <stdio.h>
xfont_t *XS_CreateFont(int id, xclient_t *owner, char *fontname)
{
xfont_t *newfont;
FILE *f;
int len;
int width;
int height;
int i;
unsigned int *out;
unsigned char *in, *insrc;
f = fopen("xfont.raw", "rb");
if (!f)
return NULL;
fseek(f, 0, SEEK_END);
len = ftell(f);
fseek(f, 0, SEEK_SET);
if (len == 256*256*3)
{
width = height = 256;
}
else if (len == 128*128*3)
width = height = 128;
else
{ //urm, no idea.
fclose(f);
return NULL;
}
newfont = malloc(sizeof(xfont_t) + (width*height*4));
memset(newfont, 0, sizeof(xfont_t));
newfont->res.id = id;
newfont->res.owner = owner;
newfont->res.restype = x_font;
XS_LinkResource(&newfont->res);
newfont->rowwidth = width;
newfont->rowheight = height;
newfont->charwidth = width/16;
newfont->charheight = height/16;
newfont->depth = 32;
in = insrc = malloc(len);
fread(in, len, 1, f);
fclose(f);
out = newfont->data;
for (i = 0; i < width*height; i++)
{
*out = (in[0]) + (in[1]<<8) + (in[2]<<16) + (255<<24);
out++;
in+=3;
}
free(insrc);
return newfont;
}
int XS_NewResource (void)
{
return baseres++;
}
void XS_CreateInitialResources(void)
{
static xpixmap_t pm;
static unsigned int rawpm[8*9] = {
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0xffffff, 0x000000, 0xffffff, 0x000000, 0x000000, 0x000000,
0x000000, 0xffffff, 0x000000, 0x000000, 0x000000, 0xffffff, 0x000000, 0x000000,
0xffffff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0x000000,
0xffffff, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0xffffff, 0x000000,
0xffffff, 0x000000, 0x000000, 0xffffff, 0x000000, 0x000000, 0xffffff, 0x000000,
0x000000, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000};
if (baseres)
return;
baseres=1;
xscreenwidth = 640;
xscreenheight = 480;
xscreen = realloc(xscreen, xscreenwidth*4 * xscreenheight);
XS_CheckResourceSentinals();
XS_DestroyResourcesOfClient(NULL);
memset(resbuckets, 0, sizeof(resbuckets));
Hash_InitTable(&restable, sizeof(resbuckets)/sizeof(resbuckets[0]), resbuckets);
resources = NULL;
XS_CreateAtom(baseres++, "PRIMARY", NULL);
XS_CreateAtom(baseres++, "SECONDARY", NULL);
XS_CreateAtom(baseres++, "ARC", NULL);
XS_CreateAtom(baseres++, "ATOM", NULL);
XS_CreateAtom(baseres++, "BITMAP", NULL);
XS_CreateAtom(baseres++, "CARDINAL", NULL);
XS_CreateAtom(baseres++, "COLORMAP", NULL);
XS_CreateAtom(baseres++, "CURSOR", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER0", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER1", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER2", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER3", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER4", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER5", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER6", NULL);
XS_CreateAtom(baseres++, "CUT_BUFFER7", NULL);
XS_CreateAtom(baseres++, "DRAWABLE", NULL);
XS_CreateAtom(baseres++, "FONT", NULL);
XS_CreateAtom(baseres++, "INTEGER", NULL);
XS_CreateAtom(baseres++, "PIXMAP", NULL);
XS_CreateAtom(baseres++, "POINT", NULL);
XS_CreateAtom(baseres++, "RECTANGLE", NULL);
XS_CreateAtom(baseres++, "RESOURCE_MANAGER", NULL);
XS_CreateAtom(baseres++, "RGB_COLOR_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_BEST_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_BLUE_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_DEFAULT_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_GRAY_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_GREEN_MAP", NULL);
XS_CreateAtom(baseres++, "RGB_RED_MAP", NULL);
XS_CreateAtom(baseres++, "STRING", NULL);
XS_CreateAtom(baseres++, "VISUALID", NULL);
XS_CreateAtom(baseres++, "WINDOW", NULL);
XS_CreateAtom(baseres++, "WM_COMMAND", NULL);
XS_CreateAtom(baseres++, "WM_HINTS", NULL);
XS_CreateAtom(baseres++, "WM_CLIENT_MACHINE", NULL);
XS_CreateAtom(baseres++, "WM_ICON_NAME", NULL);
XS_CreateAtom(baseres++, "WM_ICON_SIZE", NULL);
XS_CreateAtom(baseres++, "WM_NAME", NULL);
XS_CreateAtom(baseres++, "WM_NORMAL_HINTS", NULL);
XS_CreateAtom(baseres++, "WM_SIZE_HINTS", NULL);
XS_CreateAtom(baseres++, "WM_ZOOM_HINTS", NULL);
XS_CreateAtom(baseres++, "MIN_SPACE", NULL);
XS_CreateAtom(baseres++, "NORM_SPACE", NULL);
XS_CreateAtom(baseres++, "MAX_SPACE", NULL);
XS_CreateAtom(baseres++, "END_SPACE", NULL);
XS_CreateAtom(baseres++, "SUPERSCRIPT_X", NULL);
XS_CreateAtom(baseres++, "SUPERSCRIPT_Y", NULL);
XS_CreateAtom(baseres++, "SUBSCRIPT_X", NULL);
XS_CreateAtom(baseres++, "SUBSCRIPT_Y", NULL);
XS_CreateAtom(baseres++, "UNDERLINE_POSITION", NULL);
XS_CreateAtom(baseres++, "UNDERLINE_THICKNESS", NULL);
XS_CreateAtom(baseres++, "STRIKEOUT_ASCENT", NULL);
XS_CreateAtom(baseres++, "STRIKEOUT_DESCENT", NULL);
XS_CreateAtom(baseres++, "ITALIC_ANGLE", NULL);
XS_CreateAtom(baseres++, "X_HEIGHT", NULL);
XS_CreateAtom(baseres++, "QUAD_WIDTH", NULL);
XS_CreateAtom(baseres++, "WEIGHT", NULL);
XS_CreateAtom(baseres++, "POINT_SIZE", NULL);
XS_CreateAtom(baseres++, "RESOLUTION", NULL);
XS_CreateAtom(baseres++, "COPYRIGHT", NULL);
XS_CreateAtom(baseres++, "NOTICE", NULL);
XS_CreateAtom(baseres++, "FONT_NAME", NULL);
XS_CreateAtom(baseres++, "FAMILY_NAME", NULL);
XS_CreateAtom(baseres++, "FULL_NAME", NULL);
XS_CreateAtom(baseres++, "CAP_HEIGHT", NULL);
XS_CreateAtom(baseres++, "WM_CLASS", NULL);
XS_CreateAtom(baseres++, "WM_TRANSIENT_FOR", NULL);
rootwindow = XS_CreateWindow(baseres++, NULL, NULL, 0, 0, xscreenwidth, xscreenheight);
rootwindow->mapped = true;
XS_CheckResourceSentinals();
memset(&pm, 0, sizeof(pm));
pm.linked = true;
pm.data = (qbyte *)rawpm;
pm.depth = 24;
pm.width = 8;
pm.height = 9;
pm.references = 2;
pm.res.restype = x_pixmap;
rootwindow->backpixmap = &pm;
XW_ClearArea(rootwindow, 0, 0, rootwindow->width, rootwindow->height);
XS_CheckResourceSentinals();
xrefreshed = true;
}

135
plugins/xsv/xsv.dsp Normal file
View file

@ -0,0 +1,135 @@
# Microsoft Developer Studio Project File - Name="xsv" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=xsv - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "xsv.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "xsv.mak" CFG="xsv - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "xsv - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "xsv - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "xsv - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSV_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSV_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "xsv - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSV_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSV_EXPORTS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"D:\Quake\id1\plugins/xsvx86.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "xsv - Win32 Release"
# Name "xsv - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\engine\qclib\hash.c
# End Source File
# Begin Source File
SOURCE=.\m_x.c
# End Source File
# Begin Source File
SOURCE=..\plugin.c
# End Source File
# Begin Source File
SOURCE=..\qvm_api.c
# End Source File
# Begin Source File
SOURCE=.\x_reqs.c
# End Source File
# Begin Source File
SOURCE=.\x_res.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\qux.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=..\plugin.def
# End Source File
# End Target
# End Project