2 * Copyright © 2006 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
29 /* we need to be able to manipulate the Display structure on events */
30 #include <X11/Xlibint.h>
31 #include <X11/extensions/render.h>
32 #include <X11/extensions/Xrender.h>
33 #include "Xrandrint.h"
36 XRRAllocModeInfo (char *name, int nameLength)
38 XRRModeInfo *mode_info;
40 mode_info = Xmalloc (sizeof (XRRModeInfo) + nameLength + 1);
43 memset (mode_info, '\0', sizeof (XRRModeInfo));
44 mode_info->nameLength = nameLength;
45 mode_info->name = (char *) (mode_info + 1);
46 memcpy (mode_info->name, name, nameLength);
47 mode_info->name[nameLength] = '\0';
52 XRRCreateMode (Display *dpy, Window window, XRRModeInfo *mode_info)
54 XExtDisplayInfo *info = XRRFindDisplay(dpy);
55 xRRCreateModeReq *req;
56 xRRCreateModeReply rep;
58 RRCheckExtension (dpy, info, None);
61 GetReq (RRCreateMode, req);
62 req->reqType = info->codes->major_opcode;
63 req->randrReqType = X_RRCreateMode;
64 req->length += (mode_info->nameLength + 3) >> 2;
69 req->modeInfo.width = mode_info->width;
70 req->modeInfo.height = mode_info->height;
71 req->modeInfo.dotClock = mode_info->dotClock;
72 req->modeInfo.hSyncStart = mode_info->hSyncStart;
73 req->modeInfo.hSyncEnd = mode_info->hSyncEnd;
74 req->modeInfo.hTotal = mode_info->hTotal;
75 req->modeInfo.hSkew = mode_info->hSkew;
76 req->modeInfo.vSyncStart = mode_info->vSyncStart;
77 req->modeInfo.vSyncEnd = mode_info->vSyncEnd;
78 req->modeInfo.vTotal = mode_info->vTotal;
79 req->modeInfo.nameLength = mode_info->nameLength;
80 req->modeInfo.modeFlags = mode_info->modeFlags;
82 Data (dpy, mode_info->name, mode_info->nameLength);
83 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
96 XRRDestroyMode (Display *dpy, RRMode mode)
98 XExtDisplayInfo *info = XRRFindDisplay(dpy);
99 xRRDestroyModeReq *req;
100 RRSimpleCheckExtension (dpy, info);
103 GetReq (RRDestroyMode, req);
104 req->reqType = info->codes->major_opcode;
105 req->randrReqType = X_RRDestroyMode;
112 XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode)
114 XExtDisplayInfo *info = XRRFindDisplay(dpy);
115 xRRAddOutputModeReq *req;
116 RRSimpleCheckExtension (dpy, info);
119 GetReq (RRAddOutputMode, req);
120 req->reqType = info->codes->major_opcode;
121 req->randrReqType = X_RRAddOutputMode;
122 req->output = output;
129 XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode)
131 XExtDisplayInfo *info = XRRFindDisplay(dpy);
132 xRRDeleteOutputModeReq *req;
133 RRSimpleCheckExtension (dpy, info);
136 GetReq (RRDeleteOutputMode, req);
137 req->reqType = info->codes->major_opcode;
138 req->randrReqType = X_RRDeleteOutputMode;
139 req->output = output;
146 XRRFreeModeInfo (XRRModeInfo *modeInfo)