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 39 40/* 41 * Verify all screens have been explicitly specified 42 */ 43static BOOL 44isEveryScreenExplicit(void) 45{ 46 int i; 47 48 for (i = 0; i < g_iNumScreens; i++) 49 if (!g_ScreenInfo[i].fExplicitScreen) 50 return FALSE; 51 52 return TRUE; 53} 54 55/* 56 * winValidateArgs - Look for invalid argument combinations 57 */ 58 59Bool 60winValidateArgs (void) 61{ 62 int i; 63 int iMaxConsecutiveScreen = 0; 64 BOOL fHasNormalScreen0 = FALSE; 65 BOOL fImplicitScreenFound = FALSE; 66 67 /* 68 * Check for a malformed set of -screen parameters. 69 * Examples of malformed parameters: 70 * XWin -screen 1 71 * XWin -screen 0 -screen 2 72 * XWin -screen 1 -screen 2 73 */ 74 if (!isEveryScreenExplicit()) 75 { 76 ErrorF ("winValidateArgs - Malformed set of screen parameter(s). " 77 "Screens must be specified consecutively starting with " 78 "screen 0. That is, you cannot have only a screen 1, nor " 79 "could you have screen 0 and screen 2. You instead must " 80 "have screen 0, or screen 0 and screen 1, respectively. " 81 "You can specify as many screens as you want.\n"); 82 return FALSE; 83 } 84 85 /* Loop through all screens */ 86 for (i = 0; i < g_iNumScreens; ++i) 87 { 88 /* 89 * Check for any combination of 90 * -multiwindow, -mwextwm, and -rootless. 91 */ 92 { 93 int iCount = 0; 94 95 /* Count conflicting options */ 96#ifdef XWIN_MULTIWINDOW 97 if (g_ScreenInfo[i].fMultiWindow) 98 ++iCount; 99#endif 100#ifdef XWIN_MULTIWINDOWEXTWM 101 if (g_ScreenInfo[i].fMWExtWM) 102 ++iCount; 103#endif 104 if (g_ScreenInfo[i].fRootless) 105 ++iCount; 106 107 /* Check if the first screen is without rootless and multiwindow */ 108 if (iCount == 0 && i == 0) 109 fHasNormalScreen0 = TRUE; 110 111 /* Fail if two or more conflicting options */ 112 if (iCount > 1) 113 { 114 ErrorF ("winValidateArgs - Only one of -multiwindow, -mwextwm, " 115 "and -rootless can be specific at a time.\n"); 116 return FALSE; 117 } 118 } 119 120 /* Check for -multiwindow or -mwextwm and Xdmcp */ 121 /* allow xdmcp if screen 0 is normal. */ 122 if (g_fXdmcpEnabled && !fHasNormalScreen0 123 && (FALSE 124#ifdef XWIN_MULTIWINDOW 125 || g_ScreenInfo[i].fMultiWindow 126#endif 127#ifdef XWIN_MULTIWINDOWEXTWM 128 || g_ScreenInfo[i].fMWExtWM 129#endif 130 ) 131 ) 132 { 133 ErrorF ("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) " 134 "is invalid with -multiwindow or -mwextwm.\n"); 135 return FALSE; 136 } 137 138 /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */ 139 if (g_ScreenInfo[i].fFullScreen 140 && (FALSE 141#ifdef XWIN_MULTIWINDOW 142 || g_ScreenInfo[i].fMultiWindow 143#endif 144#ifdef XWIN_MULTIWINDOWEXTWM 145 || g_ScreenInfo[i].fMWExtWM 146#endif 147 || g_ScreenInfo[i].fRootless) 148 ) 149 { 150 ErrorF ("winValidateArgs - -fullscreen is invalid with " 151 "-multiwindow, -mwextwm, or -rootless.\n"); 152 return FALSE; 153 } 154 155 /* Check for !fullscreen and any fullscreen-only parameters */ 156 if (!g_ScreenInfo[i].fFullScreen 157 && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH 158 || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP)) 159 { 160 ErrorF ("winValidateArgs - -refresh and -depth are only valid " 161 "with -fullscreen.\n"); 162 return FALSE; 163 } 164 165 /* Check for fullscreen and any non-fullscreen parameters */ 166 if (g_ScreenInfo[i].fFullScreen 167 && ((g_ScreenInfo[i].iResizeMode != notAllowed) 168 || !g_ScreenInfo[i].fDecoration 169 || g_ScreenInfo[i].fLessPointer)) 170 { 171 ErrorF ("winValidateArgs - -fullscreen is invalid with " 172 "-scrollbars, -resize, -nodecoration, or -lesspointer.\n"); 173 return FALSE; 174 } 175 } 176 177 winDebug ("winValidateArgs - Returning.\n"); 178 179 return TRUE; 180} 181