aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xnest/Args.c
blob: 21faf2e3aecf0a356ab84dbf3185969ed58c348e (plain)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*

Copyright 1993 by Davor Matic

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.  Davor Matic makes no representations about
the suitability of this software for any purpose.  It is provided "as
is" without express or implied warranty.

*/

#ifdef HAVE_XNEST_CONFIG_H
#include <xnest-config.h>
#endif

#include <X11/X.h>
#include <X11/Xproto.h>
#include "screenint.h"
#include "input.h"
#include "misc.h"
#include "scrnintstr.h"
#include "servermd.h"

#include "Xnest.h"

#include "Display.h"
#include "Args.h"

char *xnestDisplayName = NULL;
Bool xnestSynchronize = False;
Bool xnestFullGeneration = False;
int xnestDefaultClass;
Bool xnestUserDefaultClass = False;
int xnestDefaultDepth;
Bool xnestUserDefaultDepth = False;
Bool xnestSoftwareScreenSaver = False;
int xnestX;
int xnestY;
unsigned int xnestWidth;
unsigned int xnestHeight;
int xnestUserGeometry = 0;
int xnestBorderWidth;
Bool xnestUserBorderWidth = False;
char *xnestWindowName = NULL;
int xnestNumScreens = 0;
Bool xnestDoDirectColormaps = False;
Window xnestParentWindow = 0;

int
ddxProcessArgument(int argc, char *argv[], int i)
{
    if (!strcmp(argv[i], "-display")) {
        if (++i < argc) {
            xnestDisplayName = argv[i];
            return 2;
        }
        return 0;
    }
    if (!strcmp(argv[i], "-sync")) {
        xnestSynchronize = True;
        return 1;
    }
    if (!strcmp(argv[i], "-full")) {
        xnestFullGeneration = True;
        return 1;
    }
    if (!strcmp(argv[i], "-class")) {
        if (++i < argc) {
            if (!strcmp(argv[i], "StaticGray")) {
                xnestDefaultClass = StaticGray;
                xnestUserDefaultClass = True;
                return 2;
            }
            else if (!strcmp(argv[i], "GrayScale")) {
                xnestDefaultClass = GrayScale;
                xnestUserDefaultClass = True;
                return 2;
            }
            else if (!strcmp(argv[i], "StaticColor")) {
                xnestDefaultClass = StaticColor;
                xnestUserDefaultClass = True;
                return 2;
            }
            else if (!strcmp(argv[i], "PseudoColor")) {
                xnestDefaultClass = PseudoColor;
                xnestUserDefaultClass = True;
                return 2;
            }
            else if (!strcmp(argv[i], "TrueColor")) {
                xnestDefaultClass = TrueColor;
                xnestUserDefaultClass = True;
                return 2;
            }
            else if (!strcmp(argv[i], "DirectColor")) {
                xnestDefaultClass = DirectColor;
                xnestUserDefaultClass = True;
                return 2;
            }
        }
        return 0;
    }
    if (!strcmp(argv[i], "-cc")) {
        if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) {
            if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) {
                xnestUserDefaultClass = True;
                /* lex the OS layer process it as well, so return 0 */
            }
        }
        return 0;
    }
    if (!strcmp(argv[i], "-depth")) {
        if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) {
            if (xnestDefaultDepth > 0) {
                xnestUserDefaultDepth = True;
                return 2;
            }
        }
        return 0;
    }
    if (!strcmp(argv[i], "-sss")) {
        xnestSoftwareScreenSaver = True;
        return 1;
    }
    if (!strcmp(argv[i], "-geometry")) {
        if (++i < argc) {
            xnestUserGeometry = XParseGeometry(argv[i],
                                               &xnestX, &xnestY,
                                               &xnestWidth, &xnestHeight);
            if (xnestUserGeometry)
                return 2;
        }
        return 0;
    }
    if (!strcmp(argv[i], "-bw")) {
        if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) {
            if (xnestBorderWidth >= 0) {
                xnestUserBorderWidth = True;
                return 2;
            }
        }
        return 0;
    }
    if (!strcmp(argv[i], "-name")) {
        if (++i < argc) {
            xnestWindowName = argv[i];
            return 2;
        }
        return 0;
    }
    if (!strcmp(argv[i], "-scrns")) {
        if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) {
            if (xnestNumScreens > 0) {
                if (xnestNumScreens > MAXSCREENS) {
                    ErrorF("Maximum number of screens is %d.\n", MAXSCREENS);
                    xnestNumScreens = MAXSCREENS;
                }
                return 2;
            }
        }
        return 0;
    }
    if (!strcmp(argv[i], "-install")) {
        xnestDoDirectColormaps = True;
        return 1;
    }
    if (!strcmp(argv[i], "-parent")) {
        if (++i < argc) {
            xnestParentWindow = (XID) strtol(argv[i], (char **) NULL, 0);
            return 2;
        }
    }
    return 0;
}

void
ddxUseMsg(void)
{
    ErrorF("-display string        display name of the real server\n");
    ErrorF("-sync                  sinchronize with the real server\n");
    ErrorF("-full                  utilize full regeneration\n");
    ErrorF("-class string          default visual class\n");
    ErrorF("-depth int             default depth\n");
    ErrorF("-sss                   use software screen saver\n");
    ErrorF("-geometry WxH+X+Y      window size and position\n");
    ErrorF("-bw int                window border width\n");
    ErrorF("-name string           window name\n");
    ErrorF("-scrns int             number of screens to generate\n");
    ErrorF("-install               instal colormaps directly\n");
}