1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
* Copyright © 2006 Keith Packard
*
* 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 the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <X11/Xlib.h>
/* we need to be able to manipulate the Display structure on events */
#include <X11/Xlibint.h>
#include <X11/extensions/render.h>
#include <X11/extensions/Xrender.h>
#include "Xrandrint.h"
XRRModeInfo *
XRRAllocModeInfo (_Xconst char *name, int nameLength)
{
XRRModeInfo *mode_info;
mode_info = Xmalloc (sizeof (XRRModeInfo) + nameLength + 1);
if (!mode_info)
return NULL;
memset (mode_info, '\0', sizeof (XRRModeInfo));
mode_info->nameLength = nameLength;
mode_info->name = (char *) (mode_info + 1);
memcpy (mode_info->name, name, nameLength);
mode_info->name[nameLength] = '\0';
return mode_info;
}
RRMode
XRRCreateMode (Display *dpy, Window window, XRRModeInfo *mode_info)
{
XExtDisplayInfo *info = XRRFindDisplay(dpy);
xRRCreateModeReq *req;
xRRCreateModeReply rep;
RRCheckExtension (dpy, info, None);
LockDisplay(dpy);
GetReq (RRCreateMode, req);
req->reqType = info->codes->major_opcode;
req->randrReqType = X_RRCreateMode;
req->length += (mode_info->nameLength + 3) >> 2;
req->window = window;
req->modeInfo.id = 0;
req->modeInfo.width = mode_info->width;
req->modeInfo.height = mode_info->height;
req->modeInfo.dotClock = mode_info->dotClock;
req->modeInfo.hSyncStart = mode_info->hSyncStart;
req->modeInfo.hSyncEnd = mode_info->hSyncEnd;
req->modeInfo.hTotal = mode_info->hTotal;
req->modeInfo.hSkew = mode_info->hSkew;
req->modeInfo.vSyncStart = mode_info->vSyncStart;
req->modeInfo.vSyncEnd = mode_info->vSyncEnd;
req->modeInfo.vTotal = mode_info->vTotal;
req->modeInfo.nameLength = mode_info->nameLength;
req->modeInfo.modeFlags = mode_info->modeFlags;
Data (dpy, mode_info->name, mode_info->nameLength);
if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
{
UnlockDisplay (dpy);
SyncHandle ();
return None;
}
UnlockDisplay (dpy);
SyncHandle ();
return rep.mode;
}
void
XRRDestroyMode (Display *dpy, RRMode mode)
{
XExtDisplayInfo *info = XRRFindDisplay(dpy);
xRRDestroyModeReq *req;
RRSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq (RRDestroyMode, req);
req->reqType = info->codes->major_opcode;
req->randrReqType = X_RRDestroyMode;
req->mode = mode;
UnlockDisplay (dpy);
SyncHandle ();
}
void
XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode)
{
XExtDisplayInfo *info = XRRFindDisplay(dpy);
xRRAddOutputModeReq *req;
RRSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq (RRAddOutputMode, req);
req->reqType = info->codes->major_opcode;
req->randrReqType = X_RRAddOutputMode;
req->output = output;
req->mode = mode;
UnlockDisplay (dpy);
SyncHandle ();
}
void
XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode)
{
XExtDisplayInfo *info = XRRFindDisplay(dpy);
xRRDeleteOutputModeReq *req;
RRSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
GetReq (RRDeleteOutputMode, req);
req->reqType = info->codes->major_opcode;
req->randrReqType = X_RRDeleteOutputMode;
req->output = output;
req->mode = mode;
UnlockDisplay (dpy);
SyncHandle ();
}
void
XRRFreeModeInfo (XRRModeInfo *modeInfo)
{
Xfree (modeInfo);
}
|