| 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 |
| 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 |
| 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 | #ifdef XWIN_MULTIWINDOW |
| 90 | if (g_ScreenInfo[i].fMultiWindow) |
| 91 | ++iCount; |
| 92 | #endif |
| 93 | #ifdef XWIN_MULTIWINDOWEXTWM |
| 94 | if (g_ScreenInfo[i].fMWExtWM) |
| 95 | ++iCount; |
| 96 | #endif |
| 97 | if (g_ScreenInfo[i].fRootless) |
| 98 | ++iCount; |
| 99 | |
| 100 | /* Check if the first screen is without rootless and multiwindow */ |
| 101 | if (iCount == 0 && i == 0) |
| 102 | fHasNormalScreen0 = TRUE; |
| 103 | |
| 104 | /* Fail if two or more conflicting options */ |
| 105 | if (iCount > 1) { |
| 106 | ErrorF("winValidateArgs - Only one of -multiwindow, -mwextwm, " |
| 107 | "and -rootless can be specific at a time.\n"); |
| 108 | return FALSE; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /* Check for -multiwindow or -mwextwm and Xdmcp */ |
| 113 | /* allow xdmcp if screen 0 is normal. */ |
| 114 | if (g_fXdmcpEnabled && !fHasNormalScreen0 && (FALSE |
| 115 | #ifdef XWIN_MULTIWINDOW |
| 116 | || g_ScreenInfo[i]. |
| 117 | fMultiWindow |
| 118 | #endif |
| 119 | #ifdef XWIN_MULTIWINDOWEXTWM |
| 120 | || g_ScreenInfo[i]. |
| 121 | fMWExtWM |
| 122 | #endif |
| 123 | ) |
| 124 | ) { |
| 125 | ErrorF("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) " |
| 126 | "is invalid with -multiwindow or -mwextwm.\n"); |
| 127 | return FALSE; |
| 128 | } |
| 129 | |
| 130 | /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */ |
| 131 | if (g_ScreenInfo[i].fFullScreen && (FALSE |
| 132 | #ifdef XWIN_MULTIWINDOW |
| 133 | || g_ScreenInfo[i].fMultiWindow |
| 134 | #endif |
| 135 | #ifdef XWIN_MULTIWINDOWEXTWM |
| 136 | || g_ScreenInfo[i].fMWExtWM |
| 137 | #endif |
| 138 | || g_ScreenInfo[i].fRootless) |
| 139 | ) { |
| 140 | ErrorF("winValidateArgs - -fullscreen is invalid with " |
| 141 | "-multiwindow, -mwextwm, or -rootless.\n"); |
| 142 | return FALSE; |
| 143 | } |
| 144 | |
| 145 | /* Check for !fullscreen and any fullscreen-only parameters */ |
| 146 | if (!g_ScreenInfo[i].fFullScreen |
| 147 | && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH |
| 148 | || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP)) { |
| 149 | ErrorF("winValidateArgs - -refresh and -depth are only valid " |
| 150 | "with -fullscreen.\n"); |
| 151 | return FALSE; |
| 152 | } |
| 153 | |
| 154 | /* Check for fullscreen and any non-fullscreen parameters */ |
| 155 | if (g_ScreenInfo[i].fFullScreen |
| 156 | && ((g_ScreenInfo[i].iResizeMode != notAllowed) |
| 157 | || !g_ScreenInfo[i].fDecoration |
| 158 | || g_ScreenInfo[i].fLessPointer)) { |
| 159 | ErrorF("winValidateArgs - -fullscreen is invalid with " |
| 160 | "-scrollbars, -resize, -nodecoration, or -lesspointer.\n"); |
| 161 | return FALSE; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | winDebug("winValidateArgs - Returning.\n"); |
| 166 | |
| 167 | return TRUE; |
| 168 | } |