Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xnest / Args.c
1 /*
2
3 Copyright 1993 by Davor Matic
4
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
12
13 */
14
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
17 #endif
18
19 #include <X11/X.h>
20 #include <X11/Xproto.h>
21 #include "screenint.h"
22 #include "input.h"
23 #include "misc.h"
24 #include "scrnintstr.h"
25 #include "servermd.h"
26
27 #include "Xnest.h"
28
29 #include "Display.h"
30 #include "Args.h"
31
32 char *xnestDisplayName = NULL;
33 Bool xnestSynchronize = False;
34 Bool xnestFullGeneration = False;
35 int xnestDefaultClass;
36 Bool xnestUserDefaultClass = False;
37 int xnestDefaultDepth;
38 Bool xnestUserDefaultDepth = False;
39 Bool xnestSoftwareScreenSaver = False;
40 int xnestX;
41 int xnestY;
42 unsigned int xnestWidth;
43 unsigned int xnestHeight;
44 int xnestUserGeometry = 0;
45 int xnestBorderWidth;
46 Bool xnestUserBorderWidth = False;
47 char *xnestWindowName = NULL;
48 int xnestNumScreens = 0;
49 Bool xnestDoDirectColormaps = False;
50 Window xnestParentWindow = 0;
51
52 int
53 ddxProcessArgument(int argc, char *argv[], int i)
54 {
55 if (!strcmp(argv[i], "-display")) {
56 if (++i < argc) {
57 xnestDisplayName = argv[i];
58 return 2;
59 }
60 return 0;
61 }
62 if (!strcmp(argv[i], "-sync")) {
63 xnestSynchronize = True;
64 return 1;
65 }
66 if (!strcmp(argv[i], "-full")) {
67 xnestFullGeneration = True;
68 return 1;
69 }
70 if (!strcmp(argv[i], "-class")) {
71 if (++i < argc) {
72 if (!strcmp(argv[i], "StaticGray")) {
73 xnestDefaultClass = StaticGray;
74 xnestUserDefaultClass = True;
75 return 2;
76 }
77 else if (!strcmp(argv[i], "GrayScale")) {
78 xnestDefaultClass = GrayScale;
79 xnestUserDefaultClass = True;
80 return 2;
81 }
82 else if (!strcmp(argv[i], "StaticColor")) {
83 xnestDefaultClass = StaticColor;
84 xnestUserDefaultClass = True;
85 return 2;
86 }
87 else if (!strcmp(argv[i], "PseudoColor")) {
88 xnestDefaultClass = PseudoColor;
89 xnestUserDefaultClass = True;
90 return 2;
91 }
92 else if (!strcmp(argv[i], "TrueColor")) {
93 xnestDefaultClass = TrueColor;
94 xnestUserDefaultClass = True;
95 return 2;
96 }
97 else if (!strcmp(argv[i], "DirectColor")) {
98 xnestDefaultClass = DirectColor;
99 xnestUserDefaultClass = True;
100 return 2;
101 }
102 }
103 return 0;
104 }
105 if (!strcmp(argv[i], "-cc")) {
106 if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) {
107 if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) {
108 xnestUserDefaultClass = True;
109 /* lex the OS layer process it as well, so return 0 */
110 }
111 }
112 return 0;
113 }
114 if (!strcmp(argv[i], "-depth")) {
115 if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) {
116 if (xnestDefaultDepth > 0) {
117 xnestUserDefaultDepth = True;
118 return 2;
119 }
120 }
121 return 0;
122 }
123 if (!strcmp(argv[i], "-sss")) {
124 xnestSoftwareScreenSaver = True;
125 return 1;
126 }
127 if (!strcmp(argv[i], "-geometry")) {
128 if (++i < argc) {
129 xnestUserGeometry = XParseGeometry(argv[i],
130 &xnestX, &xnestY,
131 &xnestWidth, &xnestHeight);
132 if (xnestUserGeometry)
133 return 2;
134 }
135 return 0;
136 }
137 if (!strcmp(argv[i], "-bw")) {
138 if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) {
139 if (xnestBorderWidth >= 0) {
140 xnestUserBorderWidth = True;
141 return 2;
142 }
143 }
144 return 0;
145 }
146 if (!strcmp(argv[i], "-name")) {
147 if (++i < argc) {
148 xnestWindowName = argv[i];
149 return 2;
150 }
151 return 0;
152 }
153 if (!strcmp(argv[i], "-scrns")) {
154 if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) {
155 if (xnestNumScreens > 0) {
156 if (xnestNumScreens > MAXSCREENS) {
157 ErrorF("Maximum number of screens is %d.\n", MAXSCREENS);
158 xnestNumScreens = MAXSCREENS;
159 }
160 return 2;
161 }
162 }
163 return 0;
164 }
165 if (!strcmp(argv[i], "-install")) {
166 xnestDoDirectColormaps = True;
167 return 1;
168 }
169 if (!strcmp(argv[i], "-parent")) {
170 if (++i < argc) {
171 xnestParentWindow = (XID) strtol(argv[i], (char **) NULL, 0);
172 return 2;
173 }
174 }
175 return 0;
176 }
177
178 void
179 ddxUseMsg(void)
180 {
181 ErrorF("-display string display name of the real server\n");
182 ErrorF("-sync sinchronize with the real server\n");
183 ErrorF("-full utilize full regeneration\n");
184 ErrorF("-class string default visual class\n");
185 ErrorF("-depth int default depth\n");
186 ErrorF("-sss use software screen saver\n");
187 ErrorF("-geometry WxH+X+Y window size and position\n");
188 ErrorF("-bw int window border width\n");
189 ErrorF("-name string window name\n");
190 ErrorF("-scrns int number of screens to generate\n");
191 ErrorF("-install instal colormaps directly\n");
192 }