3 Copyright 1993, 1998 The Open Group
4 Copyright (C) Colin Harrison 2005-2008
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of The Open Group shall
24 not be used in advertising or otherwise to promote the sale, use or
25 other dealings in this Software without prior written authorization
30 #ifdef HAVE_XWIN_CONFIG_H
31 #include <xwin-config.h>
34 #ifdef HAVE_SYS_UTSNAME_H
35 #include <sys/utsname.h>
38 #include "os/cmdline.h"
40 #include "os/ddx_priv.h"
42 #include <../xfree86/common/xorgVersion.h>
44 #include "winconfig.h"
46 #include "winmonitors.h"
49 #include "winclipboard/winclipboard.h"
56 winLogCommandLine(int argc
, char *argv
[]);
59 winLogVersionInfo(void);
62 * Process arguments on the command line
65 static int iLastScreen
= -1;
66 static winScreenInfo defaultScreenInfo
;
69 winInitializeScreenDefaults(void)
71 DWORD dwWidth
, dwHeight
;
72 static Bool fInitializedScreenDefaults
= FALSE
;
74 /* Bail out early if default screen has already been initialized */
75 if (fInitializedScreenDefaults
)
78 /* Zero the memory used for storing the screen info */
79 memset(&defaultScreenInfo
, 0, sizeof(winScreenInfo
));
81 /* Get default width and height */
83 * NOTE: These defaults will cause the window to cover only
84 * the primary monitor in the case that we have multiple monitors.
86 dwWidth
= GetSystemMetrics(SM_CXSCREEN
);
87 dwHeight
= GetSystemMetrics(SM_CYSCREEN
);
90 "winInitializeScreenDefaults - primary monitor w %d h %d\n",
91 (int) dwWidth
, (int) dwHeight
);
93 /* Set a default DPI, if no '-dpi' option was used */
94 if (monitorResolution
== 0) {
95 HDC hdc
= GetDC(NULL
);
98 int dpiX
= GetDeviceCaps(hdc
, LOGPIXELSX
);
99 int dpiY
= GetDeviceCaps(hdc
, LOGPIXELSY
);
102 "winInitializeScreenDefaults - native DPI x %d y %d\n",
105 monitorResolution
= dpiY
;
106 ReleaseDC(NULL
, hdc
);
110 "winInitializeScreenDefaults - Failed to retrieve native DPI, falling back to default of %d DPI\n",
112 monitorResolution
= WIN_DEFAULT_DPI
;
116 defaultScreenInfo
.iMonitor
= 1;
117 defaultScreenInfo
.hMonitor
= MonitorFromWindow(NULL
, MONITOR_DEFAULTTOPRIMARY
);
118 defaultScreenInfo
.dwWidth
= dwWidth
;
119 defaultScreenInfo
.dwHeight
= dwHeight
;
120 defaultScreenInfo
.dwUserWidth
= dwWidth
;
121 defaultScreenInfo
.dwUserHeight
= dwHeight
;
122 defaultScreenInfo
.fUserGaveHeightAndWidth
=
123 WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH
;
124 defaultScreenInfo
.fUserGavePosition
= FALSE
;
125 defaultScreenInfo
.dwBPP
= WIN_DEFAULT_BPP
;
126 defaultScreenInfo
.dwClipUpdatesNBoxes
= WIN_DEFAULT_CLIP_UPDATES_NBOXES
;
127 #ifdef XWIN_EMULATEPSEUDO
128 defaultScreenInfo
.fEmulatePseudo
= WIN_DEFAULT_EMULATE_PSEUDO
;
130 defaultScreenInfo
.dwRefreshRate
= WIN_DEFAULT_REFRESH
;
131 defaultScreenInfo
.pfb
= NULL
;
132 defaultScreenInfo
.fFullScreen
= FALSE
;
133 defaultScreenInfo
.fDecoration
= TRUE
;
134 defaultScreenInfo
.fRootless
= FALSE
;
135 defaultScreenInfo
.fMultiWindow
= FALSE
;
136 defaultScreenInfo
.fCompositeWM
= TRUE
;
137 defaultScreenInfo
.fMultiMonitorOverride
= FALSE
;
138 defaultScreenInfo
.fMultipleMonitors
= FALSE
;
139 defaultScreenInfo
.fLessPointer
= FALSE
;
140 defaultScreenInfo
.iResizeMode
= resizeDefault
;
141 defaultScreenInfo
.fNoTrayIcon
= FALSE
;
142 defaultScreenInfo
.iE3BTimeout
= WIN_E3B_DEFAULT
;
143 defaultScreenInfo
.fUseWinKillKey
= WIN_DEFAULT_WIN_KILL
;
144 defaultScreenInfo
.fUseUnixKillKey
= WIN_DEFAULT_UNIX_KILL
;
145 defaultScreenInfo
.fIgnoreInput
= FALSE
;
146 defaultScreenInfo
.fExplicitScreen
= FALSE
;
147 defaultScreenInfo
.hIcon
= (HICON
)
148 LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(IDI_XWIN
), IMAGE_ICON
,
149 GetSystemMetrics(SM_CXICON
), GetSystemMetrics(SM_CYICON
), 0);
150 defaultScreenInfo
.hIconSm
= (HICON
)
151 LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(IDI_XWIN
), IMAGE_ICON
,
152 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
),
155 /* Note that the default screen has been initialized */
156 fInitializedScreenDefaults
= TRUE
;
160 winInitializeScreen(int i
)
162 winErrorFVerb(3, "winInitializeScreen - %d\n", i
);
164 /* Initialize default screen values, if needed */
165 winInitializeScreenDefaults();
167 /* Copy the default screen info */
168 g_ScreenInfo
[i
] = defaultScreenInfo
;
170 /* Set the screen number */
171 g_ScreenInfo
[i
].dwScreen
= i
;
175 winInitializeScreens(int maxscreens
)
179 winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens
);
181 if (maxscreens
> g_iNumScreens
) {
182 /* Reallocate the memory for DDX-specific screen info */
184 realloc(g_ScreenInfo
, maxscreens
* sizeof(winScreenInfo
));
186 /* Set default values for any new screens */
187 for (i
= g_iNumScreens
; i
< maxscreens
; i
++)
188 winInitializeScreen(i
);
190 /* Keep a count of the number of screens */
191 g_iNumScreens
= maxscreens
;
195 /* See Porting Layer Definition - p. 57 */
198 * argv: pointer to an array of null-terminated strings, one for
199 * each token in the X Server command line; the first token
200 * is 'XWin.exe', or similar.
201 * argc: a count of the number of tokens stored in argv.
202 * i: a zero-based index into argv indicating the current token being
206 * return: return the number of tokens processed correctly.
209 * When looking for n tokens, check that i + n is less than argc. Or,
210 * you may check if i is greater than or equal to argc, in which case
211 * you should display the UseMsg () and return 0.
214 /* Check if enough arguments are given for the option */
215 #define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
217 /* Compare the current option with the string. */
218 #define IS_OPTION(name) (strcmp (argv[i], name) == 0)
221 ddxProcessArgument(int argc
, char *argv
[], int i
)
223 static Bool s_fBeenHere
= FALSE
;
224 winScreenInfo
*screenInfoPtr
= NULL
;
226 /* Initialize once */
229 * This initialises our hook into VErrorF () for catching log messages
230 * that are generated before OsInit () is called.
232 OsVendorVErrorFProc
= OsVendorVErrorF
;
236 /* Initialize only if option is not -help */
237 if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
238 !IS_OPTION("-version") && !IS_OPTION("--version")) {
240 /* Log the version information */
243 /* Log the command line */
244 winLogCommandLine(argc
, argv
);
247 * Initialize default screen settings. We have to do this before
248 * OsVendorInit () gets called, otherwise we will overwrite
249 * settings changed by parameters such as -fullscreen, etc.
251 winErrorFVerb(3, "ddxProcessArgument - Initializing default "
253 winInitializeScreenDefaults();
258 winDebug("ddxProcessArgument - arg: %s\n", argv
[i
]);
262 * Look for the '-help' and similar options
264 if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) {
265 /* Reset logfile. We don't need that helpmessage in the logfile */
267 g_fNoHelpMessageBox
= TRUE
;
273 if (IS_OPTION("-version") || IS_OPTION("--version")) {
274 /* Reset logfile. We don't need that versioninfo in the logfile */
282 * Look for the '-screen scr_num [width height]' argument
284 if (IS_OPTION("-screen")) {
285 int iArgsProcessed
= 1;
287 int iWidth
, iHeight
, iX
, iY
;
291 winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc
, i
);
294 /* Display the usage message if the argument is malformed */
299 /* Grab screen number */
300 nScreenNum
= atoi(argv
[i
+ 1]);
302 /* Validate the specified screen number */
303 if (nScreenNum
< 0) {
304 ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n",
311 Initialize default values for any new screens
313 Note that default values can't change after a -screen option is
314 seen, so it's safe to do this for each screen as it is introduced
316 winInitializeScreens(nScreenNum
+ 1);
318 /* look for @m where m is monitor number */
319 if (i
+ 2 < argc
&& 1 == sscanf(argv
[i
+ 2], "@%d", (int *) &iMonitor
)) {
320 struct GetMonitorInfoData data
;
322 if (QueryMonitor(iMonitor
, &data
)) {
324 "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
327 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
328 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
329 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
330 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
331 g_ScreenInfo
[nScreenNum
].dwWidth
= data
.monitorWidth
;
332 g_ScreenInfo
[nScreenNum
].dwHeight
= data
.monitorHeight
;
333 g_ScreenInfo
[nScreenNum
].dwUserWidth
= data
.monitorWidth
;
334 g_ScreenInfo
[nScreenNum
].dwUserHeight
= data
.monitorHeight
;
335 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
336 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
339 /* monitor does not exist, error out */
341 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
348 /* Look for 'WxD' or 'W D' */
349 else if (i
+ 2 < argc
350 && 2 == sscanf(argv
[i
+ 2], "%dx%d",
351 (int *) &iWidth
, (int *) &iHeight
)) {
353 "ddxProcessArgument - screen - Found ``WxD'' arg\n");
355 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
356 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
357 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
358 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
359 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
360 /* Look for WxD+X+Y */
361 if (2 == sscanf(argv
[i
+ 2], "%*dx%*d+%d+%d",
362 (int *) &iX
, (int *) &iY
)) {
364 "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
365 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
366 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
367 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
369 /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
370 if (1 == sscanf(argv
[i
+ 2], "%*dx%*d+%*d+%*d@%d",
371 (int *) &iMonitor
)) {
372 struct GetMonitorInfoData data
;
374 if (QueryMonitor(iMonitor
, &data
)) {
375 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
376 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
377 g_ScreenInfo
[nScreenNum
].dwInitialX
+=
379 g_ScreenInfo
[nScreenNum
].dwInitialY
+=
383 /* monitor does not exist, error out */
385 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
393 /* look for WxD@m where m is monitor number */
394 else if (1 == sscanf(argv
[i
+ 2], "%*dx%*d@%d", (int *) &iMonitor
)) {
395 struct GetMonitorInfoData data
;
397 if (QueryMonitor(iMonitor
, &data
)) {
399 "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
401 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
402 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
403 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
404 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
405 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
408 /* monitor does not exist, error out */
410 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
417 else if (i
+ 3 < argc
&& 1 == sscanf(argv
[i
+ 2], "%d", (int *) &iWidth
)
418 && 1 == sscanf(argv
[i
+ 3], "%d", (int *) &iHeight
)) {
420 "ddxProcessArgument - screen - Found ``W D'' arg\n");
422 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
423 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
424 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
425 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
426 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
427 if (i
+ 5 < argc
&& 1 == sscanf(argv
[i
+ 4], "%d", (int *) &iX
)
428 && 1 == sscanf(argv
[i
+ 5], "%d", (int *) &iY
)) {
430 "ddxProcessArgument - screen - Found ``X Y'' arg\n");
432 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
433 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
434 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
439 "ddxProcessArgument - screen - Did not find size arg. "
440 "dwWidth: %d dwHeight: %d\n",
441 (int) g_ScreenInfo
[nScreenNum
].dwWidth
,
442 (int) g_ScreenInfo
[nScreenNum
].dwHeight
);
444 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
447 /* Flag that this screen was explicitly specified by the user */
448 g_ScreenInfo
[nScreenNum
].fExplicitScreen
= TRUE
;
451 * Keep track of the last screen number seen, as parameters seen
452 * before a screen number apply to all screens, whereas parameters
453 * seen after a screen number apply to that screen number only.
455 iLastScreen
= nScreenNum
;
457 return iArgsProcessed
;
461 * Is this parameter attached to a screen or global?
463 * If the parameter is for all screens (appears before
464 * any -screen option), store it in the default screen
467 * If the parameter is for a single screen (appears
468 * after a -screen option), store it in the screen info
472 if (iLastScreen
== -1) {
473 screenInfoPtr
= &defaultScreenInfo
;
476 screenInfoPtr
= &(g_ScreenInfo
[iLastScreen
]);
480 * Look for the '-engine n' argument
482 if (IS_OPTION("-engine")) {
486 /* Display the usage message if the argument is malformed */
492 /* Grab the argument */
493 dwEngine
= atoi(argv
[i
]);
495 /* Count the one bits in the engine argument */
496 c8OnBits
= winCountBits(dwEngine
);
498 /* Argument should only have a single bit on */
504 screenInfoPtr
->dwEnginePreferred
= dwEngine
;
506 /* Indicate that we have processed the argument */
511 * Look for the '-fullscreen' argument
513 if (IS_OPTION("-fullscreen")) {
514 if (!screenInfoPtr
->fMultiMonitorOverride
)
515 screenInfoPtr
->fMultipleMonitors
= FALSE
;
516 screenInfoPtr
->fFullScreen
= TRUE
;
518 /* Indicate that we have processed this argument */
523 * Look for the '-lesspointer' argument
525 if (IS_OPTION("-lesspointer")) {
526 screenInfoPtr
->fLessPointer
= TRUE
;
528 /* Indicate that we have processed this argument */
533 * Look for the '-nodecoration' argument
535 if (IS_OPTION("-nodecoration")) {
536 if (!screenInfoPtr
->fMultiMonitorOverride
)
537 screenInfoPtr
->fMultipleMonitors
= FALSE
;
538 screenInfoPtr
->fDecoration
= FALSE
;
540 /* Indicate that we have processed this argument */
545 * Look for the '-rootless' argument
547 if (IS_OPTION("-rootless")) {
548 if (!screenInfoPtr
->fMultiMonitorOverride
)
549 screenInfoPtr
->fMultipleMonitors
= FALSE
;
550 screenInfoPtr
->fRootless
= TRUE
;
552 /* Indicate that we have processed this argument */
557 * Look for the '-multiwindow' argument
559 if (IS_OPTION("-multiwindow")) {
560 if (!screenInfoPtr
->fMultiMonitorOverride
)
561 screenInfoPtr
->fMultipleMonitors
= TRUE
;
562 screenInfoPtr
->fMultiWindow
= TRUE
;
564 /* Indicate that we have processed this argument */
569 * Look for the '-compositewm' argument
571 if (IS_OPTION("-compositewm")) {
572 screenInfoPtr
->fCompositeWM
= TRUE
;
574 /* Indicate that we have processed this argument */
578 * Look for the '-nocompositewm' argument
580 if (IS_OPTION("-nocompositewm")) {
581 screenInfoPtr
->fCompositeWM
= FALSE
;
583 /* Indicate that we have processed this argument */
588 * Look for the '-compositealpha' argument
590 if (IS_OPTION("-compositealpha")) {
591 g_fCompositeAlpha
= TRUE
;
593 /* Indicate that we have processed this argument */
597 * Look for the '-nocompositealpha' argument
599 if (IS_OPTION("-nocompositealpha")) {
600 g_fCompositeAlpha
= FALSE
;
602 /* Indicate that we have processed this argument */
607 * Look for the '-multiplemonitors' argument
609 if (IS_OPTION("-multiplemonitors")
610 || IS_OPTION("-multimonitors")) {
611 screenInfoPtr
->fMultiMonitorOverride
= TRUE
;
612 screenInfoPtr
->fMultipleMonitors
= TRUE
;
614 /* Indicate that we have processed this argument */
619 * Look for the '-nomultiplemonitors' argument
621 if (IS_OPTION("-nomultiplemonitors")
622 || IS_OPTION("-nomultimonitors")) {
623 screenInfoPtr
->fMultiMonitorOverride
= TRUE
;
624 screenInfoPtr
->fMultipleMonitors
= FALSE
;
626 /* Indicate that we have processed this argument */
631 * Look for the '-scrollbars' argument
633 if (IS_OPTION("-scrollbars")) {
635 screenInfoPtr
->iResizeMode
= resizeWithScrollbars
;
637 /* Indicate that we have processed this argument */
642 * Look for the '-resize' argument
644 if (IS_OPTION("-resize") || IS_OPTION("-noresize") ||
645 (strncmp(argv
[i
], "-resize=", strlen("-resize=")) == 0)) {
648 if (IS_OPTION("-resize"))
649 mode
= resizeWithRandr
;
650 else if (IS_OPTION("-noresize"))
651 mode
= resizeNotAllowed
;
652 else if (strncmp(argv
[i
], "-resize=", strlen("-resize=")) == 0) {
653 char *option
= argv
[i
] + strlen("-resize=");
655 if (strcmp(option
, "randr") == 0)
656 mode
= resizeWithRandr
;
657 else if (strcmp(option
, "scrollbars") == 0)
658 mode
= resizeWithScrollbars
;
659 else if (strcmp(option
, "none") == 0)
660 mode
= resizeNotAllowed
;
662 ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n",
668 ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n",
673 screenInfoPtr
->iResizeMode
= mode
;
675 /* Indicate that we have processed this argument */
680 * Look for the '-clipboard' argument
682 if (IS_OPTION("-clipboard")) {
683 /* Now the default, we still accept the arg for backwards compatibility */
686 /* Indicate that we have processed this argument */
691 * Look for the '-noclipboard' argument
693 if (IS_OPTION("-noclipboard")) {
694 g_fClipboard
= FALSE
;
696 /* Indicate that we have processed this argument */
701 * Look for the '-primary' argument
703 if (IS_OPTION("-primary")) {
704 fPrimarySelection
= TRUE
;
706 /* Indicate that we have processed this argument */
711 * Look for the '-noprimary' argument
713 if (IS_OPTION("-noprimary")) {
714 fPrimarySelection
= FALSE
;
716 /* Indicate that we have processed this argument */
721 * Look for the '-ignoreinput' argument
723 if (IS_OPTION("-ignoreinput")) {
724 screenInfoPtr
->fIgnoreInput
= TRUE
;
726 /* Indicate that we have processed this argument */
731 * Look for the '-emulate3buttons' argument
733 if (IS_OPTION("-emulate3buttons")) {
734 int iArgsProcessed
= 1;
735 int iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
737 /* Grab the optional timeout value */
738 if (i
+ 1 < argc
&& 1 == sscanf(argv
[i
+ 1], "%d", &iE3BTimeout
)) {
739 /* Indicate that we have processed the next argument */
744 * sscanf () won't modify iE3BTimeout if it doesn't find
745 * the specified format; however, I want to be explicit
746 * about setting the default timeout in such cases to
747 * prevent some programs (me) from getting confused.
749 iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
752 screenInfoPtr
->iE3BTimeout
= iE3BTimeout
;
754 /* Indicate that we have processed this argument */
755 return iArgsProcessed
;
759 * Look for the '-noemulate3buttons' argument
761 if (IS_OPTION("-noemulate3buttons")) {
762 screenInfoPtr
->iE3BTimeout
= WIN_E3B_OFF
;
764 /* Indicate that we have processed this argument */
769 * Look for the '-depth n' argument
771 if (IS_OPTION("-depth")) {
774 /* Display the usage message if the argument is malformed */
780 /* Grab the argument */
781 dwBPP
= atoi(argv
[i
]);
783 screenInfoPtr
->dwBPP
= dwBPP
;
785 /* Indicate that we have processed the argument */
790 * Look for the '-refresh n' argument
792 if (IS_OPTION("-refresh")) {
793 DWORD dwRefreshRate
= 0;
795 /* Display the usage message if the argument is malformed */
801 /* Grab the argument */
802 dwRefreshRate
= atoi(argv
[i
]);
804 screenInfoPtr
->dwRefreshRate
= dwRefreshRate
;
806 /* Indicate that we have processed the argument */
811 * Look for the '-clipupdates num_boxes' argument
813 if (IS_OPTION("-clipupdates")) {
814 DWORD dwNumBoxes
= 0;
816 /* Display the usage message if the argument is malformed */
822 /* Grab the argument */
823 dwNumBoxes
= atoi(argv
[i
]);
825 screenInfoPtr
->dwClipUpdatesNBoxes
= dwNumBoxes
;
827 /* Indicate that we have processed the argument */
831 #ifdef XWIN_EMULATEPSEUDO
833 * Look for the '-emulatepseudo' argument
835 if (IS_OPTION("-emulatepseudo")) {
836 screenInfoPtr
->fEmulatePseudo
= TRUE
;
838 /* Indicate that we have processed this argument */
844 * Look for the '-nowinkill' argument
846 if (IS_OPTION("-nowinkill")) {
847 screenInfoPtr
->fUseWinKillKey
= FALSE
;
849 /* Indicate that we have processed this argument */
854 * Look for the '-winkill' argument
856 if (IS_OPTION("-winkill")) {
857 screenInfoPtr
->fUseWinKillKey
= TRUE
;
859 /* Indicate that we have processed this argument */
864 * Look for the '-nounixkill' argument
866 if (IS_OPTION("-nounixkill")) {
867 screenInfoPtr
->fUseUnixKillKey
= FALSE
;
869 /* Indicate that we have processed this argument */
874 * Look for the '-unixkill' argument
876 if (IS_OPTION("-unixkill")) {
877 screenInfoPtr
->fUseUnixKillKey
= TRUE
;
879 /* Indicate that we have processed this argument */
884 * Look for the '-notrayicon' argument
886 if (IS_OPTION("-notrayicon")) {
887 screenInfoPtr
->fNoTrayIcon
= TRUE
;
889 /* Indicate that we have processed this argument */
894 * Look for the '-trayicon' argument
896 if (IS_OPTION("-trayicon")) {
897 screenInfoPtr
->fNoTrayIcon
= FALSE
;
899 /* Indicate that we have processed this argument */
904 * Look for the '-fp' argument
906 if (IS_OPTION("-fp")) {
908 g_cmdline
.fontPath
= argv
[++i
];
909 return 0; /* Let DIX parse this again */
913 * Look for the '-query' argument
915 if (IS_OPTION("-query")) {
917 g_fXdmcpEnabled
= TRUE
;
918 g_pszQueryHost
= argv
[++i
];
919 return 0; /* Let DIX parse this again */
923 * Look for the '-auth' argument
925 if (IS_OPTION("-auth")) {
926 g_fAuthEnabled
= TRUE
;
927 return 0; /* Let DIX parse this again */
931 * Look for the '-indirect' or '-broadcast' arguments
933 if (IS_OPTION("-indirect")
934 || IS_OPTION("-broadcast")) {
935 g_fXdmcpEnabled
= TRUE
;
936 return 0; /* Let DIX parse this again */
940 * Look for the '-config' argument
942 if (IS_OPTION("-config")
943 || IS_OPTION("-xf86config")) {
945 #ifdef XWIN_XF86CONFIG
946 g_cmdline
.configFile
= argv
[++i
];
948 winMessageBoxF("The %s option is not supported in this "
950 "Ignoring this option and continuing.\n",
951 MB_ICONINFORMATION
, argv
[i
]);
957 * Look for the '-configdir' argument
959 if (IS_OPTION("-configdir")) {
961 #ifdef XWIN_XF86CONFIG
962 g_cmdline
.configDir
= argv
[++i
];
964 winMessageBoxF("The %s option is not supported in this "
966 "Ignoring this option and continuing.\n",
967 MB_ICONINFORMATION
, argv
[i
]);
973 * Look for the '-keyboard' argument
975 if (IS_OPTION("-keyboard")) {
976 #ifdef XWIN_XF86CONFIG
978 g_cmdline
.keyboard
= argv
[++i
];
980 winMessageBoxF("The -keyboard option is not supported in this "
982 "Ignoring this option and continuing.\n",
989 * Look for the '-logfile' argument
991 if (IS_OPTION("-logfile")) {
993 g_pszLogFile
= argv
[++i
];
994 #ifdef RELOCATE_PROJECTROOT
995 g_fLogFileChanged
= TRUE
;
1001 * Look for the '-logverbose' argument
1003 if (IS_OPTION("-logverbose")) {
1005 g_iLogVerbose
= atoi(argv
[++i
]);
1009 if (IS_OPTION("-xkbrules")) {
1011 g_cmdline
.xkbRules
= argv
[++i
];
1014 if (IS_OPTION("-xkbmodel")) {
1016 g_cmdline
.xkbModel
= argv
[++i
];
1019 if (IS_OPTION("-xkblayout")) {
1021 g_cmdline
.xkbLayout
= argv
[++i
];
1024 if (IS_OPTION("-xkbvariant")) {
1026 g_cmdline
.xkbVariant
= argv
[++i
];
1029 if (IS_OPTION("-xkboptions")) {
1031 g_cmdline
.xkbOptions
= argv
[++i
];
1035 if (IS_OPTION("-keyhook")) {
1036 g_fKeyboardHookLL
= TRUE
;
1040 if (IS_OPTION("-nokeyhook")) {
1041 g_fKeyboardHookLL
= FALSE
;
1045 if (IS_OPTION("-swcursor")) {
1046 g_fSoftwareCursor
= TRUE
;
1050 if (IS_OPTION("-wgl")) {
1055 if (IS_OPTION("-nowgl")) {
1056 g_fNativeGl
= FALSE
;
1060 if (IS_OPTION("-hostintitle")) {
1061 g_fHostInTitle
= TRUE
;
1065 if (IS_OPTION("-nohostintitle")) {
1066 g_fHostInTitle
= FALSE
;
1070 if (IS_OPTION("-icon")) {
1073 iconspec
= argv
[++i
];
1074 screenInfoPtr
->hIcon
= LoadImageComma(iconspec
, NULL
,
1075 GetSystemMetrics(SM_CXICON
),
1076 GetSystemMetrics(SM_CYICON
),
1078 screenInfoPtr
->hIconSm
= LoadImageComma(iconspec
, NULL
,
1079 GetSystemMetrics(SM_CXSMICON
),
1080 GetSystemMetrics(SM_CYSMICON
),
1082 if ((screenInfoPtr
->hIcon
== NULL
) ||
1083 (screenInfoPtr
->hIconSm
== NULL
)) {
1084 ErrorF("ddxProcessArgument - icon - Invalid icon specification %s\n",
1089 /* Indicate that we have processed the argument */
1097 * winLogCommandLine - Write entire command line to the log file
1101 winLogCommandLine(int argc
, char *argv
[])
1107 #define CHARS_PER_LINE 60
1109 /* Bail if command line has already been logged */
1110 if (g_pszCommandLine
)
1113 /* Count how much memory is needed for concatenated command line */
1114 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
)
1116 /* Adds two characters for lines that overflow */
1117 if ((strlen(argv
[i
]) < CHARS_PER_LINE
1118 && iCurrLen
+ strlen(argv
[i
]) > CHARS_PER_LINE
)
1119 || strlen(argv
[i
]) > CHARS_PER_LINE
) {
1124 /* Add space for item and trailing space */
1125 iSize
+= strlen(argv
[i
]) + 1;
1127 /* Update current line length */
1128 iCurrLen
+= strlen(argv
[i
]);
1131 /* Allocate memory for concatenated command line */
1132 g_pszCommandLine
= malloc(iSize
+ 1);
1133 if (!g_pszCommandLine
)
1134 FatalError("winLogCommandLine - Could not allocate memory for "
1135 "command line string. Exiting.\n");
1137 /* Set first character to concatenated command line to null */
1138 g_pszCommandLine
[0] = '\0';
1140 /* Loop through all args */
1141 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
) {
1142 /* Add a character for lines that overflow */
1143 if ((strlen(argv
[i
]) < CHARS_PER_LINE
1144 && iCurrLen
+ strlen(argv
[i
]) > CHARS_PER_LINE
)
1145 || strlen(argv
[i
]) > CHARS_PER_LINE
) {
1148 /* Add line break if it fits */
1149 strncat(g_pszCommandLine
, "\n ", iSize
- strlen(g_pszCommandLine
));
1152 strncat(g_pszCommandLine
, argv
[i
], iSize
- strlen(g_pszCommandLine
));
1153 strncat(g_pszCommandLine
, " ", iSize
- strlen(g_pszCommandLine
));
1155 /* Save new line length */
1156 iCurrLen
+= strlen(argv
[i
]);
1159 ErrorF("XWin was started with the following command line:\n\n"
1160 "%s\n\n", g_pszCommandLine
);
1164 * winLogVersionInfo - Log version information
1168 winLogVersionInfo(void)
1170 static Bool s_fBeenHere
= FALSE
;
1176 ErrorF("Welcome to the XWin X Server\n");
1177 ErrorF("Vendor: %s\n", XVENDORNAME
);
1178 ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR
,
1179 XORG_VERSION_MINOR
, XORG_VERSION_PATCH
, XORG_VERSION_SNAP
);
1180 #ifdef HAVE_SYS_UTSNAME_H
1182 struct utsname name
;
1184 if (uname(&name
) >= 0) {
1185 ErrorF("OS: %s %s %s %s %s\n", name
.sysname
, name
.nodename
,
1186 name
.release
, name
.version
, name
.machine
);
1191 if (strlen(BUILDERSTRING
))
1192 ErrorF("%s\n", BUILDERSTRING
);
1193 ErrorF("Contact: %s\n", BUILDERADDR
);