1 /*
2 *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
3 *
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
11 *
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
14 *
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 *Except as contained in this notice, the name of Harold L Hunt II
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from Harold L Hunt II.
27 *
28 * Authors: Harold L Hunt II
29 */
30
31 #ifdef HAVE_XWIN_CONFIG_H
32 #include <xwin-config.h>
33 #endif
34 #include "win.h"
35 #include "winmsg.h"
36
37 /*
38 * Verify all screens have been explicitly specified
39 */
40 static BOOL
isEveryScreenExplicit(void)41 isEveryScreenExplicit(void)
42 {
43 int i;
44
45 for (i = 0; i < g_iNumScreens; i++)
46 if (!g_ScreenInfo[i].fExplicitScreen)
47 return FALSE;
48
49 return TRUE;
50 }
51
52 /*
53 * winValidateArgs - Look for invalid argument combinations
54 */
55
56 Bool
winValidateArgs(void)57 winValidateArgs(void)
58 {
59 int i;
60 BOOL fHasNormalScreen0 = FALSE;
61
62 /*
63 * Check for a malformed set of -screen parameters.
64 * Examples of malformed parameters:
65 * XWin -screen 1
66 * XWin -screen 0 -screen 2
67 * XWin -screen 1 -screen 2
68 */
69 if (!isEveryScreenExplicit()) {
70 ErrorF("winValidateArgs - Malformed set of screen parameter(s). "
71 "Screens must be specified consecutively starting with "
72 "screen 0. That is, you cannot have only a screen 1, nor "
73 "could you have screen 0 and screen 2. You instead must "
74 "have screen 0, or screen 0 and screen 1, respectively. "
75 "You can specify as many screens as you want.\n");
76 return FALSE;
77 }
78
79 /* Loop through all screens */
80 for (i = 0; i < g_iNumScreens; ++i) {
81 /*
82 * Check for any combination of
83 * -multiwindow, -mwextwm, and -rootless.
84 */
85 {
86 int iCount = 0;
87
88 /* Count conflicting options */
89 if (g_ScreenInfo[i].fMultiWindow)
90 ++iCount;
91 #ifdef XWIN_MULTIWINDOWEXTWM
92 if (g_ScreenInfo[i].fMWExtWM)
93 ++iCount;
94 #endif
95 if (g_ScreenInfo[i].fRootless)
96 ++iCount;
97
98 /* Check if the first screen is without rootless and multiwindow */
99 if (iCount == 0 && i == 0)
100 fHasNormalScreen0 = TRUE;
101
102 /* Fail if two or more conflicting options */
103 if (iCount > 1) {
104 ErrorF("winValidateArgs - Only one of -multiwindow, -mwextwm, "
105 "and -rootless can be specific at a time.\n");
106 return FALSE;
107 }
108 }
109
110 /* Check for -multiwindow or -mwextwm and Xdmcp */
111 /* allow xdmcp if screen 0 is normal. */
112 if (g_fXdmcpEnabled && !fHasNormalScreen0 && (FALSE
113 || g_ScreenInfo[i].
114 fMultiWindow
115
116 #ifdef XWIN_MULTIWINDOWEXTWM
117 || g_ScreenInfo[i].
118 fMWExtWM
119 #endif
120 )
121 ) {
122 ErrorF("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
123 "is invalid with -multiwindow or -mwextwm.\n");
124 return FALSE;
125 }
126
127 /* Check for -multiwindow, -mwextwm, or -rootless and -fullscreen */
128 if (g_ScreenInfo[i].fFullScreen && (FALSE
129 || g_ScreenInfo[i].fMultiWindow
130 #ifdef XWIN_MULTIWINDOWEXTWM
131 || g_ScreenInfo[i].fMWExtWM
132 #endif
133 || g_ScreenInfo[i].fRootless)
134 ) {
135 ErrorF("winValidateArgs - -fullscreen is invalid with "
136 "-multiwindow, -mwextwm, or -rootless.\n");
137 return FALSE;
138 }
139
140 /* Check for -multiwindow, -mwextwm, or -rootless and -nodecoration */
141 if (!g_ScreenInfo[i].fDecoration && (FALSE
142 || g_ScreenInfo[i].fMultiWindow
143 #ifdef XWIN_MULTIWINDOWEXTWM
144 || g_ScreenInfo[i].fMWExtWM
145 #endif
146 || g_ScreenInfo[i].fRootless)
147 ) {
148 ErrorF("winValidateArgs - -nodecoration is invalid with "
149 "-multiwindow, -mwextwm, or -rootless.\n");
150 return FALSE;
151 }
152
153 /* Check for !fullscreen and any fullscreen-only parameters */
154 if (!g_ScreenInfo[i].fFullScreen
155 && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
156 || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP)) {
157 ErrorF("winValidateArgs - -refresh and -depth are only valid "
158 "with -fullscreen.\n");
159 return FALSE;
160 }
161
162 /* Check for fullscreen and any non-fullscreen parameters */
163 if (g_ScreenInfo[i].fFullScreen
164 && ((g_ScreenInfo[i].iResizeMode != resizeNotAllowed)
165 || !g_ScreenInfo[i].fDecoration
166 || g_ScreenInfo[i].fLessPointer)) {
167 ErrorF("winValidateArgs - -fullscreen is invalid with "
168 "-scrollbars, -resize, -nodecoration, or -lesspointer.\n");
169 return FALSE;
170 }
171 }
172
173 winDebug("winValidateArgs - Returning.\n");
174
175 return TRUE;
176 }
177