Mercurial > sdl-ios-xcode
diff src/video/Xext/XME/xme.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | ecba4bbaf9c2 |
children | 4da1ee79c9af |
line wrap: on
line diff
--- a/src/video/Xext/XME/xme.c Sun May 21 17:27:13 2006 +0000 +++ b/src/video/Xext/XME/xme.c Sun May 28 13:04:16 2006 +0000 @@ -49,124 +49,135 @@ /*******************************************************************/ -typedef struct { - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */ - CARD16 length; - CARD16 major; - CARD16 minor; +typedef struct +{ + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */ + CARD16 length; + CARD16 major; + CARD16 minor; } xXiGMiscQueryVersionReq; -typedef struct { - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */ - CARD16 length; - CARD8 screen; - CARD8 pad0; - CARD16 pad1; +typedef struct +{ + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */ + CARD16 length; + CARD8 screen; + CARD8 pad0; + CARD16 pad1; } xXiGMiscQueryViewsReq; -typedef struct { - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */ - CARD16 length; - CARD8 screen; - CARD8 view; - CARD16 pad0; +typedef struct +{ + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */ + CARD16 length; + CARD8 screen; + CARD8 view; + CARD16 pad0; } xXiGMiscQueryResolutionsReq; -typedef struct { - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */ - CARD16 length; - CARD8 screen; - CARD8 view; - CARD16 pad0; - CARD16 width; - CARD16 height; - INT32 refresh; +typedef struct +{ + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */ + CARD16 length; + CARD8 screen; + CARD8 view; + CARD16 pad0; + CARD16 width; + CARD16 height; + INT32 refresh; } xXiGMiscChangeResolutionReq; -typedef struct { - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */ - CARD16 length; - CARD8 screen; - CARD8 pad0; - CARD16 pad1; - CARD32 window; - CARD32 cmap; +typedef struct +{ + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */ + CARD16 length; + CARD8 screen; + CARD8 pad0; + CARD16 pad1; + CARD32 window; + CARD32 cmap; } xXiGMiscFullScreenReq; /*******************************************************************/ -typedef struct { - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD16 major; - CARD16 minor; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; +typedef struct +{ + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD16 major; + CARD16 minor; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xXiGMiscQueryVersionReply; -typedef struct { - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD32 nviews; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; +typedef struct +{ + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD32 nviews; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xXiGMiscQueryViewsReply; -typedef struct { - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD16 active; - CARD16 nresolutions; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; +typedef struct +{ + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD16 active; + CARD16 nresolutions; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; } xXiGMiscQueryResolutionsReply; -typedef struct { - BYTE type; /* X_Reply */ - BOOL success; - CARD16 sequenceNumber; - CARD32 length; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; - CARD32 pad6; +typedef struct +{ + BYTE type; /* X_Reply */ + BOOL success; + CARD16 sequenceNumber; + CARD32 length; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; + CARD32 pad6; } xXiGMiscFullScreenReply; /*******************************************************************/ -typedef struct { - INT16 x; - INT16 y; - CARD16 w; - CARD16 h; +typedef struct +{ + INT16 x; + INT16 y; + CARD16 w; + CARD16 h; } XiGMiscViewInfo; -typedef struct { - CARD16 width; - CARD16 height; - INT32 refresh; +typedef struct +{ + CARD16 width; + CARD16 height; + INT32 refresh; } XiGMiscResolutionInfo; /*****************************************************************************/ @@ -201,195 +212,201 @@ /* * find_display - locate the display info block */ -static int XiGMiscCloseDisplay(); +static int XiGMiscCloseDisplay (); static XExtensionHooks xigmisc_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - XiGMiscCloseDisplay, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + XiGMiscCloseDisplay, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ }; -static XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info) - -static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info, - xigmisc_extension_name, - &xigmisc_extension_hooks, XiGMiscNumberEvents, NULL) - - +static +XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info) + static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info, + xigmisc_extension_name, + &xigmisc_extension_hooks, + XiGMiscNumberEvents, NULL) /*****************************************************************************/ + Bool XiGMiscQueryVersion (Display * dpy, int *major, int *minor) +{ + int opcode, event, error; + xXiGMiscQueryVersionReq *req; + xXiGMiscQueryVersionReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); -Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor) -{ - int opcode, event, error; - xXiGMiscQueryVersionReq *req; - xXiGMiscQueryVersionReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - - if (!XQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) - return xFalse; + if (!XQueryExtension + (dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) + return xFalse; - XiGMiscCheckExtension(dpy, info, xFalse); + XiGMiscCheckExtension (dpy, info, xFalse); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryVersion, req, info); + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryVersion, req, info); - req->major = XIGMISC_MAJOR_VERSION; - req->minor = XIGMISC_MINOR_VERSION; + req->major = XIGMISC_MAJOR_VERSION; + req->minor = XIGMISC_MINOR_VERSION; - if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return xFalse; - } + if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle (); + return xFalse; + } - *major = rep.major; - *minor = rep.minor; - UnlockDisplay(dpy); - SyncHandle(); + *major = rep.major; + *minor = rep.minor; + UnlockDisplay (dpy); + SyncHandle (); - return xTrue; + return xTrue; } -int XiGMiscQueryViews(Display *dpy, int screen, XiGMiscViewInfo **pviews) +int +XiGMiscQueryViews (Display * dpy, int screen, XiGMiscViewInfo ** pviews) { - int n, size; - XiGMiscViewInfo *views; - xXiGMiscQueryViewsReq *req; - xXiGMiscQueryViewsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscCheckExtension(dpy, info, 0); - - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryViews, req, info); - req->screen = screen; + int n, size; + XiGMiscViewInfo *views; + xXiGMiscQueryViewsReq *req; + xXiGMiscQueryViewsReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); + XiGMiscCheckExtension (dpy, info, 0); - if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - n = rep.nviews; + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryViews, req, info); + req->screen = screen; - if (n > 0) { - size = sizeof(XiGMiscViewInfo) * n; - views = (XiGMiscViewInfo*)Xmalloc(size); - if (!views) { - _XEatData(dpy, (unsigned long)size); - UnlockDisplay(dpy); - SyncHandle(); - return 0; + if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + return 0; } - _XReadPad(dpy, (void*)views, size); - - *pviews = views; - } + n = rep.nviews; - UnlockDisplay(dpy); - SyncHandle(); + if (n > 0) { + size = sizeof (XiGMiscViewInfo) * n; + views = (XiGMiscViewInfo *) Xmalloc (size); + if (!views) { + _XEatData (dpy, (unsigned long) size); + UnlockDisplay (dpy); + SyncHandle (); + return 0; + } - return n; + _XReadPad (dpy, (void *) views, size); + + *pviews = views; + } + + UnlockDisplay (dpy); + SyncHandle (); + + return n; } -int XiGMiscQueryResolutions(Display *dpy, int screen, int view, int *pactive, XiGMiscResolutionInfo **presolutions) +int +XiGMiscQueryResolutions (Display * dpy, int screen, int view, int *pactive, + XiGMiscResolutionInfo ** presolutions) { - int n, size; - XiGMiscResolutionInfo *resolutions; - xXiGMiscQueryResolutionsReq *req; - xXiGMiscQueryResolutionsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscCheckExtension(dpy, info, 0); - - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryResolutions, req, info); - req->screen = screen; - req->view = view; + int n, size; + XiGMiscResolutionInfo *resolutions; + xXiGMiscQueryResolutionsReq *req; + xXiGMiscQueryResolutionsReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); + XiGMiscCheckExtension (dpy, info, 0); - if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - n = rep.nresolutions; + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryResolutions, req, info); + req->screen = screen; + req->view = view; - if (n > 0) { - size = sizeof(XiGMiscResolutionInfo) * n; - resolutions = (XiGMiscResolutionInfo*)Xmalloc(size); - if (!resolutions) { - _XEatData(dpy, (unsigned long)size); - UnlockDisplay(dpy); - SyncHandle(); - return 0; + if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay (dpy); + SyncHandle (); + return 0; } - _XReadPad(dpy, (void*)resolutions, size); + n = rep.nresolutions; - *presolutions = resolutions; - *pactive = rep.active; - } + if (n > 0) { + size = sizeof (XiGMiscResolutionInfo) * n; + resolutions = (XiGMiscResolutionInfo *) Xmalloc (size); + if (!resolutions) { + _XEatData (dpy, (unsigned long) size); + UnlockDisplay (dpy); + SyncHandle (); + return 0; + } - UnlockDisplay(dpy); - SyncHandle(); + _XReadPad (dpy, (void *) resolutions, size); - return n; + *presolutions = resolutions; + *pactive = rep.active; + } + + UnlockDisplay (dpy); + SyncHandle (); + + return n; } -void XiGMiscChangeResolution(Display *dpy, int screen, int view, int width, int height, int refresh) +void +XiGMiscChangeResolution (Display * dpy, int screen, int view, int width, + int height, int refresh) { - xXiGMiscChangeResolutionReq *req; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + xXiGMiscChangeResolutionReq *req; + XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); - XiGMiscSimpleCheckExtension(dpy, info); + XiGMiscSimpleCheckExtension (dpy, info); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscChangeResolution, req, info); - req->screen = screen; - req->view = view; - req->width = width; - req->height = height; - req->refresh = refresh; + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscChangeResolution, req, info); + req->screen = screen; + req->view = view; + req->width = width; + req->height = height; + req->refresh = refresh; - UnlockDisplay(dpy); - SyncHandle(); + UnlockDisplay (dpy); + SyncHandle (); } -Bool XiGMiscFullScreen(Display *dpy, int screen, XID window, XID cmap) +Bool +XiGMiscFullScreen (Display * dpy, int screen, XID window, XID cmap) { - xXiGMiscFullScreenReq *req; - xXiGMiscFullScreenReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + xXiGMiscFullScreenReq *req; + xXiGMiscFullScreenReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); - XiGMiscCheckExtension(dpy, info, xFalse); + XiGMiscCheckExtension (dpy, info, xFalse); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscFullScreen, req, info); - req->screen = screen; - req->pad0 = 0; - req->pad1 = 0; - req->window = window; - req->cmap = cmap; + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscFullScreen, req, info); + req->screen = screen; + req->pad0 = 0; + req->pad1 = 0; + req->window = window; + req->cmap = cmap; - if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return xFalse; - } + if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle (); + return xFalse; + } - UnlockDisplay(dpy); - SyncHandle(); + UnlockDisplay (dpy); + SyncHandle (); - return (rep.success ? xTrue : xFalse); + return (rep.success ? xTrue : xFalse); } +/* vi: set ts=4 sw=4 expandtab: */