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 #include <../xfree86/common/xorgVersion.h>
36 #include "winconfig.h"
38 #include "winmonitors.h"
41 * References to external symbols
45 extern Bool g_fUnicodeClipboard
;
46 extern Bool g_fClipboard
;
54 winLogCommandLine(int argc
, char *argv
[]);
57 winLogVersionInfo(void);
60 * Process arguments on the command line
63 static int iLastScreen
= -1;
64 static winScreenInfo defaultScreenInfo
;
67 winInitializeScreenDefaults(void)
69 DWORD dwWidth
, dwHeight
;
70 static Bool fInitializedScreenDefaults
= FALSE
;
72 /* Bail out early if default screen has already been initialized */
73 if (fInitializedScreenDefaults
)
76 /* Zero the memory used for storing the screen info */
77 memset(&defaultScreenInfo
, 0, sizeof(winScreenInfo
));
79 /* Get default width and height */
81 * NOTE: These defaults will cause the window to cover only
82 * the primary monitor in the case that we have multiple monitors.
84 dwWidth
= GetSystemMetrics(SM_CXSCREEN
);
85 dwHeight
= GetSystemMetrics(SM_CYSCREEN
);
88 "winInitializeScreenDefaults - primary monitor w %d h %d\n",
89 (int) dwWidth
, (int) dwHeight
);
91 /* Set a default DPI, if no '-dpi' option was used */
92 if (monitorResolution
== 0) {
93 HDC hdc
= GetDC(NULL
);
96 int dpiX
= GetDeviceCaps(hdc
, LOGPIXELSX
);
97 int dpiY
= GetDeviceCaps(hdc
, LOGPIXELSY
);
100 "winInitializeScreenDefaults - native DPI x %d y %d\n",
103 monitorResolution
= dpiY
;
104 ReleaseDC(NULL
, hdc
);
108 "winInitializeScreenDefaults - Failed to retrieve native DPI, falling back to default of %d DPI\n",
110 monitorResolution
= WIN_DEFAULT_DPI
;
114 defaultScreenInfo
.iMonitor
= 1;
115 defaultScreenInfo
.hMonitor
= MonitorFromWindow(NULL
, MONITOR_DEFAULTTOPRIMARY
);
116 defaultScreenInfo
.dwWidth
= dwWidth
;
117 defaultScreenInfo
.dwHeight
= dwHeight
;
118 defaultScreenInfo
.dwUserWidth
= dwWidth
;
119 defaultScreenInfo
.dwUserHeight
= dwHeight
;
120 defaultScreenInfo
.fUserGaveHeightAndWidth
=
121 WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH
;
122 defaultScreenInfo
.fUserGavePosition
= FALSE
;
123 defaultScreenInfo
.dwBPP
= WIN_DEFAULT_BPP
;
124 defaultScreenInfo
.dwClipUpdatesNBoxes
= WIN_DEFAULT_CLIP_UPDATES_NBOXES
;
125 #ifdef XWIN_EMULATEPSEUDO
126 defaultScreenInfo
.fEmulatePseudo
= WIN_DEFAULT_EMULATE_PSEUDO
;
128 defaultScreenInfo
.dwRefreshRate
= WIN_DEFAULT_REFRESH
;
129 defaultScreenInfo
.pfb
= NULL
;
130 defaultScreenInfo
.fFullScreen
= FALSE
;
131 defaultScreenInfo
.fDecoration
= TRUE
;
132 #ifdef XWIN_MULTIWINDOWEXTWM
133 defaultScreenInfo
.fMWExtWM
= FALSE
;
134 defaultScreenInfo
.fInternalWM
= FALSE
;
136 defaultScreenInfo
.fRootless
= FALSE
;
137 #ifdef XWIN_MULTIWINDOW
138 defaultScreenInfo
.fMultiWindow
= FALSE
;
140 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
141 defaultScreenInfo
.fMultiMonitorOverride
= FALSE
;
143 defaultScreenInfo
.fMultipleMonitors
= FALSE
;
144 defaultScreenInfo
.fLessPointer
= FALSE
;
145 defaultScreenInfo
.iResizeMode
= resizeWithRandr
;
146 defaultScreenInfo
.fNoTrayIcon
= FALSE
;
147 defaultScreenInfo
.iE3BTimeout
= WIN_E3B_DEFAULT
;
148 defaultScreenInfo
.fUseWinKillKey
= WIN_DEFAULT_WIN_KILL
;
149 defaultScreenInfo
.fUseUnixKillKey
= WIN_DEFAULT_UNIX_KILL
;
150 defaultScreenInfo
.fIgnoreInput
= FALSE
;
151 defaultScreenInfo
.fExplicitScreen
= FALSE
;
153 /* Note that the default screen has been initialized */
154 fInitializedScreenDefaults
= TRUE
;
158 winInitializeScreen(int i
)
160 winErrorFVerb(3, "winInitializeScreen - %d\n", i
);
162 /* Initialize default screen values, if needed */
163 winInitializeScreenDefaults();
165 /* Copy the default screen info */
166 g_ScreenInfo
[i
] = defaultScreenInfo
;
168 /* Set the screen number */
169 g_ScreenInfo
[i
].dwScreen
= i
;
173 winInitializeScreens(int maxscreens
)
177 winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens
);
179 if (maxscreens
> g_iNumScreens
) {
180 /* Reallocate the memory for DDX-specific screen info */
182 realloc(g_ScreenInfo
, maxscreens
* sizeof(winScreenInfo
));
184 /* Set default values for any new screens */
185 for (i
= g_iNumScreens
; i
< maxscreens
; i
++)
186 winInitializeScreen(i
);
188 /* Keep a count of the number of screens */
189 g_iNumScreens
= maxscreens
;
193 /* See Porting Layer Definition - p. 57 */
196 * argv: pointer to an array of null-terminated strings, one for
197 * each token in the X Server command line; the first token
198 * is 'XWin.exe', or similar.
199 * argc: a count of the number of tokens stored in argv.
200 * i: a zero-based index into argv indicating the current token being
204 * return: return the number of tokens processed correctly.
207 * When looking for n tokens, check that i + n is less than argc. Or,
208 * you may check if i is greater than or equal to argc, in which case
209 * you should display the UseMsg () and return 0.
212 /* Check if enough arguments are given for the option */
213 #define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
215 /* Compare the current option with the string. */
216 #define IS_OPTION(name) (strcmp (argv[i], name) == 0)
219 ddxProcessArgument(int argc
, char *argv
[], int i
)
221 static Bool s_fBeenHere
= FALSE
;
222 winScreenInfo
*screenInfoPtr
= NULL
;
224 /* Initialize once */
228 * This initialises our hook into VErrorF () for catching log messages
229 * that are generated before OsInit () is called.
231 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(2, "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 - Querying monitors failed\n");
326 else if (data
.bMonitorSpecifiedExists
== TRUE
) {
328 "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
331 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
332 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
333 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
334 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
335 g_ScreenInfo
[nScreenNum
].dwWidth
= data
.monitorWidth
;
336 g_ScreenInfo
[nScreenNum
].dwHeight
= data
.monitorHeight
;
337 g_ScreenInfo
[nScreenNum
].dwUserWidth
= data
.monitorWidth
;
338 g_ScreenInfo
[nScreenNum
].dwUserHeight
= data
.monitorHeight
;
339 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
340 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
343 /* monitor does not exist, error out */
345 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
353 /* Look for 'WxD' or 'W D' */
354 else if (i
+ 2 < argc
355 && 2 == sscanf(argv
[i
+ 2], "%dx%d",
356 (int *) &iWidth
, (int *) &iHeight
)) {
358 "ddxProcessArgument - screen - Found ``WxD'' arg\n");
360 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
361 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
362 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
363 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
364 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
365 /* Look for WxD+X+Y */
366 if (2 == sscanf(argv
[i
+ 2], "%*dx%*d+%d+%d",
367 (int *) &iX
, (int *) &iY
)) {
369 "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
370 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
371 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
372 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
374 /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
375 if (1 == sscanf(argv
[i
+ 2], "%*dx%*d+%*d+%*d@%d",
376 (int *) &iMonitor
)) {
377 struct GetMonitorInfoData data
;
379 if (!QueryMonitor(iMonitor
, &data
)) {
381 ("ddxProcessArgument - screen - Querying monitors failed\n");
383 else if (data
.bMonitorSpecifiedExists
== TRUE
) {
384 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
385 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
386 g_ScreenInfo
[nScreenNum
].dwInitialX
+=
388 g_ScreenInfo
[nScreenNum
].dwInitialY
+=
392 /* monitor does not exist, error out */
394 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
404 /* look for WxD@m where m is monitor number */
405 else if (1 == sscanf(argv
[i
+ 2], "%*dx%*d@%d", (int *) &iMonitor
)) {
406 struct GetMonitorInfoData data
;
408 if (!QueryMonitor(iMonitor
, &data
)) {
410 ("ddxProcessArgument - screen - Querying monitors failed\n");
412 else if (data
.bMonitorSpecifiedExists
== TRUE
) {
414 "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
416 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
417 g_ScreenInfo
[nScreenNum
].iMonitor
= iMonitor
;
418 g_ScreenInfo
[nScreenNum
].hMonitor
= data
.monitorHandle
;
419 g_ScreenInfo
[nScreenNum
].dwInitialX
= data
.monitorOffsetX
;
420 g_ScreenInfo
[nScreenNum
].dwInitialY
= data
.monitorOffsetY
;
423 /* monitor does not exist, error out */
425 ("ddxProcessArgument - screen - Invalid monitor number %d\n",
434 else if (i
+ 3 < argc
&& 1 == sscanf(argv
[i
+ 2], "%d", (int *) &iWidth
)
435 && 1 == sscanf(argv
[i
+ 3], "%d", (int *) &iHeight
)) {
437 "ddxProcessArgument - screen - Found ``W D'' arg\n");
439 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= TRUE
;
440 g_ScreenInfo
[nScreenNum
].dwWidth
= iWidth
;
441 g_ScreenInfo
[nScreenNum
].dwHeight
= iHeight
;
442 g_ScreenInfo
[nScreenNum
].dwUserWidth
= iWidth
;
443 g_ScreenInfo
[nScreenNum
].dwUserHeight
= iHeight
;
444 if (i
+ 5 < argc
&& 1 == sscanf(argv
[i
+ 4], "%d", (int *) &iX
)
445 && 1 == sscanf(argv
[i
+ 5], "%d", (int *) &iY
)) {
447 "ddxProcessArgument - screen - Found ``X Y'' arg\n");
449 g_ScreenInfo
[nScreenNum
].fUserGavePosition
= TRUE
;
450 g_ScreenInfo
[nScreenNum
].dwInitialX
= iX
;
451 g_ScreenInfo
[nScreenNum
].dwInitialY
= iY
;
456 "ddxProcessArgument - screen - Did not find size arg. "
457 "dwWidth: %d dwHeight: %d\n",
458 (int) g_ScreenInfo
[nScreenNum
].dwWidth
,
459 (int) g_ScreenInfo
[nScreenNum
].dwHeight
);
461 g_ScreenInfo
[nScreenNum
].fUserGaveHeightAndWidth
= FALSE
;
464 /* Flag that this screen was explicity specified by the user */
465 g_ScreenInfo
[nScreenNum
].fExplicitScreen
= TRUE
;
468 * Keep track of the last screen number seen, as parameters seen
469 * before a screen number apply to all screens, whereas parameters
470 * seen after a screen number apply to that screen number only.
472 iLastScreen
= nScreenNum
;
474 return iArgsProcessed
;
478 * Is this parameter attached to a screen or global?
480 * If the parameter is for all screens (appears before
481 * any -screen option), store it in the default screen
484 * If the parameter is for a single screen (appears
485 * after a -screen option), store it in the screen info
489 if (iLastScreen
== -1) {
490 screenInfoPtr
= &defaultScreenInfo
;
493 screenInfoPtr
= &(g_ScreenInfo
[iLastScreen
]);
497 * Look for the '-engine n' argument
499 if (IS_OPTION("-engine")) {
503 /* Display the usage message if the argument is malformed */
509 /* Grab the argument */
510 dwEngine
= atoi(argv
[i
]);
512 /* Count the one bits in the engine argument */
513 c8OnBits
= winCountBits(dwEngine
);
515 /* Argument should only have a single bit on */
521 screenInfoPtr
->dwEnginePreferred
= dwEngine
;
523 /* Indicate that we have processed the argument */
528 * Look for the '-fullscreen' argument
530 if (IS_OPTION("-fullscreen")) {
531 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
532 if (!screenInfoPtr
->fMultiMonitorOverride
)
533 screenInfoPtr
->fMultipleMonitors
= FALSE
;
535 screenInfoPtr
->fFullScreen
= TRUE
;
537 /* Indicate that we have processed this argument */
542 * Look for the '-lesspointer' argument
544 if (IS_OPTION("-lesspointer")) {
545 screenInfoPtr
->fLessPointer
= TRUE
;
547 /* Indicate that we have processed this argument */
552 * Look for the '-nodecoration' argument
554 if (IS_OPTION("-nodecoration")) {
555 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
556 if (!screenInfoPtr
->fMultiMonitorOverride
)
557 screenInfoPtr
->fMultipleMonitors
= FALSE
;
559 screenInfoPtr
->fDecoration
= FALSE
;
561 /* Indicate that we have processed this argument */
565 #ifdef XWIN_MULTIWINDOWEXTWM
567 * Look for the '-mwextwm' argument
569 if (IS_OPTION("-mwextwm")) {
570 if (!screenInfoPtr
->fMultiMonitorOverride
)
571 screenInfoPtr
->fMultipleMonitors
= TRUE
;
572 screenInfoPtr
->fMWExtWM
= TRUE
;
574 /* Indicate that we have processed this argument */
578 * Look for the '-internalwm' argument
580 if (IS_OPTION("-internalwm")) {
581 if (!screenInfoPtr
->fMultiMonitorOverride
)
582 screenInfoPtr
->fMultipleMonitors
= TRUE
;
583 screenInfoPtr
->fMWExtWM
= TRUE
;
584 screenInfoPtr
->fInternalWM
= TRUE
;
586 /* Indicate that we have processed this argument */
592 * Look for the '-rootless' argument
594 if (IS_OPTION("-rootless")) {
595 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
596 if (!screenInfoPtr
->fMultiMonitorOverride
)
597 screenInfoPtr
->fMultipleMonitors
= FALSE
;
599 screenInfoPtr
->fRootless
= TRUE
;
601 /* Indicate that we have processed this argument */
605 #ifdef XWIN_MULTIWINDOW
607 * Look for the '-multiwindow' argument
609 if (IS_OPTION("-multiwindow")) {
610 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
611 if (!screenInfoPtr
->fMultiMonitorOverride
)
612 screenInfoPtr
->fMultipleMonitors
= TRUE
;
614 screenInfoPtr
->fMultiWindow
= TRUE
;
616 /* Indicate that we have processed this argument */
622 * Look for the '-multiplemonitors' argument
624 if (IS_OPTION("-multiplemonitors")
625 || IS_OPTION("-multimonitors")) {
626 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
627 screenInfoPtr
->fMultiMonitorOverride
= TRUE
;
629 screenInfoPtr
->fMultipleMonitors
= TRUE
;
631 /* Indicate that we have processed this argument */
636 * Look for the '-nomultiplemonitors' argument
638 if (IS_OPTION("-nomultiplemonitors")
639 || IS_OPTION("-nomultimonitors")) {
640 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
641 screenInfoPtr
->fMultiMonitorOverride
= TRUE
;
643 screenInfoPtr
->fMultipleMonitors
= FALSE
;
645 /* Indicate that we have processed this argument */
650 * Look for the '-scrollbars' argument
652 if (IS_OPTION("-scrollbars")) {
654 screenInfoPtr
->iResizeMode
= resizeWithScrollbars
;
656 /* Indicate that we have processed this argument */
661 * Look for the '-resize' argument
663 if (IS_OPTION("-resize") || IS_OPTION("-noresize") ||
664 (strncmp(argv
[i
], "-resize=", strlen("-resize=")) == 0)) {
667 if (IS_OPTION("-resize"))
668 mode
= resizeWithRandr
;
669 else if (IS_OPTION("-noresize"))
671 else if (strncmp(argv
[i
], "-resize=", strlen("-resize=")) == 0) {
672 char *option
= argv
[i
] + strlen("-resize=");
674 if (strcmp(option
, "randr") == 0)
675 mode
= resizeWithRandr
;
676 else if (strcmp(option
, "scrollbars") == 0)
677 mode
= resizeWithScrollbars
;
678 else if (strcmp(option
, "none") == 0)
681 ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n",
687 ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n",
692 screenInfoPtr
->iResizeMode
= mode
;
694 /* Indicate that we have processed this argument */
698 #ifdef XWIN_CLIPBOARD
700 * Look for the '-clipboard' argument
702 if (IS_OPTION("-clipboard")) {
703 /* Now the default, we still accept the arg for backwards compatibility */
706 /* Indicate that we have processed this argument */
711 * Look for the '-noclipboard' argument
713 if (IS_OPTION("-noclipboard")) {
714 g_fClipboard
= FALSE
;
716 /* Indicate that we have processed this argument */
722 * Look for the '-ignoreinput' argument
724 if (IS_OPTION("-ignoreinput")) {
725 screenInfoPtr
->fIgnoreInput
= TRUE
;
727 /* Indicate that we have processed this argument */
732 * Look for the '-emulate3buttons' argument
734 if (IS_OPTION("-emulate3buttons")) {
735 int iArgsProcessed
= 1;
736 int iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
738 /* Grab the optional timeout value */
739 if (i
+ 1 < argc
&& 1 == sscanf(argv
[i
+ 1], "%d", &iE3BTimeout
)) {
740 /* Indicate that we have processed the next argument */
745 * sscanf () won't modify iE3BTimeout if it doesn't find
746 * the specified format; however, I want to be explicit
747 * about setting the default timeout in such cases to
748 * prevent some programs (me) from getting confused.
750 iE3BTimeout
= WIN_DEFAULT_E3B_TIME
;
753 screenInfoPtr
->iE3BTimeout
= iE3BTimeout
;
755 /* Indicate that we have processed this argument */
756 return iArgsProcessed
;
760 * Look for the '-noemulate3buttons' argument
762 if (IS_OPTION("-noemulate3buttons")) {
763 screenInfoPtr
->iE3BTimeout
= WIN_E3B_OFF
;
765 /* Indicate that we have processed this argument */
770 * Look for the '-depth n' argument
772 if (IS_OPTION("-depth")) {
775 /* Display the usage message if the argument is malformed */
781 /* Grab the argument */
782 dwBPP
= atoi(argv
[i
]);
784 screenInfoPtr
->dwBPP
= dwBPP
;
786 /* Indicate that we have processed the argument */
791 * Look for the '-refresh n' argument
793 if (IS_OPTION("-refresh")) {
794 DWORD dwRefreshRate
= 0;
796 /* Display the usage message if the argument is malformed */
802 /* Grab the argument */
803 dwRefreshRate
= atoi(argv
[i
]);
805 screenInfoPtr
->dwRefreshRate
= dwRefreshRate
;
807 /* Indicate that we have processed the argument */
812 * Look for the '-clipupdates num_boxes' argument
814 if (IS_OPTION("-clipupdates")) {
815 DWORD dwNumBoxes
= 0;
817 /* Display the usage message if the argument is malformed */
823 /* Grab the argument */
824 dwNumBoxes
= atoi(argv
[i
]);
826 screenInfoPtr
->dwClipUpdatesNBoxes
= dwNumBoxes
;
828 /* Indicate that we have processed the argument */
832 #ifdef XWIN_EMULATEPSEUDO
834 * Look for the '-emulatepseudo' argument
836 if (IS_OPTION("-emulatepseudo")) {
837 screenInfoPtr
->fEmulatePseudo
= TRUE
;
839 /* Indicate that we have processed this argument */
845 * Look for the '-nowinkill' argument
847 if (IS_OPTION("-nowinkill")) {
848 screenInfoPtr
->fUseWinKillKey
= FALSE
;
850 /* Indicate that we have processed this argument */
855 * Look for the '-winkill' argument
857 if (IS_OPTION("-winkill")) {
858 screenInfoPtr
->fUseWinKillKey
= TRUE
;
860 /* Indicate that we have processed this argument */
865 * Look for the '-nounixkill' argument
867 if (IS_OPTION("-nounixkill")) {
868 screenInfoPtr
->fUseUnixKillKey
= FALSE
;
870 /* Indicate that we have processed this argument */
875 * Look for the '-unixkill' argument
877 if (IS_OPTION("-unixkill")) {
878 screenInfoPtr
->fUseUnixKillKey
= TRUE
;
880 /* Indicate that we have processed this argument */
885 * Look for the '-notrayicon' argument
887 if (IS_OPTION("-notrayicon")) {
888 screenInfoPtr
->fNoTrayIcon
= TRUE
;
890 /* Indicate that we have processed this argument */
895 * Look for the '-trayicon' argument
897 if (IS_OPTION("-trayicon")) {
898 screenInfoPtr
->fNoTrayIcon
= FALSE
;
900 /* Indicate that we have processed this argument */
905 * Look for the '-fp' argument
907 if (IS_OPTION("-fp")) {
909 g_cmdline
.fontPath
= argv
[++i
];
910 return 0; /* Let DIX parse this again */
914 * Look for the '-query' argument
916 if (IS_OPTION("-query")) {
918 g_fXdmcpEnabled
= TRUE
;
919 g_pszQueryHost
= argv
[++i
];
920 return 0; /* Let DIX parse this again */
924 * Look for the '-auth' argument
926 if (IS_OPTION("-auth")) {
927 g_fAuthEnabled
= TRUE
;
928 return 0; /* Let DIX parse this again */
932 * Look for the '-indirect' or '-broadcast' arguments
934 if (IS_OPTION("-indirect")
935 || IS_OPTION("-broadcast")) {
936 g_fXdmcpEnabled
= TRUE
;
937 return 0; /* Let DIX parse this again */
941 * Look for the '-config' argument
943 if (IS_OPTION("-config")
944 || IS_OPTION("-xf86config")) {
946 #ifdef XWIN_XF86CONFIG
947 g_cmdline
.configFile
= argv
[++i
];
949 winMessageBoxF("The %s option is not supported in this "
951 "Ignoring this option and continuing.\n",
952 MB_ICONINFORMATION
, argv
[i
]);
958 * Look for the '-configdir' argument
960 if (IS_OPTION("-configdir")) {
962 #ifdef XWIN_XF86CONFIG
963 g_cmdline
.configDir
= argv
[++i
];
965 winMessageBoxF("The %s option is not supported in this "
967 "Ignoring this option and continuing.\n",
968 MB_ICONINFORMATION
, argv
[i
]);
974 * Look for the '-keyboard' argument
976 if (IS_OPTION("-keyboard")) {
977 #ifdef XWIN_XF86CONFIG
979 g_cmdline
.keyboard
= argv
[++i
];
981 winMessageBoxF("The -keyboard option is not supported in this "
983 "Ignoring this option and continuing.\n",
990 * Look for the '-logfile' argument
992 if (IS_OPTION("-logfile")) {
994 g_pszLogFile
= argv
[++i
];
995 #ifdef RELOCATE_PROJECTROOT
996 g_fLogFileChanged
= TRUE
;
1002 * Look for the '-logverbose' argument
1004 if (IS_OPTION("-logverbose")) {
1006 g_iLogVerbose
= atoi(argv
[++i
]);
1010 #ifdef XWIN_CLIPBOARD
1012 * Look for the '-nounicodeclipboard' argument
1014 if (IS_OPTION("-nounicodeclipboard")) {
1015 g_fUnicodeClipboard
= FALSE
;
1016 /* Indicate that we have processed the argument */
1021 if (IS_OPTION("-xkbrules")) {
1023 g_cmdline
.xkbRules
= argv
[++i
];
1026 if (IS_OPTION("-xkbmodel")) {
1028 g_cmdline
.xkbModel
= argv
[++i
];
1031 if (IS_OPTION("-xkblayout")) {
1033 g_cmdline
.xkbLayout
= argv
[++i
];
1036 if (IS_OPTION("-xkbvariant")) {
1038 g_cmdline
.xkbVariant
= argv
[++i
];
1041 if (IS_OPTION("-xkboptions")) {
1043 g_cmdline
.xkbOptions
= argv
[++i
];
1047 if (IS_OPTION("-keyhook")) {
1048 g_fKeyboardHookLL
= TRUE
;
1052 if (IS_OPTION("-nokeyhook")) {
1053 g_fKeyboardHookLL
= FALSE
;
1057 if (IS_OPTION("-swcursor")) {
1058 g_fSoftwareCursor
= TRUE
;
1062 if (IS_OPTION("-silent-dup-error")) {
1063 g_fSilentDupError
= TRUE
;
1067 if (IS_OPTION("-wgl")) {
1072 if (IS_OPTION("-nowgl")) {
1073 g_fNativeGl
= FALSE
;
1081 * winLogCommandLine - Write entire command line to the log file
1085 winLogCommandLine(int argc
, char *argv
[])
1091 #define CHARS_PER_LINE 60
1093 /* Bail if command line has already been logged */
1094 if (g_pszCommandLine
)
1097 /* Count how much memory is needed for concatenated command line */
1098 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
)
1100 /* Adds two characters for lines that overflow */
1101 if ((strlen(argv
[i
]) < CHARS_PER_LINE
1102 && iCurrLen
+ strlen(argv
[i
]) > CHARS_PER_LINE
)
1103 || strlen(argv
[i
]) > CHARS_PER_LINE
) {
1108 /* Add space for item and trailing space */
1109 iSize
+= strlen(argv
[i
]) + 1;
1111 /* Update current line length */
1112 iCurrLen
+= strlen(argv
[i
]);
1115 /* Allocate memory for concatenated command line */
1116 g_pszCommandLine
= malloc(iSize
+ 1);
1117 if (!g_pszCommandLine
)
1118 FatalError("winLogCommandLine - Could not allocate memory for "
1119 "command line string. Exiting.\n");
1121 /* Set first character to concatenated command line to null */
1122 g_pszCommandLine
[0] = '\0';
1124 /* Loop through all args */
1125 for (i
= 0, iCurrLen
= 0; i
< argc
; ++i
) {
1126 /* Add a character for lines that overflow */
1127 if ((strlen(argv
[i
]) < CHARS_PER_LINE
1128 && iCurrLen
+ strlen(argv
[i
]) > CHARS_PER_LINE
)
1129 || strlen(argv
[i
]) > CHARS_PER_LINE
) {
1132 /* Add line break if it fits */
1133 strncat(g_pszCommandLine
, "\n ", iSize
- strlen(g_pszCommandLine
));
1136 strncat(g_pszCommandLine
, argv
[i
], iSize
- strlen(g_pszCommandLine
));
1137 strncat(g_pszCommandLine
, " ", iSize
- strlen(g_pszCommandLine
));
1139 /* Save new line length */
1140 iCurrLen
+= strlen(argv
[i
]);
1143 ErrorF("XWin was started with the following command line:\n\n"
1144 "%s\n\n", g_pszCommandLine
);
1148 * winLogVersionInfo - Log version information
1152 winLogVersionInfo(void)
1154 static Bool s_fBeenHere
= FALSE
;
1160 ErrorF("Welcome to the XWin X Server\n");
1161 ErrorF("Vendor: %s\n", XVENDORNAME
);
1162 ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR
,
1163 XORG_VERSION_MINOR
, XORG_VERSION_PATCH
, XORG_VERSION_SNAP
);
1164 if (strlen(BUILDERSTRING
))
1165 ErrorF("%s\n", BUILDERSTRING
);
1166 ErrorF("Contact: %s\n", BUILDERADDR
);