1 /* $Xorg: XPanoramiX.c,v 1.4 2000/08/17 19:45:51 cpqbld Exp $ */
2 /*****************************************************************
3 Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software.
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
17 BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
18 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
19 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of Digital Equipment Corporation
22 shall not be used in advertising or otherwise to promote the sale, use or other
23 dealings in this Software without prior written authorization from Digital
24 Equipment Corporation.
25 ******************************************************************/
26 /* $XFree86: xc/lib/Xinerama/Xinerama.c,v 1.2 2001/07/23 17:20:28 dawes Exp $ */
31 /* Apparently some X11 systems can't include this multiple times... */
32 #ifndef SDL_INCLUDED_XLIBINT_H
33 #define SDL_INCLUDED_XLIBINT_H 1
34 #include <X11/Xlibint.h>
37 #include <X11/Xutil.h>
38 #include "../extensions/Xext.h"
39 #include "../extensions/extutil.h" /* in ../include */
40 #include "../extensions/panoramiXext.h"
41 #include "../extensions/panoramiXproto.h" /* in ../include */
42 #include "../extensions/Xinerama.h"
44 static XExtensionInfo _panoramiX_ext_info_data;
45 static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
46 static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME;
48 #define PanoramiXCheckExtension(dpy,i,val) \
49 XextCheckExtension (dpy, i, panoramiX_extension_name, val)
50 #define PanoramiXSimpleCheckExtension(dpy,i) \
51 XextSimpleCheckExtension (dpy, i, panoramiX_extension_name)
53 static int close_display();
54 static /* const */ XExtensionHooks panoramiX_extension_hooks = {
59 NULL, /* create_font */
61 close_display, /* close_display */
62 NULL, /* wire_to_event */
63 NULL, /* event_to_wire */
65 NULL, /* error_string */
68 static XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info,
69 panoramiX_extension_name,
70 &panoramiX_extension_hooks,
73 static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info)
77 /****************************************************************************
79 * PanoramiX public interfaces *
81 ****************************************************************************/
83 Bool SDL_NAME(XPanoramiXQueryExtension) (
89 XExtDisplayInfo *info = find_display (dpy);
91 if (XextHasExtension(info)) {
92 *event_basep = info->codes->first_event;
93 *error_basep = info->codes->first_error;
101 Status SDL_NAME(XPanoramiXQueryVersion)(
107 XExtDisplayInfo *info = find_display (dpy);
108 xPanoramiXQueryVersionReply rep;
109 register xPanoramiXQueryVersionReq *req;
111 PanoramiXCheckExtension (dpy, info, 0);
114 GetReq (PanoramiXQueryVersion, req);
115 req->reqType = info->codes->major_opcode;
116 req->panoramiXReqType = X_PanoramiXQueryVersion;
117 req->clientMajor = PANORAMIX_MAJOR_VERSION;
118 req->clientMinor = PANORAMIX_MINOR_VERSION;
119 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
124 *major_versionp = rep.majorVersion;
125 *minor_versionp = rep.minorVersion;
131 SDL_NAME(XPanoramiXInfo) *SDL_NAME(XPanoramiXAllocInfo)(void)
133 return (SDL_NAME(XPanoramiXInfo) *) Xmalloc (sizeof (SDL_NAME(XPanoramiXInfo)));
136 Status SDL_NAME(XPanoramiXGetState) (
139 SDL_NAME(XPanoramiXInfo) *panoramiX_info
142 XExtDisplayInfo *info = find_display (dpy);
143 xPanoramiXGetStateReply rep;
144 register xPanoramiXGetStateReq *req;
146 PanoramiXCheckExtension (dpy, info, 0);
149 GetReq (PanoramiXGetState, req);
150 req->reqType = info->codes->major_opcode;
151 req->panoramiXReqType = X_PanoramiXGetState;
152 req->window = drawable;
153 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
160 panoramiX_info->window = rep.window;
161 panoramiX_info->State = rep.state;
165 Status SDL_NAME(XPanoramiXGetScreenCount) (
168 SDL_NAME(XPanoramiXInfo) *panoramiX_info
171 XExtDisplayInfo *info = find_display (dpy);
172 xPanoramiXGetScreenCountReply rep;
173 register xPanoramiXGetScreenCountReq *req;
175 PanoramiXCheckExtension (dpy, info, 0);
178 GetReq (PanoramiXGetScreenCount, req);
179 req->reqType = info->codes->major_opcode;
180 req->panoramiXReqType = X_PanoramiXGetScreenCount;
181 req->window = drawable;
182 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
189 panoramiX_info->window = rep.window;
190 panoramiX_info->ScreenCount = rep.ScreenCount;
194 Status SDL_NAME(XPanoramiXGetScreenSize) (
198 SDL_NAME(XPanoramiXInfo) *panoramiX_info
201 XExtDisplayInfo *info = find_display (dpy);
202 xPanoramiXGetScreenSizeReply rep;
203 register xPanoramiXGetScreenSizeReq *req;
205 PanoramiXCheckExtension (dpy, info, 0);
208 GetReq (PanoramiXGetScreenSize, req);
209 req->reqType = info->codes->major_opcode;
210 req->panoramiXReqType = X_PanoramiXGetScreenSize;
211 req->window = drawable;
212 req->screen = screen_num; /* need to define */
213 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
220 panoramiX_info->window = rep.window;
221 panoramiX_info->screen = rep.screen;
222 panoramiX_info->width = rep.width;
223 panoramiX_info->height = rep.height;
227 /*******************************************************************\
228 Alternate interface to make up for shortcomings in the original,
229 namely, the omission of the screen origin. The new interface is
230 in the "Xinerama" namespace instead of "PanoramiX".
231 \*******************************************************************/
233 Bool SDL_NAME(XineramaQueryExtension) (
239 return SDL_NAME(XPanoramiXQueryExtension)(dpy, event_base, error_base);
242 Status SDL_NAME(XineramaQueryVersion)(
248 return SDL_NAME(XPanoramiXQueryVersion)(dpy, major, minor);
251 Bool SDL_NAME(XineramaIsActive)(Display *dpy)
253 xXineramaIsActiveReply rep;
254 xXineramaIsActiveReq *req;
255 XExtDisplayInfo *info = find_display (dpy);
257 if(!XextHasExtension(info))
258 return False; /* server doesn't even have the extension */
261 GetReq (XineramaIsActive, req);
262 req->reqType = info->codes->major_opcode;
263 req->panoramiXReqType = X_XineramaIsActive;
264 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
276 SDL_NAME(XineramaScreenInfo) *
277 SDL_NAME(XineramaQueryScreens)(
282 XExtDisplayInfo *info = find_display (dpy);
283 xXineramaQueryScreensReply rep;
284 xXineramaQueryScreensReq *req;
285 SDL_NAME(XineramaScreenInfo) *scrnInfo = NULL;
287 PanoramiXCheckExtension (dpy, info, 0);
290 GetReq (XineramaQueryScreens, req);
291 req->reqType = info->codes->major_opcode;
292 req->panoramiXReqType = X_XineramaQueryScreens;
293 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
300 if((scrnInfo = Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) {
301 xXineramaScreenInfo scratch;
304 for(i = 0; i < rep.number; i++) {
305 _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
306 scrnInfo[i].screen_number = i;
307 scrnInfo[i].x_org = scratch.x_org;
308 scrnInfo[i].y_org = scratch.y_org;
309 scrnInfo[i].width = scratch.width;
310 scrnInfo[i].height = scratch.height;
313 *number = rep.number;
315 _XEatData(dpy, rep.length << 2);