2 * Copyright 2003 Red Hat Inc., Durham, North Carolina.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation on the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * Kevin E. Martin <kem@redhat.com>
37 #include <X11/extensions/dmxext.h>
39 int main(int argc
, char **argv
)
41 Display
*display
= NULL
;
44 int major_version
, minor_version
, patch_version
;
46 DMXScreenAttributes attr
;
47 unsigned int mask
= 0;
52 fprintf(stderr
, "Usage: %s display screen scrnx scrny scrnw scrnh rootx rooty rootw rooth originx originy\n", argv
[0]);
56 if (!(display
= XOpenDisplay(argv
[1]))) {
57 fprintf(stderr
, "Cannot open display %s\n", argv
[1]);
61 screen
= strtol(argv
[2], NULL
, 0);
63 mask
|= (DMXScreenWindowXoffset
|
64 DMXScreenWindowYoffset
|
65 DMXScreenWindowWidth
|
66 DMXScreenWindowHeight
);
67 attr
.screenWindowXoffset
= strtol(argv
[3], NULL
, 0);
68 attr
.screenWindowYoffset
= strtol(argv
[4], NULL
, 0);
69 attr
.screenWindowWidth
= strtol(argv
[5], NULL
, 0);
70 attr
.screenWindowHeight
= strtol(argv
[6], NULL
, 0);
72 mask
|= (DMXRootWindowXoffset
|
73 DMXRootWindowYoffset
|
76 attr
.rootWindowXoffset
= strtol(argv
[7], NULL
, 0);
77 attr
.rootWindowYoffset
= strtol(argv
[8], NULL
, 0);
78 attr
.rootWindowWidth
= strtol(argv
[9], NULL
, 0);
79 attr
.rootWindowHeight
= strtol(argv
[10], NULL
, 0);
81 mask
|= DMXRootWindowXorigin
| DMXRootWindowYorigin
;
82 attr
.rootWindowXorigin
= strtol(argv
[11], NULL
, 0);
83 attr
.rootWindowYorigin
= strtol(argv
[12], NULL
, 0);
85 if (!DMXQueryExtension(display
, &event_base
, &error_base
)) {
86 fprintf(stderr
, "DMX extension not present\n");
89 printf("DMX extension present: event_base = %d, error_base = %d\n",
90 event_base
, error_base
);
92 if (!DMXQueryVersion(display
,
93 &major_version
, &minor_version
, &patch_version
)) {
94 fprintf(stderr
, "Could not get extension version\n");
97 printf("Extension version: %d.%d patch %d\n",
98 major_version
, minor_version
, patch_version
);
100 if (major_version
== 1 && minor_version
< 3) {
102 "ReconfigureScreen not supported in this extension version\n");
106 if (major_version
< 2) {
108 "ChangeScreensAttributes not supported in this extension "
113 if (!(status
= DMXChangeScreensAttributes(display
, 1, &screen
, 1, &mask
,
114 &attr
, &errorScreen
))) {
115 printf("Reconfigured screen #%d to "
116 "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n",
118 attr
.screenWindowWidth
,
119 attr
.screenWindowHeight
,
120 (attr
.screenWindowXoffset
< 0 ? "" : "+"),
121 attr
.screenWindowXoffset
,
122 (attr
.screenWindowYoffset
< 0 ? "" : "+"),
123 attr
.screenWindowYoffset
,
124 attr
.rootWindowWidth
,
125 attr
.rootWindowHeight
,
126 (attr
.rootWindowXoffset
< 0 ? "" : "+"),
127 attr
.rootWindowXoffset
,
128 (attr
.rootWindowYoffset
< 0 ? "" : "+"),
129 attr
.rootWindowYoffset
,
130 (attr
.rootWindowXorigin
< 0 ? "" : "+"),
131 attr
.rootWindowXorigin
,
132 (attr
.rootWindowYorigin
< 0 ? "" : "+"),
133 attr
.rootWindowYorigin
);
136 "Could not set screen #%d to "
137 "%dx%d%s%d%s%d %dx%d%s%d%s%d %s%d%s%d\n"
138 "[status = %d, errorScreen=%d]\n",
140 attr
.screenWindowWidth
,
141 attr
.screenWindowHeight
,
142 (attr
.screenWindowXoffset
< 0 ? "" : "+"),
143 attr
.screenWindowXoffset
,
144 (attr
.screenWindowYoffset
< 0 ? "" : "+"),
145 attr
.screenWindowYoffset
,
146 attr
.rootWindowWidth
,
147 attr
.rootWindowHeight
,
148 (attr
.rootWindowXoffset
< 0 ? "" : "+"),
149 attr
.rootWindowXoffset
,
150 (attr
.rootWindowYoffset
< 0 ? "" : "+"),
151 attr
.rootWindowYoffset
,
152 (attr
.rootWindowXorigin
< 0 ? "" : "+"),
153 attr
.rootWindowXorigin
,
154 (attr
.rootWindowYorigin
< 0 ? "" : "+"),
155 attr
.rootWindowYorigin
,
156 status
, errorScreen
);
160 XCloseDisplay(display
);