1706f2543Smrg/*
2706f2543Smrg
3706f2543SmrgCopyright 1993 by Davor Matic
4706f2543Smrg
5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software
6706f2543Smrgand its documentation for any purpose is hereby granted without fee,
7706f2543Smrgprovided that the above copyright notice appear in all copies and that
8706f2543Smrgboth that copyright notice and this permission notice appear in
9706f2543Smrgsupporting documentation.  Davor Matic makes no representations about
10706f2543Smrgthe suitability of this software for any purpose.  It is provided "as
11706f2543Smrgis" without express or implied warranty.
12706f2543Smrg
13706f2543Smrg*/
14706f2543Smrg
15706f2543Smrg#ifdef HAVE_XNEST_CONFIG_H
16706f2543Smrg#include <xnest-config.h>
17706f2543Smrg#endif
18706f2543Smrg
19706f2543Smrg#include <X11/X.h>
20706f2543Smrg#include <X11/Xproto.h>
21706f2543Smrg#include "screenint.h"
22706f2543Smrg#include "input.h"
23706f2543Smrg#include "misc.h"
24706f2543Smrg#include "scrnintstr.h"
25706f2543Smrg#include "servermd.h"
26706f2543Smrg
27706f2543Smrg#include "Xnest.h"
28706f2543Smrg
29706f2543Smrg#include "Display.h"
30706f2543Smrg#include "Args.h"
31706f2543Smrg
32706f2543Smrgchar *xnestDisplayName = NULL;
33706f2543SmrgBool xnestSynchronize = False;
34706f2543SmrgBool xnestFullGeneration = False;
35706f2543Smrgint xnestDefaultClass;
36706f2543SmrgBool xnestUserDefaultClass = False;
37706f2543Smrgint xnestDefaultDepth;
38706f2543SmrgBool xnestUserDefaultDepth = False;
39706f2543SmrgBool xnestSoftwareScreenSaver = False;
40706f2543Smrgint xnestX;
41706f2543Smrgint xnestY;
42706f2543Smrgunsigned int xnestWidth;
43706f2543Smrgunsigned int xnestHeight;
44706f2543Smrgint xnestUserGeometry = 0;
45706f2543Smrgint xnestBorderWidth;
46706f2543SmrgBool xnestUserBorderWidth = False;
47706f2543Smrgchar *xnestWindowName = NULL;
48706f2543Smrgint xnestNumScreens = 0;
49706f2543SmrgBool xnestDoDirectColormaps = False;
50706f2543SmrgWindow xnestParentWindow = 0;
51706f2543Smrg
52706f2543Smrgint
53706f2543SmrgddxProcessArgument (int argc, char *argv[], int i)
54706f2543Smrg{
55706f2543Smrg  if (!strcmp(argv[i], "-display")) {
56706f2543Smrg    if (++i < argc) {
57706f2543Smrg      xnestDisplayName = argv[i];
58706f2543Smrg      return 2;
59706f2543Smrg    }
60706f2543Smrg    return 0;
61706f2543Smrg  }
62706f2543Smrg  if (!strcmp(argv[i], "-sync")) {
63706f2543Smrg    xnestSynchronize = True;
64706f2543Smrg    return 1;
65706f2543Smrg  }
66706f2543Smrg  if (!strcmp(argv[i], "-full")) {
67706f2543Smrg    xnestFullGeneration = True;
68706f2543Smrg    return 1;
69706f2543Smrg  }
70706f2543Smrg  if (!strcmp(argv[i], "-class")) {
71706f2543Smrg    if (++i < argc) {
72706f2543Smrg      if (!strcmp(argv[i], "StaticGray")) {
73706f2543Smrg	xnestDefaultClass = StaticGray;
74706f2543Smrg	xnestUserDefaultClass = True;
75706f2543Smrg	return 2;
76706f2543Smrg      }
77706f2543Smrg      else if (!strcmp(argv[i], "GrayScale")) {
78706f2543Smrg	xnestDefaultClass = GrayScale;
79706f2543Smrg	xnestUserDefaultClass = True;
80706f2543Smrg	return 2;
81706f2543Smrg      }
82706f2543Smrg      else if (!strcmp(argv[i], "StaticColor")) {
83706f2543Smrg	xnestDefaultClass = StaticColor;
84706f2543Smrg	xnestUserDefaultClass = True;
85706f2543Smrg	return 2;
86706f2543Smrg      }
87706f2543Smrg      else if (!strcmp(argv[i], "PseudoColor")) {
88706f2543Smrg	xnestDefaultClass = PseudoColor;
89706f2543Smrg	xnestUserDefaultClass = True;
90706f2543Smrg	return 2;
91706f2543Smrg      }
92706f2543Smrg      else if (!strcmp(argv[i], "TrueColor")) {
93706f2543Smrg	xnestDefaultClass = TrueColor;
94706f2543Smrg	xnestUserDefaultClass = True;
95706f2543Smrg	return 2;
96706f2543Smrg      }
97706f2543Smrg      else if (!strcmp(argv[i], "DirectColor")) {
98706f2543Smrg	xnestDefaultClass = DirectColor;
99706f2543Smrg	xnestUserDefaultClass = True;
100706f2543Smrg	return 2;
101706f2543Smrg      }
102706f2543Smrg    }
103706f2543Smrg    return 0;
104706f2543Smrg  }
105706f2543Smrg  if (!strcmp(argv[i], "-cc")) {
106706f2543Smrg    if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) {
107706f2543Smrg      if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) {
108706f2543Smrg	xnestUserDefaultClass = True;
109706f2543Smrg	/* lex the OS layer process it as well, so return 0 */
110706f2543Smrg      }
111706f2543Smrg    }
112706f2543Smrg    return 0;
113706f2543Smrg  }
114706f2543Smrg  if (!strcmp(argv[i], "-depth")) {
115706f2543Smrg    if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) {
116706f2543Smrg      if (xnestDefaultDepth > 0) {
117706f2543Smrg	xnestUserDefaultDepth = True;
118706f2543Smrg	return 2;
119706f2543Smrg      }
120706f2543Smrg    }
121706f2543Smrg    return 0;
122706f2543Smrg  }
123706f2543Smrg  if (!strcmp(argv[i], "-sss")) {
124706f2543Smrg    xnestSoftwareScreenSaver = True;
125706f2543Smrg    return 1;
126706f2543Smrg  }
127706f2543Smrg  if (!strcmp(argv[i], "-geometry")) {
128706f2543Smrg    if (++i < argc) {
129706f2543Smrg      xnestUserGeometry = XParseGeometry(argv[i],
130706f2543Smrg					 &xnestX, &xnestY,
131706f2543Smrg					 &xnestWidth, &xnestHeight);
132706f2543Smrg      if (xnestUserGeometry) return 2;
133706f2543Smrg    }
134706f2543Smrg    return 0;
135706f2543Smrg  }
136706f2543Smrg  if (!strcmp(argv[i], "-bw")) {
137706f2543Smrg    if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) {
138706f2543Smrg      if (xnestBorderWidth >= 0) {
139706f2543Smrg	xnestUserBorderWidth = True;
140706f2543Smrg	return 2;
141706f2543Smrg      }
142706f2543Smrg    }
143706f2543Smrg    return 0;
144706f2543Smrg  }
145706f2543Smrg  if (!strcmp(argv[i], "-name")) {
146706f2543Smrg    if (++i < argc) {
147706f2543Smrg      xnestWindowName = argv[i];
148706f2543Smrg      return 2;
149706f2543Smrg    }
150706f2543Smrg    return 0;
151706f2543Smrg  }
152706f2543Smrg  if (!strcmp(argv[i], "-scrns")) {
153706f2543Smrg    if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) {
154706f2543Smrg      if (xnestNumScreens > 0) {
155706f2543Smrg	if (xnestNumScreens > MAXSCREENS) {
156706f2543Smrg	  ErrorF("Maximum number of screens is %d.\n", MAXSCREENS);
157706f2543Smrg	  xnestNumScreens = MAXSCREENS;
158706f2543Smrg	}
159706f2543Smrg	return 2;
160706f2543Smrg      }
161706f2543Smrg    }
162706f2543Smrg    return 0;
163706f2543Smrg  }
164706f2543Smrg  if (!strcmp(argv[i], "-install")) {
165706f2543Smrg    xnestDoDirectColormaps = True;
166706f2543Smrg    return 1;
167706f2543Smrg  }
168706f2543Smrg  if (!strcmp(argv[i], "-parent")) {
169706f2543Smrg    if (++i < argc) {
170706f2543Smrg      xnestParentWindow = (XID) strtol (argv[i], (char**)NULL, 0);
171706f2543Smrg      return 2;
172706f2543Smrg    }
173706f2543Smrg  }
174706f2543Smrg  return 0;
175706f2543Smrg}
176706f2543Smrg
177706f2543Smrgvoid ddxUseMsg(void)
178706f2543Smrg{
179706f2543Smrg  ErrorF("-display string        display name of the real server\n");
180706f2543Smrg  ErrorF("-sync                  sinchronize with the real server\n");
181706f2543Smrg  ErrorF("-full                  utilize full regeneration\n");
182706f2543Smrg  ErrorF("-class string          default visual class\n");
183706f2543Smrg  ErrorF("-depth int             default depth\n");
184706f2543Smrg  ErrorF("-sss                   use software screen saver\n");
185706f2543Smrg  ErrorF("-geometry WxH+X+Y      window size and position\n");
186706f2543Smrg  ErrorF("-bw int                window border width\n");
187706f2543Smrg  ErrorF("-name string           window name\n");
188706f2543Smrg  ErrorF("-scrns int             number of screens to generate\n");
189706f2543Smrg  ErrorF("-install               instal colormaps directly\n");
190706f2543Smrg}
191